Massive update that broke backwards compatibility with older versions of PICKLES.
git-svn-id: http://svn.cleancode.org/svn/pickles@109 4d10bc64-7434-11dc-a737-d2d0f8310089
This commit is contained in:
parent
714e8e1403
commit
466c35a6bb
30 changed files with 364 additions and 165 deletions
|
@ -18,7 +18,7 @@
|
|||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Joshua John Sherman <josh@phpwithpickles.org>
|
||||
* @copyright Copyright 2007, 2008 Joshua John Sherman
|
||||
* @copyright Copyright 2007, 2008, 2009 Joshua John Sherman
|
||||
* @link http://phpwithpickles.org
|
||||
* @license http://www.gnu.org/copyleft/lesser.html
|
||||
* @package PICKLES
|
||||
|
@ -64,29 +64,38 @@ class Config extends Object {
|
|||
*/
|
||||
public function load($file) {
|
||||
|
||||
if (file_exists($file)) {
|
||||
/**
|
||||
* @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,
|
||||
* throw an internal warning.
|
||||
*/
|
||||
$data = simplexml_load_file($file, 'SimpleXMLElement', LIBXML_NOCDATA);
|
||||
// Makes sure the file is legit on the surface
|
||||
if (file_exists($file) && is_file($file) && is_readable($file)) {
|
||||
|
||||
// Loops through the top level nodes to find public nodes
|
||||
$variables = get_object_vars($data);
|
||||
// Pulls the contents of the file to allow for validation
|
||||
$contents = trim(file_get_contents($file));
|
||||
|
||||
if (is_array($variables)) {
|
||||
foreach ($variables as $key => $value) {
|
||||
if (is_object($value) && isset($value->attributes()->public) && $value->attributes()->public == true) {
|
||||
$this->_public[$key] = $value;
|
||||
// Checks that the file contents isn't empty and that the config node is present
|
||||
if ($contents != '' && substr($contents, 0, 8) == '<config>' && substr($contents, -9) == '</config>') {
|
||||
|
||||
/**
|
||||
* @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,
|
||||
* throw an internal warning.
|
||||
*/
|
||||
$data = simplexml_load_string($contents, 'SimpleXMLElement', LIBXML_NOCDATA);
|
||||
|
||||
// Loops through the top level nodes to find public nodes
|
||||
$variables = get_object_vars($data);
|
||||
|
||||
if (is_array($variables)) {
|
||||
foreach ($variables as $key => $value) {
|
||||
if (is_object($value) && isset($value->attributes()->public) && $value->attributes()->public == true) {
|
||||
$this->_public[$key] = $value;
|
||||
}
|
||||
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Joshua John Sherman <josh@phpwithpickles.org>
|
||||
* @copyright Copyright 2007, 2008 Joshua John Sherman
|
||||
* @copyright Copyright 2007, 2008, 2009 Joshua John Sherman
|
||||
* @link http://phpwithpickles.org
|
||||
* @license http://www.gnu.org/copyleft/lesser.html
|
||||
* @package PICKLES
|
||||
|
@ -95,125 +95,149 @@ class Controller extends Object {
|
|||
|
||||
// Grab the passed in module or use the default
|
||||
#$module_name = isset($_REQUEST['module']) ? strtr($_REQUEST['module'], '-', '_') : $config->getDefaultModule();
|
||||
$module_name = isset($_REQUEST['module']) ? $_REQUEST['module'] : $config->getDefaultModule();
|
||||
$module['requested']['name'] = isset($_REQUEST['module']) ? $_REQUEST['module'] : $config->getDefaultModule();
|
||||
|
||||
// Checks if we have a display type passed in
|
||||
if (strpos($module['requested']['name'], '.') !== false) {
|
||||
list($module['requested']['name'], $display_type) = explode('.', $module['requested']['name']);
|
||||
|
||||
// Checks for validity, only JSON, RSS and XML can be passed in
|
||||
switch (strtolower($display_type)) {
|
||||
case 'json':
|
||||
case 'rss':
|
||||
case 'xml':
|
||||
$display_type = strtoupper($display_type);
|
||||
break;
|
||||
|
||||
default:
|
||||
unset($display_type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Maybe the logout shouldn't be an internal thing, what if the
|
||||
* user wanted to call the logout page something else? or better
|
||||
* yet, they want to next it, like /users/logout?
|
||||
* @todo May want to make it work from /store/admin/logout and not just from /
|
||||
*/
|
||||
if ($module_name == 'logout') {
|
||||
if ($module['requested']['name'] == 'logout') {
|
||||
$security = new Security($config, $db);
|
||||
$security->logout();
|
||||
}
|
||||
else {
|
||||
// Loads the requested module's information
|
||||
$module_filename = strtr($module_name, '-', '_');
|
||||
$module_file = '../modules/' . $module_filename . '.php';
|
||||
$module_class = strtr($module_filename, '/', '_');
|
||||
|
||||
$module_name = split('_', strtr($module_name, '/', '_'));
|
||||
$module['requested']['filename'] = strtr($module['requested']['name'], '-', '_');
|
||||
$module['requested']['php_file'] = '../modules/' . $module['requested']['filename'] . '.php';
|
||||
$module['requested']['class_name'] = strtr($module['requested']['filename'], '/', '_');
|
||||
|
||||
// Establishes the shared module information
|
||||
$shared_module_class = $config->getSharedModule($module_class);
|
||||
$shared_module_filename = strtr($shared_module_class, '_', '/');
|
||||
$shared_module_file = PICKLES_PATH . 'common/modules/' . $shared_module_filename . '.php';
|
||||
$shared_module_name = split('_', $shared_module_class);
|
||||
// @todo Bug with requested modules with a dash in the name (store-locator == shared module 'store')
|
||||
$module['shared']['class_name'] = $config->getSharedModule($module['requested']['class_name']);
|
||||
$module['shared']['filename'] = strtr($module['shared']['class_name'], '_', '/');
|
||||
$module['shared']['php_file'] = PICKLES_PATH . 'common/modules/' . $module['shared']['filename'] . '.php';
|
||||
$module['shared']['name'] = $module['shared']['filename'];
|
||||
|
||||
// Tries to load the site level module
|
||||
if (file_exists($module_file)) {
|
||||
require_once $module_file;
|
||||
if (file_exists($module['requested']['php_file'])) {
|
||||
require_once $module['requested']['php_file'];
|
||||
|
||||
if (class_exists($module_class)) {
|
||||
$module = new $module_class($config, $db, $mailer, $error);
|
||||
if (class_exists($module['requested']['class_name'])) {
|
||||
$module['object'] = new $module['requested']['class_name']($config, $db, $mailer, $error);
|
||||
}
|
||||
}
|
||||
// Tries to load the shared module
|
||||
else if (file_exists($shared_module_file) && $shared_module_name != false) {
|
||||
require_once $shared_module_file;
|
||||
else if (file_exists($module['shared']['php_file']) && $module['shared']['name'] != false) {
|
||||
require_once $module['shared']['php_file'];
|
||||
|
||||
if (class_exists($shared_module_class)) {
|
||||
$module = new $shared_module_class($config, $db, $mailer, $error);
|
||||
if (class_exists($module['shared']['class_name'])) {
|
||||
$module['object'] = new $module['shared']['class_name']($config, $db, $mailer, $error);
|
||||
}
|
||||
}
|
||||
// Loads the stock module
|
||||
else {
|
||||
$module = new Module($config, $db, $mailer, $error);
|
||||
$module['object'] = new Module($config, $db, $mailer, $error);
|
||||
}
|
||||
|
||||
// Checks if we loaded a module file and no class was present
|
||||
if ($module != null) {
|
||||
if ($module['object'] != null) {
|
||||
|
||||
// Potentially starts the session if it's not started already
|
||||
if ($module->getSession() === true) {
|
||||
if ($module['object']->getSession() === true) {
|
||||
if (ini_get('session.auto_start') == 0) {
|
||||
session_start();
|
||||
}
|
||||
}
|
||||
|
||||
// Potentially requests use authentication
|
||||
if ($module->getAuthentication() === true) {
|
||||
if ($module['object']->getAuthentication() === true) {
|
||||
if (!isset($security)) {
|
||||
$security = new Security($config, $db);
|
||||
}
|
||||
$security->authenticate();
|
||||
}
|
||||
|
||||
// Checks if the display type was passed in
|
||||
if (!isset($display_type)) {
|
||||
$display_type = $module['object']->getDisplay();
|
||||
}
|
||||
|
||||
//var_dump($display_type);
|
||||
|
||||
// Creates a new viewer object
|
||||
$display_type = $module->getDisplay();
|
||||
$display_class = 'Display_' . $display_type;
|
||||
$display = new $display_class($config, $error);
|
||||
$display = new $display_class($config, $error);
|
||||
|
||||
// Potentially establishes caching
|
||||
$caching = $module->getCaching();
|
||||
$caching = $module['object']->getCaching();
|
||||
if ($caching) {
|
||||
$display->caching = $caching;
|
||||
|
||||
if ($display_type == DISPLAY_SMARTY) {
|
||||
$module->setSmartyObject($display->getSmartyObject());
|
||||
$module['object']->setSmartyObject($display->getSmartyObject());
|
||||
}
|
||||
}
|
||||
|
||||
$display->prepare();
|
||||
|
||||
// Potentially executes the module's logic
|
||||
if (method_exists($module, '__default')) {
|
||||
$module->__default();
|
||||
if (method_exists($module['object'], '__default')) {
|
||||
$module['object']->__default();
|
||||
|
||||
if ($module->getCacheID()) {
|
||||
$display->cache_id = $module->getCacheID();
|
||||
if ($module['object']->getCacheID()) {
|
||||
$display->cache_id = $module['object']->getCacheID();
|
||||
}
|
||||
|
||||
if (isset($mailer->message)) {
|
||||
$status = $mailer->send();
|
||||
$module->type = $status['type'];
|
||||
$module->message = $status['message'];
|
||||
$module['object']->setPublic('type', $status['type']);
|
||||
$module['object']->setPublic('message', $status['message']);
|
||||
}
|
||||
}
|
||||
|
||||
// If the loaded module has a name, use it to override
|
||||
if ($module->name != null && $module_filename != $module->name) {
|
||||
$module_filename = $module->name;
|
||||
$module_file = '../modules/' . $module_filename . '.php';
|
||||
$module_class = strtr($module_filename, '/', '_');
|
||||
$module_name = split('_', $module_class);
|
||||
if ($module['object']->name != null && $module['requested']['filename'] != $module['object']->name) {
|
||||
$module['requested']['filename'] = $module['object']->name;
|
||||
$module['requested']['name'] = $module['object']->name;
|
||||
}
|
||||
|
||||
if ($module['object']->template != null) {
|
||||
$module['requested']['filename'] = $module['object']->template;
|
||||
}
|
||||
|
||||
// Sets the display's properties
|
||||
$display->module_filename = $module_filename;
|
||||
$display->module_name = $module_name;
|
||||
$display->shared_module_filename = $shared_module_filename;
|
||||
$display->shared_module_name = $shared_module_name;
|
||||
|
||||
$display->module_name = $module['requested']['name'];
|
||||
$display->module_filename = $module['requested']['filename'];
|
||||
$display->shared_module_name = $module['shared']['name'];
|
||||
$display->shared_module_filename = $module['shared']['filename'];
|
||||
|
||||
// Loads the module data into the display to be rendered
|
||||
/**
|
||||
* @todo perhaps make this a passed variable
|
||||
*/
|
||||
$display->data = $module->getData();
|
||||
$display->data = $module['object']->public;
|
||||
|
||||
// Runs the requested rendering function
|
||||
$display->render();
|
||||
$display->render($module);
|
||||
|
||||
// Do some cleanup
|
||||
if (isset($security)) {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Joshua John Sherman <josh@phpwithpickles.org>
|
||||
* @copyright Copyright 2007, 2008 Joshua John Sherman
|
||||
* @copyright Copyright 2007, 2008, 2009 Joshua John Sherman
|
||||
* @link http://phpwithpickles.org
|
||||
* @license http://www.gnu.org/copyleft/lesser.html
|
||||
* @package PICKLES
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Joshua John Sherman <josh@phpwithpickles.org>
|
||||
* @copyright Copyright 2007, 2008 Joshua John Sherman
|
||||
* @copyright Copyright 2007, 2008, 2009 Joshua John Sherman
|
||||
* @link http://phpwithpickles.org
|
||||
* @license http://www.gnu.org/copyleft/lesser.html
|
||||
* @package PICKLES
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Joshua John Sherman <josh@phpwithpickles.org>
|
||||
* @copyright Copyright 2007, 2008 Joshua John Sherman
|
||||
* @copyright Copyright 2007, 2008, 2009 Joshua John Sherman
|
||||
* @link http://phpwithpickles.org
|
||||
* @license http://www.gnu.org/copyleft/lesser.html
|
||||
* @package PICKLES
|
||||
|
@ -110,10 +110,9 @@ class Display_Smarty extends Display_Common {
|
|||
if (!$this->smarty->is_cached($template, $cache_id)) {
|
||||
|
||||
// Build the combined module name array and assign it
|
||||
$module = $this->module_name;
|
||||
$module[0] = strtr($module[0], '_', '-');
|
||||
array_unshift($module, $this->module_filename);
|
||||
$this->smarty->assign('module', $module);
|
||||
$module_name = split('/', $this->module_name);
|
||||
array_unshift($module_name, $this->module_name);
|
||||
$this->smarty->assign('module_name', $module_name);
|
||||
|
||||
// Only assign the template if it's not the index, this avoids an infinite loop.
|
||||
if ($this->template != 'index.tpl') {
|
||||
|
@ -128,10 +127,17 @@ class Display_Smarty extends Display_Common {
|
|||
}
|
||||
|
||||
// Loads the module's data
|
||||
// @todo remove me!
|
||||
// if (isset($this->data) && is_array($this->data)) {
|
||||
// foreach ($this->data as $variable => $value) {
|
||||
// $this->smarty->assign($variable, $value);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Loads the module's public data
|
||||
// @todo For refactoring, need to change the name from data
|
||||
if (isset($this->data) && is_array($this->data)) {
|
||||
foreach ($this->data as $variable => $value) {
|
||||
$this->smarty->assign($variable, $value);
|
||||
}
|
||||
$this->smarty->assign('module', $this->data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Joshua John Sherman <josh@phpwithpickles.org>
|
||||
* @copyright Copyright 2007, 2008 Joshua John Sherman
|
||||
* @copyright Copyright 2007, 2008, 2009 Joshua John Sherman
|
||||
* @link http://phpwithpickles.org
|
||||
* @license http://www.gnu.org/copyleft/lesser.html
|
||||
* @package PICKLES
|
||||
|
@ -37,7 +37,13 @@ class Module extends Object {
|
|||
/**
|
||||
* Data array used by the display
|
||||
*/
|
||||
protected $data = array();
|
||||
// @todo REMOVE THIS
|
||||
//protected $data = array();
|
||||
|
||||
/**
|
||||
* Array of public variables to be available by the display
|
||||
*/
|
||||
protected $public = array();
|
||||
|
||||
/**
|
||||
* Passed objects
|
||||
|
@ -48,9 +54,10 @@ class Module extends Object {
|
|||
protected $error = null;
|
||||
|
||||
/**
|
||||
* Name of the module
|
||||
* Template file for the module
|
||||
*/
|
||||
protected $name = null;
|
||||
protected $template = null;
|
||||
protected $name = null;
|
||||
|
||||
/**
|
||||
* Module defaults
|
||||
|
@ -157,10 +164,23 @@ class Module extends Object {
|
|||
*/
|
||||
public function getDisplay() {
|
||||
|
||||
if (in_array($this->display, array(DISPLAY_JSON, DISPLAY_PHP, DISPLAY_RSS, DISPLAY_SMARTY))) {
|
||||
return $this->display;
|
||||
// Checks if the module has a display tyoe
|
||||
if (isset($this->display)) {
|
||||
// Checks if multiple display types are supported
|
||||
if (is_array($this->display)) {
|
||||
$display = $this->display[0];
|
||||
}
|
||||
else {
|
||||
$display = $this->display;
|
||||
}
|
||||
|
||||
if (in_array($display, array(DISPLAY_JSON, DISPLAY_PHP, DISPLAY_RSS, DISPLAY_SMARTY))) {
|
||||
return $display;
|
||||
}
|
||||
}
|
||||
else if (isset($this->config->modules->display)) {
|
||||
|
||||
// Checks for a display type in the config
|
||||
if (isset($this->config->modules->display)) {
|
||||
return (string)$this->config->modules->display;
|
||||
}
|
||||
else {
|
||||
|
@ -191,12 +211,29 @@ class Module extends Object {
|
|||
*
|
||||
* @param string $variable Name of the variable to be set
|
||||
* @param mixed $value Data to be set
|
||||
* @todo REMOVE ME!
|
||||
*/
|
||||
/*
|
||||
public function __set($variable, $value) {
|
||||
if ($variable != 'cache_id') {
|
||||
$this->data[$variable] = $value;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public function setPublic($variable, $value) {
|
||||
$this->public[$variable] = $value;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getPublic($variable) {
|
||||
if (isset($this->public[$variable])) {
|
||||
return $this->public[$variable];
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function setSmartyObject(Smarty $smarty) {
|
||||
$this->smarty = $smarty;
|
||||
|
@ -212,11 +249,13 @@ class Module extends Object {
|
|||
break;
|
||||
|
||||
case DISPLAY_SMARTY:
|
||||
if ($this->smarty->template_exists('index.tpl')) {
|
||||
return $this->smarty->is_cached('index.tpl', $id);
|
||||
}
|
||||
else {
|
||||
return $this->smarty->is_cached($template, $id);
|
||||
if (is_object($this->smarty)) {
|
||||
if ($this->smarty->template_exists('index.tpl')) {
|
||||
return $this->smarty->is_cached('index.tpl', $id);
|
||||
}
|
||||
else {
|
||||
return $this->smarty->is_cached($template, $id);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -34,11 +34,11 @@ class store extends Module {
|
|||
$_SESSION['cart']['count'] = $count;
|
||||
}
|
||||
|
||||
$this->cart = $_SESSION['cart'];
|
||||
$this->setPublic('cart', $_SESSION['cart']);
|
||||
|
||||
// Loads the navigation
|
||||
if (isset($config->store->sections)) {
|
||||
$this->subnav = $config->store->sections;
|
||||
$this->setPublic('subnav', $config->store->sections);
|
||||
}
|
||||
|
||||
// Loads the categories
|
||||
|
@ -56,7 +56,7 @@ class store extends Module {
|
|||
}
|
||||
}
|
||||
|
||||
$this->categories = $categories;
|
||||
$this->setPublic('categories', $categories);
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -65,8 +65,8 @@ class store extends Module {
|
|||
$object = new store_home($this->config, $this->db, $this->mailer, $this->error);
|
||||
$object->__default();
|
||||
|
||||
$this->data = $object->data;
|
||||
$this->name = 'store/home';
|
||||
$this->public = $object->public;
|
||||
$this->name = 'store/home';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
38
common/modules/store/admin.php
Normal file
38
common/modules/store/admin.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
class store_admin extends Module {
|
||||
|
||||
protected $authentication = true;
|
||||
|
||||
public function __construct(Config $config, DB $db, Mailer $mailer, Error $error) {
|
||||
parent::__construct($config, $db, $mailer, $error);
|
||||
|
||||
$options = array(
|
||||
'home',
|
||||
'orders',
|
||||
'customers',
|
||||
'products',
|
||||
'categories',
|
||||
'coupons',
|
||||
'affiliates',
|
||||
'vendors',
|
||||
'gift certs',
|
||||
'reports',
|
||||
'settings'
|
||||
);
|
||||
$this->setPublic('options', $options);
|
||||
|
||||
$this->template = 'store/admin';
|
||||
}
|
||||
|
||||
public function __default() {
|
||||
// Forces store/admin/home as the first page you get when only /store is called
|
||||
$object = new store_admin_home($this->config, $this->db, $this->mailer, $this->error);
|
||||
$object->__default();
|
||||
|
||||
$this->public = $object->public;
|
||||
$this->name = 'store/admin/home';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
18
common/modules/store/admin/affiliates.php
Normal file
18
common/modules/store/admin/affiliates.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
class store_admin_affiliates extends store_admin {
|
||||
|
||||
public function __default() {
|
||||
$sql = '
|
||||
SELECT *
|
||||
FROM affiliates
|
||||
ORDER BY
|
||||
unpaid_balance DESC,
|
||||
order_count DESC
|
||||
;
|
||||
';
|
||||
$this->setPublic('affiliates', $this->db->getArray($sql));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
10
common/modules/store/admin/home.php
Normal file
10
common/modules/store/admin/home.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
class store_admin_home extends store_admin {
|
||||
|
||||
public function __default() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -20,7 +20,7 @@ class store_cart extends store {
|
|||
public function __default() {
|
||||
|
||||
if (isset($_SESSION['cart'])) {
|
||||
$this->cart = $_SESSION['cart'];
|
||||
$this->setPublic('cart', $_SESSION['cart']);
|
||||
}
|
||||
|
||||
$discounts = null;
|
||||
|
@ -83,7 +83,7 @@ class store_cart extends store {
|
|||
}
|
||||
}
|
||||
|
||||
$this->discounts = $discounts;
|
||||
$this->setPublic('discounts', $discounts);
|
||||
|
||||
//var_dump($_SESSION['cart']);
|
||||
//var_dump($_SESSION['cart']['discounts']['inPink']);
|
||||
|
|
|
@ -12,14 +12,17 @@ class store_category extends store {
|
|||
WHERE permalink = '{$_REQUEST['permalink']}';
|
||||
");
|
||||
|
||||
$this->category = $category;
|
||||
$this->products = $this->db->getArray("
|
||||
$this->setPublic('category', $category);
|
||||
|
||||
$sql = "
|
||||
SELECT p.*
|
||||
FROM products AS p
|
||||
INNER JOIN category_xref as c
|
||||
ON p.id = c.product_id
|
||||
WHERE c.category_id = '{$category['id']}';
|
||||
");
|
||||
";
|
||||
|
||||
$this->setPublic('products', $this->db->getArray($sql));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class store_checkout extends store {
|
|||
|
||||
foreach ($values as $value) {
|
||||
if (trim($value) == '') {
|
||||
$this->message = 'Error: The ' . strtr($key, '_', ' ') . ' field is required.';
|
||||
$this->setPublic('message', 'Error: The ' . strtr($key, '_', ' ') . ' field is required.');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class store_checkout extends store {
|
|||
// Checks that the password and confirmation are the same
|
||||
if (isset($_REQUEST['password']) && trim($_REQUEST['password']) != '') {
|
||||
if ($_REQUEST['password'] != $_REQUEST['confirm_password']) {
|
||||
$this->message = 'Error: The password and confirm password fields must match.';
|
||||
$this->setPublic('message', 'Error: The password and confirm password fields must match.');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -181,6 +181,7 @@ class store_checkout extends store {
|
|||
|
||||
// Contacts the user to advise them of their sign up
|
||||
// @todo This is as MenoSol specific as it gets
|
||||
// @todo Swap out for the mailer class as well, then I can trap the sends and override for testing.
|
||||
mail($email, 'Welcome to Menopause Solutions', "
|
||||
Menopause Solutions
|
||||
-------------------------------------------------------------------
|
||||
|
@ -237,7 +238,7 @@ URL: http://www.menopausesolutions.net
|
|||
else {
|
||||
// @todo Change this out for a confirmation box and re-submit
|
||||
// $this->status = 'ExistingCustomer';
|
||||
$this->message = 'Error: The email address you supplied is already in use. There is an existing customer login form on the right-hand side of the page. If you wish to continue without logging in, please provide a different email address or delete the contents of the password box (this will skip the process of creating a new account).';
|
||||
$this->setPublic('message', 'Error: The email address you supplied is already in use. There is an existing customer login form on the right-hand side of the page. If you wish to continue without logging in, please provide a different email address or delete the contents of the password box (this will skip the process of creating a new account).');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -254,8 +255,8 @@ URL: http://www.menopausesolutions.net
|
|||
}
|
||||
|
||||
if ($this->error->getErrors()) {
|
||||
$this->status = 'Error';
|
||||
$this->message = 'There was an error adding the customer account (' . implode('. ', $this->error->getErrors()) . '.)';
|
||||
$this->setPublic('status', 'Error');
|
||||
$this->setPublic('message', 'There was an error adding the customer account (' . implode('. ', $this->error->getErrors()) . '.)');
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
|
@ -272,8 +273,8 @@ URL: http://www.menopausesolutions.net
|
|||
$xref_type = 'EMAIL';
|
||||
}
|
||||
else {
|
||||
$this->status = 'Error';
|
||||
$this->message = 'There was an internal error.';
|
||||
$this->setPublic('status', 'Error');
|
||||
$this->setPublic('message', 'There was an internal error.');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -452,12 +453,12 @@ Email : {$email}
|
|||
mail('weborders@menopausesolutions.net, tom@epuresolutions.com, joshsherman@gmail.com', 'Menopause Solutions Order Notification', $receipt, 'From: noreply@menopausesolutions.net');
|
||||
}
|
||||
|
||||
$this->status = $response['response_code'];
|
||||
$this->message = $response['response_reason_text'];
|
||||
$this->setPublic('status', $response['response_code']);
|
||||
$this->setPublic('message', $response['response_reason_text']);
|
||||
}
|
||||
// Free order (no payment processing necessary)
|
||||
else {
|
||||
$this->status = 'Approved';
|
||||
$this->setPublic('status', 'Approved');
|
||||
|
||||
$this->db->execute("
|
||||
UPDATE orders
|
||||
|
@ -477,8 +478,8 @@ Email : {$email}
|
|||
}
|
||||
}
|
||||
else {
|
||||
$this->status = 'Error';
|
||||
$this->message = 'A duplicate transaction has been submitted.';
|
||||
$this->setPublic('status', 'Error');
|
||||
$this->setPublic('message', 'A duplicate transaction has been submitted.');
|
||||
}
|
||||
|
||||
// Unsets the cart variable
|
||||
|
|
|
@ -30,8 +30,8 @@ class store_customer_login extends store {
|
|||
$password = md5($_REQUEST['password']);
|
||||
$sql = "FROM customers WHERE email_id = '{$email_id}' AND password = '{$password}';";
|
||||
if ($this->db->getField("SELECT COUNT(id) {$sql}") == 0) {
|
||||
$this->status = 'error';
|
||||
$this->message = 'Invalid logon credentials, please try again.';
|
||||
$this->setPublic('status', 'error');
|
||||
$this->setPublic('message', 'Invalid logon credentials, please try again.');
|
||||
}
|
||||
else {
|
||||
// Pulls the customer and address IDs
|
||||
|
@ -58,17 +58,17 @@ class store_customer_login extends store {
|
|||
$_SESSION['cart']['billing_address'] = $billing_address;
|
||||
|
||||
// Sets up our variables to be returned in the JSON object
|
||||
$this->status = 'success';
|
||||
$this->customer_id = $customer['id'];
|
||||
$this->shipping_address = $shipping_address;
|
||||
$this->billing_address = $billing_address;
|
||||
$this->setPublic('status', 'success');
|
||||
$this->setPublic('customer_id', $customer['id']);
|
||||
$this->setPublic('shipping_address', $shipping_address);
|
||||
$this->setPublic('billing_address', $billing_address);
|
||||
|
||||
$this->billing_same_as_shipping = $shipping_address == $billing_address;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->status = 'error';
|
||||
$this->message = 'There is no customer account associated with that email address.';
|
||||
$this->setPublic('status', 'error');
|
||||
$this->setPublic('message', 'There is no customer account associated with that email address.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ class store_home extends store {
|
|||
}
|
||||
}
|
||||
|
||||
$this->featured = $featured;
|
||||
$this->top_sellers = $this->db->getArray('SELECT id, name FROM products ORDER BY RAND() LIMIT 10;');
|
||||
$this->setPublic('featured', $featured);
|
||||
$this->setPublic('top_sellers', $this->db->getArray('SELECT id, name FROM products ORDER BY RAND() LIMIT 10;'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,12 @@ class store_product extends store {
|
|||
|
||||
public function __default() {
|
||||
|
||||
$this->product = $this->db->getArray("
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM products
|
||||
WHERE product_id = '{$_REQUEST['id']}';
|
||||
");
|
||||
";
|
||||
$this->setPublic('product', $this->db->getArray($sql));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,8 +102,12 @@ function ajaxRequest(htmlElement, customHandler, placement, url) {
|
|||
method = 'POST';
|
||||
action = url;
|
||||
|
||||
// @todo this may eventually need to be a loop that keeps going up until it's at a form tag?
|
||||
var formElement = htmlElement.parentNode;
|
||||
// Loops up through the parents until it reaches the form element
|
||||
while (htmlElement.nodeName != 'FORM') {
|
||||
htmlElement = htmlElement.parentNode;
|
||||
}
|
||||
|
||||
var formElement = htmlElement;
|
||||
}
|
||||
|
||||
if (params) {
|
||||
|
|
12
common/templates/store/admin.tpl
Normal file
12
common/templates/store/admin.tpl
Normal file
|
@ -0,0 +1,12 @@
|
|||
<h1>Store Administration</h1>
|
||||
<ol class="store-admin-navigation">
|
||||
{foreach from=$module.options item=option name=options}
|
||||
<li class="{if ($smarty.foreach.options.first && $module_name.3 == '') || ($module_name.3 == $option)}selected{/if}"><a href="/store/admin/{$option}">{$option|ucwords}</a></li>
|
||||
{/foreach}
|
||||
<li class="logout">
|
||||
<a href="/store/admin/logout">Logout</a><img src="/static/contrib/silk/icons/door_in.png" alt="Logout" title="Logout" style="margin: 0 0 -3px 5px;" />
|
||||
</li>
|
||||
</ol>
|
||||
<div class="store-admin-content">
|
||||
{include file="../../pickles/common/templates/$module_name[0].tpl"}
|
||||
</div>
|
32
common/templates/store/admin/affiliates.tpl
Normal file
32
common/templates/store/admin/affiliates.tpl
Normal file
|
@ -0,0 +1,32 @@
|
|||
<h3>Affiliates</h3>
|
||||
<div class="float-right">
|
||||
<img src="/static/contrib/silk/icons/user_add.png" style="margin: 0 5px -4px 0;"/><a href="">Add New Affiliate</a>
|
||||
</div>
|
||||
{if is_array($module.affiliates)}
|
||||
<table style="width: 100%">
|
||||
<tr>
|
||||
<th class="left">Affiliate</th>
|
||||
<th class="left">Phone</th>
|
||||
<th class="left">Email</th>
|
||||
<th>Commission</th>
|
||||
<th>Orders</th>
|
||||
<th>Balance</th>
|
||||
<th>Options</th>
|
||||
</tr>
|
||||
{foreach from=$module.affiliates item=affiliate}
|
||||
<tr class="center">
|
||||
<td class="left">{$affiliate.last_name}, {$affiliate.first_name}</td>
|
||||
<td class="left">{$affiliate.phone}</td>
|
||||
<td class="left">{$affiliate.email}</td>
|
||||
<td>{$affiliate.commission}%</td>
|
||||
<td>{$affiliate.order_count}</td>
|
||||
<td>${$affiliate.unpaid_balance}</td>
|
||||
<td>
|
||||
<a href=""><img src="/static/contrib/silk/icons/user_edit.png" alt="Edit Affiliate" title="Edit Affiliate" /></a>
|
||||
<a href=""><img src="/static/contrib/silk/icons/money.png" alt="Pay Affiliate" title="Pay Affiliate" /></a>
|
||||
<a href=""><img src="/static/contrib/silk/icons/user_delete.png" alt="Delete Affiliate" title="Delete Affiliate" /></a>
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
{/if}
|
1
common/templates/store/admin/home.tpl
Normal file
1
common/templates/store/admin/home.tpl
Normal file
|
@ -0,0 +1 @@
|
|||
This will eventually look like a better version of the DigiCrap Admin.
|
|
@ -6,7 +6,7 @@
|
|||
<div class="your-cart">
|
||||
<h1>Your Cart</h1>
|
||||
</div>
|
||||
{if is_array($cart.products) && count($cart.products) > 0}
|
||||
{if is_array($module.cart.products) && count($module.cart.products) > 0}
|
||||
<form method="POST" action="/store/cart/" name="cart">
|
||||
<table class="product-list">
|
||||
<tr>
|
||||
|
@ -16,7 +16,7 @@
|
|||
<th class="product-price">Price</th>
|
||||
<th class="product-total">Total</th>
|
||||
</tr>
|
||||
{foreach from=$cart.products key=id item=product}
|
||||
{foreach from=$module.cart.products key=id item=product}
|
||||
<tr>
|
||||
<td class="product-quantity">
|
||||
<input type="text" class="product-quantity" value="{$product.quantity}" name="quantity[{$id}]" /><br />
|
||||
|
@ -26,17 +26,17 @@
|
|||
<td class="product-description">{$product.name}</td>
|
||||
<td class="product-price">
|
||||
${$product.price|number_format:2}
|
||||
{if is_array($discounts) && array_key_exists($id, $discounts)}
|
||||
{if is_array($module.discounts) && array_key_exists($id, $module.discounts)}
|
||||
<div style="color: #090">
|
||||
-${$discounts.$id.price|number_format:2}
|
||||
-${$module.discounts.$id.price|number_format:2}
|
||||
</div>
|
||||
{/if}
|
||||
</td>
|
||||
<td class="product-total">
|
||||
${$product.total|number_format:2}
|
||||
{if is_array($discounts) && array_key_exists($id, $discounts)}
|
||||
{if is_array($module.discounts) && array_key_exists($id, $module.discounts)}
|
||||
<div style="color: #090">
|
||||
-${$discounts.$id.total|number_format:2}
|
||||
-${$module.discounts.$id.total|number_format:2}
|
||||
</div>
|
||||
{/if}
|
||||
</td>
|
||||
|
@ -49,14 +49,14 @@
|
|||
</td>
|
||||
<td class="right">
|
||||
<b>Subtotal:</b><br />
|
||||
{if $cart.discount}{/if}
|
||||
{if $module.cart.discount}{/if}
|
||||
<b>Shipping:</b><br />
|
||||
<b>Total:</b>
|
||||
</td>
|
||||
<td class="right">
|
||||
${$cart.subtotal|number_format:2}<br />
|
||||
${$module.cart.subtotal|number_format:2}<br />
|
||||
$4.99<br />
|
||||
${$cart.subtotal+4.99|number_format:2}<br />
|
||||
${$module.cart.subtotal+4.99|number_format:2}<br />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="store-categories">
|
||||
{foreach from=$categories item=parent_category}
|
||||
{foreach from=$module.categories item=parent_category}
|
||||
<div class="{$parent_category.permalink}">
|
||||
<h1>{$parent_category.name}</h1>
|
||||
</div>
|
||||
|
|
|
@ -3,17 +3,17 @@
|
|||
{include file="../../pickles/common/templates/store/categories.tpl"}
|
||||
</div>
|
||||
<div class="content-right store-category">
|
||||
<div class="{$category.permalink}">
|
||||
<h1>{$category.name}</h1>
|
||||
<div class="{$module.category.permalink}">
|
||||
<h1>{$module.category.name}</h1>
|
||||
</div>
|
||||
<div class="center">
|
||||
{$category.description}
|
||||
{$module.category.description}
|
||||
</div>
|
||||
<div class="breadcrumbs">
|
||||
<a href="/store">Shopping Home</a> > <a href="/store/category/{$category.permalink}">{$category.name}</a>
|
||||
<a href="/store">Shopping Home</a> > <a href="/store/category/{$module.category.permalink}">{$module.category.name}</a>
|
||||
</div>
|
||||
<div>
|
||||
{foreach from=$products item=product name=products}
|
||||
{foreach from=$module.products item=product name=products}
|
||||
<div class="float-left" style="width: 200px; margin: 3px">
|
||||
<img src="/images/products/{$product.id}/small.jpg" class="float-left" style="padding-right: 5px" />
|
||||
<div class="float-left" style="width: 120px">
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
{if $status == 'Approved'}
|
||||
{if $module.status == 'Approved'}
|
||||
<img src="/images/success.jpg" alt="Transaction Successful!" /><!-- h1Transaction Successful!</h1><br /-->
|
||||
Thank you for your order, a receipt should arrive via email shortly. Once your order has been shipped you will receive the shipment tracking information via email as well.
|
||||
{else}
|
||||
<!-- In theory, this should never be seen -->
|
||||
<h1>Transaction {$status}.</h1><br />
|
||||
<h1>Transaction {$module.status}.</h1><br />
|
||||
There was an error processing your order:<br /><br />
|
||||
<div style="padding-left: 40px; font-weight: bold;">{$message}</div><br />
|
||||
<div style="padding-left: 40px; font-weight: bold;">{$module.message}</div><br />
|
||||
Please return to the previous page and make sure all of the information is correct. Should you continue to have problems, please call (800) 895-4415 for futher assistance.
|
||||
{/if}
|
||||
<div style="height: 900px"></div>
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<img src="/images/products/{$featured.id}/featured.jpg" class="float-right" style="padding-right: 20px" />
|
||||
<img src="/images/products/{$module.featured.id}/featured.jpg" class="float-right" style="padding-right: 20px" />
|
||||
<div class="store-featured-product">
|
||||
<h1>Featured Product</h1>
|
||||
<h2>{$featured.name}</h2><br />
|
||||
{$featured.teaser}<br /><br />
|
||||
<h2>{$module.featured.name}</h2><br />
|
||||
{$module.featured.teaser}<br /><br />
|
||||
<ul>
|
||||
<li><a href="/store/cart/add/{$featured.id}" class="add-to-cart"><span>Add to Cart</span></a></li>
|
||||
<li><a href="/store/product/{$featured.id}" class="more-information"><span>More Information</span></a></li>
|
||||
<li><a href="/store/cart/add/{$module.featured.id}" class="add-to-cart"><span>Add to Cart</span></a></li>
|
||||
<li><a href="/store/product/{$module.featured.id}" class="more-information"><span>More Information</span></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<div class="store-subnav">
|
||||
<ul class="subnav">
|
||||
{foreach from=$config.store key=link item=label}
|
||||
<li {if $module.0 == 'store/'|cat:$link}class="selected"{/if}>
|
||||
<a href="/{$module.1}/{$link}" class="{$link}">
|
||||
{$label}{if $link == 'cart' && $cart.count != 0} ({$cart.count}){/if}
|
||||
<li {if $module_name.0 == 'store/'|cat:$link}class="selected"{/if}>
|
||||
<a href="/{$module_name.1}/{$link}" class="{$link}">
|
||||
{$label}{if $link == 'cart' && $module.cart.count != 0} ({$module.cart.count}){/if}
|
||||
</a>
|
||||
</li>
|
||||
{/foreach}
|
||||
|
|
|
@ -3,17 +3,17 @@
|
|||
{include file="../../pickles/common/templates/store/categories.tpl"}
|
||||
</div>
|
||||
<div class="content-right store-category">
|
||||
<div class="{$category.permalink}">
|
||||
<h1>{$category.name}</h1>
|
||||
<div class="{$module.category.permalink}">
|
||||
<h1>{$module.category.name}</h1>
|
||||
</div>
|
||||
<div class="center">
|
||||
{$category.description}
|
||||
{$module.category.description}
|
||||
</div>
|
||||
<div class="breadcrumbs">
|
||||
<a href="/store">Shopping Home</a> > <a href="/store/category/{$category.permalink}">{$category.name}</a>
|
||||
<a href="/store">Shopping Home</a> > <a href="/store/category/{$module.category.permalink}">{$module.category.name}</a>
|
||||
</div>
|
||||
<div>
|
||||
{foreach from=$products item=product name=products}
|
||||
{foreach from=$module.products item=product name=products}
|
||||
<div class="float-left" style="width: 200px; margin: 3px">
|
||||
<img src="/images/products/{$product.id}/small.jpg" class="float-left" style="padding-right: 5px" />
|
||||
<div class="float-left" style="width: 120px">
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
<div class="store-top-sellers">
|
||||
<h1>Top Sellers</h1>
|
||||
<div class="float-left" style="width: 175px;">
|
||||
{section name=product loop=$top_sellers start=0 loop=5 step=1}
|
||||
<a href="/store/product/{$top_sellers[product].id}"><b>{$smarty.section.product.index+1}.</b> {$top_sellers[product].name}</a><br />
|
||||
{section name=product loop=$module.top_sellers start=0 loop=5 step=1}
|
||||
<a href="/store/product/{$module.top_sellers[product].id}"><b>{$smarty.section.product.index+1}.</b> {$module.top_sellers[product].name}</a><br />
|
||||
{/section}
|
||||
</div>
|
||||
<div class="float-left" style="width: 175px; padding-left: 10px;">
|
||||
{section name=product loop=$top_sellers start=5 loop=10 step=1}
|
||||
<a href="/store/product/{$top_sellers[product].id}"><b>{$smarty.section.product.index+1}.</b> {$top_sellers[product].name}</a><br />
|
||||
{section name=product loop=$module.top_sellers start=5 loop=10 step=1}
|
||||
<a href="/store/product/{$module.top_sellers[product].id}"><b>{$smarty.section.product.index+1}.</b> {$module.top_sellers[product].name}</a><br />
|
||||
{/section}
|
||||
</div>
|
||||
<!-- Single Column -->
|
||||
<!--div>
|
||||
{section name=product loop=$top_sellers start=0 loop=10 step=1}
|
||||
<a href="/store/product/{$top_sellers[product].id}"><b>{$smarty.section.product.index+1}.</b> {$top_sellers[product].name}</a><br />
|
||||
{section name=product loop=$module.top_sellers start=0 loop=10 step=1}
|
||||
<a href="/store/product/{$module.top_sellers[product].id}"><b>{$smarty.section.product.index+1}.</b> {$module.top_sellers[product].name}</a><br />
|
||||
{/section}
|
||||
</div-->
|
||||
</div>
|
||||
|
|
|
@ -14,7 +14,8 @@ function smarty_function_var_dump($params, &$smarty) {
|
|||
}
|
||||
}
|
||||
|
||||
require_once 'contrib/dBug/dBug.php';
|
||||
// @todo
|
||||
require_once '/home/josh/3rd-party-stuff/dBug-1.2/dBug.php';
|
||||
|
||||
echo "
|
||||
<style>
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Joshua John Sherman <josh@phpwithpickles.org>
|
||||
* @copyright Copyright 2007, 2008 Joshua John Sherman
|
||||
* @copyright Copyright 2007, 2008, 2009 Joshua John Sherman
|
||||
* @link http://phpwithpickles.org
|
||||
* @license http://www.gnu.org/copyleft/lesser.html
|
||||
* @package PICKLES
|
||||
|
@ -50,6 +50,7 @@ define('DISPLAY_JSON', 'JSON');
|
|||
define('DISPLAY_PHP', 'PHP');
|
||||
define('DISPLAY_RSS', 'RSS');
|
||||
define('DISPLAY_SMARTY', 'Smarty');
|
||||
define('DISPLAY_XML', 'XML');
|
||||
|
||||
/**
|
||||
* Magic function to automatically load classes
|
||||
|
@ -62,8 +63,7 @@ define('DISPLAY_SMARTY', 'Smarty');
|
|||
*/
|
||||
function __autoload($class) {
|
||||
|
||||
// @todo Not sure this will come up, but right now core classes can only be nested a single directory deep (e.g. /classes/Display/Smarty.php)
|
||||
$filename = preg_replace('/_/', '/', $class, 1) . '.php';
|
||||
$filename = preg_replace('/_/', '/', $class) . '.php';
|
||||
|
||||
$class_file = PICKLES_PATH . 'classes/' . $filename;
|
||||
$module_file = PICKLES_PATH . 'common/modules/' . $filename;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue