當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Languages::findById方法代碼示例

本文整理匯總了PHP中Languages::findById方法的典型用法代碼示例。如果您正苦於以下問題:PHP Languages::findById方法的具體用法?PHP Languages::findById怎麽用?PHP Languages::findById使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Languages的用法示例。


在下文中一共展示了Languages::findById方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * Construction languages administration controller
  *
  * @param Request $request
  * @return LanguagesAdminController
  */
 function __construct($request)
 {
     parent::__construct($request);
     if (!LOCALIZATION_ENABLED) {
         flash_error('Localization support is disabled. Please enabled it before you can access Language administration');
         $this->redirectTo('admin');
     }
     // if
     $this->wireframe->addBreadCrumb(lang('Languages'), assemble_url('admin_languages'));
     $language_id = $this->request->getId('language_id');
     if ($language_id) {
         $this->active_language = Languages::findById($language_id);
         if (instance_of($this->active_language, 'Language')) {
             $this->wireframe->addBreadCrumb($this->active_language->getName(), $this->active_language->getViewUrl());
         }
         // if
     } else {
         $this->active_language = new Language();
     }
     // if
     $this->smarty->assign('active_language', $this->active_language);
 }
開發者ID:NaszvadiG,項目名稱:activecollab_loc,代碼行數:28,代碼來源:LanguagesAdminController.class.php

示例2: getLocale

 /**
  * Return prefered locale
  *
  * @param string $default
  * @return string
  */
 function getLocale($default = null)
 {
     if ($this->locale === false) {
         $language_id = UserConfigOptions::getValue('language', $this);
         if ($language_id) {
             $language = Languages::findById($language_id);
             if (instance_of($language, 'Language')) {
                 $this->locale = $language->getLocale();
             }
             // if
         }
         // if
         if ($this->locale === false) {
             $this->locale = $default === null ? BUILT_IN_LOCALE : $default;
         }
         // if
     }
     // if
     return $this->locale;
 }
開發者ID:NaszvadiG,項目名稱:activecollab_loc,代碼行數:26,代碼來源:User.class.php

示例3: getLanguage

 /**
  * Return invoice company
  *
  * @param void
  * @return Company
  */
 function getLanguage()
 {
     if ($this->language === false) {
         $this->language = Languages::findById($this->getLanguageId());
     }
     // if
     return $this->language;
 }
開發者ID:NaszvadiG,項目名稱:activecollab_loc,代碼行數:14,代碼來源:Invoice.class.php

