本文整理汇总了PHP中StringUtil::specialchars方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtil::specialchars方法的具体用法?PHP StringUtil::specialchars怎么用?PHP StringUtil::specialchars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringUtil
的用法示例。
在下文中一共展示了StringUtil::specialchars方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compile
/**
* Generate the content element
*/
protected function compile()
{
$rows = \StringUtil::deserialize($this->tableitems);
$this->Template->id = 'table_' . $this->id;
$this->Template->summary = \StringUtil::specialchars($this->summary);
$this->Template->useHeader = $this->thead ? true : false;
$this->Template->useFooter = $this->tfoot ? true : false;
$this->Template->useLeftTh = $this->tleft ? true : false;
$this->Template->sortable = $this->sortable ? true : false;
$arrHeader = array();
$arrBody = array();
$arrFooter = array();
// Table header
if ($this->thead) {
foreach ($rows[0] as $i => $v) {
// Set table sort cookie
if ($this->sortable && $i == $this->sortIndex) {
$co = 'TS_TABLE_' . $this->id;
$so = $this->sortOrder == 'descending' ? 'desc' : 'asc';
if (\Input::cookie($co) == '') {
\System::setCookie($co, $i . '|' . $so, 0);
}
}
// Add cell
$arrHeader[] = array('class' => 'head_' . $i . ($i == 0 ? ' col_first' : '') . ($i == count($rows[0]) - 1 ? ' col_last' : '') . ($i == 0 && $this->tleft ? ' unsortable' : ''), 'content' => $v != '' ? nl2br_html5($v) : ' ');
}
array_shift($rows);
}
$this->Template->header = $arrHeader;
$limit = $this->tfoot ? count($rows) - 1 : count($rows);
// Table body
for ($j = 0; $j < $limit; $j++) {
$class_tr = '';
if ($j == 0) {
$class_tr .= ' row_first';
}
if ($j == $limit - 1) {
$class_tr .= ' row_last';
}
$class_eo = $j % 2 == 0 ? ' odd' : ' even';
foreach ($rows[$j] as $i => $v) {
$class_td = '';
if ($i == 0) {
$class_td .= ' col_first';
}
if ($i == count($rows[$j]) - 1) {
$class_td .= ' col_last';
}
$arrBody['row_' . $j . $class_tr . $class_eo][] = array('class' => 'col_' . $i . $class_td, 'content' => $v != '' ? nl2br_html5($v) : ' ');
}
}
$this->Template->body = $arrBody;
// Table footer
if ($this->tfoot) {
foreach ($rows[count($rows) - 1] as $i => $v) {
$arrFooter[] = array('class' => 'foot_' . $i . ($i == 0 ? ' col_first' : '') . ($i == count($rows[count($rows) - 1]) - 1 ? ' col_last' : ''), 'content' => $v != '' ? nl2br_html5($v) : ' ');
}
}
$this->Template->footer = $arrFooter;
}
示例2: generate
/**
* Generate the widget and return it as string
*
* @return string
*/
public function generate()
{
$arrObjects = array('u' => 'cuser', 'g' => 'cgroup', 'w' => 'cworld');
$return = ' <table id="ctrl_defaultChmod" class="tl_chmod">
<tr>
<th></th>
<th scope="col">' . $GLOBALS['TL_LANG']['CHMOD']['editpage'] . '</th>
<th scope="col">' . $GLOBALS['TL_LANG']['CHMOD']['editnavigation'] . '</th>
<th scope="col">' . $GLOBALS['TL_LANG']['CHMOD']['deletepage'] . '</th>
<th scope="col">' . $GLOBALS['TL_LANG']['CHMOD']['editarticles'] . '</th>
<th scope="col">' . $GLOBALS['TL_LANG']['CHMOD']['movearticles'] . '</th>
<th scope="col">' . $GLOBALS['TL_LANG']['CHMOD']['deletearticles'] . '</th>
</tr>';
// Build rows for user, group and world
foreach ($arrObjects as $k => $v) {
$return .= '
<tr>
<th scope="row">' . $GLOBALS['TL_LANG']['CHMOD'][$v] . '</th>';
// Add checkboxes
for ($j = 1; $j <= 6; $j++) {
$return .= '
<td><input type="checkbox" name="' . $this->strName . '[]" value="' . \StringUtil::specialchars($k . $j) . '"' . static::optionChecked($k . $j, $this->varValue) . ' onfocus="Backend.getScrollOffset()"></td>';
}
$return .= '
</tr>';
}
return $return . '
</table>';
}
示例3: compile
/**
* Generate the content element
*/
protected function compile()
{
if ($this->linkTitle == '') {
$this->linkTitle = $GLOBALS['TL_LANG']['MSC']['backToTop'];
}
$this->Template->label = $this->linkTitle;
$this->Template->title = \StringUtil::specialchars($this->linkTitle);
$this->Template->request = ampersand(\Environment::get('request'), true);
}
示例4: generate
/**
* Generate the widget and return it as string
*
* @return string
*/
public function generate()
{
$arrOptions = array();
foreach ($this->arrOptions as $i => $arrOption) {
$arrOptions[] = sprintf('<input type="radio" name="%s" id="opt_%s" class="tl_radio" value="%s"%s%s onfocus="Backend.getScrollOffset()"> <label for="opt_%s">%s</label>', $this->strName, $this->strId . '_' . $i, \StringUtil::specialchars($arrOption['value']), $this->isChecked($arrOption), $this->getAttributes(), $this->strId . '_' . $i, $arrOption['label']);
}
// Add a "no entries found" message if there are no options
if (empty($arrOptions)) {
$arrOptions[] = '<p class="tl_noopt">' . $GLOBALS['TL_LANG']['MSC']['noResult'] . '</p>';
}
return sprintf('<fieldset id="ctrl_%s" class="tl_radio_container%s"><legend>%s%s%s%s</legend>%s</fieldset>%s', $this->strId, $this->strClass != '' ? ' ' . $this->strClass : '', $this->mandatory ? '<span class="invisible">' . $GLOBALS['TL_LANG']['MSC']['mandatory'] . ' </span>' : '', $this->strLabel, $this->mandatory ? '<span class="mandatory">*</span>' : '', $this->xlabel, implode('<br>', $arrOptions), $this->wizard);
}
示例5: compile
/**
* Generate the content element
*/
protected function compile()
{
$link = '/articles/';
$objArticle = $this->objArticle;
if ($objArticle->inColumn != 'main') {
$link .= $objArticle->inColumn . ':';
}
$link .= $objArticle->alias ?: $objArticle->id;
$this->Template->href = $this->objParent->getFrontendUrl($link);
// Clean the RTE output
$this->Template->text = \StringUtil::toHtml5($objArticle->teaser);
$this->Template->headline = $objArticle->title;
$this->Template->readMore = \StringUtil::specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['readMore'], $objArticle->title));
$this->Template->more = $GLOBALS['TL_LANG']['MSC']['more'];
}
示例6: toggleIcon
/**
* Return the "toggle visibility" button
*
* @param array $row
* @param string $href
* @param string $label
* @param string $title
* @param string $icon
* @param string $attributes
*
* @return string
*/
public function toggleIcon($row, $href, $label, $title, $icon, $attributes)
{
if (strlen(Input::get('tid'))) {
$this->toggleVisibility(Input::get('tid'), Input::get('state') == 1, @func_get_arg(12) ?: null);
$this->redirect($this->getReferer());
}
// Check permissions AFTER checking the tid, so hacking attempts are logged
if (!$this->User->hasAccess('tl_member_group::disable', 'alexf')) {
return '';
}
$href .= '&tid=' . $row['id'] . '&state=' . $row['disable'];
if ($row['disable']) {
$icon = 'invisible.svg';
}
return '<a href="' . $this->addToUrl($href) . '" title="' . StringUtil::specialchars($title) . '"' . $attributes . '>' . Image::getHtml($icon, $label, 'data-state="' . ($row['disable'] ? 0 : 1) . '"') . '</a> ';
}
示例7: compile
/**
* Generate the module
*
* @throws \Exception
*/
protected function compile()
{
\System::loadLanguageFile('tl_maintenance');
$this->Template->content = '';
$this->Template->href = $this->getReferer(true);
$this->Template->title = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']);
$this->Template->button = $GLOBALS['TL_LANG']['MSC']['backBT'];
foreach ($GLOBALS['TL_MAINTENANCE'] as $callback) {
$this->import($callback);
if (!$this->{$callback} instanceof \executable) {
throw new \Exception("{$callback} is not an executable class");
}
$buffer = $this->{$callback}->run();
if ($this->{$callback}->isActive()) {
$this->Template->content = $buffer;
break;
} else {
$this->Template->content .= $buffer;
}
}
}
示例8: compile
/**
* Generate the content element
*/
protected function compile()
{
$objFile = new \File($this->singleSRC);
if ($this->linkTitle == '') {
$this->linkTitle = \StringUtil::specialchars($objFile->basename);
}
$strHref = \Environment::get('request');
// Remove an existing file parameter (see #5683)
if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
$strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
}
$strHref .= (strpos($strHref, '?') !== false ? '&' : '?') . 'file=' . \System::urlEncode($objFile->value);
$this->Template->link = $this->linkTitle;
$this->Template->title = \StringUtil::specialchars($this->titleText ?: sprintf($GLOBALS['TL_LANG']['MSC']['download'], $objFile->basename));
$this->Template->href = $strHref;
$this->Template->filesize = $this->getReadableSize($objFile->filesize, 1);
$this->Template->icon = \Image::getPath($objFile->icon);
$this->Template->mime = $objFile->mime;
$this->Template->extension = $objFile->extension;
$this->Template->path = $objFile->dirname;
}
示例9: generateLink
/**
* Generate a link and return it as string
*
* @param string $strLink
* @param NewsModel $objArticle
* @param boolean $blnAddArchive
* @param boolean $blnIsReadMore
*
* @return string
*/
protected function generateLink($strLink, $objArticle, $blnAddArchive = false, $blnIsReadMore = false)
{
// Internal link
if ($objArticle->source != 'external') {
return sprintf('<a href="%s" title="%s" itemprop="url">%s%s</a>', \News::generateNewsUrl($objArticle, $blnAddArchive), \StringUtil::specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['readMore'], $objArticle->headline), true), $strLink, $blnIsReadMore ? '<span class="invisible"> ' . $objArticle->headline . '</span>' : '');
}
// Encode e-mail addresses
if (substr($objArticle->url, 0, 7) == 'mailto:') {
$strArticleUrl = \StringUtil::encodeEmail($objArticle->url);
} else {
$strArticleUrl = ampersand($objArticle->url);
}
// External link
return sprintf('<a href="%s" title="%s"%s itemprop="url">%s</a>', $strArticleUrl, \StringUtil::specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['open'], $strArticleUrl)), $objArticle->target ? ' target="_blank"' : '', $strLink);
}
示例10: generate
/**
* Generate the widget and return it as string
*
* @return string
*/
public function generate()
{
$this->import('Database');
$arrButtons = array('edit', 'copy', 'delete', 'enable', 'drag');
// Get all modules of the current theme
$objModules = $this->Database->prepare("SELECT id, name, type FROM tl_module WHERE pid=(SELECT pid FROM " . $this->strTable . " WHERE id=?) ORDER BY name")->execute($this->currentRecord);
// Add the articles module
$modules[] = array('id' => 0, 'name' => $GLOBALS['TL_LANG']['MOD']['article'][0], 'type' => 'article');
if ($objModules->numRows) {
$modules = array_merge($modules, $objModules->fetchAllAssoc());
}
$GLOBALS['TL_LANG']['FMD']['article'] = $GLOBALS['TL_LANG']['MOD']['article'];
// Add the module type (see #3835)
foreach ($modules as $k => $v) {
$v['type'] = $GLOBALS['TL_LANG']['FMD'][$v['type']][0];
$modules[$k] = $v;
}
$objRow = $this->Database->prepare("SELECT * FROM " . $this->strTable . " WHERE id=?")->limit(1)->execute($this->currentRecord);
// Show all columns and filter in PageRegular (see #3273)
$cols = array('header', 'left', 'right', 'main', 'footer');
// Add custom layout sections
if ($objRow->sections != '') {
$arrSections = \StringUtil::deserialize($objRow->sections);
if (!empty($arrSections) && is_array($arrSections)) {
foreach ($arrSections as $v) {
$cols[$v['id']] = $v['id'];
$GLOBALS['TL_LANG']['COLS'][$v['id']] = $v['title'];
}
}
}
// Get the new value
if (\Input::post('FORM_SUBMIT') == $this->strTable) {
$this->varValue = \Input::post($this->strId);
}
// Make sure there is at least an empty array
if (!is_array($this->varValue) || !$this->varValue[0]) {
$this->varValue = array('');
} else {
$arrCols = array();
// Initialize the sorting order
foreach ($cols as $col) {
$arrCols[$col] = array();
}
foreach ($this->varValue as $v) {
$arrCols[$v['col']][] = $v;
}
$this->varValue = array();
foreach ($arrCols as $arrCol) {
$this->varValue = array_merge($this->varValue, $arrCol);
}
}
// Add the label and the return wizard
$return = '<table id="ctrl_' . $this->strId . '" class="tl_modulewizard">
<thead>
<tr>
<th>' . $GLOBALS['TL_LANG']['MSC']['mw_module'] . '</th>
<th>' . $GLOBALS['TL_LANG']['MSC']['mw_column'] . '</th>
<th></th>
</tr>
</thead>
<tbody class="sortable">';
// Add the input fields
for ($i = 0, $c = count($this->varValue); $i < $c; $i++) {
$options = '';
// Add modules
foreach ($modules as $v) {
$options .= '<option value="' . \StringUtil::specialchars($v['id']) . '"' . static::optionSelected($v['id'], $this->varValue[$i]['mod']) . '>' . $v['name'] . ' [' . $v['type'] . ']</option>';
}
$return .= '
<tr>
<td><select name="' . $this->strId . '[' . $i . '][mod]" class="tl_select tl_chosen" onfocus="Backend.getScrollOffset()" onchange="Backend.updateModuleLink(this)">' . $options . '</select></td>';
$options = '';
// Add columns
foreach ($cols as $v) {
$options .= '<option value="' . \StringUtil::specialchars($v) . '"' . static::optionSelected($v, $this->varValue[$i]['col']) . '>' . $GLOBALS['TL_LANG']['COLS'][$v] . '</option>';
}
$return .= '
<td><select name="' . $this->strId . '[' . $i . '][col]" class="tl_select_column" onfocus="Backend.getScrollOffset()">' . $options . '</select></td>
<td>';
// Add buttons
foreach ($arrButtons as $button) {
if ($button == 'edit') {
$return .= ' <a href="contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->varValue[$i]['mod'] . '&popup=1&nb=1&rt=' . REQUEST_TOKEN . '" title="' . \StringUtil::specialchars($GLOBALS['TL_LANG']['tl_layout']['edit_module']) . '" class="module_link" ' . ($this->varValue[$i]['mod'] > 0 ? '' : ' style="display:none"') . ' onclick="Backend.openModalIframe({\'width\':768,\'title\':\'' . \StringUtil::specialchars(str_replace("'", "\\'", $GLOBALS['TL_LANG']['tl_layout']['edit_module'])) . '\',\'url\':this.href});return false">' . \Image::getHtml('edit.svg') . '</a>' . \Image::getHtml('edit_.svg', '', 'class="module_image"' . ($this->varValue[$i]['mod'] > 0 ? ' style="display:none"' : ''));
} elseif ($button == 'drag') {
$return .= ' <button type="button" class="drag-handle" title="' . \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['move']) . '">' . \Image::getHtml('drag.svg') . '</button>';
} elseif ($button == 'enable') {
$return .= ' <button type="button" data-command="enable" class="mw_enable" title="' . \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['mw_enable']) . '">' . \Image::getHtml($this->varValue[$i]['enable'] ? 'visible.svg' : 'invisible.svg') . '</button><input name="' . $this->strId . '[' . $i . '][enable]" type="checkbox" class="tl_checkbox mw_enable" value="1" onfocus="Backend.getScrollOffset()"' . ($this->varValue[$i]['enable'] ? ' checked' : '') . '>';
} else {
$return .= ' <button type="button" data-command="' . $button . '" title="' . \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['mw_' . $button]) . '">' . \Image::getHtml($button . '.svg') . '</button>';
}
}
$return .= '</td>
</tr>';
}
return $return . '
//.........这里部分代码省略.........
示例11: getHtml
/**
* Generate an image tag and return it as string
*
* @param string $src The image path
* @param string $alt An optional alt attribute
* @param string $attributes A string of other attributes
*
* @return string The image HTML tag
*/
public static function getHtml($src, $alt = '', $attributes = '')
{
$src = static::getPath($src);
if ($src == '') {
return '';
}
if (!is_file(TL_ROOT . '/' . $src)) {
// Handle public bundle resources
if (file_exists(TL_ROOT . '/web/' . $src)) {
$src = 'web/' . $src;
} else {
return '';
}
}
$objFile = new \File($src);
// Strip the web/ prefix (see #337)
if (strncmp($src, 'web/', 4) === 0) {
$src = substr($src, 4);
}
$static = strncmp($src, 'assets/', 7) === 0 ? TL_ASSETS_URL : TL_FILES_URL;
return '<img src="' . $static . \System::urlEncode($src) . '" width="' . $objFile->width . '" height="' . $objFile->height . '" alt="' . \StringUtil::specialchars($alt) . '"' . ($attributes != '' ? ' ' . $attributes : '') . '>';
}
示例12: editHeader
/**
* Return the edit header button
*
* @param array $row
* @param string $href
* @param string $label
* @param string $title
* @param string $icon
* @param string $attributes
*
* @return string
*/
public function editHeader($row, $href, $label, $title, $icon, $attributes)
{
return $this->User->canEditFieldsOf('tl_style_sheet') ? '<a href="' . $this->addToUrl($href . '&id=' . $row['id']) . '" title="' . StringUtil::specialchars($title) . '"' . $attributes . '>' . Image::getHtml($icon, $label) . '</a> ' : Image::getHtml(preg_replace('/\\.svg$/i', '_.svg', $icon)) . ' ';
}
示例13: getItemsAsArray
/**
* Generate all page links and return them as array
*
* @return array The page links as array
*/
public function getItemsAsArray()
{
$arrLinks = array();
$intNumberOfLinks = floor($this->intNumberOfLinks / 2);
$intFirstOffset = $this->intPage - $intNumberOfLinks - 1;
if ($intFirstOffset > 0) {
$intFirstOffset = 0;
}
$intLastOffset = $this->intPage + $intNumberOfLinks - $this->intTotalPages;
if ($intLastOffset < 0) {
$intLastOffset = 0;
}
$intFirstLink = $this->intPage - $intNumberOfLinks - $intLastOffset;
if ($intFirstLink < 1) {
$intFirstLink = 1;
}
$intLastLink = $this->intPage + $intNumberOfLinks - $intFirstOffset;
if ($intLastLink > $this->intTotalPages) {
$intLastLink = $this->intTotalPages;
}
for ($i = $intFirstLink; $i <= $intLastLink; $i++) {
if ($i == $this->intPage) {
$arrLinks[] = array('page' => $i, 'href' => null, 'title' => null);
} else {
$arrLinks[] = array('page' => $i, 'href' => $this->linkToPage($i), 'title' => \StringUtil::specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['goToPage'], $i)));
}
}
return $arrLinks;
}
示例14: generate
/**
* Generate the widget and return it as string
*
* @return string The widget markup
*/
public function generate()
{
$strOptions = '';
$blnHasGroups = false;
if ($this->multiple) {
$this->strName .= '[]';
} elseif (is_array($this->varValue)) {
$this->varValue = $this->varValue[0];
}
// Add empty option if there are none
if (empty($this->arrOptions)) {
$this->arrOptions = array(array('value' => '', 'label' => '-'));
}
foreach ($this->arrOptions as $arrOption) {
if ($arrOption['group']) {
if ($blnHasGroups) {
$strOptions .= '</optgroup>';
}
$strOptions .= sprintf('<optgroup label="%s">', \StringUtil::specialchars($arrOption['label']));
$blnHasGroups = true;
continue;
}
$strOptions .= sprintf('<option value="%s"%s>%s</option>', $arrOption['value'], $this->isSelected($arrOption), $arrOption['label']);
}
if ($blnHasGroups) {
$strOptions .= '</optgroup>';
}
return sprintf('<select name="%s" id="ctrl_%s" class="%s"%s>%s</select>', $this->strName, $this->strId, $this->class, $this->getAttributes(), $strOptions);
}
示例15: showFile
/**
* Return the show file button
*
* @param array $row
* @param string $href
* @param string $label
* @param string $title
* @param string $icon
* @param string $attributes
*
* @return string
*/
public function showFile($row, $href, $label, $title, $icon, $attributes)
{
return '<a href="contao/popup.php?src=' . base64_encode($row['id']) . '" title="' . StringUtil::specialchars($title) . '"' . $attributes . ' onclick="Backend.openModalIframe({\'width\':' . $row['popupWidth'] . ',\'title\':\'' . str_replace("'", "\\'", StringUtil::specialchars($row['fileNameEncoded'])) . '\',\'url\':this.href,\'height\':' . $row['popupHeight'] . '});return false">' . Image::getHtml($icon, $label) . '</a> ';
}