model() public static method

Returns the static model of the specified AR class.
public static model ( string $className = __CLASS__ ) : Menu
$className string active record class name.
return Menu the static model class
Beispiel #1
0
 public function actionIndex()
 {
     //lay 1 tin moi de hien thi phan tin tuc
     $headTab = new Menu();
     $numHeadTab1 = $headTab->model()->find('alias="tin-dia-phuong"')->id;
     $cdbNewsLocal = new CDbCriteria();
     $cdbNewsLocal->order = 'datecreate DESC';
     $cdbNewsLocal->limit = 1;
     $cdbNewsLocal->condition = 'idmenu =' . $numHeadTab1;
     $modelNewsLocal = News::model()->find($cdbNewsLocal);
     if ($modelNewsLocal === NULL) {
         Yii::app()->user->setFlash('LocalEmpty', 'Dữ liệu đang cập nhật');
         $modelLocalMore = Yii::app()->user->setFlash('LocalEmptyMore', 'Dữ liệu đang cập nhật');
     } else {
         //lay 4 tin khac de hien thi phan tin tuc
         $cdbLocalMore = new CDbCriteria();
         $cdbLocalMore->limit = 4;
         $cdbLocalMore->order = 'datecreate DESC';
         $cdbLocalMore->condition = 'id NOT IN ("' . $modelNewsLocal->id . '") AND idmenu=' . $modelNewsLocal->idmenu;
         $modelLocalMore = News::model()->findAll($cdbLocalMore);
     }
     //lay 1 tin moi de hien thi phan Tin cong nghe
     $numHeadTab2 = $headTab->model()->find('alias="tin-cong-nghe"')->id;
     $cdbNewsTech = new CDbCriteria();
     $cdbNewsTech->order = 'datecreate DESC';
     $cdbNewsTech->limit = 1;
     $cdbNewsTech->condition = 'idmenu =' . $numHeadTab2;
     $modelNewsTech = News::model()->find($cdbNewsTech);
     if ($modelNewsTech === NULL) {
         Yii::app()->user->setFlash('emptyData', 'Dữ liệu đang cập nhật');
         $modelTechMore = Yii::app()->user->setFlash('emptyDataMore', 'Dữ liệu đang cập nhật');
     } else {
         //lay 2 tin khac de hien thi phan Tin cong nghe
         $cdbTechMore = new CDbCriteria();
         $cdbTechMore->limit = 2;
         $cdbTechMore->order = 'datecreate DESC';
         $cdbTechMore->condition = 'id NOT IN ("' . $modelNewsTech->id . '") AND idmenu=' . $modelNewsTech->idmenu;
         $modelTechMore = News::model()->findAll($cdbTechMore);
     }
     //lay 1 tin moi de hien thi phan Thong bao
     $numHeadTab3 = $headTab->model()->find('alias="thong-bao"')->id;
     $cdbNewsNotify = new CDbCriteria();
     $cdbNewsNotify->order = 'datecreate DESC';
     $cdbNewsNotify->limit = 1;
     $cdbNewsNotify->condition = 'idmenu =' . $numHeadTab3;
     $modelNewsNotify = News::model()->find($cdbNewsNotify);
     if ($modelNewsNotify === NULL) {
         Yii::app()->user->setFlash('NofifyEmpty', 'Dữ liệu đang cập nhật');
         $modelNotifyMore = Yii::app()->user->setFlash('MoreNofifyEmpty', 'Dữ liệu đang cập nhật');
     } else {
         //lay 2 tin khac de hien thi phan Tin cong nghe
         $cdbNotifyMore = new CDbCriteria();
         $cdbNotifyMore->limit = 2;
         $cdbNotifyMore->order = 'datecreate DESC';
         $cdbNotifyMore->condition = 'id NOT IN ("' . $modelNewsNotify->id . '") AND idmenu=' . $modelNewsNotify->idmenu;
         $modelNotifyMore = News::model()->findAll($cdbNotifyMore);
     }
     $this->render('index', array('modelNewsLocal' => $modelNewsLocal, 'modelLocalMore' => $modelLocalMore, 'modelNewsTech' => $modelNewsTech, 'modelTechMore' => $modelTechMore, 'modelNewsNotify' => $modelNewsNotify, 'modelNotifyMore' => $modelNotifyMore));
 }
 public function loadModel($id)
 {
     if (($model = Menu::model()->findByPk($id)) === null) {
         throw new CHttpException(404, Yii::t('MenuModule.menu', 'Page was not found!'));
     }
     return $model;
 }
