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


PHP Horde_String::pad方法代码示例

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


在下文中一共展示了Horde_String::pad方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
 }
开发者ID:horde,项目名称:horde,代码行数:40,代码来源:Zip.php

示例2: _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('rar')) {
         $this->setConfigParam('rar', Horde_Compress::factory('rar'));
     }
     $rarData = $this->getConfigParam('rar')->decompress($contents);
     $fileCount = count($rarData);
     $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, 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" . $this->_textFilter(Horde_Mime_Viewer_Translation::t("Archive File Size") . ': ' . strlen($contents) . ' bytes', 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" . $this->_textFilter(sprintf(Horde_Mime_Viewer_Translation::ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount), 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n\n" . $this->_textFilter(Horde_String::pad(Horde_Mime_Viewer_Translation::t("File Name"), 50, ' ', STR_PAD_RIGHT) . 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), 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" . str_repeat('-', 109) . "\n";
     foreach ($rarData as $val) {
         $ratio = empty($val['size']) ? 0 : 100 * ($val['csize'] / $val['size']);
         $text .= $this->_textFilter(Horde_String::pad($val['name'], 50, ' ', STR_PAD_RIGHT) . Horde_String::pad($val['attr'], 10, ' ', STR_PAD_LEFT) . Horde_String::pad($val['size'], 10, ' ', STR_PAD_LEFT) . Horde_String::pad(strftime("%d-%b-%Y %H:%M", $val['date']), 19, ' ', STR_PAD_LEFT) . Horde_String::pad($val['method'], 10, ' ', STR_PAD_LEFT) . Horde_String::pad(sprintf("%1.1f%%", $ratio), 10, ' ', STR_PAD_LEFT), 'space2html', array('encode' => true, 'encode_all' => true)) . "\n";
     }
     return $this->_renderReturn(nl2br($text . str_repeat('-', 106) . "\n</span></td></tr></table>"), 'text/html; charset=' . $charset);
 }
开发者ID:horde,项目名称:horde,代码行数:27,代码来源:Rar.php

