/** * 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; }
/** * 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); }
/** * 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; }