Beispiel #3
0
 public function activate(Plugin $plugin)
 {
     $data = $plugin->getData();
     if ($data === null) {
         $data = array();
     }
     if (isset($data['id_menu']) && is_numeric($data['id_menu'])) {
         // не должно быть такого
         return;
     }
     if (Menu::model()->exists('id=:id', array(':id' => 108))) {
         // на сайте изначально был установлен данный плагин.
         // записываем данные по умолчанию
         $data['id_menu'] = 108;
         $data['id_event_type'] = 103;
     } else {
         $eventType = $this->prepareEventType('Вопрос-ответ » Новый вопрос');
         $eventType->save();
         $data['id_event_type'] = $eventType->id_event_type;
         // создаем раздел меню
         $menu = $this->prepareMenu('Вопрос-ответ', 'Вопрос-ответ', 'faq', '/faq/', isset($data['id_menu_module_template']) ? $data['id_menu_module_template'] : null);
         $menu->save();
         $data['id_menu'] = $menu->id;
         $this->createPermission($data['id_object'], 'Просмотр списка данных объекта Вопрос-ответ');
         $this->updateMenu = true;
     }
     $plugin->setData($data);
     $plugin->setConfig($this->getConfigByParamsValue($plugin->getParamsValue(), $data));
 }
Beispiel #4
0
 public function activate(Plugin $plugin)
 {
     $data = $plugin->getData();
     if ($data === null) {
         $data = array();
     }
     if (isset($data['id_menu']) && is_numeric($data['id_menu'])) {
         // не должно быть такого
         return;
     }
     if (Menu::model()->exists('id=:id', array(':id' => 116))) {
         // на сайте изначально был установлен данный плагин.
         // записываем данные по умолчанию
         $data['id_menu'] = 116;
         $data['id_site_module'] = 114;
     } else {
         // модуль ещё не установлен на сайте
         // создаем раздел меню и модуль сайта
         $menu = $this->prepareMenu('Опрос', 'Опрос', 'vote', '/vote/', isset($data['id_menu_module_template']) ? $data['id_menu_module_template'] : null, false);
         $menu->save();
         $siteModule = $this->prepareSiteModule('Голосование', $data['id_php_script_type_module']);
         $siteModule->save();
         if (!empty($data['site_module_place'])) {
             $this->restoreSiteModulePlace($siteModule->id_module, $data['site_module_place']);
             unset($data['site_module_place']);
         }
         $this->createPermission($data['id_object_voting'], 'Просмотр списка данных объекта Опросы');
         $this->createPermission($data['id_object_voting_answer'], 'Просмотр списка данных объекта Варианты ответов в опросах');
         $this->updateMenu = true;
         $data['id_menu'] = $menu->id;
         $data['id_site_module'] = $siteModule->id_module;
     }
     $plugin->setData($data);
 }
