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


PHP abbreviate_string函数代码示例

本文整理汇总了PHP中abbreviate_string函数的典型用法代码示例。如果您正苦于以下问题:PHP abbreviate_string函数的具体用法?PHP abbreviate_string怎么用?PHP abbreviate_string使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: attachment_get

 /**
  * Deliver an event/task attachment to the client
  * (similar as in Roundcube core program/steps/mail/get.inc)
  */
 public function attachment_get($attachment)
 {
     ob_end_clean();
     if ($attachment && $attachment['body']) {
         // allow post-processing of the attachment body
         $part = new rcube_message_part();
         $part->filename = $attachment['name'];
         $part->size = $attachment['size'];
         $part->mimetype = $attachment['mimetype'];
         $plugin = $this->rc->plugins->exec_hook('message_part_get', array('body' => $attachment['body'], 'mimetype' => strtolower($attachment['mimetype']), 'download' => !empty($_GET['_download']), 'part' => $part));
         if ($plugin['abort']) {
             exit;
         }
         $mimetype = $plugin['mimetype'];
         list($ctype_primary, $ctype_secondary) = explode('/', $mimetype);
         $browser = $this->rc->output->browser;
         // send download headers
         if ($plugin['download']) {
             header("Content-Type: application/octet-stream");
             if ($browser->ie) {
                 header("Content-Type: application/force-download");
             }
         } else {
             if ($ctype_primary == 'text') {
                 header("Content-Type: text/{$ctype_secondary}");
             } else {
                 header("Content-Type: {$mimetype}");
                 header("Content-Transfer-Encoding: binary");
             }
         }
         // display page, @TODO: support text/plain (and maybe some other text formats)
         if ($mimetype == 'text/html' && empty($_GET['_download'])) {
             $OUTPUT = new rcmail_html_page();
             // @TODO: use washtml on $body
             $OUTPUT->write($plugin['body']);
         } else {
             // don't kill the connection if download takes more than 30 sec.
             @set_time_limit(0);
             $filename = $attachment['name'];
             $filename = preg_replace('[\\r\\n]', '', $filename);
             if ($browser->ie && $browser->ver < 7) {
                 $filename = rawurlencode(abbreviate_string($filename, 55));
             } else {
                 if ($browser->ie) {
                     $filename = rawurlencode($filename);
                 } else {
                     $filename = addcslashes($filename, '"');
                 }
             }
             $disposition = !empty($_GET['_download']) ? 'attachment' : 'inline';
             header("Content-Disposition: {$disposition}; filename=\"{$filename}\"");
             echo $plugin['body'];
         }
         exit;
     }
     // if we arrive here, the requested part was not found
     header('HTTP/1.1 404 Not Found');
     exit;
 }
开发者ID:Fneufneu,项目名称:libcalendaring,代码行数:63,代码来源:libcalendaring.php

示例2: render_folder_tree_select

 /**
  * Return html for a flat list <select> for the mailbox tree
  */
 public function render_folder_tree_select(&$arrFolders, &$mbox_name, $maxlength, &$select, $realnames = false, $nestLevel = 0, $opts = array())
 {
     $out = '';
     foreach ($arrFolders as $folder) {
         // skip exceptions (and its subfolders)
         if (!empty($opts['exceptions']) && in_array($folder['id'], $opts['exceptions'])) {
             continue;
         }
         // skip folders in which it isn't possible to create subfolders
         if (!empty($opts['skip_noinferiors'])) {
             $attrs = $this->storage->folder_attributes($folder['id']);
             if ($attrs && in_array_nocase('\\Noinferiors', $attrs)) {
                 continue;
             }
         }
         if (!$realnames && ($folder_class = $this->folder_classname($folder['id']))) {
             $foldername = $this->gettext($folder_class);
         } else {
             $foldername = $folder['name'];
             // shorten the folder name to a given length
             if ($maxlength && $maxlength > 1) {
                 $foldername = abbreviate_string($foldername, $maxlength);
             }
         }
         $select->add(str_repeat('&nbsp;', $nestLevel * 4) . html::quote($foldername), $folder['id']);
         if (!empty($folder['folders'])) {
             $out .= $this->render_folder_tree_select($folder['folders'], $mbox_name, $maxlength, $select, $realnames, $nestLevel + 1, $opts);
         }
     }
     return $out;
 }
