コード例 #1
0
ファイル: FormMacros.php プロジェクト: exesek/nette20login
 /**
  * {label ...} and optionally {/label}
  */
 public function macroLabel(MacroNode $node, $writer)
 {
     $cmd = 'if ($_label = $_form[%node.word]->getLabel()) echo $_label->addAttributes(%node.array)';
     if ($node->isEmpty = substr($node->args, -1) === '/') {
         $node->setArgs(substr($node->args, 0, -1));
         return $writer->write($cmd);
     } else {
         return $writer->write($cmd . '->startTag()');
     }
 }
コード例 #2
0
ファイル: FormMacros.php プロジェクト: svobodni/web
 /**
  * @param \Nette\Latte\MacroNode $node
  * @param \Nette\Latte\PhpWriter $writer
  * @return string
  */
 public function macroFormBegin(MacroNode $node, PhpWriter $writer)
 {
     if ($node->isEmpty = substr($node->args, -1) === '/') {
         $node->setArgs(substr($node->args, 0, -1));
         return $writer->write('$form = $__form = $_form = (is_object(%node.word) ? %node.word : $_control->getComponent(%node.word)); $__form->render(NULL, %node.array);');
     }
     $word = $node->tokenizer->fetchWord();
     $node->isEmpty = in_array($word, array('errors', 'body', 'controls', 'buttons'));
     $node->tokenizer->reset();
     return $writer->write('$form = $__form = $_form = ' . get_called_class() . '::renderFormPart(%node.word, %node.array, get_defined_vars())');
 }
コード例 #3
0
 /**
  * {label} for {input} in {inputlist}
  */
 public function macroLabel(MacroNode $node, $writer)
 {
     if (!$this->inList || $node->args && $node->args !== '/' && strpos($node->args, '=>') === FALSE) {
         return FALSE;
     }
     $cmd = 'echo $_inputlist->getItemLabel($_inputlistKey)->addAttributes(%node.array)';
     if ($node->isEmpty = substr($node->args, -1) === '/') {
         $node->setArgs(substr($node->args, 0, -1));
         return $writer->write($cmd);
     } else {
         return $writer->write($cmd . '->startTag()');
     }
 }
コード例 #4
0
ファイル: TableMacros.php プロジェクト: drahak/tables
    /**
     * Table heading controls
     * @param \Nette\Latte\MacroNode $node
     * @param \Nette\Latte\PhpWriter $writer
     * @return string
     */
    public function macroControls(Latte\MacroNode $node, Latte\PhpWriter $writer)
    {
        $code = '$_column = is_object(%node.word) ? %node.word : $_table[%node.word]; if ($_column->isSortable()) : ?>
		<td>
			<div class="order">
				<a href="<?php echo $_control->link(\'this!\', array(\'order\' => $_column->name, \'sort\' => false)); ?>"><span>Ascending</span></a>
				<a href="<?php echo $_control->link(\'this!\', array(\'order\' => $_column->name, \'sort\' => true)); ?>"><span>Descending</span></a>
			</div>
			<?php echo $_form[$_column->getColumn()]->getControl()->addAttributes(%node.array); ?>
		</td>
		<?php endif;';
        if ($node->isEmpty = substr($node->args, -1) === '/') {
            $node->setArgs(substr($node->args, 0, -1));
        }
        return $writer->write($code);
    }
コード例 #5
0
 public function macroGettext(\Nette\Latte\MacroNode $node, $writer)
 {
     $args = $node->args;
     $prefix = '';
     if (strpos($args, 'np') === 0) {
         $args = substr($args, 2);
         $prefix = "np";
     } elseif (strpos($args, 'n') === 0) {
         $args = substr($args, 1);
         $prefix = "n";
     } elseif (strpos($args, 'p') === 0) {
         $args = substr($args, 1);
         $prefix = "p";
     }
     $node->setArgs($args);
     return $writer->write('echo %modify($template->' . $prefix . 'gettext(%node.args))');
 }
コード例 #6
0
ファイル: nette.min.php プロジェクト: rotten77/xcv
 function macroLabel(MacroNode $node, PhpWriter $writer)
 {
     $cmd = '$_input = is_object(%node.word) ? %node.word : $_form[%node.word]; if ($_label = $_input->getLabel()) echo $_label->addAttributes(%node.array)';
     if ($node->isEmpty = substr($node->args, -1) === '/') {
         $node->setArgs(substr($node->args, 0, -1));
         return $writer->write($cmd);
     } else {
         return $writer->write($cmd . '->startTag()');
     }
 }
コード例 #7
0
ファイル: loader.php プロジェクト: JanTvrdik/NetteExtras
static($compiler);$me->addMacro('form','Nette\Latte\Macros\FormMacros::renderFormBegin($form = $_form = (is_object(%node.word) ? %node.word : $_control[%node.word]), %node.array)','Nette\Latte\Macros\FormMacros::renderFormEnd($_form)');$me->addMacro('label',array($me,'macroLabel'),'?></label><?php');$me->addMacro('input','echo $_form[%node.word]->getControl()->addAttributes(%node.array)',NULL,array($me,'macroAttrInput'));$me->addMacro('formContainer','$_formStack[] = $_form; $formContainer = $_form = $_form[%node.word]','$_form = array_pop($_formStack)');}function
macroLabel(MacroNode$node,PhpWriter$writer){$cmd='if ($_label = $_form[%node.word]->getLabel()) echo $_label->addAttributes(%node.array)';if($node->isEmpty=(substr($node->args,-1)==='/')){$node->setArgs(substr($node->args,0,-1));return$writer->write($cmd);}else{return$writer->write($cmd.'->startTag()');}}function