本文整理汇总了PHP中ZLanguage::transformFS方法的典型用法代码示例。如果您正苦于以下问题:PHP ZLanguage::transformFS方法的具体用法?PHP ZLanguage::transformFS怎么用?PHP ZLanguage::transformFS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZLanguage
的用法示例。
在下文中一共展示了ZLanguage::transformFS方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderDocument
/**
* Render and display the specified legal document, or redirect to the specified custom URL if it exists.
*
* If a custom URL for the legal document exists, as specified by the module variable identified by $customUrlKey, then
* this function will redirect the user to that URL.
*
* If no custom URL exists, then this function will render and return the appropriate template for the legal document, as
* specified by $documentName. If the legal document
*
* @param string $documentName The "name" of the document, as specified by the names of the user and text template
* files in the format 'legal_user_documentname.tpl' and 'legal_text_documentname.tpl'.
* @param string $accessInstanceKey The string used in the instance_right part of the permission access key for this document.
* @param string $activeFlagKey The string used to name the module variable that indicates whether this legal document is
* active or not; typically this is a constant from {@link Legal_Constant}, such as
* {@link Legal_Constant::MODVAR_LEGALNOTICE_ACTIVE}.
* @param string $customUrlKey The string used to name the module variable that contains a custom static URL for the
* legal document; typically this is a constant from {@link Legal_Constant}, such as
* {@link Legal_Constant::MODVAR_TERMS_URL}.
*
* @return string HTML output string
*
* @throws Zikula_Exception_Forbidden Thrown if the user does not have the appropriate access level for the function.
*/
private function renderDocument($documentName, $accessInstanceKey, $activeFlagKey, $customUrlKey)
{
// Security check
if (!SecurityUtil::checkPermission($this->name . '::' . $accessInstanceKey, '::', ACCESS_OVERVIEW)) {
throw new Zikula_Exception_Forbidden();
}
if (!$this->getVar($activeFlagKey)) {
return $this->view->fetch('legal_user_policynotactive.tpl');
} else {
$customUrl = $this->getVar($customUrlKey, '');
if (empty($customUrl)) {
// work out the template path
$template = "legal_user_{$documentName}.tpl";
// get the current users language
$languageCode = ZLanguage::transformFS(ZLanguage::getLanguageCode());
if (!$this->view->template_exists("{$languageCode}/legal_text_{$documentName}.tpl")) {
$languageCode = 'en';
}
return $this->view->assign('languageCode', $languageCode)
->fetch($template);
} else {
$this->redirect($customUrl);
}
}
}
示例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: smarty_function_lang
/**
* Zikula_View function to get the site's language.
*
* Available parameters:
* - assign if set, the language will be assigned to this variable
*
* Example
* <html lang="{lang}">
*
* @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 The language, null if params['assign'] is true.
*/
function smarty_function_lang($params, Zikula_View $view)
{
$assign = isset($params['assign']) ? $params['assign'] : null;
$fs = isset($params['fs']) ? $params['fs'] : false;
$result = $fs ? ZLanguage::transformFS(ZLanguage::getLanguageCode()) : ZLanguage::getLanguageCode();
if ($assign) {
$view->assign($assign, $result);
return;
}
return $result;
}
示例4: smarty_function_adminonlinemanual
/**
* Smarty function to displaya modules online manual
*
* Admin
* {adminonlinemanual}
*
* @see function.admincategorymenu.php::smarty_function_admincategoreymenu()
* @param array $params All attributes passed to this function from the template
* @param object $smarty Reference to the Smarty object
* @param int xhtml if set, the link to the navtabs.css will be xhtml compliant
* @return string the results of the module function
*/
function smarty_function_adminonlinemanual($params, $smarty)
{
LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated.', array('adminonlinemanual')), E_USER_DEPRECATED);
$lang = ZLanguage::transformFS(ZLanguage::getLanguageCode());
$modinfo = ModUtil::getInfoFromName(ModUtil::getName());
$modpath = $modinfo['type'] == ModUtil::TYPE_SYSTEM ? 'system' : 'modules';
$file = DataUtil::formatForOS("{$modpath}/{$modinfo['directory']}/lang/{$lang}/manual.html");
$man_link = '';
if (is_readable($file)) {
PageUtil::addVar('javascript', 'zikula.ui');
$man_link = '<div style="margin-top: 20px; text-align:center">[ <a id="online_manual" href="' . $file . '">' . __('Online manual') . '</a> ]</div>' . "\n";
$man_link .= '<script type="text/javascript">var online_manual = new Zikula.UI.Window($(\'online_manual\'),{resizable: true})</script>' . "\n";
}
return $man_link;
}
示例5: loadLocaleConfig
/**
* Load locale config
*
* @return void
*/
private function loadLocaleConfig()
{
$lang = ZLanguage::transformFS($this->locale);
$override = "config/locale/{$lang}/locale.ini";
$file = file_exists($override) ? $override : "locale/{$lang}/locale.ini";
if (is_readable($file)) {
$array = parse_ini_file($file, false);
foreach ($array as $k => $v) {
$k = strtolower($k);
if ($k == "grouping" || $k == "mon_grouping") {
$v = explode(',', $v);
}
if (!is_array($v)) {
$v = strtolower(trim(trim($v, '"'), "'"));
}
$this->localeData[$k] = $v;
}
$this->validateLocale($file);
} else {
$this->registerError(__f("Error! Could not load '%s'. Please check that it exists.", $file));
}
}
示例6: smarty_function_calendarinput
/**
* Display a calendar input control.
*
* Display a calendar input control consisting of a calendar image, an optional
* hidden input field, and associated javascript to render a pop-up calendar.
* This function displays a javascript (jscalendar) calendar control.
*
* Available attributes:
* - objectname (string) The name of the object the field will be placed in
* - htmlname: (string) The html fieldname under which the date value will be submitted
* - dateformat: (string) The dateformat to use for displaying the chosen date
* - ifformat: (string) Format of the date field sent in the form (optional - defaults to dateformat)
* - defaultstring (string) The String to display before a value has been selected
* - defaultdate: (string) The Date the calendar should to default to (format: Y/m/d)
* - hidden: (bool) If set, a hidden input field will be generated to hold the selected date
* - display: (bool) If set, a <span> is generated to display the selected date (when date is added in a hidden field)
* - class: (string) The class to apply to the html elements
* - time: (bool) If set, show time selection
*
* Example:
*
* <samp>{calendarinput objectname='myobject' htmlname='from' dateformat='%Y-%m-%d' defaultdate='2005/12/31'}</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 string The HTML and Javascript code to display a calendar control.
*/
function smarty_function_calendarinput($params, Zikula_View $view)
{
if (!isset($params['objectname'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('pncalendarinput', 'objectname')));
return false;
}
if (!isset($params['htmlname'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('pncalendarinput', 'htmlname')));
return false;
}
if (!isset($params['dateformat'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('pncalendarinput', 'dateformat')));
return false;
}
$ifformat = isset($params['ifformat']) ? $params['ifformat'] : $params['dateformat'];
$inctime = isset($params['time']) ? (bool) $params['time'] : false;
$validformats = array('%Y-%m-%d', '%Y-%m-%d %H:%M');
if (!in_array($ifformat, $validformats)) {
$ifformat = $inctime ? '%Y-%m-%d %H:%M' : '%Y-%m-%d';
}
// start of old pncalendarinit
// pagevars make an extra pncalendarinit obsolete, they take care about the fact
// that the styles/jsvascript do not get loaded multiple times
static $firstTime = true;
if ($firstTime) {
$lang = ZLanguage::transformFS(ZLanguage::getLanguageCode());
// map of the jscalendar supported languages
$map = array('ca' => 'ca_ES', 'cz' => 'cs_CZ', 'da' => 'da_DK', 'de' => 'de_DE', 'el' => 'el_GR', 'en-us' => 'en_US', 'es' => 'es_ES', 'fi' => 'fi_FI', 'fr' => 'fr_FR', 'he' => 'he_IL', 'hr' => 'hr_HR', 'hu' => 'hu_HU', 'it' => 'it_IT', 'ja' => 'ja_JP', 'ko' => 'ko_KR', 'lt' => 'lt_LT', 'lv' => 'lv_LV', 'nl' => 'nl_NL', 'no' => 'no_NO', 'pl' => 'pl_PL', 'pt' => 'pt_BR', 'ro' => 'ro_RO', 'ru' => 'ru_RU', 'si' => 'si_SL', 'sk' => 'sk_SK', 'sv' => 'sv_SE', 'tr' => 'tr_TR');
if (isset($map[$lang])) {
$lang = $map[$lang];
}
$headers[] = 'javascript/jscalendar/calendar.js';
if (file_exists("javascript/jscalendar/lang/calendar-{$lang}.utf8.js")) {
$headers[] = "javascript/jscalendar/lang/calendar-{$lang}.utf8.js";
}
$headers[] = 'javascript/jscalendar/calendar-setup.js';
PageUtil::addVar('stylesheet', 'javascript/jscalendar/calendar-win2k-cold-2.css');
PageUtil::addVar('javascript', $headers);
}
$firstTime = false;
// end of old pncalendarinit
if (!isset($params['defaultstring'])) {
$params['defaultstring'] = null;
}
if (!isset($params['defaultdate'])) {
$params['defaultdate'] = null;
}
$html = '';
$fieldKey = $params['htmlname'];
if ($params['objectname']) {
$fieldKey = $params['objectname'] . '[' . $params['htmlname'] . ']';
}
$triggerName = 'trigger_' . $params['htmlname'];
$displayName = 'display_' . $params['htmlname'];
if (isset($params['class']) && !empty($params['class'])) {
$params['class'] = ' class="' . DataUtil::formatForDisplay($params['class']) . '"';
} else {
$params['class'] = '';
}
if (isset($params['display']) && $params['display']) {
$html .= '<span id="' . $displayName . '"' . $params['class'] . '>' . $params['defaultstring'] . '</span> ';
}
if (isset($params['hidden']) && $params['hidden']) {
$html .= '<input type="hidden" name="' . $fieldKey . '" id="' . $params['htmlname'] . '" value="' . $params['defaultdate'] . '" />';
}
$html .= '<img class="z-calendarimg" src="' . System::getBaseUrl() . 'javascript/jscalendar/img.gif" id="' . $triggerName . '" style="cursor: pointer;" title="' . DataUtil::formatForDisplay(__('Date selector')) . '" alt="' . DataUtil::formatForDisplay(__('Date selector')) . '" />';
$i18n = ZI18n::getInstance();
$html .= "<script type=\"text/javascript\">\n // <![CDATA[\n Calendar.setup(\n {";
//$html .= 'ifFormat : "%Y-%m-%d %H:%M:00",'; // universal format, don't change this!
$html .= 'ifFormat : "' . $ifformat . '",';
$html .= 'inputField : "' . $params['htmlname'] . '",';
$html .= 'displayArea : "' . $displayName . '",';
//.........这里部分代码省略.........
示例7: render
/**
* Render event handler.
*
* @param Zikula_Form_View $view Reference to Zikula_Form_View object.
*
* @return string The rendered output
*/
public function render(Zikula_Form_View $view)
{
static $firstTime = true;
$i18n = ZI18n::getInstance();
if (!empty($this->defaultValue) && !$view->isPostBack()) {
$d = strtolower($this->defaultValue);
$now = getdate();
$date = null;
if ($d == 'now') {
$date = time();
} elseif ($d == 'today') {
$date = mktime(0, 0, 0, $now['mon'], $now['mday'], $now['year']);
} elseif ($d == 'monthstart') {
$date = mktime(0, 0, 0, $now['mon'], 1, $now['year']);
} elseif ($d == 'monthend') {
$daysInMonth = date('t');
$date = mktime(0, 0, 0, $now['mon'], $daysInMonth, $now['year']);
} elseif ($d == 'yearstart') {
$date = mktime(0, 0, 0, 1, 1, $now['year']);
} elseif ($d == 'yearend') {
$date = mktime(0, 0, 0, 12, 31, $now['year']);
} elseif ($d == 'custom') {
$date = strtotime($this->initDate);
}
if ($date != null) {
$this->text = DateUtil::getDatetime($date, $this->ifFormat, false);
} else {
$this->text = __('Unknown date');
}
}
if ($view->isPostBack() && !empty($this->text)) {
$date = strtotime($this->text);
$this->text = DateUtil::getDatetime($date, $this->ifFormat, false);
}
if ($firstTime) {
$lang = ZLanguage::transformFS(ZLanguage::getLanguageCode());
// map of the jscalendar supported languages
$map = array('ca' => 'ca_ES', 'cz' => 'cs_CZ', 'da' => 'da_DK', 'de' => 'de_DE', 'el' => 'el_GR', 'en-us' => 'en_US', 'es' => 'es_ES', 'fi' => 'fi_FI', 'fr' => 'fr_FR', 'he' => 'he_IL', 'hr' => 'hr_HR', 'hu' => 'hu_HU', 'it' => 'it_IT', 'ja' => 'ja_JP', 'ko' => 'ko_KR', 'lt' => 'lt_LT', 'lv' => 'lv_LV', 'nl' => 'nl_NL', 'no' => 'no_NO', 'pl' => 'pl_PL', 'pt' => 'pt_BR', 'ro' => 'ro_RO', 'ru' => 'ru_RU', 'si' => 'si_SL', 'sk' => 'sk_SK', 'sv' => 'sv_SE', 'tr' => 'tr_TR');
if (isset($map[$lang])) {
$lang = $map[$lang];
}
$headers[] = 'javascript/jscalendar/calendar.js';
if (file_exists("javascript/jscalendar/lang/calendar-{$lang}.utf8.js")) {
$headers[] = "javascript/jscalendar/lang/calendar-{$lang}.utf8.js";
}
$headers[] = 'javascript/jscalendar/calendar-setup.js';
PageUtil::addVar('stylesheet', 'javascript/jscalendar/calendar-win2k-cold-2.css');
PageUtil::addVar('javascript', $headers);
}
$firstTime = false;
$result = '';
if ($this->useSelectionMode) {
$hiddenInputField = str_replace(array('type="text"', ' *'), array('type="hidden"', ''), parent::render($view));
$result .= '<div>' . $hiddenInputField . '<span id="' . $this->id . 'cal" style="background-color: #ff8; cursor: default" onmouseover="this.style.backgroundColor=\'#ff0\';" onmouseout="this.style.backgroundColor=\'#ff8\';">';
if ($this->text) {
$result .= DataUtil::formatForDisplay(DateUtil::getDatetime(DateUtil::parseUIDate($this->text, $this->ifFormat), $this->daFormat));
} else {
$result .= __('Select date');
}
$result .= '</span></div>';
if ($this->mandatory && $this->mandatorysym) {
$result .= '<span class="z-form-mandatory-flag">*</span>';
}
} else {
$result .= '<span class="z-form-date" style="white-space: nowrap">';
$result .= parent::render($view);
$txt = __('Select date');
$result .= " <img id=\"{$this->id}_img\" src=\"javascript/jscalendar/img.gif\" style=\"vertical-align: middle\" class=\"clickable\" alt=\"{$txt}\" /></span>";
}
// build jsCalendar script options
$result .= "<script type=\"text/javascript\">\n // <![CDATA[\n Calendar.setup(\n {\n inputField : \"{$this->id}\",";
if ($this->includeTime) {
$this->initDate = str_replace('-', ',', $this->initDate);
$result .= "\n ifFormat : \"" . $this->ifFormat . "\",\n showsTime : true,\n timeFormat : \"" . $i18n->locale->getTimeformat() . "\",\n singleClick : false,";
} else {
$result .= "\n ifFormat : \"" . $this->ifFormat . "\",";
}
if ($this->useSelectionMode) {
$result .= "\n displayArea : \"{$this->id}cal\",\n daFormat : \"{$this->daFormat}\",\n align : \"Bl\",\n singleClick : true,";
} else {
$result .= "\n button : \"{$this->id}_img\",";
}
$result .= "\n firstDay: " . $i18n->locale->getFirstweekday() . "\n }\n );\n // ]]>\n </script>";
return $result;
}
示例8: lang
/**
* Function to get the site's language.
*
* Available parameters:
* - fs: safe for filesystem.
* @return string The language
*/
public function lang($fs = false)
{
$result = $fs ? \ZLanguage::transformFS(\ZLanguage::getLanguageCode()) : \ZLanguage::getLanguageCode();
return $result;
}
示例9: smarty_function_img
/**
* Zikula_View function to provide easy access to an image
*
* This function provides an easy way to include an image. The function will return the
* full source path to the image. It will as well provite the width and height attributes
* if none are set.
*
* Available parameters:
* - src The file name of the image
* - modname The well-known name of a module (default: the current module)
* - modplugin The name of the plugin in the passed module
* - sysplugin The name of the system plugin
* - width, height If set, they will be passed. If none is set, they are obtained from the image
* - alt If not set, an empty string is being assigned
* - title If set it will be passed as a title attribute
* - assign If set, the results are assigned to the corresponding variable instead of printed out
* - optional If set then the plugin will not return an error if an image is not found
* - default If set then a default image is used should the requested image not be found (Note: full path required)
* - set If modname is 'core' then the set parameter is set to define the directory in /images/
* - nostoponerror If set and error ocurs (image not found or src is no image), do not trigger_error, but return false
* - retval If set indicated the field to return instead the array of values (src, width, etc.)
* - fqurl If set the image path is absolute, if not relative
* - all remaining parameters are passed to the image tag
*
* Example: {img src='heading.png'}
* Output: <img src="modules/Example/images/en/heading.png" alt="" width="261" height="69" />
*
* Example: {img src='heading.png' width='100' border='1' __alt='foobar'}
* Output: <img src="modules/Example/images/en/heading.png" width="100" border="1" alt="foobar" />
*
* Example: {img src='xhtml11.png' modname='core' set='powered'}
* Output: <img src="themes/Theme/images/powered/xhtml11.png" alt="" width="88" height="31" />
*
* Example: {img src='iconX.png' modname='ModName' modplugin='Plug1' set='icons'}
* Output: <img src="modules/ModName/plugins/Plug1/images/icons/iconX.png" alt="" width="16" height="16" />
*
* Example: {img src='iconY.png' sysplugin='Plug2' set='icons/small'}
* Output: <img src="plugins/Plug2/images/icons/small/iconY.png" alt="" width="16" height="16" />
*
* If the parameter assign is set, the results are assigned as an array. The components of
* this array are the same as the attributes of the img tag; additionally an entry 'imgtag' is
* set to the complete image tag.
*
* Example:
* {img src="heading.png" assign="myvar"}
* {$myvar.src}
* {$myvar.width}
* {$myvar.imgtag}
*
* Output:
* modules/Example/images/en/heading.gif
* 261
* <img src="modules/Example/images/en/heading.gif" alt="" width="261" height="69" />
*
* @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 The img tag, null if $params['nostoponerror'] true and there is an error.
*/
function smarty_function_img($params, Zikula_View $view)
{
$nostoponerror = isset($params['nostoponerror']) && $params['nostoponerror'] ? true : false;
if (!isset($params['src']) || !$params['src']) {
if (!$nostoponerror) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('img', 'src')));
return;
} else {
return false;
}
}
// process the image location
$modname = isset($params['modname']) ? $params['modname'] : $view->toplevelmodule;
$modplugin = isset($params['modplugin']) ? $params['modplugin'] : null;
$sysplugin = isset($params['sysplugin']) ? $params['sysplugin'] : null;
// process the image set
$set = isset($params['set']) ? $params['set'] : null;
$osset = DataUtil::formatForOS($set);
// if the module name is 'core'
if ($modname == 'core') {
if (System::isLegacyMode() && (strpos($osset, 'icons/') !== false || strpos($osset, 'global/') !== false) && strpos($params['src'], '.gif')) {
LogUtil::log(__f('Core image %s does not exist, please use the png format (called from %s).', array($params['src'], $view->getTemplatePath())), E_USER_DEPRECATED);
$params['src'] = str_replace('.gif', '.png', $params['src']);
}
}
// always provide an alt attribute.
// if none is set, assign an empty one.
$params['alt'] = isset($params['alt']) ? $params['alt'] : '';
// prevent overwriting surrounding titles (#477)
if (isset($params['title']) && empty($params['title'])) {
unset($params['title']);
}
// language
$lang = ZLanguage::transformFS(ZLanguage::getLanguageCode());
if ($sysplugin) {
$osplugdir = DataUtil::formatForOS($sysplugin);
$pluglangpath = "plugins/{$osplugdir}/images/{$lang}";
$plugpath = "plugins/{$osplugdir}/images";
// form the array of paths
$paths = array($pluglangpath, $plugpath);
} else {
//.........这里部分代码省略.........
示例10: smarty_function_helplink
/**
* Zikula_View function to create help link.
*
* This function creates a help link.
*
* To make the link appear as a button, wrap it in a div or span with a class
* of z-buttons.
*
* Available parameters:
* - filename: name of file, defaults to 'help.txt'.
* - anchor: anchor marker.
* - popup: opens the help file 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 new window is set, default is 'Help'.
* - link_contents the text for the link (between the <a> and </a> tags); optional, if not specified, then the title is used.
* - icon_type an optional icon type to include in the link, separated from the link_contents (or title) by a non-breaking space; equivalent to the type parameter from the {icon} template function
* - icon_size the size of the icon (e.g., extrasmall); optional if link_icon_type is specified, defaults to 'extrasmall', otherwise ignored;
* equivalent to the size parameter of the {icon} template function
* - icon_width the width of the icon in pixels; optional if link_icon_type is specified, if not specified, then obtained from size, otherwise ignored;
* equivalent to the width parameter of the {icon} template function
* - icon_height the height of the icon in pixels; optional if link_icon_type is specified, if not specified, then obtained from size, otherwise ignored;
* equivalent to the height parameter of the {icon} template function
* - icon_alt the alternate text for the icon, used for the alt param of the {icon} template function; optional if link_icon_type is specified,
* defaults to an empty string, otherwise ignored
* - icon_title the title text for the icon, used for the title param of the {icon} template function; optional if link_icon_type is specified,
* defaults to an empty string, otherwise ignored
* - icon_optional if true and the icon image is not found then an error will not be returned, used for the optinal param of the {icon} template
* function; optional if link_icon_type is specified, defaults to false, otherwise ignored
* - icon_default the full path to an image file to use if the icon is not found, used for the default param of the {icon} template
* function; optional if link_icon_type is specified, defaults to an empty string, otherwise ignored
* - icon_right if true, then the icon is placed on the right side of the link text (the text from either link_contents or title); optional,
* defaults to false (placing the icon on the left side of the text)
* - icon_* all remaining parameters with a "icon_" prefix are passed to the {icon} function and subsequently to the <img> tag, except for
* 'icon_assign' which is completely ignored; optional if link_icon_type is specified, otherwise ignored
* - 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: A pop-up help window with a width of 400 and a height of 300, containing the contents of help.txt, and a title of 'Help'
* {helplink popup='1' width='400' height='300' filename='help.txt' title='Help'}
*
* Example: The same as above, except displayed as a button with an icon image placed on the left side of the text 'Help' separated by a non-breaking space.
* The image does not have either alternate text nor a title.
* <div class="z-buttons">
* {helplink popup='1' width='400' height='300' filename='help.txt' title='Help' icon_type='help' icon_size='extrasmall'}
* </div>
*
* Example: The same as above, except the icon's <img> tag will contain a class attrbute with the value "my_class"
* <div class="z-buttons">
* {helplink popup='1' width='400' height='300' filename='help.txt' title='Help' icon_type='help' icon_size='extrasmall' icon_class='my_class'}
* </div>
*
* @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_helplink($params, Zikula_View $view)
{
$userLang = ZLanguage::transformFS(ZLanguage::getLanguageCode());
$systemLang = System::getVar('language_i18n');
$iconParams = array();
if (!empty($params) && is_array($params)) {
foreach ($params as $key => $value) {
if (strpos($key, 'icon_') === 0 && strlen($key) > 5) {
$iconParams[substr($key, 5)] = $value;
unset($params[$key]);
}
}
}
if (!empty($iconParams) && isset($iconParams['type'])) {
// We need to make sure the icon template function is available so we can call it.
require_once $view->_get_plugin_filepath('function', 'icon');
$iconRightSide = false;
if (isset($iconParams['right'])) {
$iconRightSide = (bool) $iconParams['right'];
unset($iconParams['right']);
}
if (isset($iconParams['assign'])) {
// We cannot use the assign parameter with the icon function in this context.
unset($iconParams['assign']);
}
} else {
$iconParams = false;
$iconRightSide = false;
}
$title = isset($params['title']) ? $params['title'] : 'Help';
$linkContents = isset($params['link_contents']) ? $params['link_contents'] : $title;
$fileName = isset($params['filename']) ? $params['filename'] : 'help.txt';
$chapter = isset($params['anchor']) ? '#' . $params['anchor'] : '';
$class = isset($params['class']) ? $params['class'] : null;
$width = isset($params['width']) ? $params['width'] : 600;
$height = isset($params['height']) ? $params['height'] : 400;
$popup = isset($params['popup']) ? true : false;
$modname = $view->getModuleName();
$linkID = isset($params['linkid']) ? $params['linkid'] : DataUtil::formatForDisplay(strtolower('manuallink_' . $modname . '_' . hash('md5', serialize($params))));
$base = ModUtil::getModuleBaseDir($modname) . "/{$modname}/docs";
$paths = array("{$base}/{$userLang}/{$fileName}", "{$base}/{$systemLang}/{$fileName}", "{$base}/en/{$fileName}");
$found = false;
foreach ($paths as $path) {
//.........这里部分代码省略.........
示例11: smarty_function_helplink
/**
* Zikula_View function to create help link.
*
* This function creates a help link.
*
* To make the link appear as a button, wrap it in a div or span with a class
* of z-buttons.
*
* Available parameters:
* - filename: name of file, defaults to 'help.txt'.
* - anchor: anchor marker.
* - popup: opens the help file 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 new window is set, default is 'Help'.
* - link_contents the text for the link (between the <a> and </a> tags); optional, if not specified, then the title is used.
* - icon_type an optional icon type to include in the link, separated from the link_contents (or title) by a non-breaking space; equivalent to the type parameter from the {icon} template function
* - icon_size the size of the icon (e.g., extrasmall); optional if link_icon_type is specified, defaults to 'extrasmall', otherwise ignored;
* equivalent to the size parameter of the {icon} template function
* - icon_width the width of the icon in pixels; optional if link_icon_type is specified, if not specified, then obtained from size, otherwise ignored;
* equivalent to the width parameter of the {icon} template function
* - icon_height the height of the icon in pixels; optional if link_icon_type is specified, if not specified, then obtained from size, otherwise ignored;
* equivalent to the height parameter of the {icon} template function
* - icon_alt the alternate text for the icon, used for the alt param of the {icon} template function; optional if link_icon_type is specified,
* defaults to an empty string, otherwise ignored
* - icon_title the title text for the icon, used for the title param of the {icon} template function; optional if link_icon_type is specified,
* defaults to an empty string, otherwise ignored
* - icon_optional if true and the icon image is not found then an error will not be returned, used for the optinal param of the {icon} template
* function; optional if link_icon_type is specified, defaults to false, otherwise ignored
* - icon_default the full path to an image file to use if the icon is not found, used for the default param of the {icon} template
* function; optional if link_icon_type is specified, defaults to an empty string, otherwise ignored
* - icon_right if true, then the icon is placed on the right side of the link text (the text from either link_contents or title); optional,
* defaults to false (placing the icon on the left side of the text)
* - icon_* all remaining parameters with a "icon_" prefix are passed to the {icon} function and subsequently to the <img> tag, except for
* 'icon_assign' which is completely ignored; optional if link_icon_type is specified, otherwise ignored
* - 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: A pop-up help window with a width of 400 and a height of 300, containing the contents of help.txt, and a title of 'Help'
* {helplink popup='1' width='400' height='300' filename='help.txt' title='Help'}
*
* Example: The same as above, except displayed as a button with an icon image placed on the left side of the text 'Help' separated by a non-breaking space.
* The image does not have either alternate text nor a title.
* <div class="z-buttons">
* {helplink popup='1' width='400' height='300' filename='help.txt' title='Help' icon_type='help' icon_size='extrasmall'}
* </div>
*
* Example: The same as above, except the icon's <img> tag will contain a class attrbute with the value "my_class"
* <div class="z-buttons">
* {helplink popup='1' width='400' height='300' filename='help.txt' title='Help' icon_type='help' icon_size='extrasmall' icon_class='my_class'}
* </div>
*
* @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_helplink($params, Zikula_View $view)
{
$userLang = ZLanguage::transformFS(ZLanguage::getLanguageCode());
$systemLang = System::getVar('language_i18n');
$iconParams = array();
if (!empty($params) && is_array($params)) {
foreach ($params as $key => $value) {
if (strpos($key, 'icon_') === 0 && strlen($key) > 5) {
$iconParams[substr($key, 5)] = $value;
unset($params[$key]);
}
}
}
if (!empty($iconParams) && isset($iconParams['type'])) {
// We need to make sure the icon template function is available so we can call it.
require_once $view->_get_plugin_filepath('function', 'icon');
$iconRightSide = false;
if (isset($iconParams['right'])) {
$iconRightSide = (bool) $iconParams['right'];
unset($iconParams['right']);
}
if (isset($iconParams['assign'])) {
// We cannot use the assign parameter with the icon function in this context.
unset($iconParams['assign']);
}
} else {
$iconParams = false;
$iconRightSide = false;
}
$title = isset($params['title']) ? $params['title'] : 'Help';
$linkContents = isset($params['link_contents']) ? $params['link_contents'] : $title;
$fileName = isset($params['filename']) ? $params['filename'] : 'help.txt';
$chapter = isset($params['anchor']) ? '#' . $params['anchor'] : '';
$class = isset($params['class']) ? $params['class'] : null;
$width = isset($params['width']) ? $params['width'] : 600;
$height = isset($params['height']) ? $params['height'] : 400;
$popup = isset($params['popup']) ? true : false;
$modname = $view->getModuleName();
$linkID = isset($params['linkid']) ? $params['linkid'] : DataUtil::formatForDisplay(strtolower('manuallink_' . $modname . '_' . hash('md5', serialize($params))));
$paths = array();
$module = ModUtil::getModule($modname);
if ($module) {
$base = $module->getPath();
//.........这里部分代码省略.........
示例12: display
//.........这里部分代码省略.........
ZLanguage::bindCoreDomain();
}
ZLanguage::setLocale($currentlanguage);
}
if (!isset($vars['languages']) || empty($vars['languages']) || !is_array($vars['languages'])) {
$vars['languages'] = $this->getAvailableLanguages($vars['fulltranslation']);
}
$this->view->setCaching(Zikula_View::CACHE_DISABLED);
// assign the block vars
$this->view->assign($vars);
$this->view->assign('currentlanguage', $currentlanguage);
// set a block title
if (empty($blockinfo['title'])) {
$blockinfo['title'] = $this->__('Choose a language');
}
// prepare vars for ModUtil::url
$module = FormUtil::getPassedValue('module', null, 'GET', FILTER_SANITIZE_STRING);
$type = FormUtil::getPassedValue('type', null, 'GET', FILTER_SANITIZE_STRING);
$func = FormUtil::getPassedValue('func', null, 'GET', FILTER_SANITIZE_STRING);
$get = $_GET;
if (isset($get['module'])) {
unset($get['module']);
}
if (isset($get['type'])) {
unset($get['type']);
}
if (isset($get['func'])) {
unset($get['func']);
}
if (isset($get['lang'])) {
unset($get['lang']);
}
if (System::isLegacyMode()) {
if (!isset($type)) {
$type = 'user';
}
if (!isset($func)) {
$func = 'main';
}
}
// make homepage calculations
$shorturls = System::getVar('shorturls', false);
if ($shorturls) {
$homepage = System::getBaseUrl().System::getVar('entrypoint', 'index.php');
$forcefqdn = true;
} else {
$homepage = System::getVar('entrypoint', 'index.php');
$forcefqdn = false;
}
// build URLS
$urls = array();
foreach ($languages as $code) {
if (isset($module) && isset($type) && isset($func)) {
$thisurl = ModUtil::url($module, $type, $func, $get, null, null, $forcefqdn, !$shorturls, $code);
} else {
$thisurl = ($shorturls ? $code : "$homepage?lang=$code");
}
$codeFS = ZLanguage::transformFS($code);
$flag = '';
if ($vars['format']) {
$flag = "images/flags/flag-$codeFS.png";
if (!file_exists($flag)) {
$flag = '';
}
$flag = (($flag && $shorturls) ? System::getBaseUrl() . $flag : $flag);
}
if ($vars['fulltranslation'] == 2) {
ZLanguage::setLocale($code);
}
$urls[] = array('code' => $code, 'name' => ZLanguage::getLanguageName($code), 'url' => $thisurl, 'flag' => $flag);
if ($vars['fulltranslation'] == 2) {
ZLanguage::setLocale($currentlanguage);
}
}
usort($urls, '_blocks_thelangblock_sort');
$this->view->assign('urls', $urls);
// get the block content from the template then end the templating
$blockinfo['content'] = $this->view->fetch('blocks_block_thelang.tpl');
// return the block to the theme
return BlockUtil::themeBlock($blockinfo);
}
示例13: smarty_function_img
//.........这里部分代码省略.........
if ($modname == 'core') {
if (!isset($params['set'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('img', 'set')));
if ($nostoponerror == true) {
return;
} else {
return false;
}
}
$osset = DataUtil::formatForOS($params['set']);
if (System::isLegacyMode() && (strpos($osset, 'icons/') !== false || strpos($osset, 'global/') !== false) && strpos($params['src'], '.gif')) {
LogUtil::log(__f('Core image %s does not exist, please use the png format (called from %s).', array($params['src'], $view->getTemplatePath())), E_DEPRECATED);
$params['src'] = str_replace('.gif', '.png', $params['src']);
}
}
// default for the optional flag
$optional = isset($params['optional']) ? $params['optional'] : true;
// always provide an alt attribute.
// if none is set, assign an empty one.
$params['alt'] = isset($params['alt']) ? $params['alt'] : '';
if (!isset($params['title'])) {
$params['title'] = '';
}
// prevent overwriting surrounding titles (#477)
if (empty($params['title'])) {
unset($params['title']);
}
// language
$lang = ZLanguage::transformFS(ZLanguage::getLanguageCode());
// theme directory
$theme = DataUtil::formatForOS(UserUtil::getTheme());
$osmodname = DataUtil::formatForOS($modname);
$themelangpath = "themes/$theme/templates/modules/$osmodname/images/$lang";
$themepath = "themes/$theme/templates/modules/$osmodname/images";
$corethemepath = "themes/$theme/images";
// module directory
$modinfo = ModUtil::getInfoFromName($modname);
$osmoddir = DataUtil::formatForOS($modinfo['directory']);
$moduleDir = ($modinfo['type'] == ModUtil::TYPE_SYSTEM ? 'system' : 'modules');
if ($modname == 'core') {
$modpath = "images/$osset";
} else {
$modlangpath = "$moduleDir/$osmoddir/images/$lang";
$modpath = "$moduleDir/$osmoddir/images";
$modlangpathOld = "$moduleDir/$osmoddir/pnimages/$lang";
$modpathOld = "$moduleDir/$osmoddir/pnimages";
}
$ossrc = DataUtil::formatForOS($params['src']);
// form the array of paths
if ($modname == 'core') {
$paths = array($themepath, $corethemepath, $modpath);
} else {
$paths = array($themelangpath, $themepath, $corethemepath, $modlangpath, $modpath, $modlangpathOld, $modpathOld);
}
// search for the image
$imgsrc = '';
foreach ($paths as $path) {