Exemplo n.º 1
0
	/**
	* Returns the user's name.
	* @return string the user's name.
	*/
	public function getRbamName() {
		if ($this->_name===null) {
			$owner = $this->getOwner();
			$attribute = Yii::app()->findModule('rbam')->userNameAttribute;

		if (is_string($attribute) && strpos($attribute, ',')!==false)
			$attribute = explode(',', str_replace('\,',self::COMMA,$attribute));

			if (is_array($attribute)) {
				$glue = str_replace(self::COMMA,',',array_shift($attribute));
				$end = end($attribute);
				$initials = ((is_array($end) || strpos($end, self::COMMA)!==false || strpos($end, ',')!==false)?array_pop($attribute):array());
				if (!empty($initials)) {
					if (is_string($initials))
						$initials = explode(',', str_replace('\,',self::COMMA,str_replace(self::COMMA,',',$initials)));
					$append = str_replace(self::COMMA,',',array_shift($initials));
				}

				$attributes = array();
				foreach ($attribute as $attr) {
					$value = CHtml::value($owner,$attr);
					if (!empty($value))
						$attributes[] = (in_array($attr, $initials)?substr($value,0,1).$append:$value);
				}
				$this->_name =  join($glue, $attributes);
			}
			else
				$this->_name = $owner->$attribute;
		}
		return $this->_name;
	}
Exemplo n.º 2
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id = null, $path = null)
 {
     //if path is given, find the content_id from the menu item
     if ($path) {
         $Content = Content::model()->findByAttributes(array('path' => $path));
     } else {
         $Content = $this->loadModel($id);
     }
     $Content = $this->loadModel($id);
     $MI = MenuItem::model()->findByAttributes(array('content_id' => $Content->id));
     if (!Yii::app()->user->checkAccess('Update Content')) {
         $today = new DateTime();
         $publish_on = new DateTime($Content->publish_on);
         $unpublish_on = new DateTime($Content->unpublish_on);
         if (!$Content->published || $publish_on > $today || $unpublish_on < $today) {
             throw new CHttpException(403, Yii::t('yii', 'You are not authorized to perform this action.'));
         }
     }
     //$this->layout = '//layouts/column1';
     $view = 'view';
     if ($this->getLayoutFile('//layouts/content_types/' . $Content->type)) {
         $this->layout = '//layouts/content_types/' . $Content->type;
     }
     if ($this->getViewFile($Content->type)) {
         $view = $Content->type;
     }
     $this->meta_keywords = CHtml::value($Content, 'meta_keywords');
     $this->meta_description = CHtml::value($Content, 'meta_description');
     $this->meta_author = CHtml::value($Content, 'UserCreated.full_name');
     //Used by the admin bar
     $this->Content = $Content;
     $this->render($view, array('Content' => $Content, 'MenuItem' => $MI));
 }
Exemplo n.º 3
0
 public function renderTableRow($row)
 {
     $data = $this->dataProvider->data[$row];
     $value = CHtml::value($data, $this->rankKey);
     $this->count++;
     if ($this->lastRankValue != $value) {
         $this->lastRankValue = $value;
         $this->lastRank = $this->rank;
         $this->rank = $this->count;
     }
     $htmlOptions = array();
     if ($this->rowHtmlOptionsExpression !== null) {
         $options = $this->evaluateExpression($this->rowHtmlOptionsExpression, array('row' => $row, 'data' => $data, 'rank' => $this->rank));
         if (is_array($options)) {
             $htmlOptions = $options;
         }
     }
     if ($this->rowCssClassExpression !== null) {
         $class = $this->evaluateExpression($this->rowCssClassExpression, array('row' => $row, 'data' => $data, 'rank' => $this->rank));
     } elseif (is_array($this->rowCssClass) && ($n = count($this->rowCssClass)) > 0) {
         $class = $this->rowCssClass[$row % $n];
     }
     if (!empty($class)) {
         if (isset($htmlOptions['class'])) {
             $htmlOptions['class'] .= ' ' . $class;
         } else {
             $htmlOptions['class'] = $class;
         }
     }
     echo CHtml::openTag('tr', $htmlOptions) . "\n";
     foreach ($this->columns as $column) {
         $column->renderDataCell($row);
     }
     echo "</tr>\n";
 }
