示例#1
0
 /**
  * {element name[:method] [key]}
  */
 public function macroElement(MacroNode $node, PhpWriter $writer)
 {
     $rawName = $node->tokenizer->fetchWord();
     if ($rawName === FALSE) {
         throw new CompileException("Missing element type in {element}");
     }
     $rawName = explode(':', $rawName, 2);
     $name = $writer->formatWord($rawName[0]);
     $method = isset($rawName[1]) ? ucfirst($rawName[1]) : '';
     $method = Strings::match($method, '#^\\w*$#') ? "render{$method}" : "{\"render{$method}\"}";
     $idRaw = $node->tokenizer->fetchWord();
     $param = $writer->formatArray();
     if (!Strings::contains($node->args, '=>')) {
         $param = substr($param, 6, -1);
         // removes array()
     }
     if (!$idRaw) {
         throw new CompileException("Missing element title in {element}");
     }
     if (substr($idRaw, 0, 1) !== '$') {
         $id = Helpers::encodeName($idRaw);
     } else {
         $id = $idRaw;
     }
     return '$_ctrl = $_presenter->getComponent(\\CmsModule\\Content\\ElementManager::ELEMENT_PREFIX . ' . '"' . $id . '"' . ' . \'_\' . ' . $name . '); ' . '$_ctrl->setName("' . trim($idRaw, '"\'') . '");' . 'if ($presenter->isPanelOpened() && (!isset($__element) || !$__element)) { echo "<span id=\\"' . \CmsModule\Content\ElementManager::ELEMENT_PREFIX . (substr($id, 0, 1) === '$' ? '{' . $id . '}' : $id) . '_' . $rawName[0] . '\\" style=\\"display: inline-block; min-width: 50px; min-height: 25px;\\" class=\\"venne-element-container\\" data-venne-element-id=\\"' . trim($id, '"\'') . '\\" data-venne-element-name=\\"' . $rawName[0] . '\\" data-venne-element-route=\\"" . $presenter->route->id . "\\" data-venne-element-language=\\"" . $presenter->language->id . "\\" data-venne-element-buttons=\\"" . (str_replace(\'"\', "\'", json_encode($_ctrl->getViews()))) . "\\">"; }' . 'if ($_ctrl instanceof Nette\\Application\\UI\\IRenderable) $_ctrl->validateControl(); ' . "\$_ctrl->{$method}({$param});" . 'if ($presenter->isPanelOpened()) { echo "</span>"; }';
 }
示例#2
0
 /**
  * @param $name
  */
 public function setName($name)
 {
     $this->name = Helpers::encodeName($name);
     $this->nameRaw = $name;
 }
示例#3
0
 /**
  * @param $class
  * @param $name
  * @param LayoutEntity $layout
  * @param PageEntity $page
  * @param RouteEntity $route
  * @param LanguageEntity $language
  */
 public function __construct($class, $name, LayoutEntity $layout = NULL, PageEntity $page = NULL, RouteEntity $route = NULL, LanguageEntity $language = NULL)
 {
     $this->class = $class;
     $this->nameRaw = $name;
     $this->name = Helpers::encodeName($name);
     $this->route = $route;
     $this->page = $page;
     $this->layout = $layout;
     $this->language = $language;
 }