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


PHP Latte\PhpWriter类代码示例

本文整理汇总了PHP中Latte\PhpWriter的典型用法代码示例。如果您正苦于以下问题:PHP PhpWriter类的具体用法?PHP PhpWriter怎么用?PHP PhpWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: macroIfCurrent

 /**
  * {ifCurrent destination [,] [params]}
  */
 public function macroIfCurrent(MacroNode $node, PhpWriter $writer)
 {
     if ($node->modifiers) {
         throw new CompileException('Modifiers are not allowed here.');
     }
     return $writer->write($node->args ? 'if ($_presenter->isLinkCurrent(%node.word, %node.array?)) {' : 'if ($_presenter->getLastCreatedRequestFlag("current")) {');
 }
开发者ID:TomasVotruba,项目名称:application,代码行数:10,代码来源:UIMacros.php

示例2: macroSecured

 public function macroSecured(Latte\MacroNode $node, Latte\PhpWriter $writer)
 {
     if ($node->prefix === $node::PREFIX_TAG) {
         return $writer->write($node->htmlNode->closing ? 'if(array_pop($_l->secured)){' : 'if($_l->secured[] = $acl->isUserAllowedTo(%node.args)) {');
     }
     return $writer->write('if ($acl->isUserAllowedTo(%node.args)) {');
 }
开发者ID:zaxcms,项目名称:framework,代码行数:7,代码来源:LattePermission.php

示例3: modify

 /**
  * @param MacroNode $node
  * @param PhpWriter $writer
  * @param string $else
  * @param bool $comma
  * @return string
  */
 private function modify(MacroNode $node, PhpWriter $writer, $else = '', $comma = TRUE)
 {
     if (!$node->modifiers) {
         return $else;
     }
     return $writer->write(($comma ? ', ' : '') . 'function ($s, $type) { $_fi = new LR\\FilterInfo($type); return %modifyContent($s); }');
 }
开发者ID:webchemistry,项目名称:component-macro,代码行数:14,代码来源:ComponentMacro.php

示例4: macroSrc

 public function macroSrc(PhpWriter $writer)
 {
     $code = self::getCode('%node.array');
     // in macro must go result on output
     $code[] = 'echo %escape(%modify($link));';
     return $writer->write(implode('', $code));
 }
开发者ID:lawondyss,项目名称:imager,代码行数:7,代码来源:Macro.php

示例5: extractFile

 /**
  * Extracts translation messages from a file to the catalogue.
  *
  * @param string           $file The path to look into
  * @param MessageCatalogue $catalogue The catalogue
  */
 public function extractFile($file, MessageCatalogue $catalogue)
 {
     $buffer = NULL;
     $parser = new Parser();
     $parser->shortNoEscape = TRUE;
     foreach ($tokens = $parser->parse(file_get_contents($file)) as $token) {
         if ($token->type !== $token::MACRO_TAG || !in_array($token->name, array('_', '/_'), TRUE)) {
             if ($buffer !== NULL) {
                 $buffer .= $token->text;
             }
             continue;
         }
         if ($token->name === '/_') {
             $catalogue->set(($this->prefix ? $this->prefix . '.' : '') . $buffer, $buffer);
             $buffer = NULL;
         } elseif ($token->name === '_' && empty($token->value)) {
             $buffer = '';
         } else {
             $args = new MacroTokens($token->value);
             $writer = new PhpWriter($args, $token->modifiers);
             $message = $writer->write('%node.word');
             if (in_array(substr(trim($message), 0, 1), array('"', '\''), TRUE)) {
                 $message = substr(trim($message), 1, -1);
             }
             $catalogue->set(($this->prefix ? $this->prefix . '.' : '') . $message, $message);
         }
     }
 }
开发者ID:tomasstrejcek,项目名称:Translation,代码行数:34,代码来源:LatteExtractor.php

