From b2a546f2bc1d8a965b06e46f404b7d233b044959 Mon Sep 17 00:00:00 2001 From: Parziphal Date: Fri, 4 Oct 2013 19:10:33 -0500 Subject: [PATCH] more changes --- composer.json | 11 ++++ lib/Rails/ActionDispatch/Http/Parameters.php | 2 +- lib/Rails/ActionView/Template.php | 62 ++++++++++---------- lib/Rails/ActionView/Template/Renderer.php | 35 +++++++++++ lib/Rails/Config/default_config.php | 16 +---- 5 files changed, 80 insertions(+), 46 deletions(-) create mode 100755 lib/Rails/ActionView/Template/Renderer.php diff --git a/composer.json b/composer.json index 6e9c915..6cae6ac 100755 --- a/composer.json +++ b/composer.json @@ -14,5 +14,16 @@ "psr-0": { "Rails\\": "lib/" } + }, + "extra": { + "ZF2/library": [ + "zendframework/zend-validator", + "zendframework/zend-log", + "zendframework/zend-mail", + "zendframework/zend-console" + // "symfony/yaml" + // "leafo/scssphp" + // "toopay/assetic-minifier" + ] } } diff --git a/lib/Rails/ActionDispatch/Http/Parameters.php b/lib/Rails/ActionDispatch/Http/Parameters.php index cb371a2..a69722b 100755 --- a/lib/Rails/ActionDispatch/Http/Parameters.php +++ b/lib/Rails/ActionDispatch/Http/Parameters.php @@ -167,7 +167,7 @@ class Parameters implements \IteratorAggregate $obj_vars = get_object_vars($this); unset($obj_vars['deleteVars'], $obj_vars['putVars'], $obj_vars['_json_params_error'], $obj_vars['patchVars'], $obj_vars['other_params'], $obj_vars['files']); - $ret = array_merge_recursive($_POST, $_GET, $obj_vars, $this->deleteVars, $this->putVars, $this->patchVars, $this->other_params/*, $this->files*/); + $ret = array_merge($_POST, $_GET, $obj_vars, $this->deleteVars, $this->putVars, $this->patchVars, $this->other_params/*, $this->files*/); return $ret; } diff --git a/lib/Rails/ActionView/Template.php b/lib/Rails/ActionView/Template.php index d8697bc..95dcd9b 100755 --- a/lib/Rails/ActionView/Template.php +++ b/lib/Rails/ActionView/Template.php @@ -37,22 +37,20 @@ class Template extends Base /** * Template file. */ - protected $template_file; + private $_templateFile; /** * Full template path. */ - protected $template_filename; + private $_templateFilename; - protected $type; + private $_type; - protected $params; + private $_contents; - protected $contents; + private $inline_code; - protected $inline_code; - - protected $lambda; + private $_lambda; /** * $render_params could be: @@ -69,11 +67,11 @@ class Template extends Base $render_params = ['file' => $render_params]; } - $this->type = key($render_params); + $this->_type = key($render_params); - switch ($this->type) { + switch ($this->_type) { case 'file': - $this->template_file = array_shift($render_params); + $this->_templateFile = array_shift($render_params); break; /** @@ -81,7 +79,7 @@ class Template extends Base * no processing is needed. It will just be added to the layout, if any. */ case 'contents': - $this->contents = array_shift($render_params); + $this->_contents = array_shift($render_params); break; /** @@ -92,10 +90,10 @@ class Template extends Base break; case 'lambda': - $this->lambda = array_shift($render_params); + $this->_lambda = array_shift($render_params); break; } - $this->params = $params; + $this->_params = $params; if (isset($params['locals'])) { $locals = $params['locals']; @@ -171,13 +169,13 @@ class Template extends Base } if (strpos($name, '.') === 0) { - if (is_int(strpos($this->template_filename, Rails::config()->paths->views->toString()))) { + if (is_int(strpos($this->_templateFilename, Rails::config()->paths->views->toString()))) { $parts = array(); $path = substr( - $this->template_filename, strlen(Rails::config()->paths->views) + 1, - strlen(pathinfo($this->template_filename, PATHINFO_BASENAME)) * -1 + $this->_templateFilename, strlen(Rails::config()->paths->views) + 1, + strlen(pathinfo($this->_templateFilename, PATHINFO_BASENAME)) * -1 ) - . pathinfo($this->template_filename, PATHINFO_FILENAME); + . pathinfo($this->_templateFilename, PATHINFO_FILENAME); foreach (explode('/', $path) as $part) { $parts[] = ltrim($part, '_'); @@ -191,34 +189,34 @@ class Template extends Base protected function _init_render() { - $layout_wrap = !empty($this->params['layout']); + $layout_wrap = !empty($this->_params['layout']); if ($layout_wrap) { - $layout_file = $this->resolve_layout_file($this->params['layout']); + $layout_file = $this->resolve_layout_file($this->_params['layout']); if (!is_file($layout_file)) throw new Exception\LayoutMissingException( sprintf("Missing layout '%s' [ file => %s ]", - $this->params['layout'], $layout_file) + $this->_params['layout'], $layout_file) ); ob_start(); } - switch ($this->type) { + switch ($this->_type) { case 'file': $this->build_template_filename(); - if (!is_file($this->template_filename)) { + if (!is_file($this->_templateFilename)) { throw new Exception\TemplateMissingException( - sprintf("Missing template file %s", $this->template_filename) + sprintf("Missing template file %s", $this->_templateFilename) ); } - require $this->template_filename; + require $this->_templateFilename; break; case 'contents': - echo $this->contents; + echo $this->_contents; break; case 'inline': @@ -226,8 +224,8 @@ class Template extends Base break; case 'lambda': - $lambda = $this->lambda; - $this->lambda = null; + $lambda = $this->_lambda; + $this->_lambda = null; $lambda = $lambda->bindTo($this); $lambda(); break; @@ -268,14 +266,14 @@ class Template extends Base private function build_template_filename() { - $template = $this->template_file; + $template = $this->_templateFile; if (strpos($template, '/') === 0 || preg_match('/^[A-Za-z]:(?:\\\|\/)/', $template)) - $this->template_filename = $template; + $this->_templateFilename = $template; else { if (is_int(strpos($template, '.'))) { - $this->template_filename = Rails::config()->paths->views . '/' . $template; + $this->_templateFilename = Rails::config()->paths->views . '/' . $template; } else { - $this->template_filename = Rails::config()->paths->views . '/' . $template . '.php'; + $this->_templateFilename = Rails::config()->paths->views . '/' . $template . '.php'; } } } diff --git a/lib/Rails/ActionView/Template/Renderer.php b/lib/Rails/ActionView/Template/Renderer.php new file mode 100755 index 0000000..49623bc --- /dev/null +++ b/lib/Rails/ActionView/Template/Renderer.php @@ -0,0 +1,35 @@ +template = $template; + $this->file = $file; + } + + public function __get($prop) + { + return $this->getLocal($prop); + } + + public function __set($prop, $value) + { + $this->setLocal($prop); + } + + public function getLocal($prop) + { + return $this->template->getLocal($prop); + } + + public function setLocal($prop, $value) + { + $this->template->setLocal($prop); + } +} diff --git a/lib/Rails/Config/default_config.php b/lib/Rails/Config/default_config.php index c6a57ab..561516d 100755 --- a/lib/Rails/Config/default_config.php +++ b/lib/Rails/Config/default_config.php @@ -77,21 +77,11 @@ $config->active_record = [ $config->action_view = [ 'layout' => 'application', - 'suffix' => 'phtml', - 'helpers' => [ - // 'will_paginate' => [ - // /** - // * Sets a default custom renderer class. - // * Built-in renderers are Bootstrap and Legacy. - // * A custom renderer class can be created, extending - // * Rails\ActionView\Helper\WillPaginate\AbstractRenderer. - // */ - // 'renderer' => 'bootstrap', - // 'always_show' => false # Show pagination even if there's only 1 page - // ] - ] + 'suffix' => 'phtml' ]; +$config->plugins = []; + $config->action_mailer = [ /** * Allows "sendmail", "smtp" or "file".