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


PHP String::truncate方法代码示例

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


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

示例1: getPropertiesPreview

 /**
  * Get a preview of the properties of this widget
  * @return string
  */
 public function getPropertiesPreview()
 {
     $text = $this->getText();
     $text = htmlentities($text->text);
     $text = String::truncate($text, 120);
     $text = nl2br($text);
     return $text;
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:12,代码来源:TextWidget.php

示例2: modifyValue

 /**
  * Truncates the provided value
  * @param string $value Value to truncate
  * @param array $arguments Array with arguments for the truncate function:
  *                         <ul>
  *                         <li>1 (integer): length to truncate (120)</li>
  *                         <li>2 (string) : etc string (...)</li>
  *                         <li>3 (boolean): flag to break words or not (false)</li>
  *                         </ul>
  * @return string
  */
 public function modifyValue($value, array $arguments)
 {
     $length = 120;
     $etc = '...';
     $breakWords = false;
     if (array_key_exists(0, $arguments)) {
         $length = $arguments[0];
     }
     if (array_key_exists(1, $arguments)) {
         $etc = $arguments[1];
     }
     if (array_key_exists(2, $arguments)) {
         $breakWords = Boolean::getBoolean($arguments[2]);
     }
     return String::truncate($value, $length, $etc, $breakWords);
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:27,代码来源:TruncateDataFormatModifier.php

示例3: getNodeHtml

 /**
  * Get the HTML of a node
  * @param joppa\model\Node $node the node to render
  * @param int $defaultNodeId id of the node of the default page
  * @param joppa\model\Node $selectedNode the current node in the ui
  * @param boolean $addUnlocalizedClass Set to true to add the unlocalized class to nodes which are not localized in the current locale
  * @param int $truncateSize number of characters to truncate the name to
  * @return string HTML representation of the node
  */
 private function getNodeHtml(Node $node, $defaultNodeId, $addUnlocalizedClass, Node $selectedNode = null, $truncateSize = 20)
 {
     $isNodeSelected = false;
     if ($selectedNode && $selectedNode->id == $node->id) {
         $isNodeSelected = true;
     }
     $nodeClass = 'node';
     if ($isNodeSelected) {
         $nodeClass .= ' selected';
     }
     if ($addUnlocalizedClass) {
         if ($node->dataLocale != $this->locale) {
             $nodeClass .= ' unlocalized';
         } else {
             $nodeClass .= ' localized';
         }
     }
     if (AjaxTreeController::isNodeCollapsed($node->id)) {
         $nodeClass .= ' closed';
     }
     $html = '<li class="' . $nodeClass . '" id="node_' . $node->id . '">';
     if ($this->nodeTypeFacade->isAvailableInFrontend($node->type)) {
         if ($node->isSecured()) {
             $nodeClass = 'secured' . ucfirst($node->type);
         } else {
             $nodeClass = $node->type;
         }
         if ($node->id == $defaultNodeId) {
             $nodeClass .= 'Default';
         }
         if (!$node->isPublished()) {
             $nodeClass .= 'Hidden';
         }
     } else {
         $nodeClass = $node->type;
     }
     if ($node->children) {
         $html .= '<a href="#" class="toggle"></a>';
     } else {
         $html .= '<span class="toggle"></span>';
     }
     $icon = new Image($this->getIcon($nodeClass));
     $html .= '<div class="handle ' . $nodeClass . '">';
     $html .= $icon->getHtml();
     $html .= '</div>';
     $html .= '<div class="menu">';
     $html .= $this->getAnchorHtml('/node/' . $node->id, String::truncate($node->name, $truncateSize, '...', true, true), false, 'name', null, $node->name);
     $html .= $this->getAnchorHtml('#', ' ', false, 'actionMenuNode', 'nodeActions_' . $node->id);
     //        $html .= $this->getAnchorHtml(' <a href="#" class="actionMenuNode" id="nodeActions_' . $node->id . '" title="' . $node->name . '"></a>';
     //        $html .= ' <a href="#" class="actionMenuNode" id="nodeActions_' . $node->id . '" title="' . $node->name . '"></a>';
     $html .= '<ul class="actions" id="nodeActions_' . $node->id . 'Menu">';
     $addedActions = false;
     foreach ($this->actions as $action) {
         if (!$action->isAvailableForNode($node)) {
             continue;
         }
         $addedActions = true;
         $html .= '<li>';
         $html .= $this->getAnchorHtml('/node/' . $action->getRoute() . '/' . $node->id, $action->getLabel($this->translator), false, $action->getRoute());
         $html .= '</li>';
     }
     $html .= '<li' . ($addedActions ? ' class="separator"' : '') . '>' . $this->getAnchorHtml('/node/edit/' . $node->id, 'button.edit', true, 'edit') . '</li>';
     $html .= '<li>' . $this->getAnchorHtml('/node/copy/' . $node->id, 'joppa.button.copy', true, 'copy') . '</li>';
     $html .= '<li>' . $this->getAnchorHtml('/node/delete/' . $node->id, 'button.delete', true, 'delete confirm') . '</li>';
     $html .= '</ul>';
     $html .= '</div>';
     if ($node->children) {
         $html .= '<ul class="children">';
         foreach ($node->children as $child) {
             $html .= $this->getNodeHtml($child, $defaultNodeId, $addUnlocalizedClass, $selectedNode, $truncateSize - 1);
         }
         $html .= '</ul>';
     }
     $html .= '</li>';
     return $html;
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:85,代码来源:TreeView.php


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