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


PHP Horde_String::length方法代码示例

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


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

示例1: compareReadmes

 public function compareReadmes($a, $b)
 {
     if ($this->_isHtmlReadme($a)) {
         return self::CHOOSE_A;
     }
     if ($this->_isHtmlReadme($b)) {
         return self::CHOOSE_B;
     }
     $a_len = Horde_String::length($a->getFileName());
     $b_len = Horde_String::length($b->getFileName());
     if ($a_len < $b_len) {
         return self::CHOOSE_A;
     } elseif ($b_len < $a_len) {
         return self::CHOOSE_B;
     } else {
         return strcasecmp($a->getFileName(), $b->getFileName());
     }
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:18,代码来源:Collection.php

示例2: selectGalleries

 /**
  * Return a string containing an <option> listing of the given
  * gallery array.
  *
  * @param array $params  An array of options:
  *   <pre>
  *     (integer)selected  The gallery_id of the gallery that is selected
  *     (integer)perm      The permissions filter to use [Horde_Perms::SHOW]
  *     (mixed)attributes  Restrict the galleries returned to those matching
  *                        the filters. Can be an array of attribute/values
  *                        pairs or a gallery owner username.
  *     (boolean)all_levels
  *     (integer)from      The gallery to start listing at.
  *     (integer)count     The number of galleries to return.
  *     (integer)ignore    An Ansel_Gallery id to ignore when building the tree.
  *   </pre>
  *
  * @return string  The HTML to display the option list.
  */
 public static function selectGalleries($params = array())
 {
     $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->listGalleries($params);
     $params = new Horde_Support_Array($params);
     $tree = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Tree')->create('gallery_tree', 'Select');
     // Remove the ignored gallery, make sure it's also not the selected
     if ($params->ignore) {
         if ($params->selected == $params->ignore) {
             $params->selected = null;
         }
     }
     foreach ($galleries as $gallery) {
         $gallery_id = $gallery->id;
         $gallery_name = $gallery->get('name');
         $label = Horde_String::abbreviate($gallery_name);
         $len = Horde_String::length($gallery_name);
         $treeparams = array();
         $treeparams['selected'] = $gallery_id == $params->selected;
         $parent = $gallery->getParent();
         $parent = empty($parent) ? null : $parent->id;
         $tree->addNode(array('id' => $gallery->id, 'parent' => $parent, 'label' => $label, 'params' => $treeparams));
     }
     return $tree->getTree();
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:43,代码来源:Ansel.php

示例3: _init


//.........这里部分代码省略.........
                 $filtermsg = $n_view->flag_filter = true;
             }
         }
         if (!$search_mbox && $mailbox->access_filters) {
             $filters = array();
             $iterator = IMP_Search_IteratorFilter::create(IMP_Search_IteratorFilter::FILTER);
             foreach ($iterator as $val) {
                 $filters[] = array('l' => $val->label, 'v' => IMP_Mailbox::formTo($val));
             }
             if (!empty($filters)) {
                 $filtermsg = true;
                 $n_view->filters = $filters;
             }
         }
         $n_view->filtermsg = $filtermsg;
         if ($imp_imap->access(IMP_Imap::ACCESS_FOLDERS)) {
             $n_view->move = Horde::widget(array('url' => '#', 'class' => 'moveAction', 'title' => _("Move"), 'nocheck' => true));
             $n_view->copy = Horde::widget(array('url' => '#', 'class' => 'copyAction', 'title' => _("Copy"), 'nocheck' => true));
             $n_view->folder_options = $folder_options;
         }
         $n_view->mailbox_url = $mailbox_url;
         $n_view->mailbox = $mailbox->form_to;
         if ($pageOb['pagecount'] > 1) {
             $n_view->multiple_page = true;
             $n_view->pages_first = $pages_first;
             $n_view->url_first = $url_first;
             $n_view->pages_prev = $pages_prev;
             $n_view->url_prev = $url_prev;
             $n_view->pages_next = $pages_next;
             $n_view->url_next = $url_next;
             $n_view->pages_last = $pages_last;
             $n_view->url_last = $url_last;
             $n_view->page_val = $pageOb['page'];
             $n_view->page_size = Horde_String::length($pageOb['pagecount']);
         }
         $this->output .= $n_view->render('navbar');
         /* Prepare the actions template. */
         $a_view = clone $view;
         if ($mailbox->access_deletemsgs) {
             $del_class = $use_trash && $mailbox->trash ? 'permdeleteAction' : 'deleteAction';
             $a_view->delete = Horde::widget(array('url' => '#', 'class' => $del_class, 'title' => _("_Delete")));
         }
         if ($showdelete['purge'] || $mailbox->vtrash) {
             $a_view->undelete = Horde::widget(array('url' => '#', 'class' => 'undeleteAction', 'title' => _("_Undelete")));
         }
         $mboxactions = array();
         if ($showdelete['purge']) {
             $mailbox_link = $mailbox_imp_url->copy()->add('mpage', $pageOb['page']);
             if (isset($deleted_prompt)) {
                 $mboxactions[] = Horde::widget(array('url' => $mailbox_link->copy()->add(array('actionID' => 'hide_deleted', 'token' => $token)), 'class' => 'hideAction', 'title' => $deleted_prompt));
             }
             $mboxactions[] = Horde::widget(array('url' => $mailbox_link->copy()->add(array('actionID' => 'expunge_mailbox', 'token' => $token)), 'class' => 'purgeAction', 'title' => _("Pur_ge Deleted")));
         }
         if (!$sortpref->sortby_locked && $sortpref->sortby != Horde_Imap_Client::SORT_SEQUENCE) {
             $mboxactions[] = Horde::widget(array('url' => $mailbox_imp_url->copy()->add(array('sortby' => Horde_Imap_Client::SORT_SEQUENCE, 'actionID' => 'change_sort', 'token' => $token)), 'title' => _("Clear Sort")));
         }
         if ($mailbox->templates) {
             $a_view->templateedit = Horde::widget(array('url' => '#', 'class' => 'templateeditAction', 'title' => _("Edit Template")));
             $mboxactions[] = Horde::widget(array('url' => $clink->copy()->add(array('actionID' => 'template_new')), 'title' => _("Create New Template")));
         }
         $a_view->mboxactions = $mboxactions;
         if ($registry->hasMethod('mail/blacklistFrom')) {
             $a_view->blacklist = Horde::widget(array('url' => '#', 'class' => 'blacklistAction', 'title' => _("_Blacklist")));
         }
         if ($registry->hasMethod('mail/whitelistFrom')) {
             $a_view->whitelist = Horde::widget(array('url' => '#', 'class' => 'whitelistAction', 'title' => _("_Whitelist")));
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:67,代码来源:Mailbox.php

示例4: 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

示例5: _buildTweet

 /**
  * Helper method to build a view object for a tweet.
  *
  * @param  stdClass $tweet  The tweet object.
  *
  * @return Horde_View  The view object, populated with tweet data.
  */
 protected function _buildTweet($tweet)
 {
     global $injector, $registry;
     $view = new Horde_View(array('templatePath' => HORDE_TEMPLATES . '/block'));
     $view->addHelper('Tag');
     $view->ajax_uri = $registry->getServiceLink('ajax', $registry->getApp());
     $filter = $injector->getInstance('Horde_Core_Factory_TextFilter');
     $instance = $this->vars->i;
     // Links and media
     $map = $previews = array();
     foreach ($tweet->entities->urls as $link) {
         $replace = '<a target="_blank" href="' . $link->url . '" title="' . $link->expanded_url . '">' . htmlspecialchars($link->display_url) . '</a>';
         $map[$link->indices[0]] = array($link->indices[1], $replace);
     }
     if (!empty($tweet->entities->media)) {
         foreach ($tweet->entities->media as $picture) {
             $replace = '<a target="_blank" href="' . $picture->url . '" title="' . $picture->expanded_url . '">' . htmlentities($picture->display_url, ENT_COMPAT, 'UTF-8') . '</a>';
             $map[$picture->indices[0]] = array($picture->indices[1], $replace);
             $previews[] = ' <a href="#" onclick="return Horde[\'twitter' . $instance . '\'].showPreview(\'' . $picture->media_url . ':small\');"><img src="' . Horde_Themes::img('mime/image.png') . '" /></a>';
         }
     }
     if (!empty($tweet->entities->user_mentions)) {
         foreach ($tweet->entities->user_mentions as $user) {
             $replace = ' <a target="_blank" title="' . $user->name . '" href="http://twitter.com/' . $user->screen_name . '">@' . htmlentities($user->screen_name, ENT_COMPAT, 'UTF-8') . '</a>';
             $map[$user->indices[0]] = array($user->indices[1], $replace);
         }
     }
     if (!empty($tweet->entities->hashtags)) {
         foreach ($tweet->entities->hashtags as $hashtag) {
             $replace = ' <a target="_blank" href="http://twitter.com/search?q=#' . urlencode($hashtag->text) . '">#' . htmlentities($hashtag->text, ENT_COMPAT, 'UTF-8') . '</a>';
             $map[$hashtag->indices[0]] = array($hashtag->indices[1], $replace);
         }
     }
     $body = '';
     $pos = 0;
     while ($pos <= Horde_String::length($tweet->text) - 1) {
         if (!empty($map[$pos])) {
             $entity = $map[$pos];
             $body .= $entity[1];
             $pos = $entity[0];
         } else {
             $body .= Horde_String::substr($tweet->text, $pos, 1);
             ++$pos;
         }
     }
     foreach ($previews as $preview) {
         $body .= $preview;
     }
     $view->body = $body;
     /* If this is a retweet, use the original author's profile info */
     if (!empty($tweet->retweeted_status)) {
         $tweetObj = $tweet->retweeted_status;
     } else {
         $tweetObj = $tweet;
     }
     /* These are all referencing the *original* tweet */
     $view->profileLink = Horde::externalUrl('http://twitter.com/' . htmlspecialchars($tweetObj->user->screen_name), true);
     $view->profileImg = $GLOBALS['browser']->usingSSLConnection() ? $tweetObj->user->profile_image_url_https : $tweetObj->user->profile_image_url;
     $view->authorName = '@' . htmlspecialchars($tweetObj->user->screen_name);
     $view->authorFullname = htmlspecialchars($tweetObj->user->name);
     $view->createdAt = $tweetObj->created_at;
     $view->clientText = $filter->filter($tweet->source, 'xss');
     $view->tweet = $tweet;
     $view->instanceid = $instance;
     return $view;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:73,代码来源:TwitterHandler.php

示例6: 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

示例7: nextStep

 /**
  * Takes all necessary actions for the given import step, parameters and
  * form values and returns the next necessary step.
  *
  * @param integer $action  The current step. One of the IMPORT_* constants.
  * @param array $param     An associative array containing needed
  *                         parameters for the current step. Keys for this
  *                         driver:
  *   - check_charset: (boolean) Do some checks to see if the correct
  *                    charset has been provided. Throws charset exception
  *                    on error.
  *   - import_mapping: TODO
  *
  * @return mixed  Either the next step as an integer constant or imported
  *                data set after the final step.
  * @throws Horde_Data_Exception
  * @throws Horde_Data_Exception_Charset
  */
 public function nextStep($action, array $param = array())
 {
     switch ($action) {
         case Horde_Data::IMPORT_FILE:
             parent::nextStep($action, $param);
             /* Move uploaded file so that we can read it again in the next
                step after the user gave some format details. */
             $file_name = $_FILES['import_file']['tmp_name'];
             if (($file_data = file_get_contents($file_name)) === false) {
                 throw new Horde_Data_Exception(Horde_Data_Translation::t("The uploaded file could not be saved."));
             }
             /* Do charset checking now, if requested. */
             if (isset($param['check_charset'])) {
                 $charset = isset($this->_vars->charset) ? Horde_String::lower($this->_vars->charset) : 'utf-8';
                 switch ($charset) {
                     case 'utf-8':
                         $error = !Horde_String::validUtf8($file_data);
                         break;
                     default:
                         $error = $file_data != Horde_String::convertCharset(Horde_String::convertCharset($file_data, $charset, 'UTF-8'), 'UTF-8', $charset);
                         break;
                 }
                 if ($error) {
                     $e = new Horde_Data_Exception_Charset(Horde_Data_Translation::t("Incorrect charset given for the data."));
                     $e->badCharset = $charset;
                     throw $e;
                 }
             }
             $this->storage->set('charset', $this->_vars->charset);
             $this->storage->set('file_data', $file_data);
             /* Read the file's first two lines to show them to the user. */
             $first_lines = '';
             if ($fp = @fopen($file_name, 'r')) {
                 for ($line_no = 1, $line = fgets($fp); $line_no <= 3 && $line; $line_no++, $line = fgets($fp)) {
                     $line = Horde_String::convertCharset($line, $this->_vars->charset, 'UTF-8');
                     $first_lines .= Horde_String::truncate($line);
                     if (Horde_String::length($line) > 100) {
                         $first_lines .= "\n";
                     }
                 }
             }
             $this->storage->set('first_lines', $first_lines);
             /* Import the first line to guess the number of fields. */
             if ($first_lines) {
                 rewind($fp);
                 $line = self::getCsv($fp);
                 if ($line) {
                     $this->storage->set('fields', count($line));
                 }
             }
             return Horde_Data::IMPORT_CSV;
         case Horde_Data::IMPORT_CSV:
             $this->storage->set('header', $this->_vars->header);
             $import_mapping = array();
             if (isset($param['import_mapping'])) {
                 $import_mapping = $param['import_mapping'];
             }
             $file_name = Horde_Util::getTempFile('import');
             file_put_contents($file_name, $this->storage->get('file_data'));
             $this->storage->set('data', $this->importFile($file_name, $this->_vars->header, $this->_vars->sep, $this->_vars->quote, $this->_vars->fields, $import_mapping, $this->storage->get('charset'), $this->storage->get('crlf')));
             $this->storage->set('map');
             return Horde_Data::IMPORT_MAPPED;
         default:
             return parent::nextStep($action, $param);
     }
 }
开发者ID:horde,项目名称:horde,代码行数:84,代码来源:Csv.php

示例8: nextStep

 /**
  * Takes all necessary actions for the given import step, parameters and
  * form values and returns the next necessary step.
  *
  * @param integer $action  The current step. One of the IMPORT_* constants.
  * @param array $param     An associative array containing needed
  *                         parameters for the current step.
  *
  * @return mixed  Either the next step as an integer constant or imported
  *                data set after the final step.
  * @throws Horde_Data_Exception
  */
 public function nextStep($action, array $param = array())
 {
     switch ($action) {
         case Horde_Data::IMPORT_FILE:
             parent::nextStep($action, $param);
             $format = $this->storage->get('format');
             if (in_array($format, array('mulberry', 'pine'))) {
                 $filedata = $this->importFile($_FILES['import_file']['tmp_name']);
                 switch ($format) {
                     case 'mulberry':
                         $appKeys = array('alias', 'name', 'email', 'company', 'workAddress', 'workPhone', 'homePhone', 'fax', 'notes');
                         $dataKeys = array(0, 1, 2, 3, 4, 5, 6, 7, 9);
                         break;
                     case 'pine':
                         $appKeys = array('alias', 'name', 'email', 'notes');
                         $dataKeys = array(0, 1, 2, 4);
                         break;
                 }
                 foreach ($appKeys as $key => $app) {
                     $map[$dataKeys[$key]] = $app;
                 }
                 $data = array();
                 foreach ($filedata as $row) {
                     $hash = array();
                     switch ($format) {
                         case 'mulberry':
                             if (preg_match("/^Grp:/", $row[0]) || empty($row[1])) {
                                 continue;
                             }
                             $row[1] = preg_replace('/^([^,"]+),\\s*(.*)$/', '$2 $1', $row[1]);
                             foreach ($dataKeys as $key) {
                                 if (array_key_exists($key, $row)) {
                                     $hash[$key] = stripslashes(preg_replace('/\\\\r/', "\n", $row[$key]));
                                 }
                             }
                             break;
                         case 'pine':
                             if (count($row) < 3 || preg_match("/^#DELETED/", $row[0]) || preg_match("/[()]/", $row[2])) {
                                 continue;
                             }
                             $row[1] = preg_replace('/^([^,"]+),\\s*(.*)$/', '$2 $1', $row[1]);
                             /* Address can be a full RFC822 address */
                             $addr_ob = new Horde_Mail_Rfc822_Address($row[2]);
                             if (!$addr_ob->valid) {
                                 continue;
                             }
                             $row[2] = $addr_ob->bare_address;
                             if (empty($row[1]) && !is_null($addr_ob->personal)) {
                                 $row[1] = $addr_ob->personal;
                             }
                             foreach ($dataKeys as $key) {
                                 if (array_key_exists($key, $row)) {
                                     $hash[$key] = $row[$key];
                                 }
                             }
                             break;
                     }
                     $data[] = $hash;
                 }
                 $this->storage->set('data', $data);
                 $this->storage->set('map', $map);
                 return $this->nextStep(Horde_Data::IMPORT_DATA, $param);
             }
             /* Store uploaded file data so that we can read it again in the
              * next step after the user gives some format details. */
             try {
                 $this->_browser->wasFileUploaded('import_file', Horde_Data_Translation::t("TSV file"));
             } catch (Horde_Browser_Exception $e) {
                 throw new Horde_Data_Exception($e);
             }
             $file_name = $_FILES['import_file']['tmp_name'];
             if (($file_data = file_get_contents($file_name)) === false) {
                 throw new Horde_Data_Exception(Horde_Data_Translation::t("The uploaded file could not be saved."));
             }
             $this->storage->set('file_data', $file_data);
             /* Read the file's first two lines to show them to the user. */
             $first_lines = '';
             if ($fp = @fopen($file_name, 'r')) {
                 $line_no = 1;
                 while ($line_no < 3 && ($line = fgets($fp))) {
                     $newline = Horde_String::length($line) > 100 ? "\n" : '';
                     $first_lines .= substr($line, 0, 100) . $newline;
                     ++$line_no;
                 }
             }
             $this->storage->set('first_lines', $first_lines);
             return Horde_Data::IMPORT_TSV;
         case Horde_Data::IMPORT_TSV:
//.........这里部分代码省略.........
开发者ID:jubinpatel,项目名称:horde,代码行数:101,代码来源:Tsv.php

示例9: formatName

 /**
  * Formats the name according to the user's preference.
  *
  * If the format is 'none', the full name with all parts is returned. If
  * the format is 'last_first' or 'first_last', only the first name and
  * last name are returned.
  *
  * @param Turba_Object $ob     The object to get a name from.
  * @param string $name_format  The formatting. One of 'none', 'last_first'
  *                             or 'first_last'. Defaults to the user
  *                             preference.
  *
  * @return string  The formatted name, either "Firstname Lastname"
  *                 or "Lastname, Firstname" depending on $name_format or
  *                 the user's preference.
  */
 public static function formatName(Turba_Object $ob, $name_format = null)
 {
     if (!$name_format) {
         if (!isset(self::$_cache['defaultFormat'])) {
             self::$_cache['defaultFormat'] = $GLOBALS['prefs']->getValue('name_format');
         }
         $name_format = self::$_cache['defaultFormat'];
     }
     /* If no formatting, return original name. */
     if (!in_array($name_format, array('first_last', 'last_first'))) {
         return $ob->getValue('name');
     }
     /* See if we have the name fields split out explicitly. */
     if ($ob->hasValue('firstname') && $ob->hasValue('lastname')) {
         return $name_format == 'last_first' ? $ob->getValue('lastname') . ', ' . $ob->getValue('firstname') : $ob->getValue('firstname') . ' ' . $ob->getValue('lastname');
     }
     /* One field, we'll have to guess. */
     $name = $ob->getValue('name');
     $lastname = self::guessLastname($name);
     if ($name_format == 'last_first' && !is_int(strpos($name, ',')) && Horde_String::length($name) > Horde_String::length($lastname)) {
         return $lastname . ', ' . preg_replace('/\\s+' . preg_quote($lastname, '/') . '/', '', $name);
     }
     if ($name_format == 'first_last' && is_int(strpos($name, ',')) && Horde_String::length($name) > Horde_String::length($lastname)) {
         return preg_replace('/' . preg_quote($lastname, '/') . ',\\s*/', '', $name) . ' ' . $lastname;
     }
     return $name;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:43,代码来源:Turba.php

示例10: _content

 /**
  * Outputs data
  *
  * @param mixed $content  A string or stream resource to write to the output
  */
 private function _content($content)
 {
     if (!is_resource($content)) {
         if ($this->_logLevel == self::LOG_PROTOCOL && ($l = Horde_String::length($content)) > self::LOG_MAXCONTENT) {
             $this->_logContent(sprintf('[%d bytes of content]', $l));
         } else {
             $this->_logContent($content);
         }
     } else {
         $this->_logContent('[STREAM]');
     }
     $this->_outByte(self::STR_I);
     $this->_outTermStr($content);
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:19,代码来源:Encoder.php

示例11: array

        Horde::url('list.php', true)->redirect();
    default:
        Horde::url('list.php', true)->redirect();
}
$view = $injector->createInstance('Horde_View');
$view->formInput = Horde_Util::formInput();
$view->id = $memo_id;
$view->listid = $memolist_id;
$view->modify = $actionID == 'modify_memo';
$view->passphrase = $show_passphrase;
$view->title = $title;
$view->url = Horde::url('memo.php');
if (!$view->modify || !$view->passphrase) {
    $injector->getInstance('Horde_Core_Factory_Imple')->create('Mnemo_Ajax_Imple_TagAutoCompleter', array('id' => 'memo_tags'));
    $view->body = $memo_body;
    $view->count = sprintf(_("%s characters"), '<span id="mnemo-count">' . Horde_String::length(str_replace(array("\r", "\n"), '', $memo_body)) . '</span>');
    $view->encrypted = $memo_encrypted;
    $view->encryption = $storage->encryptionSupported();
    try {
        $view->help = Horde::callHook('description_help', array(), 'mnemo', '');
    } catch (Horde_Exception_HookNotSet $e) {
    }
    $view->loadingImg = Horde::img('loading.gif', _("Loading..."));
    $view->notepads = array();
    if (!$prefs->isLocked('default_notepad')) {
        foreach (Mnemo::listNotepads(false, Horde_Perms::SHOW) as $id => $notepad) {
            if (!$notepad->hasPermission($user, Horde_Perms::EDIT)) {
                continue;
            }
            $view->notepads[] = array('id' => $id, 'selected' => $id == $memolist_id, 'label' => Mnemo::getLabel($notepad));
        }
开发者ID:horde,项目名称:horde,代码行数:31,代码来源:memo.php

示例12: 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

示例13: _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

示例14: 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

示例15: generatePreview

 /**
  * Generate the preview text.
  *
  * @return array  Array with the following keys:
  *   - cut: (boolean) Was the preview text cut?
  *   - text: (string) The preview text.
  */
 public function generatePreview()
 {
     // For preview generation, don't go through overhead of scanning for
     // embedded parts. Necessary evil, or else very large parts (e.g
     // 5 MB+ text parts) will take ages to scan.
     $oldbuild = $this->_build;
     $this->_build = true;
     $mimeid = $this->findBody();
     if (is_null($mimeid)) {
         $this->_build = $oldbuild;
         return array('cut' => false, 'text' => '');
     }
     $maxlen = empty($GLOBALS['conf']['msgcache']['preview_size']) ? $GLOBALS['prefs']->getValue('preview_maxlen') : $GLOBALS['conf']['msgcache']['preview_size'];
     // Retrieve 3x the size of $maxlen of bodytext data. This should
     // account for any content-encoding & HTML tags.
     $pmime = $this->getMIMEPart($mimeid, array('length' => $maxlen * 3));
     $ptext = Horde_String::convertCharset($pmime->getContents(), $pmime->getCharset(), 'UTF-8');
     if ($pmime->getType() == 'text/html') {
         $ptext = $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter($ptext, 'Html2text');
     }
     $this->_build = $oldbuild;
     if (Horde_String::length($ptext) > $maxlen) {
         return array('cut' => true, 'text' => Horde_String::truncate($ptext, $maxlen));
     }
     return array('cut' => false, 'text' => $ptext);
 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:33,代码来源:Contents.php


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