Ejemplo n.º 1
0
 public function all()
 {
     $blocks = array_values(KLib\MongoDB::find(array(), 'kn_block', 'array', array('label' => true, 'language' => true, 'key' => true)));
     $blocks = array_map(function ($i) {
         return array('id' => (string) $i['_id'], 'key' => $i['key'], 'label' => $i['label'], 'language' => $i['language'], 'labelFull' => $i['language'] . ' - ' . $i['label']);
     }, $blocks);
     return $blocks;
 }
Ejemplo n.º 2
0
 public static function allMenus()
 {
     $datas = KLib\MongoDB::find(array(), 'kn_menu', 'cursor');
     if (!is_a($datas, 'MongoCursor') || $datas->count() <= 0) {
         return array();
     }
     return KLib\instance::massAdd('Menu', $datas);
 }
Ejemplo n.º 3
0
 public function languageMenuParent()
 {
     $ret = array();
     $pageParent = KLib\MongoDB::find(array('languageParentId' => null), 'kn_menu', 'cursor', array('_id' => true, 'label' => true, 'language' => true));
     if (is_a($pageParent, 'MongoCursor') && $pageParent->count() > 0) {
         foreach ($pageParent as $k => $page) {
             $ret[] = array('key' => (string) $k, 'value' => $page['language'] . ' ' . $page['label']);
         }
     }
     return $ret;
 }
Ejemplo n.º 4
0
 public static function getByPageId($pageId)
 {
     if (!MongoId::isValid($pageId)) {
         throw new Exception('INVALID PAGEID', 500);
     }
     $datas = KLib\MongoDB::find(array('items.pageId' => (string) $pageId), 'menu', 'cursor');
     if (is_a($datas, 'MongoCursor') && $datas->count() > 0) {
         return KLib\instance::massAdd('Menu', $datas);
     }
     return array();
 }
Ejemplo n.º 5
0
 public function getById($id)
 {
     if (!MongoId::isValid($id)) {
         return null;
     }
     $datas = KLib\MongoDB::findOne(array('_id' => $id), 'kn_block');
     if (is_array($datas) && !empty($datas) && array_key_exists('type', $datas) && is_string($datas['type']) && class_exists($datas['type'])) {
         return KLib\instance::addOne($datas['type'], $datas);
     }
     return null;
 }
Ejemplo n.º 6
0
 public static function allPages($published = null)
 {
     $query = array();
     if (is_bool($published)) {
         $query['published'] = $published;
     }
     $pages = KLib\MongoDB::find($query, 'kn_page', 'cursor');
     if (is_a($pages, 'MongoCursor') && $pages->count() > 0) {
         return KLib\instance::massAdd('Page', $pages);
     }
     return array();
 }
Ejemplo n.º 7
0
 public static function getByMenuId($menuId, $lang = null)
 {
     if (!is_string($menuId)) {
         throw new Exception('INVALID MENUID', 500);
     }
     if (!array_key_exists(strtoupper($lang), C::g('LIST_LANGUAGE'))) {
         $lang = C::g('LANG_CURRENT');
     }
     $data = KLib\MongoDB::findOne(array('menuId' => $menuId, 'language' => strtoupper($lang)), 'kn_menu');
     if (is_array($data) && !empty($data)) {
         return new Self($data);
     }
     return null;
 }
Ejemplo n.º 8
0
 public function getLanguageChildren()
 {
     $main = $this->getLanguageParent();
     if (!is_a($main, 'Page') && is_null($this->languageParentId)) {
         $main = $this;
     } elseif (!is_a($main, 'Page')) {
         throw new Exception('INVALID LANGUAGEPARENTID', 500);
     }
     $datas = KLib\MongoDB::find(array('languageParentId' => $this->id), 'kn_page', 'cursor');
     return KLib\instance::massAdd('Page', $datas);
 }