示例#1
0
 /**
  * Test the Language class.
  *
  * @return void
  * @access public
  */
 public function testLanguage()
 {
     $l = new Language();
     $this->assertEquals($l->getLanguage('eng'), 'English');
     $this->assertEquals($l->getLanguage('??'), 'Unknown');
     $this->assertEquals($l->getCode('English'), 'eng');
     $this->assertEquals($l->getCode('???'), false);
 }
示例#2
0
 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;
 }
示例#3
0
 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;
 }
示例#4
0
 /**
  * @since 1.16.3
  * @return array
  */
 public function getFirstLetterData()
 {
     if ($this->firstLetterData === null) {
         $cache = ObjectCache::getLocalServerInstance(CACHE_ANYTHING);
         $cacheKey = $cache->makeKey('first-letters', $this->locale, $this->digitTransformLanguage->getCode(), self::getICUVersion(), self::FIRST_LETTER_VERSION);
         $this->firstLetterData = $cache->getWithSetCallback($cacheKey, $cache::TTL_WEEK, function () {
             return $this->fetchFirstLetterData();
         });
     }
     return $this->firstLetterData;
 }
 function __construct($page, $conds, $langObj = null)
 {
     parent::__construct($page->getContext());
     $this->mIndexField = 'am_title';
     $this->mPage = $page;
     $this->mConds = $conds;
     // FIXME: Why does this need to be set to DIR_DESCENDING to produce ascending ordering?
     $this->mDefaultDirection = IndexPager::DIR_DESCENDING;
     $this->mLimitsShown = [20, 50, 100, 250, 500, 5000];
     global $wgContLang;
     $this->talk = $this->msg('talkpagelinktext')->escaped();
     $this->lang = $langObj ? $langObj : $wgContLang;
     $this->langcode = $this->lang->getCode();
     $this->foreign = !$this->lang->equals($wgContLang);
     $request = $this->getRequest();
     $this->filter = $request->getVal('filter', 'all');
     if ($this->filter === 'all') {
         $this->custom = null;
         // So won't match in either case
     } else {
         $this->custom = $this->filter === 'unmodified';
     }
     $prefix = $this->getLanguage()->ucfirst($request->getVal('prefix', ''));
     $prefix = $prefix !== '' ? Title::makeTitleSafe(NS_MEDIAWIKI, $request->getVal('prefix', null)) : null;
     if ($prefix !== null) {
         $this->displayPrefix = $prefix->getDBkey();
         $this->prefix = '/^' . preg_quote($this->displayPrefix, '/') . '/i';
     } else {
         $this->displayPrefix = false;
         $this->prefix = false;
     }
     // The suffix that may be needed for message names if we're in a
     // different language (eg [[MediaWiki:Foo/fr]]: $suffix = '/fr'
     if ($this->foreign) {
         $this->suffix = '/' . $this->langcode;
     } else {
         $this->suffix = '';
     }
 }