Beispiel #5
0
 public function actionManager()
 {
     $moduleType = EnvUtil::getRequest("op");
     if (!in_array($moduleType, array("installed", "uninstalled"))) {
         $moduleType = "installed";
     }
     if ($moduleType == "uninstalled") {
         $moduleDirs = ModuleUtil::getModuleDirs();
         if (!empty($moduleDirs)) {
             $moduleDirs = ModuleUtil::filterInstalledModule(Module::model()->fetchAllSortByPk("module"), $moduleDirs);
         }
         $modules = ModuleUtil::initModuleParameters($moduleDirs);
     } else {
         $modules = Module::model()->fetchAll(array("order" => "iscore ,installdate desc"));
         foreach ($modules as $index => $module) {
             $menu = Menu::model()->fetchByModule($module["module"]);
             if (!empty($menu)) {
                 $route = $menu["m"] . "/" . $menu["c"] . "/" . $menu["a"];
                 $param = StringUtil::splitParam($menu["param"]);
                 $module["managerUrl"] = Ibos::app()->urlManager->createUrl($route, $param);
             } else {
                 $module["managerUrl"] = "";
             }
             $modules[$index] = $module;
         }
     }
     $data = array("modules" => $modules);
     $this->render("module" . ucfirst($moduleType), $data);
 }
Beispiel #6
0
 private function concatenatedToBuildMenu($in, $valor)
 {
     $criteria = new CDbCriteria();
     $criteria->addInCondition('id_menu_sistema', $in);
     $criteria->compare('padre', $valor);
     $criteria->compare('estatus', 1);
     $criteria->order = 'nivel';
     $menus = Menu::model()->findAll($criteria);
     $mostrar = array();
     foreach ($menus as $menu) {
         $criteria = new CDbCriteria();
         $criteria->addInCondition('id_menu_sistema', $in);
         $criteria->compare('padre', $valor);
         $criteria->compare('estatus', 1);
         $contadorHijos = Menu::model()->count($criteria);
         if ($contadorHijos == 0) {
             $mostrar[] = array('label' => 'Inicio', 'url' => array('/site/index'));
         } else {
             $addMostrar = array('label' => $menu->nombre, 'url' => array($menu->ruta), 'style' => 'home', 'items' => $this->concatenatedToBuildMenu($in, $menu->id_menu_sistema));
             if ($menu->style != '') {
                 $addMostrar['style'] = $menu->style;
             }
             $mostrar[] = $addMostrar;
         }
     }
     return $mostrar;
 }
Beispiel #7
0
 public function actionIndex()
 {
     $this->checkCookieEnabled();
     $this->htmlPageId = 'index';
     $page = Menu::model()->findByPk(InfoPages::MAIN_PAGE_ID);
     if (issetModule('seo')) {
         $seo = SeoFriendlyUrl::model()->findByAttributes(array('model_name' => 'InfoPages', 'model_id' => InfoPages::MAIN_PAGE_ID));
         if ($seo) {
             $this->setSeo($seo);
         }
     }
     $langs = Lang::getActiveLangs();
     $countLangs = count($langs);
     if (!isFree() && !isset($_GET['lang']) && ($countLangs > 1 || $countLangs == 1 && param('useLangPrefixIfOneLang'))) {
         $canonicalUrl = Yii::app()->getBaseUrl(true);
         $canonicalUrl .= '/' . Yii::app()->language;
         Yii::app()->clientScript->registerLinkTag('canonical', null, $canonicalUrl);
     }
     Yii::app()->user->setState('searchUrl', NULL);
     $lastNews = News::getLastNews();
     if (Yii::app()->request->isAjaxRequest) {
         //			$modeListShow = User::getModeListShow();
         //			if ($modeListShow == 'table') {
         //				# нужны скрипты и стили, поэтому processOutput установлен в true только для table
         //				$this->renderPartial('index', array('page' => $page, 'newsIndex' => $lastNews), false, true);
         //			}
         //			else {
         $this->renderPartial('index', array('page' => $page, 'newsIndex' => $lastNews));
         //			}
     } else {
         $this->render('index', array('page' => $page, 'newsIndex' => $lastNews));
     }
 }
