예제 #1
0
 function render(View $view, array $arguments)
 {
     if (count($arguments) !== 1) {
         throw new \InvalidArgumentException('Exactly one view must be specified');
     }
     return $view->getVariable($arguments[0])->render();
 }
예제 #2
0
 public function __construct(InputDirective $inputDirective, ViewSettings $viewSettings)
 {
     parent::__construct($viewSettings);
     $inputDirective->registerInput($this, self::TV_LOGIN);
     $inputDirective->registerInput($this, self::TV_PASSWORD);
     $inputDirective->registerInput($this, self::TV_USERNAME);
     $this->variables[self::TV_REGISTER_URL] = Router::REGISTER;
 }
예제 #3
0
 public function __construct(InputDirective $inputDirective, ViewSettings $viewSettings)
 {
     parent::__construct($viewSettings);
     $inputDirective->registerInput($this, self::TV_REGISTER);
     $inputDirective->registerInput($this, self::TV_PASSWORD);
     $inputDirective->registerInput($this, self::TV_PASSWORD2);
     $inputDirective->registerInput($this, self::TV_USERNAME);
 }
예제 #4
0
 function render(View $view, array $arguments)
 {
     if (count($arguments) !== 2) {
         throw new \InvalidArgumentException('One variable name and expression name must be specified');
     }
     $name = $arguments[0];
     $value = $arguments[1];
     /** @var View $definedIn */
     $definedIn = null;
     for ($current = $view; $definedIn === null && $current !== null; $current = $current->getParent()) {
         if ($current->isDefined($name)) {
             $definedIn = $current;
         }
     }
     if ($definedIn !== null) {
         $definedIn->setVariable($name, $value);
     } else {
         $view->setVariable($name, $value);
     }
 }
예제 #5
0
 function render(View $view, array $arguments)
 {
     if (count($arguments) !== 2) {
         throw new \InvalidArgumentException('Exactly two arguments must be specified');
     }
     $glue = $arguments[1];
     $pieces = $arguments[0];
     if (is_string($pieces)) {
         $pieces = $view->getVariable($pieces);
     }
     $renderedPieces = [];
     foreach ($pieces as $piece) {
         if ($piece instanceof View) {
             $renderedPieces[] = $piece->render();
         } else {
             $renderedPieces[] = $piece;
         }
     }
     return join($glue, $renderedPieces);
 }
예제 #6
0
 function render(View $view, array $arguments)
 {
     $flags = [];
     if (count($arguments) === 2) {
         if ($arguments[1] !== 'checkbox') {
             throw new \InvalidArgumentException("Unsupported flag '{$arguments['1']}'");
         }
         $flags[] = $arguments[1];
     } elseif (count($arguments) !== 1) {
         throw new \InvalidArgumentException('Exactly one variable name must be specified,' . 'with one optional flag');
     }
     $inputName = $arguments[0];
     if (!in_array($inputName, $this->registeredInputs)) {
         throw new \Exception("InputDirective {$inputName} have not been registered");
     }
     if (isset($_POST[$inputName])) {
         if (in_array('checkbox', $flags) && $_POST[$inputName] === 'on') {
             return 'name="' . $inputName . '" checked';
         }
         return 'name="' . $inputName . '" value="' . $view->getVariable($inputName) . '"';
     }
     return 'name="' . $inputName . '"';
 }
예제 #7
0
 public function __construct(Auth $auth, ClassDiagramView $classDiagramView, ViewSettings $viewSettings)
 {
     parent::__construct($viewSettings);
     $this->variables = [self::TV_DIAGRAM_VIEW => $classDiagramView, self::TV_ERRORS => [], self::TV_LOGGED_IN => $auth->isLoggedIn(), self::TV_FILE_GV => FileView::RV_UMLS, self::TV_FILE_URL => Router::FILE];
 }
 /**
  * @param View $view       The View this directive is rendered in.
  * @param array $arguments All arguments specified in the template.
  * @throws \InvalidArgumentException If more or less than one argument specified.
  * @return string Return a rendered version of this directive.
  */
 function render(View $view, array $arguments)
 {
     $this->view = $view;
     $this->expression = join(' ', $arguments);
     $this->calculate(self::PRIORITY_MATH);
     $this->calculate(self::MATH);
     $this->check(self::BOOLEAN_EXPRESSION);
     $this->check(self::LOGIC_EXPRESSION);
     if (preg_match(self::NEGATION, $this->expression, $match)) {
         $result = !$view->getVariable($match[1]) ? 1 : 0;
         $this->expression = str_replace($match[0], $result, $this->expression);
     }
     $this->expression = $view->getVariable($this->expression);
     $this->expression = $this->htmlEscape($this->expression);
     return $this->expression;
 }
예제 #9
0
 public function __construct(ViewSettings $settings)
 {
     parent::__construct($settings);
     $this->template = 'not-found.html';
 }