Example #1
0
 /**
  * Generate a title manifest.
  *
  * @param integer $titleId
  * @return array | false
  */
 protected function _generateManifest($titleId, $includePages = false)
 {
     $title = new Object_Title($titleId);
     if (!$title->getId()) {
         return false;
     }
     // Get the page ids.
     $pages = Repo_TitlePage::getInstance()->getTitlePages($titleId);
     $pageIds = array();
     if ($pages && $pages->count()) {
         foreach ($pages as $_p) {
             $pageIds[] = $_p->page_id;
         }
     }
     $manifest = array('version' => $title->version, 'id' => $title->id, 'title' => $title->name, 'type' => $title->type, 'isLocked' => true, 'description' => $title->description, 'isEditable' => $title->is_editable, 'pageIds' => $pageIds);
     if ($title->nav_type == 'tree') {
         $manifest['menu'] = $title->getMenu();
     }
     if ($includePages) {
         $pageManifests = array();
         if (is_array($pageIds) && !empty($pageIds)) {
             foreach ($pages as $_p) {
                 $pageManifests[] = Manager_Manifest_Page::getInstance()->getManifest($_p->id);
             }
             $manifest['pages'] = $pageManifests;
         }
     }
     if ($title->media_asset_id) {
         $media = new Object_MediaAsset($title->media_asset_id);
         $manifest['thumbnail'] = $media->getExternalLink();
     }
     return $manifest;
 }
 /**
  * Get title info by id.
  *
  * Example requeset: /admin/ajax/title-info
  */
 public function titleInfoAction()
 {
     $ids = $this->_request->getParam('id');
     if (!is_array($ids) || empty($ids)) {
         $this->_responseErrorString = 'Invalid ids';
         $this->_sendAjaxResponse();
     }
     $infos = array();
     foreach ($ids as $_id) {
         $_object = new Object_Title($_id);
         if (!$_object->getId()) {
             continue;
         }
         $_info = array('id' => $_id, 'name' => $_object->name, 'description' => $_object->description ? $_object->description : '');
         $infos[] = $_info;
     }
     $this->_responseArray = array('titles' => $infos);
     $this->_sendAjaxResponse();
 }
 /**
  * Title page tree page: edit title menu if the title type is a menu.
  *
  * It is the central place for a title menu
  */
 public function titleMenuAction()
 {
     $id = $this->_request->getParam('id');
     $title = new Object_Title($id);
     $titleId = $title->getId();
     if (empty($titleId)) {
         // No title defined, redirec to list.
         $this->_redirect('/admin/client/title');
         return false;
     }
     $this->view->title = $title;
     $this->view->client = new Object_Client($title->client_id);
     // Title pages
     $this->view->titlePages = Repo_TitlePage::getInstance()->getTitlePages($titleId);
     // Create/edit form in the modal
     $this->view->nodeForm = new Form_Admin_Client_Title_MenuNode(false, array('pages' => $this->view->titlePages));
     // Fancy tree library
     $this->view->headScript()->appendFile('/js/libraries/fancytree/jquery.fancytree-all.min.js');
     $this->view->headLink()->appendStylesheet('/js/libraries/fancytree/skin-lion/ui.fancytree.min.css');
 }