Ejemplo n.º 1
0
 public function actionList()
 {
     $title = 'Sản phẩm';
     $criteria = new CDbCriteria(array('condition' => 'status<>0', 'order' => 'count_buy DESC'));
     if ($_GET['catid']) {
         $criteria->addCondition('`cat_id` =' . $_GET['catid']);
         $term = Term::model()->findByPk($_GET['catid']);
         $title = $term->name;
     }
     $dataProvider = new CActiveDataProvider('Product', array('pagination' => array('pageSize' => Yii::app()->params['itemsPerPage']), 'criteria' => $criteria));
     $thuongHieu = Term::model()->findAll('vid=7');
     $thItems = array();
     if ($thuongHieu) {
         foreach ($thuongHieu as $thItem) {
             $thItems[] = array('title' => $thItem['name'], 'value' => $thItem['id'], 'checked' => false);
         }
     }
     $cat = Term::model()->findAll('vid=6');
     $catItems = array();
     if ($cat) {
         foreach ($cat as $thItem) {
             $catItems[] = array('title' => $thItem['name'], 'value' => $thItem['id'], 'checked' => false);
         }
     }
     $this->render('list', array('items' => $dataProvider, 'title' => $title, 'thItems' => $thItems, 'catItems' => $catItems));
 }
Ejemplo n.º 2
0
 protected function renderContent()
 {
     $extra = '';
     if (isset($_GET['c'])) {
         $url = array('/song/index', 'c' => $_GET['c']);
     } else {
         $url = array('/song/index');
     }
     $terms = Term::model()->findAll('vid = 4');
     $menuItems[] = array('label' => 'Tất cả', 'url' => $url, 'active' => !isset($_GET['c']) && !isset($_GET['tid']) ? true : false);
     foreach ($terms as $term) {
         if (isset($_GET['c'])) {
             $url = array('/song/index', 'tid' => $term->id, 'c' => $_GET['c']);
         } else {
             $url = array('/song/index', 'tid' => $term->id);
         }
         $menuItems[] = array('label' => $term->name, 'url' => $url);
     }
     $this->widget('zii.widgets.CMenu', array('items' => $menuItems, 'activateItems' => true));
 }
Ejemplo n.º 3
0
 protected function renderContent()
 {
     /*$items = array(
           array('label' => 'Tất cả', 'url' => array('video/index')),
           array('label' => 'Mới nhất', 'url' => array('video/list', 'filter' => 'latest')),
           array('label' => 'Xem nhiều nhất', 'url' => array('video/list', 'filter' => 'top_view')),
           array('label' => 'Bình chọn nhiều nhất', 'url' => array('video/list', 'filter' => 'top_like')),
       );*/
     $terms = Term::model()->findAll('vid = 2 AND parent = 0');
     foreach ($terms as $term) {
         $item = array('label' => $term->name, 'url' => array('video/catlist', 'catid' => $term->id, 'catname' => Lnt::safeTitle($term->name)));
         $items[] = $item;
         $subTerms = Term::model()->findAll('vid = 2 AND parent = ' . $term->id);
         if ($subTerms) {
             foreach ($subTerms as $sTerm) {
                 $items[] = array('itemOptions' => array('class' => 'sub'), 'label' => $sTerm->name, 'url' => array('video/catlist', 'catid' => $sTerm->id, 'catname' => Lnt::safeTitle($sTerm->name)));
             }
         }
     }
     echo "<div style='margin: 10px 0px;color: #000000;\n    font-weight: bold;\n    text-align: left;\n    text-transform: uppercase;'>Danh mục</div>";
     $this->widget('zii.widgets.CMenu', array('items' => $items, 'activateItems' => true));
 }
Ejemplo n.º 4
0
 protected function renderContent()
 {
     $id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
     $model = GxcHelpers::loadDetailModel('Taxonomy', $id);
     //The type of the content we want to create
     $type = $model->type;
     //Guid of the Object
     $guid = $model->guid;
     //List of language that should exclude not to translate
     $lang_exclude = array();
     //List of translated versions
     $versions = array();
     $list_items = array();
     //Look for the Term Items belong to this Taxonomy
     $list_terms = Term::model()->findAll(array('select' => '*', 'condition' => 'taxonomy_id=:id', 'order' => 't.parent ASC, t.order ASC, t.term_id ASC', 'params' => array(':id' => $id)));
     if ($list_terms) {
         foreach ($list_terms as $term) {
             $temp_item['id'] = $term->term_id;
             $temp_item['name'] = CHtml::encode($term->name);
             $temp_item['parent'] = $term->parent;
             //Add Item here to make sure Chrome not change the order of Json Object
             $list_items['item_' . $term->term_id] = $temp_item;
         }
     }
     // if it is ajax validation request
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'taxonomy-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     // collect user input data
     if (isset($_POST['Taxonomy'])) {
         $model->attributes = $_POST['Taxonomy'];
         if ($model->save()) {
             user()->setFlash('success', t('cms', 'Update Taxonomy Successfully!'));
         }
     }
     $this->render('cmswidgets.views.taxonomy.taxonomy_form_widget', array('model' => $model, 'lang_exclude' => $lang_exclude, 'versions' => $versions, 'type' => $type, 'list_items' => $list_items));
 }
Ejemplo n.º 5
0
        <?php 
/*        //echo $form->textField($model, 'file_path', array('maxlength' => 255));
    echo $form->fileField($model, 'file_path');
    */
?>
        <?php 
/*echo $form->error($model, 'file_path'); */
?>
    </div>-->
    <!-- row -->
    <div class="row">
        <?php 
echo $form->labelEx($model, 'term_id');
?>
        <?php 
