Example #1
0
<?php

$this->pageTitle = Yii::app()->name . ' - ' . SliderModule::t('Manage slider');
$this->menu = array(array('label' => SliderModule::t('Add image'), 'url' => array('create')));
$this->adminTitle = SliderModule::t('Manage slider');
?>

<?php 
$this->widget('CustomGridView', array('id' => 'slider-grid', 'dataProvider' => $model->search(), 'afterAjaxUpdate' => 'function(){$("a[rel=\'tooltip\']").tooltip(); $("div.tooltip-arrow").remove(); $("div.tooltip-inner").remove(); $("a.fancy").fancybox({"ajax":{"data": {"isFancy":"true"}}}); reInstallSortable();}', 'rowCssClassExpression' => '"items[]_{$data->id}"', 'filter' => $model, 'columns' => array(array('class' => 'CCheckBoxColumn', 'id' => 'itemsSelected', 'selectableRows' => '2', 'htmlOptions' => array('class' => 'center')), array('name' => 'active', 'header' => tc('Status'), 'type' => 'raw', 'value' => 'Yii::app()->controller->returnStatusHtml($data, "slider-grid", 1)', 'htmlOptions' => array('class' => 'slider_status_column'), 'filter' => false, 'sortable' => false), array('name' => 'img', 'type' => 'raw', 'value' => 'Yii::app()->controller->returnImageFancy($data, "slider-grid", 0, 150, 85)', 'htmlOptions' => array('style' => 'height: 85px; width: 150px;'), 'filter' => false, 'sortable' => false), array('header' => tt('Image title', 'slider'), 'name' => 'title_' . Yii::app()->language, 'type' => 'raw', 'sortable' => false), array('name' => 'url', 'type' => 'raw', 'value' => '$data->url?CHtml::link(tt("Link"), $data->url):""', 'sortable' => false), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{up}{down}{update}{delete}', 'htmlOptions' => array('class' => 'infopages_buttons_column'), 'buttons' => array('up' => array('label' => tc('Move an item up'), 'imageUrl' => $url = Yii::app()->assetManager->publish(Yii::getPathOfAlias('zii.widgets.assets.gridview') . '/up.gif'), 'url' => 'Yii::app()->createUrl("/slider/backend/main/move", array("id"=>$data->id, "direction" => "up"))', 'options' => array('class' => 'slider_arrow_image_up'), 'visible' => '$data->sorter > "' . $minSorter . '"', 'click' => "js: function() { ajaxMoveRequest(\$(this).attr('href'), 'slider-grid'); return false;}"), 'down' => array('label' => tc('Move an item down'), 'imageUrl' => $url = Yii::app()->assetManager->publish(Yii::getPathOfAlias('zii.widgets.assets.gridview') . '/down.gif'), 'url' => 'Yii::app()->createUrl("/slider/backend/main/move", array("id"=>$data->id, "direction" => "down"))', 'options' => array('class' => 'slider_arrow_image_down'), 'visible' => '$data->sorter < "' . $maxSorter . '"', 'click' => "js: function() { ajaxMoveRequest(\$(this).attr('href'), 'slider-grid'); return false;}")), 'deleteConfirmation' => tc('Are you sure you want to delete this item?')))));
?>

<?php 
$this->renderPartial('//site/admin-select-items', array('url' => '/slider/backend/main/itemsSelected', 'id' => 'slider-grid', 'model' => $model, 'options' => array('activate' => Yii::t('common', 'Activate'), 'deactivate' => Yii::t('common', 'Deactivate'), 'delete' => Yii::t('common', 'Delete'))));
$csrf_token_name = Yii::app()->request->csrfTokenName;
$csrf_token = Yii::app()->request->csrfToken;
$cs = Yii::app()->getClientScript();
$cs->registerCoreScript('jquery.ui');
$str_js = "\n\t\tvar fixHelper = function(e, ui) {\n\t\t\tui.children().each(function() {\n\t\t\t\t\$(this).width(\$(this).width());\n\t\t\t});\n\t\t\treturn ui;\n\t\t};\n\n\t\tfunction reInstallSortable(id, data) {\n\t\t\tinstallSortable();\n\t\t}\n\n\t\tfunction updateGrid() {\n\t\t\t\$.fn.yiiGridView.update('slider-grid');\n\t\t}\n\n\t\tfunction installSortable() {\n\t\t\t\$('#slider-grid table.items tbody').sortable({\n\t\t\t\tforcePlaceholderSize: true,\n\t\t\t\tforceHelperSize: true,\n\t\t\t\titems: 'tr',\n\t\t\t\tupdate : function () {\n\t\t\t\t\tserial = \$('#slider-grid table.items tbody').sortable('serialize', {key: 'items[]', attribute: 'class'}) + '&{$csrf_token_name}={$csrf_token}';\n\t\t\t\t\t\$.ajax({\n\t\t\t\t\t\t'url': '" . $this->createUrl('/slider/backend/main/sortitems') . "',\n\t\t\t\t\t\t'type': 'post',\n\t\t\t\t\t\t'data': serial,\n\t\t\t\t\t\t'success': function(data){\n\t\t\t\t\t\t\tupdateGrid();\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'error': function(request, status, error){\n\t\t\t\t\t\t\talert('We are unable to set the sort order at this time.  Please try again in a few minutes.');\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\thelper: fixHelper\n\t\t\t}).disableSelection();\n\t\t}\n\n\t\tinstallSortable();\n";
$cs->registerScript('sortable-project', $str_js);
Example #2
0
<?php

$this->adminTitle = tt('Add image');
$this->menu = array(array('label' => SliderModule::t('Manage slider'), 'url' => array('admin')));
echo $this->renderPartial('/backend/_form', array('model' => $model, 'isCreate' => true));
Example #3
0
<?php

$this->pageTitle = Yii::app()->name . ' - ' . SliderModule::t('Edit image');
$this->menu = array(array('label' => SliderModule::t('Manage slider'), 'url' => array('admin')), array('label' => SliderModule::t('Add image'), 'url' => array('create')), array('label' => SliderModule::t('Delete image'), 'url' => '#', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => tc('Are you sure you want to delete this item?'))));
$this->adminTitle = SliderModule::t('Edit image');
?>

<?php 
echo $this->renderPartial('/backend/_form', array('model' => $model, 'isCreate' => false));