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


PHP Horde_Core_Translation::ngettext方法代码示例

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


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

示例1: _handle

 /**
  * Variables required in form input:
  *   - imple_submit: vcard action. Contains import and source properties
  *   - mime_id
  *   - muid
  *
  * @return boolean  True on success.
  */
 protected function _handle(Horde_Variables $vars)
 {
     global $registry, $injector, $notification;
     $iCal = new Horde_Icalendar();
     try {
         $contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices_Mailbox($vars));
         if (!($mime_part = $contents->getMimePart($vars->mime_id))) {
             throw new IMP_Exception(_("Cannot retrieve vCard data from message."));
         } elseif (!$iCal->parsevCalendar($mime_part->getContents(), 'VCALENDAR', $mime_part->getCharset())) {
             throw new IMP_Exception(_("Error reading the contact data."));
         }
         $components = $iCal->getComponents();
     } catch (Exception $e) {
         $notification->push($e, 'horde.error');
     }
     $import = !empty($vars->imple_submit->import) ? $vars->imple_submit->import : false;
     $source = !empty($vars->imple_submit->source) ? $vars->imple_submit->source : false;
     if ($import && $source && $registry->hasMethod('contacts/import')) {
         $count = 0;
         foreach ($components as $c) {
             if ($c->getType() == 'vcard') {
                 try {
                     $registry->call('contacts/import', array($c, null, $source));
                     ++$count;
                 } catch (Horde_Exception $e) {
                     $notification->push(Horde_Core_Translation::t("There was an error importing the contact data:") . ' ' . $e->getMessage(), 'horde.error');
                 }
             }
         }
         $notification->push(sprintf(Horde_Core_Translation::ngettext("%d contact was successfully added to your address book.", "%d contacts were successfully added to your address book.", $count), $count), 'horde.success');
     }
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:40,代码来源:VcardImport.php

示例2: _setAuth

 /**
  * Set authentication credentials in the Horde session.
  *
  * @return boolean  True on success, false on failure.
  */
 protected function _setAuth()
 {
     global $registry;
     if ($registry->isAuthenticated(array('app' => $this->_app, 'notransparent' => true))) {
         return true;
     }
     /* Grab the current language before we destroy the session. */
     $language = $registry->preferredLang();
     /* Destroy any existing session on login and make sure to use a
      * new session ID, to avoid session fixation issues. */
     if (($userId = $registry->getAuth()) === false) {
         $GLOBALS['session']->clean();
         $userId = $this->getCredential('userId');
     }
     $credentials = $this->getCredential('credentials');
     try {
         list(, $credentials) = $this->runHook($userId, $credentials, 'postauthenticate');
     } catch (Horde_Auth_Exception $e) {
         return false;
     }
     $registry->setAuth($userId, $credentials, array('app' => $this->_app, 'change' => $this->getCredential('change'), 'language' => $language));
     /* Only set the view mode on initial authentication */
     if (!$GLOBALS['session']->exists('horde', 'view')) {
         $this->_setView();
     }
     if ($this->_base && isset($GLOBALS['notification']) && ($expire = $this->_base->getCredential('expire'))) {
         $toexpire = ($expire - time()) / 86400;
         $GLOBALS['notification']->push(sprintf(Horde_Core_Translation::ngettext("%d day until your password expires.", "%d days until your password expires.", $toexpire), $toexpire), 'horde.warning');
     }
     return true;
 }
开发者ID:horde,项目名称:horde,代码行数:36,代码来源:Application.php

示例3: _renderInline

 /**
  * Return the rendered inline version of the Horde_Mime_Part object.
  *
  * @return array  See parent::render().
  */
 protected function _renderInline()
 {
     $browser = $this->getConfigParam('browser');
     $notification = $this->getConfigParam('notification');
     $prefs = $this->getConfigParam('prefs');
     $registry = $this->getConfigParam('registry');
     $data = $this->_mimepart->getContents();
     $html = '';
     $title = Horde_Core_Translation::t("vCard");
     $iCal = new Horde_Icalendar();
     if (!$iCal->parsevCalendar($data, 'VCALENDAR', $this->_mimepart->getCharset())) {
         $notification->push(Horde_Core_Translation::t("There was an error reading the contact data."), 'horde.error');
     }
     if (Horde_Util::getFormData('import') && Horde_Util::getFormData('source') && $registry->hasMethod('contacts/import')) {
         $source = Horde_Util::getFormData('source');
         $count = 0;
         foreach ($iCal->getComponents() as $c) {
             if ($c->getType() == 'vcard') {
                 try {
                     $registry->call('contacts/import', array($c, null, $source));
                     ++$count;
                 } catch (Horde_Exception $e) {
                     $notification->push(Horde_Core_Translation::t("There was an error importing the contact data:") . ' ' . $e->getMessage(), 'horde.error');
                 }
             }
         }
         $notification->push(sprintf(Horde_Core_Translation::ngettext("%d contact was successfully added to your address book.", "%d contacts were successfully added to your address book.", $count), $count), 'horde.success');
     }
     $html .= '<table class="horde-table" style="width:100%">';
     foreach ($iCal->getComponents() as $i => $vc) {
         if ($i > 0) {
             $html .= '<tr><td colspan="2">&nbsp;</td></tr>';
         }
         $addresses = $vc->getAllAttributes('EMAIL');
         $html .= '<tr><td colspan="2" class="header">';
         if (($fullname = $vc->getAttributeDefault('FN', false)) === false) {
             $fullname = count($addresses) ? $addresses[0]['value'] : Horde_Core_Translation::t("[No Label]");
         }
         $html .= htmlspecialchars($fullname) . '</td></tr>';
         $n = $vc->printableName();
         if (!empty($n)) {
             $html .= $this->_row(Horde_Core_Translation::t("Name"), $n);
         }
         try {
             $html .= $this->_row(Horde_Core_Translation::t("Alias"), implode("\n", $vc->getAttributeValues('ALIAS')));
         } catch (Horde_Icalendar_Exception $e) {
         }
         try {
             $birthdays = $vc->getAttributeValues('BDAY');
             $birthday = new Horde_Date($birthdays[0]);
             $html .= $this->_row(Horde_Core_Translation::t("Birthday"), $birthday->strftime($prefs->getValue('date_format')));
         } catch (Horde_Icalendar_Exception $e) {
         }
         $photos = $vc->getAllAttributes('PHOTO');
         foreach ($photos as $p => $photo) {
             if (isset($photo['params']['VALUE']) && Horde_String::upper($photo['params']['VALUE']) == 'URI') {
                 $html .= $this->_row(Horde_Core_Translation::t("Photo"), '<img src="' . htmlspecialchars($photo['value']) . '" />', false);
             } elseif (isset($photo['params']['ENCODING']) && Horde_String::upper($photo['params']['ENCODING']) == 'B' && isset($photo['params']['TYPE'])) {
                 if ($browser->hasFeature('datauri') === true || $browser->hasFeature('datauri') >= strlen($photo['value'])) {
                     $html .= $this->_row(Horde_Core_Translation::t("Photo"), '<img src="' . Horde_Url_Data::create($photo['params']['TYPE'], base64_decode($photo['value'])) . '" />', false);
                 } elseif ($this->_imageUrl) {
                     $html .= $this->_row(Horde_Core_Translation::t("Photo"), '<img src="' . $this->_imageUrl->add(array('c' => $i, 'p' => $p)) . '" />', false);
                 }
             }
         }
         $labels = $vc->getAllAttributes('LABEL');
         foreach ($labels as $label) {
             if (isset($label['params']['TYPE'])) {
                 if (!is_array($label['params']['TYPE'])) {
                     $label['params']['TYPE'] = array($label['params']['TYPE']);
                 }
             } else {
                 $label['params']['TYPE'] = array_keys($label['params']);
             }
             $types = array();
             foreach ($label['params']['TYPE'] as $type) {
                 switch (Horde_String::upper($type)) {
                     case 'HOME':
                         $types[] = Horde_Core_Translation::t("Home Address");
                         break;
                     case 'WORK':
                         $types[] = Horde_Core_Translation::t("Work Address");
                         break;
                     case 'DOM':
                         $types[] = Horde_Core_Translation::t("Domestic Address");
                         break;
                     case 'INTL':
                         $types[] = Horde_Core_Translation::t("International Address");
                         break;
                     case 'POSTAL':
                         $types[] = Horde_Core_Translation::t("Postal Address");
                         break;
                     case 'PARCEL':
                         $types[] = Horde_Core_Translation::t("Parcel Address");
                         break;
//.........这里部分代码省略.........
开发者ID:raz0rsdge,项目名称:horde,代码行数:101,代码来源:Vcard.php

示例4: handle

 /**
  * Process a modification to the current layout.
  *
  * @param string $action  TODO
  * @param integer $row    TODO
  * @param integer $col    TODO
  * @param string $url     TODO
  *
  * @throws Horde_Exception
  */
 public function handle($action, $row, $col, $url = null)
 {
     switch ($action) {
         case 'moveUp':
         case 'moveDown':
         case 'moveLeft':
         case 'moveRight':
         case 'expandUp':
         case 'expandDown':
         case 'expandLeft':
         case 'expandRight':
         case 'shrinkLeft':
         case 'shrinkRight':
         case 'shrinkUp':
         case 'shrinkDown':
         case 'removeBlock':
             try {
                 call_user_func(array($this, $action), $row, $col);
                 $this->_updated = true;
             } catch (Horde_Exception $e) {
                 $GLOBALS['notification']->push($e);
             }
             break;
             // Save the changes made to a block.
         // Save the changes made to a block.
         case 'save':
             // Save the changes made to a block and continue editing.
         // Save the changes made to a block and continue editing.
         case 'save-resume':
             // Get requested block type.
             list($newapp, $newtype) = explode(':', Horde_Util::getFormData('app'));
             // Is this a new block?
             $new = false;
             if ($this->isEmpty($row, $col) || !$this->rowExists($row) || !$this->colExists($col)) {
                 // Check permissions.
                 $max_blocks = $GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('max_blocks');
                 if ($max_blocks !== true && $max_blocks <= count($this)) {
                     Horde::permissionDeniedError('horde', 'max_blocks', sprintf(Horde_Core_Translation::ngettext("You are not allowed to create more than %d block.", "You are not allowed to create more than %d blocks.", $max_blocks), $max_blocks));
                     break;
                 }
                 $new = true;
                 // Make sure there is somewhere to put it.
                 $this->addBlock($row, $col);
             }
             // Or an existing one?
             $exists = false;
             $changed = false;
             if (!$new) {
                 // Get target block info.
                 $info = $this->getBlockInfo($row, $col);
                 $exists = $this->isBlock($row, $col);
                 // Has a different block been selected?
                 if ($exists && ($info['app'] != $newapp || $info['block'] != $newtype)) {
                     $changed = true;
                 }
             }
             if ($new || $changed) {
                 // Change app or type.
                 $info = array('app' => $newapp, 'block' => $newtype);
                 $params = $this->_collection->getParams($newapp, $newtype);
                 foreach ($params as $newparam) {
                     $info['params'][$newparam] = $this->_collection->getDefaultValue($newapp, $newtype, $newparam);
                 }
                 $this->setBlockInfo($row, $col, $info);
             } elseif ($exists) {
                 // Change values.
                 $this->setBlockInfo($row, $col, array('params' => Horde_Util::getFormData('params', array())));
             }
             $this->_updated = true;
             if ($action == 'save') {
                 break;
             }
             // Make a block the current block for editing.
         // Make a block the current block for editing.
         case 'edit':
             $this->_currentBlock = array($row, $col);
             $url = null;
             break;
     }
     if (!empty($url)) {
         $url = new Horde_Url($url);
         $url->unique()->redirect();
     }
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:94,代码来源:Manager.php


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