public function actionAdd() { global $arr_response; $model = new Subject(); $model->scenario = 'add'; $_REQUEST['content_type_id'] = ContentType::model()->find('name=:name', array(':name' => $_REQUEST['content_type']))->id; $_REQUEST['country_id'] = Country::model()->find('code=:code', array(':code' => $_REQUEST['country_code']))->id; $_REQUEST['priority_id'] = Priority::model()->find('name=:name', array(':name' => $_REQUEST['priority']))->id; if ($_REQUEST['time']) { if (date("l", $_REQUEST['time'])) { //if its a valid timestamp $_REQUEST['user_position_ymd'] = date("Y", $_REQUEST['time']) . "/" . date("m", $_REQUEST['time']) . "/" . date("d", $_REQUEST['time']); $_REQUEST['user_position_hour'] = date("H", $_REQUEST['time']); $_REQUEST['user_position_minute'] = date("i", $_REQUEST['time']); } } else { $_REQUEST['user_position_anydatetime'] = 1; } $model->attributes = $_REQUEST; //NOTICE that we are creating a new record, so model its not loaded, ($model->content_type its juest the received $_REQUEST parameter) //print_r($model); //$model->content_type_id = $content_type->id; if ($model->save()) { $arr_response['response_message'] = Yii::t('subject', 'Subject successfully saved.'); } else { $arr_response['response_code'] = 409; $arr_response['response_message'] = Yii::t('subject', 'Subject could not be saved.'); $arr_response['response_details'] = $model->getErrors(); } }
echo $form->labelEx($model, 'title'); ?> <?php echo $form->textField($model, 'title', array('size' => 60, 'maxlength' => 250)); ?> <?php echo $form->error($model, 'title'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'content_type_id'); ?> <?php echo $form->DropDownList($model, 'content_type_id', CHtml::listData(ContentType::model()->findAll(array('condition' => "name <> 'text'")), 'id', 'name'), array('prompt' => 'Select Type', 'disabled' => Yii::app()->controller->action->id == 'update')); ?> <?php echo $form->error($model, 'content_type_id'); ?> </div> <div class="row"> <label><?php echo Yii::t('subject', 'Image source'); ?> </label> <?php echo $form->DropDownList($model, 'image_source', array('0' => Yii::t('subject', 'My Computer'), '1' => Yii::t('subject', 'Link or URL'))); ?>
} ///function bind_click_positions(){ $(".set_position").live('click', function(){ var id = $(this).html(); $.fn.yiiGridView.update("subject-grid", {url:"",data:{"id":id, "day":$("#Subject_Position_day_"+id).val() ,"hour":$("#Subject_Position_hour_"+id).val(), "minute":$("#Subject_Position_minute_"+id).val() } }); }); //} //Auto update the grid timeboard every subject change interval function refresh_timeboard() { $.fn.yiiGridView.update("subject-grid", {url:""}); //self.setInterval("refresh_timeboard()",<?php echo Yii::app()->params['subject_interval'] * 60; ?> 000); } </script> <p>Legend: <span class="row_red">RED</span> => Live NOW</p> <?php $dataProvider = $model->search('t.position ASC'); $dataProvider->pagination->pageSize = 30; $this->widget('zii.widgets.grid.CGridView', array('id' => 'subject-grid', 'dataProvider' => $dataProvider, 'filter' => $model, 'rowCssClass' => 'something', 'columns' => array(array('name' => 'id', 'id' => $live_subject["subject_id"] . '_' . $live_subject["subject_id_2"], 'type' => 'html', 'value' => '"<div class=\\"set_position\\" onClick=\\"\\">".$data->id."</div>"', 'headerHtmlOptions' => array('width' => '25px'), 'cssClassExpression' => '($data->id == substr($this->id, 0, strpos($this->id, "_"))) ? row_red : something', 'sortable' => true), array('name' => 'position', 'header' => 'Position Da/Ho/Mi', 'filter' => '', 'type' => 'raw', 'value' => 'CHtml::DropDownList("Subject_Position_day_".$data->id, date("j",$data->position), SiteLibrary::get_time_intervals("day")) . CHtml::DropDownList("Subject_Position_hour_".$data->id, date("G",$data->position), SiteLibrary::get_time_intervals("hour")). CHtml::DropDownList("Subject_Position_minute_".$data->id, date("i",$data->position), SiteLibrary::get_time_intervals("minute"))', 'headerHtmlOptions' => array('width' => '175px'), 'sortable' => true), array('name' => 'user_position', 'header' => 'User Position', 'type' => 'raw', 'value' => '($data->user_position) ? date("d",$data->user_position) . " " . date("H",$data->user_position) ." ". date("i",$data->user_position) : "-- -- --"'), array('name' => 'manager_position', 'header' => 'Manager Position', 'type' => 'raw', 'value' => '($data->manager_position) ? date("d",$data->manager_position) . " " . date("H",$data->manager_position) ." ". date("i",$data->manager_position) : "-- -- --"'), array('name' => 'user_id', 'type' => 'html', 'value' => 'CHtml::link(User::model()->findByPk($data->user_id)->username,Yii::app()->getRequest()->getBaseUrl(true)."/mysub/".User::model()->findByPk($data->user_id)->username)', 'filter' => '', 'headerHtmlOptions' => array('width' => '25px'), 'sortable' => true), array('name' => 'country_id', 'value' => '$data->country->name', 'filter' => CHtml::listData(Country::model()->findAll(), 'id', 'name'), 'sortable' => true), array('name' => 'category', 'filter' => CHtml::listData(Yii::app()->db->createCommand()->select('name')->from('subject_category')->queryAll(), 'name', 'name'), 'sortable' => true), array('name' => 'title', 'headerHtmlOptions' => array('width' => '200px'), 'type' => 'html', 'value' => 'CHtml::link($data->title,Yii::app()->getRequest()->getBaseUrl(true)."/sub/".$data->urn)'), array('name' => 'priority_id', 'value' => '$data->priority_type->name', 'headerHtmlOptions' => array('width' => '50px'), 'filter' => CHtml::listData(Priority::model()->findAll(), 'id', 'name'), 'sortable' => true), array('name' => 'content_type_id', 'value' => '$data->content_type->fullname', 'headerHtmlOptions' => array('width' => '50px'), 'filter' => CHtml::listData(ContentType::model()->findAll(), 'id', 'name'), 'sortable' => true), array('name' => 'time_submitted', 'value' => 'date("Y/m/d H:i", $data->time_submitted)', 'headerHtmlOptions' => array('width' => '100px'), 'sortable' => true)), 'enablePagination' => true));
public function actionInfo() { // Available contents $contents = ContentType::model()->findAll(); $vars = array('contents' => $contents); $this->render('info', $vars); }
<?php $this->breadcrumbs = array('Subjects' => array('index'), 'Manage'); $this->menu = array(array('label' => 'List Subject', 'url' => array('index')), array('label' => 'Create Subject', 'url' => array('add'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('subject-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1>Manage Subjects</h1> <p> You may optionally enter a comparison operator (<b><</b>, <b><=</b>, <b>></b>, <b>>=</b>, <b><></b> or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done. </p> <?php echo CHtml::link('Advanced Search', '#', array('class' => 'search-button')); ?> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <p>Legend: <span class="row_red">RED</span> => Live NOW</p> <?php $dataProvider = $model->search(); $dataProvider->pagination->pageSize = 50; $this->widget('zii.widgets.grid.CGridView', array('id' => 'subject-grid', 'dataProvider' => $dataProvider, 'filter' => $model, 'rowCssClass' => 'something', 'columns' => array(array('name' => 'id', 'id' => $live_subject["subject_id"] . '_' . $live_subject["subject_id_2"], 'value' => '$data->id', 'headerHtmlOptions' => array('width' => '25px'), 'cssClassExpression' => '($data->id == substr($this->id, 0, strpos($this->id, "_"))) ? row_red : something', 'sortable' => true), array('name' => 'user_id', 'type' => 'html', 'value' => 'CHtml::link($data->user->username,Yii::app()->getRequest()->getBaseUrl(true)."/mysub/".$data->user->username)', 'filter' => '', 'headerHtmlOptions' => array('width' => '25px'), 'sortable' => true), array('name' => 'country_id', 'value' => '$data->country->name', 'filter' => CHtml::listData(Country::model()->findAll(), 'id', 'name'), 'sortable' => true), array('name' => 'category', 'filter' => CHtml::listData(Yii::app()->db->createCommand()->select('name')->from('subject_category')->queryAll(), 'name', 'name'), 'sortable' => true), array('name' => 'title', 'headerHtmlOptions' => array('width' => '410px')), array('name' => 'priority_id', 'value' => '$data->priority_type->name', 'headerHtmlOptions' => array('width' => '50px'), 'filter' => CHtml::listData(Priority::model()->findAll(), 'id', 'name'), 'sortable' => true), array('name' => 'content_type_id', 'value' => '$data->content_type->fullname', 'headerHtmlOptions' => array('width' => '50px'), 'filter' => CHtml::listData(ContentType::model()->findAll(), 'id', 'name'), 'sortable' => true), array('name' => 'time_submitted', 'value' => 'date("Y/m/d H:i", $data->time_submitted)', 'headerHtmlOptions' => array('width' => '100px'), 'sortable' => true), array('name' => 'approved', 'type' => 'html', 'value' => 'CHtml::link(SiteHelper::yesno($data->approved),"moderate/".$data->id)', 'headerHtmlOptions' => array('width' => '20px'), 'filter' => array('0' => 'No', '1' => 'Yes'), 'sortable' => true), array('name' => 'authorized', 'type' => 'html', 'value' => 'CHtml::link(SiteHelper::yesno($data->authorized),"authorize/".$data->id)', 'headerHtmlOptions' => array('width' => '20px'), 'filter' => array('0' => 'No', '1' => 'Yes'), 'sortable' => true), array('name' => 'disabled', 'value' => 'SiteHelper::yesno($data->disabled)', 'headerHtmlOptions' => array('width' => '20px'), 'filter' => array('0' => 'No', '1' => 'Yes'), 'sortable' => true), array('name' => 'deleted', 'value' => 'SiteHelper::yesno($data->deleted)', 'headerHtmlOptions' => array('width' => '20px'), 'filter' => array('0' => 'No', '1' => 'Yes'), 'sortable' => true)), 'enablePagination' => true));
<?php Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('subject-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1><?php echo Yii::t('subject', 'Subjects History'); ?> </h1> <p> <?php echo Yii::t('subject', 'The following list shows all the subjects that has been placed in the live stream(homepage). Note that the time is in UTC.'); ?> </p> <?php $dataProvider = $model->search('show_time DESC'); $dataProvider->pagination->pageSize = 50; $this->widget('zii.widgets.grid.CGridView', array('id' => 'subject-grid', 'dataProvider' => $dataProvider, 'filter' => $model, 'rowCssClass' => 'something', 'columns' => array(array('name' => 'show_time', 'value' => 'date("Y/m/d H:i", $data->show_time)." UTC"', 'headerHtmlOptions' => array('width' => '120px'), 'filter' => '', 'sortable' => true), array('name' => 'user_id', 'type' => 'html', 'value' => 'CHtml::link($data->user->username,Yii::app()->getRequest()->getBaseUrl(true)."/mysub/".$data->user->username)', 'filter' => CHtml::textField('Subject[username]', $model->username), 'headerHtmlOptions' => array('width' => '90px'), 'sortable' => true), array('name' => 'priority_id', 'value' => '$data->priority_type->name', 'headerHtmlOptions' => array('width' => '50px'), 'filter' => CHtml::listData(Priority::model()->findAll(), 'id', 'name'), 'sortable' => true), array('name' => 'content_type_id', 'value' => '$data->content_type->fullname', 'headerHtmlOptions' => array('width' => '50px'), 'filter' => CHtml::listData(ContentType::model()->findAll(), 'id', 'name'), 'sortable' => true), array('name' => 'country_id', 'value' => '$data->country->name', 'headerHtmlOptions' => array('width' => '100px'), 'filter' => CHtml::listData(Country::model()->findAll(), 'id', 'name'), 'sortable' => true), array('name' => 'category', 'filter' => CHtml::listData(Yii::app()->db->createCommand()->select('name')->from('subject_category')->queryAll(), 'name', 'name'), 'sortable' => true), array('header' => Yii::t('subject', 'Search'), 'name' => 'title', 'type' => 'html', 'value' => 'CHtml::link($data->title,Yii::app()->getRequest()->getBaseUrl(true)."/sub/".$data->urn)')), 'enablePagination' => true));