示例#6
0
 /**
  * Request the message in any language that is supported.
  * As a side effect interface message status is unconditionally
  * turned off.
  * @param $lang Mixed: language code or Language object.
  * @return Message: $this
  */
 public function inLanguage($lang)
 {
     if ($lang instanceof Language || $lang instanceof StubUserLang) {
         $this->language = $lang;
     } elseif (is_string($lang)) {
         if ($this->language->getCode() != $lang) {
             $this->language = Language::factory($lang);
         }
     } else {
         $type = gettype($lang);
         throw new MWException(__METHOD__ . " must be " . "passed a String or Language object; {$type} given");
     }
     $this->interface = false;
     return $this;
 }
 /**
  * Gets the description of a group. This is a bit slow thing to do for
  * thousand+ groups, so some caching is involved.
  * @param $group MessageGroup
  * @return string Plain text
  */
 public function getGroupDescription(MessageGroup $group)
 {
     $code = $this->lang->getCode();
     $cache = wfGetCache(CACHE_ANYTHING);
     $key = wfMemckey("translate-groupdesc-{$code}-" . $group->getId());
     $desc = $cache->get($key);
     if (is_string($desc)) {
         return $desc;
     }
     $realFunction = array('MessageCache', 'singleton');
     if (is_callable($realFunction)) {
         $mc = MessageCache::singleton();
     } else {
         global $wgMessageCache;
         $mc = $wgMessageCache;
     }
     $desc = $mc->transform($group->getDescription(), true, $this->lang);
     $cache->set($key, $desc);
     return $desc;
 }
 function RemoteLanguageManager()
 {
     $version = str_replace('.', '_', VERSION);
     $language_xml = @file_get_contents('http://update.atutor.ca/languages/' . $version . '/languages.xml');
     if ($language_xml === FALSE) {
         // fix for bug #2896
         $language_xml = @file_get_contents('http://update.atutor.ca/languages/1_5_3/languages.xml');
     }
     if ($language_xml !== FALSE) {
         $languageParser = new LanguagesParser();
         $languageParser->parse($language_xml);
         $this->numLanguages = $languageParser->getNumLanguages();
         for ($i = 0; $i < $this->numLanguages; $i++) {
             $thisLanguage = new Language($languageParser->getLanguage($i));
             $this->availableLanguages[$thisLanguage->getCode()][$thisLanguage->getCharacterSet()] = $thisLanguage;
         }
     } else {
         $this->numLanguages = 0;
         $this->availableLanguages = array();
     }
 }
 function __construct($page, $conds, $langObj = null)
 {
     parent::__construct();
     $this->mIndexField = 'am_title';
     $this->mPage = $page;
     $this->mConds = $conds;
     $this->mDefaultDirection = true;
     // always sort ascending
     $this->mLimitsShown = array(20, 50, 100, 250, 500, 5000);
     global $wgLang, $wgContLang, $wgRequest;
     $this->talk = htmlspecialchars(wfMsg('talkpagelinktext'));
     $this->lang = $langObj ? $langObj : $wgContLang;
     $this->langcode = $this->lang->getCode();
     $this->foreign = $this->langcode != $wgContLang->getCode();
     $request = $wgRequest;
     $this->filter = $request->getVal('filter', 'all');
     if ($this->filter === 'all') {
         $this->custom = null;
         // So won't match in either case
     } else {
         $this->custom = $this->filter == 'unmodified';
     }
     $prefix = $wgLang->ucfirst($wgRequest->getVal('prefix', ''));
     $prefix = $prefix != '' ? Title::makeTitleSafe(NS_MEDIAWIKI, $wgRequest->getVal('prefix', null)) : null;
     if ($prefix !== null) {
         $this->displayPrefix = $prefix->getDBkey();
         $this->prefix = '/^' . preg_quote($this->displayPrefix) . '/i';
     } else {
         $this->displayPrefix = false;
         $this->prefix = false;
     }
     // The suffix that may be needed for message names if we're in a
     // different language (eg [[MediaWiki:Foo/fr]]: $suffix = '/fr'
     if ($this->foreign) {
         $this->suffix = '/' . $this->langcode;
     } else {
         $this->suffix = '';
     }
 }
示例#10
0
 /**
  * Returns a URL to the feed
  * 
  * @param $format string Feed format, 'rss' or 'atom'
  * @return String 
  */
 public function getURL($format)
 {
     global $wgContLang;
     $options = array('action' => 'featuredfeed', 'feed' => $this->name, 'feedformat' => $format);
     if ($this->options['inUserLanguage'] && $this->language->getCode() != $wgContLang->getCode()) {
         $options['language'] = $this->language->getCode();
     }
     return wfScript('api') . '?' . wfArrayToCGI($options);
 }
示例#11
0
<fieldset class="plain" style="margin-top: 13px">
    <input type="submit" name="Save" value="<?php 
echo $translator->trans('Save');
?>
" class="save-button" />
</fieldset>

</form>

</div>

<?php 
// Load tinymce once for all textareas
if (count($loadAsRichtext) > 0) {
    $languageSelectedObj = new Language((int) camp_session_get('LoginLanguageId', 0));
    $editorLanguage = !empty($_COOKIE['TOL_Language']) ? $_COOKIE['TOL_Language'] : $languageSelectedObj->getCode();
    $editorOptions = array('max_chars' => $captionLimit, 'toolbar_length' => 15);
    editor_load_tinymce($loadAsRichtext, $g_user, $editorLanguage, $editorOptions);
}
?>

<script type="text/javascript">
/**
 * Copy field value to all fields of that name.
 *
 * @param string field
 * @param int imageId
 *
 * @return void
 */
