本文整理汇总了PHP中Horde_String::truncate方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_String::truncate方法的具体用法?PHP Horde_String::truncate怎么用?PHP Horde_String::truncate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_String
的用法示例。
在下文中一共展示了Horde_String::truncate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _renderInfo
/**
* Return the rendered information about the Horde_Mime_Part object.
*
* @return array See parent::render().
* @throws Horde_Exception
*/
protected function _renderInfo()
{
$charset = $this->getConfigParam('charset');
$contents = $this->_mimepart->getContents();
if (!$this->getConfigParam('zip')) {
$this->setConfigParam('zip', Horde_Compress::factory('Zip'));
}
$zipInfo = $this->getConfigParam('zip')->decompress($contents, array('action' => Horde_Compress_Zip::ZIP_LIST));
$fileCount = count($zipInfo);
$name = $this->_mimepart->getName(true);
if (empty($name)) {
$name = Horde_Mime_Viewer_Translation::t("unnamed");
}
$monospace = $this->getConfigParam('monospace');
$text = '<table><tr><td align="left"><span ' . ($monospace ? 'class="' . $monospace . '">' : 'style="font-family:monospace">') . $this->_textFilter(Horde_Mime_Viewer_Translation::t("Archive Name") . ': ' . $name . "\n" . Horde_Mime_Viewer_Translation::t("Archive File Size") . ': ' . strlen($contents) . " bytes\n" . sprintf(Horde_Mime_Viewer_Translation::ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount) . "\n\n" . str_repeat(' ', 15) . Horde_String::pad(Horde_Mime_Viewer_Translation::t("Attributes"), 10, ' ', STR_PAD_LEFT) . Horde_String::pad(Horde_Mime_Viewer_Translation::t("Size"), 10, ' ', STR_PAD_LEFT) . Horde_String::pad(Horde_Mime_Viewer_Translation::t("Modified Date"), 19, ' ', STR_PAD_LEFT) . Horde_String::pad(Horde_Mime_Viewer_Translation::t("Method"), 10, ' ', STR_PAD_LEFT) . Horde_String::pad(Horde_Mime_Viewer_Translation::t("Ratio"), 10, ' ', STR_PAD_LEFT) . "\n", 'Space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . str_repeat('-', 74) . "\n";
foreach ($zipInfo as $key => $val) {
$ratio = empty($val['size']) ? 0 : 100 * ($val['csize'] / $val['size']);
$val['name'] = Horde_String::pad(Horde_String::truncate($val['name'], 15), 15, ' ', STR_PAD_RIGHT);
$val['attr'] = Horde_String::pad($val['attr'], 10, ' ', STR_PAD_LEFT);
$val['size'] = Horde_String::pad($val['size'], 10, ' ', STR_PAD_LEFT);
$val['date'] = Horde_String::pad(strftime("%d-%b-%Y %H:%M", $val['date']), 19, ' ', STR_PAD_LEFT);
$val['method'] = Horde_String::pad($val['method'], 10, ' ', STR_PAD_LEFT);
$val['ratio'] = Horde_String::pad(sprintf("%1.1f%%", $ratio), 10, ' ', STR_PAD_LEFT);
reset($val);
while (list($k, $v) = each($val)) {
$val[$k] = $this->_textFilter($v, 'Space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true));
}
if (!is_null($this->_callback)) {
$val = call_user_func($this->_callback, $key, $val);
}
$text .= $val['name'] . $val['attr'] . $val['size'] . $val['date'] . $val['method'] . $val['ratio'] . "\n";
}
return $this->_renderReturn(nl2br($text . str_repeat('-', 74) . "\n</span></td></tr></table>"), 'text/html; charset=' . $charset);
}
示例2: display
/**
*/
public function display(Horde_Core_Prefs_Ui $ui)
{
global $injector, $page_output, $prefs;
$page_output->addScriptFile('hordecore.js', 'horde');
$page_output->addScriptFile('prefs/searches.js');
$p_css = new Horde_Themes_Element('prefs.css');
$page_output->addStylesheet($p_css->fs, $p_css->uri);
$imp_search = $injector->getInstance('IMP_Search');
$fout = $vout = array();
$view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/prefs'));
$view->addHelper('FormTag');
$view->addHelper('Tag');
$view->addHelper('Text');
$vfolder_locked = $prefs->isLocked('vfolder');
$iterator = IMP_Search_IteratorFilter::create(IMP_Search_IteratorFilter::DISABLED | IMP_Search_IteratorFilter::VFOLDER);
foreach ($iterator as $val) {
if (!$val->prefDisplay) {
continue;
}
$editable = !$vfolder_locked && $imp_search->isVFolder($val, true);
$m_url = $val->enabled ? $val->mbox_ob->url('mailbox')->link() : null;
$vout[] = array('description' => Horde_String::truncate($val->querytext, 200), 'edit' => $editable ? $imp_search->editUrl($val) : null, 'enabled' => $val->enabled, 'enabled_locked' => $vfolder_locked, 'key' => $val->id, 'label' => $val->label, 'm_url' => $m_url);
}
$view->vfolders = $vout;
$filter_locked = $prefs->isLocked('filter');
$iterator = IMP_Search_IteratorFilter::create(IMP_Search_IteratorFilter::DISABLED | IMP_Search_IteratorFilter::FILTER);
foreach ($iterator as $val) {
if (!$val->prefDisplay) {
continue;
}
$editable = !$filter_locked && $imp_search->isFilter($val, true);
$fout[] = array('description' => Horde_String::truncate($val->querytext, 200), 'edit' => $editable ? $imp_search->editUrl($val) : null, 'enabled' => $val->enabled, 'enabled_locked' => $filter_locked, 'key' => $val->id, 'label' => $val->label);
}
$view->filters = $fout;
if (empty($fout) && empty($vout)) {
$view->nosearches = true;
} else {
$GLOBALS['page_output']->addInlineJsVars(array('ImpSearchesPrefs.confirm_delete_filter' => _("Are you sure you want to delete this filter?"), 'ImpSearchesPrefs.confirm_delete_vfolder' => _("Are you sure you want to delete this virtual folder?")));
}
return $view->render('searches');
}
示例3: _init
//.........这里部分代码省略.........
if (empty($lastMbox) || $ob['mailbox'] != $lastMbox) {
if (!empty($lastMbox)) {
$this->_outputSummaries($msgs, $summary_view);
$msgs = array();
}
$mbox = IMP_Mailbox::get($ob['mailbox']);
$search_view->mbox_link = Horde::link($mbox->url($mailbox_url), sprintf(_("View messages in %s"), $mbox->display), 'smallheader') . $mbox->display_html . '</a>';
$this->output .= $search_view->render('searchmbox');
$mh_view->show_checkbox = !$mh_count++;
$this->output .= $mh_view->render('message_headers');
}
}
$lastMbox = $ob['mailbox'];
/* Initialize the data fields. */
$msg = array('bg' => '', 'buid' => $imp_mailbox->getBuid($ob['mailbox'], $ob['uid']), 'class' => '', 'date' => $imp_ui->getDate($ob['envelope']->date), 'preview' => '', 'status' => '', 'size' => IMP::sizeFormat($ob['size']));
/* Generate the target link. */
if ($mailbox->drafts || $mailbox->templates) {
$clink_copy = clone $clink_ob;
$clink_copy->args['buid'] = $msg['buid'];
$clink_copy->args['mailbox'] = $mailbox;
$target = $clink_copy->link()->add(array('actionID' => $mailbox->drafts ? 'draft' : 'template'));
} else {
$target = $mailbox->url('message', $msg['buid']);
}
/* Get all the flag information. */
$flag_parse = $imp_flags->parse(array('flags' => $ob['flags'], 'headers' => $ob['headers'], 'runhook' => $ob, 'personal' => $ob['envelope']->to));
$css_class = $subject_flags = array();
foreach ($flag_parse as $val) {
if ($val instanceof IMP_Flag_User) {
$subject_flags[] = $val;
} else {
if (!$val->bgdefault) {
$msg['bg'] = $val->bgcolor;
}
$css_class[] = $val->css;
$msg['status'] .= $val->span;
}
}
$msg['class'] = implode(' ', $css_class);
/* Show message preview? */
if ($show_preview && isset($ob['preview'])) {
if (empty($ob['preview'])) {
$ptext = '[[' . _("No Preview Text") . ']]';
} else {
$ptext = empty($strip_preview) ? str_replace("\r", '', $ob['preview']) : preg_replace(array('/\\n/', '/(\\s)+/'), array(' ', '$1'), str_replace("\r", "\n", $ob['preview']));
if (!$preview_tooltip) {
$ptext = $injector->getInstance('Horde_Core_Factory_TextFilter')->filter($ptext, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::NOHTML));
}
$maxlen = $prefs->getValue('preview_maxlen');
if (Horde_String::length($ptext) > $maxlen) {
$ptext = Horde_String::truncate($ptext, $maxlen);
} elseif (empty($ob['previewcut'])) {
$ptext .= '[[' . _("END") . ']]';
}
}
$msg['preview'] = $ptext;
}
/* Format the From: Header. */
$getfrom = $imp_ui->getFrom($ob['envelope']);
$msg['from'] = htmlspecialchars($getfrom['from'], ENT_QUOTES, 'UTF-8');
switch ($fromlinkstyle) {
case 0:
$from_tmp = array();
foreach ($getfrom['from_list']->base_addresses as $from_ob) {
$from_tmp[] = call_user_func_array(array('Horde', $preview_tooltip ? 'linkTooltip' : 'link'), array($clink->copy()->add(array('actionID' => 'mailto_link', 'to' => strval($from_ob))), sprintf(_("New Message to %s"), $from_ob->label))) . htmlspecialchars($from_ob->label, ENT_QUOTES, 'UTF-8') . '</a>';
}
if (!empty($from_tmp)) {
$msg['from'] = implode(', ', $from_tmp);
}
break;
default:
$from_uri = $mailbox->url('message', $msg['buid']);
$msg['from'] = Horde::link($from_uri) . $msg['from'] . '</a>';
break;
}
/* Format the Subject: Header. */
$msg['subject'] = $imp_ui->getSubject($ob['envelope']->subject, true);
$msg['subject'] = $preview_tooltip ? substr(Horde::linkTooltip($target, $msg['preview'], '', '', '', $msg['preview']), 0, -1) . ' class="mboxSubject">' . $msg['subject'] . '</a>' : substr(Horde::link($target, $imp_ui->getSubject($ob['envelope']->subject)), 0, -1) . ' class="mboxSubject">' . $msg['subject'] . '</a>' . (!empty($msg['preview']) ? '<br /><small>' . $msg['preview'] . '</small>' : '');
/* Add subject flags. */
foreach ($subject_flags as $val) {
$flag_label = Horde_String::truncate($val->label, 12);
$msg['subject'] = '<span class="' . $val->css . '" style="' . ($val->bgdefault ? '' : 'background:' . htmlspecialchars($val->bgcolor) . ';') . 'color:' . htmlspecialchars($val->fgcolor) . '" title="' . htmlspecialchars($val->label) . '">' . htmlspecialchars($flag_label) . '</span>' . $msg['subject'];
}
/* Set up threading tree now. */
if ($thread_sort) {
$t_ob = $imp_mailbox->getThreadOb($ob['idx']);
$msg['subject'] = ($sortpref->sortdir ? $t_ob->reverse_img : $t_ob->img) . ' ' . $msg['subject'];
}
$msgs[$msg['buid']] = $msg;
}
$this->_outputSummaries($msgs, $summary_view);
$this->output .= '</form>';
/* If there are 20 messages or less, don't show the actions/navbar
* again. */
if ($pageOb['end'] - $pageOb['begin'] >= 20) {
$this->output .= $a_view->render('actions');
$n_view->id = 2;
$this->output .= $n_view->render('navbar');
}
}
示例4: _init
/**
* URL Parameters:
* a: (string) Action ID.
* allto: (boolean) View all To addresses?
* buid: (string) Browser UID.
* t: (string) Token.
*/
protected function _init()
{
global $injector, $notification, $page_output, $prefs, $session;
$imp_mailbox = $this->indices->mailbox->list_ob;
$imp_mailbox->setIndex($this->indices);
$mailbox_url = IMP_Minimal_Mailbox::url(array('mailbox' => $this->indices->mailbox));
/* Make sure we have a valid index. */
if (!$imp_mailbox->isValidIndex()) {
$mailbox_url->add('a', 'm')->redirect();
}
$imp_ui = $injector->getInstance('IMP_Message_Ui');
/* Run through action handlers */
$msg_delete = false;
switch ($this->vars->a) {
// 'd' = delete message
case 'd':
$old_index = $imp_mailbox->getIndex();
try {
$session->checkToken($this->vars->t);
$msg_delete = (bool) $injector->getInstance('IMP_Message')->delete($this->indices, array('mailboxob' => $imp_mailbox));
} catch (Horde_Exception $e) {
$notification->push($e);
}
break;
// 'u' = undelete message
// 'u' = undelete message
case 'u':
$old_index = $imp_mailbox->getIndex();
$injector->getInstance('IMP_Message')->undelete($this->indices);
break;
// 'rs' = report spam
// 'ri' = report innocent
// 'rs' = report spam
// 'ri' = report innocent
case 'rs':
case 'ri':
$old_index = $imp_mailbox->getIndex();
$msg_delete = $injector->getInstance('IMP_Factory_Spam')->create($this->vars->a == 'rs' ? IMP_Spam::SPAM : IMP_Spam::INNOCENT)->report($this->indices, array('mailboxob' => $imp_mailbox)) === 1;
break;
}
if ($msg_delete && $imp_ui->moveAfterAction($this->indices->mailbox)) {
$imp_mailbox->setIndex(1);
}
/* We may have done processing that has taken us past the end of the
* message array, so we will return to the mailbox. */
if (!$imp_mailbox->isValidIndex() || $msg_delete && $prefs->getValue('mailbox_return')) {
$mailbox_url->add('s', $old_index)->redirect();
}
/* Now that we are done processing, get the index and array index of
* the current message. */
$msg_index = $imp_mailbox[$imp_mailbox->getIndex()];
$mailbox = $msg_index['m'];
$uid = $msg_index['u'];
$buid = $imp_mailbox->getBuid($mailbox, $uid);
/* Get envelope/flag/header information. */
try {
$imp_imap = $mailbox->imp_imap;
/* Need to fetch flags before HEADERTEXT, because SEEN flag might
* be set before we can grab it. */
$query = new Horde_Imap_Client_Fetch_Query();
$query->flags();
$flags_ret = $imp_imap->fetch($mailbox, $query, array('ids' => $imp_imap->getIdsOb($uid)));
$query = new Horde_Imap_Client_Fetch_Query();
$query->envelope();
$fetch_ret = $imp_imap->fetch($mailbox, $query, array('ids' => $imp_imap->getIdsOb($uid)));
} catch (IMP_Imap_Exception $e) {
$mailbox_url->add('a', 'm')->redirect();
}
$envelope = $fetch_ret->first()->getEnvelope();
$flags = $flags_ret->first()->getFlags();
/* Parse the message. */
try {
$imp_contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($imp_mailbox));
$mime_headers = $imp_contents->getHeaderAndMarkAsSeen();
} catch (IMP_Exception $e) {
$mailbox_url->add('a', 'm')->redirect();
}
/* Get the starting index for the current message and the message
* count. */
$msgindex = $imp_mailbox->getIndex();
$msgcount = count($imp_mailbox);
/* Generate the mailbox link. */
$mailbox_link = $mailbox_url->add('s', $msgindex);
$self_link = self::url(array('buid' => $buid, 'mailbox' => $this->indices->mailbox));
/* Create the Identity object. */
$user_identity = $injector->getInstance('IMP_Identity');
/* Develop the list of headers to display. */
$basic_headers = $imp_ui->basicHeaders();
$display_headers = $msgAddresses = array();
if ($subject = $mime_headers->getValue('subject')) {
/* Filter the subject text, if requested. */
$subject = Horde_String::truncate(IMP::filterText($subject), 50);
} else {
//.........这里部分代码省略.........
示例5: _parsevEvent
/**
* Parses a vEvent into the message properties.
*
* @param Horde_Icalendar_Vevent $vevent The vEvent to parse.
* @param string $method The method (e.g., 'REQUEST').
*
* @throws Horde_ActiveSync_Exception
*/
protected function _parsevEvent($vevent, $method = 'REQUEST')
{
if ($method == 'REQUEST') {
$this->responserequested = '1';
} else {
$this->responserequested = '0';
}
try {
$organizer = parse_url($vevent->getAttribute('ORGANIZER'));
$this->organizer = $organizer['path'];
} catch (Horde_Icalendar_Exception $e) {
}
try {
$this->globalobjid = Horde_Mapi::createGoid($vevent->getAttribute('UID'));
$this->starttime = new Horde_Date($vevent->getAttribute('DTSTART'));
$this->endtime = new Horde_Date($vevent->getAttribute('DTEND'));
} catch (Horde_Exception $e) {
throw new Horde_ActiveSync_Exception($e);
}
try {
$this->dtstamp = new Horde_Date($vevent->getAttribute('DTSTAMP'));
} catch (Horde_Exception $e) {
}
try {
$this->location = Horde_String::truncate($vevent->getAttribute('LOCATION'), 255);
} catch (Horde_Icalendar_Exception $e) {
}
try {
$class = $vevent->getAttribute('CLASS');
if (!is_array($class)) {
$this->sensitivity = $class == 'PRIVATE' ? Horde_ActiveSync_Message_Appointment::SENSITIVITY_PRIVATE : ($class == 'CONFIDENTIAL' ? Horde_ActiveSync_Message_Appointment::SENSITIVITY_CONFIDENTIAL : ($class == 'PERSONAL' ? Horde_ActiveSync_Message_Appointment::SENSITIVITY_PERSONAL : Horde_ActiveSync_Message_Appointment::SENSITIVITY_NORMAL));
}
} catch (Horde_Icalendar_Exception $e) {
}
try {
$status = $vevent->getAttribute('STATUS');
if (!is_array($status)) {
$status = Horde_String::upper($status);
$this->busystatus = $status == 'TENTATIVE' ? Horde_ActiveSync_Message_Appointment::BUSYSTATUS_TENTATIVE : ($status == 'CONFIRMED' ? Horde_ActiveSync_Message_Appointment::BUSYSTATUS_BUSY : Horde_ActiveSync_Message_Appointment::BUSYSTATUS_FREE);
}
} catch (Horde_Icalendar_Exception $e) {
}
// vCalendar 1.0 alarms
try {
$alarm = $vevent->getAttribute('AALARM');
if (!is_array($alarm) && intval($alarm)) {
$this->reminder = intval($this->starttime->timestamp() - $alarm);
}
} catch (Horde_Icalendar_Exception $e) {
}
// vCalendar 2.0 alarms
foreach ($vevent->getComponents() as $alarm) {
if (!$alarm instanceof Horde_Icalendar_Valarm) {
continue;
}
try {
$trigger = $alarm->getAttribute('TRIGGER');
$triggerParams = $alarm->getAttribute('TRIGGER', true);
} catch (Horde_Icalendar_Exception $e) {
continue;
}
if (isset($triggerParams['VALUE']) && $triggerParams['VALUE'] == 'DATE-TIME') {
if (isset($triggerParams['RELATED']) && $triggerParams['RELATED'] == 'END') {
$this->reminder = intval($this->endtime->timestamp() - $trigger);
} else {
$this->reminder = intval($this->starttime->timestamp() - $trigger);
}
} else {
$this->reminder = -intval($trigger);
}
}
}
示例6: quickAdd
/**
* Imports an event parsed from a string.
*
* @param string $text The text to parse into an event
* @param string $calendar The calendar into which the event will be
* imported. If 'null', the user's default
* calendar will be used.
*
* @return array The UID of all events that were added.
* @throws Kronolith_Exception
*/
public function quickAdd($text, $calendar = null)
{
$text = trim($text);
if (strpos($text, "\n") !== false) {
list($title, $description) = explode($text, "\n", 2);
} else {
$title = $text;
$description = '';
}
$title = trim($title);
$description = trim($description);
$dateParser = Horde_Date_Parser::factory(array('locale' => $GLOBALS['language']));
$r = $dateParser->parse($title, array('return' => 'result'));
if (!($d = $r->guess())) {
throw new Horde_Exception(sprintf(_("Cannot parse event description \"%s\""), Horde_String::truncate($text)));
}
$title = $r->untaggedText();
$kronolith_driver = self::getDriver(null, $calendar);
$event = $kronolith_driver->getEvent();
$event->initialized = true;
$event->title = $title;
$event->description = $description;
$event->start = $d;
$event->end = $d->add(array('hour' => 1));
$event->save();
return $event;
}
示例7: redirectMessage
/**
* Redirect the message.
*
* Variables used:
* - composeCache: (string) The IMP_Compose cache identifier.
* - redirect_to: (string) The address(es) to redirect to.
*
* @return object An object with the following entries:
* - action: (string) 'redirectMessage'.
* - success: (integer) 1 on success, 0 on failure.
*/
public function redirectMessage()
{
$result = new stdClass();
$result->action = 'redirectMessage';
$result->success = 1;
try {
$imp_compose = $GLOBALS['injector']->getInstance('IMP_Factory_Compose')->create($this->vars->composeCache);
$res = $imp_compose->sendRedirectMessage($this->vars->redirect_to);
foreach ($res as $val) {
$subject = $val->headers->getValue('subject');
$GLOBALS['notification']->push(empty($subject) ? _("Message redirected successfully.") : sprintf(_("Message \"%s\" redirected successfully."), Horde_String::truncate($subject)), 'horde.success');
$this->_base->queue->maillog(new IMP_Indices($val->mbox, $val->uid));
}
} catch (Horde_Exception $e) {
$GLOBALS['notification']->push($e);
$result->success = 0;
}
return $result;
}
示例8: array
$realname = $currFile->getFileName();
$mimeType = Horde_Mime_Magic::filenameToMIME($realname);
$currFile->mimeType = $mimeType;
if (Horde_String::lower(Horde_String::substr($realname, 0, 6)) == 'readme') {
$readmes[] = $currFile;
}
$icon = $injector->getInstance('Horde_Core_Factory_MimeViewer')->getIcon($mimeType);
$author = Chora::showAuthorName($lg->getAuthor());
$filerev = $lg->getRevision();
$date = $lg->getDate();
$log = $lg->getMessage();
$attic = $currFile->isDeleted();
$fileName = $where . ($attic ? '/' . 'Attic' : '') . '/' . $realname;
$name = $injector->getInstance('Horde_Core_Factory_TextFilter')->filter($realname, 'space2html', array('encode' => true, 'encode_all' => true));
$url = Chora::url('browsefile', $fileName, $branchArgs);
$readableDate = Chora::readableTime($date);
if ($log) {
$shortLog = Horde_String::truncate(str_replace("\n", ' ', trim($log)), $conf['options']['shortLogLength']);
}
require CHORA_TEMPLATES . '/directory/file.inc';
}
echo '</tbody>';
}
echo '</table>';
if ($readmes) {
$readmeCollection = new Chora_Readme_Collection($readmes);
$readmeFile = $readmeCollection->chooseReadme();
$readmeRenderer = new Chora_Renderer_File_Html($injector->createInstance('Horde_View'), $readmeFile, $readmeFile->getRevision());
echo $readmeRenderer->render();
}
$page_output->footer();
示例9: _init
/**
*/
protected function _init()
{
global $injector, $notification, $page_output, $registry, $session;
$imp_mailbox = $this->indices->mailbox->list_ob;
switch ($mode = $this->vars->get('mode', 'thread')) {
case 'thread':
/* THREAD MODE: Make sure we have a valid index. */
list($m, $u) = $this->indices->getSingle();
$imp_indices = $imp_mailbox->getFullThread($u, $m);
break;
default:
/* MSGVIEW MODE: Make sure we have a valid list of messages. */
$imp_indices = $this->indices;
break;
}
if (!count($imp_indices)) {
$notification->push(_("Could not load message."), 'horde.error');
$this->indices->mailbox->url('mailbox')->redirect();
}
/* Run through action handlers. */
switch ($this->vars->actionID) {
case 'add_address':
try {
$contact_link = $injector->getInstance('IMP_Contacts')->addAddress($this->vars->address, $this->vars->name);
$notification->push(sprintf(_("Entry \"%s\" was successfully added to the address book"), $contact_link), 'horde.success', array('content.raw'));
} catch (Horde_Exception $e) {
$notification->push($e);
}
break;
}
$msgs = $tree = array();
$subject = '';
$page_label = $this->indices->mailbox->label;
$imp_ui = $injector->getInstance('IMP_Message_Ui');
$query = new Horde_Imap_Client_Fetch_Query();
$query->envelope();
/* Force images to show in HTML data. */
$injector->getInstance('IMP_Images')->alwaysShow = true;
$multiple = count($imp_indices) > 1;
foreach ($imp_indices as $ob) {
$imp_imap = $ob->mbox->imp_imap;
$fetch_res = $imp_imap->fetch($ob->mbox, $query, array('ids' => $imp_imap->getIdsOb($ob->uids)));
foreach ($ob->uids as $idx) {
$envelope = $fetch_res[$idx]->getEnvelope();
/* Get the body of the message. */
$curr_msg = $curr_tree = array();
$contents = $injector->getInstance('IMP_Factory_Contents')->create($ob->mbox->getIndicesOb($idx));
$mime_id = $contents->findBody();
if ($contents->canDisplay($mime_id, IMP_Contents::RENDER_INLINE)) {
$ret = $contents->renderMIMEPart($mime_id, IMP_Contents::RENDER_INLINE);
$ret = reset($ret);
$curr_msg['body'] = $ret['data'];
if (!empty($ret['js'])) {
$page_output->addInlineScript($ret['js'], true);
}
} else {
$curr_msg['body'] = '<em>' . _("There is no text that can be displayed inline.") . '</em>';
}
$curr_msg['idx'] = $idx;
/* Get headers for the message. */
$date_ob = new IMP_Message_Date($envelope->date);
$curr_msg['date'] = $date_ob->format($date_ob::DATE_LOCAL);
if ($this->indices->mailbox->special_outgoing) {
$curr_msg['addr_to'] = true;
$curr_msg['addr'] = _("To:") . ' ' . $imp_ui->buildAddressLinks($envelope->to, Horde::selfUrlParams());
$addr = _("To:") . ' ' . htmlspecialchars($envelope->to[0]->label, ENT_COMPAT, 'UTF-8');
} else {
$from = $envelope->from;
$curr_msg['addr_to'] = false;
$curr_msg['addr'] = $imp_ui->buildAddressLinks($from, Horde::selfUrlParams());
$addr = htmlspecialchars($from[0]->label, ENT_COMPAT, 'UTF-8');
}
$subject_header = htmlspecialchars($envelope->subject, ENT_COMPAT, 'UTF-8');
switch ($mode) {
case 'thread':
if (empty($subject)) {
$subject = preg_replace('/^re:\\s*/i', '', $subject_header);
}
$curr_msg['link'] = $multiple ? Horde::widget(array('url' => '#display', 'title' => _("Thread List"), 'nocheck' => true)) : '';
$curr_tree['subject'] = $imp_mailbox->getThreadOb($imp_mailbox->getArrayIndex($fetch_res[$idx]->getUid(), $ob->mbox) + 1)->img;
break;
default:
$curr_msg['link'] = Horde::widget(array('url' => '#display', 'title' => _("Back to Multiple Message View Index"), 'nocheck' => true));
$curr_tree['subject'] = '';
break;
}
switch ($registry->getView()) {
case $registry::VIEW_BASIC:
$curr_msg['link'] .= ' | ' . Horde::widget(array('url' => $this->indices->mailbox->url('message', $idx), 'title' => _("Go to Message"), 'nocheck' => true)) . ' | ' . Horde::widget(array('url' => $this->indices->mailbox->url('mailbox')->add(array('start' => $imp_mailbox->getArrayIndex($idx))), 'title' => sprintf(_("Bac_k to %s"), $page_label)));
break;
}
$curr_tree['subject'] .= Horde::link('#i' . $idx) . Horde_String::truncate($subject_header, 60) . '</a> (' . $addr . ')';
$msgs[] = $curr_msg;
$tree[] = $curr_tree;
}
}
/* Flag messages as seen. */
$injector->getInstance('IMP_Message')->flag(array('add' => array(Horde_Imap_Client::FLAG_SEEN)), $imp_indices);
//.........这里部分代码省略.........
示例10: attachImapMessage
/**
* Add mail message(s) from the mail server as a message/rfc822
* attachment.
*
* @param IMP_Indices $indices An indices object.
*
* @return string Subject string.
*
* @throws IMP_Exception
*/
public function attachImapMessage($indices)
{
if (!count($indices)) {
return false;
}
$attached = 0;
foreach ($indices as $ob) {
foreach ($ob->uids as $idx) {
++$attached;
$contents = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($ob->mbox, $idx));
$headerob = $contents->getHeader();
$part = new Horde_Mime_Part();
$part->setCharset('UTF-8');
$part->setType('message/rfc822');
$part->setName(_("Forwarded Message"));
$part->setContents($contents->fullMessageText(array('stream' => true)), array('usestream' => true));
// Throws IMP_Compose_Exception.
$this->addAttachmentFromPart($part);
$part->clearContents();
}
}
if ($attached > 1) {
return 'Fwd: ' . sprintf(_("%u Forwarded Messages"), $attached);
}
if ($name = $headerob['Subject']) {
$name = Horde_String::truncate($name, 80);
} else {
$name = _("[No Subject]");
}
return 'Fwd: ' . strval(new Horde_Imap_Client_Data_BaseSubject($name, array('keepblob' => true)));
}
示例11:
<li>
<a href="<?php
echo $entry->link() == '' ? 'http://www.horde.org' : HordeWeb_Utils::wrapLink($entry->link());
?>
"><?php
echo $entry->title();
?>
</a>
<div class="description"><?php
echo Horde_String::truncate(strip_tags($entry->description()), 180);
?>
</div>
</li>
示例12: redirectMessage
/**
* Redirect the message.
*
* Variables used: See the list of variables needed for
* IMP_Ajax_Application#composeSetup().
*
* @return object An object with the following entries:
* - action: (string) 'redirectMessage'.
* - success: (integer) 1 on success, 0 on failure.
*/
public function redirectMessage()
{
try {
list($result, $imp_compose, $headers, ) = $this->_base->composeSetup('sendMessage');
if (!IMP_Compose::canCompose()) {
$result->success = 0;
return $result;
}
$res = $imp_compose->sendRedirectMessage($headers['redirect_to']);
foreach ($res as $val) {
$subject = $val->headers['Subject'];
$GLOBALS['notification']->push(empty($subject) ? _("Message redirected successfully.") : sprintf(_("Message \"%s\" redirected successfully."), Horde_String::truncate($subject)), 'horde.success');
$this->_base->queue->maillog(new IMP_Indices($val->mbox, $val->uid));
}
} catch (Horde_Exception $e) {
$GLOBALS['notification']->push($e);
$result->success = 0;
}
return $result;
}
示例13: getCostObjectType
/**
* Return data for costobjects, optionally filtered by client_ids.
*
* @param mixed $client_ids A client id or an array of client ids to
* filter cost obejcts by.
*
* @return array An array of cost objects data.
*/
public static function getCostObjectType($client_ids = null)
{
$elts = array('' => _("--- No Cost Object ---"));
$counter = 0;
foreach (self::getCostObjects($client_ids) as $category) {
Horde_Array::arraySort($category['objects'], 'name');
$elts['category%' . $counter++] = sprintf('--- %s ---', $category['category']);
foreach ($category['objects'] as $object) {
$name = Horde_String::truncate($object['name'], 80);
$hours = 0.0;
$filter = array('costobject' => $object['id']);
if (!empty($GLOBALS['conf']['time']['sum_billable_only'])) {
$filter['billable'] = true;
}
$result = $GLOBALS['injector']->getInstance('Hermes_Driver')->getHours($filter, array('hours'));
foreach ($result as $entry) {
if (!empty($entry['hours'])) {
$hours += $entry['hours'];
}
}
/* Show summary of hours versus estimate for this
* deliverable. */
if (empty($object['estimate'])) {
$name .= sprintf(_(" (%0.2f hours)"), $hours);
} else {
$name .= sprintf(_(" (%d%%, %0.2f of %0.2f hours)"), (int) ($hours / $object['estimate'] * 100), $hours, $object['estimate']);
}
$elts[$object['id']] = $name;
}
}
return $elts;
}
示例14: natcasesort
}
?>
<?php
echo $this->redirectUrl->add('b', $bookmark->id)->link(array('target' => $this->target)) . $this->h($bookmark->title ? $bookmark->title : $bookmark->url);
?>
</a>
<small>
<?php
echo $this->h($bookmark->url);
?>
<?php
if (strlen($bookmark->description)) {
?>
—
<?php
echo $this->h(Horde_String::truncate($bookmark->description, 200));
?>
<?php
}
?>
</small>
<ul class="horde-tags">
<?php
natcasesort($bookmark->tags);
?>
<?php
foreach ($bookmark->tags as $tag) {
$url = $GLOBALS['injector']->getInstance('Trean_TagBrowser')->addTagLink($tag);
?>
<li><a href="<?php
echo $url;
示例15: _init
//.........这里部分代码省略.........
break;
}
exit;
}
}
/* Prepare the search view. */
$view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/search'));
$view->addHelper('Text');
$view->addHelper('Tag');
$view->addHelper('FormTag');
$view->action = self::url();
/* Determine if we are editing a search query. */
$q_ob = $default_mailbox->getSearchOb();
if ($this->vars->edit_query && $default_mailbox->search) {
if ($default_mailbox->vfolder) {
if (!$default_mailbox->editvfolder) {
$notification->push(_("Built-in Virtual Folders cannot be edited."), 'horde.error');
$registry->getServiceLink('prefs', 'imp')->add('group', 'searches')->redirect();
}
$view->edit_query = true;
$view->edit_query_vfolder = $default_mailbox->form_to;
} elseif ($imp_search->isFilter($q_ob)) {
if (!$imp_search->isFilter($q_ob, true)) {
$notification->push(_("Built-in Filters cannot be edited."), 'horde.error');
$registry->getServiceLink('prefs', 'imp')->add('group', 'searches')->redirect();
}
$view->edit_query = true;
$view->edit_query_filter = $default_mailbox->form_to;
}
if ($view->edit_query) {
$view->search_label = $q_ob->label;
$js_vars['ImpSearch.prefsurl'] = strval($registry->getServiceLink('prefs', 'imp')->add('group', 'searches')->setRaw(true));
}
} else {
/* Process list of recent searches. */
$iterator = IMP_Search_IteratorFilter::create(IMP_Search_IteratorFilter::QUERY);
$rs = array();
foreach ($iterator as $val) {
$rs[$val->formid] = array('c' => $val->criteria, 'f' => array('m' => IMP_Mailbox::formTo($val->all ? array(IMP_Search_Query::ALLSEARCH) : array_map('strval', $val->mbox_list)), 's' => IMP_Mailbox::formTo(array_map('strval', $val->subfolder_list))), 'l' => Horde_String::truncate($val->querytext));
}
if (!empty($rs)) {
$js_vars['ImpSearch.i_recent'] = $rs;
}
$s_mboxes = IMP_Mailbox::formTo($search_mailbox);
$js_vars['ImpSearch.i_mboxes'] = array('m' => $this->vars->subfolder ? array() : $s_mboxes, 's' => $this->vars->subfolder ? $s_mboxes : array());
}
if ($default_mailbox->search) {
$js_vars['ImpSearch.i_criteria'] = $q_ob->criteria;
$js_vars['ImpSearch.i_mboxes'] = array('m' => IMP_Mailbox::formTo($q_ob->all ? array(IMP_Search_Query::ALLSEARCH) : $q_ob->mbox_list), 's' => IMP_Mailbox::formTo($q_ob->subfolder_list));
}
/* Create the criteria list. */
$c_list = $types = array();
foreach ($criteria as $key => $val) {
$c_list[] = array('l' => $val['label'], 'v' => $key);
$types[$key] = $val['type'];
}
$view->clist = $c_list;
/* Create the filter list. These are all-or-nothing searches. */
$f_list = array();
foreach ($filters as $key => $val) {
$f_list[] = array('l' => $val['label'], 'v' => $key);
$types[$key] = 'filter';
}
$view->filterlist = $f_list;
/* Create the flag list. */
$flist = $imp_flags->getList(array('imap' => true, 'mailbox' => $default_mailbox));
$flag_set = array();
foreach ($flist as $val) {
$flag_set[] = array('l' => $val->label, 'v' => rawurlencode($val->form_set));
$types[rawurlencode($val->form_set)] = 'flag';
}
$view->flist = $flag_set;
/* Generate master mailbox list. */
$mbox_list = array();
if (!$view->edit_query_filter) {
$js_vars['ImpSearch.allsearch'] = IMP_Mailbox::formTo(IMP_Search_Query::ALLSEARCH);
$ob = $injector->getInstance('IMP_Search_Ui')->getSearchMboxList();
$mbox_list = $ob->mbox_list;
$view->subscribe = $prefs->getValue('subscribe');
$view->tree = $ob->tree->getTree();
}
/* Prepare the topbar. */
if (!$dynamic_view) {
$injector->getInstance('Horde_View_Topbar')->subinfo = $injector->getInstance('IMP_View_Subinfo')->render();
}
Horde_Core_Ui_JsCalendar::init();
$page_output->addScriptFile('hordecore.js', 'horde');
$page_output->addScriptFile('horde.js', 'horde');
$page_output->addScriptFile('search.js');
$page_output->addInlineJsVars(array_merge($js_vars, array('ImpSearch.data' => array('constants' => $constants, 'dynamic_view' => $dynamic_view, 'inbox' => IMP_Mailbox::get('INBOX')->form_to, 'mbox_list' => $mbox_list, 'months' => Horde_Core_Ui_JsCalendar::months(), 'searchmbox' => $default_mailbox->form_to, 'types' => $types), 'ImpSearch.text' => array('and' => _("and"), 'customhdr' => _("Custom Header:"), 'datereset' => _("Date Reset"), 'dateselection' => _("Date Selection"), 'flag' => _("Flag:"), 'loading' => _("Loading..."), 'need_criteria' => _("Please select at least one search criteria."), 'need_date' => _("Need at least one date in the date range search."), 'need_mbox' => _("Please select at least one mailbox to search."), 'need_label' => _("Saved searches require a label."), 'not_match' => _("Do NOT Match"), 'or' => _("OR"), 'search_all' => _("Search All Mailboxes"), 'search_term' => _("Search Term:"), 'subfolder_search' => _("Search all subfolders?"), 'to' => _("to")))), array('onload' => true));
if ($dynamic_view) {
if (!$this->vars->edit_query) {
$view->return_mailbox_val = sprintf(_("Return to %s"), $default_mailbox->display_html);
}
$page_output->topbar = $page_output->sidebar = false;
$this->header_params = array('html_id' => 'htmlAllowScroll');
}
$this->title = _("Search");
$this->output = $view->render('search');
}