Exemplo n.º 4
0
 /**
  * Renders a table body row.
  * @param integer $row the row number (zero-based).
  * Adds in data for drag & drop ordering if id and sort_order fields available.
  */
 public function renderTableRow($row)
 {
     $data = $this->dataProvider->data[$row];
     if (array_key_exists('Id', $data->tableSchema->columns)) {
         $tag = '<tr data-record-id="' . CHtml::value($data, 'Id') . '"';
         if (array_key_exists('sort_order', $data->tableSchema->columns)) {
             $tag .= ' data-sort-order="' . CHtml::value($data, 'sort_order') . '"';
         }
     } else {
         $tag = '<tr id="34444" ';
     }
     if ($this->rowCssClassExpression !== null) {
         echo $tag .= ' class="' . $this->evaluateExpression($this->rowCssClassExpression, array('row' => $row, 'data' => $data)) . '">';
     } else {
         if (is_array($this->rowCssClass) && ($n = count($this->rowCssClass)) > 0) {
             echo $tag .= ' class="' . $this->rowCssClass[$row % $n] . '">';
         } else {
             echo $tag .= '>';
         }
     }
     foreach ($this->columns as $column) {
         $column->renderDataCell($row);
     }
     echo "</tr>\n";
 }
Exemplo n.º 5
0
 /**
  * Renders the data cell content.
  * This method renders a checkbox in the data cell.
  * @param integer $row the row number (zero-based)
  * @param mixed $data the data associated with the row
  * This method is Copyright (c) 2008-2014 by Yii Software LLC
  * http://www.yiiframework.com/license/ 
  */
 protected function renderDataCellContent($row, $data)
 {
     if ($this->value !== null) {
         $value = $this->evaluateExpression($this->value, array('data' => $data, 'row' => $row));
     } elseif ($this->name !== null) {
         $value = CHtml::value($data, $this->name);
     } else {
         $value = $this->grid->dataProvider->keys[$row];
     }
     $checked = false;
     if ($this->checked !== null) {
         $checked = $this->evaluateExpression($this->checked, array('data' => $data, 'row' => $row));
     }
     $options = $this->checkBoxHtmlOptions;
     if ($this->disabled !== null) {
         $options['disabled'] = $this->evaluateExpression($this->disabled, array('data' => $data, 'row' => $row));
     }
     $name = $options['name'];
     unset($options['name']);
     $options['value'] = $value;
     /* x2modstart */
     // made id customizable through interface
     if (isset($options['id'])) {
         $options['id'] = $this->evaluateExpression($options['id'], array('data' => $data, 'row' => $row));
     }
     if (!isset($options['id'])) {
         /* x2modend */
         $options['id'] = $this->id . '_' . $row;
     }
     echo CHtml::checkBox($name, $checked, $options);
 }
