當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PhpWriter::write方法代碼示例

本文整理匯總了PHP中Latte\PhpWriter::write方法的典型用法代碼示例。如果您正苦於以下問題:PHP PhpWriter::write方法的具體用法?PHP PhpWriter::write怎麽用?PHP PhpWriter::write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Latte\PhpWriter的用法示例。


在下文中一共展示了PhpWriter::write方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: macroLabel

 public function macroLabel(Latte\MacroNode $node, Latte\PhpWriter $writer)
 {
     while ($node->parentNode) {
         if ($node->parentNode->name == 'gpspicker') {
             $cmd = 'if ($_label = $_gpspicker->getPartialLabel(%node.word)) 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()');
             }
         }
         $node = $node->parentNode;
     }
     throw new CompileException('{gpspicker:label} can be used only within {gpspicker} macro.');
 }
開發者ID:impala23,項目名稱:nette-forms-gpspicker,代碼行數:16,代碼來源:GpsPickerMacros.php

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: macroVersion

 /**
  * generates random number for front assets versing
  */
 public function macroVersion(MacroNode $node, PhpWriter $writer)
 {
     $length = 10;
     $word = $node->tokenizer->fetchWord();
     if (is_numeric($word)) {
         $length = (int) $word;
     }
     return $writer->write(' ?>?' . Random::generate($length) . '<?php ');
 }
開發者ID:janlanger,項目名稱:nette-skeleton,代碼行數:12,代碼來源:UIMacros.php

示例13: 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

示例14: 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

示例15: 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


注:本文中的Latte\PhpWriter::write方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。