本文整理汇总了PHP中Dataface_Application::url方法的典型用法代码示例。如果您正苦于以下问题:PHP Dataface_Application::url方法的具体用法?PHP Dataface_Application::url怎么用?PHP Dataface_Application::url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dataface_Application
的用法示例。
在下文中一共展示了Dataface_Application::url方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLanguageSelectorHTML
/**
* Returns the HTML for a language selector. This can be a list of flags, or
* names of languages, or a select list of names of languages.
*
* @param $params An associative array of parameters for this method.
* Keys:
* name : The name of the select widget or id of the ul (if unordered list)
* var : The GET variable that will be set by selecting one of these languages.
* selected : The code of the language that is considered to be currently selected.
* autosubmit : Whether the select list should auto submit
* type : 'select' or 'ul'
* lang : language code override
* use_flags : default true.
*/
function getLanguageSelectorHTML($params = array())
{
$languages = $this->app->_conf['languages'];
if (!isset($params['use_flags'])) {
$params['use_flags'] = true;
}
import('I18Nv2/Language.php');
$langcode = isset($params['lang']) ? $params['lang'] : $this->app->_conf['lang'];
$languageCodes = new I18Nv2_Language($langcode);
$currentLanguage = @$languages[$langCode] ? $languages[$langCode] : $languageCodes->getName($this->app->_conf['lang']);
$name = isset($params['name']) ? $params['name'] : 'language';
$options = array();
$var = isset($params['var']) ? $params['var'] : '-lang';
$selected = isset($params['selected']) ? $params['selected'] : $this->app->_conf['lang'];
$selectedValue = @$languages[$selected] ? $languages[$selected] : $languageCodes->getName($selected);
$autosubmit = isset($params['autosubmit']) and $params['autosubmit'];
$type = isset($params['type']) ? $params['type'] : 'select';
if (isset($params['table'])) {
$table =& Dataface_Table::loadTable($params['table']);
$tlangs = array_keys($table->getTranslations());
foreach ($tlangs as $tcode) {
if (!isset($languages[$tcode])) {
$languages[$tcode] = $languageCodes->getName($tcode);
if (!$languages[$tcode]) {
$languages[$tcode] = $tcode;
}
}
}
}
if (!is_array($languages)) {
return '';
}
if ($autosubmit) {
$onchange = 'javascript:window.location=this.options[this.selectedIndex].value;';
foreach ($languages as $lang => $langname) {
//$curri18n = new I18Nv2_Language($langCode);
//$langname = $curri18n->getName($lang);
$options[$this->app->url($var . '=' . $lang)] = array('code' => $lang, 'name' => $langname);
}
} else {
$onchange = '';
foreach ($languages as $lang => $langname) {
//$curri18n = new I18Nv2_Language($langCode);
//$langname = $curri18n->getName($lang);
$options[$lang] = array('code' => $lang, 'name' => $langname);
}
}
if (count($options) <= 1) {
return '';
}
ob_start();
if ($type == 'select') {
echo '<select name="' . df_escape($name) . '" ' . ($onchange ? 'onchange="' . df_escape($onchange) . '"' : '') . '>
';
foreach ($options as $code => $value) {
echo '<option value="' . df_escape($code) . '"' . ($value['code'] == $selected ? ' selected' : '') . '>' . df_escape($value['name']) . '</option>
';
}
echo '</select>';
} else {
echo '<ul id="' . df_escape($name) . '" class="language-selection-list">
';
foreach ($languages as $code => $languageName) {
//if ( !isset($params['lang']) and @$this->app->_conf['language_labels'][$code] and $this->app->_conf['language_labels'][$code] != $code ){
// $languageName = $this->app->_conf['language_labels'][$code];
//} else {
// $languageName = $languageCodes->getName($code);
//}
//$languageName = $languageCodes->getName($code);
echo '<li class="language-selection-item ' . ($code == $this->app->_conf['lang'] ? ' selected-language' : '') . '">
<a href="' . df_escape($this->app->url($var . '=' . $code)) . '">';
if ($params['use_flags'] or !$languageName) {
echo '<img src="' . df_escape(DATAFACE_URL . '/images/flags/' . $code . '_small.gif') . '" alt="' . df_escape($languageName) . '" />';
} else {
echo df_escape($languageName);
}
echo '</a></li>';
}
echo "</ul>";
}
$out = ob_get_contents();
ob_end_clean();
return $out;
}