当前位置: 首页>>代码示例>>PHP>>正文


PHP Language::exists方法代码示例

本文整理汇总了PHP中Language::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::exists方法的具体用法?PHP Language::exists怎么用?PHP Language::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Language的用法示例。


在下文中一共展示了Language::exists方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: GetURI

 public static function GetURI($p_publicationId, $p_languageId, $p_issueNo = null, $p_sectionNo = null, $p_articleNo = null)
 {
     $translator = \Zend_Registry::get('container')->getService('translator');
     $languageObj = new Language($p_languageId);
     if (!$languageObj->exists()) {
         return new PEAR_Error($translator->trans('Language does not exist.'));
     }
     $uri = '/' . $languageObj->getCode() . '/';
     if (!is_null($p_issueNo) && is_null($p_articleNo)) {
         $issueObj = new Issue($p_publicationId, $p_languageId, $p_issueNo);
         if (!$issueObj->exists()) {
             return new PEAR_Error($translator->trans('Issue does not exist.'));
         }
         $uri .= $issueObj->getUrlName() . '/';
     }
     if (!is_null($p_sectionNo) && is_null($p_articleNo)) {
         $sectionObj = new Section($p_publicationId, $p_issueNo, $p_languageId, $p_sectionNo);
         if (!$sectionObj->exists()) {
             return new PEAR_Error($translator->trans('Section does not exist.'));
         }
         $uri .= $sectionObj->getUrlName() . '/';
     }
     if (!is_null($p_articleNo)) {
         $articleObj = new Article($p_languageId, $p_articleNo);
         if (!$articleObj->exists()) {
             return new PEAR_Error($translator->trans('Article does not exist.'));
         }
         $issueObj = new Issue($p_publicationId, $p_languageId, $articleObj->getIssueNumber());
         $sectionObj = new Section($p_publicationId, $articleObj->getIssueNumber(), $p_languageId, $articleObj->getSectionNumber());
         $uri .= $issueObj->getUrlName() . '/';
         $uri .= $sectionObj->getUrlName() . '/';
         $uri .= $articleObj->getUrlName() . '/';
     }
     return $uri;
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:35,代码来源:ShortURL.php

示例2: GetURI

 public static function GetURI($p_publicationId, $p_languageId, $p_issueNo = null, $p_sectionNo = null, $p_articleNo = null)
 {
     $languageObj = new Language($p_languageId);
     if (!$languageObj->exists()) {
         return new PEAR_Error(getGS('Language does not exist.'));
     }
     $uri = $GLOBALS['Campsite']['SUBDIR'] . '/' . $languageObj->getCode() . '/';
     if (!is_null($p_issueNo) && is_null($p_articleNo)) {
         $issueObj = new Issue($p_publicationId, $p_languageId, $p_issueNo);
         if (!$issueObj->exists()) {
             return new PEAR_Error(getGS('Issue does not exist.'));
         }
         $uri .= $issueObj->getUrlName() . '/';
     }
     if (!is_null($p_sectionNo) && is_null($p_articleNo)) {
         $sectionObj = new Section($p_publicationId, $p_issueNo, $p_languageId, $p_sectionNo);
         if (!$sectionObj->exists()) {
             return new PEAR_Error(getGS('Section does not exist.'));
         }
         $uri .= $sectionObj->getUrlName() . '/';
     }
     if (!is_null($p_articleNo)) {
         $articleObj = new Article($p_languageId, $p_articleNo);
         if (!$articleObj->exists()) {
             return new PEAR_Error(getGS('Article does not exist.'));
         }
         $issueObj = new Issue($p_publicationId, $p_languageId, $articleObj->getIssueNumber());
         $sectionObj = new Section($p_publicationId, $articleObj->getIssueNumber(), $p_languageId, $articleObj->getSectionNumber());
         $uri .= $issueObj->getUrlName() . '/';
         $uri .= $sectionObj->getUrlName() . '/';
         $uri .= $articleObj->getUrlName() . '/';
     }
     return $uri;
 }
开发者ID:nidzix,项目名称:Newscoop,代码行数:34,代码来源:ShortURL.php

示例3: getWeekDayName

 public function getWeekDayName()
 {
     $language = new Language(CampTemplate::singleton()->context()->language->number);
     if (!$language->exists()) {
         return null;
     }
     return $language->getProperty('WDay' . (int) $this->getWeekDay());
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:8,代码来源:MetaDate.php

示例4: testExists

 /**
  * @covers FormHandler\Language::exists
  */
 public function testExists()
 {
     //test some falsy names
     $this->assertFalse(Language::exists('en.'));
     $this->assertFalse(Language::exists('en/'));
     $this->assertFalse(Language::exists('en\\'));
     $this->assertFalse(Language::exists('ladsjfp'));
     //test for existing language
     $this->assertTrue(Language::exists('en'));
 }
开发者ID:FormHandler,项目名称:FormHandler,代码行数:13,代码来源:LanguageTest.php

示例5: smarty_modifier_camp_date_format

/**
 * Campsite camp_date_format modifier plugin
 *
 * Type:     modifier
 * Name:     camp_date_format
 * Purpose:  format datestamps via MySQL date and time functions
 *
 * @param string
 *     $p_unixtime the date in unixtime format from $smarty.now
 * @param string
 *     $p_format the date format wanted
 *
 * @return
 *     string the formatted date
 *     null in case a non-valid format was passed
 */
function smarty_modifier_camp_date_format($p_unixtime, $p_format = null, $p_onlyEnglish = false)
{
    static $attributes = array('year'=>'%Y', 'mon'=>'%c', 'mday'=>'%e', 'yday'=>'%j',
                        'wday'=>'%w', 'hour'=>'%H', 'min'=>'%i', 'sec'=>'%S',
                        'mon_name'=>'%M', 'wday_name'=>'%W');
    static $specifiersMap = array('%h'=>'%I', '%i'=>'%M', '%s'=>'%S');
    static $conversionMap = array('%M'=>'__month_name__', '%W'=>'__weekday_name__',
                                  '%c'=>'__month__', '%e'=>'__day_of_the_month__',
                                  '%D'=>'__day_of_the_month_suffix__', '%l'=>'__hour_12_clock__');
    static $numberSuffix = array(0=>'th', 1=>'st', 2=>'nd', 3=>'rd', 4=>'th', 5=>'th', 6=>'th',
                                 7=>'th', 8=>'th', 9=>'th');

    if (array_key_exists(trim(strtolower($p_format)), $attributes)) {
        $p_format = $attributes[trim(strtolower($p_format))];
    }

    // gets the context variable
    $campsite = CampTemplate::singleton()->get_template_vars('gimme');

    // makes sure $p_unixtime is unixtime stamp
    $p_unixtime = smarty_make_timestamp($p_unixtime);

    if (is_null($p_format) || empty($p_format)) {
    	return strftime('%D %T', $p_unixtime);
    }

    $p_replaceCount = 0;
    $p_format = str_replace(array_keys($conversionMap), array_values($conversionMap),
    $p_format, $p_replaceCount);

    $p_format = str_replace(array_keys($specifiersMap), array_values($specifiersMap), $p_format);

    $formattedDate = strftime($p_format, $p_unixtime);
    if ($p_replaceCount > 0) {
    	$languageObj = new Language($campsite->language->number);
        if (!$languageObj->exists()) {
            $languageObj = new Language(1);
        }
        $timeArray = getdate($p_unixtime);
        $suffixNo = $timeArray['mday'] % 10;
        $hour = $timeArray['hours'] % 12;
        if ($hour == 0) {
        	$hour = 12;
        }
        $replaceValues = array($languageObj->getProperty('Month'.$timeArray['mon']),
                               $languageObj->getProperty('WDay'.(1+$timeArray['wday'])),
                               $timeArray['mon'],
                               $timeArray['mday'],
                               $timeArray['mday'].$numberSuffix[$suffixNo],
                               $hour);
        $formattedDate = str_replace(array_values($conversionMap), $replaceValues, $formattedDate);
    }
    return $formattedDate;
} // fn smarty_modifier_camp_date_format
开发者ID:nistormihai,项目名称:Newscoop,代码行数:70,代码来源:modifier.camp_date_format.php

示例6: Language

<?php
require_once($GLOBALS['g_campsiteDir']."/$ADMIN_DIR/issues/issue_common.php");
require_once($GLOBALS['g_campsiteDir'].'/classes/Template.php');
require_once($GLOBALS['g_campsiteDir'].'/classes/Alias.php');

$Language = Input::Get('Language', 'int', 0);
$Pub = Input::Get('Pub', 'int', 0);
$Issue = Input::Get('Issue', 'int', 0);

$errorStr = "";
$languageObj = new Language($Language);
if (!$languageObj->exists()) {
	$errorStr = getGS('There was an error reading the language parameter.');
}
if ($errorStr == "") {
	$publicationObj = new Publication($Pub);
	if (!$publicationObj->exists())
		$errorStr = getGS('There was an error reading the publication parameter.');
}
if ($errorStr == "") {
	$issueObj = new Issue($Pub, $Language, $Issue);
	if (!$issueObj->exists())
		$errorStr = getGS('There was an error reading the issue parameter.');
}
if ($errorStr == "" && ($templateId = $issueObj->getIssueTemplateId()) == 0)
	$errorStr = 'This issue cannot be previewed. Please make sure it has the front page template selected.';

if ($errorStr != "") {
	camp_html_display_error($errorStr, null, true);
}
开发者ID:nistormihai,项目名称:Newscoop,代码行数:30,代码来源:preview.php

示例7: trim

$f_article_code = Input::Get('f_article_code', 'string', 0);
$f_translation_title = trim(Input::Get('f_translation_title'));
$f_translation_language = Input::Get('f_translation_language');
list($articleNumber, $languageId) = explode("_", $f_article_code);
$backLink = "/{$ADMIN}/articles/translate.php?f_language_id={$f_language_id}" . "&f_publication_id={$f_publication_id}&f_issue_number={$f_issue_number}" . "&f_section_number={$f_section_number}&f_article_code={$f_article_code}" . "&f_translation_title={$f_translation_title}&f_translation_language={$f_translation_language}";
if (!Input::IsValid()) {
    camp_html_display_error(getGS('Invalid input: $1', Input::GetErrorString()));
    exit;
}
$articleObj = new Article($languageId, $articleNumber);
if (!$articleObj->exists()) {
    camp_html_display_error(getGS('Article does not exist.'));
    exit;
}
$translationLanguageObj = new Language($f_translation_language);
if (!$translationLanguageObj->exists()) {
    camp_html_display_error(getGS('Language does not exist.'));
    exit;
}
$translationArticle = new Article($f_translation_language, $articleNumber);
if ($translationArticle->exists()) {
    camp_html_add_msg(getGS("The article has already been translated into \$1.", $translationLanguageObj->getNativeName()));
    camp_html_goto_page($backLink);
}
$f_publication_id = $articleObj->getPublicationId();
// Only create the translated issue and section if the article has been
// categorized.
if ($f_publication_id > 0) {
    $publicationObj = new Publication($f_publication_id);
    if (!$publicationObj->exists()) {
        camp_html_display_error(getGS('Publication does not exist.'), $backLink);
开发者ID:nidzix,项目名称:Newscoop,代码行数:31,代码来源:do_translate.php

示例8: __construct

 /**
  * Constructor
  *
  * @param string $name the name for the form (used in the <form> tag
  * @param string $action the action for the form (used in <form action="xxx">)
  * @param string $extra extra css or js which is included in the <form> tag
  * @author Teye Heimans
  * @author Marien den Besten
  */
 public function __construct($name = null, $action = null, $extra = null)
 {
     //initialize object
     $this->resetObject();
     // try to disable caching from the browser if possible
     if (!headers_sent()) {
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
         header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
         header('Cache-Control: no-store, no-cache, must-revalidate');
         header('Cache-Control: post-check=0, pre-check=0', false);
         header('Pragma: no-cache');
         header("Cache-control: private");
     }
     // set the name of the form (the user has submitted one)
     if (!empty($name)) {
         $this->name = $name;
     } else {
         $form_name = Configuration::get('default_form_name');
         // get a unique form name because the user did not give one
         $i = null;
         while (defined('FH_' . $form_name . $i)) {
             $i = is_null($i) ? 1 : $i + 1;
         }
         define('FH_' . $form_name . $i, 1);
         $this->name = $form_name . $i;
         $i = null;
     }
     // set the action of the form if none is given
     if (!empty($action)) {
         $this->action = $action;
     } else {
         $this->action = $_SERVER['PHP_SELF'];
         if (!empty($_SERVER['QUERY_STRING'])) {
             $this->action .= '?' . $_SERVER['QUERY_STRING'];
         }
     }
     // get the $extra (JS, css, etc..) to put into the <form> tag
     $extra = !is_string($extra) ? '' : $extra;
     $extra = strpos($extra, 'accept-charset') === false ? trim($extra) . ' accept-charset="utf-8"' : $extra;
     $this->extra = $extra;
     // set the default mask
     $this->setMask(Configuration::get('default_row_mask'));
     // check if the form is posted
     $this->setPosted($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST[$this->name . '_submit']));
     // make a hidden field so we can identify the form
     Field\Hidden::set($this, $this->name . '_submit')->setValue(1, true)->hideFromOnCorrect();
     // get the current page
     $this->pageCurrent = isset($_POST[$this->name . '_page']) ? $_POST[$this->name . '_page'] : 1;
     // set the language...
     if (Configuration::get('auto_detect_language') == true && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         $language = Language::detect($_SERVER['HTTP_ACCEPT_LANGUAGE']);
         if (!is_null($language)) {
             Language::load($language);
         }
     } elseif (Language::exists(Configuration::get('default_language'))) {
         Language::load(Configuration::get('default_language'));
     }
     //set forms javascript
     static $jquery = false;
     if ($jquery === false && Configuration::get('include_jquery') == true) {
         $jquery = true;
         $this->_setJS('//code.jquery.com/jquery-1.11.1.min.js', true);
     }
     $this->_setJS(\FormHandler\Configuration::get('fhtml_dir') . "js/main.js", true);
 }
开发者ID:FormHandler,项目名称:FormHandler,代码行数:74,代码来源:FormHandler.php

示例9: trim

$f_country_code = Input::Get('f_country_code');
$f_country_orig_language = Input::Get('f_country_orig_language');
$f_country_new_language = Input::Get('f_country_new_language');
$f_country_name = trim(Input::Get('f_country_name'));

$country = new Country($f_country_code, $f_country_orig_language);
$language = new Language($f_country_new_language);
$correct = true;
$created = false;

if (empty($f_country_name)) {
	$correct = false;
	$errorMsgs[] = getGS("You must fill in the $1 field.", "<B>".getGS("Name")."</B>");
}

if (!$language->exists()) {
    $correct = false;
    $errorMsgs[] = getGS('You must select a language.');
}

if ($correct) {
	$newCountry = new Country($f_country_code, $f_country_new_language);
	$created = $newCountry->create(array('Name' => $f_country_name));
	if ($created) {
	    camp_html_goto_page("/$ADMIN/country/");
	} else {
		$errorMsgs[] = getGS('The country name $1 could not be translated','<B>'.$country->getName().'</B>');
	}
}

$crumbs = array();
开发者ID:nistormihai,项目名称:Newscoop,代码行数:31,代码来源:do_translate.php


注:本文中的Language::exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。