Exemplo n.º 1
0
 /**
  * Generates the TabularInputWidget and the javascript that drives the blocs.
  */
 public function run()
 {
     // Preparing variables.
     $layouts = array();
     $layoutSelect = array();
     $afterAddItem = '';
     $beforeAddItem = '';
     $afterInit = '';
     $sortableStart = '';
     $sortableStop = '';
     $beforeDeleteItem = '';
     $afterDeleteItem = '';
     foreach (Yii::app()->params['blocs'] as $bloc) {
         $modelClassName = 'Bloc' . ucfirst($bloc);
         $newBlocModel = new $modelClassName();
         $newBlocModel->title_anchor = true;
         $newBlocModel->title_page = true;
         $layouts['application.components.blocs.' . $bloc . '.views.admin'] = $newBlocModel;
         $layoutSelect['application.components.blocs.' . $bloc . '.views.admin'] = Yii::t('admin', 'bloc_' . $bloc);
         $afterAddItem .= Yii::app()->cms->blocs[$bloc]->afterAddItem() . "\n";
         $beforeAddItem .= Yii::app()->cms->blocs[$bloc]->beforeAddItem() . "\n";
         $afterInit .= Yii::app()->cms->blocs[$bloc]->afterInit() . "\n";
         $sortableStart .= Yii::app()->cms->blocs[$bloc]->sortableStart() . "\n";
         $sortableStop .= Yii::app()->cms->blocs[$bloc]->sortableStop() . "\n";
         $beforeDeleteItem .= Yii::app()->cms->blocs[$bloc]->beforeDeleteItem() . "\n";
         $afterDeleteItem .= Yii::app()->cms->blocs[$bloc]->afterDeleteItem() . "\n";
     }
     $renderData = array();
     foreach ($this->models as $key => $models) {
         if ($key !== 0) {
             $renderData[$key] = $models;
         }
     }
     // Instanciating widget.
     $this->widget('application.components.widgets.TabularInput.TabularInputWidget', array('id' => $this->id, 'form' => isset($this->form) ? $this->form : null, 'models' => $this->models[0], 'layoutExpression' => "'application.components.blocs.'.lcfirst(mb_substr(get_class(\$model), 4)).'.views.admin'", 'layout' => $layouts, 'layoutSelect' => $layoutSelect, 'itemTitleExpression' => "Yii::t('admin', \$model->tableName())", 'orderAttribute' => 'rank', 'nestedWidgets' => array('{formId}-{itemId}-blocDocumentDocumentForm', '{formId}-{itemId}-blocPeoplePeopleForm', '{formId}-{itemId}-blocCitationCitationForm', '{formId}-{itemId}-blocFeatureFeatureForm'), 'renderData' => $renderData, 'sortable' => array('start' => "js:function(event, ui){\n\t\t\t\t\t" . AdminHelper::tabularInputCkEditorSortableStart() . "\n\t\t\t\t\t" . $sortableStart . "\n\t\t\t\t}", 'stop' => "js:function(event, ui){\n\t\t\t\t\t" . AdminHelper::tabularInputCkEditorSortableStop() . "\n\t\t\t\t\t" . $sortableStop . "\n\t\t\t\t}"), 'beforeDeleteItem' => "function(id, itemId){\n\t\t\t\t" . AdminHelper::tabularInputCkEditorBeforeDeleteItem() . "\n\t\t\t\t" . $beforeDeleteItem . "\n\t\t\t}", 'afterDeleteItem' => "function(id, itemId){\n\t\t\t\t" . $afterDeleteItem . "\n\t\t\t}", 'beforeAddItem' => "function(id, itemId){\n\t\t\t\t" . $beforeAddItem . "\n\t\t\t}", 'afterAddItem' => "function(id, itemId){\n\t\t\t\t" . AdminHelper::tabularInputAfterAddItemDatetimePicker() . "\n\t\t\t\t" . $afterAddItem . "\n\t\t\t}", 'afterInit' => "function(id){\n\t\t\t\t" . $afterInit . "\n\t\t\t}"));
 }
Exemplo n.º 2
0
<?php

echo $this->renderPartial('//adminLayouts/_blocHeader', array('form' => $form, 'model' => $model, 'formId' => $formId, 'itemId' => $itemId));
?>

<div class="form-group">
	<?php 
echo $form->labelEx($model, '[' . $formId . '][' . $itemId . ']layout', array('class' => 'control-label col-sm-3 col-xs-12'));
?>
	<div class="col-sm-6 col-xs-12"><?php 
echo $form->dropDownList($model, '[' . $formId . '][' . $itemId . ']layout', array('1' => 'Colonnes (adapté pour les textes courts)', '2' => 'Lignes (adapté pour les textes longs)'), array('empty' => '', 'class' => 'form-control'));
?>
</div>
	<?php 
echo $form->error($model, '[' . $formId . '][' . $itemId . ']layout', array('class' => 'error text-left col-sm-3 col-xs-12'));
?>
</div>

<fieldset>

	<legend>Caractéristiques</legend>

	<?php 
$this->widget('application.components.widgets.TabularInput.TabularInputWidget', array('id' => $formId . '-' . $itemId . '-blocFeatureFeatureForm', 'form' => $form, 'layout' => array('application.components.blocs.feature.views.admin_featureFeature' => new BlocFeatureFeature()), 'models' => isset($blocFeatureFeature[$itemId]) ? $blocFeatureFeature[$itemId] : array(), 'itemTitleExpression' => "CHtml::encode(\$model->title)", 'orderAttribute' => 'rank', 'sortable' => array('start' => "js:function(event, ui){\n\t\t\t\t" . AdminHelper::tabularInputCkEditorSortableStart() . "\n\t\t\t}", 'stop' => "js:function(event, ui){\n\t\t\t\t" . AdminHelper::tabularInputCkEditorSortableStop() . "\n\t\t\t}")));
?>
	
</fieldset>

<?php 
echo $form->hiddenField($model, '[' . $formId . '][' . $itemId . ']rank');