Esempio n. 1
0
 public function getById($id)
 {
     $lesson = self::returnedLesson(parent::getById($id));
     /*
      * Récupere tous les slides
      */
     if ($lesson != null) {
         $manageSlides = new SlideManager();
         $slides = $manageSlides->getSlidesOfLesson($lesson->getId());
         $lesson->setSlides($slides);
     }
     return $lesson;
 }
Esempio n. 2
0
 public function run()
 {
     if ($this->beginCache("slideshow", array('duration' => 0))) {
         $criteria = new CDbCriteria();
         $criteria->addCondition('status=1');
         $criteria->order = 'pos DESC';
         $criteria->limit = 20;
         $items = SlideManager::model()->findAll($criteria);
         $slide = '';
         if ($items) {
             $i = 0;
             foreach ($items as $item) {
                 //<img src="<?php echo Yii::app()->baseUrl; /images/img_slice_21.jpg" title="Xin chao"/>
                 $imgclass = $i ? "notshow" : "";
                 $imgUrl = Lnt::createImage($item->image, 528, 272);
                 $slide .= CHtml::image($imgUrl, $item->title, array('title' => CHtml::link($item->title, $item->url), 'width' => 528, 'height' => 272, 'class' => $imgclass));
                 $i++;
             }
         }
         echo $slide;
         $this->endCache();
     }
 }
Esempio n. 3
0
        $course = new Course(array('name' => 'Temporary Course', 'description' => '', 'authors' => array($user->id()), 'categories' => array($catWPId !== 0 ? $catWPId : 1)));
        $courseId = $managerCourse->add($course);
        $resultLesson = $access->getResults("SELECT * FROM {$tableCourse}");
        $authors = array();
        foreach ($resultLesson as $lesson) {
            $managerLesson = new LessonManager();
            if ($a = get_user_by('login', $lesson['author'])) {
                $authors[] = $a->ID;
            }
            $lessonId = $managerLesson->add(new Lesson(array('name' => $lesson['nom'] != "" ? $lesson['nom'] : "Course", 'author' => $a ? $a->display_name : $user->displayName(), 'authorId' => $a ? $a->ID : $user->id(), 'description' => $lesson['cours_des'], 'duration' => $lesson['duration'], 'courseId' => $courseId)));
            if (!in_array($user->id(), $authors)) {
                $authors[] = $user->id();
            }
            if ($access->getVar("SHOW TABLES LIKE '{$tableSlides}'") == $tableSlides) {
                $slidesResult = $access->getResults("SELECT * FROM {$tableSlides} WHERE course_id = '" . $lesson['course_id'] . "'");
                $managerSlide = new SlideManager();
                foreach ($slidesResult as $slide) {
                    $managerSlide->add(new Slide(array('courseId' => $lessonId, 'name' => $slide['slides_name'] != "" ? $slide['slides_name'] : "Slide", 'content' => $slide['slides_content'], 'order' => $slide['slides_order'])));
                }
            }
        }
        $course->setAuthors($authors);
        $managerCourse->update($courseId, $course);
        add_action('admin_init', 'sp_notice_warning_migrate');
        function sp_notice_warning_migrate()
        {
            $sp_user = new StudyPressUserWP();
            add_user_meta($sp_user->id(), 'sp_menu_add_warning_migrate', true, true);
        }
    }
}
Esempio n. 4
0
            $v->addRule('file', 'numeric', true, 1, 99999, true);
        }
        if (isset($_POST['lesson']['courseId']) && !empty($_POST['lesson']['courseId'])) {
            $v->addRule('courseId', 'numeric', true, 1, 99999, true);
        } else {
            $v->errors['courseId'] = $tr->__("You must create a course");
        }
        $v->run();
        if (sizeof($v->errors) > 0) {
            $error_lesson_add = $v->getMessageErrors();
        } else {
            $currentUser = new StudyPressUserWP();
            $id_lesson = $managerLesson->add(new Lesson(array('pictureUrl' => isset($v->sanitized['pictureurl']) ? $v->sanitized['pictureurl'] : '', 'name' => $v->sanitized['name'], 'author' => $currentUser->displayName(), 'authorId' => $currentUser->id(), 'courseId' => $v->sanitized['courseId'])));
            if (isset($v->sanitized['file']) && !empty($v->sanitized['file'])) {
                $urlFile = wp_get_attachment_url($v->sanitized['file']);
                $managerSlide = new SlideManager();
                $slide = new Slide(array('courseId' => $id_lesson, 'name' => $tr->__("Download the file"), 'content' => "<a href='" . $urlFile . "'>" . basename($urlFile, pathinfo($urlFile, PATHINFO_EXTENSION)) . "</a>"));
                $managerSlide->add($slide);
                $lesson = $managerLesson->getById($id_lesson);
                $postId = $managerLesson->post($lesson);
                $permalink = get_permalink($postId);
                $action = $lesson->getAuthor() . " " . $tr->__("shared a lesson") . " : " . "<a href='{$permalink}'>" . $lesson->getName() . "</a>";
                $imageUrl = $lesson->getPicture();
                $content = "<a href='{$permalink}'><img src='{$imageUrl}' width='150' height='150' /></a>";
                $managerLesson->shareOnGroupsBP($lesson, $action, $content);
            }
        }
    }
}
/*
|---------------------------------------------------------------------
Esempio n. 5
0
<?php

$this->breadcrumbs = array(SlideManager::label(2), Yii::t('app', 'Index'));
$this->menu = array(array('label' => Yii::t('app', 'Create') . ' ' . SlideManager::label(), 'url' => array('create')), array('label' => Yii::t('app', 'Manage') . ' ' . SlideManager::label(2), 'url' => array('admin')));
?>

<h1><?php 
echo GxHtml::encode(SlideManager::label(2));
?>
</h1>

<?php 
$this->widget('zii.widgets.CListView', array('dataProvider' => $dataProvider, 'itemView' => '_view'));
 public function actionAdmin()
 {
     $model = new SlideManager('search');
     $model->unsetAttributes();
     if (isset($_GET['SlideManager'])) {
         $model->setAttributes($_GET['SlideManager']);
     }
     $this->render('admin', array('model' => $model));
 }
Esempio n. 7
0
        $v = new validation();
        $v->addSource($_POST);
        $v->AddRules(array('id_lesson' => array('type' => 'numeric', 'required' => 'true', 'min' => '1', 'max' => '999999', 'trim' => 'true'), 'note' => array('type' => 'string', 'required' => 'true', 'min' => '1', 'max' => '200', 'trim' => 'true')));
        $v->run();
        if (sizeof($v->errors) > 0) {
            header("HTTP/1.0 400 Bad Request");
            echo $v->getMessageErrors();
        } else {
            $lesson = $managerLesson->getById($v->sanitized['id_lesson']);
            $notes = $lesson->getTags();
        }
    }
}
if (isset($_POST['type']) && $_POST['type'] === "order-slide") {
    if (isset($_POST['order']) && !empty($_POST['order'])) {
        $managerSlide = new SlideManager();
        $v = new validation();
        $v->addSource($_POST['order']);
        foreach ($_POST['order'] as $key => $value) {
            if (preg_match('/^[0-9]{1,}$/', $key)) {
                $v->addRule($key, 'numeric', true, 1, 9999999, true);
            }
        }
        $v->run();
        if (sizeof($v->errors) > 0) {
            header("HTTP/1.0 400 Bad Request");
            echo $v->getMessageErrors();
        } else {
            $re = array();
            foreach ($v->sanitized as $ordre => $id) {
                $re[$id] = $ordre + 1;