echo $form->dropDownList($model, 'term_id', GxHtml::listDataEx(Term::model()->findAllAttributes(null, true, 'vid=2')));
?>
        <?php 
echo $form->error($model, 'term_id');
?>
    </div>
    <!-- row -->
    <div class="row">
        <?php 
echo $form->labelEx($model, 'teacher_id');
?>
        <?php 
echo $form->dropDownList($model, 'teacher_id', GxHtml::listDataEx(Teacher::model()->findAllAttributes(null, true)));
?>
        <?php 
echo $form->error($model, 'teacher_id');
Ejemplo n.º 6
0
<?php

$this->breadcrumbs = array("Hợp âm");
$this->menu = array(array('label' => 'Danh sách', 'url' => array('admin')), array('label' => 'Tạo mới', 'url' => array('create')));
?>

<h1><?php 
echo "Quản lý hợp âm";
?>
</h1>


<?php 
function getLyricLink($hopam)
{
    return CHtml::link("Download", Yii::app()->createUrl('hopam/download', array('path' => $hopam->lyrics)));
}
$this->widget('zii.widgets.grid.CGridView', array('id' => 'hopam-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'id', 'htmlOptions' => array('width' => '5%')), 'title', array('name' => 'lyrics', 'value' => 'getLyricLink($data)', 'type' => 'html', 'htmlOptions' => array('width' => '5%'), 'filter' => false), array('name' => 'tid', 'value' => 'GxHtml::valueEx($data->t)', 'filter' => GxHtml::listDataEx(Term::model()->findAllAttributes(null, true, 'vid=3'))), array('name' => 'view', 'htmlOptions' => array('width' => '10%')), array('name' => 'ban_artist'), array('class' => 'CButtonColumn', 'template' => '{update}{delete}'))));
Ejemplo n.º 7
0
 protected function renderContent()
 {
     //Get some pre value from URL
     //The type of the content we want to create
     $type = isset($_GET['type']) ? strtolower(trim($_GET['type'])) : '';
     //If it has guid, it means this is a translated version
     $guid = isset($_GET['guid']) ? strtolower(trim($_GET['guid'])) : '';
     //Get the list of Content Type
     $types = GxcHelpers::getAvailableContentType();
     //List of language that should exclude not to translate
     $lang_exclude = array();
     //List of translated versions
     $versions = array();
     //Available Terms for this Object Type
     $terms = array();
     //Selected Terms
     $selected_terms = array();
     //Get Term Order
     $term_orders = ConstantDefine::getTermOrder();
     //If $type is empty then redirect to choose content type page
     if ($type != '') {
         //Check if the type appear in content type Definition
         if (array_key_exists($type, $types)) {
             // If the guid is not empty, it means we are creating a translated version of a content
             // We will exclude the translated language and include the name of the translated content to $versions
             if ($guid != '') {
                 $temp_object = Object::model()->findAll('guid=:gid', array(':gid' => $guid));
                 if (count($temp_object) > 0) {
                     foreach ($temp_object as $obj) {
                         $lang_exclude[] = $obj->lang;
                         $langs = GxcHelpers::getAvailableLanguages();
                         $versions[] = $obj->object_name . ' - ' . $langs[$obj->lang]['name'];
                     }
                 }
             }
             //Import the Content Type Class
             Yii::import('common.content_type.' . $type . '.' . $types[$type]['class']);
             //Init the class
             $typeClassObj = new $types[$type]['class']();
             $content_resources = $typeClassObj->Resources();
             //We start to implement the checking Permission HERE
             $param_content_check = array();
             $data_content_check = array();
             $param_content_check['type'] = $type;
             if (GxcContentPermission::checkCreatePermission($param_content_check, $data_content_check, $typeClassObj->Permissions())) {
                 $param_content_check['new_content'] = true;
                 $content_status = GxcContentPermission::getContentStatus($param_content_check, $data_content_check, $typeClassObj->Permissions());
                 $model = new $types[$type]['class']();
                 // Uncomment the following line if AJAX validation is needed
                 // $this->performAjaxValidation($model);
                 $model->object_date = date('Y-m-d H:i:s');
                 $model->person = '';
                 $model->guid = $guid;
                 $get_languages = GxcHelpers::loadLanguageItems($lang_exclude);
                 $available_languages = array();
                 foreach ($get_languages as $key => $value) {
                     $available_languages[] = $key;
                 }
                 //Get available Taxonomy and Terms for this Object
                 $available_taxonomy = Taxonomy::model()->findAll(' type = :type AND lang IN (' . implode(',', $available_languages) . ') ', array(':type' => $type));
                 if ($available_taxonomy) {
                     foreach ($available_taxonomy as $t) {
                         $temp = array();
                         $temp['id'] = $t->taxonomy_id;
                         $temp['lang'] = $t->lang;
                         $temp['name'] = $t->name;
                         $temp['terms'] = array();
                         //Look for the Term Items belong to this Taxonomy
                         $list_terms = Term::model()->findAll(array('select' => '*', 'condition' => 'taxonomy_id=:id', 'order' => 't.parent ASC, t.order ASC', 'params' => array(':id' => $t->taxonomy_id)));
                         if ($list_terms) {
                             foreach ($list_terms as $term) {
                                 $temp_item['id'] = $term->term_id;
                                 $temp_item['name'] = CHtml::encode($term->name);
                                 $temp_item['parent'] = $term->parent;
                                 $temp['terms']['item_' . $term->term_id] = $temp_item;
                             }
                         }
                         $terms[$t->taxonomy_id] = $temp;
                     }
                 }
                 if (isset($_POST[$types[$type]['class']])) {
                     $model->attributes = $_POST[$types[$type]['class']];
                     //Convert the date time publish to timestamp
                     $model->object_date = strtotime($model->object_date);
                     $model->object_date_gmt = local_to_gmt($model->object_date);
                     //Check which button the User click To Send to person or group
                     $button = $_POST['which_button'];
                     $trans = new Transfer();
                     // Get the Terms that the User Choose
                     //
                     $post_terms = isset($_POST['terms']) ? $_POST['terms'] : array();
                     $selected_terms = array();
                     if (!empty($post_terms)) {
                         foreach ($post_terms as $t) {
                             $t = explode('_', $t);
                             if (!isset($selected_terms[$t[1]])) {
                                 $selected_temp = array();
                                 $selected_temp['id'] = $terms[$t[1]]['id'];
                                 $selected_temp['lang'] = $terms[$t[1]]['lang'];
                                 $selected_temp['name'] = $terms[$t[1]]['name'];
                                 $selected_temp['terms']['item_' . $t[0]]['id'] = $t[0];
                                 $selected_temp['terms']['item_' . $t[0]]['name'] = $terms[$t[1]]['terms']['item_' . $t[0]]['name'];
                                 $selected_temp['terms']['item_' . $t[0]]['parent'] = $terms[$t[1]]['terms']['item_' . $t[0]]['parent'];
                                 $selected_temp['terms']['item_' . $t[0]]['data'] = $t[2];
                                 $selected_temp['terms']['item_' . $t[0]]['data_name'] = $term_orders[$t[2]];
                                 $selected_terms[$t[1]] = $selected_temp;
                             } else {
                                 if (!isset($selected_terms['terms']['item_' . $t[0]])) {
                                     $selected_terms[$t[1]]['terms']['item_' . $t[0]]['id'] = $t[0];
                                     $selected_terms[$t[1]]['terms']['item_' . $t[0]]['name'] = $terms[$t[1]]['terms']['item_' . $t[0]]['name'];
                                     $selected_terms[$t[1]]['terms']['item_' . $t[0]]['parent'] = $terms[$t[1]]['terms']['item_' . $t[0]]['parent'];
                                     $selected_terms[$t[1]]['terms']['item_' . $t[0]]['data'] = $t[2];
                                     $selected_terms[$t[1]]['terms']['item_' . $t[0]]['data_name'] = $term_orders[$t[2]];
                                 }
                             }
                         }
                     }
                     // After having the selected Terms, we need to make sure  all parents
                     // of the selected Terms must be added also
                     foreach ($selected_terms as $tx_key => $t) {
                         $array_parent_selected_terms = array();
                         foreach ($t['terms'] as $key => $st_terms) {
                             $current_term = $st_terms;
                             while ($current_term['parent'] != 0) {
                                 if (!isset($array_parent_selected_terms['item_' . $current_term['parent']]) && !isset($t['terms']['item_' . $current_term['parent']])) {
                                     $array_parent_selected_terms['item_' . $current_term['parent']] = $terms[$tx_key]['terms']['item_' . $current_term['parent']];
                                     $array_parent_selected_terms['item_' . $current_term['parent']]['data'] = key($term_orders);
                                     $array_parent_selected_terms['item_' . $current_term['parent']]['data_name'] = $term_orders[key($term_orders)];
                                 }
                                 $current_term = $terms[$tx_key]['terms']['item_' . $current_term['parent']];
                             }
                         }
                         $selected_terms[$tx_key]['terms'] = CMap::mergeArray($t['terms'], $array_parent_selected_terms);
                     }
                     //Re-Set the Status based on what User Chooose
                     //The content is sent to ROLES OR STATUS
                     if ($button == '1') {
                         //Check if the object_status is number or character
                         if (!is_numeric($model->object_status)) {
                             //Set the status to Pending
                             $trans->note = $model->object_status;
                             $model->object_status = ConstantDefine::OBJECT_STATUS_PENDING;
                             $trans->type = ConstantDefine::TRANS_ROLE;
                             $trans->after_status = ConstantDefine::OBJECT_STATUS_PENDING;
                         } else {
                             $trans->type = ConstantDefine::TRANS_STATUS;
                             $trans->after_status = $model->object_status;
                         }
                         $trans->from_user_id = user()->id;
                         $trans->to_user_id = 0;
                         $trans->before_status = ConstantDefine::OBJECT_STATUS_DRAFT;
                     }
                     //The content is sent to PERSON DIRECTLY
                     if ($button == '2') {
                         $to_user_id = User::findPeople($model->person);
                         //Start to Transfer to the user and set the status to Pending
                         if ($to_user_id) {
                             $model->object_status = ConstantDefine::OBJECT_STATUS_PENDING;
                             $trans->from_user_id = user()->id;
                             $trans->to_user_id = $to_user_id->user_id;
                             $trans->type = ConstantDefine::TRANS_PERSON;
                             $trans->before_status = ConstantDefine::OBJECT_STATUS_PENDING;
                             $trans->after_status = ConstantDefine::OBJECT_STATUS_PENDING;
                         } else {
                             $model->addError('person', t('User not found'));
                         }
                     }
                     //Work with Resource Binding
                     $resource = array();
                     $resource_upload = array();
                     foreach ($content_resources as $res) {
                         $resource_upload[] = GxcHelpers::getArrayResourceObjectBinding('resource_upload_' . $res['type']);
                     }
                     $i = 0;
                     $count_resource = 0;
                     foreach ($content_resources as $cres) {
                         $j = 1;
                         foreach ($resource_upload[$i] as $res_up) {
                             $j++;
                             $count_resource++;
                         }
                         $i++;
                     }
                     $model->total_number_resource = $count_resource;
                     if ($model->save()) {
                         user()->setFlash('success', t('cms', 'Create new Content Successfully!'));
                         $trans->object_id = $model->object_id;
                         $trans->save();
                         // We have all the selected Terms for now
                         // We will add them to Object Terms
                         foreach ($selected_terms as $tx_key => $t) {
                             foreach ($t['terms'] as $key => $st_terms) {
                                 $obj_term = new ObjectTerm();
                                 $obj_term->object_id = $model->object_id;
                                 $obj_term->term_id = $st_terms['id'];
                                 $obj_term->data = $st_terms['data'];
                                 $obj_term->save();
                                 unset($obj_term);
                             }
                         }
                         //Update Resource Binding Here
                         $i = 0;
                         $count_resource = 0;
                         foreach ($content_resources as $cres) {
                             $j = 1;
                             foreach ($resource_upload[$i] as $res_up) {
                                 $obj_res = new ObjectResource();
                                 $obj_res->resource_id = $res_up['resid'];
                                 $obj_res->object_id = $model->object_id;
                                 $obj_res->description = '';
                                 $obj_res->type = $cres['type'];
                                 $obj_res->resource_order = $j;
                                 $obj_res->save();
                                 $j++;
                                 $count_resource++;
                             }
                             $i++;
                         }
                         //Re-init new Model
                         $model = new $types[$type]['class']();
                         $model->object_date = date('Y-m-d H:i:s');
                         Yii::app()->controller->refresh();
                     } else {
                         $model->object_date = date('Y-m-d H:i:s', $model->object_date);
                     }
                 }
                 $render_template = 'cmswidgets.views.object.object_form_widget';
                 if (file_exists(Yii::getPathOfAlias('common.content_type.' . strtolower($type) . '.object_form_widget') . '.php')) {
                     $render_template = 'common.content_type.' . strtolower($type) . '.object_form_widget';
                 }
                 $this->render($render_template, array('model' => $model, 'versions' => $versions, 'lang_exclude' => $lang_exclude, 'content_status' => $content_status, 'terms' => $terms, 'selected_terms' => $selected_terms, 'type' => $type, 'content_resources' => $content_resources));
             }
         } else {
             //The type is not in Content Type Definition
             $this->render('cmswidgets.views.object.object_start_widget', array('types' => $types));
         }
     } else {
         //There is no Type in $_GET
         $this->render('cmswidgets.views.object.object_start_widget', array('types' => $types));
     }
 }
Ejemplo n.º 8
0
 public static function ReBindValueForMenuType($type, $value)
 {
     $result = '';
     switch ($type) {
         case ConstantDefine::MENU_TYPE_PAGE:
             $page = Page::model()->findByPk($value);
             if ($page) {
                 $result = $page->name;
             }
             break;
         case ConstantDefine::MENU_TYPE_TERM:
             $term = Term::model()->findByPk($value);
             if ($term) {
                 $result = $term->name;
             }
             break;
     }
     return $result;
 }
Ejemplo n.º 9
0
 protected function findNextOrder($parentId, $term)
 {
     $criteria = new CDbCriteria();
     $criteria->order = 't.ordering DESC';
     if ($parentId > 0) {
         $criteria->join = 'INNER JOIN ' . SITE_ID . '_taxonomy_term_hierarchy th ON th.term_id = t.id';
         $criteria->compare('th.parent_id', $parentId);
     } else {
         $criteria->compare('t.v_id', $term->v_id);
         $criteria->addCondition('t.id NOT IN (SELECT term_id FROM ' . SITE_ID . '_taxonomy_term_hierarchy)');
     }
     $orderModel = Term::model()->find($criteria);
     return is_object($orderModel) ? (int) $orderModel->ordering : 0;
 }
Ejemplo n.º 10
0
<?php

$this->breadcrumbs = array('Bản nhạc' => array('admin'), 'Quản lý');
$this->menu = array(array('label' => 'Danh sách', 'url' => array('admin')), array('label' => 'Tạo mới', 'url' => array('create')));
?>

<h1>Quản lý bản nhạc</h1>
<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'song-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', 'title', array('name' => 'tid', 'value' => 'GxHtml::valueEx($data->t)', 'filter' => GxHtml::listDataEx(Term::model()->findAllAttributes(null, true, 'vid=4'))), 'view', array('name' => 'ban_id', 'value' => 'GxHtml::valueEx($data->ban)', 'filter' => GxHtml::listDataEx(Ban::model()->findAllAttributes(null, true))), array('class' => 'CButtonColumn', 'template' => '{update}{delete}'))));
Ejemplo n.º 11
0
 /**
  * get root term by vocabulary id
  * 
  * @param int $type vocabulary IDs
  * 
  * @return array Term
  */
 protected function getTerms($type)
 {
     $criteria = new CDbCriteria();
     $criteria->compare('v_id', $type);
     return Term::model()->findAll($criteria);
 }