Exemplo n.º 6
0
 public function renderDataCellContent($row, $data)
 {
     $isModel = $data instanceof CModel;
     if ($isModel) {
         $widgetClass = 'EditableField';
         $attribute = empty($this->editable['attribute']) ? $this->name : $this->editable['attribute'];
         $options = array('model' => $data, 'attribute' => $attribute);
         //if value defined in column config --> we should evaluate it
         //and pass to widget via `text` option: set flag `passText` = true
         $passText = !empty($this->value);
     } else {
         $widgetClass = 'Editable';
         $options = array('pk' => $data[$this->grid->dataProvider->keyField], 'name' => empty($this->editable['name']) ? $this->name : $this->editable['name']);
         $passText = true;
         //if autotext will be applied, do not pass `text` option (pass `value` instead)
         if (empty($this->value) && Editable::isAutotext($this->editable, isset($this->editable['type']) ? $this->editable['type'] : '')) {
             $options['value'] = $data[$this->name];
             $passText = false;
         }
     }
     //for live update
     $options['liveTarget'] = $this->grid->id;
     $options = CMap::mergeArray($this->editable, $options);
     //get text for element
     $ctext = CHtml::value($data, $attribute);
     //if value defined for column --> use it as element text
     if ($passText) {
         ob_start();
         parent::renderDataCellContent($row, $data);
         $text = ob_get_clean();
         $ctext = $text;
         $options['text'] = $text;
         $options['encode'] = false;
     }
     //apply may be a string expression, see https://github.com/vitalets/x-editable-yii/issues/33
     if (isset($options['apply']) && is_string($options['apply'])) {
         $options['apply'] = $this->evaluateExpression($options['apply'], array('data' => $data, 'row' => $row));
     }
     //evaluate htmlOptions inside editable config as they can depend on $data
     //see https://github.com/vitalets/x-editable-yii/issues/40
     if (isset($options['htmlOptions']) && is_array($options['htmlOptions'])) {
         foreach ($options['htmlOptions'] as $k => $v) {
             if (is_string($v) && (strpos($v, '$data') !== false || strpos($v, '$row') !== false)) {
                 $options['htmlOptions'][$k] = $this->evaluateExpression($v, array('data' => $data, 'row' => $row));
             }
         }
     }
     $this->grid->controller->widget($widgetClass, $options);
     //Added to support creating models on the fly
     //$ctext = CHtml::value($data, $attribute);
     $mClass = empty($this->modelName) ? get_class($data) : $this->modelName;
     if (empty($this->parentModel)) {
         echo cHtml::openTag('input', array('type' => 'hidden', 'class' => "optvalinput{$attribute}", 'id' => "{$mClass}_{$row}_{$attribute}", 'name' => "{$mClass}[{$row}][{$attribute}]", 'value' => $ctext));
     } else {
         echo cHtml::openTag('input', array('type' => 'hidden', 'class' => "optvalinput{$attribute}", 'id' => "{$this->parentModel[1]}_{$this->parentModel[0]}_{$mClass}_{$row}_{$attribute}", 'name' => "{$this->parentModel[1]}[{$this->parentModel[0]}][{$mClass}][{$row}][{$attribute}]", 'value' => $ctext));
     }
     echo cHtml::closeTag('input');
 }
Exemplo n.º 7
0
 protected function renderDataCellContent($row, $data)
 {
     if ($this->value !== null) {
         $value = $this->evaluateExpression($this->value, array('data' => $data, 'row' => $row, 'rank' => $this->grid->rank, 'lastRank' => $this->grid->lastRank, 'displayRank' => $this->grid->getDisplayRank($row)));
     } elseif ($this->name !== null) {
         $value = CHtml::value($data, $this->name);
     }
     echo $value === null ? $this->grid->nullDisplay : $this->grid->getFormatter()->format($value, $this->type);
 }
Exemplo n.º 8
0
 protected function getItemValue($row, $data)
 {
     if (!empty($this->value)) {
         return $this->evaluateExpression($this->value, array('data' => $data, 'row' => $row));
     } elseif (!empty($this->name)) {
         return CHtml::value($data, $this->name);
     }
     return null;
 }
 protected function renderDataCellContent($row, $data)
 {
     $value = CHtml::value($data, $this->name);
     $this->callbackUrl['pk'] = $data->primaryKey;
     $this->callbackUrl['name'] = urlencode($this->name);
     $this->callbackUrl['value'] = (int) empty($value);
     $link = CHtml::normalizeUrl($this->callbackUrl);
     echo CHtml::link(!empty($value) ? 'Y' : 'N', $link, array('class' => $this->_flagClass));
 }
