示例#1
5
 public function actionIndex()
 {
     $lang = new Lang();
     $lang->scenario = 'restcreate';
     $lang->attributes = ['name' => 'Deutsch', 'short_code' => 'de', 'is_default' => 0];
     $lang->save(false);
     foreach ($this->pages as $d) {
         $model = new Nav();
         $navItemId = $model->createPage($d['parent'], 1, 1, $d['title'], $d['alias'], 1, 'Description of ' . $d['title']);
         if ($navItemId) {
             $item = NavItem::findOne(['alias' => $d['alias']]);
             if ($item) {
                 $item->nav->updateAttributes(['is_offline' => 0, 'is_hidden' => 0]);
             }
         }
     }
     foreach ($this->redirects as $redir) {
         $model = new Nav();
         $redirItemId = $model->createRedirect($redir['parent'], 1, 1, $redir['title'], $redir['alias'], $redir['type'], $redir['typeValue'], 'Description of ' . $redir['title']);
         if ($redirItemId) {
             $item = NavItem::findOne(['alias' => $redir['alias']]);
             if ($item) {
                 $item->nav->updateAttributes(['is_offline' => 0, 'is_hidden' => 0]);
             }
         }
     }
 }
 /**
  * Get an array of all languages (its not an AR object!)
  *
  * @return array
  */
 public function getLanguages()
 {
     if ($this->_languages === null) {
         $this->_languages = Lang::getQuery();
     }
     return $this->_languages;
 }
示例#3
0
 /**
  * Get all drafts nav items
  *
  * @return array
  */
 public static function getDrafts()
 {
     if (self::$drafts === null) {
         self::$drafts = (new Query())->select(['cms_nav.id', 'nav_container_id', 'parent_nav_id', 'is_hidden', 'is_offline', 'is_draft', 'is_home', 'cms_nav_item.title'])->from('cms_nav')->leftJoin('cms_nav_item', 'cms_nav.id=cms_nav_item.nav_id')->orderBy('cms_nav.sort_index ASC')->where(['cms_nav_item.lang_id' => Lang::getDefault()['id'], 'cms_nav.is_deleted' => 0, 'cms_nav.is_draft' => 1])->all();
     }
     return self::$drafts;
 }
示例#4
0
 public function getDefaultLangShortCode()
 {
     if ($this->_defaultLangShortCode === null) {
         $lang = Lang::getDefault();
         $this->_defaultLangShortCode = $lang['short_code'];
     }
     return $this->_defaultLangShortCode;
 }
示例#5
0
 public function getLang()
 {
     return $this->hasOne(Lang::className(), ['id' => 'lang_id']);
 }
 /**
  * Get all available languages from the database as array.
  *
  * @return array The available languages.
  */
 public function actionDataLanguages()
 {
     return Lang::find()->asArray()->all();
 }