本文整理汇总了PHP中Language::GetLanguages方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::GetLanguages方法的具体用法?PHP Language::GetLanguages怎么用?PHP Language::GetLanguages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Language
的用法示例。
在下文中一共展示了Language::GetLanguages方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_set_language
/**
* Campsite set_language function plugin
*
* Type: function
* Name: set_language
* Purpose:
*
* @param array
* $p_params The English name of the language to be set
* @param object
* $p_smarty The Smarty object
*/
function smarty_function_set_language($p_params, &$p_smarty)
{
// gets the context variable
$campsite = $p_smarty->get_template_vars('gimme');
if (isset($p_params['name'])) {
$languageName = $p_params['name'];
} else {
$property = array_shift(array_keys($p_params));
CampTemplate::singleton()->trigger_error("invalid parameter '$property' in set_language");
return false;
}
if ($campsite->language->defined
&& $campsite->language->english_name == $languageName) {
return;
}
$languages = Language::GetLanguages(null, null, $languageName);
if (empty($languages)) {
$campsite->language->trigger_invalid_value_error('name', $languageName, $p_smarty);
return false;
}
$campsite->language = new MetaLanguage($languages[0]->getLanguageId());
} // fn smarty_function_set_language
示例2: CreateList
/**
* Creates the list of objects. Sets the parameter $p_hasNextElements to
* true if this list is limited and elements still exist in the original
* list (from which this was truncated) after the last element of this
* list.
*
* @param int $p_start
* @param int $p_limit
* @param array $p_parameters
* @param int &$p_count
* @return array
*/
protected function CreateList($p_start = 0, $p_limit = 0, array $p_parameters, &$p_count)
{
$context = CampTemplate::singleton()->context();
if ($p_parameters['of_article']) {
$metaLanguagesList = $context->article->languages_list($p_parameters['exclude_current'], $this->m_order);
} elseif ($p_parameters['of_issue']) {
$metaLanguagesList = $context->issue->languages_list($p_parameters['exclude_current'], $this->m_order);
} elseif ($p_parameters['of_publication']) {
$metaLanguagesList = $context->publication->languages_list($p_parameters['exclude_current'], $this->m_order);
} else {
if ($p_parameters['exclude_current']) {
$excludeList = array($context->language->number);
} else {
$excludeList = array();
}
$languagesList = Language::GetLanguages(null, null, null, $excludeList, $this->m_order);
$metaLanguagesList = array();
foreach ($languagesList as $language) {
$metaLanguagesList[] = new MetaLanguage($language->getLanguageId());
}
}
return $metaLanguagesList;
}
示例3: translated_to
/**
* Returns true if the article was translated in to the language
* identified by the given language code
*
* @param string $p_language - language code
* @return bool
*/
public function translated_to($p_language) {
if (is_string($p_language)) {
$languages = Language::GetLanguages(null, $p_language);
if (sizeof($languages) == 0) {
return (int)false;
}
$language = $languages[0];
} else {
$language = $p_language;
}
$article = new Article($language->getLanguageId(),
$this->m_dbObject->getArticleNumber());
return (int)$article->exists()
&& ($article->isPublished() || CampTemplate::singleton()->context()->preview);
}
示例4: smarty_function_count
/**
* Campsite Map function plugin
*
* Type: function
* Name: count
* Purpose: Triggers a statistics counting request
*
* @param array
* $p_params List of parameters from template
* @param object
* $p_smarty Smarty template object
*
* @return
* string The html content
*/
function smarty_function_count($p_params, &$p_smarty)
{
global $Campsite;
$campsite = $p_smarty->getTemplateVars('gimme');
$content = '';
$art_number = 0;
$art_language_num = 0;
$art_language_code = '';
if (isset($p_params['article']) && is_numeric($p_params['article'])) {
$art_number = $p_params['article'];
}
if (isset($p_params['language'])) {
$langs = array();
if (is_numeric($p_params['language'])) {
$langs = \Language::GetLanguages($p_params['language']);
} else {
$langs = \Language::GetLanguages(null, $p_params['language']);
}
if (!isset($langs[0])) {
return '';
// 'no lang'
}
$art_language_obj = $langs[0];
$art_language_num = $art_language_obj->getLanguageId();
$art_language_code = $art_language_obj->getCode();
}
$count_automatically = true;
if (isset($p_params['dont_count_automatically'])) {
$count_automatically = false;
}
if (!$art_number || !$art_language_num) {
$meta_article = $campsite->article;
if ($meta_article->defined) {
if (!$art_number) {
$art_number = $meta_article->number;
}
if (!$art_language_num) {
$art_language_meta = $meta_article->language;
$art_language_num = $art_language_meta->number;
$art_language_code = $art_language_meta->code;
}
}
}
if (!$art_language_num) {
$art_language_meta = $campsite->language;
$art_language_num = $art_language_meta->number;
$art_language_code = $art_language_meta->code;
}
if (!$art_number || !$art_language_num) {
return '';
// 'no art_num or lang'
}
$article = new \Article($art_language_num, $art_number);
if (!$article->exists()) {
return '';
// 'no art'
}
try {
$requestObjectId = $article->getProperty('object_id');
$updateArticle = empty($requestObjectId);
$objectType = new \ObjectType('article');
$object_type_id = $objectType->getObjectTypeId();
if ($updateArticle) {
$requestObject = new \RequestObject($requestObjectId);
if (!$requestObject->exists()) {
$requestObject->create(array('object_type_id' => $objectType->getObjectTypeId()));
$requestObjectId = $requestObject->getObjectId();
}
$article->setProperty('object_id', $requestObjectId);
}
// statistics shall be only gathered if the site admin set it on (and not for editor previews)
if (!$campsite->preview) {
$stat_web_url = $Campsite['WEBSITE_URL'];
if ('/' != $stat_web_url[strlen($stat_web_url) - 1]) {
$stat_web_url .= '/';
}
$article_number = $article->getProperty('Number');
$name_spec = '_' . $article_number . '_' . $art_language_code;
$content .= \Statistics::JavaScriptTrigger(array('count_automatically' => $count_automatically, 'name_spec' => $name_spec, 'object_type_id' => $object_type_id, 'request_object_id' => $requestObjectId));
}
} catch (\Exception $ex) {
return '';
}
return $content;
}
示例5: camp_html_display_error
camp_html_display_error($errorStr, $BackLink);
exit;
}
// When the user selects a language the form is submitted to the same page (translation.php).
// Read article translation form input values for the case when the page has been reloaded
// because of language select.
$f_translation_title = Input::Get('f_translation_title', 'string', '', true);
$f_language_selected = Input::Get('f_translation_language', 'int', 0, true);
$f_translation_language = Input::Get('f_translation_language', 'int', 0, true);
if ($f_publication_id > 0) {
$f_translation_issue_name = Input::Get('f_issue_name', 'string', $issueObj->getName(), true);
$f_translation_issue_urlname = Input::Get('f_issue_urlname', 'string', $issueObj->getUrlName(), true);
$f_translation_section_name = Input::Get('f_section_name', 'string', $sectionObj->getName(), true);
$f_translation_section_urlname = Input::Get('f_section_urlname', 'string', $sectionObj->getUrlName(), true);
}
$allLanguages = Language::GetLanguages(null, null, null, array(), array(array('field' => 'byname', 'dir' => 'asc')), true);
$articleLanguages = $articleObj->getLanguages();
$articleLanguages = DbObjectArray::GetColumn($articleLanguages, "Id");
if ($f_language_selected > 0 && $f_issue_number > 0) {
$translationIssueObj = new Issue($f_publication_id, $f_language_selected, $f_issue_number);
$translationSectionObj = new Section($f_publication_id, $f_issue_number, $f_language_selected, $f_section_number);
}
if ($f_publication_id > 0) {
$topArray = array('Pub' => $publicationObj, 'Issue' => $issueObj, 'Section' => $sectionObj, 'Article' => $articleObj);
camp_html_content_top(getGS('Translate article'), $topArray, true, true);
} else {
$crumbs = array();
$crumbs[] = array(getGS("Actions"), "");
$crumbs[] = array(getGS('Translate article'), "");
echo camp_html_breadcrumbs($crumbs);
}
示例6: require_once
require_once($GLOBALS['g_campsiteDir']."/classes/Language.php");
require_once($GLOBALS['g_campsiteDir']."/classes/Alias.php");
require_once($GLOBALS['g_campsiteDir']."/include/phorum_load.php");
require_once($GLOBALS['g_campsiteDir'].'/classes/Phorum_forum.php');
require_once($GLOBALS['g_campsiteDir'].'/classes/Phorum_setting.php');
require_once($GLOBALS['g_campsiteDir']."/$ADMIN_DIR/camp_html.php");
camp_load_translation_strings("api");
// Check permissions
if (!$g_user->hasPermission('ManagePub')) {
camp_html_display_error(getGS("You do not have the right to add publications."));
exit;
}
$languages = Language::GetLanguages(null, null, null, array(), array(), true);
$defaultLanguage = array_pop(Language::GetLanguages(null, camp_session_get('TOL_Language', 'en'), null, array(), array(), true));
$urlTypes = UrlType::GetUrlTypes();
$allTemplates = Template::GetAllTemplates(null, true, true, true);
$timeUnits = TimeUnit::GetTimeUnits(camp_session_get('TOL_Language', 'en'));
$shortNameUrlType = UrlType::GetByName('short names');
$aliases = array();
$crumbs = array();
$crumbs[] = array(getGS("Publications"), "/$ADMIN/pub/");
$crumbs[] = array(getGS("Add new publication"), "");
echo camp_html_breadcrumbs($crumbs);
include_once($GLOBALS['g_campsiteDir']."/$ADMIN_DIR/javascript_common.php");
?>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1" class="action_buttons" style="padding-top: 5px;">
示例7: _getLanguage
/**
* Get language by code
*
* @param string $code
* @param MetaPublication $publication
* @return MetaLanguage
*/
private function _getLanguage($code, MetaPublication $publication)
{
$cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
$cacheKey = $cacheService->getCacheKey(array('CampURIShortNameLanguage', $code, $publication->name), 'language');
if ($cacheService->contains($cacheKey)) {
return $cacheService->fetch($cacheKey);
} else {
$language = $publication->default_language;
if (!empty($code)) {
$langArray = Language::GetLanguages(null, $code);
if (is_array($langArray) && sizeof($langArray) == 1) {
$language = new MetaLanguage($langArray[0]->getLanguageId());
}
}
if (!$language->defined()) {
throw new InvalidArgumentException("Invalid language identifier in URL.", self::INVALID_LANGUAGE);
}
$cacheService->save($cacheKey, $language);
return $language;
}
}
示例8: putGS
}
?>
</select></dd>
</dl>
<dl>
<dt><label for="filter_language"><?php
putGS('Language');
?>
</label></dt>
<dd><select id="filter_name" name="language">
<option value=""><?php
putGS('All');
?>
</option>
<?php
foreach (Language::GetLanguages() as $language) {
?>
<option value="<?php
echo $language->getLanguageId();
?>
"><?php
echo htmlspecialchars($language->getNativeName());
?>
</option>
<?php
}
?>
</select></dd>
</dl>
</div>
</dd>
示例9: getFormMask
private function getFormMask($p_owner=false, $p_admin=false)
{
global $g_user;
$data = $this->getData();
foreach (User::GetUsers() as $User) {
if (1 || $User->hasPermission('PLUGIN_BLOG_USER')) {
$ownerList[$User->getUserId()] = "{$User->getRealName()} ({$User->getUserName()})";
}
}
asort($ownerList);
$languageList = array('' => getGS("---Select language---"));
foreach (Language::GetLanguages() as $Language) {
$languageList[$Language->getLanguageId()] = $Language->getNativeName();
}
asort($languageList);
foreach ($data as $k => $v) {
// clean user input
if (!in_array($k, self::$m_html_allowed_fields)) {
$data[$k] = camp_html_entity_decode_array($v);
}
}
// load possible topic list
foreach ($this->GetTopicTreeFlat() as $topicId => $topicName) {
$topics[$topicId] = $topicName;
}
// get the topics used
foreach ($this->getTopics() as $Topic) {
$active_topics[$Topic->getTopicId()] = $Topic->getName($this->getLanguageId());
}
$languageSelectedObj = new Language($data['fk_language_id']);
$editorLanguage = !empty($_COOKIE['TOL_Language']) ? $_COOKIE['TOL_Language'] : $languageSelectedObj->getCode();
$mask = array(
'f_blog_id' => array(
'element' => 'f_blog_id',
'type' => 'hidden',
'constant' => $data['blog_id']
),
SecurityToken::SECURITY_TOKEN => array(
'element' => SecurityToken::SECURITY_TOKEN,
'type' => 'hidden',
'constant' => SecurityToken::GetToken()
),
'language' => array(
'element' => 'Blog[fk_language_id]',
'type' => 'select',
'label' => getGS('Language'),
'default' => $data['fk_language_id'],
'options' => $languageList,
'required' => true
),
'title' => array(
'element' => 'Blog[title]',
'type' => 'text',
'label' => getGS('Title'),
'default' => $data['title'],
'required' => true
),
'tiny_mce' => array(
'element' => 'tiny_mce',
'text' => self::GetEditor('tiny_mce_box', $g_user, $editorLanguage),
'type' => 'static'
),
'info' => array(
'element' => 'Blog[info]',
'type' => 'textarea',
'label' => getGS('Info'),
'default' => $data['info'],
'required' => true,
'attributes'=> array('cols' => 86, 'rows' => 16, 'id' => 'tiny_mce_box', 'class' => 'tinymce')
),
'feature' => array(
'element' => 'Blog[feature]',
'type' => 'text',
'label' => getGS('Feature'),
'default' => $data['feature'],
),
'status' => array(
'element' => 'Blog[status]',
'type' => 'select',
'label' => getGS('Status'),
'default' => $data['status'],
'required' => true,
'options' => array(
'online' => getGS('online'),
'offline' => getGS('offline'),
'moderated' => getGS('moderated'),
'readonly' => getGS('read only'),
),
),
'admin_status' => array(
'element' => 'Blog[admin_status]',
//.........这里部分代码省略.........
示例10: camp_session_get
<?php
require_once $GLOBALS['g_campsiteDir'] . "/{$ADMIN_DIR}/topics/topics_common.php";
$f_show_languages = camp_session_get('f_show_languages', array());
$topics = Topic::GetTree();
// return value is sorted by language
$allLanguages = Language::GetLanguages(null, null, null, array(), array(), true);
$loginLanguageId = 0;
$loginLanguage = Language::GetLanguages(null, camp_session_get('TOL_Language', 'en'), null, array(), array(), true);
if (is_array($loginLanguage) && count($loginLanguage) > 0) {
$loginLanguage = array_pop($loginLanguage);
$loginLanguageId = $loginLanguage->getLanguageId();
}
if (count($f_show_languages) <= 0) {
$f_show_languages = DbObjectArray::GetColumn($allLanguages, 'Id');
}
$crumbs = array();
$crumbs[] = array(getGS("Configure"), "");
$crumbs[] = array(getGS("Topics"), "");
echo camp_html_breadcrumbs($crumbs);
camp_html_display_msgs("0.5em", 0);
?>
<form action="" method="post">
<fieldset class="controls">
<legend><?php
putGS("Show languages");
?>
</legend>
<div class="buttons">
<input type="button" value="<?php
示例11: setURL
/**
* Sets the URL values.
*
* Algorithm:
* - identify object (e.g.: publication, language, issue, section, article)
* - object defined
* - valid object?
* - yes: set
* - no: return error
* - object undefined
* - has default value?
* - yes: set
* - no:
* - object mandatory?
* - yes: return error
* - no: continue
*
* @return PEAR_Error
*
*/
private function setURL()
{
$this->setQueryVar('acid', null);
$this->m_publication = null;
$this->m_language = null;
$this->m_issue = null;
$this->m_section = null;
$this->m_article = null;
// gets the publication object based on site name (URI host)
$alias = preg_replace('/^'.$this->getScheme().':\/\//', '', $this->getBase());
$aliasObj = new Alias($alias);
if ($aliasObj->exists()) {
$this->m_publication = new MetaPublication($aliasObj->getPublicationId());
}
if (is_null($this->m_publication) || !$this->m_publication->defined()) {
return new PEAR_Error("Invalid site name '$alias' in URL.", self::INVALID_SITE_NAME);
}
// reads parameters values if any
$params = str_replace($this->m_config->getSetting('SUBDIR'), '', $this->getPath());
$cParams = explode('/', trim($params, '/'));
$cParamsSize = sizeof($cParams);
if ($cParamsSize >= 1) {
$cLangCode = $cParams[0];
}
if ($cParamsSize >= 2) {
$cIssueSName = $cParams[1];
}
if ($cParamsSize >= 3) {
$cSectionSName = $cParams[2];
}
if ($cParamsSize >= 4) {
$cArticleSName = $cParams[3];
}
// gets the language identifier and sets the language code
if (!empty($cLangCode)) {
$langArray = Language::GetLanguages(null, $cLangCode);
if (is_array($langArray) && sizeof($langArray) == 1) {
$this->m_language = new MetaLanguage($langArray[0]->getLanguageId());
}
} else {
$this->m_language = new MetaLanguage($this->m_publication->default_language->number);
}
if (is_null($this->m_language) || !$this->m_language->defined()) {
return new PEAR_Error("Invalid language identifier in URL.", self::INVALID_LANGUAGE);
}
// gets the issue number and sets the issue short name
if (!empty($cIssueSName)) {
$publishedOnly = !$this->m_preview;
$issueArray = Issue::GetIssues($this->m_publication->identifier,
$this->m_language->number, null, $cIssueSName, null, $publishedOnly);
if (is_array($issueArray) && sizeof($issueArray) == 1) {
$this->m_issue = new MetaIssue($this->m_publication->identifier,
$this->m_language->number,
$issueArray[0]->getIssueNumber());
} else {
return new PEAR_Error("Invalid issue identifier in URL.", self::INVALID_ISSUE);
}
} else {
$issueObj = Issue::GetCurrentIssue($this->m_publication->identifier,
$this->m_language->number);
$this->m_issue = new MetaIssue($this->m_publication->identifier,
$this->m_language->number, $issueObj->getIssueNumber());
if (!$this->m_issue->defined()) {
return new PEAR_Error("No published issue was found.", self::INVALID_ISSUE);
}
}
// gets the section number and sets the section short name
if (!empty($cSectionSName)) {
$sectionArray = Section::GetSections($this->m_publication->identifier,
$this->m_issue->number,
$this->m_language->number,
$cSectionSName);
if (is_array($sectionArray) && sizeof($sectionArray) == 1) {
$this->m_section = new MetaSection($this->m_publication->identifier,
//.........这里部分代码省略.........
示例12: GetCampLanguagesList
public static function GetCampLanguagesList()
{
foreach (Language::GetLanguages() as $Language) {
$languageList[$Language->getLanguageId()] = $Language->getNativeName();
}
asort($languageList);
return $languageList;
}
示例13: _getLanguage
/**
* Get language by code
*
* @param string $code
* @param MetaPublication $publication
* @return MetaLanguage
*/
private function _getLanguage($code, MetaPublication $publication)
{
if (!empty($code)) {
$langArray = Language::GetLanguages(null, $code);
if (is_array($langArray) && sizeof($langArray) == 1) {
$language = new MetaLanguage($langArray[0]->getLanguageId());
}
} else {
$language = $publication->default_language;
}
if (empty($language) || !$language->defined()) {
throw new InvalidArgumentException("Invalid language identifier in URL.", self::INVALID_LANGUAGE);
}
return $language;
}
示例14: getLanguage
/**
* Get language
*
* @param string $code
* @return int
*/
public function getLanguage($code)
{
$languages = \Language::GetLanguages(null, $code);
if (empty($languages)) {
throw new \InvalidArgumentException("Language with code '{$code}' not found");
}
return array_shift($languages)->getLanguageId();
}
示例15: camp_load_translation_strings
<?php
camp_load_translation_strings("plugin_debate");
// Check permissions
if (!$g_user->hasPermission('plugin_debate_admin')) {
camp_html_display_error(getGS('You do not have the right to manage debates.'));
exit;
}
$allLanguages = Language::GetLanguages();
$f_debate_nr = Input::Get('f_debate_nr', 'int');
$f_fk_language_id = Input::Get('f_fk_language_id', 'int');
$debate = new Debate($f_fk_language_id, $f_debate_nr);
if ($debate->exists()) {
foreach ($debate->getTranslations() as $translation) {
$existing[$translation->getLanguageId()] = true;
}
$title = $debate->getProperty('title');
$question = $debate->getProperty('question');
$is_used_as_default = false;
}
echo camp_html_breadcrumbs(array(array(getGS('Plugins'), $Campsite['WEBSITE_URL'] . '/admin/plugins/manage.php'), array(getGS('Debates'), $Campsite['WEBSITE_URL'] . '/admin/debate/index.php'), array(getGS('Translate Debate'), '')));
?>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1" class="action_buttons" style="padding-top: 5px;">
<TR>
<TD><A HREF="index.php"><IMG SRC="<?php
echo $Campsite["ADMIN_IMAGE_BASE_URL"];
?>
/left_arrow.png" BORDER="0"></A></TD>
<TD><A HREF="index.php"><B><?php
putGS("Debate List");
?>