function copyToAll(field, imageId)
示例#12
0
$f_language_id = Input::Get('Language', 'int', 0);
if (!Input::IsValid()) {
    camp_html_display_error($translator->trans('Invalid input: $1', array('$1' => Input::GetErrorString())), $_SERVER['REQUEST_URI']);
    exit;
}
$publicationObj = new Publication($f_publication_id);
$issueObj = new Issue($f_publication_id, $f_language_id, $f_issue_number);
$newSectionNumber = Section::GetUnusedSectionNumber($f_publication_id, $f_issue_number);
$topArray = array('Pub' => $publicationObj, 'Issue' => $issueObj);
camp_html_content_top($translator->trans('Add new section', array(), 'sections'), $topArray, true, true, array($translator->trans("Sections") => "/{$ADMIN}/sections/?Pub={$f_publication_id}&Issue={$f_issue_number}&Language={$f_language_id}"));
$controller->view->headTitle($translator->trans('Add new section', array(), 'sections') . ' - Newscoop Admin', 'SET');
$languageObj = new Language($f_language_id);
if (!is_object($languageObj)) {
    $languageObj = new Language(1);
}
$editorLanguage = camp_session_get('TOL_Language', $languageObj->getCode());
editor_load_tinymce('f_description', $g_user, 0, $editorLanguage, 'section');
?>
<p>
<form name="section_add" method="POST" action="/<?php 
echo $ADMIN;
?>
/sections/do_add.php" onsubmit="return <?php 
camp_html_fvalidate();
?>
;">
<?php 
echo SecurityToken::FormParameter();
?>
<table border="0" cellspacing="0" cellpadding="0" class="box_table">
<tr>
示例#13
0
文件: index.php 项目: nidzix/Newscoop
            ?>
"><span></span>x</a>
            <a class="edit" title="<?php 
            putGS('Edit');
            ?>
"><?php 
            putGS('Edit');
            ?>
</a>

            <span class="open" title="<?php 
            putGS('Click to edit');
            ?>
">
                <span><?php 
            echo $topicLanguage->getCode();
            ?>
</span>
                <strong><?php 
            echo htmlspecialchars($topicName);
            ?>
</strong>
            </span>

            <form method="post" action="/<?php 
            echo $ADMIN;
            ?>
/topics/do_edit.php" onsubmit="return validate(this);">
                <?php 
            echo SecurityToken::FormParameter();
            ?>
示例#14
0
 /**
  * Purge a limited set of language variants on Chinese wikis
  *
  * See BAC-1278 / BAC-698 for details
  *
  * @param Language $contLang
  * @param array $variants
  * @return bool
  * @author macbre
  */
 static function onTitleGetLangVariants(Language $contLang, array &$variants)
 {
     switch ($contLang->getCode()) {
         case 'zh':
             // skin displays links to these variants only
             $variants = ['zh-hans', 'zh-hant'];
             break;
     }
     return true;
 }