Ejemplo n.º 12
0
 public function actionCatlist()
 {
     $criteria = new CDbCriteria(array('condition' => 't.status=1', 'order' => 't.create_time DESC'));
     if (isset($_GET['catid'])) {
         $criteria->addSearchCondition('term_id', $_GET['catid']);
         /**
          * @var $cat Term
          */
         $cat = Term::model()->findByPk($_GET['catid']);
         $title = $cat->name;
         $subTerms = Term::model()->findAll('parent=' . $_GET['catid']);
         if ($subTerms) {
             $sTerms = array();
             foreach ($subTerms as $term) {
                 $sTerms[] = $term->id;
             }
             $criteria->addInCondition("term_id", $sTerms, 'OR');
         }
     } else {
         $title = 'Tất cả Video';
     }
     $dataProvider = new CActiveDataProvider('Video', array('pagination' => array('pageSize' => Yii::app()->params['postsPerPage']), 'criteria' => $criteria));
     /*if($_GET['filter']){
           $sort = new CSort();
           $sort->attributes = array(
               'linkCountSort' => array(
                   'asc' => '(SELECT count(id) FROM {like}
                    WHERE nid = t.author_id) ASC',
                   'desc' => '(SELECT count(posts.id) FROM posts
                    WHERE posts.author_id = t.author_id) DESC',
               ));
           $dataProvider->sort = $sort;
       }*/
     $this->render('list', array('dataProvider' => $dataProvider, 'title' => $title));
 }
