diff --git a/VERSION.txt b/VERSION.txt index 0a527922f..4f6564b5b 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -6,4 +6,4 @@ // +---------------------------------------------------------------------------------------------------+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////// -1.0.0.2292 \ No newline at end of file +1.0.0.2300 \ No newline at end of file diff --git a/cake/basics.php b/cake/basics.php index 875a0cd70..1008443e5 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -1072,7 +1072,7 @@ function LogError ($message) */ function fileExistsInPath ($file) { - $paths = explode(PATH_SEPARATOR, get_include_path()); + $paths = explode(PATH_SEPARATOR, ini_get('include_path')); foreach ($paths as $path) { $fullPath = $path . DIRECTORY_SEPARATOR . $file; @@ -1088,4 +1088,28 @@ function fileExistsInPath ($file) return false; } +/** + * Convert forward slashes to underscores and removes first and last underscores in a string + * + * @param string + * @return string with underscore remove from start and end of string + */ +function convertSlash($string) +{ + $string = preg_replace('/\/\//', '/', $string); + $string = str_replace('/', '_', $string); + $pos = strpos($string, '_'); + $pos1 = strrpos($string, '_'); + $char = strlen($string) -1; + if($pos1 == $char) + { + $string = substr($string, 0, $char); + } + if ($pos === 0) + { + $string = substr($string, 1); + } + return $string; +} + ?> \ No newline at end of file diff --git a/cake/bootstrap.php b/cake/bootstrap.php index 9b5ea3cc2..e1f127ef8 100644 --- a/cake/bootstrap.php +++ b/cake/bootstrap.php @@ -115,9 +115,7 @@ if(defined('CACHE_CHECK') && CACHE_CHECK === true) { $uri = setUri(); } - - $filename = CACHE.'views'.DS.str_replace('/', '_', $uri.'.php'); - + $filename = CACHE.'views'.DS.convertSlash($uri).'.php'; if (file_exists($filename)) { uses(DS.'controller'.DS.'component', DS.'view'.DS.'view'); @@ -125,6 +123,13 @@ if(defined('CACHE_CHECK') && CACHE_CHECK === true) $view = new View($v); $view->renderCache($filename, $TIME_START); } + elseif (file_exists(CACHE.'views'.DS.convertSlash($uri).'_index.php')) + { + uses(DS.'controller'.DS.'component', DS.'view'.DS.'view'); + $v = null; + $view = new View($v); + $view->renderCache(CACHE.'views'.DS.convertSlash($uri).'_index.php', $TIME_START); + } } require LIBS.'model'.DS.'connection_manager.php'; diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index a6808c0ae..da912c45b 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -474,18 +474,6 @@ class Controller extends Object $this->beforeRender(); - if (!isset($this->_viewVars['data'])) - { - if (isset($this->params['data'])) - { - $this->set('data', $this->params['data']); - } - else - { - $this->set('data', array()); - } - } - $this->_viewClass =& new $viewClass($this); if(!empty($this->modelNames)) { @@ -852,7 +840,7 @@ class Controller extends Object { return null; } - + $conditions = array(); foreach ($data as $model => $fields) { diff --git a/cake/libs/view/helpers/cache.php b/cake/libs/view/helpers/cache.php index 9e8acfb34..4f7e0e7d7 100644 --- a/cake/libs/view/helpers/cache.php +++ b/cake/libs/view/helpers/cache.php @@ -51,32 +51,43 @@ class CacheHelper extends Helper { $check = str_replace('/', '_', $this->here); $replace = str_replace('/', '_', $this->base); + $match = str_replace($this->base, '', $this->here); + $match = str_replace('//', '/', $match); + $match = str_replace('/'.$this->controllerName.'/', '', $match); $check = str_replace($replace, '', $check); $check = str_replace('_'.$this->controllerName.'_', '', $check); - $pos = strpos($check, '_'); - $pos1 = strrpos($check, '_'); - if($pos1 > 0) - { - $check = substr($check, 0, $pos1); - } - if ($pos !== false) - { - $check = substr($check, 1); - } + $check = convertSlash($check); $keys = str_replace('/', '_', array_keys($this->cacheAction)); - $key = preg_grep("/^$check/", array_values($keys)); - if(isset($key['0'])) + $found = array_keys($this->cacheAction); + $index = null; + $count = 0; + foreach ($keys as $key => $value) { - $key = str_replace('_', '/', $key['0']); + if(strpos($check, $value) === 0) + { + $index = $found[$count]; + break; + } + $count++; } - else + if(isset($index)) { - $key = 'index'; + $pos1 = strrpos($match, '/'); + $char = strlen($match) -1; + if($pos1 == $char) + { + $match = substr($match, 0, $char); + } + $key = $match; + } + elseif ($this->action == 'index') + { + $index = 'index'; } - if(isset($this->cacheAction[$key])) + if(isset($this->cacheAction[$index])) { - $cacheTime = $this->cacheAction[$key]; + $cacheTime = $this->cacheAction[$index]; } else { @@ -116,16 +127,19 @@ class CacheHelper extends Helper $file = file_get_contents($file); } - preg_match_all('/(?P(?:.*|(?:[\\S\\s]*[^\\S]))<\/cake:nocache>)/i', $cache, $oresult, PREG_PATTERN_ORDER); - preg_match_all('/(?P(?:.*|(?:[\\S\\s]*[^\\S])))<\/cake:nocache>/i', $file, $result, PREG_PATTERN_ORDER); + preg_match_all('/(?P(?<=)[\\s\\S]*?(?=<\/cake:nocache>)<\/cake:nocache>)/i', $cache, $oresult, PREG_PATTERN_ORDER); + preg_match_all('/(?<=)(?P[\\s\\S]*?)(?=<\/cake:nocache>)/i', $file, $result, PREG_PATTERN_ORDER); if(!empty($result['replace'])) { $count = 0; foreach($result['replace'] as $result) { - $this->replace[] = $result; - $this->match[] = $oresult['found'][$count]; + if(isset($oresult['found'][$count])) + { + $this->replace[] = $result; + $this->match[] = $oresult['found'][$count]; + } $count++; } } @@ -157,17 +171,33 @@ class CacheHelper extends Helper { $cacheTime = $now + strtotime($timestamp); } - $result = preg_replace('/\/\//', '/', $this->here); - $cache = str_replace('/', '_', $result.'.php'); - $cache = str_replace('favicon.ico', '', $cache); - $file = ''. - 'view->name.'\'); ?>'. - 'controller = new '.$this->view->name.'Controller(); ?>'. - 'helpers = unserialize(\''. serialize($this->view->helpers).'\'); ?>'. - 'webroot = \''. $this->view->webroot.'\'; ?>'. - 'data = unserialize(\''. serialize($this->view->data).'\'); ?>'. - ''. - '_loadHelpers($loaded, $this->helpers); ?>'.$file; + $cache = convertSlash($this->here).'.php'; + $file = ' + view->name.'\'); + $this->controller = new '.$this->view->name.'Controller(); + $this->helpers = unserialize(\''. serialize($this->view->helpers).'\'); + $this->webroot = \''. $this->view->webroot.'\'; + $this->data = unserialize(\''. serialize($this->view->data).'\'); + $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}); + } + ?> + '.$file; return cache('views'.DS.$cache, $file, $timestamp); } } diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php index 38fff3e04..ce5cc3e1c 100644 --- a/cake/libs/view/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -1384,9 +1384,7 @@ class HtmlHelper extends Helper '05'=>'5','06'=>'6','07'=>'7','08'=>'8','09'=>'9', '10'=>'10','11'=>'11','12'=>'12'); } - - $option = $this->selectTag($tagName.'_hour', $hours, $hourValue, $selectAttr, - $optionAttr); + $option = $this->selectTag($tagName.'_hour', $hours, $hourValue, $selectAttr, $optionAttr, $showEmpty); return $option; } @@ -1407,9 +1405,7 @@ class HtmlHelper extends Helper { $mins[$minCount] = sprintf('%02d', $minCount); } - - $option = $this->selectTag($tagName.'_min', $mins, $minValue, $selectAttr, - $optionAttr); + $option = $this->selectTag($tagName.'_hour', $hours, $hourValue, $selectAttr, $optionAttr, $showEmpty); return $option; } @@ -1427,9 +1423,7 @@ class HtmlHelper extends Helper $value = isset($value)? $value : $this->tagValue($tagName."_meridian"); $merValue = empty($selected) ? date('a') : $selected ; $meridians = array('am'=>'am','pm'=>'pm'); - - $option = $this->selectTag($tagName.'_meridian', $meridians, $merValue, $selectAttr, - $optionAttr); + $option = $this->selectTag($tagName.'_hour', $hours, $hourValue, $selectAttr, $optionAttr, $showEmpty); return $option; } diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index dcd53eb0f..744e6cf59 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -670,6 +670,7 @@ class View extends Object } $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);