示例#15
0
 /**
  * Process item
  * @param  Article $article
  * @return array
  */
 public function processItem($article)
 {
     global $g_user, $Campsite;
     $translator = \Zend_Registry::get('container')->getService('translator');
     $editorService = \Zend_Registry::get('container')->getService('newscoop.editor');
     $articleLink = $editorService->getLink($article);
     $articleLinkParams = $editorService->getLinkParameters($article);
     $articleLinkParamsTranslate = $articleLinkParams . '&amp;f_action=translate&amp;f_action_workflow=' . $article->getWorkflowStatus() . '&amp;f_article_code=' . $article->getArticleNumber() . '_' . $article->getLanguageId();
     $previewLink = $Campsite['WEBSITE_URL'] . '/admin/articles/preview.php' . $editorService->getLinkParameters($article);
     $htmlPreviewLink = '<a href="' . $previewLink . '" target="_blank" title="' . $translator->trans('Preview') . '">' . $translator->trans('Preview') . '</a>';
     $translateLink = $Campsite['WEBSITE_URL'] . '/admin/articles/translate.php' . $articleLinkParamsTranslate;
     $htmlTranslateLink = '<a href="' . $translateLink . '" target="_blank" title="' . $translator->trans('Translate') . '">' . $translator->trans('Translate') . '</a>';
     $lockInfo = '';
     $lockHighlight = false;
     $timeDiff = camp_time_diff_str($article->getLockTime());
     if ($article->isLocked() && $timeDiff['days'] <= 0) {
         $lockUser = new User($article->getLockedByUser());
         if ($timeDiff['hours'] > 0) {
             $lockInfo = $translator->trans('The article has been locked by $1 ($2) $3 hour(s) and $4 minute(s) ago.', array('$1' => htmlspecialchars($lockUser->getRealName()), '$2' => htmlspecialchars($lockUser->getUserName()), '$3' => $timeDiff['hours'], '$4' => $timeDiff['minutes']), 'articles');
         } else {
             $lockInfo = $translator->trans('The article has been locked by $1 ($2) $3 minute(s) ago.', array('$1' => htmlspecialchars($lockUser->getRealName()), '$2' => htmlspecialchars($lockUser->getUserName()), '$3' => $timeDiff['minutes']), 'articles');
         }
         if ($article->getLockedByUser() != $g_user->getUserId()) {
             $lockHighlight = true;
         }
     }
     $tmpUser = new User($article->getCreatorId());
     $tmpArticleType = new ArticleType($article->getType());
     $tmpAuthor = new Author();
     $articleAuthors = ArticleAuthor::GetAuthorsByArticle($article->getArticleNumber(), $article->getLanguageId());
     foreach ((array) $articleAuthors as $author) {
         if (strtolower($author->getAuthorType()->getName()) == 'author') {
             $tmpAuthor = $author;
             break;
         }
     }
     if (!$tmpAuthor->exists() && isset($articleAuthors[0])) {
         $tmpAuthor = $articleAuthors[0];
     }
     $onFrontPage = $article->onFrontPage() ? $translator->trans('Yes') : $translator->trans('No');
     $onSectionPage = $article->onSectionPage() ? $translator->trans('Yes') : $translator->trans('No');
     $imagesNo = (int) ArticleImage::GetImagesByArticleNumber($article->getArticleNumber(), true);
     $topicsNo = (int) ArticleTopic::GetArticleTopics($article->getArticleNumber(), true);
     $commentsNo = '';
     if ($article->commentsEnabled()) {
         global $controller;
         $repositoryComments = $controller->getHelper('entity')->getRepository('Newscoop\\Entity\\Comment');
         $filter = array('thread' => $article->getArticleNumber(), 'language' => $article->getLanguageId());
         $params = array('sFilter' => $filter);
         $commentsNo = $repositoryComments->getCount($params);
     } else {
         $commentsNo = 'No';
     }
     // get language code
     $language = new Language($article->getLanguageId());
     return array($article->getArticleNumber(), $article->getLanguageId(), $article->getOrder(), sprintf('%s <a href="%s" title="%s %s">%s</a>', $article->isLocked() ? '<span class="ui-icon ui-icon-locked' . (!$lockHighlight ? ' current-user' : '') . '" title="' . $lockInfo . '"></span>' : '', $articleLink, $translator->trans('Edit'), htmlspecialchars($article->getName() . " ({$article->getLanguageName()})"), htmlspecialchars($article->getName() . (empty($_REQUEST['language']) ? " ({$language->getCode()})" : ''))), htmlspecialchars($article->getSection()->getName()), $article->getWebcode(), htmlspecialchars($tmpArticleType->getDisplayName()), htmlspecialchars($tmpUser->getRealName()), htmlspecialchars($tmpAuthor->getName()), $article->getWorkflowStatus(), $onFrontPage, $onSectionPage, $imagesNo, $topicsNo, $commentsNo, (int) $article->getReads(), Geo_Map::GetArticleMapId($article) != null ? $translator->trans('Yes') : $translator->trans('No'), (int) sizeof(Geo_Map::GetLocationsByArticle($article)), $article->getCreationDate(), $article->getPublishDate(), $article->getLastModified(), $htmlPreviewLink, $htmlTranslateLink);
 }
示例#16
0
 function validateVariant($variant = null)
 {
     return $variant === $this->mLang->getCode() ? $variant : null;
 }
示例#17
0
            $color2 = 1;
            ?>
class="list_row_odd"<?php 
        }
        ?>
">
			<TD <?php 
        if ($isFirstTranslation) {
            ?>
style="border-top: 2px solid #8AACCE;"<?php 
        }
        ?>
 valign="middle" align="center">
				<?php 
        $language = new Language($languageId);
        p($language->getCode());
        ?>
			</TD>
			<TD <?php 
        if ($isFirstTranslation) {
            ?>
style="border-top: 2px solid #8AACCE;"<?php 
        }
        ?>
 valign="middle" align="left" width="450px">
				<?php 
        echo htmlspecialchars($transName);
        ?>
			</TD>
			</tr>
			<?php 
