本文整理汇总了PHP中Horde_String::abbreviate方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_String::abbreviate方法的具体用法?PHP Horde_String::abbreviate怎么用?PHP Horde_String::abbreviate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_String
的用法示例。
在下文中一共展示了Horde_String::abbreviate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: _buildTree
/**
*/
protected function _buildTree($node_id)
{
if (isset($this->_filter[$node_id])) {
return '';
}
$node =& $this->_nodes[$node_id];
if ($abbrev = $this->getOption('abbrev')) {
$orig_label = $node['label'];
$node['label'] = Horde_String::abbreviate($node['orig_label'], $abbrev - $node['indent'] * 2);
} else {
$orig_label = null;
}
/* Ignore container elements. */
if (!$this->getOption('container_select') && !empty($node['container'])) {
if (!empty($node['vfolder'])) {
return '';
}
$node_id = '';
$this->_nodes[$node_id] = $node;
}
$out = parent::_buildTree($node_id);
if ($orig_label) {
$node['label'] = $orig_label;
}
return $out;
}
示例3: sentMailList
/**
* AJAX action: Generate the sent-mail select list.
*
* Variables used: NONE
*
* @return object An object with the following properties:
* - flist: (array) TODO
*/
public function sentMailList()
{
global $injector;
/* Check to make sure the sent-mail mailboxes are created; they need
* to exist to show up in drop-down list. */
$identity = $injector->getInstance('IMP_Identity');
foreach ($identity->getAllSentmail() as $mbox) {
$mbox->create();
}
$flist = array();
$iterator = new IMP_Ftree_IteratorFilter($injector->getInstance('IMP_Ftree'));
$iterator->add($iterator::NONIMAP);
foreach ($iterator as $val) {
$mbox_ob = $val->mbox_ob;
$tmp = array('f' => $mbox_ob->display, 'l' => Horde_String::abbreviate(str_repeat(' ', 2 * $val->level) . $mbox_ob->basename, 30), 'v' => $val->container ? '' : $mbox_ob->form_to);
if ($tmp['f'] == $tmp['v']) {
unset($tmp['f']);
}
$flist[] = $tmp;
}
$ret = new stdClass();
$ret->flist = $flist;
return $ret;
}
示例4: createTree
/**
* Creates a Horde_Tree representation of the current tree.
*
* @param string|Horde_Tree $name Either the tree name, or a Horde_Tree
* object to add nodes to.
* @param array $opts Additional options:
* - basename: (boolean) Use raw basename instead of abbreviated label?
* DEFAULT: false
* - checkbox: (boolean) Display checkboxes?
* DEFAULT: false
* - editvfolder: (boolean) Display vfolder edit links?
* DEFAULT: false
* - iterator: (Iterator) Tree iterator to use.
* DEFAULT: Base iterator.
* - open: (boolean) Force child mailboxes to this status.
* DEFAULT: null
* - parent: (string) The parent object of the current level.
* DEFAULT: null (add to base level)
* - poll_info: (boolean) Include poll information in output?
* DEFAULT: false
* - render_params: (array) List of params to pass to renderer if
* auto-creating.
* DEFAULT: 'alternate', 'lines', and 'lines_base'
* are passed in with true values.
* - render_type: (string) The renderer name.
* DEFAULT: Javascript
*
* @return Horde_Tree The tree object.
*/
public function createTree($name, array $opts = array())
{
global $injector, $registry;
$opts = array_merge(array('parent' => null, 'render_params' => array(), 'render_type' => 'Javascript'), $opts);
$view = $registry->getView();
if ($name instanceof Horde_Tree_Renderer_Base) {
$tree = $name;
$parent = $opts['parent'];
} else {
$tree = $injector->getInstance('Horde_Core_Factory_Tree')->create($name, $opts['render_type'], array_merge(array('alternate' => true, 'lines' => true, 'lines_base' => true, 'nosession' => true), $opts['render_params']));
$parent = null;
}
$iterator = empty($opts['iterator']) ? new IMP_Ftree_IteratorFilter($this) : $opts['iterator'];
foreach ($iterator as $val) {
$after = '';
$elt_parent = null;
$mbox_ob = $val->mbox_ob;
$params = array();
switch ($opts['render_type']) {
case 'IMP_Tree_Flist':
if ($mbox_ob->vfolder_container) {
continue 2;
}
$is_open = true;
$label = $params['orig_label'] = empty($opts['basename']) ? $mbox_ob->abbrev_label : $mbox_ob->basename;
break;
case 'IMP_Tree_Jquerymobile':
$is_open = true;
$label = $mbox_ob->display_html;
$icon = $mbox_ob->icon;
$params['icon'] = $icon->icon;
$params['special'] = $mbox_ob->inbox || $mbox_ob->special;
$params['class'] = 'imp-folder';
$params['urlattributes'] = array('id' => 'imp-mailbox-' . $mbox_ob->form_to);
/* Force to flat tree so that non-polled parents don't cause
* polled children to be skipped by renderer (see Bug
* #11238). */
$elt_parent = $this[self::BASE_ELT];
break;
case 'IMP_Tree_Simplehtml':
$is_open = $val->open;
if ($tree->shouldToggle($mbox_ob->form_to)) {
if ($is_open) {
$this->collapse($val);
} else {
$this->expand($val);
}
$is_open = !$is_open;
}
$label = htmlspecialchars(Horde_String::abbreviate($mbox_ob->abbrev_label, 30 - $val->level * 2));
break;
case 'Javascript':
$is_open = $val->open;
$label = empty($opts['basename']) ? htmlspecialchars($mbox_ob->abbrev_label) : htmlspecialchars($mbox_ob->basename);
$icon = $mbox_ob->icon;
$params['icon'] = $icon->icon;
$params['iconopen'] = $icon->iconopen;
break;
}
if (!empty($opts['poll_info']) && $val->polled) {
$poll_info = $mbox_ob->poll_info;
if ($poll_info->unseen) {
switch ($opts['render_type']) {
case 'IMP_Tree_Jquerymobile':
$after = $poll_info->unseen;
break;
default:
$label = '<strong>' . $label . '</strong> (' . $poll_info->unseen . ')';
}
}
}
//.........这里部分代码省略.........