开发者ID:peknur,项目名称:roundcubemail,代码行数:34,代码来源:rcmail.php

示例3: actions


//.........这里部分代码省略.........
                         $kep14 = $this->rc->config->get('managesieve_kolab_master');
                         if ($result === true) {
                             $this->rc->output->set_env('active_sets', $this->active);
                             $this->rc->output->show_message('managesieve.setactivated', 'confirmation');
                             $this->rc->output->command('managesieve_updatelist', 'setact', array('name' => $script_name, 'active' => true, 'all' => !$kep14));
                         } else {
                             $this->rc->output->show_message('managesieve.setactivateerror', 'error');
                         }
                     } else {
                         if ($action == 'deact' && !$error) {
                             $script_name = rcube_utils::get_input_value('_set', rcube_utils::INPUT_GPC, true);
                             $result = $this->deactivate_script($script_name);
                             if ($result === true) {
                                 $this->rc->output->set_env('active_sets', $this->active);
                                 $this->rc->output->show_message('managesieve.setdeactivated', 'confirmation');
                                 $this->rc->output->command('managesieve_updatelist', 'setact', array('name' => $script_name, 'active' => false));
                             } else {
                                 $this->rc->output->show_message('managesieve.setdeactivateerror', 'error');
                             }
                         } else {
                             if ($action == 'setdel' && !$error) {
                                 $script_name = rcube_utils::get_input_value('_set', rcube_utils::INPUT_GPC, true);
                                 $result = $this->remove_script($script_name);
                                 if ($result === true) {
                                     $this->rc->output->show_message('managesieve.setdeleted', 'confirmation');
                                     $this->rc->output->command('managesieve_updatelist', 'setdel', array('name' => $script_name));
                                     $this->rc->session->remove('managesieve_current');
                                 } else {
                                     $this->rc->output->show_message('managesieve.setdeleteerror', 'error');
                                 }
                             } else {
                                 if ($action == 'setget') {
                                     $script_name = rcube_utils::get_input_value('_set', rcube_utils::INPUT_GPC, true);
                                     $script = $this->sieve->get_script($script_name);
                                     if (PEAR::isError($script)) {
                                         exit;
                                     }
                                     $browser = new rcube_browser();
                                     // send download headers
                                     header("Content-Type: application/octet-stream");
                                     header("Content-Length: " . strlen($script));
                                     if ($browser->ie) {
                                         header("Content-Type: application/force-download");
                                     }
                                     if ($browser->ie && $browser->ver < 7) {
                                         $filename = rawurlencode(abbreviate_string($script_name, 55));
                                     } else {
                                         if ($browser->ie) {
                                             $filename = rawurlencode($script_name);
                                         } else {
                                             $filename = addcslashes($script_name, '\\"');
                                         }
                                     }
                                     header("Content-Disposition: attachment; filename=\"{$filename}.txt\"");
                                     echo $script;
                                     exit;
                                 } else {
                                     if ($action == 'list') {
                                         $result = $this->list_rules();
                                         $this->rc->output->command('managesieve_updatelist', 'list', array('list' => $result));
                                     } else {
                                         if ($action == 'ruleadd') {
                                             $rid = rcube_utils::get_input_value('_rid', rcube_utils::INPUT_GPC);
                                             $id = $this->genid();
                                             $content = $this->rule_div($fid, $id, false);
                                             $this->rc->output->command('managesieve_rulefill', $content, $id, $rid);
                                         } else {
                                             if ($action == 'actionadd') {
                                                 $aid = rcube_utils::get_input_value('_aid', rcube_utils::INPUT_GPC);
                                                 $id = $this->genid();
                                                 $content = $this->action_div($fid, $id, false);
                                                 $this->rc->output->command('managesieve_actionfill', $content, $id, $aid);
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $this->rc->output->send();
     } else {
         if ($this->rc->task == 'mail') {
             // Initialize the form
             $rules = rcube_utils::get_input_value('r', rcube_utils::INPUT_GET);
             if (!empty($rules)) {
                 $i = 0;
                 foreach ($rules as $rule) {
                     list($header, $value) = explode(':', $rule, 2);
                     $tests[$i] = array('type' => 'contains', 'test' => 'header', 'arg1' => $header, 'arg2' => $value);
                     $i++;
                 }
                 $this->form = array('join' => count($tests) > 1 ? 'allof' : 'anyof', 'name' => '', 'tests' => $tests, 'actions' => array(0 => array('type' => 'fileinto'), 1 => array('type' => 'stop')));
             }
         }
     }
     $this->send();
 }
开发者ID:zamentur,项目名称:roundcube_ynh,代码行数:101,代码来源:rcube_sieve_engine.php

示例4: _deliver_zipfile

 /**
  * Helper method to send the zip archive to the browser
  */
 private function _deliver_zipfile($tmpfname, $filename)
 {
     $browser = new rcube_browser();
     $rcmail = rcmail::get_instance();
     $rcmail->output->nocacheing_headers();
     if ($browser->ie && $browser->ver < 7) {
         $filename = rawurlencode(abbreviate_string($filename, 55));
     } else {
         if ($browser->ie) {
             $filename = rawurlencode($filename);
         } else {
             $filename = addcslashes($filename, '"');
         }
     }
     // send download headers
     header("Content-Type: application/octet-stream");
     if ($browser->ie) {
         header("Content-Type: application/force-download");
     }
     // don't kill the connection if download takes more than 30 sec.
     @set_time_limit(0);
     header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
     header("Content-length: " . filesize($tmpfname));
     readfile($tmpfname);
 }
开发者ID:rasky,项目名称:roundcubemail,代码行数:28,代码来源:zipdownload.php

示例5: _gen_addressbooks_list

 private function _gen_addressbooks_list($arrBooks, $command)
 {
     $rcmail = rcmail::get_instance();
     $groupTotal = 0;
     $maxlength = 35;
     $maxlength_grp = 33;
     $out = '';
     // address books
     foreach ($arrBooks as $j => $source) {
         $title = null;
         $id = $source['id'] ? $source['id'] : $j;
         $bookname = !empty($source['name']) ? Q($source['name']) : Q($id);
         // shorten the address book name to a given length
         if ($maxlength && $maxlength > 1) {
             $bname = abbreviate_string($bookname, $maxlength);
             if ($bname != $bookname) {
                 $title = $bookname;
             }
             $bookname = $bname;
         }
         if ($source['readonly']) {
             $out .= html::tag('li', array('id' => 'rcm_contextaddr_' . $id, 'class' => 'addressbook disabled'), html::a(array('href' => $command, 'id' => 'rcm_contextgrps_' . JQ($id), 'onclick' => "rcm_set_dest_book('" . JQ($id) . "', '" . JQ($id) . "', null)", 'class' => 'active', 'title' => $title), Q($bookname)));
         } else {
             $out .= html::tag('li', array('id' => 'rcm_contextaddr_' . $id, 'class' => 'addressbook'), html::a(array('href' => $command, 'id' => 'rcm_contextgrps_' . JQ($id), 'onclick' => "rcm_set_dest_book('" . JQ($id) . "', '" . JQ($id) . "', null)", 'class' => 'active', 'title' => $title), Q($bookname)));
         }
         // contact groups
         if ($source['groups']) {
             $groups = $rcmail->get_address_book($source['id'])->list_groups();
             foreach ($groups as $group) {
                 $title = null;
                 $gid = 'G' . $id . $group['ID'];
                 $groupname = !empty($group['name']) ? Q($group['name']) : Q($gid);
                 // shorten the address book name to a given length
                 if ($maxlength_grp && $maxlength_grp > 1) {
                     $gname = abbreviate_string($groupname, $maxlength_grp);
                     if ($gname != $groupname) {
                         $title = $groupname;
                     }
                     $groupname = $gname;
                 }
                 if ($source['readonly']) {
                     $out .= html::tag('li', array('class' => 'contactgroup disabled'), html::a(array('href' => $command, 'id' => 'rcm_contextgrps_' . JQ($gid), 'onclick' => "rcm_set_dest_book('" . JQ($gid) . "', '" . JQ($id) . "', '" . JQ($group['ID']) . "')", 'class' => 'active', 'title' => $title), Q('&nbsp;&nbsp;' . $groupname)));
                 } else {
                     $out .= html::tag('li', array('class' => 'contactgroup'), html::a(array('href' => $command, 'id' => 'rcm_contextgrps_' . JQ($gid), 'onclick' => "rcm_set_dest_book('" . JQ($gid) . "', '" . JQ($id) . "', '" . JQ($group['ID']) . "')", 'class' => 'active', 'title' => $title), Q('&nbsp;&nbsp;' . $groupname)));
                 }
                 $groupTotal++;
             }
         }
         $groupTotal++;
     }
     if ($groupTotal > 5) {
         $out = html::tag('ul', array('id' => 'rcm_contextgrps', 'class' => 'toolbarmenu folders scrollable'), $out);
         $out = html::tag('div', array('class' => 'scroll_up_pas'), '') . $out . html::tag('div', array('class' => 'scroll_down_act'), '');
         $out = html::tag('div', array('class' => 'popupmenu'), $out);
     } else {
         $out = html::tag('ul', array('id' => 'rcm_contextgrps', 'class' => 'popupmenu toolbarmenu folders'), $out);
     }
     return $out;
 }
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:59,代码来源:contextmenu.php

示例6: serialize_event

 /**
  * Helper method to serialize the given event for storing in invitations table
  */
 private static function serialize_event($event)
 {
     $ev = $event;
     $ev['description'] = abbreviate_string($ev['description'], 100);
     unset($ev['attachments']);
     return serialize($ev);
 }
开发者ID:MetallianFR68,项目名称:myroundcube,代码行数:10,代码来源:calendar_itip.php

示例7: action_div

    function action_div($fid, $id, $div = true)
    {
        $action = isset($this->form) ? $this->form['actions'][$id] : $this->script[$fid]['actions'][$id];
        $rows_num = isset($this->form) ? sizeof($this->form['actions']) : sizeof($this->script[$fid]['actions']);
        $out = $div ? '<div class="actionrow" id="actionrow' . $id . '">' . "\n" : '';
        $out .= '<table><tr><td class="rowactions">';
        // action select
        $select_action = new html_select(array('name' => "_action_type[]", 'id' => 'action_type' . $id, 'onchange' => 'action_type_select(' . $id . ')'));
        if (in_array('fileinto', $this->exts)) {
            $select_action->add(Q($this->gettext('messagemoveto')), 'fileinto');
        }
        $select_action->add(Q($this->gettext('messageredirect')), 'redirect');
        if (in_array('reject', $this->exts)) {
            $select_action->add(Q($this->gettext('messagediscard')), 'reject');
        } elseif (in_array('ereject', $this->exts)) {
            $select_action->add(Q($this->gettext('messagediscard')), 'ereject');
        }
        if (in_array('vacation', $this->exts)) {
            $select_action->add(Q($this->gettext('messagereply')), 'vacation');
        }
        $select_action->add(Q($this->gettext('messagedelete')), 'discard');
        $select_action->add(Q($this->gettext('rulestop')), 'stop');
        $out .= $select_action->show($action['type']);
        $out .= '</td>';
        // actions target inputs
        $out .= '<td class="rowtargets">';
        // shared targets
        $out .= '<input type="text" name="_action_target[]" id="action_target' . $id . '" ' . 'value="' . ($action['type'] == 'redirect' ? Q($action['target'], 'strict', false) : '') . '" size="40" ' . 'style="display:' . ($action['type'] == 'redirect' ? 'inline' : 'none') . '" ' . $this->error_class($id, 'action', 'target') . ' />';
        $out .= '<textarea name="_action_target_area[]" id="action_target_area' . $id . '" ' . 'rows="3" cols="40" ' . $this->error_class($id, 'action', 'targetarea') . 'style="display:' . (in_array($action['type'], array('reject', 'ereject')) ? 'inline' : 'none') . '">' . (in_array($action['type'], array('reject', 'ereject')) ? Q($action['target'], 'strict', false) : '') . "</textarea>\n";
        // vacation
        $out .= '<div id="action_vacation' . $id . '" style="display:' . ($action['type'] == 'vacation' ? 'inline' : 'none') . '">';
        $out .= '<span class="label">' . Q($this->gettext('vacationreason')) . '</span><br />' . '<textarea name="_action_reason[]" id="action_reason' . $id . '" ' . 'rows="3" cols="40" ' . $this->error_class($id, 'action', 'reason') . '>' . Q($action['reason'], 'strict', false) . "</textarea>\n";
        $out .= '<br /><span class="label">' . Q($this->gettext('vacationaddresses')) . '</span><br />' . '<input type="text" name="_action_addresses[]" ' . 'value="' . (is_array($action['addresses']) ? Q(implode(', ', $action['addresses']), 'strict', false) : $action['addresses']) . '" size="40" ' . $this->error_class($id, 'action', 'addresses') . ' />';
        $out .= '<br /><span class="label">' . Q($this->gettext('vacationdays')) . '</span><br />' . '<input type="text" name="_action_days[]" ' . 'value="' . Q($action['days'], 'strict', false) . '" size="2" ' . $this->error_class($id, 'action', 'days') . ' />';
        $out .= '</div>';
        // mailbox select
        $out .= '<select id="action_mailbox' . $id . '" name="_action_mailbox[]" style="display:' . (!isset($action) || $action['type'] == 'fileinto' ? 'inline' : 'none') . '">';
        $this->rc->imap_init(true);
        $a_folders = $this->rc->imap->list_mailboxes();
        $delimiter = $this->rc->imap->get_hierarchy_delimiter();
        // set mbox encoding
        $mbox_encoding = $this->rc->config->get('managesieve_mbox_encoding', 'UTF7-IMAP');
        if ($action['type'] == 'fileinto') {
            $mailbox = $action['target'];
        } else {
            $mailbox = '';
        }
        foreach ($a_folders as $folder) {
            $utf7folder = $this->rc->imap->mod_mailbox($folder);
            $names = explode($delimiter, rcube_charset_convert($folder, 'UTF7-IMAP'));
            $name = $names[sizeof($names) - 1];
            if ($replace_delimiter = $this->rc->config->get('managesieve_replace_delimiter')) {
                $utf7folder = str_replace($delimiter, $replace_delimiter, $utf7folder);
            }
            // convert to Sieve implementation encoding
            $utf7folder = $this->mbox_encode($utf7folder, $mbox_encoding);
            if ($folder_class = rcmail_folder_classname($name)) {
                $foldername = $this->gettext($folder_class);
            } else {
                $foldername = $name;
            }
            $out .= sprintf('<option value="%s"%s>%s%s</option>' . "\n", htmlspecialchars($utf7folder), $mailbox == $utf7folder ? ' selected="selected"' : '', str_repeat('&nbsp;', 4 * (sizeof($names) - 1)), Q(abbreviate_string($foldername, 40 - (2 * sizeof($names) - 1))));
        }
        $out .= '</select>';
        $out .= '</td>';
        // add/del buttons
        $out .= '<td class="rowbuttons">';
        $out .= '<input type="button" id="actionadd' . $id . '" value="' . Q($this->gettext('add')) . '" 
	onclick="rcmail.managesieve_actionadd(' . $id . ')" class="button" /> ';
        $out .= '<input type="button" id="actiondel' . $id . '" value="' . Q($this->gettext('del')) . '"
        onclick="rcmail.managesieve_actiondel(' . $id . ')" class="button' . ($rows_num < 2 ? ' disabled' : '') . '"' . ($rows_num < 2 ? ' disabled="disabled"' : '') . ' />';
        $out .= '</td>';
        $out .= '</tr></table>';
        $out .= $div ? "</div>\n" : '';
        return $out;
    }
开发者ID:ehmedov,项目名称:www,代码行数:76,代码来源:managesieve.php


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