From 9bdd0b30453d337aa48e6e75f5e0a3fe98b0500e Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sat, 11 Oct 2008 21:59:42 +0000 Subject: [PATCH] Cleaned up white space, also updated the RSS viewer to not use Config::getInstance() git-svn-id: http://svn.cleancode.org/svn/pickles@71 4d10bc64-7434-11dc-a737-d2d0f8310089 --- classes/Config.php | 20 ++++++++++---------- classes/Controller.php | 6 +++--- classes/DB.php | 16 ++++++++-------- classes/Error.php | 4 ++-- classes/Logger.php | 6 +++--- classes/Mailer.php | 10 +++++----- classes/Model.php | 8 ++++---- classes/Object.php | 8 ++++---- classes/Security.php | 4 ++-- classes/Viewer/Common.php | 10 ++++++---- classes/Viewer/Debug.php | 6 +++--- classes/Viewer/JSON.php | 4 ++-- classes/Viewer/PHP.php | 12 ++++++------ classes/Viewer/RSS.php | 20 +++++++++----------- classes/Viewer/Smarty.php | 6 +++--- 15 files changed, 70 insertions(+), 70 deletions(-) diff --git a/classes/Config.php b/classes/Config.php index ed74ec7..e7c3122 100755 --- a/classes/Config.php +++ b/classes/Config.php @@ -7,12 +7,12 @@ * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. - * + * * PICKLES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with PICKLES. If not, see * . @@ -64,7 +64,7 @@ class Config extends Object { /** * @todo LIBXML_NOCDATA is 5.1+ and I want PICKLES to * be 5.0+ compatible. Potential fix is to read - * the file in as a string, and if it has CDATA, + * the file in as a string, and if it has CDATA, * throw an internal warning. */ $data = simplexml_load_file($file, 'SimpleXMLElement', LIBXML_NOCDATA); @@ -86,7 +86,7 @@ class Config extends Object { } } - /** + /** * Gets the authentication value * * @return boolean The model's authentication setting or false @@ -111,8 +111,8 @@ class Config extends Object { return 'home'; } - - /** + + /** * Gets active status of the site * * @return boolean The site's disabled setting or false @@ -126,7 +126,7 @@ class Config extends Object { } /** - * Alias for $config->_public + * Alias for $config->_public * * @return Returns the variable value or null if no variable. */ @@ -138,7 +138,7 @@ class Config extends Object { return null; } - /** + /** * Gets the session value * * @return boolean The model's session setting or false @@ -198,7 +198,7 @@ class Config extends Object { foreach ($this->mappings->table as $table) { if (isset($table->name) && trim($table->name) != '' && $table->name == $requested_table) { $table_mapping['name'] = (string)(isset($table->alias) && trim($table->alias) != '' ? $table->alias : $table->name); - + if (isset($table->fields->field)) { foreach ($table->fields->field as $field) { if (isset($field->name) && trim($field->name) != '') { @@ -213,7 +213,7 @@ class Config extends Object { return $table_mapping; } - /** + /** * Gets the viewer value * * @return boolean The model's viewer setting or false diff --git a/classes/Controller.php b/classes/Controller.php index 7d87986..74fd2c4 100755 --- a/classes/Controller.php +++ b/classes/Controller.php @@ -7,12 +7,12 @@ * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. - * + * * PICKLES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with PICKLES. If not, see * . @@ -148,7 +148,7 @@ class Controller extends Object { // Creates a new viewer object $viewer_class = 'Viewer_' . $model->getViewer(); - $viewer = new $viewer_class($config, null); + $viewer = new $viewer_class($config, $error); // Sets the viewers properties $viewer->model_name = $model_name; diff --git a/classes/DB.php b/classes/DB.php index ff68904..32412d0 100755 --- a/classes/DB.php +++ b/classes/DB.php @@ -7,12 +7,12 @@ * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. - * + * * PICKLES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with PICKLES. If not, see * . @@ -106,7 +106,7 @@ class DB extends Object { return false; } - + return true; } @@ -137,7 +137,7 @@ class DB extends Object { */ public function execute($sql) { $this->open(); - + if (trim($sql) != '') { $this->results = mysql_query($sql, $this->connection); if (empty($this->results)) { @@ -194,7 +194,7 @@ class DB extends Object { return null; } - + /** * Gets a row from a result set * @@ -239,7 +239,7 @@ class DB extends Object { return null; } - + /** * Gets all the rows from a result set * @@ -322,7 +322,7 @@ class DB extends Object { /** * Updates an existing row row in a table * - * Easy update of an existing row or rows (depending on the passed + * Easy update of an existing row or rows (depending on the passed * conditions) in a table without being too savvy with SQL. * * @params string $table Name of the table you want to insert to @@ -338,7 +338,7 @@ class DB extends Object { $this->open(); if (trim($table) != '') { - $fields = $where = null; + $fields = $where = null; if (is_array($values)) { foreach ($values as $key => $value) { $fields .= ($fields ? ', ' : null) . $key . " = '" . mysql_real_escape_string(stripslashes($value), $this->connection) . "'"; diff --git a/classes/Error.php b/classes/Error.php index b2171dc..f55ceff 100755 --- a/classes/Error.php +++ b/classes/Error.php @@ -7,12 +7,12 @@ * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. - * + * * PICKLES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with PICKLES. If not, see * . diff --git a/classes/Logger.php b/classes/Logger.php index e6a4cc2..796857b 100644 --- a/classes/Logger.php +++ b/classes/Logger.php @@ -7,12 +7,12 @@ * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. - * + * * PICKLES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with PICKLES. If not, see * . @@ -33,7 +33,7 @@ class Logger extends Object { public function write($type, $message) { if (!file_exists(LOG_PATH)) { mkdir(LOG_PATH, 0777, true); } - + $message = '[' . date('r') . '] [client ' . $_SERVER['REMOTE_ADDR'] . '] [uri ' . $_SERVER['REQUEST_URI'] . '] [script ' . $_SERVER['SCRIPT_NAME'] . (isset($$_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '') . '] ' . $message; file_put_contents(LOG_PATH . $type . '.log', $message . "\n", FILE_APPEND); diff --git a/classes/Mailer.php b/classes/Mailer.php index 6a626ee..879fc7c 100644 --- a/classes/Mailer.php +++ b/classes/Mailer.php @@ -7,12 +7,12 @@ * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. - * + * * PICKLES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with PICKLES. If not, see * . @@ -50,7 +50,7 @@ class Mailer extends Object { * @return array An associative array with a status type and message */ public function send() { - + // Gets the values (is any) set in the config $defaults = $this->config->contact; @@ -72,11 +72,11 @@ class Mailer extends Object { // Loads the subject line prefix $prefix = isset($this->prefix) ? $this->prefix : (isset($defaults->prefix) && $defaults->prefix != '' ? $defaults->prefix : null); - + // Assembles the subject line with prefix $subject = str_replace("\n", '', (isset($prefix) ? '[' . $prefix . '] ' : '')); - // Tacks on the subject + // Tacks on the subject if (isset($this->subject)) { $subject .= $this->subject; } diff --git a/classes/Model.php b/classes/Model.php index a0ab88b..20b8936 100644 --- a/classes/Model.php +++ b/classes/Model.php @@ -7,12 +7,12 @@ * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. - * + * * PICKLES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with PICKLES. If not, see * . @@ -33,12 +33,12 @@ * available. */ class Model extends Object { - + /** * Data array used by the viewer */ protected $data = array(); - + /** * Config object */ diff --git a/classes/Object.php b/classes/Object.php index 54bf6c2..a2f52b6 100644 --- a/classes/Object.php +++ b/classes/Object.php @@ -7,12 +7,12 @@ * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. - * + * * PICKLES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with PICKLES. If not, see * . @@ -39,7 +39,7 @@ class Object { * Protected instance of the Config class */ protected $config = null; - + /** * Protected instance of the DB class */ @@ -64,7 +64,7 @@ class Object { } $parents = class_parents($this); - + $logger = new Logger(); $logger->write('object', get_class($this) . (is_array($parents) ? ' -> ' . implode(' -> ', $parents) : '')); } diff --git a/classes/Security.php b/classes/Security.php index 69f932b..fb0948d 100644 --- a/classes/Security.php +++ b/classes/Security.php @@ -7,12 +7,12 @@ * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. - * + * * PICKLES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with PICKLES. If not, see * . diff --git a/classes/Viewer/Common.php b/classes/Viewer/Common.php index d39927e..f6035b3 100644 --- a/classes/Viewer/Common.php +++ b/classes/Viewer/Common.php @@ -7,12 +7,12 @@ * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. - * + * * PICKLES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with PICKLES. If not, see * . @@ -38,9 +38,11 @@ abstract class Viewer_Common extends Object { * * @param object $model Object for the model we're loading */ - public function __construct(Config $config) { + public function __construct(Config $config, Error $error) { parent::__construct($config); + $this->error = $error; + /** * @todo This may need to be flipped on only for Smarty and PHP templates */ @@ -55,7 +57,7 @@ abstract class Viewer_Common extends Object { // XHTML compliancy stuff ini_set('arg_separator.output', '&'); ini_set('url_rewriter.tags', 'a=href,area=href,frame=src,input=src,fieldset='); - + header('Content-type: text/html; charset=UTF-8'); } diff --git a/classes/Viewer/Debug.php b/classes/Viewer/Debug.php index 039d146..1ee7eb9 100644 --- a/classes/Viewer/Debug.php +++ b/classes/Viewer/Debug.php @@ -7,12 +7,12 @@ * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. - * + * * PICKLES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with PICKLES. If not, see * . @@ -27,7 +27,7 @@ /** * Debugging Viewer * - * Displays debugging information on the screen. + * Displays debugging information on the screen. */ class Viewer_Debug extends Viewer_Common { diff --git a/classes/Viewer/JSON.php b/classes/Viewer/JSON.php index 447191e..eb5e3dd 100644 --- a/classes/Viewer/JSON.php +++ b/classes/Viewer/JSON.php @@ -7,12 +7,12 @@ * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. - * + * * PICKLES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with PICKLES. If not, see * . diff --git a/classes/Viewer/PHP.php b/classes/Viewer/PHP.php index 27393fe..f1b915c 100644 --- a/classes/Viewer/PHP.php +++ b/classes/Viewer/PHP.php @@ -7,12 +7,12 @@ * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. - * + * * PICKLES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with PICKLES. If not, see * . @@ -37,14 +37,14 @@ class Viewer_PHP extends Viewer_Common { * Displays the Smarty generated pages */ public function display() { - + $smarty->template_dir = '../templates/'; - /** + /** * @todo Resurrect my buffer clean up code */ $smarty->load_filter('output','trimwhitespace'); - + // Pass all of our controller values to Smarty $smarty->assign('section', $this->model->section); $smarty->assign('model', $this->model->name); @@ -52,7 +52,7 @@ class Viewer_PHP extends Viewer_Common { // Loads the data from the config $data = $this->config->getViewerData(); - + if (isset($data) && is_array($data)) { $smarty->assign('config', $data); } diff --git a/classes/Viewer/RSS.php b/classes/Viewer/RSS.php index 83cdd8c..fc67983 100644 --- a/classes/Viewer/RSS.php +++ b/classes/Viewer/RSS.php @@ -7,12 +7,12 @@ * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. - * + * * PICKLES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with PICKLES. If not, see * . @@ -46,21 +46,19 @@ class Viewer_RSS extends Viewer_Common { * @todo Error handling is non-existant. */ public function display() { - $config = Config::getInstance(); - $data = $this->model->getData(); + if (isset($this->data->channel)) { + $channel = $this->data['channel']; + $channel = $this->config->rss->$channel; - if (isset($data['channel'])) { - $channel = $config->rss[$data['channel']]; - - if (isset($data['items'])) { - $items = $data['items']; + if (isset($this->data->items)) { + $items = $this->data['items']; } else { - // Error - no items + $this->error->addError('No items were provided'); } } else { - // Error - no channel specified + $this->error->addError('No channel was specified'); } header('Content-type: application/rss+xml; charset=UTF-8'); diff --git a/classes/Viewer/Smarty.php b/classes/Viewer/Smarty.php index 3ac4653..0746bfa 100644 --- a/classes/Viewer/Smarty.php +++ b/classes/Viewer/Smarty.php @@ -7,12 +7,12 @@ * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. - * + * * PICKLES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with PICKLES. If not, see * . @@ -91,7 +91,7 @@ class Viewer_Smarty extends Viewer_Common { // Loads the data from the config $data = $this->config->getPublicData(); - + if (isset($data) && is_array($data)) { $smarty->assign('config', $data); }