Exemplo n.º 10
0
	/**
	 * Renders the data cell content.
	 * This method renders a hyperlink in the data cell.
	 * @param integer $row the row number (zero-based)
	 * @param mixed $data the data associated with the row
	 */
	protected function renderDataCellContent($row,$data)
	{
	    echo CHtml::link(
	        CHtml::image(
	            CHtml::value($data,$this->name) ? $this->onButtonImageUrl : $this->offButtonImageUrl
	        ),
	        Yii::app()->controller->createUrl(($this->action?$this->action:$this->name),array("id"=>$data->primaryKey)),
	        array('class'=>'onoffbutton')
	    );
	}
Exemplo n.º 11
0
 public function run()
 {
     $formatter = $this->getFormatter();
     echo CHtml::openTag($this->tagName, $this->htmlOptions);
     $i = 0;
     $n = is_array($this->itemCssClass) ? count($this->itemCssClass) : 0;
     foreach ($this->attributes as $attribute) {
         if (is_string($attribute)) {
             if (!preg_match('/^([\\w\\.]+)(:(\\w*))?(:(.*))?$/', $attribute, $matches)) {
                 throw new CException(Yii::t('zii', 'The attribute must be specified in the format of "Name:Type:Label", where "Type" and "Label" are optional.'));
             }
             $attribute = array('name' => $matches[1], 'type' => isset($matches[3]) ? $matches[3] : 'text');
             if (isset($matches[5])) {
                 $attribute['label'] = $matches[5];
             }
         }
         if (isset($attribute['visible']) && !$attribute['visible']) {
             continue;
         }
         $tr = array('{label}' => '', '{class}' => $n ? $this->itemCssClass[$i % $n] : '');
         if (isset($attribute['cssClass'])) {
             $tr['{class}'] = $attribute['cssClass'] . ' ' . ($n ? $tr['{class}'] : '');
         }
         if (isset($attribute['label'])) {
             $tr['{label}'] = $attribute['label'];
         } else {
             if (isset($attribute['name'])) {
                 if ($this->data instanceof CModel) {
                     $tr['{label}'] = $this->data->getAttributeLabel($attribute['name']);
                 } else {
                     $tr['{label}'] = ucwords(trim(strtolower(str_replace(array('-', '_', '.'), ' ', preg_replace('/(?<![A-Z])[A-Z]/', ' \\0', $attribute['name'])))));
                 }
             }
         }
         if (!isset($attribute['type'])) {
             $attribute['type'] = 'text';
         }
         if (isset($attribute['value'])) {
             $value = $attribute['value'];
         } else {
             if (isset($attribute['name'])) {
                 $value = CHtml::value($this->data, $attribute['name']);
                 if (Yii::app()->dater->isDbDate($value)) {
                     $value = Yii::app()->dater->readableFormat($value);
                 }
             } else {
                 $value = null;
             }
         }
         $tr['{value}'] = $value === null ? $this->nullDisplay : $formatter->format($value, $attribute['type']);
         echo strtr(isset($attribute['template']) ? $attribute['template'] : $this->itemTemplate, $tr);
         $i++;
     }
     echo CHtml::closeTag($this->tagName);
 }
Exemplo n.º 12
0
 protected function renderDataCellContent($row, $data)
 {
     $value = CHtml::value($data, $this->name);
     $this->callbackUrl['pk'] = $data->primaryKey;
     $this->callbackUrl['name'] = urlencode($this->name);
     $this->callbackUrl['value'] = (int) empty($value);
     $link = CHtml::normalizeUrl($this->callbackUrl);
     $yes = $this->icons ? CHtml::image($this->_assets . '/checkbox-checked.png') : '+';
     $no = $this->icons ? CHtml::image($this->_assets . '/checkbox-unchecked.png') : '-';
     echo CHtml::link(!empty($value) ? $yes : $no, $link, array('class' => $this->_flagClass));
 }
