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


PHP Requirements::includeInHTML方法代码示例

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


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

示例1: testArgsInUrls

 function testArgsInUrls()
 {
     // Clear previous requirements
     Requirements::clear();
     // clearing all previously generated requirements (just in case)
     Requirements::clear_combined_files();
     Requirements::delete_combined_files('RequirementsTest_bc.js');
     Requirements::javascript(SAPPHIRE_DIR . '/tests/forms/RequirementsTest_a.js?test=1&test=2&test=3');
     Requirements::css(SAPPHIRE_DIR . '/tests/forms/RequirementsTest_a.css?test=1&test=2&test=3');
     $html = Requirements::includeInHTML(false, self::$html_template);
     /* Javascript has correct path */
     $this->assertTrue((bool) preg_match('/src=".*\\/RequirementsTest_a\\.js\\?m=\\d\\d+&test=1&test=2&test=3/', $html), 'javascript has correct path');
     /* CSS has correct path */
     $this->assertTrue((bool) preg_match('/href=".*\\/RequirementsTest_a\\.css\\?m=\\d\\d+&test=1&test=2&test=3/', $html), 'css has correct path');
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:15,代码来源:RequirementsTest.php

示例2: process

 /**
  * The process() method handles the "meat" of the template processing.
  * It takes care of caching the output (via {@link SS_Cache}),
  * as well as replacing the special "$Content" and "$Layout"
  * placeholders with their respective subtemplates.
  * The method injects extra HTML in the header via {@link Requirements::includeInHTML()}.
  * 
  * Note: You can call this method indirectly by {@link ViewableData->renderWith()}.
  * 
  * @param ViewableData $item
  * @param SS_Cache $cache Optional cache backend
  * @return String Parsed template output.
  */
 public function process($item, $arguments = null)
 {
     SSViewer::$topLevel[] = $item;
     if ($arguments && $arguments instanceof Zend_Cache_Core) {
         Deprecation::notice('3.0', 'Use setPartialCacheStore to override the partial cache storage backend, ' . 'the second argument to process is now an array of variables.');
         $this->setPartialCacheStore($arguments);
         $arguments = null;
     }
     if (isset($this->chosenTemplates['main'])) {
         $template = $this->chosenTemplates['main'];
     } else {
         $keys = array_keys($this->chosenTemplates);
         $key = reset($keys);
         $template = $this->chosenTemplates[$key];
     }
     $cacheFile = TEMP_FOLDER . "/.cache" . str_replace(array('\\', '/', ':'), '.', Director::makeRelative(realpath($template)));
     $lastEdited = filemtime($template);
     if (!file_exists($cacheFile) || filemtime($cacheFile) < $lastEdited || isset($_GET['flush'])) {
         $content = file_get_contents($template);
         $content = SSViewer::parseTemplateContent($content, $template);
         $fh = fopen($cacheFile, 'w');
         fwrite($fh, $content);
         fclose($fh);
     }
     $underlay = array('I18NNamespace' => basename($template));
     // Makes the rendered sub-templates available on the parent item,
     // through $Content and $Layout placeholders.
     foreach (array('Content', 'Layout') as $subtemplate) {
         if (isset($this->chosenTemplates[$subtemplate])) {
             $subtemplateViewer = new SSViewer($this->chosenTemplates[$subtemplate]);
             $subtemplateViewer->setPartialCacheStore($this->getPartialCacheStore());
             $underlay[$subtemplate] = $subtemplateViewer->process($item, $arguments);
         }
     }
     $val = $this->includeGeneratedTemplate($cacheFile, $item, $arguments, $underlay);
     $output = Requirements::includeInHTML($template, $val);
     array_pop(SSViewer::$topLevel);
     // If we have our crazy base tag, then fix # links referencing the current page.
     if ($this->rewriteHashlinks && self::$options['rewriteHashlinks']) {
         if (strpos($output, '<base') !== false) {
             if (SSViewer::$options['rewriteHashlinks'] === 'php') {
                 $thisURLRelativeToBase = "<?php echo strip_tags(\$_SERVER['REQUEST_URI']); ?>";
             } else {
                 $thisURLRelativeToBase = strip_tags($_SERVER['REQUEST_URI']);
             }
             $output = preg_replace('/(<a[^>]+href *= *)"#/i', '\\1"' . $thisURLRelativeToBase . '#', $output);
         }
     }
     return $output;
 }
开发者ID:normann,项目名称:sapphire,代码行数:63,代码来源:SSViewer.php

示例3: process

 /**
  * The process() method handles the "meat" of the template processing.
  *
  * It takes care of caching the output (via {@link SS_Cache}), as well as 
  * replacing the special "$Content" and "$Layout" placeholders with their 
  * respective subtemplates.
  *
  * The method injects extra HTML in the header via {@link Requirements::includeInHTML()}.
  * 
  * Note: You can call this method indirectly by {@link ViewableData->renderWith()}.
  * 
  * @param ViewableData $item
  * @param array|null $arguments - arguments to an included template
  * @param Object $inheritedScope - the current scope of a parent template including a sub-template
  *
  * @return HTMLText Parsed template output.
  */
 public function process($item, $arguments = null, $inheritedScope = null)
 {
     SSViewer::$topLevel[] = $item;
     if (isset($this->chosenTemplates['main'])) {
         $template = $this->chosenTemplates['main'];
     } else {
         $keys = array_keys($this->chosenTemplates);
         $key = reset($keys);
         $template = $this->chosenTemplates[$key];
     }
     $cacheFile = TEMP_FOLDER . "/.cache" . str_replace(array('\\', '/', ':'), '.', Director::makeRelative(realpath($template)));
     $lastEdited = filemtime($template);
     if (!file_exists($cacheFile) || filemtime($cacheFile) < $lastEdited) {
         $content = file_get_contents($template);
         $content = $this->parseTemplateContent($content, $template);
         $fh = fopen($cacheFile, 'w');
         fwrite($fh, $content);
         fclose($fh);
     }
     $underlay = array('I18NNamespace' => basename($template));
     // Makes the rendered sub-templates available on the parent item,
     // through $Content and $Layout placeholders.
     foreach (array('Content', 'Layout') as $subtemplate) {
         if (isset($this->chosenTemplates[$subtemplate])) {
             $subtemplateViewer = new SSViewer($this->chosenTemplates[$subtemplate], $this->parser);
             $subtemplateViewer->includeRequirements(false);
             $subtemplateViewer->setPartialCacheStore($this->getPartialCacheStore());
             $underlay[$subtemplate] = $subtemplateViewer->process($item, $arguments);
         }
     }
     $output = $this->includeGeneratedTemplate($cacheFile, $item, $arguments, $underlay, $inheritedScope);
     if ($this->includeRequirements) {
         $output = Requirements::includeInHTML($template, $output);
     }
     array_pop(SSViewer::$topLevel);
     // If we have our crazy base tag, then fix # links referencing the current page.
     $rewrite = Config::inst()->get('SSViewer', 'rewrite_hash_links');
     if ($this->rewriteHashlinks && $rewrite) {
         if (strpos($output, '<base') !== false) {
             if ($rewrite === 'php') {
                 $thisURLRelativeToBase = "<?php echo Convert::raw2att(preg_replace(\"/^(\\\\/)+/\", \"/\", \$_SERVER['REQUEST_URI'])); ?>";
             } else {
                 $thisURLRelativeToBase = Convert::raw2att(preg_replace("/^(\\/)+/", "/", $_SERVER['REQUEST_URI']));
             }
             $output = preg_replace('/(<a[^>]+href *= *)"#/i', '\\1"' . $thisURLRelativeToBase . '#', $output);
         }
     }
     return DBField::create_field('HTMLText', $output, null, array('shortcodes' => false));
 }
开发者ID:tcaiger,项目名称:mSupplyNZ,代码行数:66,代码来源:SSViewer.php

示例4: process

	/**
	 * The process() method handles the "meat" of the template processing.
	 */
	public function process($item) {
		SSViewer::$topLevel[] = $item;

		if(isset($this->chosenTemplates['main'])) {
			$template = $this->chosenTemplates['main'];
		} else {
			$template = $this->chosenTemplates[ reset($dummy = array_keys($this->chosenTemplates)) ];
		}
		
		if(isset($_GET['debug_profile'])) Profiler::mark("SSViewer::process", " for $template");
		$cacheFile = TEMP_FOLDER . "/.cache" . str_replace(array('\\','/',':'),'.',realpath($template));

		$lastEdited = filemtime($template);

		if(!file_exists($cacheFile) || filemtime($cacheFile) < $lastEdited || isset($_GET['flush'])) {
			if(isset($_GET['debug_profile'])) Profiler::mark("SSViewer::process - compile", " for $template");
			
			$content = file_get_contents($template);
			$content = SSViewer::parseTemplateContent($content, $template);
			
			$fh = fopen($cacheFile,'w');
			fwrite($fh, $content);
			fclose($fh);

			if(isset($_GET['debug_profile'])) Profiler::unmark("SSViewer::process - compile", " for $template");
		}
	
		
		if(isset($_GET['showtemplate']) && !Director::isLive()) {
			$lines = file($cacheFile);
			echo "<h2>Template: $cacheFile</h2>";
			echo "<pre>";
			foreach($lines as $num => $line) {
				echo str_pad($num+1,5) . htmlentities($line);
			}
			echo "</pre>";
		}
		
		
		foreach(array('Content', 'Layout') as $subtemplate) {
			if(isset($this->chosenTemplates[$subtemplate])) {
				$subtemplateViewer = new SSViewer($this->chosenTemplates[$subtemplate]);
				$item = $item->customise(array(
					$subtemplate => $subtemplateViewer->process($item)
				));
			}
		}
		
		$itemStack = array();
		$val = "";

		include($cacheFile);

		$output = $val;		
		$output = Requirements::includeInHTML($template, $output);
		
		array_pop(SSViewer::$topLevel);

		if(isset($_GET['debug_profile'])) Profiler::unmark("SSViewer::process", " for $template");
		
		
		// If we have our crazy base tag, then fix # links referencing the current page.
		if(strpos($output, '<base') !== false) {		
			$thisURLRelativeToBase = Director::makeRelative(Director::absoluteURL($_SERVER['REQUEST_URI']));
			$output = preg_replace('/(<a[^>+]href *= *")#/i', '\\1' . $thisURLRelativeToBase . '#', $output);
		}

		return $output;
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:72,代码来源:SSViewer.php

示例5: process

 /**
  * The process() method handles the "meat" of the template processing.
  * It takes care of caching the output (via {@link SS_Cache}),
  * as well as replacing the special "$Content" and "$Layout"
  * placeholders with their respective subtemplates.
  * The method injects extra HTML in the header via {@link Requirements::includeInHTML()}.
  * 
  * Note: You can call this method indirectly by {@link ViewableData->renderWith()}.
  * 
  * @param ViewableData $item
  * @param SS_Cache $cache Optional cache backend
  * @return String Parsed template output.
  */
 public function process($item, $cache = null)
 {
     SSViewer::$topLevel[] = $item;
     if (!$cache) {
         $cache = SS_Cache::factory('cacheblock');
     }
     if (isset($this->chosenTemplates['main'])) {
         $template = $this->chosenTemplates['main'];
     } else {
         $template = $this->chosenTemplates[reset($dummy = array_keys($this->chosenTemplates))];
     }
     if (isset($_GET['debug_profile'])) {
         Profiler::mark("SSViewer::process", " for {$template}");
     }
     $cacheFile = TEMP_FOLDER . "/.cache" . str_replace(array('\\', '/', ':'), '.', realpath($template));
     $lastEdited = filemtime($template);
     if (!file_exists($cacheFile) || filemtime($cacheFile) < $lastEdited || isset($_GET['flush'])) {
         if (isset($_GET['debug_profile'])) {
             Profiler::mark("SSViewer::process - compile", " for {$template}");
         }
         $content = file_get_contents($template);
         $content = SSViewer::parseTemplateContent($content, $template);
         $fh = fopen($cacheFile, 'w');
         fwrite($fh, $content);
         fclose($fh);
         if (isset($_GET['debug_profile'])) {
             Profiler::unmark("SSViewer::process - compile", " for {$template}");
         }
     }
     if (isset($_GET['showtemplate']) && !Director::isLive()) {
         $lines = file($cacheFile);
         echo "<h2>Template: {$cacheFile}</h2>";
         echo "<pre>";
         foreach ($lines as $num => $line) {
             echo str_pad($num + 1, 5) . htmlentities($line);
         }
         echo "</pre>";
     }
     // Makes the rendered sub-templates available on the parent item,
     // through $Content and $Layout placeholders.
     foreach (array('Content', 'Layout') as $subtemplate) {
         if (isset($this->chosenTemplates[$subtemplate])) {
             $subtemplateViewer = new SSViewer($this->chosenTemplates[$subtemplate]);
             $item = $item->customise(array($subtemplate => $subtemplateViewer->process($item, $cache)));
         }
     }
     $itemStack = array();
     $val = "";
     $valStack = array();
     include $cacheFile;
     $output = $val;
     $output = Requirements::includeInHTML($template, $output);
     array_pop(SSViewer::$topLevel);
     if (isset($_GET['debug_profile'])) {
         Profiler::unmark("SSViewer::process", " for {$template}");
     }
     // If we have our crazy base tag, then fix # links referencing the current page.
     if ($this->rewriteHashlinks && self::$options['rewriteHashlinks']) {
         if (strpos($output, '<base') !== false) {
             if (SSViewer::$options['rewriteHashlinks'] === 'php') {
                 $thisURLRelativeToBase = "<?php echo \$_SERVER['REQUEST_URI']; ?>";
             } else {
                 $thisURLRelativeToBase = Director::makeRelative(Director::absoluteURL($_SERVER['REQUEST_URI']));
             }
             $output = preg_replace('/(<a[^>]+href *= *)"#/i', '\\1"' . $thisURLRelativeToBase . '#', $output);
         }
     }
     return $output;
 }
开发者ID:NARKOZ,项目名称:silverstripe-doc-restructuring,代码行数:82,代码来源:SSViewer.php

示例6: testBlockedCombinedJavascript

	function testBlockedCombinedJavascript() {
		$combinedFilePath = Director::baseFolder() . '/' . 'RequirementsTest_bc.js';

		/* BLOCKED COMBINED FILES ARE NOT INCLUDED */
		$this->setupCombinedRequirements();
		Requirements::block('RequirementsTest_bc.js');
		Requirements::delete_combined_files('RequirementsTest_bc.js');

		clearstatcache(); // needed to get accurate file_exists() results
		$html = Requirements::includeInHTML(false, self::$html_template);

		$this->assertFalse((bool)preg_match('/src=".*\/RequirementsTest_bc\.js/', $html), 'blocked combined files are not included ');
		Requirements::unblock('RequirementsTest_bc.js');

		/* BLOCKED UNCOMBINED FILES ARE NOT INCLUDED */
		// need to re-add requirements, as Requirements::process_combined_includes() alters the
		// original arrays grml...
		$this->setupCombinedRequirements();
		Requirements::block('sapphire/tests/forms/RequirementsTest_b.js');
		Requirements::delete_combined_files('RequirementsTest_bc.js');
		clearstatcache(); // needed to get accurate file_exists() results
		$html = Requirements::includeInHTML(false, self::$html_template);
		$this->assertFalse((strpos(file_get_contents($combinedFilePath), "alert('b')") !== false), 'blocked uncombined files are not included');
		Requirements::unblock('RequirementsTest_b.js');
		
		/* A SINGLE FILE CAN'T BE INCLUDED IN TWO COMBINED FILES */
		$this->setupCombinedRequirements();
		clearstatcache(); // needed to get accurate file_exists() results

		// This throws a notice-level error, so we prefix with @
		@Requirements::combine_files(
			'RequirementsTest_ac.js',
			array(
				'sapphire/tests/forms/RequirementsTest_a.js',
				'sapphire/tests/forms/RequirementsTest_c.js'
			)
		);

		$combinedFiles = Requirements::get_combine_files();
		$this->assertEquals(
			array_keys($combinedFiles),
			array('RequirementsTest_bc.js'),
			"A single file can't be included in two combined files"
		);
		
		Requirements::delete_combined_files('RequirementsTest_bc.js');
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:47,代码来源:RequirementsTest.php


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