Пример #1
0
 public function beforeSave()
 {
     if (!DxdUtil::startWith($this->url, 'http://') && !DxdUtil::startWith($this->url, 'https://')) {
         $this->url = 'http://' . $this->url;
     }
     if (strpos($this->url, '.swf') === false) {
         Yii::import('ext.videolink.VideoLink');
         $video = new VideoLink();
         $result = @$video->parse($this->url);
         if ($result) {
             $this->url = $result['swf'];
             $this->source = $result['source'];
             $this->title = $result['title'];
         }
     }
     return parent::beforeSave();
 }
Пример #2
0
 public static function getTopItems()
 {
     $navs = Nav::model()->findAll(array('order' => 'weight asc'));
     $items = array();
     foreach ($navs as $nav) {
         $item = array();
         if (DxdUtil::startWith($nav->url, 'http://') || DxdUtil::startWith($nav->url, 'https://')) {
             $item['url'] = $nav->url;
         } else {
             $item['url'] = Yii::app()->createUrl($nav->url);
         }
         if ($nav->activeRule) {
             $item['active'] = eval($nav->activeRule);
         }
         $item['label'] = $nav->title;
         $items[] = $item;
     }
     return $items;
 }
Пример #3
0
 public function actionOrder($categoryId)
 {
     if (isset($_POST['order'])) {
         $ids = explode(",", $_POST['order']);
         for ($i = 0; $i < count($ids); $i++) {
             if (DxdUtil::startWith($ids[$i], 'page-')) {
                 $id = substr($ids[$i], 5);
                 $model = $this->loadModel($id);
                 //$model->updateByPk( $id,array("weight"=>$i+1));
                 $model->weight = $i + 1;
                 $model->save();
             }
         }
     }
 }
Пример #4
0
 public function actionOrder($courseId)
 {
     $course = $this->loadCourse($courseId);
     if (isset($_POST['order'])) {
         //			$course->orderLessons($_POST['order']);
         $ids = explode(",", $_POST['order']);
         for ($i = 0; $i < count($ids); $i++) {
             if (DxdUtil::startWith($ids[$i], 'lesson-')) {
                 $id = substr($ids[$i], 7);
                 $lesson = Lesson::model()->findbyPk($id);
                 $lesson->updateByPk($id, array("weight" => $i + 1));
             } else {
                 $id = substr($ids[$i], 8);
                 $chapter = Chapter::model()->findbyPk($id);
                 $chapter->updateByPk($id, array("weight" => $i + 1));
             }
         }
         Chapter::model()->refreshAllNumbers($courseId);
         Lesson::model()->refreshAllNumbers($courseId);
         Lesson::model()->refreshAllChapterIds($courseId);
         Yii::app()->end();
     }
 }