示例#18
0
 /**
  * Gets the language code of the current translation language; or none
  * if there is no translation.
  *
  * @param int p_lang
  *
  * @return string
  */
 public function getDisplayNameLanguageCode($p_lang = 0)
 {
     if (!$p_lang) {
         $lang = camp_session_get('LoginLanguageId', 1);
     } else {
         $lang = $p_lang;
     }
     $languageObj = new Language($lang);
     $translations = $this->getTranslations();
     if (!isset($translations[$lang])) {
         return '';
     }
     return '(' . $languageObj->getCode() . ')';
 }
 protected static function getLanguageAttributes(Language $language)
 {
     global $wgTranslateDocumentationLanguageCode;
     $code = $language->getCode();
     $dir = $language->getDir();
     if ($code === $wgTranslateDocumentationLanguageCode) {
         // Should be good enough for now
         $code = 'en';
     }
     return array('lang' => $code, 'dir' => $dir);
 }
示例#20
0
 /**
  * Compare with an other language object
  *
  * @since 1.28
  * @param Language $lang
  * @return boolean
  */
 public function equals(Language $lang)
 {
     return $lang->getCode() === $this->mCode;
 }
示例#21
0
:</td>
    <td>
        <select name="f_root_topic_id" class="input_select">
<?php 
    $TOL_Language = camp_session_get('LoginLanguageId', 1);
    $lang = new Language($TOL_Language);
    $em = \Zend_Registry::get('container')->getService('em');
    $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
    $topicService = \Zend_Registry::get('container')->getService('newscoop_newscoop.topic_service');
    $topicsCount = $topicService->countBy();
    $cacheKey = $cacheService->getCacheKey(array('topics_add_article_type', $topicsCount), 'topic');
    $repository = $em->getRepository('Newscoop\\NewscoopBundle\\Entity\\Topic');
    if ($cacheService->contains($cacheKey)) {
        $topics = $cacheService->fetch($cacheKey);
    } else {
        $topicsQuery = $repository->getTranslatableTopics($lang->getCode());
        $topics = $topicsQuery->getResult();
        $cacheService->save($cacheKey, $topics);
    }
    foreach ($topics as $topic) {
        echo '<option value="' . $topic->getTopicId() . '">' . htmlspecialchars($topicService->getReadablePath($topic)) . "</option>\n";
    }
    ?>
        </select>
    </td>
</tr>
<TR>
    <TD COLSPAN="2">
    <DIV ALIGN="CENTER">
    <INPUT TYPE="HIDDEN" NAME="f_article_type" VALUE="<?php 
    print htmlspecialchars($articleTypeName);
示例#22
0
 /**
  * Helper method to get all messages
  *
  * @param Language $lang - Language object to get all messages from
  * @return array - list of all messages as key/value array
  */
 private function getAllMessages(Language $lang)
 {
     $this->app->wf->ProfileIn(__METHOD__);
     if (is_null($this->allMessages)) {
         $this->app->wf->ProfileIn(__METHOD__ . '::miss');
         $this->allMessages = $lang->getAllMessages();
         $langCode = $lang->getCode();
         // append legacy data
         if (isset(Language::$dataCache->legacyData[$langCode]['messages'])) {
             $this->allMessages = Language::$dataCache->legacyData[$langCode]['messages'] + $this->allMessages;
         }
         $this->app->wf->ProfileOut(__METHOD__ . '::miss');
     }
     $this->app->wf->ProfileOut(__METHOD__);
     return $this->allMessages;
 }
