/** * Load the model menu object * * @param int $siteId * @param int $id * @return \GO\Site\Model\Menu * @throws Exception */ private function _loadModel($siteId, $id = false) { if (!empty($id)) { $model = \GO\Site\Model\Menu::model()->findByPk($id); } else { $model = new \GO\Site\Model\Menu(); $model->site_id = $siteId; } if (!$model) { throw new \Exception('Model with id: ' . $id . ' not found.'); } return $model; }
public function __construct($config = array()) { parent::__construct($config); $this->_menuModel = \GO\Site\Model\Menu::model()->findSingleByAttributes(array('site_id' => \Site::model()->id, 'menu_slug' => $this->id)); }
/** * Rearrange the tree based on the given sorting * * @param array $params * @return array */ protected function actionTreeSort($sortOrder, $parent) { // EXAMPLE INPUT // parent:1_menu_11 // sortOrder:["1_menuitem_30","1_menuitem_31","1_menuitem_33","1_menuitem_8"] $sortOrder = json_decode($sortOrder, true); $extractedParentNode = \GO\Site\SiteModule::extractTreeNode($parent); switch ($extractedParentNode['type']) { case 'content': $allowedTypes = array('content'); return \GO\Site\Model\Content::setTreeSort($extractedParentNode, $sortOrder, $allowedTypes); break; // case 'site': // $allowedTypes = array('content'); // return \GO\Site\Model\Site::setTreeSort($extractedParentNode, $sortOrder, $allowedTypes); // break; // case 'site': // $allowedTypes = array('content'); // return \GO\Site\Model\Site::setTreeSort($extractedParentNode, $sortOrder, $allowedTypes); // break; case 'menu': $allowedTypes = array('menuitem'); return \GO\Site\Model\Menu::setTreeSort($extractedParentNode, $sortOrder, $allowedTypes); break; case 'menuitem': $allowedTypes = array('menuitem'); return \GO\Site\Model\MenuItem::setTreeSort($extractedParentNode, $sortOrder, $allowedTypes); break; } }