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

📄 view.php.svn-base

📁 j2me is based on j2mepolish, client & server for mobile application. server part
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
		return $this->renderElement($name, $params);	}/** * Renders a layout. Returns output from _render(). Returns false on error. * * @param string $contentForLayout Content to render in a view, wrapped by the surrounding layout. * @return mixed Rendered output, or false on error * @access public */	function renderLayout($contentForLayout) {		$layoutFilename = $this->_getLayoutFileName();		if (Configure::read() > 2 && $this->controller != null) {			$debug = View::_render(LIBS . 'view' . DS . 'templates' . DS . 'elements' . DS . 'dump.thtml', array('controller' => $this->controller), false);		} else {			$debug = '';		}		if ($this->pageTitle !== false) {			$pageTitle = $this->pageTitle;		} else {			$pageTitle = Inflector::humanize($this->viewPath);		}		$dataForLayout = array_merge($this->viewVars, array('title_for_layout'   => $pageTitle,																				'content_for_layout' => $contentForLayout,																				'cakeDebug'          => $debug));		if (is_file($layoutFilename)) {			if (empty($this->loaded) && !empty($this->helpers)) {				$loadHelpers = true;			} else {				$loadHelpers = false;				$dataForLayout = array_merge($dataForLayout, $this->loaded);			}			if (substr($layoutFilename, -5) === 'thtml') {				$out = View::_render($layoutFilename, $dataForLayout, $loadHelpers, true);			} else {				$out = $this->_render($layoutFilename, $dataForLayout, $loadHelpers);			}			if ($out === false) {				$out = $this->_render($layoutFilename, $dataForLayout);				trigger_error(sprintf("Error in layout %s, got: <blockquote>%s</blockquote>", $layoutFilename, $out), E_USER_ERROR);				return false;			} else {				return $out;			}		} else {			return $this->cakeError('missingLayout', array(array('layout' => $this->layout,																					'file' => $layoutFilename,																					'base' => $this->base)));		}	}/** * Sets layout to be used when rendering. * * @param string $layout Name of layout. * @return void * @access public * @deprecated in 1.2.x.x */	function setLayout($layout) {		$this->layout = $layout;	}/** * Displays an error page to the user. Uses layouts/error.html to render the page. * * @param int $code HTTP Error code (for instance: 404) * @param string $name Name of the error (for instance: Not Found) * @param string $message Error message as a web page * @return rendered error message * @access public * */	function error($code, $name, $message) {		header ("HTTP/1.0 {$code} {$name}");		print ($this->_render(VIEWS . 'layouts/error.thtml', array('code'    => $code,																						'name'    => $name,																						'message' => $message)));	}/** * Returns filename of given action's template file (.thtml) as a string. CamelCased action names will be under_scored! This means that you can have LongActionNames that refer to long_action_names.thtml views. * * @param string $action Controller action to find template filename for * @return string Template filename * @access protected */	function _getViewFileName($action) {		$action = Inflector::underscore($action);		$paths = Configure::getInstance();		if (!is_null($this->webservices)) {			$type = strtolower($this->webservices) . DS;		} else {			$type = null;		}		$position = strpos($action, '..');		if ($position === false) {		} else {			$action = explode('/', $action);			$i = array_search('..', $action);			unset($action[$i - 1]);			unset($action[$i]);			$action='..' . DS . implode(DS, $action);		}		foreach($paths->viewPaths as $path) {			if (file_exists($path . $this->viewPath . DS . $this->subDir . $type . $action . $this->ext)) {				$viewFileName = $path . $this->viewPath . DS . $this->subDir . $type . $action . $this->ext;				return $viewFileName;			}		}		if ($viewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'errors' . DS . $type . $action . '.thtml')) {		} elseif($viewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . $this->viewPath . DS . $type . $action . '.thtml')) {		} else {			$viewFileName = VIEWS . $this->viewPath . DS . $this->subDir . $type . $action . $this->ext;		}		return $viewFileName;	}/** * Returns layout filename for this template as a string. * * @return string Filename for layout file (.thtml). * @access protected */	function _getLayoutFileName() {		if (isset($this->webservices) && !is_null($this->webservices)) {			$type = strtolower($this->webservices) . DS;		} else {			$type = null;		}		if (isset($this->plugin) && !is_null($this->plugin)) {			if (file_exists(APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . 'layouts' . DS . $this->layout . $this->ext)) {				$layoutFileName = APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . 'layouts' . DS . $this->layout . $this->ext;				return $layoutFileName;			}		}		$paths = Configure::getInstance();		foreach($paths->viewPaths as $path) {			if (file_exists($path . 'layouts' . DS . $this->subDir . $type . $this->layout . $this->ext)) {				$layoutFileName = $path . 'layouts' . DS . $this->subDir . $type . $this->layout . $this->ext;				return $layoutFileName;			}		}		if($layoutFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'layouts' . DS . $type . $this->layout . '.thtml')) {		} else {			$layoutFileName = LAYOUTS . $type . $this->layout.$this->ext;		}		return $layoutFileName;	}/** * Renders and returns output for given view filename with its array of data. * * @param string $___viewFn Filename of the view * @param array $___dataForView Data to include in rendered view * @return string Rendered output * @access protected */	function _render($___viewFn, $___dataForView, $loadHelpers = true, $cached = false) {		if ($this->helpers != false && $loadHelpers === true) {			$loadedHelpers = array();			$loadedHelpers = $this->_loadHelpers($loadedHelpers, $this->helpers);			foreach(array_keys($loadedHelpers) as $helper) {				$replace = strtolower(substr($helper, 0, 1));				$camelBackedHelper = preg_replace('/\\w/', $replace, $helper, 1);				${$camelBackedHelper} =& $loadedHelpers[$helper];				if (isset(${$camelBackedHelper}->helpers) && is_array(${$camelBackedHelper}->helpers)) {					foreach(${$camelBackedHelper}->helpers as $subHelper) {						${$camelBackedHelper}->{$subHelper} =& $loadedHelpers[$subHelper];					}				}				$this->loaded[$camelBackedHelper] = (${$camelBackedHelper});			}		}		extract($___dataForView, EXTR_SKIP);		$BASE = $this->base;		$params =& $this->params;		$page_title = $this->pageTitle;		ob_start();		if (Configure::read() > 0) {			include ($___viewFn);		} else {			@include ($___viewFn);		}		if ($this->helpers != false && $loadHelpers === true) {			foreach ($loadedHelpers as $helper) {				if (is_object($helper)) {					if (is_subclass_of($helper, 'Helper') || is_subclass_of($helper, 'helper')) {						$helper->afterRender();					}				}			}		}		$out = ob_get_clean();		if (isset($this->loaded['cache']) && ((isset($this->controller) && $this->controller->cacheAction != false)) && (defined('CACHE_CHECK') && CACHE_CHECK === true)) {			if (is_a($this->loaded['cache'], 'CacheHelper')) {				$cache =& $this->loaded['cache'];				if ($cached === true) {					$cache->view = &$this;				}				$cache->base			= $this->base;				$cache->here			= $this->here;				$cache->action			= $this->action;				$cache->controllerName	= $this->params['controller'];				$cache->cacheAction		= $this->controller->cacheAction;				$cache->cache($___viewFn, $out, $cached);			}		}		return $out;	}/** * Loads helpers, with their dependencies. * * @param array $loaded List of helpers that are already loaded. * @param array $helpers List of helpers to load. * @return array * @access protected */	function &_loadHelpers(&$loaded, $helpers) {		static $tags;		$helpers[] = 'Session';		if (empty($tags)) {			$helperTags = new Helper();			$tags = $helperTags->loadConfig();		}		foreach($helpers as $helper) {			$pos = strpos($helper, '/');			if ($pos === false) {				$plugin = $this->plugin;			} else {				$parts = explode('/', $helper);				$plugin = Inflector::underscore($parts['0']);				$helper = $parts['1'];			}			$helperCn = $helper . 'Helper';			if (in_array($helper, array_keys($loaded)) !== true) {				if (!class_exists($helperCn)) {				    if (is_null($plugin) || !loadPluginHelper($plugin, $helper)) {						if (!loadHelper($helper)) {							$this->cakeError('missingHelperFile', array(array(													'helper' => $helper,													'file' => Inflector::underscore($helper) . '.php',													'base' => $this->base)));							exit();						}				    }					if (!class_exists($helperCn)) {						$this->cakeError('missingHelperClass', array(array(												'helper' => $helper,												'file' => Inflector::underscore($helper) . '.php',												'base' => $this->base)));						exit();					}				}				$camelBackedHelper = Inflector::variable($helper);				${$camelBackedHelper} =& new $helperCn;				${$camelBackedHelper}->view =& $this;				${$camelBackedHelper}->tags = $tags;				$vars = array('base', 'webroot', 'here', 'params', 'action', 'data', 'themeWeb', 'plugin');				$c = count($vars);				for ($j = 0; $j < $c; $j++) {					${$camelBackedHelper}->{$vars[$j]} = $this->{$vars[$j]};				}				if (!empty($this->validationErrors)) {					${$camelBackedHelper}->validationErrors = $this->validationErrors;				}				$loaded[$helper] =& ${$camelBackedHelper};				if (isset(${$camelBackedHelper}->helpers) && is_array(${$camelBackedHelper}->helpers)) {					$loaded = &$this->_loadHelpers($loaded, ${$camelBackedHelper}->helpers);				}			}		}		return $loaded;	}/** * Returns a plugin view * * @param string $action Name of action to render for * @param string $layout Layout to use * @return mixed View::render() if template is found, error if template is missing * @access public */	function pluginView($action, $layout) {		$viewFileName = APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $action . $this->ext;		if (file_exists($viewFileName)) {			$this->render($action, $layout, $viewFileName);		} else {			return $this->cakeError('missingView', array(array(											'className' => $this->controller->name,											'action' => $action,											'file' => $viewFileName,											'base' => $this->base)));		}	}/** * Renders a cached view if timestamp in file is less or equal to current time. * * If $layout is xml content type will be set before rendering the cache * * * @param string $filename * @param int $timeStart * @return mixed outputs view, or returns void if timestamp has expired * @access public */	function renderCache($filename, $timeStart) {		ob_start();		include ($filename);		if (Configure::read() > 0 && $this->layout != 'xml') {			echo "<!-- Cached Render Time: " . round(getMicrotime() - $timeStart, 4) . "s -->";		}		$out = ob_get_clean();		if (preg_match('/^<!--cachetime:(\\d+)-->/', $out, $match)) {			if (time() >= $match['1']) {				@unlink($filename);				unset ($out);				return;			} else {				if($this->layout === 'xml'){					header('Content-type: text/xml');				}				$out = str_replace('<!--cachetime:'.$match['1'].'-->', '', $out);				e($out);				die();			}		}	}}?>

⌨️ 快捷键说明

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