public function getMenu($isAuthenticated, $currentPageId = null) { $contentSearch = new FM_ContentSearch(); $contentSearch->initialize('pages')->onlyLiveContent(!$isAuthenticated)->fullInfo(true)->withAllFieldsAndValues(true)->addWhereCondition('main_menu', '=', 1)->order('order_no'); $pages = $contentSearch->getContentList(); $pageParents = array(); if ($currentPageId && isset($pages[$currentPageId])) { $pageId = $currentPageId; while ($pageId && isset($pages[$pageId]) && isset($pages[$pageId]['parent_page_id']) && $pages[$pageId]['parent_page_id'] && isset($pages[$pages[$pageId]['parent_page_id']])) { $pageParents[] = $pageId = $pages[$pageId]['parent_page_id']; } } $parents = array(); foreach ($pages as $page) { $parentId = intval(isset($page['parent_page_id']) ? $page['parent_page_id'] : 0); if (!isset($parents[$parentId])) { $parents[$parentId] = array(); } if ($page['id'] === $currentPageId) { $page['current'] = true; $page['active'] = true; } if (in_array($page['id'], $pageParents)) { $page['active'] = true; } $parents[$parentId][] = $page; } return $this->_menuBranch($parents, $parents[0]); }
private function _parseContentFields($contentFieldsList) { if (count($contentFieldsList) > 0) { $contentList = array(); foreach ($contentFieldsList as $contentField) { // Set a limit into the PHP code if ($this->_limit && count($this->_whereConditions) == 0) { if (count($contentList) == $this->_limit) { return $contentList; } } if (!isset($contentList[$contentField['id']])) { $contentList[$contentField['id']] = array('id' => $contentField['id'], 'id_content_type' => $contentField['id_content_type'], 'title' => $contentField['title'], 'relative_path' => $contentField['relative_path'], 'absolute_path' => $contentField['absolute_path']); if ($this->_fullInfo) { $contentList[$contentField['id']]['id_user'] = $contentField['id_user']; $contentList[$contentField['id']]['status'] = $contentField['status']; $contentList[$contentField['id']]['data_insert'] = $contentField['data_insert']; $contentList[$contentField['id']]['data_last_update'] = $contentField['data_last_update']; $contentList[$contentField['id']]['order_no'] = $contentField['order_no']; } } // Check content field type if ($contentField['type'] == 'gallery') { // Load the gallery for this content $gallery = $this->ci->fm_cms->getAllContentAttachmentsByIdContent($contentField['id']); $contentList[$contentField['id']][$contentField['name']] = $gallery; } elseif ($contentField['type'] == 'linked_content') { // Load the linked content $contentSearch = new FM_ContentSearch(); $contentLinked = $this->ci->fm_cms->getContentById($contentField['value']); $contentSearch->initialize($contentLinked['id_content_type'])->fullInfo(TRUE)->addWhereCondition('id', '=', $contentField['value']); $contentLinked = current($contentSearch->getContentList()); $contentList[$contentField['id']][$contentField['name']] = $contentLinked; } elseif ($contentField['type'] == 'multiple_linked_content') { // Load the linked content $contentSearch = new FM_ContentSearch(); $multipleLinkedContent = $this->ci->fm_cms->getContentById($contentField['value']); $contentSearch->initialize($multipleLinkedContent['id_content_type'])->fullInfo(TRUE)->withAllFieldsAndValues(TRUE)->addWhereCondition('id', 'IN', $contentField['value']); $multipleLinkedContent = $contentSearch->getContentList(); $contentList[$contentField['id']][$contentField['name']] = $multipleLinkedContent; } else { $contentList[$contentField['id']][$contentField['name']] = $contentField['value']; } } return $contentList; } else { return array(); } }
public function updateSonsPath($absolutePath, $parentId) { $contentSearch = new FM_ContentSearch(); $contentSearch->initialize('pages')->select('id', 'relative_path')->addWhereCondition('parent_page_id', '=', $parentId); $contentList = $contentSearch->getContentList(); foreach ($contentList as $content) { $content['absolute_path'] = "{$absolutePath}{$content['relative_path']}/"; $this->db->where('id', $content['id']); $this->db->update($this->_tableName, array('absolute_path' => $content['absolute_path'])); $this->updateSonsPath($content['absolute_path'], $content['id']); } }
public function calendarAction() { if (isset($_GET['day'])) { // Get specific day list($day, $month, $year) = explode('-', $_GET['day']); $condition = $day . '/' . $month . '/' . $year; } else { if (isset($_GET['month_year'])) { // Get specific month list($month, $year) = explode('-', $_GET['month_year']); $condition = '%/' . $month . '/' . $year; } else { // Get current month $condition = '%/' . date('m/Y'); } } $contentSearch = new FM_ContentSearch(); $contentSearch->initialize('calendar')->onlyLiveContent(true)->withAllFieldsAndValues(TRUE)->addWhereCondition('day', 'LIKE', $condition); $contentList = $contentSearch->getContentList(); $currentMonth = array(); if (count($contentList) > 0) { foreach ($contentList as $item) { list($day, $month, $year) = explode('/', $item['day']); $timestamp = mktime(0, 0, 0, $month, $day, $year); $data = array('items' => explode(',', $item['items'])); if (isset($item['ecomobile_text']) && $item['ecomobile_text'] != '') { $data['ecomobile_text'] = $item['ecomobile_text']; } $currentMonth[$timestamp] = $data; } ksort($currentMonth); echo json_encode(array('result' => 'ok', 'data' => $currentMonth)); } else { echo json_encode(array('result' => 'ko', 'data' => 'No results for the query')); } }
public function getOptionsContentList() { $this->view = FALSE; $this->layout = FALSE; $cType = $this->uri->segment(4); if ($cType) { $contentSearch = new FM_ContentSearch(); $contentSearch->initialize($cType)->fullInfo(TRUE); $contentList = $contentSearch->getContentList(); $options = array(); if (count($contentList) > 0) { foreach ($contentList as $content) { $tmp = array('value' => $content['id'], 'label' => $content['title']); $options[] = $tmp; } } echo json_encode($options); } }