public function getPage() { if (!is_a($this->page, 'Page')) { $this->page = KLib\instance::of('Page', $this->pageId); } return $this->page; }
public static function loadKadmin() { if (!is_file(C::g('AUTH_FILE'))) { throw new Exception('AUTH FILE NOT FOUND', 500); } $datas = json_decode(file_get_contents(C::g('AUTH_FILE')), true); return KLib\instance::massAdd('Kadmin', $datas, 'id'); }
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); }
public function pre() { $this->user = Authenticate::session(); if (!is_a($this->user, 'Kadmin')) { throw new Exception('Not Authorized', 401); } if (MongoId::isValid($this->param2)) { $this->page = KLib\instance::of('Page', $this->param2); } }
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; }
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(); }
public function getLanguageParent() { if (!is_a($this->languageParent, 'Menu') && MongoId::isValid($this->languageParentId)) { $this->languageParent = KLib\instance::of('Menu', $this->languageParentId); } return $this->languageParent; }
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); }