Exemplo n.º 13
0
 /**
  * Renders the data cell content.
  * This method evaluates {@link value} or {@link name} and renders the result.
  *
  * @param integer $row the row number (zero-based)
  * @param mixed $data the data associated with the row
  */
 protected function renderDataCellContent($row, $data)
 {
     $value = CHtml::value($data, $this->name);
     $valueId = $data->{$this->modelId};
     $this->htmlEditFieldOptions['itemId'] = $valueId;
     $fieldUID = $this->getViewDivClass();
     echo CHtml::tag('div', array('valueid' => $valueId, 'id' => $fieldUID . '-' . $valueId, 'class' => $fieldUID), $value);
     echo CHtml::openTag('div', array('style' => 'display: none;', 'id' => $this->getFieldDivClass() . $data->{$this->modelId}));
     echo CHtml::textField($this->name . '[' . $valueId . ']', $value, $this->htmlEditFieldOptions);
     echo CHtml::closeTag('div');
 }
Exemplo n.º 14
0
 /**
  * Renders the data cell content.
  * This method evaluates {@link value} or {@link name} and renders the result.
  * @param integer $row the row number (zero-based)
  * @param mixed $data the data associated with the row
  */
 protected function renderDataCellContent($row, $data)
 {
     if ($this->value !== null) {
         $value = $this->evaluateExpression($this->value, array('data' => $data, 'row' => $row));
         if (!empty($this->data) && isset($this->data[$value])) {
             $value = $this->data[$value];
         }
     } elseif ($this->name !== null) {
         $value = CHtml::value($data, $this->name);
     }
     echo $value === null ? $this->grid->nullDisplay : $this->grid->getFormatter()->format($value, $this->type);
 }
Exemplo n.º 15
0
 protected function renderDataCellContent($row, $data)
 {
     if ($this->format === null) {
         $this->format = "dd.MM.yyyy HH:mm:ss";
     }
     $this->grid->getFormatter()->dateFormat = $this->format;
     if ($this->value !== null) {
         $value = $this->evaluateExpression($this->value, array('data' => $data, 'row' => $row));
     } elseif ($this->name !== null) {
         $value = CHtml::value($data, $this->name);
     }
     echo $value === null ? $this->grid->nullDisplay : Yii::app()->dateFormatter->format($this->format, $value);
 }
Exemplo n.º 16
0
 /**
  * Renders the data cell content.
  * This method evaluates {@link value} or {@link name} and renders the result.
  *
  * @param integer $row the row number (zero-based)
  * @param mixed $data the data associated with the row
  *
  * @return string|void
  */
 public function renderDataCellContent($row, $data)
 {
     if ($this->grid->json) {
         if ($this->value !== null) {
             $value = $this->evaluateExpression($this->value, array('data' => $data, 'row' => $row));
         } elseif ($this->name !== null) {
             $value = CHtml::value($data, $this->name);
         }
         $value = !isset($value) ? $this->grid->nullDisplay : $this->grid->getFormatter()->format($value, $this->type);
         return $value;
     }
     parent::renderDataCellContent($row, $data);
 }
Exemplo n.º 17
0
 public function renderTableRow($row)
 {
     $this->_currentRow = $row;
     if ($this->groupKey !== null) {
         $data = $this->dataProvider->data[$row];
         $group = CHtml::value($data, $this->groupKey);
         if ($this->lastGroup != $group) {
             $this->lastGroup = $group;
             $this->renderGroupHeader($row);
         }
     }
     parent::renderTableRow($row);
 }
Exemplo n.º 18
0
 protected function renderDataCellContent($row, $data)
 {
     $indent = '';
     if (isset($data->indent)) {
         $indent = isset($data->indent) ? str_repeat($this->indentSymbol, $data->indent * $this->indentSize) : '';
     }
     if ($this->value !== null) {
         $value = $this->evaluateExpression($this->value, array('data' => $data, 'row' => $row));
     } elseif ($this->name !== null) {
         $value = CHtml::value($data, $this->name);
     }
     echo $value === null ? $this->grid->nullDisplay : $indent . $this->grid->getFormatter()->format($value, $this->type);
 }