Beispiel #8
0
 public function actionSearch($type = 'all')
 {
     if (!param('useShowUserInfo')) {
         throw new CHttpException(403, tt('Displays information about the users is disabled by the administrator', 'users'));
     }
     $usersListPage = Menu::model()->findByPk(Menu::USERS_LIST_ID);
     if ($usersListPage) {
         if ($usersListPage->active == 0) {
             throw404();
         }
     }
     $this->showSearchForm = false;
     $existTypes = User::getTypeList('withAll');
     $criteria = new CDbCriteria();
     $type = in_array($type, array_keys($existTypes)) ? $type : 'all';
     //$criteria->compare('active', 1);
     if ($type != 'all') {
         $criteria->compare('type', $type);
     }
     //$criteria->compare('isAdmin', 0);
     $criteria->with = array('countAdRel');
     $sort = new CSort();
     $sort->sortVar = 'sort';
     $sort->defaultOrder = 'date_created DESC';
     $sort->multiSort = true;
     $sort->attributes = array('username' => array('label' => tc('by username'), 'default' => 'desc'), 'date_created' => array('label' => tc('by date of registration'), 'default' => 'desc'));
     $dataProvider = new CActiveDataProvider(User::model()->active(), array('criteria' => $criteria, 'sort' => $sort, 'pagination' => array('pageSize' => 12)));
     $this->render('search', array('dataProvider' => $dataProvider, 'type' => $type));
 }
