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


PHP Html::xhtml方法代码示例

本文整理汇总了PHP中Nette\Utils\Html::xhtml方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::xhtml方法的具体用法?PHP Html::xhtml怎么用?PHP Html::xhtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Utils\Html的用法示例。


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

示例1: startup

 private function startup()
 {
     // HTML vs XHTML
     if ($this->isXhtml()) {
         Nette\Utils\Html::$xhtml = TRUE;
     } else {
         Nette\Utils\Html::$xhtml = FALSE;
     }
     // Split more admin users
     if (count($this->fbAdmins) > 0) {
         $this->og['admins'] = implode(', ', $this->fbAdmins);
     }
     // Check auto url
     if ($this->isAutoUrl()) {
         $this->og['url'] = $this->presenter->context->httpRequest->getUrl();
     }
 }
开发者ID:rostenkowski,项目名称:nette-plugins,代码行数:17,代码来源:OpenGraphTags.php

示例2: __construct

 /**
  * Creates template.
  *
  * @param \ApiGen\Generator $generator
  */
 public function __construct(Generator $generator)
 {
     $this->generator = $generator;
     $this->config = $generator->getConfig();
     $that = $this;
     // Output in HTML5
     Nette\Utils\Html::$xhtml = false;
     // FSHL
     $fshl = new FSHL\Highlighter(new FSHL\Output\Html());
     $fshl->setLexer(new FSHL\Lexer\Php());
     // Texy
     $this->texy = new \Texy();
     $this->texy->allowedTags = array_flip($this->config->allowedHtml);
     $this->texy->allowed['list/definition'] = false;
     $this->texy->allowed['phrase/em-alt'] = false;
     $this->texy->allowed['longwords'] = false;
     $this->texy->allowed['typography'] = false;
     $this->texy->linkModule->shorten = false;
     // Highlighting <code>, <pre>
     $this->texy->addHandler('beforeParse', function ($texy, &$text, $singleLine) {
         $text = preg_replace('~<code>(.+?)</code>~', '#code#\\1#/code#', $text);
     });
     $this->texy->registerLinePattern(function ($parser, $matches, $name) use($fshl) {
         return \TexyHtml::el('code', $fshl->highlight($matches[1]));
     }, '~#code#(.+?)#/code#~', 'codeInlineSyntax');
     $this->texy->registerBlockPattern(function ($parser, $matches, $name) use($fshl) {
         if ('code' === $matches[1]) {
             $lines = array_filter(explode("\n", $matches[2]));
             if (!empty($lines)) {
                 $firstLine = array_shift($lines);
                 $indent = '';
                 $li = 0;
                 while (isset($firstLine[$li]) && preg_match('~\\s~', $firstLine[$li])) {
                     foreach ($lines as $line) {
                         if (!isset($line[$li]) || $firstLine[$li] !== $line[$li]) {
                             break 2;
                         }
                     }
                     $indent .= $firstLine[$li++];
                 }
                 if (!empty($indent)) {
                     $matches[2] = str_replace("\n" . $indent, "\n", 0 === strpos($matches[2], $indent) ? substr($matches[2], $li) : $matches[2]);
                 }
             }
             $content = $fshl->highlight($matches[2]);
         } else {
             $content = htmlspecialchars($matches[2]);
         }
         $content = $parser->getTexy()->protect($content, \Texy::CONTENT_BLOCK);
         return \TexyHtml::el('pre', $content);
     }, '~<(code|pre)>(.+?)</\\1>~s', 'codeBlockSyntax');
     // Common operations
     $this->registerHelperLoader('Nette\\Templating\\Helpers::loader');
     // PHP source highlight
     $this->registerHelper('highlightPHP', function ($source, $context) use($that, $fshl) {
         return $that->resolveLink($that->getTypeName($source), $context) ?: $fshl->highlight((string) $source);
     });
     $this->registerHelper('highlightValue', function ($definition, $context) use($that) {
         return $that->highlightPHP(preg_replace('~^(?:[ ]{4}|\\t)~m', '', $definition), $context);
     });
     // Urls
     $this->registerHelper('packageUrl', new Nette\Callback($this, 'getPackageUrl'));
     $this->registerHelper('namespaceUrl', new Nette\Callback($this, 'getNamespaceUrl'));
     $this->registerHelper('groupUrl', new Nette\Callback($this, 'getGroupUrl'));
     $this->registerHelper('classUrl', new Nette\Callback($this, 'getClassUrl'));
     $this->registerHelper('methodUrl', new Nette\Callback($this, 'getMethodUrl'));
     $this->registerHelper('propertyUrl', new Nette\Callback($this, 'getPropertyUrl'));
     $this->registerHelper('constantUrl', new Nette\Callback($this, 'getConstantUrl'));
     $this->registerHelper('functionUrl', new Nette\Callback($this, 'getFunctionUrl'));
     $this->registerHelper('elementUrl', new Nette\Callback($this, 'getElementUrl'));
     $this->registerHelper('sourceUrl', new Nette\Callback($this, 'getSourceUrl'));
     $this->registerHelper('manualUrl', new Nette\Callback($this, 'getManualUrl'));
     // Packages & namespaces
     $this->registerHelper('packageLinks', new Nette\Callback($this, 'getPackageLinks'));
     $this->registerHelper('namespaceLinks', new Nette\Callback($this, 'getNamespaceLinks'));
     $this->registerHelper('subgroupName', function ($groupName) {
         if ($pos = strrpos($groupName, '\\')) {
             return substr($groupName, $pos + 1);
         }
         return $groupName;
     });
     // Types
     $this->registerHelper('typeLinks', new Nette\Callback($this, 'getTypeLinks'));
     // Docblock descriptions
     $this->registerHelper('description', function ($annotation, $context) use($that) {
         $description = trim(strpbrk($annotation, "\n\r\t \$"));
         if ($context instanceof ReflectionParameter) {
             $description = preg_replace('~^(\\$' . $context->getName() . '(?:,\\.{3})?)(\\s+|$)~i', '\\2', $description, 1);
             $context = $context->getDeclaringFunction();
         }
         return $that->doc($description, $context);
     });
     $this->registerHelper('shortDescription', function ($element, $block = false) use($that) {
         return $that->doc($element->getShortDescription(), $element, $block);
     });
//.........这里部分代码省略.........
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:101,代码来源:Template.php

示例3: __construct

 /**
  * Creates template.
  *
  * @param \ApiGen\Generator $generator
  * @param \ApiGen\ISourceCodeHighlighter $highlighter
  */
 public function __construct(Generator $generator, ISourceCodeHighlighter $highlighter)
 {
     $this->generator = $generator;
     $this->config = $generator->getConfig();
     // @todo DI
     $this->markup = new MarkdownMarkup($this->config->allowedHtml, $highlighter);
     $that = $this;
     // Output in HTML5
     Nette\Utils\Html::$xhtml = false;
     // Common operations
     $this->registerHelperLoader('Nette\\Templating\\Helpers::loader');
     // PHP source highlight
     $this->registerHelper('highlightPHP', function ($source, $context) use($that, $highlighter) {
         return $that->resolveLink($that->getTypeName($source), $context) ?: $highlighter->highlight((string) $source);
     });
     $this->registerHelper('highlightValue', function ($definition, $context) use($that) {
         return $that->highlightPHP(preg_replace('~^(?:[ ]{4}|\\t)~m', '', $definition), $context);
     });
     // Urls
     $this->registerHelper('packageUrl', new Nette\Callback($this, 'getPackageUrl'));
     $this->registerHelper('namespaceUrl', new Nette\Callback($this, 'getNamespaceUrl'));
     $this->registerHelper('groupUrl', new Nette\Callback($this, 'getGroupUrl'));
     $this->registerHelper('classUrl', new Nette\Callback($this, 'getClassUrl'));
     $this->registerHelper('methodUrl', new Nette\Callback($this, 'getMethodUrl'));
     $this->registerHelper('propertyUrl', new Nette\Callback($this, 'getPropertyUrl'));
     $this->registerHelper('constantUrl', new Nette\Callback($this, 'getConstantUrl'));
     $this->registerHelper('functionUrl', new Nette\Callback($this, 'getFunctionUrl'));
     $this->registerHelper('elementUrl', new Nette\Callback($this, 'getElementUrl'));
     $this->registerHelper('sourceUrl', new Nette\Callback($this, 'getSourceUrl'));
     $this->registerHelper('manualUrl', new Nette\Callback($this, 'getManualUrl'));
     // Packages & namespaces
     $this->registerHelper('packageLinks', new Nette\Callback($this, 'getPackageLinks'));
     $this->registerHelper('namespaceLinks', new Nette\Callback($this, 'getNamespaceLinks'));
     $this->registerHelper('subgroupName', function ($groupName) {
         if ($pos = strrpos($groupName, '\\')) {
             return substr($groupName, $pos + 1);
         }
         return $groupName;
     });
     // Types
     $this->registerHelper('typeLinks', new Nette\Callback($this, 'getTypeLinks'));
     // Docblock descriptions
     $this->registerHelper('description', function ($annotation, $context) use($that) {
         $description = trim(strpbrk($annotation, "\n\r\t \$")) ?: $annotation;
         return $that->doc($description, $context);
     });
     $this->registerHelper('shortDescription', function ($element, $block = false) use($that) {
         return $that->doc($element->getShortDescription(), $element, $block);
     });
     $this->registerHelper('longDescription', function ($element) use($that) {
         $long = $element->getLongDescription();
         // Merge lines
         $long = preg_replace_callback('~(?:<(code|pre)>.+?</\\1>)|([^<]*)~s', function ($matches) {
             return !empty($matches[2]) ? preg_replace('~\\n(?:\\t|[ ])+~', ' ', $matches[2]) : $matches[0];
         }, $long);
         return $that->doc($long, $element, true);
     });
     // Individual annotations processing
     $this->registerHelper('annotation', function ($value, $name, Reflection\ReflectionElement $context) use($that, $generator) {
         switch ($name) {
             case 'return':
             case 'throws':
                 // TODO: Needs fix - This produces duplicate throws statements
                 //					$description = $that->description($value, $context);
                 //					return sprintf('<code>%s</code>%s', $that->getTypeLinks($value, $context), $description ? '<br>' . $description : '');
                 return $that->getTypeLinks($value, $context);
             case 'license':
                 list($url, $description) = $that->split($value);
                 return $that->link($url, $description ?: $url);
             case 'link':
                 list($url, $description) = $that->split($value);
                 if (Nette\Utils\Validators::isUrl($url)) {
                     return $that->link($url, $description ?: $url);
                 }
                 break;
             case 'see':
                 $doc = array();
                 foreach (preg_split('~\\s*,\\s*~', $value) as $link) {
                     if (null !== $generator->resolveElement($link, $context)) {
                         $doc[] = sprintf('<code>%s</code>', $that->getTypeLinks($link, $context));
                     } else {
                         $doc[] = $that->doc($link, $context);
                     }
                 }
                 return implode(', ', $doc);
             case 'uses':
             case 'usedby':
                 list($link, $description) = $that->split($value);
                 $separator = $context instanceof Reflection\ReflectionClass || !$description ? ' ' : '<br>';
                 if (null !== $generator->resolveElement($link, $context)) {
                     return sprintf('<code>%s</code>%s%s', $that->getTypeLinks($link, $context), $separator, $description);
                 }
                 break;
             default:
//.........这里部分代码省略.........
开发者ID:sirone,项目名称:apigen,代码行数:101,代码来源:Template.php


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