示例6: macroPhone

 /**
  * @param MacroNode $node
  * @param PhpWriter $writer
  *
  * @return string
  *
  * @throws Latte\CompileException
  */
 public function macroPhone(MacroNode $node, PhpWriter $writer)
 {
     $arguments = self::prepareMacroArguments($node->args);
     if ($arguments['phone'] === NULL) {
         throw new Latte\CompileException("Please provide phone number.");
     }
     return $writer->write('echo %escape($template->getPhoneNumberService()->format("' . $arguments['phone'] . '", "' . $arguments['country'] . '", ' . $arguments['format'] . '))');
 }
开发者ID:iPublikuj,项目名称:phone,代码行数:16,代码来源:Macros.php

示例7: macroSet

 public function macroSet(MacroNode $node, PhpWriter $writer)
 {
     $parts = Strings::replace($node->args, '~(\\s*(=>|=)\\s*|\\s+)~', '~~~', 1);
     $parts = Strings::split($parts, '/~~~/');
     $variable = $parts[0];
     $rest = $parts[1];
     return $writer->write($variable . ' = %modify(' . $rest . ')');
 }
开发者ID:manGoweb,项目名称:MangoPressTemplating,代码行数:8,代码来源:MangoPressTemplatingMacroSet.php

示例8: macroImgLink

    /**
     * {imgLink $img [type]}
     * @param Latte\MacroNode $node
     * @param Latte\PhpWriter $writer
     * @return string
     */
    public function macroImgLink(Latte\MacroNode $node, Latte\PhpWriter $writer)
    {
        list($img, $type) = $this->getImageFromNode($node);
        return '
			$args = [' . ($type ? "'type' => '{$type}', " : NULL) . "'storage' => " . '$imageStorage' . ($node->args ? ', ' . $writer->formatArgs() : NULL) . '];
			echo ' . get_class($this) . '::imgLink(' . $img . ', $args);
		';
    }
开发者ID:harmim,项目名称:images,代码行数:14,代码来源:Macros.php

示例9: macroRowCol

 public function macroRowCol(MacroNode $node, PhpWriter $writer)
 {
     $name = $node->tokenizer->fetchWord();
     if ($name === false) {
         throw new CompileException("Missing Column name in {{$node->name}}.");
     }
     $node->tokenizer->reset();
     return $writer->write("\n            \$rowClassName = 'row';\n            \$args = %node.array;\n            if (array_key_exists('row', \$args)) {\n                \$rowClassName = \$args['row'];\n            }\n            \n            echo '<div class=\"' . \$rowClassName . '\">';\n            echo '<div class=\"' .%node.word. '\">';\n        ");
 }
开发者ID:blitzik,项目名称:CMS,代码行数:9,代码来源:GridMacros.php

示例10: attrImg

 /**
  * @param Latte\MacroNode $node
  * @param Latte\PhpWriter $writer
  * @return string
  */
 public function attrImg(Latte\MacroNode $node, Latte\PhpWriter $writer)
 {
     if ($node->htmlNode->name === 'a') {
         $attr = 'href=';
     } else {
         $attr = 'src=';
     }
     return $writer->write('echo \' ' . $attr . '"\' . $imageStorage->get(%node.args)->getLink() . \'"\'');
 }
开发者ID:webchemistry,项目名称:images,代码行数:14,代码来源:Macros.php

示例11: macroTranslate

 /**
  * Add support of placeholder replacement into the standart translator macro
  *
  * @param MacroNode $node
  * @param PhpWriter $writer
  * @return strings
  */
 public function macroTranslate(MacroNode $node, PhpWriter $writer)
 {
     if ($node->closing) {
         return $writer->write('echo %modify($template->translate(ob_get_clean()))');
     } elseif ($node->isEmpty = $node->args !== '') {
         return $writer->write('echo %modify(Nedryse\\Latte\\Macros\\TemplateMacroSet::template(call_user_func_array(array($template, \'translate\'), array_merge(array(%node.word), $_args = ((is_array(current($_args = %node.array)) === TRUE) ? current($_args) : $_args))), array_merge($template->getParameters(), get_defined_vars(), $_args)))');
     } else {
         return 'ob_start()';
     }
 }