示例4: send

 /**
  * Send email to list of recipients
  * 
  * $to is a list of users who need to receive email notifications. If this 
  * function gets list of email addresses default language will be used. If 
  * we get User instances we'll use language set as prefered on their profile 
  * page
  * 
  * $to can also be a single user or email address
  * 
  * $tpl is a script in format module/name. If / is not present activeCollab 
  * will assume that template is in system module
  * 
  * Context is object that this email is primary related to
  * 
  * $attachments is array of attachments that are structured like this
  *    path -> path to file
  *    name -> name which will be displayed in email (if ommited original filename will be used)
  *    mime_type -> file mime type (if ommited system will determine mime type automatically)
  * here is sample of one $attachments array
  *    $attachments = array(
  *      array('path' => '/work/picture3.png', 'name' => 'simple_file_name.png', 'mime_type' => 'image/png')
  *    );
  * 
  * @param array $to
  * @param string $tpl
  * @param array $replacements
  * @param mixed $context
  * @param array $attachments
  * @return boolean
  */
 function send($to, $tpl, $replacements = null, $context = null, $attachments = null)
 {
     static $mark_as_bulk = null, $empty_return_path = null;
     if (isset($this) && instance_of($this, 'ApplicationMailer')) {
         if (!$this->connected) {
             $this->connect();
         }
         // if
         if (!is_foreachable($to)) {
             if (instance_of($to, 'User') || is_valid_email($to)) {
                 $to = array($to);
             } else {
                 return true;
                 // no recipients
             }
             // if
         }
         // if
         if (strpos($tpl, '/') === false) {
             $template_module = SYSTEM_MODULE;
         } else {
             list($template_module, $template_name) = explode('/', $tpl);
         }
         // if
         $template = EmailTemplates::findById(array('module' => $template_module, 'name' => $template_name));
         if (!instance_of($template, 'EmailTemplate')) {
             return false;
         }
         // if
         $owner_company = get_owner_company();
         if (is_array($replacements)) {
             $replacements['owner_company_name'] = $owner_company->getName();
         } else {
             $replacements = array('owner_company_name' => $owner_company->getName());
         }
         // if
         // Array of messages and recipients organized by language
         $to_send = array();
         // Set default locale (built in one)
         $default_locale = BUILT_IN_LOCALE;
         // Do we have a default language set
         $default_language_id = ConfigOptions::getValue('language');
         if ($default_language_id) {
             $default_language = Languages::findById($default_language_id);
             if (instance_of($default_language, 'Language') && !$default_language->isBuiltIn()) {
                 $default_locale = $default_language->getLocale();
             }
             // if
         }
         // if
         // Cache of loaded languages
         $languages = array();
         // Get from email and from name
         $from_email = ConfigOptions::getValue('notifications_from_email');
         $from_name = ConfigOptions::getValue('notifications_from_name');
         if (!is_valid_email($from_email)) {
             $from_email = ADMIN_EMAIL;
         }
         // if
         if (empty($from_name)) {
             $from_name = $owner_company->getName();
         }
         // if
         // Now prepare messages
         foreach ($to as $recipient) {
             $locale = $default_locale;
             if (instance_of($recipient, 'User')) {
                 $locale = $recipient->getLocale($default_locale);
                 $recipient_name = $recipient->getDisplayName();
//.........這裏部分代碼省略.........
開發者ID:NaszvadiG,項目名稱:activecollab_loc,代碼行數:101,代碼來源:ApplicationMailer.class.php

示例5: init_locale

 /**
  * Initialize locale settings based on logged in user
  *
  * @param void
  * @return null
  */
 function init_locale()
 {
     // Used when application is initialized from command line (we don't have
     // all the classes available)
     if (!class_exists('ConfigOptions') || !class_exists('UserConfigOptions')) {
         return true;
     }
     // if
     $logged_user =& get_logged_user();
     $language_id = null;
     if (instance_of($logged_user, 'User')) {
         if (LOCALIZATION_ENABLED) {
             $language_id = UserConfigOptions::getValue('language', $logged_user);
         }
         // if
         $format_date = UserConfigOptions::getValue('format_date', $logged_user);
         $format_time = UserConfigOptions::getValue('format_time', $logged_user);
     } else {
         if (LOCALIZATION_ENABLED) {
             $language_id = ConfigOptions::getValue('language');
         }
         // if
         $format_date = ConfigOptions::getValue('format_date');
         $format_time = ConfigOptions::getValue('format_time');
     }
     // if
     $language = new Language();
     // Now load languages
     if (LOCALIZATION_ENABLED && $language_id) {
         $language = Languages::findById($language_id);
         if (instance_of($language, 'Language')) {
             $current_locale = $language->getLocale();
             $GLOBALS['current_locale'] = $current_locale;
             $GLOBALS['current_locale_translations'] = array();
             if ($current_locale != BUILT_IN_LOCALE) {
                 setlocale(LC_ALL, $current_locale);
                 // Set locale
                 // workaround for tr, ku, az locales according to http://bugs.php.net/bug.php?id=18556
                 $current_locale_country = explode('.', $current_locale);
                 $current_locale_country = strtolower($current_locale_country[0]);
                 if (in_array($current_locale_country, array('tr_tr', 'ku', 'az_az'))) {
                     setlocale(LC_CTYPE, BUILT_IN_LOCALE);
                 }
                 // if
                 $GLOBALS['current_locale_translations'][$current_locale] = array();
                 $language->loadTranslations($current_locale);
             }
             // if
         }
         // if
     }
     // if
     $this->smarty->assign('current_language', $language);
     define('USER_FORMAT_DATETIME', "{$format_date} {$format_time}");
     define('USER_FORMAT_DATE', $format_date);
     define('USER_FORMAT_TIME', $format_time);
     return true;
 }
開發者ID:NaszvadiG,項目名稱:activecollab_loc,代碼行數:64,代碼來源:ActiveCollab.class.php


注:本文中的Languages::findById方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。