From 1dfdd22f4362fc6e6398a146e56bad4976b44df6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Wed, 8 Jan 2014 10:54:16 +0100 Subject: [PATCH] Finish the refactoring for Json. --- JSON_renderer.php | 18 +++++++++++++++++- base.php | 17 ----------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/JSON_renderer.php b/JSON_renderer.php index 43b0ded..fc2ccd1 100644 --- a/JSON_renderer.php +++ b/JSON_renderer.php @@ -101,6 +101,22 @@ class JSONRenderer return array ( "title" => $entry->title, "content" => $entry->content, "navlink" => $entry->getNavLink () ); } + public static function getContentArrayTypeahead ($page) { + $out = array (); + foreach ($page->entryArray as $entry) { + if ($entry instanceof EntryBook) { + array_push ($out, array ("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->book->getDetailUrl ())); + } else { + if (empty ($entry->className) xor Base::noDatabaseSelected ()) { + array_push ($out, array ("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->getNavLink ())); + } else { + array_push ($out, array ("class" => $entry->className, "title" => $entry->content, "navlink" => $entry->getNavLink ())); + } + } + } + return $out; + } + public static function getJson ($complete = false) { global $config; $page = getURLParam ("page", Base::PAGE_INDEX); @@ -114,7 +130,7 @@ class JSONRenderer $currentPage->InitializeContent (); if ($search) { - return $currentPage->getContentArrayTypeahead (); + return self::getContentArrayTypeahead ($currentPage); } $out = array ( "title" => $currentPage->title); diff --git a/base.php b/base.php index 9f74588..537839b 100644 --- a/base.php +++ b/base.php @@ -551,23 +551,6 @@ class Page if (get_class ($this->entryArray [0]) == "EntryBook") return true; return false; } - - public function getContentArrayTypeahead () { - $out = array (); - foreach ($this->entryArray as $entry) { - if ($entry instanceof EntryBook) { - array_push ($out, array ("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->book->getDetailUrl ())); - } else { - if (empty ($entry->className) xor Base::noDatabaseSelected ()) { - array_push ($out, array ("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->getNavLink ())); - } else { - array_push ($out, array ("class" => $entry->className, "title" => $entry->content, "navlink" => $entry->getNavLink ())); - } - } - } - return $out; - } - } class PageAllAuthors extends Page