Ejemplo n.º 13
0
        <?php 
echo $form->labelEx($model, 'province_id');
?>
        <?php 
echo $form->dropDownList($model, 'province_id', CMap::mergeArray(array(0 => 'Chọn tỉnh/tp'), GxHtml::listDataEx(Term::model()->findAllAttributes(null, true, 'vid=5 AND parent = 0'))));
?>
        <?php 
echo $form->error($model, 'province_id');
?>
    </div>
		<div class="row">
		<?php 
echo $form->labelEx($model, 'district_id');
?>
            <?php 
echo $form->dropDownList($model, 'district_id', CMap::mergeArray(array(0 => 'Chọn quận/huyện'), $model->province_id ? GxHtml::listDataEx(Term::model()->findAllAttributes(null, true, 'vid=5 AND parent = ' . $model->province_id)) : array()));
?>
		<?php 
echo $form->error($model, 'district_id');
?>
		</div><!-- row -->

		<label><?php 
//echo GxHtml::encode($model->getRelationLabel('classGuitars'));
?>
</label>
<!--		--><?php 
//echo $form->checkBoxList($model, 'classGuitars', GxHtml::encodeEx(GxHtml::listDataEx(ClassGuitar::model()->findAllAttributes(null, true)), false, true));
?>

<?php 
Ejemplo n.º 14
0
Yii::import('application.extensions.image.Image');
function getImage($image)
{
    if ($image) {
        $thumbImage = new Image(Yii::getPathOfAlias('webroot') . '/' . $image);
        $img_url = $thumbImage->createThumb(110, 70);
        return CHtml::image($img_url);
    }
}
$this->breadcrumbs = array('Sản phẩm' => array('admin'), Yii::t('app', 'Quản lý'));
$this->menu = array(array('label' => 'Danh sách', 'url' => array('admin')), array('label' => 'Tạo mới', 'url' => array('create')));
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('product-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n");
?>

<h1>Quản lý sản phẩm</h1>
<?php 
/*echo GxHtml::link(Yii::t('app', 'Tìm kiếm nâng cao'), '#', array('class' => 'search-button')); */
?>
<!--
<div class="search-form">
    <?php 
/*$this->renderPartial('_search', array(
    'model' => $model,
)); */
?>
</div><!-- search-form -->

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'product-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('title', 'code', array('name' => 'price', 'value' => 'number_format($data->price,0,",",".")." đ"'), array('name' => 'image', 'value' => 'getImage($data->image)', 'type' => 'html'), array('name' => 'cat_id', 'value' => 'GxHtml::valueEx($data->cat)', 'filter' => GxHtml::listDataEx(Term::model()->findAllAttributes(null, true, 'vid=6'))), array('name' => 'th_id', 'value' => 'GxHtml::valueEx($data->th)', 'filter' => GxHtml::listDataEx(Term::model()->findAllAttributes(null, true, 'vid=7'))), array('name' => 'status', 'value' => 'GxHtml::valueEx($data->status)', 'filter' => array('Ẩn', 'Hiện', 'Hết hàng')), array('class' => 'CButtonColumn', 'template' => '{update}{delete}'))));
Ejemplo n.º 15
0
 /**
  * get all terms of current object
  * 
  * @param int $vstate vocabulary state
  * @param int $state term state
  * @return array Term
  */
 public function getTerms($vstate = Vocabulary::STATE_ACTIVE, $state = Term::STATE_ACTIVE)
 {
     $criteria = new CDbCriteria();
     $criteria->join = "INNER JOIN " . SITE_ID . '_' . "taxonomy_vocabulary tv ON tv.id = t.v_id" . "\n INNER JOIN " . SITE_ID . '_' . "taxonomy_index ti ON ti.term_id = t.id";
     if (is_numeric($this->taxonomy)) {
         $criteria->compare('tv.id', $this->taxonomy);
     } else {
         $criteria->compare('tv.alias', $this->taxonomy);
     }
     $criteria->compare('tv.module', $this->module);
     $criteria->compare('tv.state', $vstate);
     $criteria->compare('t.state', $state);
     $objectId = (int) $this->getOwner()->{$this->objectAttribute};
     if ($objectId) {
         $criteria->compare('ti.object_id', $objectId);
     }
     return Term::model()->findAll($criteria);
 }
Ejemplo n.º 16
0
 /**
  * get property of Term
  *
  * @param int $id term ID
  * @param string $propertyClassName Class Name of property class
  *
  * @return Object|string
  */
 protected function getProperty($id, $propertyClassName)
 {
     $property = '';
     if (empty($propertyClassName) === false) {
         if ($id) {
             $property = Term::model($propertyClassName)->findByAttributes(array('term_id' => $id));
         }
         if (!isset($property) || !is_object($property)) {
             $property = new $propertyClassName();
         }
         if (isset($property->xml)) {
             $property->xml = base64_decode($property->xml);
         }
     }
     return $property;
 }
Ejemplo n.º 17
0
 public static function getTermName($id)
 {
     $term = Term::model()->findByPk($id);
     if ($term) {
         return $term->name;
     }
     return '';
 }
Ejemplo n.º 18
0
 public static function getTerms()
 {
     $terms = Term::model()->findAll();
     $result = array('0' => t('All'));
     foreach ($terms as $term) {
         $result[$term->term_id] = $term->name;
     }
     return $result;
 }
Ejemplo n.º 19
0
 /**
  * Returns the static model of the specified AR class.
  * Please note that you should have this exact method in all your CActiveRecord descendants!
  * @param string $className active record class name.
  * @return Term the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
Ejemplo n.º 20
0
	<div class="row">
		<?php 
echo $form->label($model, 'cat_id');
?>
		<?php 
echo $form->dropDownList($model, 'cat_id', GxHtml::listDataEx(Term::model()->findAllAttributes(null, true, 'vid=6')), array('prompt' => Yii::t('app', 'All')));
?>
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'th_id');
?>
		<?php 
echo $form->dropDownList($model, 'th_id', GxHtml::listDataEx(Term::model()->findAllAttributes(null, true, 'vid=7')), array('prompt' => Yii::t('app', 'All')));
?>
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'status');
?>
		<?php 
echo $form->dropDownList($model, 'status', array('Ẩn', 'Hiện', 'Hết hàng'));
?>
	</div>

	<div class="row buttons">
		<?php 
echo GxHtml::submitButton(Yii::t('app', 'Search'));
Ejemplo n.º 21
0
 protected function renderContent()
 {
     $id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
     $model = GxcHelpers::loadDetailModel('Object', $id);
     //We start to implement the checking Permission HERE
     $param_content_check = array();
     $data_content_check = array();
     $param_content_check['type'] = $model->object_type;
     $param_content_check['new_content'] = false;
     $param_content_check['content_status'] = $model->object_status;
     $param_content_check['content_author'] = $model->object_author;
     //Get current trans_to of the object
     $trans = Transfer::model()->findAll(array('condition' => ' object_id=:obj ', 'params' => array(':obj' => $model->object_id), 'order' => 'transfer_id DESC'));
     $param_content_check['check_trans_note'] = false;
     if ($trans != null && count($trans) > 0) {
         $latest_trans_to = $trans[0];
         $param_content_check['trans_type'] = $latest_trans_to->type;
         $param_content_check['trans_to'] = $latest_trans_to->to_user_id;
         $param_content_check['trans_note'] = $latest_trans_to->note;
     }
     //Get Types list and type of the Object
     $types = GxcHelpers::getAvailableContentType();
     $type = (string) $model->object_type;
     //Import the Content Type Class
     Yii::import('common.content_type.' . $type . '.' . $types[$type]['class']);
     $typeClassObj = new $types[$type]['class']();
     $content_resources = $typeClassObj->Resources();
     //Check if the User has the Permission to update the Content
     if (GxcContentPermission::checkUpdatePermission($param_content_check, $data_content_check, $typeClassObj->Permissions())) {
         //Convert the object date from timestamp to datetime format
         $model->object_date = date('Y-m-d H:i:s', $model->object_date);
         //Get available content Status that the Object can be sent to
         $content_status = GxcContentPermission::getContentStatus($param_content_check, $data_content_check, $typeClassObj->Permissions());
         //If the Object is Pending and being sent to someone, get that person info
         if ($model->object_status == ConstantDefine::OBJECT_STATUS_PENDING) {
             if ($latest_trans_to->type == ConstantDefine::TRANS_PERSON) {
                 $send_to_user = User::model()->findbyPk($latest_trans_to->to_user_id);
                 if ($send_to_user == null) {
                     $model->person = '';
                 } else {
                     $model->person = trim($send_to_user->display_name);
                 }
             }
         }
         //Unset value for Lang Exclude, Version and Guid when updating
         $lang_exclude = array();
         $versions = array();
         $guid = $model->guid;
         // Create new instance Object based on Object Type
         $object = new $types[$type]['class']();
         $object->person = $model->person;
         $object->setAttributes($model->attributes, false);
         // Get Extra Info - Object Meta of the Object Type
         $object_metas = ObjectMeta::model()->findAll('meta_object_id = :obj ', array(':obj' => $model->object_id));
         foreach ($object_metas as $object_meta) {
             $key = (string) $object_meta->meta_key;
             $object->{$key} = $object_meta->meta_value;
         }
         // This is not a new Record
         $object->isNewRecord = false;
         //Set current tags for Object
         $object->_oldTags = $object->tags;
         $object->scenario = 'updateWithTags';
         //Available Terms for this Object Type
         $terms = array();
         //Selected Terms
         $selected_terms = array();
         //Get Term Order
         $term_orders = ConstantDefine::getTermOrder();
         //Get available Taxonomy and Terms for this Object
         $available_taxonomy = Taxonomy::model()->findAll(' type = :type AND lang IN (' . $object->lang . ') ', array(':type' => $type));
         if ($available_taxonomy) {
             foreach ($available_taxonomy as $t) {
                 $temp = array();
                 $temp['id'] = $t->taxonomy_id;
                 $temp['lang'] = $t->lang;
                 $temp['name'] = $t->name;
                 $temp['terms'] = array();
                 $selected_temp = array();
                 $selected_temp['id'] = $t->taxonomy_id;
                 $selected_temp['lang'] = $t->lang;
                 $selected_temp['name'] = $t->name;
                 $selected_temp['terms'] = array();
                 //Look for the Term Items belong to this Taxonomy
                 $list_terms = Term::model()->findAll(array('select' => '*', 'condition' => 'taxonomy_id=:id', 'order' => 't.parent ASC, t.order ASC', 'params' => array(':id' => $t->taxonomy_id)));
                 if ($list_terms) {
                     foreach ($list_terms as $term) {
                         $temp_item['id'] = $term->term_id;
                         $temp_item['name'] = CHtml::encode($term->name);
                         $temp_item['parent'] = $term->parent;
                         $temp['terms']['item_' . $term->term_id] = $temp_item;
                     }
                 }
                 $terms[$t->taxonomy_id] = $temp;
                 //Look for selected Terms belong to this Taxonomy
                 $sl_terms = ObjectTerm::model()->findAll(array('select' => '*', 'condition' => 'object_id=:id', 'params' => array(':id' => $object->object_id)));
                 if ($sl_terms) {
                     foreach ($sl_terms as $sl_term) {
                         if (isset($terms[$t->taxonomy_id]['terms']['item_' . $sl_term->term_id])) {
                             $selected_temp['terms']['item_' . $sl_term->term_id] = $terms[$t->taxonomy_id]['terms']['item_' . $sl_term->term_id];
                             $selected_temp['terms']['item_' . $sl_term->term_id]['data'] = $sl_term->data;
                             $selected_temp['terms']['item_' . $sl_term->term_id]['data_name'] = $term_orders[$sl_term->data];
                         }
                     }
                 }
                 $selected_terms[$t->taxonomy_id] = $selected_temp;
             }
         }
         //IF having the Post Method - Start to working to save it
         if (isset($_POST[$types[$type]['class']])) {
             $object->attributes = $_POST[$types[$type]['class']];
             //Convert the date time publish to timestamp
             $object->object_date = strtotime($object->object_date);
             $object->object_date_gmt = local_to_gmt($object->object_date);
             //Check which button the User click To Send to person or group
             $button = $_POST['which_button'];
             $trans = new Transfer();
             // Get the Terms that the User Choose
             $post_terms = isset($_POST['terms']) ? $_POST['terms'] : array();
             $selected_terms = array();
             if (!empty($post_terms)) {
                 foreach ($post_terms as $t) {
                     $t = explode('_', $t);
                     if (!isset($selected_terms[$t[1]])) {
                         $selected_temp = array();
                         $selected_temp['id'] = $terms[$t[1]]['id'];
                         $selected_temp['lang'] = $terms[$t[1]]['lang'];
                         $selected_temp['name'] = $terms[$t[1]]['name'];
                         $selected_temp['terms']['item_' . $t[0]]['id'] = $t[0];
                         $selected_temp['terms']['item_' . $t[0]]['name'] = $terms[$t[1]]['terms']['item_' . $t[0]]['name'];
                         $selected_temp['terms']['item_' . $t[0]]['parent'] = $terms[$t[1]]['terms']['item_' . $t[0]]['parent'];
                         $selected_temp['terms']['item_' . $t[0]]['data'] = $t[2];
                         $selected_temp['terms']['item_' . $t[0]]['data_name'] = $term_orders[$t[2]];
                         $selected_terms[$t[1]] = $selected_temp;
                     } else {
                         if (!isset($selected_terms['terms']['item_' . $t[0]])) {
                             $selected_terms[$t[1]]['terms']['item_' . $t[0]]['id'] = $t[0];
                             $selected_terms[$t[1]]['terms']['item_' . $t[0]]['name'] = $terms[$t[1]]['terms']['item_' . $t[0]]['name'];
                             $selected_terms[$t[1]]['terms']['item_' . $t[0]]['parent'] = $terms[$t[1]]['terms']['item_' . $t[0]]['parent'];
                             $selected_terms[$t[1]]['terms']['item_' . $t[0]]['data'] = $t[2];
                             $selected_terms[$t[1]]['terms']['item_' . $t[0]]['data_name'] = $term_orders[$t[2]];
                         }
                     }
                 }
             }
             // After having the selected Terms, we need to make sure  all parents
             // of the selected Terms must be added also
             foreach ($selected_terms as $tx_key => $t) {
                 $array_parent_selected_terms = array();
                 foreach ($t['terms'] as $key => $st_terms) {
                     $current_term = $st_terms;
                     while ($current_term['parent'] != 0) {
                         if (!isset($array_parent_selected_terms['item_' . $current_term['parent']]) && !isset($t['terms']['item_' . $current_term['parent']])) {
                             $array_parent_selected_terms['item_' . $current_term['parent']] = $terms[$tx_key]['terms']['item_' . $current_term['parent']];
                             $array_parent_selected_terms['item_' . $current_term['parent']]['data'] = key($term_orders);
                             $array_parent_selected_terms['item_' . $current_term['parent']]['data_name'] = $term_orders[key($term_orders)];
                         }
                         $current_term = $terms[$tx_key]['terms']['item_' . $current_term['parent']];
                     }
                 }
                 $selected_terms[$tx_key]['terms'] = CMap::mergeArray($t['terms'], $array_parent_selected_terms);
             }
             //Re-Set the Status based on what User Chooose
             //The content is sent to ROLES OR STATUS
             if ($button == '1') {
                 //Check if the object_status is number or character
                 if (!is_numeric($object->object_status)) {
                     //Set the status to Pending
                     $trans->note = $object->object_status;
                     $object->object_status = ConstantDefine::OBJECT_STATUS_PENDING;
                     $trans->type = ConstantDefine::TRANS_ROLE;
                     $trans->after_status = ConstantDefine::OBJECT_STATUS_PENDING;
                 } else {
                     $trans->type = ConstantDefine::TRANS_STATUS;
                     $trans->after_status = $object->object_status;
                 }
                 $trans->from_user_id = user()->id;
                 $trans->to_user_id = 0;
                 $trans->before_status = ConstantDefine::OBJECT_STATUS_DRAFT;
             }
             //The content is sent to PERSON DIRECTLY
             if ($button == '2') {
                 $to_user_id = User::findPeople($object->person);
                 //Start to Transfer to the user and set the status to Pending
                 if ($to_user_id) {
                     $object->object_status = ConstantDefine::OBJECT_STATUS_PENDING;
                     $trans->from_user_id = user()->id;
                     $trans->to_user_id = $to_user_id->user_id;
                     $trans->type = ConstantDefine::TRANS_PERSON;
                     $trans->before_status = ConstantDefine::OBJECT_STATUS_PENDING;
                     $trans->after_status = ConstantDefine::OBJECT_STATUS_PENDING;
                 } else {
                     $object->addError('person', t('User not found'));
                 }
             }
             //Work with Resource Binding
             $resource = array();
             $resource_upload = array();
             foreach ($content_resources as $res) {
                 $resource_upload[] = GxcHelpers::getArrayResourceObjectBinding('resource_upload_' . $res['type']);
             }
             $i = 0;
             $count_resource = 0;
             foreach ($content_resources as $cres) {
                 $j = 1;
                 foreach ($resource_upload[$i] as $res_up) {
                     $j++;
                     $count_resource++;
                 }
                 $i++;
             }
             $object->total_number_resource = $count_resource;
             if ($object->save()) {
                 user()->setFlash('success', t('cms', 'Update content Successfully!'));
                 $trans->object_id = $object->object_id;
                 $trans->save();
                 //This is the update process, we should delete old
                 //Object Term binding
                 ObjectTerm::model()->deleteAll('object_id = :id', array(':id' => $object->object_id));
                 // We have all the selected Terms for now
                 // We will add them to Object Terms
                 foreach ($selected_terms as $tx_key => $t) {
                     foreach ($t['terms'] as $key => $st_terms) {
                         $obj_term = new ObjectTerm();
                         $obj_term->object_id = $object->object_id;
                         $obj_term->term_id = $st_terms['id'];
                         $obj_term->data = $st_terms['data'];
                         $obj_term->save();
                         unset($obj_term);
                     }
                 }
                 //Re update for Resource
                 ObjectResource::model()->deleteAll('object_id = :id', array(':id' => $object->object_id));
                 $i = 0;
                 $count_resource = 0;
                 foreach ($content_resources as $cres) {
                     $j = 1;
                     foreach ($resource_upload[$i] as $res_up) {
                         $obj_res = new ObjectResource();
                         $obj_res->resource_id = $res_up['resid'];
                         $obj_res->object_id = $object->object_id;
                         $obj_res->description = '';
                         $obj_res->type = $cres['type'];
                         $obj_res->resource_order = $j;
                         $obj_res->save();
                         $j++;
                         $count_resource++;
                     }
                     $i++;
                 }
             }
             $object->object_date = date('Y-m-d H:i:s', $object->object_date);
         }
         //Start Render the Form
         $render_template = 'cmswidgets.views.object.object_form_widget';
         if (file_exists(Yii::getPathOfAlias('common.content_type.' . strtolower($type) . '.object_form_widget') . '.php')) {
             $render_template = 'common.content_type.' . strtolower($type) . '.object_form_widget';
         }
         $this->render($render_template, array('model' => $object, 'versions' => $versions, 'lang_exclude' => $lang_exclude, 'content_status' => $content_status, 'terms' => $terms, 'selected_terms' => $selected_terms, 'type' => $type, 'content_resources' => $content_resources));
     }
 }
Ejemplo n.º 22
0
<?php

$this->breadcrumbs = array(Yii::t('app', 'Quản lý video'));
$this->menu = array(array('label' => 'Danh sách', 'url' => array('admin')), array('label' => 'Tạo mới', 'url' => array('create')));
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('video-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n");
?>

<h1><?php 
echo Yii::t('app', 'Quản lý Video');
?>
</h1>
<!--
<?php 
/*echo GxHtml::link(Yii::t('app', 'Tìm kiếm'), '#', array('class' => 'search-button')); */
?>
<div class="search-form">
<?php 
/*$this->renderPartial('_search', array(
	'model' => $model,
)); */
?>
</div><!-- search-form -->

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'video-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', 'title', 'link_youtube', array('name' => 'term_id', 'value' => 'GxHtml::valueEx($data->term)', 'filter' => GxHtml::listDataEx(Term::model()->findAllAttributes(null, true, 'vid=2'))), array('name' => 'teacher_id', 'value' => 'GxHtml::valueEx($data->teacher)', 'filter' => GxHtml::listDataEx(Teacher::model()->findAllAttributes(null, true))), array('class' => 'CButtonColumn', 'template' => '{update},{delete}'))));
Ejemplo n.º 23
0
 protected function findTermRoot($vocId, $id = null, $state = Term::STATE_ACTIVE, $orderBy = 'ordering')
 {
     $criteria = new CDbCriteria();
     $criteria->compare('v_id', $vocId);
     $criteria->compare('state', $state);
     if (!empty($id)) {
         if (is_numeric($id)) {
             $criteria->addCondition('id = :id');
         } else {
             $criteria->addCondition('alias = :id');
         }
         $criteria->params[':id'] = $id;
     } else {
         $criteria->addCondition('id NOT IN (SELECT term_id FROM ' . SITE_ID . '_' . 'taxonomy_term_hierarchy)');
     }
     $criteria->order = $orderBy;
     return Term::model()->findAll($criteria);
 }
Ejemplo n.º 24
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Term::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }