本文整理汇总了PHP中CHtml::renderAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP CHtml::renderAttributes方法的具体用法?PHP CHtml::renderAttributes怎么用?PHP CHtml::renderAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHtml
的用法示例。
在下文中一共展示了CHtml::renderAttributes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderContainer
/**
* Renders container where to allocate the chart.
*/
public function renderContainer()
{
// if no container is set, it will create one
if ($this->containerId == null) {
$this->containerId = 'div-chart' . $this->options['id'];
echo '<div ' . \CHtml::renderAttributes($this->options) . '></div>';
}
}
示例2: run
/**
* Widget's run method
*/
public function run() {
$id = $this->getId();
// if no container is set, it will create one
if ($this->containerId == null) {
$this->htmlOptions['id'] = 'div-chart' . $id;
$this->containerId = $this->htmlOptions['id'];
echo '<div ' . CHtml::renderAttributes($this->htmlOptions) . '></div>';
}
$this->registerClientScript();
}
示例3: alert
/**
* Returns an alert box
*
* @param string $content the text within the alert box
* @param array $htmlOptions the HTML attributes of the alert box
* @param string $close the label for the close button. Set to false if you don't wish to display it.
* @return string the alert box
* @see http://foundation.zurb.com/docs/components/alert-boxes.html
*/
public static function alert($content, $htmlOptions = array(), $close = '×')
{
ArrayHelper::addValue('class', 'alert-box', $htmlOptions);
ob_start();
echo '<div data-alert ' . \CHtml::renderAttributes($htmlOptions) . '>';
echo $content;
if ($close !== false) {
echo static::closeLink($close);
}
echo '</div>';
return ob_get_clean();
}
示例4: renderMenu
/**
* Renders the menu.
*
* @param mixed $items normalized list of items
*/
protected function renderMenu($items)
{
$htmlOptions = $this->htmlOptions;
if (!isset($htmlOptions['id'])) {
$htmlOptions['id'] = $this->getId();
}
if (!isset($htmlOptions['class'])) {
$htmlOptions['class'] = 'yiiListMenu';
}
echo '<ul' . CHtml::renderAttributes($htmlOptions) . '>';
$this->renderMenuRecurse($items);
echo '</ul>';
}
示例5: run
/**
* Renders the widget.
*/
public function run()
{
$id = $this->getId();
// if there is no renderTo id, build the layer with current id and initialize renderTo option
if (!isset($this->options['chart']) || !isset($this->options['chart']['renderTo'])) {
$this->htmlOptions['id'] = $id;
echo '<div ' . CHtml::renderAttributes($this->htmlOptions) . ' ></div>';
if (isset($this->options['chart']) && is_array($this->options['chart'])) {
$this->options['chart']['renderTo'] = $id;
} else {
$this->options['chart'] = array('renderTo' => $id);
}
}
$this->registerClientScript();
}
示例6: renderDataCell
/**
* Renders|returns the data cell.
*
* @param int $row
*
* @return array|void
*/
public function renderDataCell($row)
{
if ($this->grid->json) {
$data = $this->grid->dataProvider->data[$row];
$options = $this->htmlOptions;
if ($this->cssClassExpression !== null) {
$class = $this->evaluateExpression($this->cssClassExpression, array('row' => $row, 'data' => $data));
if (!empty($class)) {
if (isset($options['class'])) {
$options['class'] .= ' ' . $class;
} else {
$options['class'] = $class;
}
}
}
return array('attrs' => CHtml::renderAttributes($options), 'content' => $this->renderDataCellContent($row, $data));
}
parent::renderDataCell($row);
}
示例7: tableHead
public static function tableHead($link, $header, $options = array())
{
$out = '';
$page = (int) Yii::app()->request->getQuery('page');
$page = $page > 0 ? $page : 1;
$sort = Yii::app()->request->getQuery('sort');
$sort = empty($sort) ? 'asc' : $sort;
$order = Yii::app()->request->getQuery('order');
foreach ($header as $field => $title) {
$th_attrs = array();
if (is_array($title)) {
$th_attrs = isset($title[1]) ? $title[1] : array();
$title = $title[0];
}
$params = array('order' => $field, 'sort' => $sort == 'asc' ? 'desc' : 'asc');
if (isset($options['page']) && $options['page']) {
$params['page'] = $page;
}
if (isset($options['query']) && is_array($options['query'])) {
$params = array_merge($params, $options['query']);
}
$out .= '<th' . CHtml::renderAttributes($th_attrs) . '>';
if (is_string($field)) {
$out .= '<a href="' . Yii::app()->createUrl($link, $params) . '">';
}
$out .= $title;
if (is_string($field)) {
if ($order == $field) {
$out .= $sort == 'asc' ? ' <i class="icon-chevron-up"></i>' : ' <i class="icon-chevron-down"></i>';
}
$out .= '</a>';
}
$out .= '</th>';
}
return $out;
}
示例8: run
/**
*### .run()
*
* Runs the widget.
* @since 9/21/12 8:13 PM antonio ramirez <antonio@clevertech.biz>
* Updated to use stacked progress bars
*/
public function run()
{
echo CHtml::openTag('div', $this->htmlOptions);
if (empty($this->stacked)) {
echo '<div class="bar" style="width: ' . $this->percent . '%;">' . $this->content . '</div>';
} elseif (is_array($this->stacked)) {
foreach ($this->stacked as $bar) {
$options = isset($bar['htmlOptions']) ? $bar['htmlOptions'] : array();
if (empty($options['style'])) {
$options['style'] = '';
} else {
$options['style'] .= ' ';
}
$options['style'] .= 'width: ' . $bar['percent'] . '%';
if (empty($options['class'])) {
$options['class'] = '';
} else {
$options['style'] .= ' ';
}
$options['class'] .= 'bar bar-' . $bar['type'];
echo '<div ' . CHtml::renderAttributes($options) . '>' . @$bar['content'] . '</div>';
}
}
echo '</div>';
}
示例9: array
column end">
<?php
}
?>
<?php
$attr = array('id' => CHtml::modelName($element) . '_' . $field, 'name' => CHtml::modelName($element) . '[' . $field . ']', 'placeholder' => @$htmlOptions['placeholder']);
if ($rows) {
$attr['rows'] = $rows;
}
if ($cols) {
$attr['cols'] = $cols;
}
?>
<textarea
<?php
echo CHtml::renderAttributes(array_merge($htmlOptions, $attr));
?>
><?php
echo CHtml::encode($value);
?>
</textarea>
<?php
if (!$nowrapper) {
?>
<?php
if ($button) {
?>
<button type="submit" class="<?php
echo $button['colour'];
?>
<?php
示例10: renderExtendedSummary
/**
*### .renderExtendedSummary()
*
* Renders summary
*/
public function renderExtendedSummary()
{
if (!isset($this->extendedSummaryOptions['class'])) {
$this->extendedSummaryOptions['class'] = $this->extendedSummaryCssClass;
} else {
$this->extendedSummaryOptions['class'] .= ' ' . $this->extendedSummaryCssClass;
}
echo '<div ' . CHtml::renderAttributes($this->extendedSummaryOptions) . '></div>';
}
示例11: addStylesheetTag
/**
*
* Adds stylesheet support
* @param array $htmlOptions
*/
public function addStylesheetTag($htmlOptions)
{
if (!is_array($htmlOptions)) {
throw new CException(Yii::t('EFeed', __FUNCTION__ . ' parameter must be an array.'));
}
$this->stylesheets[] = '<?xml-stylesheet ' . CHtml::renderAttributes($htmlOptions) . ' ?>';
}
示例12:
<?php
/**
* @var Notify $notify
*/
$blockParams = ['class' => 'clearfix notify' . ($notify->isRead ? ' read' : ''), 'data-id' => $notify->id];
if ($notify->url) {
$blockParams['onClick'] = "document.location.href = '" . $notify->url . "'";
}
?>
<div <?php
echo CHtml::renderAttributes($blockParams);
?>
>
<div class="left-block">
<?php
if ($notify->img) {
?>
<div class="image">
<?php
echo CHtml::image($notify->getImage());
?>
<img src="<?php
echo $link;
?>
">
</div>
<?php
}
?>
示例13: renderChart
/**
* Renders a chart based on the data series specified
* @throws CException
*/
public function renderChart()
{
$displayChart = !empty($this->grid->chartOptions) && @$this->grid->chartOptions['data'] && $this->grid->dataProvider->getItemCount();
if (!$displayChart || $this->grid->dataProvider->getItemCount() <= 0) {
return null;
}
if (!isset($this->grid->chartOptions['data']['series'])) {
throw new CException(Yii::t('zii', 'You need to set the "series" attribute in order to render a chart'));
}
$configSeries = $this->grid->chartOptions['data']['series'];
if (!is_array($configSeries)) {
throw new CException(Yii::t('zii', '"chartOptions.series" is expected to be an array.'));
}
if (!isset($this->grid->chartOptions['config'])) {
$this->grid->chartOptions['config'] = array();
}
$this->renderChartControlButtons();
$chartId = $this->grid->registerChartControlButtonsScript();
// render Chart
// chart options
$data = $this->grid->dataProvider->getData();
$count = count($data);
$seriesData = array();
$cnt = 0;
foreach ($configSeries as $set) {
$seriesData[$cnt] = array('name' => isset($set['name']) ? $set['name'] : null, 'data' => array());
for ($row = 0; $row < $count; ++$row) {
$column = $this->grid->getColumnByName($set['attribute']);
if (!is_null($column) && $column->value !== null) {
$seriesData[$cnt]['data'][] = $this->evaluateExpression($column->value, array('data' => $data[$row], 'row' => $row));
} else {
$value = CHtml::value($data[$row], $set['attribute']);
$seriesData[$cnt]['data'][] = is_numeric($value) ? (double) $value : $value;
}
}
++$cnt;
}
$options = CMap::mergeArray($this->grid->chartOptions['config'], array('series' => $seriesData));
$this->grid->chartOptions['htmlOptions'] = isset($this->grid->chartOptions['htmlOptions']) ? $this->chartOptions['htmlOptions'] : array();
// sorry but use a class to provide styles, we need this
$this->grid->chartOptions['htmlOptions']['style'] = 'display:none';
// build unique ID
// important!
echo '<div class="row-fluid">';
if ($this->grid->ajaxUpdate !== false) {
if (isset($options['chart']) && is_array($options['chart'])) {
$options['chart']['renderTo'] = $chartId;
} else {
$options['chart'] = array('renderTo' => $chartId);
}
$jsOptions = CJSON::encode($options);
if (isset($this->grid->chartOptions['htmlOptions']['data-config'])) {
unset($this->grid->chartOptions['htmlOptions']['data-config']);
}
echo "<div id='{$chartId}' " . CHtml::renderAttributes($this->grid->chartOptions['htmlOptions']) . " data-config='{$jsOptions}'></div>";
$this->grid->componentsAfterAjaxUpdate[] = "highchart{$chartId} = new Highcharts.Chart(\$('#{$chartId}').data('config'));";
}
$configChart = array('class' => 'yiiwheels.widgets.highcharts.WhHighCharts', 'id' => $chartId, 'pluginOptions' => $options, 'htmlOptions' => $this->grid->chartOptions['htmlOptions']);
$chart = Yii::createComponent($configChart);
$chart->init();
$chart->run();
echo '</div>';
}
示例14: checkBox
/**
* Generates a check box.
* @param string $name the input name
* @param boolean $checked whether the check box is checked
* @param array $htmlOptions additional HTML attributes. Besides normal HTML attributes, a few special
* attributes are also recognized (see {@link clientChange} and {@link tag} for more details.)
* Since version 1.1.2, a special option named 'uncheckValue' is available that can be used to specify
* the value returned when the checkbox is not checked. When set, a hidden field is rendered so that
* when the checkbox is not checked, we can still obtain the posted uncheck value.
* If 'uncheckValue' is not set or set to NULL, the hidden field will not be rendered.
* @return string the generated check box
* @see clientChange
* @see inputField
*/
public static function checkBox($name, $checked = false, $htmlOptions = array())
{
$label = self::popOption('label', $htmlOptions, '');
$labelOptions = self::popOption('labelOptions', $htmlOptions, array());
$checkBox = CHtml::checkBox($name, $checked, $htmlOptions);
if ($label) {
$labelOptions = self::addClassName('checkbox', $labelOptions);
ob_start();
echo '<label ' . CHtml::renderAttributes($labelOptions) . '>';
echo $checkBox;
echo $label;
echo '</label>';
return ob_get_clean();
}
return $checkBox;
}
示例15: array
/** @var TbActiveForm $form */
?>
<fieldset>
<legend>
<?php
if ($this->backUrl) {
echo CHtml::link('', $this->backUrl, array('class' => 'icon-back'));
}
?>
<?php
echo $this->title;
?>
</legend>
<?php
echo '<', $this->listTag, CHtml::renderAttributes($this->listOptions), '>';
foreach ($this->listItemData as $item) {
$this->controller->renderPartial($this->listItemView, array('item' => $item));
}
echo '</', $this->listTag, '>';
?>
</fieldset>
<div class="form-actions">
<a href="<?php
echo $this->addButtonLink;
?>
" class="btn-item-add"><i class="icon-plus"></i> <?php
echo $this->addButtonText;
?>
</a>
<?php