Committing any outstanding changes so that I can work on PICKLES from my laptop.

git-svn-id: http://svn.cleancode.org/svn/pickles@112 4d10bc64-7434-11dc-a737-d2d0f8310089
This commit is contained in:
Josh Sherman 2009-04-05 20:56:04 +00:00
parent 48a98802f3
commit d3f7e6734c
5 changed files with 203 additions and 33 deletions

8
classes/Cache.php Normal file
View file

@ -0,0 +1,8 @@
<?php
class Cache extends Object {
public static
}
?>

View file

@ -104,44 +104,68 @@ class Display_Smarty extends Display_Common {
$this->template = $template;
$cache_id = isset($this->cache_id) ? $this->cache_id : $this->module_filename;
$template = $this->smarty->template_exists('index.tpl') ? 'index.tpl' : $this->template;
if (!$this->smarty->is_cached($template, $cache_id)) {
$template_found = false;
// Build the combined module name array and assign it
$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') {
$this->smarty->assign('template', strtr($this->template, '-', '_'));
// Checks that the passed in main template is for real
if (isset($this->config->templates->main)) {
// If there's no .tpl at the end, appends it
if (strstr('\.tpl', $this->config->templates['main'])) {
$this->config->templates->main .= '.tpl';
}
// Loads the data from the config
$data = $this->config->getPublicData();
if (isset($data) && is_array($data)) {
$this->smarty->assign('config', $data);
// Checks that the template exists
if ($this->smarty->template_exists($this->config->templates->main)) {
$template = $this->config->templates->main;
$template_found = true;
}
// 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)) {
$this->smarty->assign('module', $this->data);
else {
$this->error->addError('The specified main template file (' . $this->config->templates->main . ') could not be found');
}
}
$this->smarty->display($template, $cache_id);
// If no main template was found, try to load the module template
if ($template_found == false) {
if ($this->smarty->template_exists($this->template) == true) {
$template = $this->template;
$template_found = true;
}
}
// If no module template is found, error out.
if ($template_found == false) {
$this->error->addError('No valid template file could be found');
}
else {
if (!$this->smarty->is_cached($template, $cache_id)) {
// Build the combined module name array and assign it
$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') {
$this->smarty->assign('template', strtr($this->template, '-', '_'));
}
// Loads the data from the config
$data = $this->config->getPublicData();
if (isset($data) && is_array($data)) {
$this->smarty->assign('config', $data);
}
// Loads the module's public data
// @todo For refactoring, need to change the name from data
if (isset($this->data) && is_array($this->data)) {
$this->smarty->assign('module', $this->data);
}
}
$this->smarty->display($template, $cache_id);
}
}
public function getSmartyObject() {

80
classes/Form.php Normal file
View file

@ -0,0 +1,80 @@
<?php
class Form {
public function fromTable($table) {
$this->getArray('DESCRIBE menopausesolutions.affiliates');
$form = "<form>\n\t<dl>\n";
while ($row = mysql_fetch_assoc($results)) {
$label = ucwords(strtr($row['Field'], '_', ' '));
$attributes = "name='{$row['Field']}' id='{$row['Field']}'";
$form .= "\t\t<dt>{$label}:</dt>\n\t\t<dd>\n\t\t\t";
// ENUM()
if (preg_match('/^enum/', $row['Type'])) {
$options = str_replace(array("enum('", "')"), '', $row['Type']);
$options = explode("','", $options);
if (is_array($options)) {
if (count($options) <= 2) {
foreach ($options as $option) {
$form .= "<input type='radio' {$attributes} value='{$option}' /> {$option} ";
}
}
else {
$form .= "<select {$attributes}>";
if ($row['Null'] == 'YES' && $options[0] != '') {
array_unshift($options, '');
}
foreach ($options as $option) {
$form .= "<option value='{$option}'>{$option}</option>";
}
}
}
$form .= '</select>';
}
// TEXT and BLOG (all sizes)
else if (preg_match('/(tiny|medium|long)?(text|blob)$/', $row['Type'])) {
$form .= "<textarea {$attributes}></textarea>";
}
// DATE (not DATETIME)
else if (preg_match('/^date$/', $row['Type'])) {
}
/*
else if (preg_match('/^datetime$/', $row['Type'])) {
}
*/
else if (preg_match('/(tiny|medium|long)?int([0-9]+)$/', $row['Type'])) {
var_dump(split('int', $row['Type']));
}
// Generic default (input box)
else {
var_dump($row);
if (preg_match('/^(var)?char\([0-9]+\)$/', $row['Type'])) {
$type_array = split('(\(|\))', $row['Type']);
$attributes .= " maxlength='{$type_array[1]}' size='{$type_array[1]}'";
}
$form .= "<input type='text' {$attributes} />";
}
$form .= "\n\t\t</dd>\n";
}
$form .= "\t</dl>\n</form>\n";
exit($form);
}
}
?>

View file

@ -0,0 +1,58 @@
<?php
/**
* Authorize.Net Customer Information Manager (CIM) Web Service Class File for PICKLES
*
* PICKLES is free software: you can redistribute it and/or modify
* 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/>.
*
* @author Joshua John Sherman <josh@phpwithpickles.org>
* @copyright Copyright 2009 Joshua John Sherman
* @link http://phpwithpickles.org
* @license http://www.gnu.org/copyleft/lesser.html
* @package PICKLES
*/
/**
* Authorize.Net Customer Information Manager (CIM) Web Service
*/
class WebService_AuthorizeNet_AIM extends WebService_Common {
private $loginname = "YourApiLogin"; // Keep this secure.
private $transactionkey = "YourTransactionKey"; // Keep this secure.
private $url = "apitest.authorize.net";
private $path = "/xml/v1/request.api";
public function createCustomerProfile() { }
public function createCustomerPaymentProfile() { }
public function createCustomerShippingAddress() { }
public function createCustomerProfileTransaction() { }
public function deleteCustomerProfile() { }
public function deleteCustomerPaymentProfile() { }
public function deleteCustomerShippingAddress() { }
public function getCustomerProfileIds() { }
public function getCustomerProfile() { }
public function getCustomerPaymentProfile() { }
public function getCustomerShippingAddress() { }
public function updateCustomerProfile() { }
public function updateCustomerPaymentProfile() { }
public function updateCustomerShippingAddress() { }
public function validateCustomerPaymentProfile() { }
public function process() {
return $response;
}
}
?>

View file

@ -2,7 +2,7 @@
<?php
/**
* PICKLES Scaffolding Generator (to pickle)
* PICKLES Scaffolding Generator (verb: to pickle)
*
* This is the file that you include on the page you're instantiating the
* controller from (typically index.php). The path to the PICKLES code base
@ -24,7 +24,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
@ -135,7 +135,7 @@ class home extends Model {
// The follow are set to the default values, so they are optional
protected \$authorization = false;
protected \$viewer = 'Smarty';
protected \$display = 'Smarty';
protected \$session = false;
public function __default() {