开发者ID:nedryse,项目名称:latte-template-macroset,代码行数:17,代码来源:TemplateMacroSet.php

示例12: macroIfNotEnabled

 /**
  * {ifEnabled ...}
  */
 public function macroIfNotEnabled(MacroNode $node, PhpWriter $writer)
 {
     if ($node->data->capture = $node->args === '') {
         return 'ob_start()';
     }
     if ($node->prefix === $node::PREFIX_TAG) {
         return $writer->write($node->htmlNode->closing ? 'if (array_pop($_l->ifs)) {' : 'if ($_l->ifs[] = (%node.args)) {');
     }
     return $writer->write('if (!call_user_func($this->filters->enabled, %node.word, %node.array?)) {');
 }
开发者ID:bazo,项目名称:nette-features-extension,代码行数:13,代码来源:FeaturesMacros.php

示例13: macroInput

 /**
  * {input ...}
  */
 public function macroInput(MacroNode $node, PhpWriter $writer)
 {
     $class = get_class($this);
     $words = $node->tokenizer->fetchWords();
     if (!$words) {
         throw new CompileException("Missing name in {{$node->name}}.");
     }
     $name = array_shift($words);
     return $writer->write(($name[0] === '$' ? '$_input = is_object(%0.word) ? %0.word : $_form[%0.word];' : '$_input = $_form[%0.word];') . 'echo ' . $class . '::input($_input->%1.raw->addAttributes(%node.array), $_input)', $name, $words ? 'getControlPart(' . implode(', ', array_map(array($writer, 'formatWord'), $words)) . ')' : 'getControl()');
 }
开发者ID:racinmat,项目名称:forms,代码行数:13,代码来源:BaseInputMacros.php

示例14: macroCaption

 /**
  * Render button caption
  * @author Pavel Železný <info@pavelzelezny.cz>
  * @param \Latte\MacroNode $node
  * @param \Latte\PhpWriter $writer
  * @return string
  */
 public function macroCaption(MacroNode $node, PhpWriter $writer)
 {
     if ($node->args !== '') {
         $code = '$_input = (is_object(%node.word) ? %node.word : $_form[%node.word]);';
         $code .= 'echo $_input->getControl()->caption;';
         $code .= 'unset($_input);';
     } else {
         $code = 'echo isset($_buttonCaption) ? $_buttonCaption : NULL;';
     }
     return $writer->write($code);
 }
开发者ID:mike227,项目名称:n-forms,代码行数:18,代码来源:ButtonMacros.php

示例15: macroEditrouble

 /**
  * @param MacroNode $node
  * @param PhpWriter $writer
  * @throws CompileException
  */
 public function macroEditrouble(MacroNode $node, PhpWriter $writer)
 {
     $name = $node->tokenizer->fetchWord();
     if ($name === false) {
         throw new CompileException("Missing editrouble name in {{$node->name}}.");
     }
     $args = $writer->write('%node.args');
     $attrs = " data-editrouble='\" . json_encode([" . ($args ? $args . ',' : '') . "'name' => \"" . $name . "\"]) . \"'";
     preg_match('#(^.*?>)(.*)(<.*\\z)#s', $node->content, $parts);
     $node->content = '<?php echo \'' . substr($parts[1], 0, -1) . '\' . ' . '($_presenter->editroubleConnector->checkPermission() ? ' . '"' . $attrs . '" : \'\') . \'>\'; ' . $writer->write('echo $_presenter->editroubleConnector->getContent("' . $name . '", [%node.args])') . ' ?>' . $parts[3];
 }
开发者ID:FreezyBee,项目名称:Editrouble,代码行数:16,代码来源:Macros.php


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