⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 html.php

📁 Joomla15 - 最新开源CMS
💻 PHP
📖 第 1 页 / 共 2 页
字号:
			{
				echo '	<div class="patTemplateTmplContent">';
				echo '	  <div class="patTemplateCol">Comments</div>';
				echo '	  <div style="margin-bottom:7px;">';
							  echo implode( '<br>', $tmpl['comments'] );
				echo '	  </div>';
				echo '	</div>';
			}

			/**
			 * ------------------------------------------------------------------
			 * display template content
			 */
			echo '	<div class="patTemplateTmplContent">';
			switch( $tmpl['attributes']['type'] )
			{
				case 'condition':
				case 'modulo':
					$this->_displayConditions( $tmpl, $name, $vars );
					break;

				default:
					echo '	  <div class="patTemplateCol">Content</div>';
					echo '	  <div class="patTemplateSource"><pre>'.$this->_highlightVars( htmlspecialchars( $tmpl['content'] ), $vars[$name] ).'</pre></div>';
					break;
			}

			echo '	</div>';
			echo '  </div>';
			echo '</div>';
		}

		echo '</div>';
	}

	function _displayVariables( $tmpl, $tmplName, $setVars, $vars )
	{
		if( empty( $setVars ) )
		{
			echo '<i class="patTemplate">[none]</i>';
			return true;
		}

		echo '<table border="0" cellpadding="3" cellpadding="0" class="patTemplate">';
		$this->_useBorders( true );
		$this->_displayHead( 'Name', 'Assigned value', 'Modifier' );

		foreach( $setVars as $var )
		{
			if( isset( $vars[$tmplName][$var] ) )
				$value = $vars[$tmplName][$var];
			else
				$value = '<i class="patTemplate">[no value set]</i>';

			if( isset( $tmpl['modifyVars'][$var] ) )
			{
				$params	=	array();
				foreach( $tmpl['modifyVars'][$var]['params'] as $n => $val )
				{
					array_push( $params, $n.'="'.$val.'"' );
				}
				$modifier = sprintf( '%s( %s )', $tmpl['modifyVars'][$var]['mod'], implode( ', ', $params ) );
			}
			else
			{
				$modifier = '<i class="patTemplate">[none]</i>';
			}

			$this->_displayLine( $var, $value, $modifier );
		}
		echo '</table>';

		$this->_useBorders( false );
	}

	function _displayConditions( $tmpl, $tmplName, $vars )
	{
		foreach( $tmpl['subtemplates'] as $cond => $spec )
		{
			echo '  <h3 class="patTemplateSub" onclick="patTemplateToggle(\'Cond'.$cond.'\');" style="cursor:pointer;"><span id="tmpl-Cond'.$cond.'-sign" class="patTemplateSign">[+]</span> Subtemplate <a name="Cond'.$cond.'">"'.$cond.'"</a></h3>';
			echo '  <div class="patTemplateData" id="tmpl-Cond'.$cond.'" style="margin-bottom:15px;">';
			echo '	<script language="JavaScript1.2" type="text/javascript">';
			echo '	  patTemplateAddTmpl( \'Cond'.$cond.'\' );';
			echo '	</script>';

			if( !empty( $spec['comments'] ) )
			{
				echo '	<div class="patTemplateCol">Comments</div>';
				echo '	<div style="margin-bottom:7px;">';
							echo implode( '<br>', $spec['comments'] );
				echo '	</div>';
			}

				echo '	<div class="patTemplateCol">Dependencies</div>';
				echo '	<div style="margin-bottom:7px;">';
			if( !empty( $spec['dependencies'] ) )
			{
				$dependencies = array();
				foreach( $spec['dependencies'] as $dependency )
					array_push( $dependencies, '<a href="javascript:jump( \''.$dependency.'\' );" class="patTemplate">'.$dependency.'</a>' );

				echo implode( ', ', $dependencies );
			}
			else
			{
				echo '<i class="patTemplate">[none]</i>';
			}
				echo '	</div>';

			echo '	<div class="patTemplateCol">Content</div>';
			echo '	<div class="patTemplateSource"><pre>'.$this->_highlightVars( htmlspecialchars( $spec['data'] ), $vars[$tmplName] ).'</pre></div>';
			echo '  </div>';
		}
	}

	/**
	* display the attributes of a template
	*
	* @access   private
	* @param	array	   template data
	* @param	string	  name of the template
	*/
	function _displayAttributes( $tmpl, $tmplName = null )
	{
		echo '<div class="patTemplateCol">Attributes</div>';
		echo '<table border="0" cellpadding="0" cellpadding="0">';

		/**
		 * type
		 */
		switch( $tmpl['attributes']['type'] )
		{
			case 'modulo':
				if( $tmpl['attributes']['modulo'] == 2 )
					$type = 'OddEven';
				else
					$type = 'modulo (' . $tmpl['attributes']['modulo'] . ')';
			case 'condition':
				if( !isset( $type ) )
					$type	=	'condition';

				$this->_displayLine( 'Type', $tmpl['attributes']['type'] );
				/**
				 * condition variable, only used in condition templates
				 */
				if( isset( $tmpl['attributes']['conditionvar'] ) )
				{
					if( isset( $tmpl['attributes']['conditiontmpl'] ) )
						$this->_displayLine( 'ConditionVar', $tmpl['attributes']['conditiontmpl'].'.'.$tmpl['attributes']['conditionvar'] );
					elseif( isset( $tmpl['attributes']['useglobals'] ) && $tmpl['attributes']['useglobals'] == 'yes' )
						$this->_displayLine( 'ConditionVar', '__globals.'.$tmpl['attributes']['conditionvar'] );
					else
						$this->_displayLine( 'ConditionVar', $tmpl['attributes']['conditionvar'] );
				}
				break;

			case 'simplecondition':
				$this->_displayLine( 'Type', 'simplecondition' );
				$requiredvars = array();
				foreach ($tmpl['attributes']['requiredvars'] as $tmp) {
					if ($tmp[0] !== $tmplName) {
						$var = $tmp[0] . '.' . $tmp[1];
					} else {
						$var = $tmp[1];
					}
					if ($tmp[2] !== null) {
						$var = $var . '='.$tmp[2];
					}
					array_push($requiredvars, $var);
				}

				$this->_displayLine( 'RequiredVars', implode( ', ', $requiredvars ) );

				break;
			default:
				$this->_displayLine( 'Type', $tmpl['attributes']['type'] );
		}

		/**
		 * standard attributes
		 */
		$this->_displayLine( 'Visibility', $tmpl['attributes']['visibility'] );
		$this->_displayLine( 'WhiteSpace', $tmpl['attributes']['whitespace'] );
		$this->_displayLine( 'AddSystemVars', $tmpl['attributes']['addsystemvars'] );
		$this->_displayLine( 'UnusedVars', $tmpl['attributes']['unusedvars'] );

		/**
		 * external source
		 */
		if( isset( $tmpl['attributes']['src'] ) )
			$this->_displayLine( 'External Src', $tmpl['attributes']['src'] );
		/**
		 * varscope
		 */
		if (isset($tmpl['attributes']['varscope'])) {
			if (is_array($tmpl['attributes']['varscope'])) {
				$this->_displayLine( 'Varscope', implode(', ', $tmpl['attributes']['varscope'] ) );
			} else {
				$this->_displayLine( 'Varscope', $tmpl['attributes']['varscope'] );
			}
		}

		echo '		  </table>';
	}

	function _displayTemplateState( $tmpl )
	{
			echo '		  <div class="patTemplateCol">States</div>';
			echo '		  <table border="0" cellpadding="0" cellpadding="0">';
							$this->_displayLine( 'Loaded', $tmpl['loaded'] );
							$this->_displayLine( 'Parsed', $tmpl['parsed'] );
			echo '		  </table>';
	}

	/**
	* hilight variables in a template
	*
	* @access	private
	* @param	string		template content
	* @return	string		template content
	*/
	function _highlightVars( $template, $vars )
	{
		$pattern  = '/('.$this->_tmpl->getStartTag().'TMPL\:([^a-z]+)'.$this->_tmpl->getEndTag().')/U';
		$template = preg_replace( $pattern, '<span class="patTemplateTmpl" onclick="jump(\'\2\')" title="Click to view the dependency \'\2\'.">\1</span>', $template );

		$pattern = '/('.$this->_tmpl->getStartTag().'([^a-z:]+)'.$this->_tmpl->getEndTag().')/U';
		$matches = array();
		preg_match_all( $pattern, $template, $matches );
		for( $i = 0; $i < count( $matches[1] ); $i++ )
		{
			if( isset( $vars[$matches[2][$i]] ) )
			{
				$value = $vars[$matches[2][$i]];
			}
			else
			{
				$value = '[No value set]';
			}
			$replace  = '<span class="patTemplateVar" title="'.$value.'">'.$matches[1][$i].'</span>';
			$template = str_replace( $matches[1][$i], $replace, $template );
		}
		return $template;
	}

	/**
	* display a table header
	*
	* @access	private
	* @param	string		property
	* @param	mixed		value, you may pass more than one value
	*/
	function _displayHead()
	{
		$args		=	func_get_args();

		echo '  <tr valign="top">';
		foreach( $args as $head )
		{
			printf( '   <td class="'.$this->_getClassName( 'patTemplateProp' ).'">%s</td>', $head );
		}
		echo '  </tr>';
	}

	function _getClassName( $class )
	{
		if( !$this->_useBorders )
			return $class;

		return $class .= 'Border';
	}

	/**
	* sets whether to draw borders in the tables generated via the
	* {@link _displayHead()} and {@link _displayLine()} methods.
	*
	* @access	private
	* @param	bool		$state	Whether to draw the borders. true=draw, false=don't draw
	*/
	function _useBorders( $state )
	{
		$this->_useBorders = $state;
	}

	/**
	* display a line in a table
	*
	* @access	private
	* @param	string		property
	* @param	mixed		value, you may pass more than one value
	*/
	function _displayLine( $prop, $value )
	{
		$args	=	func_get_args();
		$prop	=	array_shift( $args );

		echo '  <tr valign="top">';
		printf( '   <td class="'.$this->_getClassName( 'patTemplateProp' ).'">%s</td>', $prop );
		if( count( $args ) == 1 )
		{
			echo '   <td class="'.$this->_getClassName( 'patTemplateVal' ).'">&nbsp;:&nbsp;</td>';
		}

		foreach( $args as $value )
		{
			if( is_bool( $value ) )
			{
				$value = ( $value === true ) ? 'yes' : 'no';
			}

			printf( '   <td class="'.$this->_getClassName( 'patTemplateVal' ).'">%s</td>', $value );
		}
		echo '  </tr>';
	}

	/**
	* display the footer
	*
	* @access	public
	*/
	function displayFooter()
	{
		echo ' </div>';
		echo ' </body>';
		echo '</html>';
	}
}
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -