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


PHP Horde_String::substr方法代码示例

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


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

示例1: __construct

 /**
  * Constructor.
  *
  * @param array $config  Configuration key-value pairs.
  */
 public function __construct($config = array())
 {
     global $prefs, $registry;
     parent::__construct($config);
     $blank = new Horde_Url();
     $this->addNewButton(_("_New Event"), $blank, array('id' => 'kronolithNewEvent'));
     $this->newExtra = $blank->link(array_merge(array('id' => 'kronolithQuickEvent'), Horde::getAccessKeyAndTitle(_("Quick _insert"), false, true)));
     $sidebar = $GLOBALS['injector']->createInstance('Horde_View');
     /* Minical. */
     $today = new Horde_Date($_SERVER['REQUEST_TIME']);
     $sidebar->today = $today->format('F Y');
     $sidebar->weekdays = array();
     for ($i = $prefs->getValue('week_start_monday'), $c = $i + 7; $i < $c; $i++) {
         $weekday = Horde_Nls::getLangInfo(constant('DAY_' . ($i % 7 + 1)));
         $sidebar->weekdays[$weekday] = Horde_String::substr($weekday, 0, 2);
     }
     /* Calendars. */
     $sidebar->newShares = $registry->getAuth() && !$prefs->isLocked('default_share');
     $sidebar->admin = $registry->isAdmin();
     $sidebar->resourceAdmin = $registry->isAdmin() || $GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('resource_management');
     $sidebar->resources = $GLOBALS['conf']['resources']['enabled'];
     $sidebar->addRemote = !$prefs->isLocked('remote_cals');
     $remotes = unserialize($prefs->getValue('remote_cals'));
     $sidebar->showRemote = !($prefs->isLocked('remote_cals') && empty($remotes));
     $this->content = $sidebar->render('dynamic/sidebar');
 }
开发者ID:horde,项目名称:horde,代码行数:31,代码来源:Sidebar.php