Exemplo n.º 19
0
 /**
  * Renders a data cell content, wrapping the value with the link that will activate the picker
  *
  * @param int $row
  * @param mixed $data
  */
 public function renderDataCellContent($row, $data)
 {
     if ($this->value !== null) {
         $value = $this->evaluateExpression($this->value, array('data' => $data, 'row' => $row));
     } else {
         if ($this->name !== null) {
             $value = CHtml::value($data, $this->name);
         }
     }
     $class = preg_replace('/\\s+/', '.', $this->class);
     $value = !isset($value) ? $this->grid->nullDisplay : $this->grid->getFormatter()->format($value, $this->type);
     $value = CHtml::link($value, '#', array('class' => $class));
     echo $value;
 }
 protected function renderDataCellContent($row, $data)
 {
     if ($this->value !== null) {
         $value = $this->evaluateExpression($this->value, array('data' => $data, 'row' => $row));
     } else {
         if ($this->name !== null) {
             $value = CHtml::value($data, $this->name);
         }
     }
     if ($this->percent !== 0) {
         $this->percent = $value;
     }
     echo CHtml::openTag('div', $this->htmlOpt);
     echo '<div class="bar" style="width: ' . $this->percent . '%;"></div>';
     echo '</div>';
 }
 /**
  * Renders the data cell content.
  * This method evaluates {@link value} or {@link name} and renders the result.
  *
  * @param integer $row the row number (zero-based)
  * @param mixed $data the data associated with the row
  */
 protected function renderDataCellContent($row, $data)
 {
     if ($this->value !== null) {
         $value = $this->evaluateExpression($this->value, array('data' => $data, 'row' => $row));
     } elseif ($this->name !== null) {
         $value = CHtml::value($data, $this->name);
     }
     $valueId = $data->{$this->modelId};
     $this->htmlEditFieldOptions['itemId'] = $valueId;
     $this->htmlEditFieldOptions['style'] = 'width:50px;';
     $fieldUID = $this->getViewDivClass();
     echo CHtml::tag('div', array('valueid' => $valueId, 'id' => $fieldUID . '-' . $valueId, 'class' => $fieldUID . ' editable-cell'), $value);
     echo CHtml::openTag('div', array('style' => 'display: none;', 'id' => $this->getFieldDivClass() . $data->{$this->modelId}));
     echo CHtml::textField($this->name . '[' . $valueId . ']', $value, $this->htmlEditFieldOptions);
     echo CHtml::closeTag('div');
 }
Exemplo n.º 22
0
 /**
  * Renders the data cell content.
  * This method evaluates {@link value} or {@link name} and renders the result. It also adds a tooltip if the $tooltip_content property is set.
  * @param integer $row the row number (zero-based)
  * @param mixed $data the data associated with the row
  */
 protected function renderDataCellContent($row, $data)
 {
     if ($this->value !== null) {
         $value = $this->evaluateExpression($this->value, array('data' => $data, 'row' => $row));
     } else {
         if ($this->name !== null) {
             $value = CHtml::value($data, $this->name);
         }
     }
     $content = $value === null ? $this->grid->nullDisplay : $this->grid->getFormatter()->format($value, $this->type);
     if ($this->tooltip_content) {
         $tooltip = $this->evaluateExpression($this->tooltip_content, array('data' => $data, 'row' => $row));
         if ($tooltip) {
             $content = "<span class=\"grid-tooltip grid-tooltip-{$this->id}\" title=\"{$tooltip}\">{$content}</span>";
         }
     }
     echo $content;
 }
 /**
  * Renders a data cell content, wrapping the value with the link that will activate the picker
  * @param int $row
  * @param mixed $data
  */
 public function renderDataCellContent($row, $data)
 {
     if ($this->value !== null) {
         $value = $this->evaluateExpression($this->value, array('data' => $data, 'row' => $row));
     } else {
         if ($this->name !== null) {
             $value = CHtml::value($data, $this->name);
         }
     }
     $class = preg_replace('/\\s+/', '.', $this->class);
     if ($this->containerHtmlOptions !== null) {
         $this->containerHtmlOptions['class'] .= ' ' . $class;
     } else {
         $this->containerHtmlOptions = array('class' => $class);
     }
     $value = !isset($value) ? $this->grid->nullDisplay : $this->grid->getFormatter()->format($value, $this->type);
     $value = CHtml::tag($this->containerTag, $this->containerHtmlOptions, $value);
     echo $value;
 }