示例3: deflist

 public function deflist($block)
 {
     $elements = explode($this->wiki->delim, $block);
     $term = false;
     $list = array();
     foreach ($elements as $element) {
         if ($term === false) {
             $term = $element;
         } else {
             $list[$term] = $element;
             $term = false;
         }
     }
     $term_length = max(array_map('strlen', array_keys($list)));
     $result = '';
     foreach ($list as $term => $info) {
         $lead = Horde_String::pad($term . ': ', $term_length + 2);
         $definition = Horde_String::wordwrap($lead . $info, max(80, $term_length + 30), "\n" . str_repeat(' ', $term_length + 3));
         $result .= ':' . $definition . "\n";
     }
     $result .= "\n";
     return $result;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:23,代码来源:Deflist.php

示例4: run

 /**
  * Run the module.
  *
  * @param Horde_Cli $cli       The CLI handler.
  * @param mixed     $options   An array of options.
  * @param mixed     $arguments An array of arguments.
  * @param array     &$world    A list of initialized dependencies.
  *
  * @return NULL
  */
 public function run($cli, $options, $arguments, &$world)
 {
     if (!isset($arguments[1])) {
         $action = 'folders';
     } else {
         $action = $arguments[1];
     }
     switch ($action) {
         case 'folders':
             $folders = $world['storage']->getList()->listFolders();
             foreach ($folders as $folder) {
                 $cli->writeln($folder);
             }
             break;
         case 'types':
             $types = $world['storage']->getList()->getQuery()->listTypes();
             if (!empty($types)) {
                 $pad = max(array_map('strlen', array_keys($types))) + 2;
                 foreach ($types as $folder => $type) {
                     $cli->writeln(Horde_String::pad($folder . ':', $pad) . $type);
                 }
             }
             break;
         case 'type':
             if (!isset($arguments[2])) {
                 throw new Horde_Kolab_Cli_Exception('You must provide a TYPE argument!');
             }
             $type = $arguments[2];
             $folders = $world['storage']->getList()->getQuery()->listByType($type);
             foreach ($folders as $folder) {
                 $cli->writeln($folder);
             }
             break;
         case 'owners':
             $owners = $world['storage']->getList()->getQuery()->listOwners();
             if (!empty($owners)) {
                 $pad = max(array_map('strlen', array_keys($owners))) + 2;
                 foreach ($owners as $folder => $owner) {
                     $cli->writeln(Horde_String::pad($folder . ':', $pad) . $owner);
                 }
             }
             break;
         case 'defaults':
             $defaults = $world['storage']->getList()->getQuery()->listDefaults();
             if (!empty($defaults)) {
                 foreach ($defaults as $owner => $folders) {
                     $cli->writeln('User "' . $owner . '":');
                     $cli->writeln();
                     foreach ($folders as $type => $folder) {
                         $cli->writeln('  ' . Horde_String::pad($type . ':', 14) . $folder);
                     }
                     $cli->writeln();
                 }
             }
             break;
         case 'aclsupport':
             if ($world['storage']->getList()->getQuery(Horde_Kolab_Storage_List::QUERY_ACL)->hasAclSupport()) {
                 echo "The remote server supports ACL.\n";
             } else {
                 echo "The remote server does not support ACL.\n";
             }
             break;
         case 'namespaces':
             $cli->writeln((string) $world['storage']->getList()->getNamespace());
             break;
         case 'sync':
             $folders = $world['storage']->getList()->synchronize();
             break;
         default:
             $cli->message(sprintf(Horde_Kolab_Cli_Translation::t('Action %s not supported!'), $action), 'cli.error');
             break;
     }
 }
开发者ID:horde,项目名称:horde,代码行数:83,代码来源:List.php

示例5: _finish

 /**
  * Wrap up the listing. This will produce a condensed list of packages in
  * case quiet Output was requested.
  *
  * @return NULL
  */
 private function _finish()
 {
     if (empty($this->_short_list)) {
         return;
     }
     $channels = array();
     $names = array();
     $colors = array();
     foreach ($this->_short_list as $key => $element) {
         $channels[] = $element['channel'];
         $names[] = $element['name'];
         $colors[] = $element['color'];
     }
     array_multisort($channels, $names, $colors);
     foreach ($names as $key => $name) {
         $this->_output->{$colors[$key]}(Horde_String::pad($name, 28) . Horde_String::pad('[' . $channels[$key] . ']', 20));
     }
 }
开发者ID:horde,项目名称:horde,代码行数:24,代码来源:Dependencies.php

示例6: getForwardHeaders

 /**
  * Return nicely formatted text representing the headers to display with
  * in-line forwarded messages.
  *
  * @return string
  */
 public function getForwardHeaders()
 {
     $tmp = array();
     $h = $this->getHeaders();
     if ($ob = $h->getValue('date')) {
         $tmp[Horde_ActiveSync_Translation::t('Date')] = $ob;
     }
     if ($ob = strval($h->getOb('from'))) {
         $tmp[Horde_ActiveSync_Translation::t('From')] = $ob;
     }
     if ($ob = strval($h->getOb('reply-to'))) {
         $tmp[Horde_ActiveSync_Translation::t('Reply-To')] = $ob;
     }
     if ($ob = $h->getValue('subject')) {
         $tmp[Horde_ActiveSync_Translation::t('Subject')] = $ob;
     }
     if ($ob = strval($h->getOb('to'))) {
         $tmp[Horde_ActiveSync_Translation::t('To')] = $ob;
     }
     if ($ob = strval($h->getOb('cc'))) {
         $tmp[Horde_ActiveSync_Translation::t('Cc')] = $ob;
     }
     $max = max(array_map(array('Horde_String', 'length'), array_keys($tmp))) + 2;
     $text = '';
     foreach ($tmp as $key => $val) {
         $text .= Horde_String::pad($key . ': ', $max, ' ', STR_PAD_LEFT) . $val . "\n";
     }
     return $text;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:35,代码来源:Message.php

示例7: toString

 /**
  * Returns a plain text representation of a ticket.
  */
 public function toString()
 {
     $fields = array('queue' => _("Queue"), 'version' => _("Version"), 'type' => _("Type"), 'state' => _("State"), 'priority' => _("Priority"), 'due' => _("Due"));
     /* Find longest translated field name. */
     $length = 0;
     foreach (array_merge($fields, array(_("Summary"), _("Owners"))) as $field) {
         $length = max($length, Horde_String::length($field));
     }
     $wrap_break = "\n" . str_repeat(' ', $length + 2) . '| ';
     $wrap_width = 73 - $length;
     /* Ticket properties. */
     $message = ' ' . Horde_String::pad(_("Ticket"), $length) . ' | ' . $this->_id . "\n" . ' ' . Horde_String::pad(_("Summary"), $length) . ' | ' . Horde_String::wrap($this->get('summary'), $wrap_width, $wrap_break) . "\n";
     foreach ($fields as $field => $label) {
         if ($name = $this->get($field . '_name')) {
             $message .= ' ' . Horde_String::pad($label, $length) . ' | ' . Horde_String::wrap($name, $wrap_width, $wrap_break) . "\n";
         }
     }
     $message .= ' ' . Horde_String::pad(_("Owners"), $length) . ' | ' . Horde_String::wrap(Whups::getOwners($this->_id, false, true), $wrap_width, $wrap_break) . "\n";
     return $message;
 }
开发者ID:horde,项目名称:horde,代码行数:23,代码来源:Ticket.php

示例8: _getMsgHeaders

 /**
  * Determine the header information to display in the forward/reply.
  *
  * @param Horde_Mime_Headers $h  The headers object for the message.
  *
  * @return string  The header information for the original message.
  */
 protected function _getMsgHeaders($h)
 {
     $tmp = array();
     if ($ob = $h['date']) {
         $tmp[_("Date")] = $ob->value;
     }
     if ($ob = strval($h['from'])) {
         $tmp[_("From")] = $ob;
     }
     if ($ob = strval($h['reply-to'])) {
         $tmp[_("Reply-To")] = $ob;
     }
     if ($ob = $h['subject']) {
         $tmp[_("Subject")] = $ob->value;
     }
     if ($ob = strval($h['to'])) {
         $tmp[_("To")] = $ob;
     }
     if ($ob = strval($h['cc'])) {
         $tmp[_("Cc")] = $ob;
     }
     $text = '';
     if (!empty($tmp)) {
         $max = max(array_map(array('Horde_String', 'length'), array_keys($tmp))) + 2;
         foreach ($tmp as $key => $val) {
             $text .= Horde_String::pad($key . ': ', $max, ' ', STR_PAD_LEFT) . $val . "\n";
         }
     }
     return $text;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:37,代码来源:Compose.php

示例9: run

 /**
  * Run the module.
  *
  * @param Horde_Cli $cli       The CLI handler.
  * @param mixed     $options   An array of options.
  * @param mixed     $arguments An array of arguments.
  * @param array     &$world    A list of initialized dependencies.
  *
  * @return NULL
  */
 public function run($cli, $options, $arguments, &$world)
 {
     if (!isset($arguments[1])) {
         $action = 'show';
     } else {
         $action = $arguments[1];
     }
     if (!isset($arguments[2])) {
         $folder_name = 'INBOX';
     } else {
         $folder_name = $arguments[2];
     }
     switch ($action) {
         case 'create':
             if (!isset($arguments[3])) {
                 $folder = $world['storage']->getList()->createFolder($folder_name);
             } else {
                 $folder = $world['storage']->getList()->createFolder($folder_name, $arguments[3]);
             }
             $this->_showFolder($folder_name, $world, $cli);
             break;
         case 'rename':
             $folder = $world['storage']->getList()->renameFolder($folder_name, $arguments[3]);
             $this->_showFolder($arguments[3], $world, $cli);
             break;
         case 'delete':
             $folder = $world['storage']->getList()->deleteFolder($folder_name);
             break;
         case 'getacl':
             $acl = $world['storage']->getList()->getQuery(Horde_Kolab_Storage_List::QUERY_ACL)->getAcl($folder_name);
             $cli->writeln($folder_name);
             $cli->writeln(str_repeat('=', strlen($folder_name)));
             $pad = max(array_map('strlen', array_keys($acl))) + 2;
             foreach ($acl as $user => $rights) {
                 $cli->writeln(Horde_String::pad($user . ':', $pad) . $rights);
             }
             break;
         case 'getmyacl':
             $acl = $world['storage']->getList()->getQuery(Horde_Kolab_Storage_List::QUERY_ACL)->getMyAcl($folder_name);
             $cli->writeln('Your rights on ' . $folder_name . ': ' . $acl);
             break;
         case 'setacl':
             $acl = $world['storage']->getList()->getQuery(Horde_Kolab_Storage_List::QUERY_ACL)->setAcl($folder_name, $arguments[3], $arguments[4]);
             break;
         case 'deleteacl':
             $acl = $world['storage']->getList()->getQuery(Horde_Kolab_Storage_List::QUERY_ACL)->deleteAcl($folder_name, $arguments[3]);
             break;
         case 'getdesc':
             $list = $world['storage']->getList();
             $world['storage']->addListQuery($list, Horde_Kolab_Storage_List::QUERY_SHARE);
             $cli->writeln($list->getQuery(Horde_Kolab_Storage_List::QUERY_SHARE)->getDescription($folder_name));
             break;
         case 'setdesc':
             $list = $world['storage']->getList();
             $world['storage']->addListQuery($list, Horde_Kolab_Storage_List::QUERY_SHARE);
             $list->getQuery(Horde_Kolab_Storage_List::QUERY_SHARE)->setDescription($folder_name, $arguments[3]);
             break;
         case 'getshare':
             $list = $world['storage']->getList();
             $world['storage']->addListQuery($list, Horde_Kolab_Storage_List::QUERY_SHARE);
             $parameters = $list->getQuery(Horde_Kolab_Storage_List::QUERY_SHARE)->getParameters($folder_name);
             $pad = max(array_map('strlen', array_keys($parameters))) + 2;
             foreach ($parameters as $key => $value) {
                 $cli->writeln(Horde_String::pad($key . ':', $pad) . $value);
             }
             break;
         case 'show':
             $this->_showFolder($folder_name, $world, $cli);
             break;
         default:
             $cli->message(sprintf(Horde_Kolab_Cli_Translation::t('Action %s not supported!'), $action), 'cli.error');
             break;
     }
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:84,代码来源:Folder.php


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