示例#23
0
 function getFirstLetterData()
 {
     if ($this->firstLetterData !== null) {
         return $this->firstLetterData;
     }
     $cache = wfGetCache(CACHE_ANYTHING);
     $cacheKey = wfMemcKey('first-letters', $this->locale, $this->digitTransformLanguage->getCode(), self::getICUVersion());
     $cacheEntry = $cache->get($cacheKey);
     if ($cacheEntry && isset($cacheEntry['version']) && $cacheEntry['version'] == self::FIRST_LETTER_VERSION) {
         $this->firstLetterData = $cacheEntry;
         return $this->firstLetterData;
     }
     // Generate data from serialized data file
     if (isset(self::$tailoringFirstLetters[$this->locale])) {
         $letters = wfGetPrecompiledData("first-letters-root.ser");
         // Append additional characters
         $letters = array_merge($letters, self::$tailoringFirstLetters[$this->locale]);
         // Remove unnecessary ones, if any
         if (isset(self::$tailoringFirstLetters['-' . $this->locale])) {
             $letters = array_diff($letters, self::$tailoringFirstLetters['-' . $this->locale]);
         }
         // Apply digit transforms
         $digits = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
         $letters = array_diff($letters, $digits);
         foreach ($digits as $digit) {
             $letters[] = $this->digitTransformLanguage->formatNum($digit, true);
         }
     } else {
         $letters = wfGetPrecompiledData("first-letters-{$this->locale}.ser");
         if ($letters === false) {
             throw new MWException("MediaWiki does not support ICU locale " . "\"{$this->locale}\"");
         }
     }
     /* Sort the letters.
      *
      * It's impossible to have the precompiled data file properly sorted,
      * because the sort order changes depending on ICU version. If the
      * array is not properly sorted, the binary search will return random
      * results.
      *
      * We also take this opportunity to remove primary collisions.
      */
     $letterMap = array();
     foreach ($letters as $letter) {
         $key = $this->getPrimarySortKey($letter);
         if (isset($letterMap[$key])) {
             // Primary collision
             // Keep whichever one sorts first in the main collator
             if ($this->mainCollator->compare($letter, $letterMap[$key]) < 0) {
                 $letterMap[$key] = $letter;
             }
         } else {
             $letterMap[$key] = $letter;
         }
     }
     ksort($letterMap, SORT_STRING);
     /* Remove duplicate prefixes. Basically if something has a sortkey
      * which is a prefix of some other sortkey, then it is an
      * expansion and probably should not be considered a section
      * header.
      *
      * For example 'þ' is sometimes sorted as if it is the letters
      * 'th'. Other times it is its own primary element. Another
      * example is '₨'. Sometimes its a currency symbol. Sometimes it
      * is an 'R' followed by an 's'.
      *
      * Additionally an expanded element should always sort directly
      * after its first element due to they way sortkeys work.
      *
      * UCA sortkey elements are of variable length but no collation
      * element should be a prefix of some other element, so I think
      * this is safe. See:
      * - https://ssl.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm
      * - http://site.icu-project.org/design/collation/uca-weight-allocation
      *
      * Additionally, there is something called primary compression to
      * worry about. Basically, if you have two primary elements that
      * are more than one byte and both start with the same byte then
      * the first byte is dropped on the second primary. Additionally
      * either \x03 or \xFF may be added to mean that the next primary
      * does not start with the first byte of the first primary.
      *
      * This shouldn't matter much, as the first primary is not
      * changed, and that is what we are comparing against.
      *
      * tl;dr: This makes some assumptions about how icu implements
      * collations. It seems incredibly unlikely these assumptions
      * will change, but nonetheless they are assumptions.
      */
     $prev = false;
     $duplicatePrefixes = array();
     foreach ($letterMap as $key => $value) {
         // Remove terminator byte. Otherwise the prefix
         // comparison will get hung up on that.
         $trimmedKey = rtrim($key, "");
         if ($prev === false || $prev === '') {
             $prev = $trimmedKey;
             // We don't yet have a collation element
             // to compare against, so continue.
             continue;
         }
         // Due to the fact the array is sorted, we only have
         // to compare with the element directly previous
         // to the current element (skipping expansions).
         // An element "X" will always sort directly
         // before "XZ" (Unless we have "XY", but we
         // do not update $prev in that case).
         if (substr($trimmedKey, 0, strlen($prev)) === $prev) {
             $duplicatePrefixes[] = $key;
             // If this is an expansion, we don't want to
             // compare the next element to this element,
             // but to what is currently $prev
             continue;
         }
         $prev = $trimmedKey;
     }
     foreach ($duplicatePrefixes as $badKey) {
         wfDebug("Removing '{$letterMap[$badKey]}' from first letters.\n");
         unset($letterMap[$badKey]);
         // This code assumes that unsetting does not change sort order.
     }
     $data = array('chars' => array_values($letterMap), 'keys' => array_keys($letterMap), 'version' => self::FIRST_LETTER_VERSION);
     // Reduce memory usage before caching
     unset($letterMap);
     // Save to cache
     $this->firstLetterData = $data;
     $cache->set($cacheKey, $data, $cache::TTL_WEEK);
     return $data;
 }
示例#24
0
 /**
  * Helper method to get all messages
  *
  * @param Language $lang - Language object to get all messages from
  * @return array - list of all message keys
  */
 private static function getAllMessageKeys(Language $lang)
 {
     wfProfileIn(__METHOD__);
     if (is_null(self::$allMessageKeys)) {
         wfProfileIn(__METHOD__ . '::miss');
         $messageKeys = $lang->getAllMessageKeys();
         self::$allMessageKeys = $messageKeys['messages'];
         $langCode = $lang->getCode();
         // append legacy data
         if (isset(Language::$dataCache->legacyData[$langCode]['messages'])) {
             self::$allMessageKeys = array_unique(array_keys(Language::$dataCache->legacyData[$langCode]['messages']), self::$allMessageKeys);
         }
         wfProfileOut(__METHOD__ . '::miss');
     }
     wfProfileOut(__METHOD__);
     return self::$allMessageKeys;
 }
