diff --git a/lib/Rails/ActionController/Base.php b/lib/Rails/ActionController/Base.php index 4e4dd0d..e5a6c96 100755 --- a/lib/Rails/ActionController/Base.php +++ b/lib/Rails/ActionController/Base.php @@ -621,15 +621,18 @@ abstract class Base extends ActionController if (!$ext) { $template_name = $main_param; - if ($this->request()->format() == 'html') { + # Unknown routes don't have format. + $format = $this->request()->format(); + + if (!$format || $format == 'html') { $ext = 'php'; } else { - if ($this->request()->format() == 'xml') { + if ($format == 'xml') { $respParams['is_xml'] = true; } - $ext = [$this->request()->format(), 'php']; + $ext = [$format, 'php']; - $this->response()->headers()->contentType($this->request()->format()); + $this->response()->headers()->contentType($format); } } else { $pinfo = pathinfo($main_param); diff --git a/lib/Rails/ActionController/ExceptionHandler.php b/lib/Rails/ActionController/ExceptionHandler.php index 0c7b2b0..eac7e78 100755 --- a/lib/Rails/ActionController/ExceptionHandler.php +++ b/lib/Rails/ActionController/ExceptionHandler.php @@ -7,7 +7,9 @@ use Rails\ActionController\Base; /** * Basic use: * Create a class that extends this one. - * According to Exception or status, change the value of $template + * According to Exception or status, change the value of $template by + * overriding handle(). Although this isn't needed for basic handling, + * default setup should work fine. * The system will render that template. */ abstract class ExceptionHandler extends Base diff --git a/lib/Rails/ActionController/Response/Template.php b/lib/Rails/ActionController/Response/Template.php index a6916ed..aa331d4 100755 --- a/lib/Rails/ActionController/Response/Template.php +++ b/lib/Rails/ActionController/Response/Template.php @@ -73,13 +73,12 @@ class Template extends Base private function build_template_file_name() { - $views_path = Rails::config()->paths->views; - if (is_array($this->_params['extension'])) $ext = implode('.', $this->_params['extension']); else $ext = $this->_params['extension']; + $views_path = Rails::config()->paths->views; $this->template_file_name = $views_path . DIRECTORY_SEPARATOR . $this->_params['template_name'] . '.' . $ext; } } \ No newline at end of file diff --git a/lib/Rails/ActionDispatch/Request.php b/lib/Rails/ActionDispatch/Request.php index 4bbffe1..450f742 100755 --- a/lib/Rails/ActionDispatch/Request.php +++ b/lib/Rails/ActionDispatch/Request.php @@ -155,8 +155,9 @@ class Request public function format() { - if ($route = \Rails::application()->dispatcher()->router()->route()) + if ($route = \Rails::application()->dispatcher()->router()->route()) { return $route->format; + } } /** diff --git a/lib/Rails/ActiveRecord/Base.php b/lib/Rails/ActiveRecord/Base.php index 9362296..cdd0aeb 100755 --- a/lib/Rails/ActiveRecord/Base.php +++ b/lib/Rails/ActiveRecord/Base.php @@ -277,6 +277,8 @@ abstract class Base return $this->getAttribute($prop); } elseif ($this->getAssociation($prop) !== null) { return $this->loadedAssociations[$prop]; + } elseif ($getter = $this->getterExists($prop)) { + return $this->$getter(); } throw new Exception\RuntimeException( @@ -969,7 +971,6 @@ abstract class Base } else { $setter = 'set' . ucfirst($attrName); } - $reflection = self::getReflection(); if ($reflection->hasMethod($setter) && $reflection->getMethod($setter)->isPublic()) { diff --git a/lib/Rails/ActiveRecord/Base/Methods/AttributeMethods.php b/lib/Rails/ActiveRecord/Base/Methods/AttributeMethods.php index 45ec7f6..8cc60f7 100755 --- a/lib/Rails/ActiveRecord/Base/Methods/AttributeMethods.php +++ b/lib/Rails/ActiveRecord/Base/Methods/AttributeMethods.php @@ -194,6 +194,8 @@ trait AttributeMethods if (!$attrs) { return; } + // if (get_called_class() == 'TagImplication') + // vpe('a', $attrs); if (empty($options['without_protection'])) { $this->filterProtectedAttributes($attrs); @@ -210,6 +212,7 @@ trait AttributeMethods // return; // } + // if (get_called_class() == 'TagImplication' && !in_array($propName, ['reason', 'creator_id', 'is_pending'])) // $inflector = Rails::services()->get('inflector'); // $reflection = new \ReflectionClass(get_called_class()); diff --git a/lib/Rails/ActiveRecord/Registry.php b/lib/Rails/ActiveRecord/Registry.php index e044f42..1a682c3 100755 --- a/lib/Rails/ActiveRecord/Registry.php +++ b/lib/Rails/ActiveRecord/Registry.php @@ -6,9 +6,7 @@ use Rails\ActiveRecord\ActiveRecord; /** * This class is supposed to store all the - * models created. Since they're objects, this - * serves as cache. We will save up memory and - * sql queries. This is supposed to be great. + * models created. */ class Registry { @@ -84,6 +82,7 @@ class Registry public function search($id) { + return; $id = (string)$id; if (isset($this->_reg[$this->connection()][$this->_current_model]) && isset($this->_reg[$this->connection()][$this->_current_model][$id])) return $this->_reg[$this->connection()][$this->_current_model][$id]; @@ -91,6 +90,7 @@ class Registry public function register($model) { + return; $cn = get_class($model); if (!$cn::table()->primaryKey()) { diff --git a/lib/Rails/Application/Base.php b/lib/Rails/Application/Base.php index b75554d..ffe2c16 100755 --- a/lib/Rails/Application/Base.php +++ b/lib/Rails/Application/Base.php @@ -75,11 +75,16 @@ class Base $paths = Rails::config()->paths; $paths->application->setPath($basePath)->setBasePaths([]); + $trait = $basePath . '/traits/AdminController.php'; require_once $trait; - $trait = $basePath . '/traits/ApplicationController.php'; require_once $trait; + $panelAppController = $basePath . '/controllers/ApplicationController.php'; + require_once $panelAppController; + $panelController = $basePath . '/controllers/AdminController.php'; + require_once $panelController; + Rails::loader()->addPaths([ $paths->helpers->toString(), @@ -176,8 +181,9 @@ class Base if ($this->dispatcher()->router()->route()->assets_route()) { Rails::assets()->server()->dispatch_request(); } else { - if ($this->dispatcher()->router()->route()->rails_admin()) - $this->setPanelConfig(); + if ($this->dispatcher()->router()->route()->rails_admin()) { + self::setPanelConfig(); + } $this->_load_controller(); $this->controller()->run_request_action(); } diff --git a/lib/Rails/Assets/File.php b/lib/Rails/Assets/File.php index fcadce6..200217e 100755 --- a/lib/Rails/Assets/File.php +++ b/lib/Rails/Assets/File.php @@ -54,7 +54,9 @@ class File if (preg_match('/^\w:/', $path) || strpos($path, '/') === 0) { $path = str_replace('\\', '/', $path); + foreach ($this->assets_paths() as $asset_path) { + $asset_path = str_replace('\\', '/', $asset_path); if (strpos($path, $asset_path) === 0) { $this->baseDir = $asset_path; $path = substr($path, strlen($asset_path) + 1); @@ -223,4 +225,4 @@ class File $this->subDirs = $subDirs; } -} \ No newline at end of file +} diff --git a/lib/Rails/Config/default_config.php b/lib/Rails/Config/default_config.php index 561516d..ad5a1eb 100755 --- a/lib/Rails/Config/default_config.php +++ b/lib/Rails/Config/default_config.php @@ -77,7 +77,7 @@ $config->active_record = [ $config->action_view = [ 'layout' => 'application', - 'suffix' => 'phtml' + // 'suffix' => 'phtml' ]; $config->plugins = []; diff --git a/lib/Rails/Panel/controllers/AdminController.php b/lib/Rails/Panel/controllers/AdminController.php index 3a6df9c..b4e5032 100755 --- a/lib/Rails/Panel/controllers/AdminController.php +++ b/lib/Rails/Panel/controllers/AdminController.php @@ -81,21 +81,16 @@ class AdminController extends ApplicationController Rails::assets()->compileFile($file); } } catch (Rails\Assets\Parser\Javascript\ClosureApi\Exception\ErrorsOnCodeException $e) { - if ($e instanceof Rails\Assets\Parser\Javascript\ClosureApi\Exception\ErrorsOnCodeException) { - Rails::log()->error( - sprintf( - "[%s] Asset compilation error for file %s\n%s", - date('Y-m-d H:i:s'), - $file_path . '.' . $ext, - $e->getMessage() - ) - ); - $message = sprintf("ClosureAPI reported an error - JS file was saved to %s for verfications, error was logged.
%s
", - Rails\Assets\Parser\Javascript\ClosureApi\ClosureApi::errorFile(), $e->getMessage()); - } else { - // throw $e; - // $message = sprintf('%s raised: %s', get_class($e), $e->getMessage()); - } + Rails::log()->error( + sprintf( + "[%s] Asset compilation error for file %s\n%s", + date('Y-m-d H:i:s'), + $file_path . '.' . $ext, + $e->getMessage() + ) + ); + $message = sprintf("ClosureAPI reported an error - JS file was saved to %s for verfications, error was logged.
%s
", + Rails\Assets\Parser\Javascript\ClosureApi\ClosureApi::errorFile(), $e->getMessage()); $this->error = $message; } diff --git a/lib/Rails/SystemExit/SystemExit.php b/lib/Rails/SystemExit/SystemExit.php index d69b36f..d8a6bd9 100755 --- a/lib/Rails/SystemExit/SystemExit.php +++ b/lib/Rails/SystemExit/SystemExit.php @@ -16,7 +16,7 @@ class SystemExit public function unregister($name) { if (isset($this->callbacks[$name])) { - unset($this->callbacks[$name]; + unset($this->callbacks[$name]); return true; } else { return false; @@ -29,4 +29,4 @@ class SystemExit call_user_func($callback); } } -} \ No newline at end of file +} diff --git a/lib/Rails/Toolbox/FileTools.php b/lib/Rails/Toolbox/FileTools.php index 558b353..5d284d1 100755 --- a/lib/Rails/Toolbox/FileTools.php +++ b/lib/Rails/Toolbox/FileTools.php @@ -12,8 +12,9 @@ use FilesystemIterator; abstract class FileTools { /** - * Deletes all files directories recursively from a directory. + * Deletes all files and directories recursively from a directory. * Note that existance of the dir must be previously checked. + * The directory isn't deleted. * SO.com:1407338 */ static public function emptyDir($dirpath)