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
This commit is contained in:
parent
b25ba0992a
commit
9bdd0b3045
15 changed files with 70 additions and 70 deletions
|
@ -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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
|
@ -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) . "'";
|
||||
|
|
|
@ -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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
|
|
|
@ -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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
|
@ -33,12 +33,12 @@
|
|||
* available.
|
||||
*/
|
||||
class Model extends Object {
|
||||
|
||||
|
||||
/**
|
||||
* Data array used by the viewer
|
||||
*/
|
||||
protected $data = array();
|
||||
|
||||
|
||||
/**
|
||||
* Config object
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
|
@ -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) : ''));
|
||||
}
|
||||
|
|
|
@ -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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
|
|
|
@ -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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
|
@ -27,7 +27,7 @@
|
|||
/**
|
||||
* Debugging Viewer
|
||||
*
|
||||
* Displays debugging information on the screen.
|
||||
* Displays debugging information on the screen.
|
||||
*/
|
||||
class Viewer_Debug extends Viewer_Common {
|
||||
|
||||
|
|
|
@ -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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
|
|
|
@ -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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
|
@ -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');
|
||||
|
|
|
@ -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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue