Ejemplo n.º 1
0
<?php

$this->page_title = $this->t('admin', 'update');
$this->tabs = array($this->t('admin', 'manage') => $this->createUrl("manage"), $this->t('admin', 'sorting') => $this->createUrl("sorting"), $this->t('admin', 'create') => $this->createUrl("create", array('parent_id' => 1)));
?>
<div>
    Это страница для сортировки категорий.<br/>
    Для удобства использования сайта созданы некоторые ограничения:<br/>
    Нельзя главную категорией сделать второстепенной и наоборот.<br/>
    В остальном вы имеете полную своботу их перемещения.<br/>
</div>
<?php 
$this->widget('content.portlets.NestedSortable', array('model' => Documentation::model(), 'sortable' => true, 'id' => 'docs_sorting'));
 /**
  * Grab all topics from the toc.txt file to display them as a list
  */
 public function getTopics($type = 'guide')
 {
     if ($this->_topics === null) {
         $model = Documentation::model()->find('mkey=:mkey AND type=:type AND language=:lang', array(':type' => $type, ':mkey' => 'toc', ':lang' => $this->language));
         if (!$model) {
             $model = Documentation::model()->find('mkey=:mkey AND type=:type AND language=:lang', array(':type' => $type, ':mkey' => 'toc', ':lang' => 'source'));
         }
         $lines = explode("\n", $model->content);
         $chapter = '';
         foreach ($lines as $line) {
             if (($line = trim($line)) === '') {
                 continue;
             }
             if ($line[0] === '*') {
                 $chapter = trim($line, '* ');
             } else {
                 if ($line[0] === '-' && preg_match('/\\[(.*?)\\]\\((.*?)\\)/', $line, $matches)) {
                     $this->_topics[$chapter][$matches[2]] = $matches[1];
                 }
             }
         }
     }
     return $this->_topics;
 }
 /**
  * Import the topics to the DB
  */
 public function importTopics($lang = 'he')
 {
     // Topics
     $guides = Documentation::model()->documentationFolders;
     if (count($guides)) {
         foreach ($guides as $key => $guide) {
             // Load the guides files
             $files = $this->grabTopics($key, $lang);
             if (count($files)) {
                 foreach ($files as $file) {
                     // make a short name
                     $name = str_replace('.txt', '', end(explode('/', $file)));
                     // Check if we have one in the DB
                     $exists = Documentation::model()->exists('mkey=:key AND type=:type AND language=:lang', array(':lang' => $lang, ':key' => $name, ':type' => $key));
                     if ($exists) {
                         continue;
                     }
                     $contents = file_get_contents($file);
                     $contents = str_replace('«', '<', $contents);
                     $contents = str_replace('»', '>', $contents);
                     // Add
                     $save = new Documentation();
                     $save->name = $name;
                     $save->mkey = $name;
                     $save->language = $lang;
                     $save->type = $key;
                     $save->content = $contents;
                     $save->save();
                 }
             }
         }
     }
 }
 /**
  * Get the rows for the sitemap
  */
 protected function getRows()
 {
     $_rows = array();
     // Grab blog cats
     $blogCats = BlogCats::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language));
     if (count($blogCats)) {
         foreach ($blogCats as $blogCat) {
             $_rows[] = $this->makeData($this->getFullUrl('/blog/category/' . $blogCat->alias), time(), 'monthly', 0.1);
         }
     }
     // Grab blog rows
     $blogRows = Blog::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language));
     if (count($blogRows)) {
         foreach ($blogRows as $blogRow) {
             $_rows[] = $this->makeData($this->getFullUrl('/blog/view/' . $blogRow->alias), $blogRow->postdate, 'weekly', 1);
         }
     }
     // Grab tutorials cats
     $tutorialsCats = TutorialsCats::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language));
     if (count($tutorialsCats)) {
         foreach ($tutorialsCats as $tutorialsCat) {
             $_rows[] = $this->makeData($this->getFullUrl('/tutorials/category/' . $tutorialsCat->alias), time(), 'monthly', 0.1);
         }
     }
     // Grab tutorials rows
     $tutorialsRows = Tutorials::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language));
     if (count($tutorialsRows)) {
         foreach ($tutorialsRows as $tutorialsRow) {
             $_rows[] = $this->makeData($this->getFullUrl('/tutorials/view/' . $tutorialsRow->alias), $tutorialsRow->postdate, 'weekly', 1);
         }
     }
     // Grab extensions cats
     $extensionsCats = ExtensionsCats::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language));
     if (count($extensionsCats)) {
         foreach ($extensionsCats as $extensionsCat) {
             $_rows[] = $this->makeData($this->getFullUrl('/extensions/category/' . $extensionsCat->alias), time(), 'monthly', 0.1);
         }
     }
     // Grab extensions rows
     $extensionsRows = Extensions::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language));
     if (count($extensionsRows)) {
         foreach ($extensionsRows as $extensionsRow) {
             $_rows[] = $this->makeData($this->getFullUrl('/extensions/view/' . $extensionsRow->alias), $extensionsRow->postdate, 'weekly', 1);
         }
     }
     // Grab users rows
     $usersRows = Members::model()->findAll();
     if (count($usersRows)) {
         foreach ($usersRows as $usersRow) {
             $_rows[] = $this->makeData($this->getFullUrl('/user/' . $usersRow->id . '-' . $usersRow->seoname), $usersRow->joined, 'monthly', 1);
         }
     }
     // Grab forum topics rows
     $forumTopics = ForumTopics::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language));
     if (count($forumTopics)) {
         foreach ($forumTopics as $forumTopic) {
             $_rows[] = $this->makeData($this->getFullUrl('/forum/topic/' . $forumTopic->id . '-' . $forumTopic->alias), $forumTopic->dateposted, 'daily', 1);
         }
     }
     // Grab custom pages
     $customPages = CustomPages::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language));
     if (count($customPages)) {
         foreach ($customPages as $customPage) {
             $_rows[] = $this->makeData($this->getFullUrl('/' . $forumTopic->alias), $customPage->dateposted, 'weekly', 1);
         }
     }
     // Grab documentation pages
     $documentations = Documentation::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language));
     if (count($documentations)) {
         foreach ($documentations as $documentation) {
             $_rows[] = $this->makeData($this->getFullUrl('/documentation/guide/' . $documentation->type . '/topic/' . $documentation->mkey), $documentation->last_updated, 'weekly', 1);
         }
     }
     // Return array
     return $_rows;
 }