diff --git a/libs/controller.php b/libs/controller.php index bb7e91300..34bcc6e45 100644 --- a/libs/controller.php +++ b/libs/controller.php @@ -211,7 +211,22 @@ class Controller extends Object * */ function constructClasses(){ + + if (!empty($this->beforeFilter)) + { + if(is_array($this->beforeFilter)) + { + foreach($this->beforeFilter as $filter) + { + } + } + else + { + + } + } + if(empty($this->params['pass'])) { $id = false; @@ -255,27 +270,6 @@ class Controller extends Object } } } - - if (!empty($this->beforeFilter)) - { - if(is_array($this->beforeFilter)) - { - foreach($this->beforeFilter as $filter) - { - if(is_callable(array($this,$filter))) - { - $this->$filter(); - } - } - } - else - { - if(is_callable(array($this,$this->beforeFilter))) - { - $this->{$this->beforeFilter}(); - } - } - } } /** diff --git a/libs/dispatcher.php b/libs/dispatcher.php index 2a69e1c0e..ae130068c 100644 --- a/libs/dispatcher.php +++ b/libs/dispatcher.php @@ -79,6 +79,12 @@ class Dispatcher extends Object $missingController = false; $missingAction = false; $missingView = false; + + if(!in_array('render', array_keys($params))) + { + $params['render'] = 0; + } + if (empty($params['controller'])) { @@ -129,6 +135,7 @@ class Dispatcher extends Object $controller->passed_args = empty($params['pass'])? null: $params['pass']; $controller->viewpath = Inflector::underscore($ctrlName); $controller->autoLayout = !$params['bare']; + $controller->autoRender = !$params['render']; if((in_array('scaffold', array_keys($classVars))) && ($missingAction === true)) { @@ -197,6 +204,7 @@ class Dispatcher extends Object $params['form'][$name] = $data; } $params['bare'] = empty($params['ajax'])? (empty($params['bare'])? 0: 1): 1; + return $params; } diff --git a/libs/helper.php b/libs/helper.php index b0f9ae0e3..2ce1a1bc5 100644 --- a/libs/helper.php +++ b/libs/helper.php @@ -129,22 +129,6 @@ class Helper extends Object $this->tags[$keyName]); } - -/** - * - * Allow calling a controllers method from a helper - * - * - * @param unknown_type $url - * @param unknown_type $extra - * @return unknown - */ - function renderMethod ($url, $extra = false) - { - $dispatcher = new Dispatcher(); - return $dispatcher->dispatch($url, array('bare'=>1)); - } - function readConfigFile ($fileName) { $fileLineArray = file($fileName); diff --git a/libs/helpers/ajax.php b/libs/helpers/ajax.php index 435428f44..c865bcbf7 100644 --- a/libs/helpers/ajax.php +++ b/libs/helpers/ajax.php @@ -158,7 +158,7 @@ class AjaxHelper extends Helper } if (isset($options['after'])) { - $func = "$func; {$options['before']};"; + $func = "$func; {$options['after']};"; } if (isset($options['condition'])) { diff --git a/libs/helpers/html.php b/libs/helpers/html.php index 352271675..8b4c8cc06 100644 --- a/libs/helpers/html.php +++ b/libs/helpers/html.php @@ -503,10 +503,10 @@ class HtmlHelper extends Helper $out = array(); foreach ($names as $arg) { - $out[] = sprintf($this->tags['tableHeader'], $this->parseHtmlOptions($th_options), $arg); + $out[] = sprintf($this->tags['tableheader'], $this->parseHtmlOptions($th_options), $arg); } - return sprintf($this->tags['tableHeader'], $this->parseHtmlOptions($tr_options), join(' ', $out)); + return sprintf($this->tags['tableheader'], $this->parseHtmlOptions($tr_options), join(' ', $out)); } @@ -1239,8 +1239,8 @@ class HtmlHelper extends Helper function dayOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null) { - $value = isset($value)? $value : $this->tagValue($tagName); - $dayValue = empty($value) ? date('d') : date('d',strtotime( $value ) ); + $value = isset($value)? $value : $this->tagValue($tagName."_day"); + $dayValue = empty($value) ? date('d') : $value; $days=array('1'=>'1','2'=>'2','3'=>'3','4'=>'4', '5'=>'5','6'=>'6','7'=>'7','8'=>'8','9'=>'9', '10'=>'10','11'=>'11','12'=>'12', @@ -1257,9 +1257,9 @@ class HtmlHelper extends Helper function yearOptionTag( $tagName, $value=null, $minYear=null, $maxYear=null, $selected=null, $optionAttr=null) { - $value = isset($value)? $value : $this->tagValue($tagName); + $value = isset($value)? $value : $this->tagValue($tagName."_year"); - $yearValue = empty($value) ? date('Y') : date('Y',strtotime( $value ) ); + $yearValue = empty($value) ? date('Y') : $value; $maxYear = is_null($maxYear) ? $yearValue + 10 : $maxYear; @@ -1286,8 +1286,8 @@ class HtmlHelper extends Helper function monthOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null) { - $value = isset($value)? $value : $this->tagValue($tagName); - $monthValue = empty($value) ? date('m') : date('m',strtotime( $value ) ); + $value = isset($value)? $value : $this->tagValue($tagName."_month"); + $monthValue = empty($value) ? date('m') : $value ; $months=array('1'=>'January','2'=>'February','3'=>'March', '4'=>'April','5'=>'May','6'=>'June','7'=>'July','8'=>'August', '9'=>'September','10'=>'October','11'=>'November','12'=>'December'); @@ -1301,14 +1301,14 @@ class HtmlHelper extends Helper $selected=null, $optionAttr=null ) { - $value = isset($value)? $value : $this->tagValue($tagName); + $value = isset($value)? $value : $this->tagValue($tagName."_hour"); if ( $format24Hours ) { - $hourValue = empty($value) ? date('H') : date('H',strtotime( $value ) ); + $hourValue = empty($value) ? date('H') : $value; } else { - $hourValue = empty($value) ? date('g') : date('g',strtotime( $value ) ); + $hourValue = empty($value) ? date('g') : $value; } if ( $format24Hours ) { $hours = array('0'=>'00','1'=>'01','2'=>'02','3'=>'03','4'=>'04', @@ -1333,8 +1333,8 @@ class HtmlHelper extends Helper function minuteOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null) { - $value = isset($value)? $value : $this->tagValue($tagName); - $minValue = empty($value) ? date('i') : date('i',strtotime( $value ) ); + $value = isset($value)? $value : $this->tagValue($tagName."_min"); + $minValue = empty($value) ? date('i') : $value ; for( $minCount=0; $minCount<61; $minCount++) { $mins[$minCount] = sprintf('%02d', $minCount); @@ -1347,8 +1347,8 @@ class HtmlHelper extends Helper function meridianOptionTag( $tagName, $value=null, $selected=null, $optionAttr=null) { - $value = isset($value)? $value : $this->tagValue($tagName); - $merValue = empty($value) ? date('a') : date('a',strtotime( $value ) ); + $value = isset($value)? $value : $this->tagValue($tagName."_meridian"); + $merValue = empty($value) ? date('a') : $value ; $meridians = array('am'=>'am','pm'=>'pm'); $option = $this->selectTag($tagName.'_meridian', $meridians, $merValue, @@ -1379,7 +1379,7 @@ class HtmlHelper extends Helper switch ($timeFormat) { case '24': - $opt .= $this->hourOptionTag( $tagName, true ) . ':' . $this->minuteOptionTag( $tagName ); + $opt .= $this->hourOptionTag( $tagName, null , true ) . ':' . $this->minuteOptionTag( $tagName ); break; case '12': $opt .= $this->hourOptionTag( $tagName ) . ':' . $this->minuteOptionTag( $tagName ) . ' ' . $this->meridianOptionTag($tagName); @@ -1395,4 +1395,4 @@ class HtmlHelper extends Helper } } -?> +?> \ No newline at end of file diff --git a/libs/model.php b/libs/model.php index 2c4ea644b..0fea7d24f 100644 --- a/libs/model.php +++ b/libs/model.php @@ -535,7 +535,7 @@ class Model extends Object function _constructAssociatedModels($modelName, $type, $settings = false) { $modelName = Inflector::singularize($modelName); - $collectionKey = strtolower($modelName); + $collectionKey = Inflector::underscore($modelName); switch($type) { diff --git a/libs/object.php b/libs/object.php index 4cd0d4998..796fae68e 100644 --- a/libs/object.php +++ b/libs/object.php @@ -104,8 +104,16 @@ class Object * @param unknown_type $extra * @return unknown */ - function renderMethod ($url, $extra = array()) + function requestAction ($url, $extra = array()) { + if(in_array('render', $extra)) + { + $extra['render'] = 0; + } + else + { + $extra['render'] = 1; + } $extra = array_merge($extra, array('bare'=>1)); $dispatcher =& new Dispatcher(); return $dispatcher->dispatch($url, $extra); diff --git a/libs/scaffold.php b/libs/scaffold.php index fd8e91f6d..4ca1e4269 100644 --- a/libs/scaffold.php +++ b/libs/scaffold.php @@ -194,7 +194,7 @@ class Scaffold extends Object { function _scaffoldCreate($params) { $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames() ); - $this->cleanUpFields(); + $this->_cleanUpFields(); if ($this->controllerClass->models[$this->modelKey]->save($this->controllerClass->params['data'])) { diff --git a/libs/view.php b/libs/view.php index 43a0f2216..16c163c0d 100644 --- a/libs/view.php +++ b/libs/view.php @@ -438,6 +438,7 @@ class View extends Object function missingView() { //We are simulating action call below, this is not a filename! + $this->autoLayout = true; $this->missingView = $this->name; $this->render('../errors/missingView'); }