This commit is contained in:
Parziphal 2013-10-26 10:53:37 -05:00
parent 3190e22c97
commit a70f9cbfdb
13 changed files with 48 additions and 35 deletions

View File

@ -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);

View File

@ -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

View File

@ -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;
}
}

View File

@ -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;
}
}
/**

View File

@ -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()) {

View File

@ -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());

View File

@ -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()) {

View File

@ -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();
}

View File

@ -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;
}
}
}

View File

@ -77,7 +77,7 @@ $config->active_record = [
$config->action_view = [
'layout' => 'application',
'suffix' => 'phtml'
// 'suffix' => 'phtml'
];
$config->plugins = [];

View File

@ -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.<br /><pre>%s</pre>",
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.<br /><pre>%s</pre>",
Rails\Assets\Parser\Javascript\ClosureApi\ClosureApi::errorFile(), $e->getMessage());
$this->error = $message;
}

View File

@ -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);
}
}
}
}

View File

@ -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)