/** * Converts a string to a xml-safe string * Converts it to html-safe first and then it * will replace html entities to xml entities * * <code> * * echo xml::encode('some über crazy stuff'); * // output: some über crazy stuff * * </code> * * @param string $text * @param boolean $html True: convert to html first * @return string */ public static function encode($string, $html = true) { // convert raw text to html safe text if ($html) { $text = html::encode($string, false); } // convert html entities to xml entities return strtr($text, html::entities()); }
public static function attributes($attrs, $value = NULL) { if (empty($attrs)) { return ''; } if (is_string($attrs)) { if (!isset($value)) { return ' ' . $attrs; } if (empty($value)) { return ''; } return ' ' . $attrs . '="' . html::encode($value) . '"'; } $str = ''; if (is_array($attrs)) { foreach ($attrs as $key => $val) { if (!empty($val)) { $str .= ' ' . $key . '="' . html::encode($val) . '"'; } } } return $str; }
<!-- <div class="mm-m-y-param"> <div><span class='l-param'>Год:</span> <span class='v-param'><?php echo html::encode($model->year); ?> </span></div> <div><span class='l-param'>Мощность:</span> <span class='v-param'><?php echo html::encode($model->power); ?> л/с</span></div> </div> --> <div class="nma--r-pledge"><span class="difficult">Залог:</span> <span class="difficult-count"> <?php if ($model->pledge == NULL) { echo "без залога"; } else { ?> <?php echo html::encode($model->pledge); ?> <span class='rubl'>Р</span> <?php } ?> </span> </div> </div> </div> <div style="clear:both;"></div>
</td> <td><input type="number" name="<?php echo $order['amount']; ?> " min="1" id="number-<?php echo html::encode($value['id']); ?> " max="1000" /></td> <td><input name="box" type="checkbox" value="<?php echo html::encode($value['id']); ?> " id="<?php echo html::encode($value['id']); ?> " /></td> </tr> <?php } ?> </tbody> </table> </div> <?php echo LinkPager::widget(['pagination' => $pages]); ?> <!-- <div class="tcdPageCode left_page"></div> --> </div>
/** * 单选输入框 * * @param $attrs array 控件参数 * @return string 控件代码 */ public static function radio($attrs) { $options = arr::take('options', $attrs); $options = field::_option($options); $value = arr::take('value', $attrs); $attrs['class'] = isset($attrs['class']) ? 'radio ' . $attrs['class'] : 'radio'; //默认样式inline,允许传入block使得checkbox每个元素显示一行 $valid = arr::take('valid', $attrs); $html[] = '<ul' . html::attributes($attrs) . '>'; if (is_array($options)) { $i = 1; foreach ($options as $val => $text) { $checked = $val == $value ? ' checked="checked"' : ''; //这儿代码可能有问题,请检查 $html[] = ' <li>'; $html[] = ' <input type="radio" name="' . $attrs['name'] . '" id="' . $attrs['name'] . '-item' . $i . '" value="' . $val . '"' . $checked . '' . (isset($valid) && $i == 1 ? ' valid = "' . $valid . '"' : '') . '/>'; $html[] = ' <label for="' . $attrs['name'] . '-item' . $i . '">' . html::encode($text) . '</label>'; $html[] = ' </li>'; //这儿代码不完美 $i++; } } $html[] = '</ul>'; if (isset($valid)) { $html[] = '<label for="' . $attrs['name'] . '" class="error">' . $attrs['title'] . '</label>'; } return implode("\n", $html); }
/** * Shortcut for html() * * @see html() */ function h($text, $keepTags = true) { return html::encode($text, $keepTags); }
//Columna "LINEA"= orden + titulo(serie,numero,idLinea) echo '<td class="cen" title="' . html::encode(sprintf('%s/%06d [%d]', $modelo->serie, $modelo->numero, $modelo->idLinea)) . '">' . html::encode(sprintf('%d', $modelo->orden)) . '</td>'; //Columna ARTICULO $articulo = $modelo->refArt; if ($articulo === null) { $articulo = '...'; } else { if (!$modelo->cargarArticulo()) { $articulo = '*' . $articulo; //indicar una referencia que no existe en la bd. } } //if echo '<td class="cen">' . html::encode($articulo) . '</td>'; //Columna DESCRIPCION echo '<td class="izq">' . html::encode($modelo->texto) . '</td>'; //Columna CANTIDAD echo '<td class="der">' . sprintf('%d', $modelo->cantidad) . '</td>'; //Columna PRECIO echo '<td class="der">' . sprintf('%0.2f', $modelo->precio) . '</td>'; //Columna %IVA echo '<td class="der">' . sprintf('%0.2f', $modelo->iva) . '</td>'; //Columna IMPORTE echo '<td class="der">' . sprintf('%0.2f', $modelo->importeBase) . '</td>'; echo '</tr>'; //---------- //Acumular las bases y cuotas de iva... if (!isset($sumas[$modelo->iva])) { $sumas[$modelo->iva] = array('base' => 0.0, 'iva' => 0.0); } //if
<?php //Pieza de generación del "menu izquierdo"... ?> <div class="menu"> <ul> <li><a href="?a=inicio">Inicio</a></li> <li><a href="?a=clientes">Clientes</a></li> <li><a href="?a=articulos">Articulos</a></li> <li><a href="?a=pedidos">Pedidos</a></li> <?php $usuario = sesion::get('usuario'); if ($usuario !== null) { ?> <li><a href="?a=clientes.ver&id=<?php echo html::encode($usuario->referencia); ?> ">Mis datos</a></li> <?php } ?> </ul> </div>
?> </td> </tr> <tr> <th>Cantidad</th> <td><?php echo html::encode($miCarro[$key]->cantidad); ?> </td> </tr> <tr> <th>Total por producto</th> <td><?php echo html::encode($miCarro[$key]->cantidad * $miCarro[$key]->precio) . '€'; ?> </td> </tr> <tr> <td colspan="2"><div class="acciones"><?php vista::generarPieza('boton_accion', array('texto' => 'Eliminar del carro', 'icono' => 'editar.png', 'activo' => false, 'url' => array('a' => 'carrito.eliminar', 'id' => $miCarro[$key]->referencia, 'p' => $pagina))); ?> </div></td> </tr> </tbody> </table> <?php $totalCarro = $totalCarro + $miCarro[$key]->cantidad * $miCarro[$key]->precio; ?>
?> </td></tr> <tr><th>Cliente</th><td><?php echo html::encode($cliente); ?> </td></tr> <tr><th>Dom. Envio</th><td><?php echo html::encode($modelo->domEnvio); ?> </td></tr> <tr><th>Estado</th><td><?php echo html::encode($estado); ?> </td></tr> <tr><th>Notas</th><td><?php echo html::encode($modelo->notas); ?> </td></tr> <tr><td colspan="2"><?php vista::generarParcial('pedido_ficha_lineas', array('modelos' => $modelo->lineas, 'pedido' => $modelo)); ?> </td></tr> <?php } else { ?> <tr><th>Error</th><td><?php echo $error; ?> </td></tr> <?php }
value="<?php echo html::encode($modelo->notas); ?> "/> </td></tr> <tr><th>E-Mail</th><td> <input type="text" name="cliente[email]" id="cliente_email" maxlength="100" value="<?php echo html::encode($modelo->email); ?> "/> </td></tr> <tr><th>Password</th><td> <input type="password" name="cliente[password]" id="cliente_password" maxlength="32" value="<?php echo html::encode($modelo->password); ?> "/> </td></tr> <?php } else { ?> <tr><th>Error</th><td><?php echo $error; ?> </td></tr> <?php } //if ?> </tbody>
<th>Dom.Fiscal</th> <th>Acciones</th> </tr> </thead> <tbody> <?php //Generar los registros obtenidos de clientes. $cli = new cliente(); foreach ($registros as $indice => $registro) { $cli->llenar($registro); echo '<tr class="' . ($indice % 2 == 0 ? 'par' : 'impar') . '">'; echo '<td class="cen">' . html::encode($cli->referencia) . '</td>'; echo '<td class="cen">' . html::encode($cli->cifnif) . '</td>'; echo '<td class="izq">' . html::encode($cli->nombre) . '</td>'; echo '<td class="izq">' . html::encode($cli->apellidos) . '</td>'; echo '<td class="izq">' . html::encode($cli->domFiscal) . '</td>'; echo '<td class="cen">'; echo '<div class="acciones">'; //-- echo 'Ver Modificar Eliminar'; //if (tiene_permiso( 'clientes.ver')) vista::generarPieza('boton_accion', array('texto' => 'Ver', 'icono' => 'ver.png', 'activo' => false, 'url' => array('a' => 'clientes.ver', 'id' => $cli->referencia, 'p' => $pagina))); //if (tiene_permiso( 'clientes.editar')) vista::generarPieza('boton_accion', array('texto' => 'Editar', 'icono' => 'editar.png', 'activo' => false, 'url' => array('a' => 'clientes.editar', 'id' => $cli->referencia, 'p' => $pagina))); //if (tiene_permiso( 'clientes.borrar')) vista::generarPieza('boton_accion', array('texto' => 'Borrar', 'icono' => 'borrar.png', 'activo' => false, 'url' => array('a' => 'clientes.borrar', 'id' => $cli->referencia, 'p' => $pagina))); echo '</div>'; echo '</td>'; echo '</tr>'; } //foreach ?>
<th>Notas</th> <th>Acciones</th> </tr> </thead> <tbody> <?php //Generar los registros obtenidos de articulos. $modelo = new articulo(); foreach ($registros as $indice => $registro) { $modelo->llenar($registro); echo '<tr class="' . ($indice % 2 == 0 ? 'par' : 'impar') . '">'; echo '<td class="cen">' . html::encode($modelo->referencia) . '</td>'; echo '<td class="cen">' . html::encode($modelo->texto) . '</td>'; echo '<td class="der">' . sprintf('%0.2f', $modelo->precio) . '</td>'; echo '<td class="der">' . sprintf('%0.2f', $modelo->iva) . '</td>'; echo '<td class="izq">' . html::encode($modelo->notas) . '</td>'; echo '<td class="cen">'; echo '<div class="acciones">'; //-- echo 'Ver Modificar Eliminar'; //if (tiene_permiso( 'articulos.ver')) vista::generarPieza('boton_accion', array('texto' => 'Ver', 'icono' => 'ver.png', 'activo' => false, 'url' => array('a' => 'articulos.ver', 'id' => $modelo->referencia, 'p' => $pagina))); //if (tiene_permiso( 'articulos.editar')) vista::generarPieza('boton_accion', array('texto' => 'Editar', 'icono' => 'editar.png', 'activo' => false, 'url' => array('a' => 'articulos.editar', 'id' => $modelo->referencia, 'p' => $pagina))); //if (tiene_permiso( 'articulos.borrar')) vista::generarPieza('boton_accion', array('texto' => 'Borrar', 'icono' => 'borrar.png', 'activo' => false, 'url' => array('a' => 'articulos.borrar', 'id' => $modelo->referencia, 'p' => $pagina))); echo '</div>'; echo '</td>'; echo '</tr>'; } //foreach ?>
/** * 多选输入框 * * @param $attrs array 控件参数 * @return string 控件代码 */ public static function checkbox($attrs) { $options = array_take('options', $attrs); //取出options,并unset,这儿用了一个自定义的函数array_take //$options = html::options($options); //格式化数组 $value = array_take('value', $attrs); //即取出了value和options,又把他们从$attrs中去掉了 if (!is_array($value)) { $value = array($value); } $attrs['class'] = isset($attrs['class']) ? 'checkbox ' . $attrs['class'] : 'checkbox'; //默认样式inline,允许传入block使得checkbox每个元素显示一行 $html[] = '<ul' . html::attributes($attrs) . '>'; if (is_array($options)) { $i = 1; foreach ($options as $val => $text) { $checked = in_array($val, $value) ? ' checked="checked"' : ''; //这儿代码可能有问题,请检查 $html[] = '<li><input type="checkbox" name="' . $attrs['name'] . '[]" id="' . $attrs['name'] . '-item' . $i . '" value="' . $val . '"' . $checked . '/><label for="' . $attrs['name'] . '-item' . $i . '">' . html::encode($text) . '</label></li>'; //这儿代码不完美 $i++; } } $html[] = '</ul>'; return implode("\n", $html); }
/** * 文本段输入控件 * * @param $attrs array 控件参数 * @return string 控件代码 */ public static function textarea($attrs) { $attrs['class'] = isset($attrs['class']) ? 'textarea ' . $attrs['class'] : 'textarea'; $attrs += array('rows' => '8', 'cols' => '5'); $value = arr::take('value', $attrs); return '<textarea' . html::attributes($attrs) . '>' . html::encode($value) . '</textarea>'; }
</th> <th> <?php echo Yii::t('app', '状态'); ?> </th> </tr> </thead> <tbody> <?php foreach ($model as $v) { ?> <tr> <td> <?php echo html::encode($v['id']); ?> </td> <td> <?php echo Html::encode($v['username']); ?> </td> <td> <?php echo Html::encode($v['email']); ?> </td> <td> <?php echo Html::encode($v['zipcode']);
/** * Converts a string to a html-safe string * * <code> * * echo str::html('some <em>über crazy</em> stuff'); * // output: some <em>über crazy</em> stuff * * echo str::html('some <em>über crazy</em> stuff', false); * // output: some <em>über crazy</em> stuff * * </code> * * @param string $string * @param boolean $keepTags True: lets stuff inside html tags untouched. * @return string The html string */ public static function html($string, $keepTags = true) { return html::encode($string, $keepTags); }
<br> <table> <?php foreach ($model as $preparat) { print "<tr>"; if ($preparat['is_active'] == 1) { $color = "#5cb85c"; } else { $color = "#d9534f"; } print "<td width=\"10px\"> <span class=\"glyphicon glyphicon-ok\" style='color: {$color}'></span> </td>"; print "<td width=\"10px\"> </td>"; print "<td> <a href=\"" . Url::toRoute("preparat/update/{$preparat['id']}") . "\" title=\"Update\" aria-label=\"Update\" data-pjax=\"0\"><span class=\"glyphicon glyphicon-pencil\"></span></a></td>"; print "<td> " . html::encode($preparat['name']) . "</td>"; print "<td>" . html::encode($preparat['manuf']) . "</td>"; print "</tr>"; } ?> </table> <?php /* GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], 'id', 'name',
echo $model->account->phone; ?> </span> </div> <div class="mm-name"><?php echo html::encode($model->name); echo $model->year ? ", " . $model->year : ""; ?> </div> <div class="mm-cat"><?php echo $model->getCategoryList($model->category); ?> </div> <p class="mm-other"><?php echo html::encode($model->info); ?> </p> <div class="shadow2" style="padding-bottom: 5px;"> <div class="shadow2-1"> <span>Цены</span> <span style="margin-left: 18px; display: inline-block; text-align: center; width: 200px;">Характеристики</span> <span style="display: inline-block;text-align: center; width: 200px;">Условия</span> </div> <div style="clear:both;"></div> <div style="float:left;width:210px;" class="it-33"> <div class="vls"> <?php echo $model->cost1 ? "<span>" . $model->cost1 . " руб</span> на 1 сутки" : "";
<ul style="width: 570px;float: left;" id="list-bread"> <li><a href="<?php echo Url::toRoute(['site/index', 'city_url' => $model->account->city->trans]); ?> ">Прокат авто в <?php echo html::encode($model->account->city->padezh); ?> </a><span> > </span></li> <li><a href="<?php echo Url::toRoute(['cars/our-cars', 'city_url' => $model->account->city->trans, 'slug_url' => $model->account->slug_url]); ?> ">Автопрокат <?php echo html::encode($model->account->username); ?> </a><span> > </span></li> <li><?php echo $model->name; ?> </li> </ul> </div> <div class="col-xs-4 right-bread "> <span style="color: #767676;"><?php echo html::encode($model->account->address); ?> </span> | г.<?php echo html::encode($this->context->city); ?> </div> </div>
public static function button(array $attrs) { $attrs['type'] = isset($attrs['type']) ? $attrs['type'] : 'button'; $attrs['class'] = isset($attrs['class']) ? 'button ' . $attrs['class'] : 'button'; $value = arr::take('value', $attrs); $icon = arr::take('icon', $attrs); $icon = empty($icon) ? 'empty' : $icon; return '<button' . html::attributes($attrs) . '><p><span class="button-icon zotop-icon zotop-icon-' . $icon . '"></span><span class="button-text">' . html::encode($value) . '</span></p></button>'; }
foreach ($model['items'] as $value) { ?> <?php if ($i <= 4) { ?> <li> <img src="<?php echo $_SERVER['BACKEND_WEB'] . $value['img']; ?> " /> <span class="span_1"><?php echo html::encode($value['price']); ?> </span> <span style="color:#333333;"><?php echo html::encode($value['sexual_taste']); ?> </span> </li> <?php } ?> <?php ++$i; } ?> </ul> </div> <div class="main_telphone"> <div class="telphone_qq"> <div class="qq_title"><img src="<?php
<?php use yii\helpers\Html; ?> <h1><?php echo html::encode($model->helloString); ?> </h1>
$form = ActiveForm::begin(['enableClientValidation' => false, 'validateOnSubmit' => false, 'validateOnBlur' => false, 'action' => 'https://money.yandex.ru/quickpay/confirm.xml', 'id' => 'formpay']); ?> <input type="hidden" name="receiver" value="<?php echo Yii::$app->params['yandexId']; ?> "/> <input type="hidden" name="formcomment" value="Only3.ru. Прокат авто" /> <input type="hidden" name="short-dest" value="Only3.ru. Прокат авто" /> <input type="hidden" name="label" value="<?php echo $rentModel->id; ?> " /> <input type="hidden" name="quickpay-form" value="donate" /> <input type="hidden" name="targets" value="Бронирование <?php echo html::encode($systemModel->name); echo $systemModel->year ? ", " . $systemModel->year : ""; ?> " /> <input type="hidden" name="sum" value="<?php echo $rentModel->summ; ?> " data-type="number" /> <input type="hidden" name="comment" value="" /> <input type="hidden" name="need-fio" value="false"/> <input type="hidden" name="need-email" value="false" /> <input type="hidden" name="need-phone" value="false"/> <input type="hidden" name="need-address" value="false"/> <div class='row-formpay' style="background-image: url('/images/i-credit.png');"> <input type="radio" name="paymentType" value="AC" checked id="input-type-card" />
<h1>Catálogo</h1> <div class="hoja"> <?php $articulo = new articulo(); foreach ($registros as $indice => $registro) { $articulo->llenar($registro); echo '<table>'; echo '<tbody class="ficha">'; echo '<tr>'; echo '<th>Texto: </th>'; echo '<td>' . html::encode($articulo->texto) . '</td>'; echo '</tr>'; echo '<tr>'; echo '<th>Precio: </th>'; echo '<td>' . html::encode($articulo->precio) . '€</td>'; echo '</tr>'; echo '<tr>'; echo '<td colspan="2">'; echo '<div class="acciones">'; vista::generarPieza('boton_accion', array('texto' => 'Detalles', 'icono' => 'ver.png', 'activo' => false, 'url' => array('a' => 'inicio.ver', 'id' => $articulo->referencia, 'p' => $pagina))); vista::generarPieza('boton_accion', array('texto' => 'Añadir al carro', 'icono' => 'editar.png', 'activo' => false, 'url' => array('a' => 'carrito.introducir', 'id' => $articulo->referencia, 'p' => $pagina))); echo '</div>'; echo '</td>'; echo '</tr>'; echo '<hr>'; } echo '</tbody>'; echo '</table>'; echo '<hr>'; echo '<table>'; echo '<tfoot>';
public static function input(array $attrs) { $attrs['type'] = isset($attrs['type']) ? $attrs['type'] : 'text'; if (isset($attrs['name'])) { $attrs['id'] = isset($attrs['id']) ? $attrs['id'] : $attrs['name']; } $attrs['value'] = isset($attrs['value']) ? html::encode($attrs['value']) : ''; return '<input' . html::attributes($attrs) . '/>'; }
echo $systemModel->account->phone; ?> </span> </div> <div class="mm-name"><?php echo html::encode($systemModel->name); echo $systemModel->year ? ", " . $systemModel->year : ""; ?> </div> <div class="mm-cat"><?php echo $systemModel->getCategoryList($systemModel->category); ?> </div> <p class="mm-other"><?php echo html::encode($systemModel->info); ?> </p> <div class="shadow2" style="padding-bottom: 5px;"> <div class="shadow2-1"> <span>Цены</span> <span style="margin-left: 18px; display: inline-block; text-align: center; width: 200px;">Характеристики</span> <span style="display: inline-block;text-align: center; width: 200px;">Условия</span> </div> <div style="clear:both;"></div> <div style="float:left;width:210px;" class="it-33"> <div class="vls"> <?php echo $systemModel->cost1 ? "<span>" . $systemModel->cost1 . " <span style='font-size: 14px;font-weight: normal;' class='rubl'>Р</span></span> на 1 сутки" : "";