示例#25
0
{
	$_SERVER['SERVER_PORT'] = 80;
}
$scheme = $_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://';
$siteAlias = new Alias($publicationObj->getDefaultAliasId());
$websiteURL = $scheme.$siteAlias->getName();

$accessParams = "LoginUserId=" . $g_user->getUserId() . "&LoginUserKey=" . $g_user->getKeyId()
				. "&AdminAccess=all";
$urlType = $publicationObj->getProperty('IdURLType');
if ($urlType == 1) {
	$templateObj = new Template($templateId);
	$url = "$websiteURL"  . $Campsite['SUBDIR'] . "/tpl/" . $templateObj->getName()
		. "?IdLanguage=$Language&IdPublication=$Pub&NrIssue=$Issue&$accessParams";
} else {
	$url = "$websiteURL" . $Campsite['SUBDIR'] . '/' . $languageObj->getCode()
		. "/" . $issueObj->getUrlName() . "?$accessParams";
}

$selectedLanguage = (int)CampRequest::GetVar('Language');
$url .= "&previewLang=$selectedLanguage";

if ($g_user->hasPermission("ManageTempl") || $g_user->hasPermission("DeleteTempl")) {
	// Show dual-pane view for those with template management priviledges
?>
<FRAMESET ROWS="60%,*" BORDER="1">
	<FRAME SRC="<?php echo "$url&preview=on"; ?>" NAME="body" FRAMEBORDER="1">
	<FRAME NAME="e" SRC="empty.php" FRAMEBORDER="1">
</FRAMESET>
<?php
} else {
示例#26
0
if (!$templateId) {
    $errorStr = $translator->trans('This issue cannot be previewed. Please make sure it has the front template selected.', array(), 'issues');
    camp_html_display_error($errorStr, null, true);
}
if (!isset($_SERVER['SERVER_PORT'])) {
    $_SERVER['SERVER_PORT'] = 80;
}
$scheme = $_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://';
$siteAlias = new Alias($publicationObj->getDefaultAliasId());
$websiteURL = $scheme . $siteAlias->getName();
$accessParams = "";
$urlType = $publicationObj->getProperty('IdURLType');
if ($urlType == 1) {
    $url = "{$websiteURL}" . "/tpl/" . $templateObj->getName() . "?IdLanguage={$Language}&IdPublication={$Pub}&NrIssue={$Issue}&{$accessParams}";
} else {
    $url = "{$websiteURL}" . '/' . $languageObj->getCode() . "/" . $issueObj->getUrlName() . "?{$accessParams}";
}
$selectedLanguage = (int) CampRequest::GetVar('Language');
$url .= "&previewLang={$selectedLanguage}";
if ($g_user->hasPermission("ManageTempl") || $g_user->hasPermission("DeleteTempl")) {
    // Show dual-pane view for those with template management priviledges
    ?>
<FRAMESET ROWS="60%,*" BORDER="1">
	<FRAME SRC="<?php 
    echo "{$url}&preview=on";
    ?>
" NAME="body"
		FRAMEBORDER="1">
	<FRAME NAME="e" SRC="empty.php" FRAMEBORDER="1">
</FRAMESET>
	<?php 
示例#27
0
 function getDefaultVariant()
 {
     return $this->mLang->getCode();
 }
示例#28
0
	</TR>

    <tr id="translate_type_<?php p($i); ?>" style="display: none;"><td colspan="6">
    	<table>

		<?php
		$color2 = 0;
		$isFirstTranslation = true;
		$typeTranslations = $currentArticleType->getTranslations();
		foreach ($typeTranslations as $typeLanguageId => $typeTransName) {
		?>
		<TR <?php  if ($color2) { $color2 = 0; ?>class="list_row_even"<?php  } else { $color2 = 1; ?>class="list_row_odd"<?php  } ?>">
			<TD <?php if ($isFirstTranslation) { ?>style="border-top: 2px solid #8AACCE;"<?php } ?> valign="middle" align="center">
				<?php
				$typeLanguage = new Language($typeLanguageId);
				p($typeLanguage->getCode());
				?>
			</TD>
			<TD <?php if ($isFirstTranslation) { ?>style="border-top: 2px solid #8AACCE;"<?php } ?> valign="middle" align="left" width="450px">
				<?php
				echo htmlspecialchars($typeTransName);
				?>
			</TD>
			</tr>
			<?php
			$isFirstTranslation = false;
		}
		?>

    	<tr>
    	<td colspan="2">
示例#29
0
 /**
  * Given a language, try and fetch a message from that language, then the
  * fallbacks of that language, then the site language, then the fallbacks for the
  * site language.
  *
  * @param Language $lang Requested language
  * @param string $lckey Lowercase key for the message
  * @param string $uckey Uppercase key for the message
  * @param bool $useDB Whether to use the database
  *
  * @see MessageCache::get
  * @return string|bool The message, or false if not found
  */
 protected function getMessageFromFallbackChain($lang, $lckey, $uckey, $useDB)
 {
     global $wgLanguageCode, $wgContLang;
     $langcode = $lang->getCode();
     $message = false;
     // First try the requested language.
     if ($useDB) {
         if ($langcode === $wgLanguageCode) {
             // Messages created in the content language will not have the /lang extension
             $message = $this->getMsgFromNamespace($uckey, $langcode);
         } else {
             $message = $this->getMsgFromNamespace("{$uckey}/{$langcode}", $langcode);
         }
     }
     if ($message !== false) {
         return $message;
     }
     // Check the CDB cache
     $message = $lang->getMessage($lckey);
     if ($message !== null) {
         return $message;
     }
     list($fallbackChain, $siteFallbackChain) = Language::getFallbacksIncludingSiteLanguage($langcode);
     // Next try checking the database for all of the fallback languages of the requested language.
     if ($useDB) {
         foreach ($fallbackChain as $code) {
             if ($code === $wgLanguageCode) {
                 // Messages created in the content language will not have the /lang extension
                 $message = $this->getMsgFromNamespace($uckey, $code);
             } else {
                 $message = $this->getMsgFromNamespace("{$uckey}/{$code}", $code);
             }
             if ($message !== false) {
                 // Found the message.
                 return $message;
             }
         }
     }
     // Now try checking the site language.
     if ($useDB) {
         $message = $this->getMsgFromNamespace($uckey, $wgLanguageCode);
         if ($message !== false) {
             return $message;
         }
     }
     $message = $wgContLang->getMessage($lckey);
     if ($message !== null) {
         return $message;
     }
     // Finally try the DB for the site language's fallbacks.
     if ($useDB) {
         foreach ($siteFallbackChain as $code) {
             $message = $this->getMsgFromNamespace("{$uckey}/{$code}", $code);
             if ($message === false && $code === $wgLanguageCode) {
                 // Messages created in the content language will not have the /lang extension
                 $message = $this->getMsgFromNamespace($uckey, $code);
             }
             if ($message !== false) {
                 // Found the message.
                 return $message;
             }
         }
     }
     return false;
 }
示例#30
0
 /**
  * Given a language, try and fetch messages from that language and its fallbacks.
  *
  * @see MessageCache::get
  * @param Language|StubObject $lang Preferred language
  * @param string $lckey Lowercase key for the message (as for localisation cache)
  * @param bool $useDB Whether to include messages from the wiki database
  * @param bool[] $alreadyTried Contains true for each language that has been tried already
  * @return string|bool The message, or false if not found
  */
 private function getMessageForLang($lang, $lckey, $useDB, &$alreadyTried)
 {
     global $wgContLang;
     $langcode = $lang->getCode();
     // Try checking the database for the requested language
     if ($useDB) {
         $uckey = $wgContLang->ucfirst($lckey);
         if (!isset($alreadyTried[$langcode])) {
             $message = $this->getMsgFromNamespace($this->getMessagePageName($langcode, $uckey), $langcode);
             if ($message !== false) {
                 return $message;
             }
             $alreadyTried[$langcode] = true;
         }
     } else {
         $uckey = null;
     }
     // Check the CDB cache
     $message = $lang->getMessage($lckey);
     if ($message !== null) {
         return $message;
     }
     // Try checking the database for all of the fallback languages
     if ($useDB) {
         $fallbackChain = Language::getFallbacksFor($langcode);
         foreach ($fallbackChain as $code) {
             if (isset($alreadyTried[$code])) {
                 continue;
             }
             $message = $this->getMsgFromNamespace($this->getMessagePageName($code, $uckey), $code);
             if ($message !== false) {
                 return $message;
             }
             $alreadyTried[$code] = true;
         }
     }
     return false;
 }