Exemplo n.º 24
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (!$this->hasModel() && $this->name === null) {
         throw new CException("Either 'name', or 'model' and 'attribute' properties must be specified.");
     }
     if (!isset($this->htmlOptions['id'])) {
         $this->htmlOptions['id'] = $this->hasModel() ? CHtml::activeId($this->model, $this->attribute) : $this->getId();
     }
     $this->attachBehavior('ywplugin', array('class' => 'yiiwheels.behaviors.WhPlugin'));
     $this->htmlOptions = TbArray::merge($this->asDataAttributes($this->pluginOptions), $this->htmlOptions);
     $this->pluginOptions = false;
     if ($this->hasModel()) {
         $this->htmlOptions['data-name'] = CHtml::activeId($this->model, $this->attribute);
         $this->htmlOptions['data-value'] = CHtml::value($this->model, $this->attribute);
     } else {
         $this->htmlOptions['data-name'] = $this->name;
         $this->htmlOptions['data-value'] = $this->value;
     }
 }
Exemplo n.º 25
0
 /**
  * Renders a data cell content, wrapping the value with the link that will activate the picker
  *
  * @param int $row        	
  * @param mixed $data        	
  */
 public function renderDataCellContent($row, $data)
 {
     $value = '';
     if ($this->value !== null) {
         $value = $this->evaluateExpression($this->value, array('data' => $data, 'row' => $row));
     } else {
         if ($this->name !== null) {
             $value = CHtml::value($data, $this->name);
         }
     }
     $htmlOptions = array('data-toggle' => 'popover');
     foreach ($this->options as $key => $val) {
         if ($this->isAValidOption($key)) {
             if (!$val instanceof CJavaScriptExpression && strpos($val, 'js:') === 0) {
                 $val = new CJavaScriptExpression($val);
             }
             $htmlOptions['data-' . $key] = $val;
         }
     }
     echo CHtml::link($value, "#", $htmlOptions);
 }
Exemplo n.º 26
0
 protected function renderDataColumnDataCellContent($row, $data)
 {
     if ($this->owner->value !== null) {
         $value = $this->owner->evaluateExpression($this->owner->value, array('data' => $data, 'row' => $row));
     } else {
         if ($this->owner->name !== null) {
             $value = CHtml::value($data, $this->owner->name);
         }
     }
     if ($value === null) {
         $value = $this->owner->grid->nullDisplay;
     } else {
         $value = $this->owner->grid->getFormatter()->format($value, $this->owner->type);
     }
     if ($this->owner->name == $this->owner->grid->titleFieldName) {
         $interval = CHtml::value($data, $this->owner->grid->layerFieldName) * $this->owner->grid->layerInterval;
         echo CHtml::tag('div', array('style' => 'padding-left:' . $interval . 'px'), $value);
     } else {
         echo $value;
     }
 }
Exemplo n.º 27
0
 /**
  * Renders the data cell content.
  * This method renders the view, update and toggle buttons in the data cell.
  * @param integer $row the row number (zero-based)
  * @param mixed $data the data associated with the row
  */
 protected function renderDataCellContent($row, $data)
 {
     $checked = CHtml::value($data, $this->name);
     $button = $this->button;
     $button['icon'] = $checked ? $this->checkedIcon : $this->uncheckedIcon;
     $button['url'] = isset($button['url']) ? $this->evaluateExpression($button['url'], array('data' => $data, 'row' => $row)) : '#';
     if (!$this->displayText) {
         $icon = CHtml::image($checked ? Yii::app()->baseUrl . $this->iconFolder . $this->icon_filename_checked : Yii::app()->baseUrl . $this->iconFolder . $this->icon_filename_unchecked, $checked ? $this->checkedButtonLabel : $this->uncheckedButtonLabel);
         //$button['htmlOptions']['title'] = $checked ? $this->checkedButtonLabel : $this->uncheckedButtonLabel;
         //$button['htmlOptions']['rel'] = 'tooltip';
         $button['htmlOptions']['data-hint'] = $checked ? $this->hint_checked : $this->hint_unchecked;
         $button['htmlOptions']['class'] = $button['htmlOptions']['class'] . ' hint--bottom';
         echo CHtml::link($icon, $button['url'], $button['htmlOptions']);
     } else {
         $button['label'] = $checked ? $this->checkedButtonLabel : $this->uncheckedButtonLabel;
         $button['class'] = 'bootstrap.widgets.TbButton';
         $widget = Yii::createComponent($button);
         $widget->init();
         $widget->run();
     }
 }
