Commit: 9ad4648dbdd246171b3fea0243703f5015d37010

Author: alkemann | Date: 2009-11-18 17:18:34 +0100
fixed some formating in paste model and controller
diff --git a/controllers/PastesController.php b/controllers/PastesController.php index f814332..12c6386 100644 --- a/controllers/PastesController.php +++ b/controllers/PastesController.php @@ -24,10 +24,7 @@ class PastesController extends \lithium\action\Controller { */ public function index() { return array('latest' => Paste::find('all', array('conditions'=> array( - 'design' => 'latest', - 'view' => 'all', - 'limit' => '10', - 'descending' => 'true' + 'design' => 'latest', 'view' => 'all', 'limit' => '10', 'descending' => 'true' )))); } @@ -110,4 +107,5 @@ class PastesController extends \lithium\action\Controller { $this->render('form'); } } + ?> \ No newline at end of file diff --git a/models/Paste.php b/models/Paste.php index ed51074..020c8a3 100644 --- a/models/Paste.php +++ b/models/Paste.php @@ -87,25 +87,25 @@ class Paste extends \lithium\data\Model { public static function __init($options = array()) { parent::__init($options); Paste::applyFilter('find', function($self, $params, $chain) { - if (isset($params['options']['conditions']['design']) && - $params['options']['conditions']['design'] == 'latest') { - $conditions = $params['options']['conditions']; - $result = $chain->next($self, $params, $chain); - if ($result === null) { - Paste::createView()->save(); - return null; //static::find('all', $conditions); - } - foreach ($result as $paste) { - $paste->preview = rawurldecode($paste->preview); - } - return $result; - } else { - $result = $chain->next($self, $params, $chain); - $result->content = rawurldecode($result->content); - $result->parsed = rawurldecode($result->parsed); - return $result; + if (isset($params['options']['conditions']['design']) && + $params['options']['conditions']['design'] == 'latest') { + $conditions = $params['options']['conditions']; + $result = $chain->next($self, $params, $chain); + if ($result === null) { + Paste::createView()->save(); + return null; //static::find('all', $conditions); } - }); + foreach ($result as $paste) { + $paste->preview = rawurldecode($paste->preview); + } + return $result; + } else { + $result = $chain->next($self, $params, $chain); + $result->content = rawurldecode($result->content); + $result->parsed = rawurldecode($result->parsed); + return $result; + } + }); Paste::applyFilter('save', function($self, $params, $chain) { if ($params['record']->id != '_design/latest') { $document = $params['record']; @@ -198,4 +198,5 @@ class Paste extends \lithium\data\Model { } } + ?> \ No newline at end of file