public function actionAjaxGetChannels()
 {
     $pointId = Yii::app()->request->getPost('pointId');
     $pointDateStr = date('Y-m-d');
     $requestTime = date('H:i:s');
     $pointDatetimeStr = $pointDateStr . " 23:59:59";
     $pointDateTimestamp = strtotime($pointDateStr);
     $weekDay = strtolower(date('D', $pointDateTimestamp));
     $Playlist = new Playlists();
     $pointChannels = Channel::model()->findAll('id_point=:id_point AND window_id IS NOT NULL', array(':id_point' => $pointId));
     $resp = array();
     foreach ($pointChannels as $pointChannel) {
         $pointChannelId = $pointChannel->internalId;
         $windowId = $pointChannel->window_id;
         if (!is_null($windowId)) {
             $bg = $Playlist->GetBGContentArr($pointId, $pointChannelId, $pointDatetimeStr, $weekDay);
             $adv = $Playlist->GetAdvContentArr($pointId, $pointChannelId, $pointDatetimeStr, $weekDay);
             $blockStructedContent = $Playlist->BuildBlockStructedContent($bg, $adv);
             $straightTimeContent = $Playlist->ConverBlockStructedToStraightTimeContent($blockStructedContent);
             $straightTimeContentHisToSecs = $this->ConvertHisToSecsInStraightTime($straightTimeContent, $requestTime);
             $url = Yii::app()->request->getBaseUrl(true) . '/spool/points/' . $pointId . '/' . $pointChannelId;
             $straightTimeContentWithURLPath = $this->UpdateContentPathes($straightTimeContentHisToSecs, $url);
             $window = Window::model()->findByPK($windowId);
             $widgetToChannel = WidgetToChannel::model()->find("channel_id = :channel_id", array("channel_id" => $pointChannel->id));
             $widget = '';
             if (count($widgetToChannel) > 0) {
                 $widgetModel = Widget::model()->findByPk($widgetToChannel['widget_id']);
                 $widget = $widgetModel['content'];
             }
             $resp[] = array('width' => $window->width, 'height' => $window->height, 'top' => $window->top, 'left' => $window->left, 'content' => $straightTimeContentWithURLPath, 'widget' => $widget);
         }
     }
     echo json_encode($resp);
     exit;
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Screen'])) {
         $model->attributes = $_POST['Screen'];
         if ($model->save()) {
             if (isset($_POST['Blocks'])) {
                 $blocks = $_POST['Blocks'];
                 Window::model()->deleteAllByAttributes(array('screen_id' => $model->id));
                 foreach ($blocks as $name => $block) {
                     $windowModel = new Window();
                     $windowParams = explode(",", $block);
                     $window = array('screen_id' => $model->id, 'name' => $name, 'height' => $windowParams[1], 'width' => $windowParams[0], 'top' => $windowParams[3], 'left' => $windowParams[2], 'authorId' => Yii::app()->user->getId());
                     $windowModel->attributes = $window;
                     $windowModel->save();
                 }
             }
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $windows = Window::model()->findAllByAttributes(array('screen_id' => $model->id));
     $this->render('update', array('model' => $model, 'windows' => $windows));
 }
示例#3
0
foreach ($screens as $val) {
    $dropDown[$val->id] = $val->name;
}
if (!$model->isNewRecord) {
    $screenId = $model->screen_id;
    $selectedItems[$screenId] = array('selected' => 'selected');
}
echo $form->dropDownList($model, 'screen_id', $dropDown, array('options' => $selectedItems, 'multiple' => false, 'class' => 'form-control', 'size' => '10'));
printf("<div id='windowsList'>");
if (!$model->isNewRecord) {
    $screenId = $model->screen_id;
    $screen = Screen::model()->findByPk($screenId);
    $windows = $screen->windows;
    foreach ($windows as $window) {
        $windowId = $window->id;
        $windowInst = Window::model()->findByPk($windowId);
        $windowName = $windowInst->name;
        $channels = $windowInst->netChannels;
        foreach ($channels as $channel) {
            if ($channel->net_id == $model->id) {
                printf("<div class='ChannelsContainer btn-toolbar' data-channelid='%s' role='toolbar' aria-label=''>", $channel['id']);
                $channelM = NetChannel::model()->findByPk($channel['id']);
                $pls = $channelM->playlists;
                printf("<div class='btn-group' role='group' aria-label=''>" . "<button type='button' class='btn btn-default ChannelButt' disabled='disabled'>Screen %s</button>" . "<button type='button' class='AddPlaylistsBut btn btn-info' data-channelid='%s'>" . "<span class='glyphicon glyphicon-plus'></span> Add playlists" . "</button></div>", $windowName, $channel['id']);
                foreach ($pls as $pl) {
                    echo "<div class='btn-group' role='group' aria-label=''>";
                    printf("<button type='button' class='PlaylistLinks btn btn-default' " . "data-plid='%s'>%s</button>", $pl['id'], CHtml::link($pl['name'], array('playlists/' . $pl['id'])));
                    printf("<button type='button' class='RemovePlaylist btn btn-danger' " . "data-plidtoremove='%s' " . "data-channelidpltoremove='%s' " . ">x</button>", $pl['id'], $channel['id']);
                    echo "</div>";
                }
                echo "</div>";