Exemplo n.º 28
0
 protected function renderDataCellContent($row, $data)
 {
     $value = CHtml::value($data, $this->name);
     $spinUpValue = $value + 1;
     $spinDownValue = $value - 1;
     $this->callbackUrl['id'] = $data->primaryKey;
     $this->callbackUrl['name'] = urlencode($this->name);
     $this->callbackUrl['value'] = $spinUpValue;
     $spinUpUrl = CHtml::normalizeUrl($this->callbackUrl);
     $this->callbackUrl['value'] = $spinDownValue;
     $spinDownUrl = CHtml::normalizeUrl($this->callbackUrl);
     //To account for if the user has provided the class value for linkHtmlOptions
     if (!isset($this->linkHtmlOptions['class'])) {
         $this->linkHtmlOptions = array_merge($this->linkHtmlOptions, array('class' => $this->_spinnerClass));
     } else {
         $this->linkHtmlOptions['class'] .= " {$this->_spinnerClass}";
     }
     $spinUpLink = CHtml::link('+', $spinUpUrl, $this->linkHtmlOptions);
     $spinDownLink = CHtml::link('&#8722;', $spinDownUrl, $this->linkHtmlOptions);
     echo $spinUpLink . ' ' . $value . ' ' . $spinDownLink;
 }
 /**
  * Renders the data cell content.
  * This method evaluates {@link value} or {@link name} and renders the result.
  * @param integer the row number (zero-based)
  * @param mixed the data associated with the row
  */
 protected function renderDataCellContent($row, $data)
 {
     if ($this->value !== null) {
         $value = $this->value;
     } elseif ($this->name !== null) {
         $value = CHtml::value($data, $this->name);
     }
     $image = $value ? $this->trueImageUrl : $this->falseImageUrl;
     $otherImage = $value ? $this->falseImageUrl : $this->trueImageUrl;
     $url = isset($this->toggleUrl) ? $this->evaluateExpression($this->toggleUrl, array('data' => $data, 'row' => $row)) : '#';
     $options = isset($this->options) ? $this->options : array();
     if (!isset($options['title'])) {
         $options['title'] = $this->label;
     }
     $imgChange = array('onmouseover' => "this.src='{$otherImage}'", 'onmouseout' => "this.src='{$image}'");
     if (isset($this->trueImageUrl) && is_string($this->trueImageUrl)) {
         echo CHtml::link(CHtml::image($image, $this->label, $imgChange), $url, $options);
     } else {
         echo CHtml::link($this->label, $url, $options);
     }
     //		echo $value;
 }
Exemplo n.º 30
0
 public function listDataExtJson($model, $field, $desc = array(), $separator = "/", $condition = "")
 {
     $data = $model::model()->findAll($condition);
     if ($data) {
         foreach ($data as $n => $submodel) {
             $value = CHtml::value($submodel, $field);
             $listData[$n][id] = $value;
             $i = 0;
             foreach ($desc as $valor) {
                 if (count($desc) - 1 == $i) {
                     $listData[$n][text] .= CHtml::value($submodel, $valor);
                 } else {
                     $listData[$n][text] .= CHtml::value($submodel, $valor) . $separator;
                 }
                 $i++;
             }
         }
     } else {
         $listData = array();
     }
     $aux = $listData;
     return json_encode($aux);
 }