本文整理汇总了PHP中DataUtil::formatForDisplay方法的典型用法代码示例。如果您正苦于以下问题:PHP DataUtil::formatForDisplay方法的具体用法?PHP DataUtil::formatForDisplay怎么用?PHP DataUtil::formatForDisplay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataUtil
的用法示例。
在下文中一共展示了DataUtil::formatForDisplay方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_configgetvar
/**
* Obtain and display a configuration variable from the Zikula system.
*
* Available attributes:
* - name (string) The name of the configuration variable to obtain
* - html (bool) If set, the output is prepared for display by
* DataUtil::formatForDisplayHTML instead of
* DataUtil::formatForDisplay
* - assign (string) the name of a template variable to assign the
* output to, instead of returning it to the template. (optional)
*
* <i>Note that if the the result is assigned to a template variable, it is not
* prepared for display by either DataUtil::formatForDisplayHTML or
* DataUtil::formatForDisplay. If it is to be displayed, the safetext
* modifier should be used.</i>
*
* Examples:
*
* <samp><p>Welcome to {configgetvar name='sitename'}!</p></samp>
*
* <samp>{configgetvar name='sitename' assign='thename'}</samp><br>
* <samp><p>Welcome to {$thename|safetext}!</p></samp>
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the {@link Zikula_View} object.
*
* @return mixed The value of the configuration variable.
*/
function smarty_function_configgetvar($params, $view)
{
LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated.', array('configgetvar')), E_USER_DEPRECATED);
$name = isset($params['name']) ? $params['name'] : null;
$default = isset($params['default']) ? $params['default'] : null;
$html = isset($params['html']) ? $params['html'] : null;
$assign = isset($params['assign']) ? $params['assign'] : null;
if (!$name) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('configgetvar', 'name')));
return false;
}
$result = System::getVar($name, $default);
if ($assign) {
$view->assign($assign, $result);
} else {
if (is_bool($html) && $html) {
return DataUtil::formatForDisplayHTML($result);
} else {
return DataUtil::formatForDisplay($result);
}
}
}
示例2: smarty_function_manuallink
/**
* Zikula_View function to create manual link.
*
* This function creates a manual link from some parameters.
*
* Available parameters:
* - manual: name of manual file, manual.html if not set
* - chapter: an anchor in the manual file to jump to
* - newwindow: opens the manual in a new window using javascript
* - width: width of the window if newwindow is set, default 600
* - height: height of the window if newwindow is set, default 400
* - title: name of the new window if newwindow is set, default is modulename
* - class: class for use in the <a> tag
* - assign: if set, the results ( array('url', 'link') are assigned to the corresponding variable instead of printed out
*
* Example
* {manuallink newwindow=1 width=400 height=300 title=rtfm }
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return string|void
*/
function smarty_function_manuallink($params, Zikula_View $view)
{
LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated.', array('manuallink')), E_USER_DEPRECATED);
$userlang = ZLanguage::transformFS(ZLanguage::getLanguageCode());
$stdlang = System::getVar('language_i18n');
$title = isset($params['title']) ? $params['title'] : 'Manual';
$manual = isset($params['manual']) ? $params['manual'] : 'manual.html';
$chapter = isset($params['chapter']) ? '#' . $params['chapter'] : '';
$class = isset($params['class']) ? 'class="' . $params['class'] . '"' : '';
$width = isset($params['width']) ? $params['width'] : 600;
$height = isset($params['height']) ? $params['height'] : 400;
$modname = ModUtil::getName();
$possibleplaces = array("modules/{$modname}/docs/{$userlang}/manual/{$manual}", "modules/{$modname}/docs/{$stdlang}/manual/{$manual}", "modules/{$modname}/docs/en/manual/{$manual}", "modules/{$modname}/docs/{$userlang}/{$manual}", "modules/{$modname}/docs/{$stdlang}/{$manual}", "modules/{$modname}/docs/lang/en/{$manual}");
foreach ($possibleplaces as $possibleplace) {
if (file_exists($possibleplace)) {
$url = $possibleplace . $chapter;
break;
}
}
if (isset($params['newwindow'])) {
$link = "<a {$class} href='#' onclick=\"window.open( '" . DataUtil::formatForDisplay($url) . "' , '" . DataUtil::formatForDisplay($modname) . "', 'status=yes,scrollbars=yes,resizable=yes,width={$width},height={$height}'); picwin.focus();\">" . DataUtil::formatForDisplayHTML($title) . "</a>";
} else {
$link = "<a {$class} href=\"" . DataUtil::formatForDisplay($url) . "\">" . DataUtil::formatForDisplayHTML($title) . "</a>";
}
if (isset($params['assign'])) {
$ret = array('url' => $url, 'link' => $link);
$view->assign($params['assign'], $ret);
return;
} else {
return $link;
}
}
示例3: content_needleapi_content
/**
* Content needle
* @param $args['nid'] needle id
* @return array()
*/
function content_needleapi_content($args)
{
$dom = ZLanguage::getModuleDomain('Content');
// Get arguments from argument array
$nid = $args['nid'];
unset($args);
// cache the results
static $cache;
if (!isset($cache)) {
$cache = array();
}
if (!empty($nid)) {
if (!isset($cache[$nid])) {
// not in cache array
if (ModUtil::available('Content')) {
$contentpage = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $nid, 'includeContent' => false));
if ($contentpage != false) {
$cache[$nid] = '<a href="' . DataUtil::formatForDisplay(ModUtil::url('Content', 'user', 'view', array('pid' => $nid))) . '" title="' . DataUtil::formatForDisplay($contentpage['title']) . '">' . DataUtil::formatForDisplay($contentpage['title']) . '</a>';
} else {
$cache[$nid] = '<em>' . DataUtil::formatForDisplay(__('Unknown id', $dom)) . '</em>';
}
} else {
$cache[$nid] = '<em>' . DataUtil::formatForDisplay(__('Content not available', $dom)) . '</em>';
}
}
$result = $cache[$nid];
} else {
$result = '<em>' . DataUtil::formatForDisplay(__('No needle id', $dom)) . '</em>';
}
return $result;
}
示例4: addParameters
/**
* called near end of loader() before template is fetched
* @return array
*/
public static function addParameters()
{
// get plugins for tinymce
$tinymce_listplugins = ModUtil::getVar('moduleplugin.scribite.tinymce', 'activeplugins');
$tinymce_buttonmap = array('paste' => 'pastetext,pasteword,selectall', 'insertdatetime' => 'insertdate,inserttime', 'table' => 'tablecontrols,table,row_props,cell_props,delete_col,delete_row,col_after,col_before,row_after,row_before,split_cells,merge_cells', 'directionality' => 'ltr,rtl', 'layer' => 'moveforward,movebackward,absolute,insertlayer', 'save' => 'save,cancel', 'style' => 'styleprops', 'xhtmlxtras' => 'cite,abbr,acronym,ins,del,attribs', 'searchreplace' => 'search,replace');
if (is_array($tinymce_listplugins)) {
// Buttons/controls: http://www.tinymce.com/wiki.php/Buttons/controls
// We have some plugins with the button name same as plugin name
// and a few plugins with custom button names, so we have to check the mapping array.
$tinymce_buttons = array();
foreach ($tinymce_listplugins as $tinymce_button) {
if (array_key_exists($tinymce_button, $tinymce_buttonmap)) {
$tinymce_buttons = array_merge($tinymce_buttons, explode(",", $tinymce_buttonmap[$tinymce_button]));
} else {
$tinymce_buttons[] = $tinymce_button;
}
}
// TODO: I really would like to split this into multiple row, but I do not know how
// $tinymce_buttons_splitted = array_chunk($tinymce_buttons, 20);
// foreach ($tinymce_buttons_splitted as $key => $tinymce_buttonsrow) {
// $tinymce_buttonsrows[] = DataUtil::formatForDisplay(implode(',', $tinymce_buttonsrow));
// }
$tinymce_buttons = DataUtil::formatForDisplay(implode(',', $tinymce_buttons));
return array('buttons' => $tinymce_buttons);
}
return array('buttons' => '');
}
示例5: render
/**
* Render event handler.
*
* @param Zikula_Form_View $view Reference to Form render object.
*
* @return string The rendered output
*/
public function render(Zikula_Form_View $view)
{
$validators =& $view->validators;
$html = '';
foreach ($validators as $validator) {
if (!$validator->isValid) {
$label = '';
if (get_class($validator) == 'Zikula_Form_Plugin_RadioButton') {
foreach ($view->plugins as $plugin) {
if (get_class($plugin) == 'Zikula_Form_Plugin_Label' && $plugin->for == $validator->dataField) {
$label = $plugin->text;
break;
}
}
}
$label = !empty($label) ? $label : $validator->myLabel;
$html .= "<li><label for=\"{$validator->id}\">" . DataUtil::formatForDisplay($label) . ': ';
$html .= DataUtil::formatForDisplay($validator->errorMessage) . "</label></li>\n";
}
}
if ($html != '') {
$html = "<div class=\"{$this->cssClass}\">\n<ul>\n{$html}</ul>\n</div>\n";
}
return $html;
}
示例6: chgUsers
/**
* Change the users in select list
* @author: Albert Pï¿œrez Monfort (aperezm@xtec.cat)
* @param: args Array with the id of the note
* @return: Redirect to the user main page
*/
public function chgUsers($args) {
if (!SecurityUtil::checkPermission('IWforums::', '::', ACCESS_ADMIN)) {
throw new Zikula_Exception_Fatal($this->__('Sorry! No authorization to access this module.'));
}
$gid = $this->request->getPost()->get('gid', '');
if (!$gid) {
throw new Zikula_Exception_Fatal($this->__('no group id'));
}
// get group members
$sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
$groupMembers = ModUtil::func('IWmain', 'user', 'getMembersGroup',
array('sv' => $sv,
'gid' => $gid));
asort($groupMembers);
if (empty($groupMembers)) {
AjaxUtil::error($this->__('unable to get group members or group is empty for gid=') . DataUtil::formatForDisplay($gid));
}
$view = Zikula_View::getInstance('IWforums', false);
$view->assign('groupMembers', $groupMembers);
$view->assign('action', 'chgUsers');
$content = $view->fetch('IWforums_admin_ajax.htm');
return new Zikula_Response_Ajax(array('content' => $content));
}
示例7: getPanelContent
/**
* Returns the the HTML code of the content panel.
*
* @return string HTML
*/
public function getPanelContent()
{
$rows = array();
foreach ($this->_log as $log) {
$hasFileAndLine = isset($log['errfile']) && $log['errfile'] && isset($log['errline']) && $log['errline'];
$rows[] = '<tr class="DebugToolbarType' . $log['type'] . '">
<td class="DebugToolbarLogsType">' . $this->getImageForErrorType($log['type']) . ' ' . $this->errorTypeToString($log['type']) . '</td>
<td class="DebugToolbarLogsMessage">' . DataUtil::formatForDisplay($log['errstr']) . '</td>
<td class="DebugToolbarLogsFile">' . ($hasFileAndLine ? $log['errfile'] . ':' . $log['errline'] : '-') . '</td>
</tr>';
}
if (empty($rows)) {
$rows[] = '<tr>
<td colspan="3">' . __('No items found.') . '</td>
</tr>';
}
return '<table class="DebugToolbarTable">
<tr>
<th class="DebugToolbarLogsType">' . __('Type') . '</th>
<th class="DebugToolbarLogsMessage">' . __('Message') . '</th>
<th class="DebugToolbarLogsFile">' . __('File: Line') . '</th>
</tr>
' . implode(' ', $rows) . '
</table>';
}
示例8: smarty_function_mediashare_breadcrumb
function smarty_function_mediashare_breadcrumb($params, &$smarty)
{
$dom = ZLanguage::getModuleDomain('mediashare');
if (!isset($params['albumId'])) {
$smarty->trigger_error(__f('Missing [%1$s] in \'%2$s\'', array('albumId', 'mediashare_breadcrumb'), $dom));
return false;
}
$mode = isset($params['mode']) ? $params['mode'] : 'view';
$breadcrumb = pnModAPIFunc('mediashare', 'user', 'getAlbumBreadcrumb', array('albumId' => (int) $params['albumId']));
if ($breadcrumb === false) {
$smarty->trigger_error(LogUtil::getErrorMessagesText());
return false;
}
$urlType = $mode == 'edit' ? 'edit' : 'user';
$url = pnModUrl('mediashare', $urlType, 'view', array('aid' => 0));
$result = "<div class=\"mediashare-breadcrumb\">";
$first = true;
foreach ($breadcrumb as $album) {
$url = DataUtil::formatForDisplay(pnModUrl('mediashare', $urlType, 'view', array('aid' => $album['id'])));
$result .= ($first ? '' : ' » ') . "<a href=\"{$url}\">" . htmlspecialchars($album['title']) . "</a>";
$first = false;
}
$result .= "</div>";
if (isset($params['assign'])) {
$smarty->assign($params['assign'], $result);
}
return $result;
}
示例9: initialize
public function initialize(Zikula_Form_View $view)
{
if (!SecurityUtil::checkPermission('Mailer::', '::', ACCESS_ADMIN)) {
throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
}
// assign the module mail agent types
$view->assign('mailertypeItems', array(
array('value' => 1, 'text' => DataUtil::formatForDisplay($this->__("Internal PHP `mail()` function"))),
array('value' => 2, 'text' => DataUtil::formatForDisplay($this->__('Sendmail message transfer agent'))),
array('value' => 3, 'text' => DataUtil::formatForDisplay($this->__('QMail message transfer agent'))),
array('value' => 4, 'text' => DataUtil::formatForDisplay($this->__('SMTP mail transfer protocol'))),
array('value' => 5, 'text' => DataUtil::formatForDisplay($this->__('Development/debug mode (Redirect e-mails to LogUtil)')))
));
$view->assign('encodingItems', array(
array('value' => '8bit', 'text' => '8bit'),
array('value' => '7bit', 'text' => '7bit'),
array('value' => 'binary', 'text' => 'binary'),
array('value' => 'base64', 'text' => 'base64'),
array('value' => 'quoted-printable', 'text' => 'quoted-printable')
));
$view->assign('smtpsecuremethodItems', array(
array('value' => '', 'text' => 'None'),
array('value' => 'ssl', 'text' => 'SSL'),
array('value' => 'tls', 'text' => 'TLS')
));
// assign all module vars
$this->view->assign($this->getVars());
return true;
}
示例10: toggleblock
/**
* Toggleblock.
*
* This function toggles active/inactive.
*
* @param bid int id of block to toggle.
*
* @return mixed true or Ajax error
*/
public function toggleblock()
{
$this->checkAjaxToken();
$this->throwForbiddenUnless(SecurityUtil::checkPermission('Blocks::', '::', ACCESS_ADMIN));
$bid = $this->request->request->get('bid', -1);
if ($bid == -1) {
throw new Zikula_Exception_Fatal($this->__('No block ID passed.'));
}
// read the block information
$blockinfo = BlockUtil::getBlockInfo($bid);
if ($blockinfo == false) {
throw new Zikula_Exception_Fatal($this->__f('Error! Could not retrieve block information for block ID %s.', DataUtil::formatForDisplay($bid)));
}
if ($blockinfo['active'] == 1) {
ModUtil::apiFunc('Blocks', 'admin', 'deactivate', array('bid' => $bid));
} else {
ModUtil::apiFunc('Blocks', 'admin', 'activate', array('bid' => $bid));
}
return new Zikula_Response_Ajax(array('bid' => $bid));
}
示例11: smarty_function_modgetvar
/**
* Zikula_View function to get module variable
*
* This function obtains a module-specific variable from the Zikula system.
*
* Note that the results should be handled by the safetext or the safehtml
* modifier before being displayed.
*
*
* Available parameters:
* - module: The well-known name of a module from which to obtain the variable
* - name: The name of the module variable to obtain
* - assign: If set, the results are assigned to the corresponding variable instead of printed out
* - html: If true then result will be treated as html content
* - default: The default value to return if the config variable is not set
*
* Example
* {modgetvar module='Example' name='foobar' assign='foobarOfExample'}
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return string The module variable.
*/
function smarty_function_modgetvar($params, Zikula_View $view)
{
$assign = isset($params['assign']) ? $params['assign'] : null;
$default = isset($params['default']) ? $params['default'] : null;
$module = isset($params['module']) ? $params['module'] : null;
$html = isset($params['html']) ? (bool) $params['html'] : false;
$name = isset($params['name']) ? $params['name'] : null;
if (!$module) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modgetvar', 'module')));
return false;
}
if (!$name && !$assign) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modgetvar', 'name')));
return false;
}
if (!$name) {
$result = ModUtil::getVar($module);
} else {
$result = ModUtil::getVar($module, $name, $default);
}
if ($assign) {
$view->assign($assign, $result);
} else {
if ($html) {
return DataUtil::formatForDisplayHTML($result);
} else {
return DataUtil::formatForDisplay($result);
}
}
}
示例12: changeModuleCategory
/**
* Change the category a module belongs to by ajax.
*
* @return AjaxUtil::output Output to the calling ajax request is returned.
* response is a string moduleid on sucess.
*/
public function changeModuleCategory()
{
$this->checkAjaxToken();
$this->throwForbiddenUnless(SecurityUtil::checkPermission('Admin::', '::', ACCESS_ADMIN));
$moduleID = $this->request->getPost()->get('modid');
$newParentCat = $this->request->getPost()->get('cat');
//get info on the module
$module = ModUtil::getInfo($moduleID);
if (!$module) {
//deal with couldnt get module info
throw new Zikula_Exception_Fatal($this->__('Error! Could not get module name for id %s.'));
}
//get the module name
$displayname = DataUtil::formatForDisplay($module['displayname']);
$module = $module['name'];
$oldcid = ModUtil::apiFunc('Admin', 'admin', 'getmodcategory', array('mid' => $moduleID));
//move the module
$result = ModUtil::apiFunc('Admin', 'admin', 'addmodtocategory', array('category' => $newParentCat, 'module' => $module));
if (!$result) {
throw new Zikula_Exception_Fatal($this->__('Error! Could not add module to module category.'));
}
$output = array();
$output['response'] = $moduleID;
$output['newParentCat'] = $newParentCat;
$output['oldcid'] = $oldcid;
$output['modulename'] = $displayname;
$output['url'] = ModUtil::url($module, 'admin', 'main');
return new Zikula_Response_Ajax($output);
}
示例13: setstatus
/**
* This function sets active/inactive status.
*
* @param eid
*
* @return mixed true or Ajax error
*/
public function setstatus()
{
$this->checkAjaxToken();
$this->throwForbiddenUnless(SecurityUtil::checkPermission('Ephemerides::', '::', ACCESS_ADMIN));
$eid = $this->request->request->get('eid', 0);
$status = $this->request->request->get('status', 0);
$alert = '';
if ($eid == 0) {
$alert .= $this->__('No ID passed.');
} else {
$item = array('eid' => $eid, 'status' => $status);
$res = DBUtil::updateObject($item, 'ephem', '', 'eid');
if (!$res) {
$alert .= $item['eid'] . ', ' . $this->__f('Could not change item, ID %s.', DataUtil::formatForDisplay($eid));
if ($item['status']) {
$item['status'] = 0;
} else {
$item['status'] = 1;
}
}
}
// get current status to return
$item = ModUtil::apiFunc($this->name, 'user', 'get', array('eid' => $eid));
if (!$item) {
$alert .= $this->__f('Could not get data, ID %s.', DataUtil::formatForDisplay($eid));
}
return new Zikula_Response_Ajax(array('eid' => $eid, 'status' => $item['status'], 'alert' => $alert));
}
示例14: smarty_function_nextpostlink
/**
* Smarty function to display a link to the next post
*
* Example
* <!--[nextpostlink sid=$info.sid layout='%link% <span class="news_metanav">»</span>']-->
*
* @author Mark West
* @since 20/10/03
* @see function.nextpostlink.php::smarty_function_nextpostlink()
* @param array $params All attributes passed to this function from the template
* @param object &$smarty Reference to the Smarty object
* @param integer $sid article id
* @param string $layout HTML string in which to insert link
* @return string the results of the module function
*/
function smarty_function_nextpostlink($params, &$smarty)
{
if (!isset($params['sid'])) {
// get the info template var
$info = $smarty->get_template_vars('info');
$params['sid'] = $info['sid'];
}
if (!isset($params['layout'])) {
$params['layout'] = '%link% <span class="news_metanav">»</span>';
}
$article = ModUtil::apiFunc('News', 'user', 'getall',
array('query' => array(array('sid', '>', $params[sid])),
'orderdir' => 'ASC',
'numitems' => 1));
if (!$article) {
return;
}
$articlelink = '<a href="'.DataUtil::formatForDisplay(ModUtil::url('News', 'user', 'display', array('sid' => $article[0]['sid']))).'">'.DataUtil::formatForDisplay($article[0]['title']).'</a>';
$articlelink = str_replace('%link%', $articlelink, $params['layout']);
if (isset($params['assign'])) {
$smarty->assign($params['assign'], $articlelink);
} else {
return $articlelink;
}
}
示例15: renderFootnotes
/**
* Render the links into a list and return html.
* @return string
*/
private function renderFootnotes()
{
$text = '';
if (!empty($this->links)) {
$text .= '<div><strong>' . __('Links') . '</strong>';
$text .= '<ol>';
$this->links = array_unique($this->links);
foreach ($this->links as $key => $link) {
// check for an e-mail address
if (preg_match("/^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}\$/i", $link)) {
$linkText = $link;
$link = 'mailto:' . $link;
} else {
$linkText = $link;
}
$linkText = \DataUtil::formatForDisplay($linkText);
$link = \DataUtil::formatForDisplay($link);
// output link
$text .= '<li><a class="print-normal" href="' . $link . '">' . $linkText . '</a></li>' . "\n";
}
$text .= '</ol>';
$text .= '</div>';
}
return $text;
}