示例2: init

 /**
  * Output the necessary javascript code to allow display of the calendar
  * widget.
  *
  * @param array $params  Configuration parameters for the widget:
  * <pre>
  * 'click_month' - (boolean) If true, the month is clickable.
  *                 DEFAULT: false
  * 'click_week' - (boolean) If true, will display a clickable week.
  *                DEFAULT: false
  * 'click_year' - (boolean) If true, the year is clickable.
  *                DEFAULT: false
  * 'full_weekdays' - (boolean) Add full weekday localized list to
  *                   javascript object.
  *                   DEFAULT: false
  * 'short_weekdays' - (boolean) Display only the first letter of
  *                    weekdays?
  *                    DEFAULT: false
  * </pre>
  */
 public static function init(array $params = array())
 {
     if (self::$_initRun) {
         return;
     }
     self::$_initRun = true;
     $params = array_merge(array('click_month' => false, 'click_week' => false, 'click_year' => false, 'full_weekdays' => false, 'short_weekdays' => false), $params);
     $weekdays = self::weekdays();
     if ($params['short_weekdays']) {
         foreach ($weekdays as &$day) {
             $day = Horde_String::substr($day, 0, 1);
         }
     }
     $js = array('-Horde_Calendar.click_month' => intval($params['click_month']), '-Horde_Calendar.click_week' => intval($params['click_week']), '-Horde_Calendar.click_year' => intval($params['click_year']), '-Horde_Calendar.firstDayOfWeek' => intval($GLOBALS['prefs']->getValue('first_week_day')), 'Horde_Calendar.months' => self::months(), 'Horde_Calendar.weekdays' => $weekdays);
     if ($params['full_weekdays']) {
         $js['Horde_Calendar.fullweekdays'] = self::fullWeekdays();
     }
     $page_output = $GLOBALS['injector']->getInstance('Horde_PageOutput');
     $page_output->addScriptFile('calendar.js', 'horde');
     $page_output->addInlineJsVars($js);
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:41,代码来源:JsCalendar.php

示例3: _init


//.........这里部分代码省略.........
     switch ($priority = $injector->getInstance('IMP_Mime_Headers')->getPriority($mime_headers)) {
         case 'high':
         case 'low':
             $basic_headers['priority'] = _("Priority");
             $display_headers['priority'] = Horde_String::ucfirst($priority);
             break;
     }
     /* Set the status information of the message. */
     $status = '';
     $match_identity = $identity = null;
     if (!empty($msgAddresses)) {
         $match_identity = $identity = $user_identity->getMatchingIdentity($msgAddresses);
         if (is_null($identity)) {
             $identity = $user_identity->getDefault();
         }
     }
     $flag_parse = $injector->getInstance('IMP_Flags')->parse(array('flags' => $flags, 'personal' => $match_identity));
     foreach ($flag_parse as $val) {
         if ($abbrev = $val->abbreviation) {
             $status .= $abbrev;
         } elseif ($val instanceof IMP_Flag_User) {
             $status .= ' *' . Horde_String::truncate($val->label, 8) . '*';
         }
     }
     /* Create the body of the message. */
     $inlineout = $imp_contents->getInlineOutput(array('display_mask' => IMP_Contents::RENDER_INLINE, 'no_inline_all' => true));
     $msg_text = $inlineout['msgtext'];
     $this->view->msg = nl2br($injector->getInstance('Horde_Core_Factory_TextFilter')->filter($msg_text, 'space2html'));
     $menu = array();
     if ($this->indices->mailbox->access_deletemsgs) {
         $menu[] = in_array(Horde_Imap_Client::FLAG_DELETED, $flags) ? array(_("Undelete"), $self_link->copy()->add('a', 'u')) : array(_("Delete"), $self_link->copy()->add(array('a' => 'd', 't' => $session->getToken())));
     }
     /* Add compose actions (Reply, Reply List, Reply All, Forward,
      * Redirect, Edit as New). */
     if (IMP_Compose::canCompose()) {
         $clink_ob = new IMP_Compose_Link();
         $clink_ob->args['buid'] = $buid;
         $clink_ob->args['mailbox'] = $this->indices->mailbox;
         $clink = $clink_ob->link()->add(array('identity' => $identity));
         $menu[] = array(_("Reply"), $clink->copy()->add(array('a' => 'r')));
         if ($list_info['reply_list']) {
             $menu[] = array(_("Reply to List"), $clink->copy()->add(array('a' => 'rl')));
         }
         $addr_ob = clone $envelope->to;
         $addr_ob->add($envelope->cc);
         $addr_ob->setIteratorFilter(0, $user_identity->getAllFromAddresses());
         if (count($addr_ob)) {
             $menu[] = array(_("Reply All"), $clink->copy()->add(array('a' => 'ra')));
         }
         $menu[] = array(_("Forward"), $clink->copy()->add(array('a' => 'f')));
         $menu[] = array(_("Redirect"), $clink->copy()->add(array('a' => 'rc')));
         $menu[] = array(_("Edit as New"), $clink->copy()->add(array('a' => 'en')));
     }
     /* Generate previous/next links. */
     if ($prev_msg = $imp_mailbox[$imp_mailbox->getIndex() - 1]) {
         $menu[] = array(_("Previous Message"), self::url(array('buid' => $imp_mailbox->getBuid($prev_msg['m'], $prev_msg['u']), 'mailbox' => $this->indices->mailbox)));
     }
     if ($next_msg = $imp_mailbox[$imp_mailbox->getIndex() + 1]) {
         $menu[] = array(_("Next Message"), self::url(array('buid' => $imp_mailbox->getBuid($next_msg['m'], $next_msg['u']), 'mailbox' => $this->indices->mailbox)));
     }
     $menu[] = array(sprintf(_("To %s"), $this->indices->mailbox->label), $mailbox_link);
     if ($mailbox->spam_show) {
         $menu[] = array(_("Report as Spam"), $self_link->copy()->add(array('a' => 'rs', 't' => $session->getToken())));
     }
     if ($mailbox->innocent_show) {
         $menu[] = array(_("Report as Innocent"), $self_link->copy()->add(array('a' => 'ri', 't' => $session->getToken())));
     }
     $this->view->menu = $this->getMenu('message', $menu);
     $hdrs = array();
     foreach ($display_headers as $head => $val) {
         $tmp = array('label' => $basic_headers[$head]);
         if (Horde_String::lower($head) == 'to' && !isset($this->vars->allto) && ($pos = strpos($val, ',')) !== false) {
             $val = Horde_String::substr($val, 0, $pos);
             $tmp['all_to'] = $self_link->copy()->add('allto', 1);
         }
         $tmp['val'] = $val;
         $hdrs[] = $tmp;
     }
     $this->view->hdrs = $hdrs;
     $atc = array();
     foreach ($inlineout['atc_parts'] as $key) {
         $summary = $imp_contents->getSummary($key, IMP_Contents::SUMMARY_BYTES | IMP_Contents::SUMMARY_SIZE | IMP_Contents::SUMMARY_DESCRIP | IMP_Contents::SUMMARY_DOWNLOAD);
         $tmp = array('descrip' => $summary['description_raw'], 'size' => $summary['size'], 'type' => $summary['type']);
         if (!empty($summary['download'])) {
             /* Preference: if set, only show download confirmation screen
              * if attachment over a certain size. */
             $tmp['download'] = IMP_Minimal_Messagepart::url(array('buid' => $buid, 'mailbox' => $this->indices->mailbox))->add('atc', $key);
         }
         if ($imp_contents->canDisplay($key, IMP_Contents::RENDER_INLINE)) {
             $tmp['view'] = IMP_Minimal_Messagepart::url(array('buid' => $buid, 'mailbox' => $this->indices->mailbox))->add('id', $key);
         }
         $atc[] = $tmp;
     }
     $this->view->atc = $atc;
     $this->title = $display_headers['subject'];
     $this->view->title = ($status ? $status . ' ' : '') . sprintf(_("(Message %d of %d)"), $msgindex, $msgcount);
     $page_output->noDnsPrefetch();
     $this->_pages[] = 'message';
     $this->_pages[] = 'menu';
 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:101,代码来源:Message.php

示例4: _guessName

 /**
  * Helper function for guessing name parts from a single name string.
  *
  * @param array $hash  The attributes array.
  */
 protected function _guessName(&$hash)
 {
     if (($pos = strpos($hash['name'], ',')) !== false) {
         // Assume Last, First
         $hash['lastname'] = Horde_String::substr($hash['name'], 0, $pos);
         $hash['firstname'] = trim(Horde_String::substr($hash['name'], $pos + 1));
     } elseif (($pos = Horde_String::rpos($hash['name'], ' ')) !== false) {
         // Assume everything after last space as lastname
         $hash['lastname'] = trim(Horde_String::substr($hash['name'], $pos + 1));
         $hash['firstname'] = Horde_String::substr($hash['name'], 0, $pos);
     } else {
         $hash['lastname'] = $hash['name'];
         $hash['firstname'] = '';
     }
 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:20,代码来源:Driver.php

示例5: wordwrap

 /**
  * Wraps the text of a message.
  *
  * @since Horde 3.2
  *
  * @param string $string Horde_String containing the text to wrap.
  * @param integer $width Wrap the string at this number of
  *                               characters.
  * @param string $break Character(s) to use when breaking lines.
  * @param boolean $cut Whether to cut inside words if a line
  *                               can't be wrapped.
  * @param string $charset Character set to use when breaking lines.
  * @param boolean $line_folding Whether to apply line folding rules per
  *                               RFC 822 or similar. The correct break
  *                               characters including leading whitespace
  *                               have to be specified too.
  *
  * @return string  Horde_String containing the wrapped text.
  */
 public function wordwrap($string, $width = 75, $break = "\n", $cut = false, $charset = null, $line_folding = false)
 {
     /* Get the user's default character set if none passed in. */
     if (is_null($charset)) {
         $charset = self::$charset;
     }
     $charset = Horde_String::_mbstringCharset($charset);
     $string = Horde_String::convertCharset($string, $charset, 'utf-8');
     $wrapped = '';
     while (Horde_String::length($string, 'utf-8') > $width) {
         $line = Horde_String::substr($string, 0, $width, 'utf-8');
         $string = Horde_String::substr($string, Horde_String::length($line, 'utf-8'), null, 'utf-8');
         // Make sure didn't cut a word, unless we want hard breaks anyway.
         if (!$cut && preg_match('/^(.+?)(\\s|\\r?\\n)/u', $string, $match)) {
             $line .= $match[1];
             $string = Horde_String::substr($string, Horde_String::length($match[1], 'utf-8'), null, 'utf-8');
         }
         // Wrap at existing line breaks.
         if (preg_match('/^(.*?)(\\r?\\n)(.*)$/u', $line, $match)) {
             $wrapped .= $match[1] . $match[2];
             $string = $match[3] . $string;
             continue;
         }
         // Wrap at the last colon or semicolon followed by a whitespace if
         // doing line folding.
         if ($line_folding && preg_match('/^(.*?)(;|:)(\\s+.*)$/u', $line, $match)) {
             $wrapped .= $match[1] . $match[2] . $break;
             $string = $match[3] . $string;
             continue;
         }
         // Wrap at the last whitespace of $line.
         if ($line_folding) {
             $sub = '(.+[^\\s])';
         } else {
             $sub = '(.*)';
         }
         if (preg_match('/^' . $sub . '(\\s+)(.*)$/u', $line, $match)) {
             $wrapped .= $match[1] . $break;
             $string = ($line_folding ? $match[2] : '') . $match[3] . $string;
             continue;
         }
         // Hard wrap if necessary.
         if ($cut) {
             $wrapped .= Horde_String::substr($line, 0, $width, 'utf-8') . $break;
             $string = Horde_String::substr($line, $width, null, 'utf-8') . $string;
             continue;
         }
         $wrapped .= $line;
     }
     return Horde_String::convertCharset($wrapped . $string, 'utf-8', $charset);
 }
开发者ID:techdata,项目名称:as2secure-bundle,代码行数:70,代码来源:String.php

示例6: toASAppointment

 /**
  * Export this event as a MS ActiveSync Message
  *
  * @param array $options  Options:
  *   - protocolversion: (float)  The EAS version to support
  *                      DEFAULT: 2.5
  *   - bodyprefs: (array)  A BODYPREFERENCE array.
  *                DEFAULT: none (No body prefs enforced).
  *   - truncation: (integer)  Truncate event body to this length
  *                 DEFAULT: none (No truncation).
  *
  * @return Horde_ActiveSync_Message_Appointment
  */
 public function toASAppointment(array $options = array())
 {
     global $prefs, $registry;
     $message = new Horde_ActiveSync_Message_Appointment(array('logger' => $GLOBALS['injector']->getInstance('Horde_Log_Logger'), 'protocolversion' => $options['protocolversion']));
     if (!$this->isPrivate()) {
         // Handle body/truncation
         if (!empty($options['bodyprefs'])) {
             if (Horde_String::length($this->description) > 0) {
                 $bp = $options['bodyprefs'];
                 $note = new Horde_ActiveSync_Message_AirSyncBaseBody();
                 // No HTML supported. Always use plaintext.
                 $note->type = Horde_ActiveSync::BODYPREF_TYPE_PLAIN;
                 if (isset($bp[Horde_ActiveSync::BODYPREF_TYPE_PLAIN]['truncationsize'])) {
                     $truncation = $bp[Horde_ActiveSync::BODYPREF_TYPE_PLAIN]['truncationsize'];
                 } elseif (isset($bp[Horde_ActiveSync::BODYPREF_TYPE_HTML])) {
                     $truncation = $bp[Horde_ActiveSync::BODYPREF_TYPE_HTML]['truncationsize'];
                     $this->description = Horde_Text_Filter::filter($this->description, 'Text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO));
                 } else {
                     $truncation = false;
                 }
                 if ($truncation && Horde_String::length($this->description) > $truncation) {
                     $note->data = Horde_String::substr($this->desciption, 0, $truncation);
                     $note->truncated = 1;
                 } else {
                     $note->data = $this->description;
                 }
                 $note->estimateddatasize = Horde_String::length($this->description);
                 $message->airsyncbasebody = $note;
             }
         } else {
             $message->setBody($this->description);
         }
         $message->setLocation($this->location);
     }
     $message->setSubject($this->getTitle());
     $message->setDatetime(array('start' => $this->start, 'end' => $this->end, 'allday' => $this->isAllDay()));
     $message->setTimezone($this->start);
     // Organizer
     if (count($this->attendees)) {
         if ($this->creator == $registry->getAuth()) {
             $as_ident = $prefs->getValue('activesync_identity') == 'horde' ? $prefs->getValue('default_identity') : $prefs->getValue('activesync_identity');
             $name = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create($this->creator)->getValue('fullname', $as_ident);
             $email = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create($this->creator)->getValue('from_addr', $as_ident);
         } else {
             $name = Kronolith::getUserName($this->creator);
             $email = Kronolith::getUserEmail($this->creator);
         }
         $message->setOrganizer(array('name' => $name, 'email' => $email));
     }
     // Privacy
     $message->setSensitivity($this->private ? Horde_ActiveSync_Message_Appointment::SENSITIVITY_PRIVATE : Horde_ActiveSync_Message_Appointment::SENSITIVITY_NORMAL);
     // Busy Status
     switch ($this->status) {
         case Kronolith::STATUS_CANCELLED:
             $status = Horde_ActiveSync_Message_Appointment::BUSYSTATUS_FREE;
             break;
         case Kronolith::STATUS_CONFIRMED:
             $status = Horde_ActiveSync_Message_Appointment::BUSYSTATUS_BUSY;
             break;
         case Kronolith::STATUS_TENTATIVE:
             $status = Horde_ActiveSync_Message_Appointment::BUSYSTATUS_TENTATIVE;
         case Kronolith::STATUS_FREE:
         case Kronolith::STATUS_NONE:
             $status = Horde_ActiveSync_Message_Appointment::BUSYSTATUS_FREE;
     }
     $message->setBusyStatus($status);
     // DTStamp
     $message->setDTStamp($_SERVER['REQUEST_TIME']);
     // Recurrence
     if ($this->recurs()) {
         $message->setRecurrence($this->recurrence, $GLOBALS['prefs']->getValue('week_start_monday'));
         /* Exceptions are tricky. Exceptions, even those that represent
          * deleted instances of a recurring event, must be added. To do this
          * we query the storage for all the events that represent exceptions
          * (those with the baseid == $this->uid) and then remove the
          * exceptionoriginaldate from the list of exceptions we know about.
          * Any dates left in this list when we are done, must represent
          * deleted instances of this recurring event.*/
         if (!empty($this->recurrence) && ($exceptions = $this->recurrence->getExceptions())) {
             $results = $this->boundExceptions();
             foreach ($results as $exception) {
                 $e = new Horde_ActiveSync_Message_Exception(array('protocolversion' => $options['protocolversion']));
                 $e->setDateTime(array('start' => $exception->start, 'end' => $exception->end, 'allday' => $exception->isAllDay()));
                 // The start time of the *original* recurring event
                 $e->setExceptionStartTime($exception->exceptionoriginaldate);
                 $originaldate = $exception->exceptionoriginaldate->format('Ymd');
                 $key = array_search($originaldate, $exceptions);
//.........这里部分代码省略.........
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:101,代码来源:Event.php

示例7: toASNote

 /**
  * Create an AS memo from this task
  *
  * @param array $memo  A memo array.
  * @param array $options
  *
  * @return Horde_ActiveSync_Message_Note
  */
 public function toASNote($memo, $options = array())
 {
     $message = new Horde_ActiveSync_Message_Note(array('protocolversion' => $options['protocolversion']));
     $message->subject = $memo['desc'];
     $bp = $options['bodyprefs'];
     $body = new Horde_ActiveSync_Message_AirSyncBaseBody();
     // When the note is encrypted, we won't have the passphrase so the
     // body will be a Mnemo_Exception.
     if ($memo['body'] instanceof Mnemo_Exception) {
         $memo['body'] = $memo['body']->getMessage();
     }
     if (isset($bp[Horde_ActiveSync::BODYPREF_TYPE_HTML])) {
         $body->type = Horde_ActiveSync::BODYPREF_TYPE_HTML;
         $memo['body'] = Horde_Text_Filter::filter($memo['body'], 'Text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO));
         if (isset($bp[Horde_ActiveSync::BODYPREF_TYPE_HTML]['truncationsize']) && Horde_String::length($memo['body']) > $bp[Horde_ActiveSync::BODYPREF_TYPE_HTML]['truncationsize']) {
             $body->data = Horde_String::substr($memo['body'], $bp[Horde_ActiveSync::BODYPREF_TYPE_HTML]['truncationsize']);
             $body->truncated = 1;
         } else {
             $body->data = $memo['body'];
         }
     } else {
         $body->type = Horde_ActiveSync::BODYPREF_TYPE_PLAIN;
         if (isset($bp[Horde_ActiveSync::BODYPREF_TYPE_PLAIN]['truncationsize']) && Horde_String::length($memo['body']) > $bp[Horde_ActiveSync::BODYPREF_TYPE_PLAIN]['truncationsize']) {
             $body->data = Horde_String::substr($memo['body'], 0, $bp[Horde_ActiveSync::BODYPREF_TYPE_PLAIN]['truncationsize']);
             $body->truncated = 1;
         } else {
             $body->data = $memo['body'];
         }
     }
     $body->estimateddatasize = Horde_String::length($memo['body']);
     $message->body = $body;
     if (!empty($memo['tags'])) {
         $message->categories = $memo['tags'];
     }
     $history = $GLOBALS['injector']->getInstance('Horde_History');
     $last = $history->getActionTimeStamp('mnemo:' . $memo['memolist_id'] . ':' . $memo['uid'], 'modify');
     if (empty($last)) {
         $last = $history->getActionTimeStamp('mnemo:' . $memo['memolist_id'] . ':' . $memo['uid'], 'add');
     }
     $message->lastmodified = new Horde_Date($last);
     return $message;
 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:50,代码来源:Driver.php

示例8: guessLastname

 /**
  * Returns a best guess at the lastname in a string.
  *
  * @param string $name  String contain the full name.
  *
  * @return string  String containing the last name.
  */
 public static function guessLastname($name)
 {
     $name = trim(preg_replace('|\\s|', ' ', $name));
     if (!empty($name)) {
         /* Assume that last names are always before any commas. */
         if (is_int(strpos($name, ','))) {
             $name = Horde_String::substr($name, 0, strpos($name, ','));
         }
         /* Take out anything in parentheses. */
         $name = trim(preg_replace('|\\(.*\\)|', '', $name));
         $namelist = explode(' ', $name);
         $name = $namelist[$nameindex = count($namelist) - 1];
         while (!empty($name) && ($nlength = Horde_String::length($name)) < 5 && strspn($name[$nlength - 1], '.:-') && !empty($namelist[$nameindex - 1])) {
             $name = $namelist[--$nameindex];
         }
     }
     return strlen($name) ? $name : null;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:25,代码来源:Turba.php

示例9: verifyDir

 /**
  * This function verifies whether a given directory is below the root.
  *
  * @param string $dir  The directory to check.
  *
  * @return boolean  True if the directory is below the root.
  */
 public static function verifyDir($dir)
 {
     return Horde_String::substr(Horde_Util::realPath($dir), 0, Horde_String::length(self::$backend['root'])) == self::$backend['root'];
 }
开发者ID:horde,项目名称:horde,代码行数:11,代码来源:Gollem.php

示例10: _getMessageText

 /**
  * Regenerates body text for use in the compose screen from IMAP data.
  *
  * @param IMP_Contents $contents  An IMP_Contents object.
  * @param array $options          Additional options:
  * <ul>
  *  <li>html: (boolean) Return text/html part, if available.</li>
  *  <li>imp_msg: (integer) If non-empty, the message data was created by
  *               IMP. Either:
  *   <ul>
  *    <li>self::COMPOSE</li>
  *    <li>self::FORWARD</li>
  *    <li>self::REPLY</li>
  *   </ul>
  *  </li>
  *  <li>replylimit: (boolean) Enforce length limits?</li>
  *  <li>toflowed: (boolean) Do flowed conversion?</li>
  * </ul>
  *
  * @return mixed  Null if bodypart not found, or array with the following
  *                keys:
  *   - charset: (string) The guessed charset to use.
  *   - flowed: (Horde_Text_Flowed) A flowed object, if the text is flowed.
  *             Otherwise, null.
  *   - id: (string) The MIME ID of the bodypart.
  *   - mode: (string) Either 'text' or 'html'.
  *   - text: (string) The body text.
  */
 protected function _getMessageText($contents, array $options = array())
 {
     global $conf, $injector, $notification, $prefs;
     $body_id = null;
     $mode = 'text';
     $options = array_merge(array('imp_msg' => self::COMPOSE), $options);
     if (!empty($options['html']) && self::canHtmlCompose() && ($body_id = $contents->findBody('html')) !== null) {
         $mime_message = $contents->getMIMEMessage();
         switch ($mime_message->getPrimaryType()) {
             case 'multipart':
                 if ($body_id != '1' && $mime_message->getSubType() == 'mixed' && ($id_ob = new Horde_Mime_Id('1')) && !$id_ob->isChild($body_id)) {
                     $body_id = null;
                 } else {
                     $mode = 'html';
                 }
                 break;
             default:
                 if (strval($body_id) != '1') {
                     $body_id = null;
                 } else {
                     $mode = 'html';
                 }
                 break;
         }
     }
     if (is_null($body_id)) {
         $body_id = $contents->findBody();
         if (is_null($body_id)) {
             return null;
         }
     }
     if (!($part = $contents->getMimePart($body_id))) {
         return null;
     }
     $type = $part->getType();
     $part_charset = $part->getCharset();
     $msg = Horde_String::convertCharset($part->getContents(), $part_charset, 'UTF-8');
     /* Enforce reply limits. */
     if (!empty($options['replylimit']) && !empty($conf['compose']['reply_limit'])) {
         $limit = $conf['compose']['reply_limit'];
         if (Horde_String::length($msg) > $limit) {
             $msg = Horde_String::substr($msg, 0, $limit) . "\n" . _("[Truncated Text]");
         }
     }
     if ($mode == 'html') {
         $dom = $injector->getInstance('Horde_Core_Factory_TextFilter')->filter($msg, 'Xss', array('charset' => $this->charset, 'return_dom' => true, 'strip_style_attributes' => false));
         /* If we are replying to a related part, and this part refers
          * to local message parts, we need to move those parts into this
          * message (since the original message may disappear during the
          * compose process). */
         if ($related_part = $contents->findMimeType($body_id, 'multipart/related')) {
             $this->_setMetadata('related_contents', $contents);
             $related_ob = new Horde_Mime_Related($related_part);
             $related_ob->cidReplace($dom, array($this, '_getMessageTextCallback'), $part_charset);
             $this->_setMetadata('related_contents', null);
         }
         /* Convert any Data URLs to attachments. */
         $xpath = new DOMXPath($dom->dom);
         foreach ($xpath->query('//*[@src]') as $val) {
             $data_url = new Horde_Url_Data($val->getAttribute('src'));
             if (strlen($data_url->data)) {
                 $data_part = new Horde_Mime_Part();
                 $data_part->setContents($data_url->data);
                 $data_part->setType($data_url->type);
                 try {
                     $atc = $this->addAttachmentFromPart($data_part);
                     $val->setAttribute('src', $atc->viewUrl());
                     $this->addRelatedAttachment($atc, $val, 'src');
                 } catch (IMP_Compose_Exception $e) {
                     $notification->push($e, 'horde.warning');
                 }
             }
//.........这里部分代码省略.........
开发者ID:raz0rsdge,项目名称:horde,代码行数:101,代码来源:Compose.php

示例11: truncateMiddle

 /**
  * Limits a string to a given maximum length in a smarter way than just
  * using substr().
  *
  * Namely, cut from the MIDDLE instead of from the end so that if we're
  * doing this on (for instance) a bunch of binder names that start off with
  * the same verbose description, and then are different only at the very
  * end, they'll still be different from one another after truncating.
  *
  * <code>
  * $str = 'The quick brown fox jumps over the lazy dog tomorrow morning.';
  * $shortStr = $this->truncateMiddle($str, 40);
  * // $shortStr == 'The quick brown fox... tomorrow morning.'
  * </code>
  *
  * @param string $str         A text to truncate.
  * @param integer $maxLength  The maximum length of the text
  * @param string $joiner      Replacement string for the truncated text.
  *
  * @return string  The truncated text.
  */
 public function truncateMiddle($str, $maxLength = 80, $joiner = '...')
 {
     if (Horde_String::length($str) <= $maxLength) {
         return $str;
     }
     $maxLength = $maxLength - Horde_String::length($joiner);
     if ($maxLength <= 0) {
         return $str;
     }
     $startPieceLength = (int) ceil($maxLength / 2);
     $endPieceLength = (int) floor($maxLength / 2);
     $trimmedString = rtrim(Horde_String::substr($str, 0, $startPieceLength)) . $joiner;
     if ($endPieceLength > 0) {
         $trimmedString .= ltrim(Horde_String::substr($str, -1 * $endPieceLength));
     }
     return $trimmedString;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:38,代码来源:Text.php

示例12: externalUrl

 /**
  * Returns an external link passed through the dereferrer to strip session
  * IDs from the referrer.
  *
  * @param string $url   The external URL to link to.
  * @param boolean $tag  If true, a complete <a> tag is returned, only the
  *                      url otherwise.
  *
  * @return string  The link to the dereferrer script.
  */
 public static function externalUrl($url, $tag = false)
 {
     if (!isset($_GET[session_name()]) || Horde_String::substr($url, 0, 1) == '#' || Horde_String::substr($url, 0, 7) == 'mailto:') {
         $ext = $url;
     } else {
         $ext = self::signQueryString($GLOBALS['registry']->getServiceLink('go', 'horde')->add('url', $url));
     }
     if ($tag) {
         $ext = self::link($ext, $url, '', '_blank');
     }
     return $ext;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:22,代码来源:Horde.php

示例13: getOptionsWidget

 /**
  * Returns the widget necessary to configure this block.
  *
  * @param $app TODO
  * @param $block TODO
  * @param $param_id TODO
  * @param $val TODO
  *
  * @return TODO
  */
 public function getOptionsWidget($app, $block, $param_id, $val = null)
 {
     $widget = '';
     /* getParams() loads $_blocks */
     $this->getParams($app, $block);
     $param = $this->_blocks[$app][$block]['params'][$param_id];
     if (!isset($param['default'])) {
         $param['default'] = '';
     }
     switch ($param['type']) {
         case 'boolean':
         case 'checkbox':
             $checked = !empty($val[$param_id]) ? ' checked="checked"' : '';
             $widget = sprintf('<input type="checkbox" name="params[%s]"%s />', $param_id, $checked);
             break;
         case 'enum':
             $widget = sprintf('<select name="params[%s]">', $param_id);
             foreach ($param['values'] as $key => $name) {
                 if (Horde_String::length($name) > 30) {
                     $name = substr($name, 0, 27) . '...';
                 }
                 $widget .= sprintf("<option value=\"%s\"%s>%s</option>\n", htmlspecialchars($key), isset($val[$param_id]) && $val[$param_id] == $key ? ' selected="selected"' : '', htmlspecialchars($name));
             }
             $widget .= '</select>';
             break;
         case 'multienum':
             $widget = sprintf('<select multiple="multiple" name="params[%s][]">', $param_id);
             foreach ($param['values'] as $key => $name) {
                 if (Horde_String::length($name) > 30) {
                     $name = substr($name, 0, 27) . '...';
                 }
                 $widget .= sprintf("<option value=\"%s\"%s>%s</option>\n", htmlspecialchars($key), isset($val[$param_id]) && in_array($key, $val[$param_id]) ? ' selected="selected"' : '', htmlspecialchars($name));
             }
             $widget .= '</select>';
             break;
         case 'mlenum':
             // Multi-level enum.
             if (is_array($val) && isset($val['__' . $param_id])) {
                 $firstval = $val['__' . $param_id];
             } else {
                 $tmp = array_keys($param['values']);
                 $firstval = current($tmp);
             }
             $blockvalues = $param['values'][$firstval];
             asort($blockvalues);
             $widget = sprintf('<select name="params[__%s]" onchange="document.blockform.action.value=\'save-resume\';document.blockform.submit()">', $param_id) . "\n";
             foreach (array_keys($param['values']) as $key) {
                 $name = Horde_String::length($key) > 30 ? Horde_String::substr($key, 0, 27) . '...' : $key;
                 $widget .= sprintf("<option value=\"%s\"%s>%s</option>\n", htmlspecialchars($key), $key == $firstval ? ' selected="selected"' : '', htmlspecialchars($name));
             }
             $widget .= "</select><br />\n";
             $widget .= sprintf("<select name=\"params[%s]\">\n", $param_id);
             foreach ($blockvalues as $key => $name) {
                 $name = Horde_String::length($name) > 30 ? Horde_String::substr($name, 0, 27) . '...' : $name;
                 $widget .= sprintf("<option value=\"%s\"%s>%s</option>\n", htmlspecialchars($key), $val[$param_id] == $key ? ' selected="selected"' : '', htmlspecialchars($name));
             }
             $widget .= "</select><br />\n";
             break;
         case 'int':
         case 'text':
             $widget = sprintf('<input type="text" name="params[%s]" value="%s" />', $param_id, !isset($val[$param_id]) ? $param['default'] : $val[$param_id]);
             break;
         case 'password':
             $widget = sprintf('<input type="password" name="params[%s]" value="%s" />', $param_id, !isset($val[$param_id]) ? $param['default'] : $val[$param_id]);
             break;
         case 'error':
             $widget = '<span class="form-error">' . $param['default'] . '</span>';
             break;
     }
     return $widget;
 }
开发者ID:horde,项目名称:horde,代码行数:81,代码来源:Collection.php

示例14: getMessageBodyData

 /**
  * Returns the main text body of the message suitable for sending over
  * EAS response.
  *
  * @param array $options  An options array containgin:
  *  - bodyprefs: (array)  Bodypref settings
  *               DEFAULT: none (No bodyprefs used).
  *  - mimesupport: (integer)  Indicates if MIME is supported or not.
  *                  Possible values: 0 - Not supported 1 - Only S/MIME or
  *                  2 - All MIME.
  *                  DEFAULT: 0 (No MIME support)
  *  - protocolversion: (float)  The EAS protocol we are supporting.
  *                     DEFAULT 2.5
  *
  * @return array  An array of one or both of 'plain' and 'html' content.
  *
  * @throws Horde_ActiveSync_Exception, Horde_Exception_NotFound
  */
 public function getMessageBodyData(array $options = array())
 {
     $version = empty($options['protocolversion']) ? Horde_ActiveSync::VERSION_TWOFIVE : $options['protocolversion'];
     // Look for the parts we need. We try to detect and fetch only the parts
     // we need, while ensuring we have something to return. So, e.g., if we
     // don't have BODYPREF_TYPE_HTML, we only request plain text, but if we
     // can't find plain text but we have a html body, fetch that anyway.
     $text_id = $this->_message->findBody('plain');
     $html_id = $this->_message->findBody('html');
     // Deduce which part(s) we need to request.
     $want_html_text = $version >= Horde_ActiveSync::VERSION_TWELVE && (!empty($options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_HTML]) || !empty($options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_MIME]));
     $want_plain_text = $version == Horde_ActiveSync::VERSION_TWOFIVE || empty($options['bodyprefs']) || !empty($options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_PLAIN]) || !empty($options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_RTF]) || !empty($options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_MIME]) || $want_html_text && empty($html_id);
     $want_html_as_plain = false;
     if (!empty($text_id) && $want_plain_text) {
         $text_body_part = $this->_message->getPart($text_id);
         $charset = $text_body_part->getCharset();
     } elseif ($want_plain_text && !empty($html_id) && empty($options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_MIME])) {
         $want_html_text = true;
         $want_html_as_plain = true;
     }
     if (!empty($html_id) && $want_html_text) {
         $html_body_part = $this->_message->getPart($html_id);
         $html_charset = $html_body_part->getCharset();
     }
     // Sanity check the truncation stuff
     if (empty($options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_PLAIN]) && !empty($options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_HTML]) && $want_plain_text && $want_html_text) {
         // We only have HTML truncation data, requested HTML body but only
         // have plaintext.
         $options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_PLAIN] = $options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_HTML];
     }
     $query = new Horde_Imap_Client_Fetch_Query();
     $query_opts = array('decode' => true, 'peek' => true);
     // Get body information
     if ($version >= Horde_ActiveSync::VERSION_TWELVE) {
         if (!empty($html_id)) {
             $query->bodyPartSize($html_id);
             $query->bodyPart($html_id, $query_opts);
         }
         if (!empty($text_id)) {
             $query->bodyPart($text_id, $query_opts);
             $query->bodyPartSize($text_id);
         }
     } else {
         // EAS 2.5 Plaintext body
         $query->bodyPart($text_id, $query_opts);
         $query->bodyPartSize($text_id);
     }
     try {
         $fetch_ret = $this->_imap->fetch($this->_mbox, $query, array('ids' => new Horde_Imap_Client_Ids(array($this->_uid))));
     } catch (Horde_Imap_Client_Exception $e) {
         throw new Horde_ActiveSync_Exception($e);
     }
     if (!($data = $fetch_ret->first())) {
         throw new Horde_Exception_NotFound(sprintf('Could not load message %s from server.', $this->_uid));
     }
     $return = array();
     if (!empty($text_id) && $want_plain_text) {
         $text = $data->getBodyPart($text_id);
         if (!$data->getBodyPartDecode($text_id)) {
             $text_body_part->setContents($text);
             $text = $text_body_part->getContents();
         }
         $text_size = !is_null($data->getBodyPartSize($text_id)) ? $data->getBodyPartSize($text_id) : Horde_String::length($text);
         if (!empty($options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_PLAIN]['truncationsize'])) {
             // EAS >= 12.0 truncation
             $text = Horde_String::substr($text, 0, $options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_PLAIN]['truncationsize'], $charset);
         }
         $truncated = $text_size > Horde_String::length($text);
         if ($version >= Horde_ActiveSync::VERSION_TWELVE && $truncated && !empty($options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_PLAIN]['allornone'])) {
             $text = '';
         }
         $return['plain'] = array('charset' => $charset, 'body' => $text, 'truncated' => $truncated, 'size' => $text_size);
     }
     if (!empty($html_id) && $want_html_text) {
         $html = $data->getBodyPart($html_id);
         if (!$data->getBodyPartDecode($html_id)) {
             $html_body_part->setContents($html);
             $html = $html_body_part->getContents();
         }
         // Size of the original HTML part.
         $html_size = !is_null($data->getBodyPartSize($html_id)) ? $data->getBodyPartSize($html_id) : Horde_String::length($html);
         if (!empty($options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_HTML]['truncationsize'])) {
//.........这里部分代码省略.........
开发者ID:jubinpatel,项目名称:horde,代码行数:101,代码来源:Message.php

示例15:

?>
</a>
 </div>

 <div data-role="content" id="kronolith-minical" class="kronolith-minical">
  <table>
   <thead>
    <tr>
<?php 
for ($i = $GLOBALS['prefs']->getValue('week_start_monday'), $c = $i + 7; $i < $c; $i++) {
    ?>
     <th title="<?php 
    echo Horde_Nls::getLangInfo(constant('DAY_' . ($i % 7 + 1)));
    ?>
"><?php 
    echo Horde_String::substr(Horde_Nls::getLangInfo(constant('DAY_' . ($i % 7 + 1))), 0, 1);
    ?>
</th>
<?php 
}
?>
    </tr>
   </thead>
   <tbody><tr><td></td></tr></tbody>
  </table>
 </div>

 <div id="kronolithDayDetailHeader" data-role="header">
   <h3></h3>
 </div>
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:30,代码来源:month.html.php


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