コード例 #1
0
ファイル: PagstructureOp.php プロジェクト: Cryde/sydney-core
 /**
  * Returns the structure in an array form which could be used
  * to display the HTML in the page module.
  *
  * @return Array
  * @param int $safinstancesId [optional]
  * @param int $parentId [optional]
  */
 public function toArrayLoop($safinstancesId = 0, $parentId = null)
 {
     $toReturn = array();
     $selector = $this->select()->where('safinstances_id = ' . $safinstancesId)->order('pagorder');
     if ($parentId === null) {
         $selector->where('parent_id IS NULL');
     } else {
         $selector->where('parent_id = ' . $parentId);
     }
     $selector = $this->applyFilter($selector);
     // Load translation
     $translate = new Translate_Content_Node();
     foreach ($this->fetchAll($selector) as $row) {
         if (!$this->isNodeLoaded($row->id)) {
             $menusId = array();
             $menuIdsDb = new PagstructurePagmenus();
             foreach ($menuIdsDb->fetchAll('pagstructure_id = ' . $row->id) as $menuIdValue) {
                 $menusId[] = $menuIdValue->pagmenus_id;
             }
             $pageStats = new Pagstats();
             $stats = $pageStats->loadStats($row->id);
             $isCollapsed = false;
             $toReturn[$row->id] = array('id' => $row->id, 'label' => $translate->_($row->id, $row->label), 'htmltitle' => $row->htmltitle, 'url' => $row->url, 'isCollapsed' => $isCollapsed, 'status' => $row->status, 'metadesc' => $row->metadesc, 'metakeywords' => $row->metakeywords, 'datemodified' => $row->datemodified, 'date_lastupdate_content' => $row->date_lastupdate_content, 'who_modified' => $row->who_modified, 'who_lastupdate_content' => $row->who_lastupdate_content, 'ishome' => $row->ishome, 'iscachable' => $row->iscachable, 'cachetime' => $row->cachetime, 'menusid' => $menusId, 'redirecttoid' => $row->redirecttoid, 'usersgroups_id' => $row->usersgroups_id, 'pagorder' => $row->pagorder, 'shortdesc' => $row->shortdesc, 'colorcode' => $row->colorcode, 'layout' => $row->layout, 'kids' => array(), 'stats' => $stats);
             // store node loaded
             $this->setNode($row->id);
             // get the kids now if any
             $kids = $this->toArrayLoop($safinstancesId, $row->id);
             if (count($kids) > 0) {
                 $toReturn[$row->id]['kids'] = $kids;
             }
             $this->stringNodes[$row->id] = $toReturn[$row->id];
         }
     }
     return $toReturn;
 }
コード例 #2
0
ファイル: IndexController.php プロジェクト: Cryde/sydney-core
    /**
     * Returns an array which can be used to represent the menus linked to a page structure
     *
     * @param $pagStructureId Int ID of the entry in the structure
     * @param $isNewPage Boolean true if it's a new page (so we check the default menu)
     * @return Array Structure of the array elements : array( id , label, desc , isChcecked )
     */
    public function getMenusArray($pagStructureId = 0, $isNewPage = true)
    {
        $selectedDb = new PagstructurePagmenus();
        $selected = $selectedDb->getPagmenusLinkedTo($pagStructureId);
        $toReturn = array();
        $sql = 'SELECT pagmenus.id AS id, pagmenus.label AS label, pagmenus.desc AS descr
				FROM pagmenus, pagmenus_safinstances
				WHERE pagmenus.id = pagmenus_safinstances.pagmenus_id
				AND  pagmenus_safinstances.safinstances_id = ' . $this->safinstancesId . '
				AND pagmenus.active = 1';
        $db = $this->_registry->get('db');
        foreach ($db->fetchAll($sql) as $it) {
            if ($it['id'] == 1 && $isNewPage) {
                $isChecked = true;
            } elseif (in_array($it['id'], $selected)) {
                $isChecked = true;
            } else {
                $isChecked = false;
            }
            $toReturn[] = array($it['id'], $it['label'], $it['descr'], $isChecked);
        }
        return $toReturn;
    }