Beispiel #9
0
 public function actionIndex()
 {
     $page = Menu::model()->findByPk(InfoPages::MAIN_PAGE_ID);
     $langs = Lang::getActiveLangs();
     $countLangs = count($langs);
     if (!isFree() && !isset($_GET['lang']) && ($countLangs > 1 || $countLangs == 1 && param('useLangPrefixIfOneLang'))) {
         $canonicalUrl = Yii::app()->getBaseUrl(true);
         $canonicalUrl .= '/' . Yii::app()->language;
         Yii::app()->clientScript->registerLinkTag('canonical', null, $canonicalUrl);
     }
     Yii::app()->user->setState('searchUrl', NULL);
     $criteriaNews = new CDbCriteria();
     $criteriaNews->limit = 10;
     $criteriaNews->order = 'date_created DESC';
     $newsIndex = News::model()->findAll($criteriaNews);
     if (isset($_GET['is_ajax'])) {
         //			$modeListShow = User::getModeListShow();
         //			if ($modeListShow == 'table') {
         //				# нужны скрипты и стили, поэтому processOutput установлен в true только для table
         //				$this->renderPartial('index', array('page' => $page, 'newsIndex' => $newsIndex), false, true);
         //			}
         //			else {
         $this->renderPartial('index', array('page' => $page, 'newsIndex' => $newsIndex));
         //			}
     } else {
         $this->render('index', array('page' => $page, 'newsIndex' => $newsIndex));
     }
 }
 public function loadModel($id)
 {
     if (($model = Menu::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
Beispiel #11
0
 protected function deleteMenu($menuId)
 {
     $menuItems = MenuItem::model()->findAllByAttributes(array('menuId' => $menuId));
     foreach ($menuItems as $item) {
         $item->delete();
     }
     Menu::model()->deleteByPk($menuId);
 }
Beispiel #12
0
 public function run()
 {
     parent::run();
     $criteria = new CDbCriteria();
     $criteria->order = 't.order ASC';
     $menu = Menu::model()->findAll($criteria);
     $this->render('home_menu_bar');
 }
Beispiel #13
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  *
  * @param integer $id the ID of the model to be loaded
  *
  * @throws CHttpException
  *
  * @return Menu
  */
 public function loadModel($id)
 {
     $model = Menu::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Beispiel #14
0
 public function run()
 {
     parent::run();
     $criteria = new CDbCriteria();
     $criteria->order = 't.order ASC';
     $menu = Menu::model()->findAll($criteria);
     $data['adv'] = Advertisement::model()->findAll("state = 1");
     $this->render('bottom_logos', $data);
 }
Beispiel #15
0
 public static function createLinks()
 {
     $menuItems = Menu::model()->findAll();
     foreach ($menuItems as $menuItem) {
         $makeLink = "make" . ucfirst($menuItem->link_type) . "Link";
         $menuItem->link = self::$makeLink($menuItem->link);
     }
     return self::makeMenuArray($menuItems);
 }
Beispiel #16
0
    /**
     * !CodeTemplates.overridecomment.nonjd!
     * @see CController::init()
     */
    public function init()
    {
        parent::init();
        if ($this->_setting['site_status'] == 'close') {
            //网站关闭
            $encode_intro = CHtml::encode($this->_setting['site_status_intro']);
            $site_name = CHtml::encode($this->_setting['site_name']);
            echo <<<EOT
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
\t<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\t<title>{$site_name}</title>
</head>
<body>
\t<p style="width:800px; line-height:40px;  margin:0 auto; margin-top:50px; color:#FFFFFF; text-align:center; background-color:#3C5880;">{$encode_intro}</p>
</body>
</html>\t
EOT;
            exit;
        }
        //前端ip访问控制
        $cur_ip = $this->_request->userHostAddress;
        $access_ips = $this->_setting['deny_access_ip'];
        $access_ips && ($access_ips = explode("\r\n", trim($access_ips)));
        $access = Helper::ipAccess($cur_ip, $access_ips);
        if (!$access) {
            throw new CHttpException(403, '403 Forbidden!');
            exit;
        }
        //主题设置
        Yii::app()->theme = $this->_setting['theme'];
        $this->_stylePath = Yii::app()->theme->baseUrl . '/styles';
        //菜单导航
        $this->_public_menu = Yii::app()->cache->get('global_menus');
        if ($this->_public_menu == false) {
            $menus = Menu::model()->findAll('status_is =:status ORDER BY sort_order, id', array(':status' => 'Y'));
            $tree = new Xtree();
            foreach ((array) $menus as $menu) {
                $data[] = $menu->attributes;
            }
            $tree->setTree($data, 'id', 'parent_id', array('menu_name', 'menu_link', 'unique', 'target'));
            $this->_public_menu = $tree->getArrayList(0);
            Yii::app()->cache->set('global_menus', $this->_public_menu, 3600 * 24 * 7);
        }
        $this->_cur_url = Yii::app()->request->getUrl();
        //登录状态
        if (!Yii::app()->user->getIsGuest()) {
            $this->_login_status = true;
        }
        //加载公共资源
        //不需要加载bootstrap的页面,要小写
        $not_need_bootstrap = array('goods/buy');
        //Yii::app()->clientScript->registerCssFile($this->_stylePath . "/bootstrap3/css/bootstrap.min.css");
        //Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/global.css");
        Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js");
    }
 public function up()
 {
     Yii::app()->getModule('menu');
     $Menu = Menu::model()->findByAttributes(['code' => 'top-menu-cabinet']);
     $menuItems = $Menu->menuItems(['condition' => 'href=:href', 'params' => ['href' => '/cabinet/deal']]);
     if (!is_null($menuItems) && count($menuItems)) {
         $menuItem = $menuItems[0];
         MenuItem::model()->deleteByPk($menuItem->id);
     }
 }
Beispiel #18
0
 public function init()
 {
     parent::init();
     $articlePage = Menu::model()->findByPk(Menu::ARTICLES_ID);
     if ($articlePage) {
         if ($articlePage->active == 0) {
             throw404();
         }
     }
 }
Beispiel #19
0
 public function init()
 {
     parent::init();
     $specialOfferPage = Menu::model()->findByPk(Menu::SPECIALOFFERS_ID);
     if ($specialOfferPage) {
         if ($specialOfferPage->active == 0) {
             throw404();
         }
     }
 }
Beispiel #20
0
 public function init()
 {
     parent::init();
     $reviewsPage = Menu::model()->findByPk(Menu::REVIEWS_ID);
     if ($reviewsPage) {
         if ($reviewsPage->active == 0) {
             throw404();
         }
     }
 }
Beispiel #21
0
 public static function getMenuTree()
 {
     if (empty(self::$menuTree)) {
         $rows = Menu::model()->findAll('parent = 0 AND status = 1 ORDER BY id ASC');
         foreach ($rows as $item) {
             self::$menuTree[] = self::getMenuItems($item);
         }
     }
     return self::$menuTree;
 }
Beispiel #22
0
 public function init()
 {
     parent::init();
     $vacancyPage = Menu::model()->findByPk(Menu::VACANCY_ID);
     if ($vacancyPage) {
         if ($vacancyPage->active == 0) {
             throw404();
         }
     }
 }
Beispiel #23
0
 /**
  * Get the root menu tree nodes
  * 
  * @param Site $site
  * @return array
  */
 public static function getTreeMenuNodes(Site $site)
 {
     $tree = array();
     $menus = Menu::model()->findByAttribute('site_id', $site->id, \GO\Base\Db\FindParams::newInstance());
     foreach ($menus as $menu) {
         $hasChildren = $menu->hasChildren();
         $node = array('id' => $menu->site_id . '_menu_' . $menu->id, 'menu_id' => $menu->id, 'cls' => 'site-node-menu', 'site_id' => $menu->site->id, 'iconCls' => 'go-model-icon-Menu', 'text' => $menu->label, 'hasChildren' => $hasChildren, 'expanded' => !$hasChildren || \GO\Site\Model\Site::isExpandedNode($menu->site_id . '_menu_' . $menu->id), 'children' => $hasChildren ? $menu->getMenuChildrenTree() : null);
         $tree[] = $node;
     }
     return $tree;
 }
Beispiel #24
0
 public function getMenuTitle()
 {
     if ($this->menuId == Menu::NONE) {
         return '';
     }
     $menu = Menu::model()->findByPk($this->menuId);
     if (!$menu) {
         return '';
     }
     return $menu->name;
 }
Beispiel #25
0
 public static function getMenuTypes()
 {
     $criteria = new CDbCriteria();
     $criteria->select = 'id, name';
     $menus = Menu::model()->findAll($criteria);
     $arr = array();
     foreach ($menus as $menu) {
         $arr[$menu->id] = $menu->name;
     }
     return $arr;
 }
Beispiel #26
0
 public function getMenuListPage()
 {
     $pageNum = empty($_REQUEST['pageNum']) ? 1 : $_REQUEST['pageNum'];
     $criteria = new CDbCriteria();
     $criteria->order = 'id DESC';
     $criteria->offset = ($pageNum - 1) * 20;
     $criteria->limit = 20;
     $count = Menu::model()->count($criteria);
     $list = Menu::model()->findAll($criteria);
     return array('count' => $count, 'list' => $list, 'pageNum' => $pageNum);
 }
Beispiel #27
0
 public static function findMenu()
 {
     $result = array();
     $menus = Menu::model()->findAll();
     if ($menus) {
         foreach ($menus as $menu) {
             $result[$menu->menu_id] = $menu->menu_name;
         }
     }
     return $result;
 }
Beispiel #28
0
 public function actionIndex()
 {
     $newsPage = Menu::model()->findByPk(Menu::NEWS_ID);
     if ($newsPage) {
         if ($newsPage->active == 0) {
             throw404();
         }
     }
     $model = new $this->modelName();
     $result = $model->getAllWithPagination();
     $this->render('index', array('items' => $result['items'], 'pages' => $result['pages']));
 }
Beispiel #29
0
 /**
  * 判断数据是否存在
  * 
  * return \$this->model
  */
 public function loadModel()
 {
     if ($this->model === null) {
         if (isset($_GET['id'])) {
             $this->model = Menu::model()->findbyPk($_GET['id']);
         }
         if ($this->model === null) {
             throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.'));
         }
     }
     return $this->model;
 }
Beispiel #30
0
 public function getMenuTitle()
 {
     $title = "";
     if (empty($this->menuId)) {
         return $title;
     }
     $main = Menu::model()->findByPk($this->menuId);
     if ($main != null && $main->position != 9) {
         $title = $main->name;
     }
     return $title;
 }