コード例 #1
0
ファイル: Base.php プロジェクト: jbzdak/wikidot
 /**
  * External representation of a page object
  *  
  * @param DB_Page $page
  * @param string $hint
  * @return array
  */
 protected function _reprPage($page, $hint)
 {
     if ($hint == "meta") {
         $category = $page->getCategoryName();
         $name = preg_replace("|^{$category}:|", "", $page->getUnixName());
         $tags = $page->getTagsAsArray();
         $parent_page_name = null;
         if ($parent_page_id = $page->getParentPageId()) {
             if ($parent_page = DB_PagePeer::instance()->selectByPrimaryKey($parent_page_id)) {
                 $parent_page_name = $parent_page->getUnixName();
             }
         }
         $user_created_name = null;
         if ($user_created_id = $page->getOwnerUserId()) {
             if ($user_created = DB_OzoneUserPeer::instance()->selectByPrimaryKey($user_created_id)) {
                 $user_created_name = $user_created->getNickName();
             }
         }
         return array("site" => $page->getSite()->getUnixName(), "category" => $category, "name" => $name, "full_name" => $page->getUnixName(), "title" => $page->getTitleRaw(), "title_shown" => $page->getTitle(), "title_or_unix_name" => $page->getTitleOrUnixName(), "tag_string" => join(" ", $tags), "tag_array" => $tags, "parent_page" => $parent_page_name, "date_edited" => $this->_reprDate($page->getDateLastEdited()), "user_edited" => $page->getLastEditUserString(), "date_created" => $this->_reprDate($page->getDateCreated()), "user_created" => $user_created_name);
     } else {
         return array("source" => $page->getSource(), "html" => $this->_reprPageCompiled($page->getCompiled()), "meta" => $this->_reprPage($page, "meta"));
     }
 }