From f45cecd35d812728e2e4970645c3edff448bdfe2 Mon Sep 17 00:00:00 2001
From: Steve Sutton '.$this->nav.'
';
+ }
+ }
+
+ // }}}
+
+ // {{{ &factory()
+
+ /**
+ * Provides an interface for generating Banner:: objects of various types
+ *
+ * @param String $driver The kind of Banner:: object to instantiate.
+ *
+ * @return Object Banner an instance of the driver class or if fails
+ * a PEAR error.
+ *
+ * @author Jamie Kahgee ';
+
+ if ($banner['external'] == 't') {
+ $target = 'target="_blank"';
+ }
+
+ $this->bannerDisplay
+ = ''.$img.'';
+ }
+
+ // }}}
+ // {{{ getLocation()
+
+ /**
+ * Gets the url from the current banner
+ *
+ * @author Jamie Kahgee
';
+
+ if ($banner['external'] == 't') {
+ $target = 'target="_blank"';
+ }
+
+ foreach ($this->availableBanners as $b) {
+ $jsonSet[] = array(
+ 'image' => $b['image'],
+ 'description' => $b['description'],
+ 'id' => $b['id'],
+ );
+ }
+ $bannerList = ' ';
+
+ $this->bannerDisplay = $bannerList
+ . ''.$img.'';
+ }
+
+ // }}}
+ // {{{ setFadingOutput()
+
+ /**
+ * Sets up banners that rotate with a fading effect
+ *
+ * @author Jamie Kahgee
';
+
+ if ($b['external'] == 't') {
+ $target = 'target="_blank"';
+ }
+
+ $banners[]
+ = ''.$img.'';
+ }
+
+ $this->bannerDisplay = implode("\n", $banners);
+ }
+
+ // }}}
+
+ // {{{ hasBannersAvailable()
+
+ /**
+ * Whether we have available banners in the pool for the current page
+ *
+ * @author Jamie Kahgee
We will email you a link to the PDF version of the {brochure}.
+ORDER BY MAIL:
+{contactForm:h} diff --git a/Toolkit/Contacts/templates/currentTables/Element.tpl b/Toolkit/Contacts/templates/currentTables/Element.tpl new file mode 100755 index 0000000..595457b --- /dev/null +++ b/Toolkit/Contacts/templates/currentTables/Element.tpl @@ -0,0 +1,14 @@ +Below is the list of businesses you have added to your Trip Planner. The form below will be sent to each individual business listing that has an email address listed with their business listing. For those businesses with no email address, we have included their phone numbers for you to call directly and request additional information.
+These business listings have no current email address on file. To receive additional information please call the phone numbers listed next to each business name.
+Name + | Phone + | + |
---|---|---|
{member[memberName]} | +{member[memberPhone]} | +Remove | +
This list of businesses will receive the following information form directly to their email account.
+{member[memberName]} | +Remove | +
+ + {subject:h} + +
++ + From {fname:h} {lname:h} + +
+
+
|
+ |||
+
|
+
Dear {fname}
+Your friend {yname} has been to demo.gaslightmedia.com, and thought you might be interested in it.
+Message here.
+Thank you for requesting the {pdfName} Link. Here is the link to the Adobe PDF version: +
+Brochure ({pdfFileSize})
+Thank you for your interest in {client_info[name]:h}'!
+Sincerely,
+{client_info[name]:h}
+{client_info[url]:h}
+ + + diff --git a/Toolkit/DataGridBuilder.php b/Toolkit/DataGridBuilder.php new file mode 100644 index 0000000..691d539 --- /dev/null +++ b/Toolkit/DataGridBuilder.php @@ -0,0 +1,285 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @link http://demo.gaslightmedia.com + */ + +/** + * Create Datagrids for displaying data + * + * This abstract class handles all the base functionality of creating + * handeling all the details associated w/ a regular dataGrid. + * 1. Creation + * 2. Sorting (via column headers or sortform) + * 3. Pagenation + * + * @category Structures + * @package Toolkit_DataGridBuilder + * @author Jamie Kahgee
+ * protected $email = false;
+ *
+ *
+ * @var unknown
+ * @access protected
+ */
+ protected $email;
+
+ /**
+ * From header in the owner email
+ *
+ * This just sets the From header in the owner email
+ * SITENAME {v[label]:h} | + {if:v[nowrap]} +{v[element]:h} | + {else:} +{v[element]:h} | + {end:} +
A new Event Record has been created from "Add Your Event"
+The record needs to be approved before changes go live.
+Goto Pending Records to View and Approve their changes.
+ + diff --git a/Toolkit/FileServer/AdapterAbstract.php b/Toolkit/FileServer/AdapterAbstract.php new file mode 100644 index 0000000..92494cc --- /dev/null +++ b/Toolkit/FileServer/AdapterAbstract.php @@ -0,0 +1,401 @@ + + * @copyright 2010 Jamie Kahgee + * @license http://www.gaslightmedia.com/ Gaslightmedia + * @version CVS: $Id: AdapterAbstract.php,v 1.1 2012/02/03 19:04:13 matrix Exp $ + * @link <> + * @see References to other sections (if any)... + */ + + +/** + * Validation Secret + */ +define('IS_VALIDATE_SECRET', 'Glm0IS1secreT'); + +/** + * URL to file server, this is dynamic based on the server + * so can be setup for any sandbox + */ +define('IS_SUBMIT_URL', FILE_SERVER_URL . 'submit.phtml'); + +/** + * Adapter class for linking to the file server + * + * @category FileServer + * @package Toolkit_FileServer + * @author Jamie Kahgee
+ * $this->ctrlObj['url'] = BASE_URL;
+ *
+ *
+ *
+ * public function configureElements()
+ * {
+ * $e = array();
+ *
+ * $e[] = array(
+ * 'type' => 'text',
+ * 'req' => false
+ * 'name' => 'text_field',
+ * 'display' => 'Text Label',
+ * );
+ * $e[] = array(
+ * 'type' => 'checkbox',
+ * 'req' => false
+ * 'name' => 'checkbox_field',
+ * 'display' => 'Checkbox Label',
+ * );
+ *
+ * // ... More Element Definitions
+ *
+ * $this->setupElements($e);
+ * }
+ *
+ *
+ * @access public
+ * @return void
+ */
+ //public function configureElements();
+
+ // }}}
+ // {{{ configureForm()
+
+ /**
+ * Calls all the configuration methods to configure a form for use
+ *
+ * @access public
+ * @return void
+ */
+ //public function configureForm();
+
+ // }}}
+ // {{{ configureRules()
+
+ /**
+ * Defines all element rules to be used for validation in the form
+ *
+ * At the bare minimum, this function needs to be called to setup the
+ * form rules, even if no extra rules are defined. Because it still
+ * creates all the required rules that are defined w/ each element.
+ *
+ *
+ * public function configureRules()
+ * {
+ * $r = array();
+ *
+ * $r[] = array(
+ * 'element' => 'text_field',
+ * 'message' => 'ERROR: 10 characters max!',
+ * 'type' => 'maxlength',
+ * 'format' => 10,
+ * 'validation' => $this->validationType,
+ * 'reset' => true,
+ * 'force' => false,
+ * );
+ * $r[] = array(
+ * 'element' => 'text_field',
+ * 'message' => 'ERROR: Numric characters only!',
+ * 'type' => 'numeric',
+ * 'format' => null,
+ * 'validation' => $this->validationType,
+ * 'reset' => true,
+ * 'force' => false,
+ * );
+ *
+ * // ... More Rule Definitions
+ *
+ * $this->setupRules($r);
+ * }
+ *
+ *
+ * @access public
+ * @return void
+ */
+ public function configureRules();
+
+ // }}}
+ // {{{ toHtml()
+
+ /**
+ * Get an html string that contains the form
+ *
+ * Check if the form needs to be validated (ie. it was submitted)
+ * Check if submitted data needs to be processed
+ *
+ * @access public
+ * @return string an html string that contains the entire form
+ */
+ public function toHtml();
+
+ // }}}
+}
+?>
diff --git a/Toolkit/FormBuilder.php b/Toolkit/FormBuilder.php
new file mode 100644
index 0000000..3f51aad
--- /dev/null
+++ b/Toolkit/FormBuilder.php
@@ -0,0 +1,1183 @@
+
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version CVS: $Id: FormBuilder.php,v 1.2 2009/12/15 20:18:15 jamie Exp $
+ * @link http://demo.gaslightmedia.com
+ */
+
+/**
+ * Allow the inclusion of the Element Grid plugin for QuickForms
+ */
+require_once 'HTML/QuickForm/ElementGrid.php';
+
+/**
+ * Handle QuickForm CAPTCHA's
+ */
+require_once 'HTML/QuickForm/CAPTCHA/Image.php';
+
+/**
+ * Require PEAR QuickForm class
+ */
+require_once 'HTML/QuickForm.php';
+
+require_once 'HTML/QuickForm/Rule/Zip.php';
+require_once 'HTML/QuickForm/Rule/Phone.php';
+require_once 'HTML/QuickForm/Rule/Banwords.php';
+require_once 'HTML/QuickForm/Rule/State.php';
+
+/**
+ * Base functionality for creating HTML_Quickforms
+ *
+ * @category Forms
+ * @package Toolkit_FormBuilder
+ * @author Jamie Kahgee
+ * $rules[] = array('element' => 'phone',
+ * 'message' => 'ERROR: Invalid Phone Format!',
+ * 'type' => 'phone',
+ * 'format' => null,
+ * 'validation' => $this->validationType,
+ * 'reset' => true,
+ * 'force' => false);
+ *
+ *
+ * Zip: Validates input against US and CA zip codes, if DB check is
+ * set to true, validate zip codes against all the zip codes in the
+ * DB.
+ *
+ * $rules[] = array('element' => 'zip',
+ * 'message' => 'ERROR: Invalid Zip!',
+ * 'type' => 'zip',
+ * 'format' => array('requireDBCheck' => true),
+ * 'validation' => $this->validationType,
+ * 'reset' => true,
+ * 'force' => false);
+ *
+ *
+ * Banwords: Make sure each each doesn't contain a banned word. Checking
+ * against a DB of banned words.
+ *
+ * State: Validate input against US and CA region / province codes. If DB
+ * check is set to true, validate region / province against all the
+ * regions / provinces in the DB.
+ *
+ * $rules[] = array('element' => 'state_id',
+ * 'message' => 'ERROR: Invalid State / Province!',
+ * 'type' => 'state',
+ * 'format' => array('requireDBCheck' => true),
+ * 'validation' => $this->validationType,
+ * 'reset' => true,
+ * 'force' => false);
+ *
+ *
+ * @var array
+ * @access protected
+ * @see app.gaslightmedia.com/glmPEAR/HTML/QuickForm/Rule/Zip.php
+ * @see app.gaslightmedia.com/glmPEAR/HTML/QuickForm/Rule/Phone.php
+ * @see app.gaslightmedia.com/glmPEAR/HTML/QuickForm/Rule/Banwords.php
+ * @see app.gaslightmedia.com/glmPEAR/HTML/QuickForm/Rule/State.php
+ */
+ protected $registeredRules = array('phone', 'zip', 'state');
+
+ // }}}
+ // {{{ __construct()
+
+ /**
+ * Class constructor
+ *
+ * @param string $formName Form's name.
+ * @param string $method (optional)Form's method defaults to 'POST'
+ * @param string $action (optional)Form's action
+ * @param string $target (optional)Form's target defaults to '_self'
+ * @param mixed $attributes (optional)Extra attributes for
+ * class exampleClass
+ * {
+ * $registeredRules = array(
+ * array(
+ * 'checkEmail',
+ * 'callback',
+ * 'email',
+ * 'Validate'
+ * )
+ * );
+ *
+ * // ... Rest of your class code
+ *
+ * public function configureRules()
+ * {
+ * $r = array();
+ *
+ * $r[] = array(
+ * 'element' => 'process_email',
+ * 'message' => 'ERROR: Invalid email format!',
+ * 'type' => 'checkEmail',
+ * 'format' => array('use_rfc822' => true),
+ * 'validation' => $this->validationType,
+ * 'reset' => false,
+ * 'force' => false
+ * );
+ *
+ * $this->setupRules($r);
+ * }
+ *
+ * // ... Rest of your class code
+ * }
+ *
+ *
+ * If the registeredRule is a string, the corresponding rule in the
+ * glmPEAR/HTML/QuickForm/Rule/ directory will be registered with
+ * the form.
+ *
+ * This will set up the 'phone' rule already defined in the
+ * glmPEAR/HTML/QuickForm/Rule directory which validates both
+ * US and Canadian phone numbers
+ *
+ * class exampleClass
+ * {
+ * $registeredRules = array('phone');
+ *
+ * // ... Rest of your class code
+ *
+ * public function configureRules()
+ * {
+ * $r = array();
+ *
+ * $r[] = array(
+ * 'element' => 'phone',
+ * 'message' => 'ERROR: Invalid number (xxx) xxx-xxxx!',
+ * 'type' => 'phone',
+ * 'format' => null,
+ * 'validation' => $this->validationType,
+ * 'reset' => false,
+ * 'force' => false
+ * );
+ *
+ * $this->setupRules($r);
+ * }
+ *
+ * // ... Rest of your class code
+ * }
+ *
+ *
+ * @return void
+ * @access protected
+ */
+ protected function registerRules()
+ {
+ if (is_array($this->registeredRules)) {
+ foreach ($this->registeredRules as $r) {
+ if (is_array($r)) {
+ call_user_func_array(array(&$this, 'registerRule'), $r);
+ } else {
+ // Don't nedd to register rules more than once
+ if (!$this->isRuleRegistered($r)) {
+ $this->registerRule($r, null, "HTML_QuickForm_Rule_$r");
+ }
+ }
+ }
+ }
+ }
+
+ // }}}
+
+ // {{{ setAutoValidateDateElements()
+
+ /**
+ * Set if we need to auto validate the Date Elements
+ *
+ * @param boolean $validate true/false to auto validate date elements
+ *
+ * @return void
+ * @access public
+ */
+ public function setAutoValidateDateElements($validate)
+ {
+ $this->autoValidateDateElements = $validate;
+ }
+
+ // }}}
+ // {{{ setFormData()
+
+ /**
+ * Sets the submitted values from the form
+ *
+ * Set these values into an internal variable so they will be accessible
+ * anywhere we need them in the form.
+ *
+ * @param array $exclude (optional) Any element names you don't want
+ * included. Since this is primarily used in
+ * emailing, this is helpful to exclude any data
+ * we don't want before the array is generated.
+ *
+ * @return void
+ * @access protected
+ */
+ protected function setFormData(array $exclude = array())
+ {
+ $values = $this->getSubmitValues();
+ foreach ($values as $k => $v) {
+ if ($this->elementExists($k)) {
+ $e =& $this->getElement($k);
+ if (!in_array($e->getName(), $exclude)) {
+ switch ($e->getType()) {
+ case 'date' :
+ list($m, $d, $y) = array_values($e->getValue());
+ // If all the date fields are empty, then don't add
+ // the output to the formData.
+ if (!(empty($m[0]) && empty($d[0]) && empty($y[0]))) {
+ $this->formData[$e->getName()]['label']
+ = $e->getLabel();
+
+ $oldDate = $e->getValue();
+ $newDate = Toolkit_Common::arrayFlatten(
+ $oldDate,
+ 0,
+ $newDate
+ );
+
+ $this->formData[$e->getName()]['element']
+ = implode(' / ', $newDate);
+ unset($oldDate, $newDate);
+ }
+ break;
+
+ case 'group':
+ $e->freeze();
+ $this->formData[$e->getName()]['label'] = $e->getLabel();
+ $this->formData[$e->getName()]['element'] = $e->toHtml();
+ break;
+
+ case 'select' :
+ $this->formData[$e->getName()]['label'] = $e->getLabel();
+
+ $values = $e->getValue();
+ foreach ($values as $v) {
+ $this->formData[$e->getName()]['element'] .= $v;
+ }
+ break;
+
+ default :
+ $this->formData[$e->getName()]['label'] = $e->getLabel();
+ $this->formData[$e->getName()]['element'] = $e->getValue();
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ // }}}
+ // {{{ setupConstants()
+
+ /**
+ * Sets the form constant values
+ *
+ * @param array $constants Associative array of form constant values.
+ *
+ * @return void
+ * @access protected
+ */
+ protected function setupConstants($constants)
+ {
+ $this->setConstants($constants);
+ }
+
+ // }}}
+ // {{{ setupDefaults()
+
+ /**
+ * Sets the form default values
+ *
+ * @param array $defaults Associative array of form default values.
+ *
+ * @return void
+ * @access protected
+ */
+ protected function setupDefaults($defaults)
+ {
+ $this->setDefaults($defaults);
+ }
+
+ // }}}
+ // {{{ setupElements()
+
+ /**
+ * Sets up all the elements to the form
+ *
+ * Takes a multi-dimensional array of form elements and uses them
+ * to set up the form objects elements
+ *
+ * @param array $elements Multi-Dimensional array of form elements.
+ *
+ * @return void
+ * @access protected
+ */
+ protected function setupElements($elements)
+ {
+ if (!is_array($elements)) {
+ return;
+ }
+ foreach ($elements as &$e) {
+ $this->prepElement($e);
+ switch ($e['type']) {
+ case 'group' :
+ if (is_array($e['group']) && !empty($e['group'])) {
+ // Special rendering for grouped elements.
+ unset($field);
+ foreach ($e['group'] as $g) {
+ $this->prepElement($g);
+ $field[] =& HTML_QuickForm::createElement(
+ $g['type'],
+ $g['name'],
+ $g['display'],
+ $g['opts'],
+ $g['att'],
+ $g['val']
+ );
+ }
+ $source =& $this->addGroup(
+ $field,
+ $e['name'],
+ $e['label'],
+ $e['seperator'],
+ $e['appendName']
+ );
+ }
+ break;
+
+ case 'elementGrid' :
+ $source =& $this->addElement(
+ $e['type'],
+ $e['name'],
+ $e['display'],
+ $e['opts'],
+ $e['att'],
+ $e['val']
+ );
+ unset($columnNames);
+
+ // Loop through the rows (r) and columns (c)
+ // to add each of the elements to our grid.
+ foreach ($e['group'] as $k => $r) {
+ unset($set, $rowTitle);
+ foreach ($r as $c) {
+ $columnNames[$c['display']] = $c['display'];
+
+ $set[] =& $this->createGridElement(
+ $c['type'],
+ $c['name'],
+ null,
+ $c['opts'],
+ $c['att']
+ );
+ }
+ $rowTitle = is_int($k) ? ' ' : $k;
+ $source->addRow(&$set, $rowTitle);
+ }
+
+ $source->setColumnNames($columnNames);
+ break;
+
+ default :
+ // Render all elements except groups
+ try {
+ $source =& $this->addElement(
+ $e['type'],
+ $e['name'],
+ $e['display'],
+ $e['opts'],
+ $e['att'],
+ $e['val']
+ );
+
+ if (PEAR::isError($source)) {
+ throw new Exception ('PEAR QuickForm Element Error');
+ }
+ } catch (HTML_QuickForm_Error $e) {
+ Toolkit_Common::dieGracefully(null, $e);
+ } catch (Exception $e) {
+ Toolkit_Common::handleError($e);
+ }
+
+ if ($e['type'] == 'advmultiselect') {
+ $source->setLabel($e['labels']);
+ }
+ if ($e['name'] == 'categories') {
+ $res = $source->loadArray($this->categories);
+ if (PEAR::isError($res)) {
+ Toolkit_Common::dieGracefully(null, $res);
+ }
+ }
+ if ($e['type'] == 'header') {
+ $this->formHeaders[$e['display']] = $e;
+ }
+
+ if ($e['name'] == 'captcha_rmv') {
+ $this->captchaAnswer =& $source;
+ }
+
+ if ($e['name'] == 'captcha_question') {
+ $this->captchaQuestion =& $source;
+ }
+ break;
+ }
+ }
+ $this->formElements = $elements;
+ }
+
+ // }}}
+ // {{{ setupFilters()
+
+ /**
+ * Sets any filters needed for the form elements when submitting
+ *
+ * @param array $filters Element filters.
+ *
+ * @return void
+ * @access protected
+ */
+ protected function setupFilters($filters)
+ {
+ foreach ($filters as $f) {
+ $res = $this->applyFilter($f['element'], $f['filter']);
+
+ if (PEAR::isError($res)) {
+ Toolkit_Common::handleError($res);
+ }
+ }
+ }
+
+ // }}}
+ // {{{ setupRules()
+
+ /**
+ * Apply rules to the form
+ *
+ * 100 & 1000 char length limitations are automatically assigned to
+ * text/textarea elements to help reduce load limitations on the server.
+ * -request per Chuck in a conference call on (5/22/2009 @ 12:15pm)
+ *
+ * Applies rules that are defined in child classes to the form elements
+ * group rules can be kind of tricky, since you can't apply a rule
+ * directly to an element inside of a rule you have to define
+ * the rule inside a nest of array's and then add a group rule.
+ * the array will contain all the elements inside the group you wish
+ * to apply rules to.
+ *
+ * You can assign as many rules as you would like to individual elements,
+ * and you aren't required to make the array associative, although it is
+ * easier to see whats going on.
+ *
+ * see: http://pear.activeventure.com/package/package.html.html-quickform.html-quickform.addgrouprule.html
+ * for another example.
+ *
+ * // Define the rules for each element in the group.
+ * $num_rule = array(
+ * 'ERROR: Must contain a valid decimal number!',
+ * 'numeric'
+ * );
+ * // Collect together the rules for each element.
+ * $lat_rules = array('lat' => array($num_rule));
+ * $lon_rules = array('lon' => array($num_rule));
+ * $r[] = array(
+ * 'element' => 'latitude',
+ * 'message' => 'ERROR:',
+ * 'type' => 'group',
+ * 'format' => $lat_rules,
+ * 'validation' => $this->validationType,
+ * 'reset' => false,
+ * 'force' => false
+ * );
+ *
+ *
+ * To make a group required but not require every element in the group
+ * you can use the addGroupRule function again
+ * for example: say you have a group of checkboxes and you only only
+ * require 1 be checked. a simple group rule such as the following
+ * will handle this.
+ * N.B. notice the extra "howMany" index.
+ *
+ * $r[] = array(
+ * 'element' => 'element_name',
+ * 'message' => 'ERROR: Error to display!',
+ * 'type' => 'required',
+ * 'format' => null,
+ * 'howMany' => 1,
+ * 'validation'=> $this->validationType,
+ * 'reset' => true,
+ * 'force' => false,
+ * );
+ *
+ *
+ * @param array $rules Multi-Dimensional array of rules for form elements.
+ *
+ * @return void
+ * @access protected
+ */
+ protected function setupRules(array $rules = null)
+ {
+ $this->registerRules();
+ $preRegisteredRules = $this->getRegisteredRules();
+ if (is_array($this->formElements)) {
+ foreach ($this->formElements as $e) {
+ // Put length limitations on text and textarea fields
+ if ($e['type'] == 'text' && !$e['noCharLimit']) {
+ $this->addCharLimit($e['name'], 100);
+ } elseif ($e['type'] == 'textarea' && !$e['noCharLimit']) {
+ $this->addCharLimit($e['name'], 1000);
+ } elseif ($e['type'] == 'group') {
+ // We need to apply these same limitations to the
+ // text and textarea fields inside of groups
+ $r = array();
+ if (is_array($e['group'])) {
+ foreach ($e['group'] as $i) {
+ // Loop through group elements and if they are
+ // text/textarea fields then put the field into
+ // a rule array that we will assign to the group
+ if ($i['type'] == 'text') {
+ $r[$i['name']][] = array(
+ 'ERROR: 100 characters max!',
+ 'maxlength'
+ );
+ } elseif ($i['type'] == 'textarea') {
+ $r[$i['name']][] = array(
+ 'ERROR: 1000 characters max!',
+ 'maxlength'
+ );
+ }
+ }
+ }
+ if (!empty($r)) {
+ $this->addGroupRule($e['name'], $r);
+ }
+ }
+ if ($this->validationType == 'client') {
+ $label = $e['display'];
+ }
+ if ($e['req']) {
+ if ($e['type'] == 'group') {
+ foreach ($e['group'] as $ge) {
+ if ($ge['req']) {
+ $rule[$ge['name']][] = array(
+ 'ERROR: You must complete this field!',
+ 'required',
+ null,
+ $this->validationType);
+ }
+ }
+ $this->addGroupRule($e['name'], $rule);
+ unset($rule);
+ } elseif ($e['type'] == 'date') {
+ if (!empty($e['error'])) {
+ // Custom error message for the date element.
+ $error = $e['error'];
+ } else {
+ // Default error message for the date element.
+ $error = 'ERROR: You must enter a date!';
+ }
+ $this->addGroupRule(
+ $e['name'],
+ $error,
+ 'required',
+ 3,
+ $this->validationType
+ );
+ if ($this->autoValidateDateElements) {
+ $this->addRule(
+ $e['name'],
+ 'ERROR: Date is invalid!',
+ 'callback',
+ array(&$this, 'checkDateInput')
+ );
+ }
+ } else {
+ $this->addRule(
+ $e['name'],
+ "$label ERROR: You must complete this field!",
+ 'required',
+ null,
+ $this->validationType
+ );
+ }
+ }
+ }
+ }
+ if (is_array($rules)) {
+ foreach ($rules as $r) {
+ if (!is_array($r['element'])) {
+ $group = ($this->getElementType($r['element']) == 'group');
+ }
+ if ($group) {
+ $this->addGroupRule(
+ $r['element'],
+ $r['message'],
+ $r['type'],
+ $r['format'],
+ $r['howMany'],
+ $r['validation'],
+ $r['reset']
+ );
+ } elseif (in_array($r['type'], $preRegisteredRules)) {
+ $this->addRule(
+ $r['element'],
+ $r['message'],
+ $r['type'],
+ $r['format'],
+ $r['validation'],
+ $r['reset'],
+ $r['force']
+ );
+ }
+ }
+ }
+ }
+
+ // }}}
+ // {{{ setupRenderers()
+
+ /**
+ * Sets up renderers for form objects
+ *
+ * Uses the default form renderer to allow templates to be injected
+ * into the form object before displaying on a page. This allows
+ * changing the face of the form w/ out any backend adjustment.
+ *
+ * Files that can be created for templates are
+ *
+ * Examples:
+ * # Element.tpl
+ *
+ *
+ *
+ *
+ * *
+ *
+ *
+ *
+ *
+ *
+ * {error}
+ *
+ * {element}
+ *
+ *
+ *
+ *
+ * # Form.tpl
+ *
+ *
+ *
+ *
+ * {content}
+ *
+ *
+ *
+ *
+ *
+ * # GroupElement.tpl
+ *
+ *
+ *
+ * {element}
+ *
+ * *
+ *
+ * {label}
+ *
+ *
+ *
+ *
+ * # Group.tpl
+ *
+ *
+ *
+ * {content}
+ *
+ *
+ *
+ *
+ * # Header.tpl
+ *
+ *
+ *
+ * {header}
+ *
+ *
+ *
+ *
+ * # RequiredNote.tpl
+ *
+ * * Denotes required field
+ *
+ *
+ * @param array $groups any groups that need to be rendered
+ * via the groupElementTemplate and groupTemplate
+ *
+ * @return void
+ * @access protected
+ */
+ protected function setupRenderers(array $groups = array())
+ {
+ if (is_dir($this->template)) {
+ if ($dh = opendir($this->template)) {
+ while (($file = readdir($dh)) !== false) {
+ // Ignore current dir and parent dir.
+ if ($file != '..' && $file != '.' && $file != 'CVS') {
+ $baseName = reset(explode('.', $file));
+ // Ignores swp files.
+ if (!empty($baseName)) {
+ $method = "set{$baseName}Template";
+ $template = file_get_contents($this->template . $file);
+ $renderer =& $this->defaultRenderer();
+ if ( $method != 'setGroupTemplate'
+ && $method != 'setGroupElementTemplate'
+ ) {
+ if (method_exists($renderer, $method)) {
+ $renderer->$method($template);
+ }
+ } else {
+ // apply the templates to any defined groups
+ foreach ($groups as $k) {
+ $renderer->$method($template, $k);
+ }
+ }
+ }
+ }
+ }
+ closedir($dh);
+ }
+ }
+ }
+
+ // }}}
+ // {{{ setUseCaptcha()
+
+ /**
+ * Set if we need to use a captcha in this form or not
+ *
+ * @param boolean $useCaptcha true/false to use a captcha with the form
+ *
+ * @return void
+ * @access public
+ */
+ public function useCaptcha($useCaptcha)
+ {
+ $this->useCaptcha = $useCaptcha;
+ }
+
+ // }}}
+ // {{{ show()
+
+ /**
+ * Shows the form
+ *
+ * @return void
+ * @access public
+ */
+ public function show()
+ {
+ Toolkit_Common::show();
+ }
+
+ // }}}
+}
+?>
diff --git a/Toolkit/Image/Server.php b/Toolkit/Image/Server.php
new file mode 100755
index 0000000..fc562ff
--- /dev/null
+++ b/Toolkit/Image/Server.php
@@ -0,0 +1,369 @@
+
+ * @copyright 2008 Steve Sutton
+ * @license Gaslight Media
+ * @version CVS: $Id: Server.php,v 1.1.1.1 2009/09/17 20:08:56 matrix Exp $
+ * @link http://demo.gaslightmedia.com
+ */
+
+/**
+ * Description for define
+ */
+define('IS_VALIDATE_SECRET', 'Glm0IS1secreT');
+
+/**
+ * Description for define
+ */
+define('IS_SUBMIT_URL', 'is0.gaslightmedia.com/submit.phtml');
+
+/**
+ * Toolkit_Image_Server
+ *
+ * Class for implementation of the image server process Chuck has
+ * setup for is0.gaslightmedia.com
+ * Uses Curl PHP Library to upload images to the server
+ *
+ * @category Images
+ * @package Toolkit_Image
+ * @author Steve Sutton '.print_r($response, true).''; + return false; + exit; + } + return $StoredName; + } + } + + // }}} + + // {{{ getImageSize() + + /** + * getImageSize + * + * Return image data on an image from image server + * + * @param string $image Full URI to image + * http://is0/userId/imageStyle/imageName + * Must be a full URI including an authority. + * No relative URIs, the // are mandatory + * + * @return array Image data 0 => width, 1 => height, 2 => html + * @access public + * @throws PEAR Error + */ + function getImageSize($image) + { + $options = array('allowed_schemes' => array('http')); + if (!Validate::uri($image, $options)) { + return PEAR::raiseError('Invalid URI for the image'); + } + + $ch = curl_init(); + $curlOptions = array( + CURLOPT_URL => "{$image}/info", + CURLOPT_HEADER => 0, + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_POSTFIELDS => $fileData + ); + curl_setopt_array($ch, $curlOptions); + + $response = curl_exec($ch); + curl_close($ch); + $wPattern = "/
Your Login Information has been sent to $email
" . + "Continue to Member Login
"; + } else { + $output = 'Email address not found.
'; + } + } elseif ($this->isSubmitted()) { + $output = $this->errorMsg; + $output .= parent::toHtml(); + } else { + $output .= parent::toHtml(); + } + + return $output; + } + + // }}} +} +?> diff --git a/Toolkit/Members/Auxiliary.php b/Toolkit/Members/Auxiliary.php new file mode 100644 index 0000000..8e7fc50 --- /dev/null +++ b/Toolkit/Members/Auxiliary.php @@ -0,0 +1,405 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version CVS: $Id: Auxiliary.php,v 1.1.1.1 2009/09/17 20:08:56 matrix Exp $ + * @link http://demo.gaslightmedia.com + */ + +/** + * Base class used for building forms to accompany the members database + * + * This class handles all common functions that are to be used in + * the auxiliary forms used to assist in the members DB. + * (categories, amenities, regions, etc...). + * + * @category MembersDB + * @package Toolkit_Members + * @author Jamie Kahgee
+ Please define the
+ MEMBER_RECORD_UPDATES_ADVISOR constant
+ in the setup file first.
This Constant should hold
+ the email address of the person you would like notified
+ when a member submits an update.
Set to false if you do
+ not want an email to be sent.
+
+ Has updated thier business record and is now in a pending + state. To approve / reject thier changes you can either log + into your {$page->siteName} admin area or follow this + {$page->link} +
"; + $crlf = "\n"; + $mimeMail = new Mail_mime($crlf); + $from = ereg_replace("[^A-Za-z ]", "", SITENAME) . ' <' . OWNER_EMAIL . '>'; + $mimeMail->setFrom($from); + $mimeMail->setSubject('Member Record Update'); + if (!empty($this->secondaryAdvisees)) { + foreach ($this->secondaryAdvisees as $k => $v) { + if (is_string($k) && !is_numeric($k)) { + $email = "$k <$v>"; + } else { + $email = $v; + } + $mimeMail->addCC($email); + } + } + $mimeMail->setHTMLBody($htmlMsg); + $mimeMail->setTXTBody($msg); + + $mail =& Mail::factory('mail'); + $body = $mimeMail->get(); + $headers = $mimeMail->headers($hdrs); + + $res = $mail->send($this->primaryAdvisee, $headers, $body); + if (PEAR::isError($res)) { + return Toolkit_Common::handleError($res); + } else { + return $res; + } + } + } + + // }}} + + // {{{ fieldPending() + + /** + * Determines if template fields are pending or not + * + * Each field in the template calls this function to determine if it + * is in a pending state or not. Fields that return true get a + * different colored background and border so they are easily recognizable. + * + * fields are considered pending if they are in the pendingFields array. + * + * @param string $elem element to check for pending + * + * @return boolean If the field is pending + * @access protected + */ + public function fieldPending($elem) + { + if (!is_array($this->pendingFields)) { + return false; + } else { + return in_array($elem->name, $this->pendingFields); + } + } + + // }}} + // {{{ filterURI() + + /** + * Filters uri's before they are validated + * + * @param string $uri URI to filter + * + * @return mixed new uri if missing scheme + * @access + */ + protected function filterURI($uri) + { + if (strstr($uri, 'http://') != $uri) { + return "http://$uri"; + } else { + return $uri; + } + } + + // }}} + // {{{ filterPhone() + + /** + * Filters phone numbers before they are validated + * + * @param string $phone number to filter + * + * @return mixed newly formatted phone number + * @access + */ + protected function filterPhone($phone) + { + // Ditch anything that is not a number + $number = preg_replace('/[^0-9]/', '', $phone); + + // Invalid Number, validation will catch error + $len = strlen($number); + if (($len < 10) || ($len > 11)) { + return $phone; + } + + // subscriber number + $sn = substr($number, -4); + // city code + $cc = substr($number, -7, 3); + // area code + $ac = substr($number, -10, 3); + if ($len == 11) { + // country prefix + $cp = $number[0]; + } + + $filteredNumber = "($ac) $cc-$sn"; + if (!is_null($cp)) { + $filteredNumber = "$cp $filteredNumber"; + } + + return $filteredNumber; + } + + // }}} + + // {{{ generateLatLon() + + /** + * Generates the listings lat and lon coordinates from either an address + * or their zip code. Depending on what gets entered into the form. + * + * If generating by zip code, we simply query the zip DB stored on ds3. + * Otherwise we query using google. + * + * @param mixed $data Array of data or zip + * + * @return Array Array of lat/lon coordinates + * @access protected + */ + protected function generateLatLon($data) + { + if (is_array($data)) { + try { + // Since we don't store the city or state names we need to query + // for it really quick to get it. + $sql = " + SELECT state_name + FROM state s + WHERE state_id = :sid"; + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(':sid', $data['state_id'], PDO::PARAM_INT); + $stmt->execute(); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + // Use google maps to get the lan/lon coords from our data. + $api_key = 'ABQIAAAAWqyv9sBAgUBdsdOdgo7LsRTeX7yNUukyMrmY8FsCXcCA9axlYBRmLDu7pJM7HIzM1e6MYO-pqjjp5w'; + $addr = $values['street']; + $city = $values['city']; + $state = $row['state_name']; + $zip = $values['zip']; + $url = "http://maps.google.com/maps/geo?output=xml&key=$api_key&q="; + $q = "$addr, $city, $state, $zip"; + $url .= urlencode($q); + // Query Google for this location's longitude and latitude + $command = "/usr/bin/curl '$url'"; + exec($command, $output, $return); + if (preg_match_all("/'.print_r($cData, true).'
'); + try { + $sql = " + DELETE FROM member_session + WHERE member_id = :member_id + AND contact_id = :contact_id"; + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(":member_id", $memberId, PDO::PARAM_INT); + $stmt->bindParam(":contact_id", $cData['id'], PDO::PARAM_INT); + $stmt->execute(); + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + } + } + + // }}} + // {{{ retrieveList() + + /** + * Retreive the list form the database storage and repopulate the accounts data + * to the session var $this->session = $_SESSION['wish_list'] + * + * @return void + * @access public + */ + function retrieveList() + { + if ($this->isLoggedIn()) { + $cData = $this->auth->getAuthData(); + try { + $sql = " + SELECT * + FROM member_session + WHERE contact_id = :contact_id"; + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(":contact_id", $cData['id'], PDO::PARAM_INT); + $stmt->execute(); + while ($row = $stmt->fetch()) { + // don't dupe the list + if (!$this->session[$row['member_id']]) { + $this->session[$row['member_id']] = array( + 'catid' => $row['catid'] + ); + } + } + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + } + } + + // }}} + // {{{ saveList() + + /** + * Save the list for the user. This is called on the login page after the + * session is repopulated out from database. No worries about dupes here. + * this function checks for existing records then won't reinsert. + * + * @param int $contactId the id from contact table for lookup + * + * @return void + * @access public + */ + function saveList($contactId = null) + { + if ($this->isLoggedIn() && is_array($this->session)) { + if (isset($contactId) && is_numeric($contactId)) { + $cData['id'] = $contactId; + } else { + $cData = $this->auth->getAuthData(); + } + $sql = " + SELECT member_id + FROM member_session + WHERE contact_id = :contact_id"; + try { + $getDat = $this->dbh->prepare($sql); + $getDat->bindParam(":contact_id", $cData['id'], PDO::PARAM_INT); + $getDat->execute(); + while ($row = $getDat->fetch()) { + $mStoreSess[$row['member_id']] = $row['member_id']; + } + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + foreach ($this->session as $memberId => $sData) { + if (!$mStoreSess[$memberId]) { + try { + $sql = " + INSERT INTO member_session + (contact_id, member_id, catid) + VALUES + (:contact_id, :member_id, :catid)"; + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam(":member_id", $memberId, PDO::PARAM_INT); + $stmt->bindParam(":contact_id", $cData['id'], PDO::PARAM_INT); + $stmt->bindParam(":catid", $sData['catid'], PDO::PARAM_INT); + $stmt->execute(); + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + } + } + } + } + // }}} +} +?> diff --git a/Toolkit/Members/TripPlanner/TripAuth.php b/Toolkit/Members/TripPlanner/TripAuth.php new file mode 100644 index 0000000..4a21ad5 --- /dev/null +++ b/Toolkit/Members/TripPlanner/TripAuth.php @@ -0,0 +1,788 @@ + + * @copyright 2009 Gaslight Media + * @license http://www.gaslightmedia.com Gaslightmedia + * @version CVS: $Id: TripAuth.php,v 1.2 2009/12/15 20:18:16 jamie Exp $ + * @link http://demo.gaslightmedia.com + * @see Toolkit_Members_Auth-LoginForm, Toolkit_Members_Auth-PasswordForm + */ + +require_once 'Auth.php'; + +/** + * Methods for the memberdb authentication system + * + * Handles Cookie and session generation, id challenges and security for + * the memberdb application + * + * @category MembersDB + * @package Toolkit_Members + * @author Steve SuttonYour Login Information has been sent to $email
" . + "Continue to Member Login
"; + } else { + $output = 'Email address not found.
'; + } + } elseif ($this->isSubmitted()) { + $output = $this->errorMsg; + $output .= parent::toHtml(); + } else { + $output .= parent::toHtml(); + } + + return $output; + } + + // }}} +} +?> diff --git a/Toolkit/Members/TripPlanner/helpme.html b/Toolkit/Members/TripPlanner/helpme.html new file mode 100644 index 0000000..aebc3c1 --- /dev/null +++ b/Toolkit/Members/TripPlanner/helpme.html @@ -0,0 +1,55 @@ + + + ++This section has been designed to allow you to build your own itinerary including attractions, recreation +and places to stay in Michigan's Upper Peninsula. To get started, search for the recreation, attraction or +place to stay on our Web site. As you find items that may be of interest to you, simply click the "Add to +Trip Planner" icon on each business listing. Each item will then get added to your list. Once you have +completed adding items to your planner list, you may take the following actions:
+ + + +'.print_r($_REQUEST, true).''); +$dont_include_functions = true; +/** + * requires setup.phtml + */ +require_once '../../../setup.phtml'; + +HTTP_Session2::useCookies(false); +HTTP_Session2::start(); + +$tripPlannerAuth =& new Toolkit_Members_TripPlanner_TripAuth( + 'DB', + array(), + '', + false +); +$tripPlannerAuth->setIdle(); +$tripPlannerAuth->start(); +$sessionList = new Toolkit_Members_TripPlanner_Sessions( + Toolkit_Database::getInstance(), + &$tripPlannerAuth +); +if ($_SESSION['wish_list'][$_REQUEST['member_id']]) { + $sessionList->removeRecord($_REQUEST['member_id']); + $add = false; +} else { + $sessionList->addRecord($_REQUEST['member_id'], $_REQUEST['catid']); + $add = true; +} + +//remove the email from GET array and goback to member detail page +unset($_REQUEST['member_email']); +if (is_array($_REQUEST)) { + foreach ($_REQUEST as $pname => $pval) { + if ($pval) { + $param_part[] = $pname.'='.urlencode($pval); + } + } +} +if (is_array($param_part)) { + $params = implode("&", $param_part); +} + +// need to make sure any GET parameter passed to this page get resent back +$url = BASE_URL . "index.php?catid=".$_REQUEST['catid']; +$url .= ($_REQUEST['detail']) ? "&member_id=" . $_REQUEST['member_id'] :'&_qf__SearchForm='; +$url .= ($_REQUEST['search']) ? "&search=" . $_REQUEST['search'] :''; +$url .= ($_REQUEST['business_name']) ?"&business_name=" . urlencode($_REQUEST['business_name']):''; +$url .= ($_REQUEST['category_id']) ? "&category_id=" . $_REQUEST['category_id'] :''; +$url .= ($_REQUEST['sub_category_id']) ? "&sub_category_id=" . $_REQUEST['sub_category_id'] :''; +$url .= ($_REQUEST['region_id']) ? "®ion_id=" . $_REQUEST['region_id'] :''; +$url .= ($_REQUEST['city_id']) ? "&city_id=" . $_REQUEST['city_id'] :''; +$url .= ($_REQUEST['page']) ? "&page=" . $_REQUEST['page'] :''; +$url .= ($_REQUEST['cPage']) ? "&cPage=" . $_REQUEST['cPage'] :''; +$url .= ($_REQUEST['alpha']) ? "&alpha=" . $_REQUEST['alpha'] :''; +$url .= ($_REQUEST['pageOffset']) ? "&pageOffset=" . $_REQUEST['pageOffset'] :''; +$url .= ($add == true) ? '&sessionAdd=1': '&sessionAdd=2'; +header("location: $url"); +exit(); +?> diff --git a/Toolkit/Members/TripPlannerList.php b/Toolkit/Members/TripPlannerList.php new file mode 100644 index 0000000..902675d --- /dev/null +++ b/Toolkit/Members/TripPlannerList.php @@ -0,0 +1,431 @@ + + * @copyright 2009 Gaslight Media + * @license Gaslight Media + * @version CVS: $Id: TripPlannerList.php,v 1.1.1.1 2009/09/17 20:08:56 matrix Exp $ + * @link <> + */ + +/** + * Short description for class + * + * Long description (if any) ... + * + * @category Toolkit + * @package Toolkit_Members + * @author Steve Sutton
'.print_r($page, true).''; + echo $out; + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + } else { + echo $this->showEmpty(); + } + } + + // }}} + // {{{ isLoggedIn() + + /** + * check if user is logged in or not + * + * @access public + * @return string + */ + function isLoggedIn() + { + $tripPlannerAuth =& new Toolkit_Members_TripPlanner_TripAuth('DB', array(), '', false); + $tripPlannerAuth->setIdle(); + $tripPlannerAuth->start(); + + $test = $tripPlannerAuth->checkAuth(); + if ($test) { + // give back the username + return $tripPlannerAuth->getUsername(); + } else { + return false; + } + } + + // }}} + // {{{ printAncestors() + + /** + * printAncestors + * + * @param mixed $catid page id + * + * @access public + * @return string + */ + function printAncestors($catid) + { + $ancestors = $this->getAncestors($catid, 0); + if (is_array($ancestors)) { + for ($i = 0; $i < count($ancestors); ++$i) { + $out[] = '' . $ancestors[$i]["label"] . ''; + } + if (is_array($out)) { + return implode(" / ", $out); + } + } + } + + // }}} + // {{{ saveList() + + + /** + * Short description for function + * + * Long description (if any) ... + * + * @return string Return description (if any) ... + * @access public + */ + function saveList() + { + if ($this->isLoggedIn()) { + $contactId = $_SESSION['_authsession']['data']['id']; + // if they already have something saved then wipe it out. + // (only one list per contact) + try { + $sql = " + DELETE FROM member_session + WHERE contact_id = :contact_id"; + $del = $this->dbh->prepare($sql); + $del->bindParam(":contact_id", $contactId, PDO::PARAM_INT); + $del->execute(); + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + + $sql = " + INSERT INTO member_session + (member_id,contact_id,catid) + VALUES + (:member_id,:contact_id,:catid)"; + $stmt = $this->dbh->prepare($sql); + if (is_array($_SESSION['wish_list'])) { + foreach ($_SESSION['wish_list'] as $member_id => $mData) { + $catid = $mData['catid']; + try { + $stmt->bindParam(":member_id", $member_id, PDO::PARAM_INT); + $stmt->bindParam(":contact_id", $contactId, PDO::PARAM_INT); + $stmt->bindParam(":catid", $catid, PDO::PARAM_INT); + $stmt->execute(); + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + } + $html = '
You list has been saved.
'; + } + } + return $html; + } + + // }}} + // {{{ show() + + + /** + * Calls the appropiate function for listing,saving,sending + * or printing the list also will need to handle grabbing list from + * database and repopulate the session. + * + * @return void + * @access public + */ + function show() + { + echo $this->toHTML(); + } + + // }}} + // {{{ showEmpty() + + /** + * shows the template tripPlannerNoList.tpl + * + * @access public + * @return string + */ + function showEmpty() + { + $temp = new HTML_Template_Flexy($this->flexyConfig); + $temp->compile("tripPlannerNoList.tpl"); + $page = new stdClass; + $toolbox = new GLM_TEMPLATE(HOME_ID); + $page->accountUrl = $toolbox->get_seo_url($this->plannerFormPageId); + $page->loginUrl = BASE_URL . 'Toolkit/Members/TripPlanner/login.php'; + $page->logoutUrl = BASE_URL . 'Toolkit/Members/TripPlanner/login.php?logout=1'; + $page->saveUrl = BASE_URL . 'index.php?catid='.$this->plannerListPageId.'&cPage=Save+List'; + $page->requestUrl = BASE_URL . 'index.php?catid='.$this->plannerListPageId.'&cPage=Send+List'; + $page->loginStat = ($_REQUEST['status']) ? 'Invalid username or password.': ''; + $page->isLoggedIn = $this->isLoggedIn(); + $page->username = $page->isLoggedIn; + $page->baseurl = BASE_URL; + return $temp->BufferedOutputObject($page); + } + + // }}} + // {{{ toHTML() + + /** + * Short description for function + * + * Long description (if any) ... + * + * @return string Return description (if any) ... + * @access public + */ + function toHTML() + { + if (is_array($_SESSION['wish_list']) && !empty($_SESSION['wish_list'])) { + switch ($_REQUEST['cPage']) { + case "Send List": + $pp = new Toolkit_Contacts_SendTripPlanner($this->dbh, + 'TravelList', + 'post', + BASE_URL . + 'index.php?catid='.$this->plannerListPageId); + $pp->configureForm(); + $html = $pp->toHTML(); + break; + case "Save List": + $html = $this->saveList(); + $html .= $this->getSessionList(); + break; + case "Login": + break; + case "Show List": + default: + $html = $this->getSessionList(); + break; + } + } else { + echo $this->showEmpty(); + } + return $html; + } + // }}} +} +?> diff --git a/Toolkit/Members/UserSearchForm.php b/Toolkit/Members/UserSearchForm.php new file mode 100644 index 0000000..572a0d9 --- /dev/null +++ b/Toolkit/Members/UserSearchForm.php @@ -0,0 +1,775 @@ + + * @copyright 2009 Jamie Kahgee + * @license http://www.gaslightmedia.com Gaslightmedia + * @version CVS: $Id: UserSearchForm.php,v 1.1.1.1 2009/09/17 20:08:56 matrix Exp $ + * @link http://demo.gaslightmedia.com + */ + +/** + * Member Search Form + * + * @category MembersDB + * @package Toolkit_Members + * @author Jamie KahgeeGoogle provides the tools needed for placing your business correctly on their maps. +Visit this page: http://www.google.com/lbc
+In addition to your correct location in their maps, you can also add other information pertaining +to your business such as opening hours, services, contact information etc.
+ +You can use this option to set your lat/long information for the Google Maps on this site only.
+Once your location is displaying right from the Google Local Business Center, you can remove numbers in these fields.
diff --git a/Toolkit/Members/export-images-is0.php b/Toolkit/Members/export-images-is0.php new file mode 100755 index 0000000..34bb34a --- /dev/null +++ b/Toolkit/Members/export-images-is0.php @@ -0,0 +1,81 @@ + + * @author Jamie Kahgee'; + print_r($data); + echo ''; +} catch(PDOException $e) { + die($e->getMessage()); +} +$db->beginTransaction(); +$IServer = new Toolkit_Image_Server(); +if (is_array($data)) { + $prep2 = " + UPDATE member + SET logo = :image + WHERE member_id = :id"; + $stmt3 = $db->prepare($prep2); + + foreach ($data as &$row) { + $row['logo'] = trim($row['logo']); + var_dump(OLDORG.$row['logo']); + if (!ereg("^is", $row['logo'])) { + $image_URL = OLDORG.urlencode($row['logo']); + $image = $IServer->imageUpload($image_URL); + if ($image) { + try { + $stmt3->bindParam(":image", $image, PDO::PARAM_STR); + $stmt3->bindParam(":id", $row['member_id'], PDO::PARAM_INT); + $stmt3->execute(); + } catch(PDOException $e) { + die($e->getMessage()); + } + } + echo '
+
|
+ |
+
|
+
+
|
+
+ Remember to click on the Submit button on the + bottom of the page after doing any changes. +
+ {form.javascript:h} + + {form.outputHeader():h} + {form.hidden:h} + + + {validated():h} ++ Check off any available amenities and click + the submit button on the bottom of the page. +
+ {foreach:form.sections,sec} ++ Remember to click on the Submit button on the + bottom of the page after doing any changes. +
+ {form.javascript:h} + {form.outputHeader():h} + {form.hidden:h} + + + {validated():h} ++ * + {if:elem.error}{end:} + {elem.label} + {if:elem.error}{end:} + | ++ + {elem.error} + + {elem.html:h} + | +
+
|
+ |
+
|
+
+ Month + | ++ Listed + | ++ Details + | ++ Clicks + | +
---|---|---|---|
+ {row[month]} + | ++ {row[list]} + | ++ {row[detail]} + | ++ {row[click]} + | +
+ Exposure Reports - check the statistics being compiled that include: +
+ Member Name + | ++ Listed + | ++ Details + | ++ Clicks + | +
---|---|---|---|
+ {row[member_name]:h} + | ++ {row[list]} + | ++ {row[detail]} + | ++ {row[click]} + | +
+ | Amenity Name | +
---|---|
+ | + +{v:h} | +
+ | City Name | +
---|---|
+ | + +{v:h} | +
+ | Subject | +Last Updated | +
---|---|---|
+ | + +{v[subject]:h} | +{v[last_update]:h} | +
Showing records {firstRecord} to {lastRecord}
+Showing records {firstRecord} to {lastRecord}
+ + {getPaging():h} +{else:} ++ | Region Name | +
---|---|
+ | + +{v:h} | +
Showing records {firstRecord} to {lastRecord}
++ + | ++ Member Name + | ++ First Name + | ++ Last Name + | +
---|---|---|---|
+ [Edit] + | ++ {row[member_name]:h} + | ++ {row[fname]} + | ++ {row[lname]} + | +
Par | +Yardage | +Course Rating | +Slope Rating | +
---|---|---|---|
{par:h} | +{yardage:h} | +{course_rating:h} | +{slope_rating:h} | +
Breakfast | +Brunch | +Lunch | +Dinner | +Alcohol | +
---|---|---|---|---|
{breakfast:h} | +{brunch:h} | +{lunch:h} | +{dinner:h} | +{alcohol:h} | +
Showing records {firstRecord} to {lastRecord}
+
+
|
+
+
|
+
{elem.html:h} | +{elem.label:h} | + {else:} + ++ * + {if:elem.error}{end:} + {elem.label} + {if:elem.error}{end:} + | +
+
+ {elem.error}
+
+ {elem.html:h}
+ |
+ {end:}
+
Email:
+Password:
+ +{loginStat}
+ +- or -
+ ++ Logged in as {username} + Log Out +
+{row[street]:h}
+{row[city]:h}, {row[state_abbr]:h} {row[zip]:h}
+Time you should plan to spend here: {row[time_allocated]}
+Email:
+Password:
+ +{loginStat}
+ +- or -
+ ++ Logged in as {username} + Log Out +
++ Has updated thier business record and is now in a pending + state. To approve / reject thier changes you can either log + into your {$page->siteName} admin area or follow this + {$page->link} +
"; + $crlf = "\n"; + $mimeMail = new Mail_mime($crlf); + $from = ereg_replace("[^A-Za-z ]", "", SITENAME) . '5ic7XC*2PRyZs2nd
zFr20p1+lU)V@d&oIV;d=u;g)IXjMd`r#xT)16@A=B@r;Aym
z%7C$)-M5ycAbh@|o@)JZJh4xCEK|96hAZ~bVtKUXMg%Adw_ni^i`nl6iU7rdvIE?5
zBba-DO^wn>2Vl)aYVIN6%I+*5JgTRyKX(85J9w=KZ0rDAWoRwVJ!ftO+36w+0===P
zKO?UVG$HIOE`jdju0GFlbHGWiZtM^#V-*nnT+dfBWfMM8o3l
z
+
+
+
+
+
+
+
+
+
+
+
","
"]||!O.indexOf("",""]||(!O.indexOf(" "," "]||!O.indexOf("a';var H=K.getElementsByTagName("*"),E=K.getElementsByTagName("a")[0];if(!H||!H.length||!E){return}o.support={leadingWhitespace:K.firstChild.nodeType==3,tbody:!K.getElementsByTagName("tbody").length,objectAll:!!K.getElementsByTagName("object")[0].getElementsByTagName("*").length,htmlSerialize:!!K.getElementsByTagName("link").length,style:/red/.test(E.getAttribute("style")),hrefNormalized:E.getAttribute("href")==="/a",opacity:E.style.opacity==="0.5",cssFloat:!!E.style.cssFloat,scriptEval:false,noCloneEvent:true,boxModel:null};G.type="text/javascript";try{G.appendChild(document.createTextNode("window."+J+"=1;"))}catch(I){}F.insertBefore(G,F.firstChild);if(l[J]){o.support.scriptEval=true;delete l[J]}F.removeChild(G);if(K.attachEvent&&K.fireEvent){K.attachEvent("onclick",function(){o.support.noCloneEvent=false;K.detachEvent("onclick",arguments.callee)});K.cloneNode(true).fireEvent("onclick")}o(function(){var L=document.createElement("div");L.style.width=L.style.paddingLeft="1px";document.body.appendChild(L);o.boxModel=o.support.boxModel=L.offsetWidth===2;document.body.removeChild(L).style.display="none"})})();var w=o.support.cssFloat?"cssFloat":"styleFloat";o.props={"for":"htmlFor","class":"className","float":w,cssFloat:w,styleFloat:w,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",tabindex:"tabIndex"};o.fn.extend({_load:o.fn.load,load:function(G,J,K){if(typeof G!=="string"){return this._load(G)}var I=G.indexOf(" ");if(I>=0){var E=G.slice(I,G.length);G=G.slice(0,I)}var H="GET";if(J){if(o.isFunction(J)){K=J;J=null}else{if(typeof J==="object"){J=o.param(J);H="POST"}}}var F=this;o.ajax({url:G,type:H,dataType:"html",data:J,complete:function(M,L){if(L=="success"||L=="notmodified"){F.html(E?o("").append(M.responseText.replace(/
+
diff --git a/Toolkit/Photos/templates/photos.html b/Toolkit/Photos/templates/photos.html
new file mode 100755
index 0000000..fdd861d
--- /dev/null
+++ b/Toolkit/Photos/templates/photos.html
@@ -0,0 +1,15 @@
+
{album}
+ {foreach:photos,photo}
+ {if:photo[firstInRow]}
+
+ {end:}
+ {end:}
+'.$this->nav.'
';
+ }
+ }
+
+ // }}}
+ // {{{ setupRenderers()
+
+
+ /**
+ * Short description for function
+ *
+ * Long description (if any) ...
+ *
+ * @return void
+ * @access protected
+ */
+ protected function setupRenderers()
+ {
+ $renderer =& new HTML_QuickForm_Renderer_Object(true);
+
+ $this->accept($renderer);
+
+ $this->template =& new HTML_Template_Flexy($this->options);
+
+ // Make the view a copy of the $this object
+ // That way we have access to call functions in
+ // this class from within the template.
+ $this->view = $this;
+ $this->view->form = $renderer->toObject();
+ $this->template->compile($this->formTemplate);
+ }
+
+ // }}}
+ // {{{ toHTML()
+
+ /**
+ * Renders the form
+ *
+ * sets the page the form should be redirected to instead of coming back
+ * around to itself.
+ *
+ * @author Jamie Kahgee '.print_r($data, true).'
';
+ } catch(PDOException $e) {
+ echo ''.print_r($e, true).'
';
+ die($e->getMessage);
+ }
+ }
+
+
+ // }}}
+ // {{{ setNewscatid
+
+
+ /**
+ * setNewscatid
+ *
+ * sets the _newscatid
+ *
+ * @param unknown $id category id for news
+ *
+ * @return void
+ * @access public
+ */
+ function setNewscatid($id)
+ {
+ $this->_newscatid = $id;
+ }
+
+
+ // }}}
+ // {{{ setToolboxid
+
+
+ /**
+ * setToolboxid
+ *
+ * sets the _toolboxid
+ *
+ * @return void
+ * @access public
+ */
+ function setToolboxid()
+ {
+ $this->_toolboxid =& $GLOBALS['catid'];
+ }
+
+ // }}}
+}
+?>
diff --git a/Toolkit/Press/templates/news.html b/Toolkit/Press/templates/news.html
new file mode 100755
index 0000000..de2148d
--- /dev/null
+++ b/Toolkit/Press/templates/news.html
@@ -0,0 +1,34 @@
+{pr_date}
+{title}
+{header}
+{if:image}
+ {if:imagename}
+ ';
+
+ {end:}
+{end:}
+{description:h}
+{if:file}
+
{if:filename}{filename}{else:}{file}{end:}
+{end:}
+{foreach:section,k,v}
+ {v[header]}
+ {if:v[image]}
+
+ {end:}
+ {v[description]:h}
+ {if:v[file]}
+
{if:v[filename]}{v[filename]}{else:}{v[file]}{end:}
+ {end:}
+{end:}
+
+
+{foreach:news_summary,k,v}
+
+{end:}
diff --git a/Toolkit/ShortURL.php b/Toolkit/ShortURL.php
new file mode 100755
index 0000000..6642309
--- /dev/null
+++ b/Toolkit/ShortURL.php
@@ -0,0 +1,127 @@
+
+ * @copyright 2009 Gaslight Media
+ * @license Gaslight Media
+ * @version CVS: $Id: ShortURL.php,v 1.1.1.1 2009/09/17 20:08:55 matrix Exp $
+ * @link <>
+ */
+
+/**
+ * Toolkit_ShortURL
+ *
+ * Integration of Toolbox with creation of ShortURL
+ * the url rewrite happens with one line of code in .htaccess
+ * RewriteRule ^([A-Za-z0-9_-]*)$ index.php?page=$1 [L]
+ * index page checks for $_GET['page'] and then calls
+ * getShortUrlId to get the page's catid. If not found it
+ * defaults to HOME_ID
+ *
+ * @category Toolkit
+ * @package Toolkit_ShortURL
+ * @author Steve Sutton ";
+
+ /**
+ * Description for var
+ * @var string
+ * @access public
+ */
+ var $endLevel = "
";
+
+ /**
+ * Description for var
+ * @var string
+ * @access public
+ */
+ var $beginItem = "';
+
+ $d['current_image'] = sprintf($i, THUMB . $d['image']);
+
+ } catch (PDOException $e) {
+ return Toolkit_Common::handleError($e);
+ }
+ } else {
+ $d = array(
+ 'template' => 1,
+ );
+ }
+ $this->setupDefaults($d);
+ }
+
+ // }}}
+ // {{{ configureElements()
+
+ /**
+ * Form element definitions
+ *
+ * @param Config_Container $c Configuration object
+ *
+ * @return void
+ * @access public
+ */
+ public function configureElements(Config_Container $c)
+ {
+ $e = array();
+
+ // get reference to [listing type] section of config file
+ $config =& $c->getItem('section', 'listing type');
+ $pluralDirective =& $config->getItem('directive', 'plural');
+ $pluralType = $pluralDirective->getContent();
+
+ // Grouped Elements are defined here.
+ $submitBtns = array();
+
+ $submitBtns[] = array(
+ 'type' => 'submit',
+ 'req' => false,
+ 'name' => 'update_rmv',
+ 'display' => 'Update'
+ );
+ $submitBtns[] = array(
+ 'type' => 'submit',
+ 'req' => false,
+ 'name' => 'cancel_rmv',
+ 'display' => 'Cancel'
+ );
+ $submitBtns[] = array(
+ 'type' => 'submit',
+ 'req' => false,
+ 'name' => 'delete_rmv',
+ 'display' => 'Delete'
+ );
+
+ $templates = array();
+
+ $options = range(1, 6);
+ foreach ($options as $i) {
+ $img = "
";
+
+ $templates[] = array(
+ 'type' => 'radio',
+ 'req' => false,
+ 'name' => 'template',
+ 'display' => "Template $i
$img",
+ 'att' => $i,
+ 'opts' => $i,
+ );
+ }
+
+ // All Elements are created here.
+ // This includes group element definitions.
+ $res = $this->getConstant('MEMBERS_DB');
+ $isErr = PEAR::isError($res);
+ if ($isErr) {
+ Toolkit_Common::handleError($e);
+ }
+ if ($res && !$isErr) {
+ $e[] = array(
+ 'type' => 'header',
+ 'req' => false,
+ 'name' => 'memberDbHdr',
+ 'display' => $pluralType,
+ );
+ $e[] = array(
+ 'type' => 'static',
+ 'req' => false,
+ 'name' => 'pageCategories'
+ );
+ // Note that we call to populate this select list at the
+ // bottom of this function after the element is made
+ // so we load attributes (classes) into each option as needed.
+ $e[] = array(
+ 'type' => 'select',
+ 'req' => false,
+ 'name' => 'memberCat',
+ 'display' => 'Member Categories',
+ 'opts' => array('' => '-- None --'),
+ 'att' => array(
+ 'multiple' => 'multiple',
+ 'size' => 7
+ )
+ );
+ $e[] = array(
+ 'type' => 'advcheckbox',
+ 'req' => false,
+ 'name' => 'no_search_form',
+ 'display' => 'Search Box',
+ 'val' => array(0, 1)
+ );
+ }
+ $e[] = array(
+ 'type' => 'header',
+ 'req' => false,
+ 'name' => 'pageAttributesHdr',
+ 'display' => 'Page Attributes'
+ );
+ $e[] = array(
+ 'type' => 'text',
+ 'req' => false,
+ 'name' => 'category',
+ 'display' => 'Navigation Name'
+ );
+ $e[] = array(
+ 'type' => 'select',
+ 'req' => false,
+ 'name' => 'parent',
+ 'display' => 'Parent Page',
+ 'opts' => array('0' => '-- No Parent --'),
+ );
+ $e[] = array(
+ 'type' => 'text',
+ 'req' => false,
+ 'name' => 'keyword',
+ 'display' => 'Keyword'
+ );
+ $e[] = array(
+ 'type' => 'advcheckbox',
+ 'req' => false,
+ 'name' => 'section_links',
+ 'display' => 'Search',
+ 'opts' => 'Create a list of links to the paragraph headlines',
+ 'val' => array(0, 1)
+ );
+ $res = $this->getConstant('HOME_HEADLINES');
+ $isErr = PEAR::isError($res);
+ if ($isErr) {
+ Toolkit_Common::handleError($e);
+ }
+ if ($res && !$isErr) {
+ $e[] = array(
+ 'type' => 'header',
+ 'req' => false,
+ 'name' => 'homePageHeadlinesHdr',
+ 'display' => 'Headlines'
+ );
+ $e[] = array(
+ 'type' => 'advcheckbox',
+ 'req' => false,
+ 'name' => 'featured',
+ 'display' => 'Home Page Headlines',
+ 'val' => array(0, 1)
+ );
+ $e[] = array(
+ 'type' => 'text',
+ 'req' => false,
+ 'name' => 'feature_intro',
+ 'display' => 'Headline Intro'
+ );
+ }
+ $e[] = array(
+ 'type' => 'header',
+ 'req' => false,
+ 'name' => 'pageBodyHdr',
+ 'display' => 'Page Body'
+ );
+ $e[] = array(
+ 'type' => 'text',
+ 'req' => false,
+ 'name' => 'intro',
+ 'display' => 'Page Title'
+ );
+ $e[] = array(
+ 'type' => 'textarea',
+ 'req' => false,
+ 'name' => 'description',
+ 'display' => 'Description',
+ 'opts' => array(
+ 'cols' => 70,
+ 'rows' => 25
+ ),
+ );
+ if ($this->hasUploadedImage()) {
+ $e[] = array(
+ 'type' => 'static',
+ 'req' => false,
+ 'name' => 'current_image',
+ 'display' => 'Current Image'
+ );
+ $e[] = array(
+ 'type' => 'text',
+ 'req' => false,
+ 'name' => 'imagename',
+ 'display' => 'Image Caption'
+ );
+ $e[] = array(
+ 'type' => 'checkbox',
+ 'req' => false,
+ 'name' => 'remove_image',
+ 'display' => 'Delete Image'
+ );
+ }
+ $e[] = array(
+ 'type' => 'file',
+ 'req' => false,
+ 'name' => 'image',
+ 'display' => 'New Image'
+ );
+ $e[] = array(
+ 'type' => 'group',
+ 'req' => false,
+ 'name' => 'page_layout',
+ 'group' => $templates,
+ 'label' => 'Template',
+ 'seperator' => '',
+ 'appendName' => false
+ );
+
+ // If we are editing a page, show three submit buttons
+ // otherwise, just show one insert button.
+ if (is_numeric($_GET['id'])) {
+ $e[] = array(
+ 'type' => 'group',
+ 'req' => false,
+ 'name' => 'submit_buttons',
+ 'group' => $submitBtns,
+ 'label' => '',
+ 'seperator' => '',
+ 'appendName' => false,
+ );
+ } else {
+ $e[] = array(
+ 'type' => 'submit',
+ 'req' => false,
+ 'name' => 'insert_rmv',
+ 'display' => 'Insert'
+ );
+ }
+
+ $this->setupElements($e);
+ // Load the member categories after the elements have been created
+ // so we can get more control how the options are rendered
+ // ie (adding classes to them)
+ $res = $this->getConstant('MEMBERS_DB');
+ $isErr = PEAR::isError($res);
+ if ($isErr) {
+ Toolkit_Common::handleError($e);
+ }
+ if ($res && !$isErr) {
+ $this->loadMemberCategories();
+ }
+ // Do the same for the pages
+ $this->loadParentPages();
+ }
+
+ // }}}
+ // {{{ configureFilters()
+
+ /**
+ * Form filter definitions
+ *
+ * Applies a data filter for the given fields when the form is submitted
+ *
+ * @return void
+ * @access public
+ */
+ public function configureFilters()
+ {
+ $f = array();
+
+ $f[] = array(
+ 'element' => '__ALL__',
+ 'filter' => 'trim'
+ );
+
+ $this->setupFilters($f);
+ }
+
+ // }}}
+ // {{{ configureForm()
+
+ /**
+ * Bundle all form configuration calls into one function call
+ *
+ * @param Config_Container $c Configuration object
+ *
+ * @return void
+ * @access public
+ */
+ public function configureForm(Config_Container $c)
+ {
+ $this->configureElements($c);
+ $this->configureRules();
+ $this->configureFilters();
+ $this->configureDefaults();
+ }
+
+ // }}}
+ // {{{ configureRules()
+
+ /**
+ * Form rule definitions
+ *
+ * Adds validation rules for the given fields
+ *
+ * @return void
+ * @access public
+ */
+ public function configureRules()
+ {
+ $r = array();
+ // Form Rules
+
+ $this->setupRules($r);
+ }
+
+ // }}}
+
+ // {{{ getCurrentParent()
+
+ /**
+ * Gets the parent id of a page
+ *
+ * @param integer $id page id
+ *
+ * @return integer parent id
+ * @access protected
+ */
+ protected function getCurrentParent($id)
+ {
+ try {
+ $sql = "
+ SELECT parent
+ FROM {$this->tableName}
+ WHERE id = :id";
+
+ $stmt = $this->dbh->prepare($sql);
+ $stmt->bindParam(':id', $id, PDO::PARAM_INT);
+ $stmt->execute();
+ $stmt->bindColumn('parent', $parent);
+ $stmt->fetch();
+
+ return $parent;
+ } catch (PDOException $e) {
+ return Toolkit_Common::handleError($e);
+ }
+ }
+
+ // }}}
+ // {{{ getNewParentPosition()
+
+ /**
+ * Gets the position to use for a page
+ *
+ * If we are inserting a new page we need to get the position to insert
+ * the new page at. Or if we are updating an existing page and reassigning
+ * it to a new parent, we need to get the new position to insert
+ * the page at.
+ *
+ * @param integer $parent page id of the new parent page
+ *
+ * @return integer new position to use
+ * @access protected
+ */
+ protected function getNewParentPosition($parent)
+ {
+ try {
+ $sql = "
+ SELECT count(*) + 1 AS newparent
+ FROM {$this->tableName}
+ WHERE parent = :parent
+ AND id != :home_id";
+
+ $stmt = $this->dbh->prepare($sql);
+ $stmt->bindParam(':parent', $parent, PDO::PARAM_INT);
+ $stmt->bindValue(':home_id', HOME_ID, PDO::PARAM_INT);
+ $stmt->execute();
+ $stmt->bindColumn('newparent', $newParent);
+ $stmt->fetch();
+
+ if ($parent == 0) {
+ ++$newParent;
+ }
+
+ return $newParent;
+ } catch (PDOException $e) {
+ return Toolkit_Common::handleError($e);
+ }
+ }
+
+ // }}}
+ // {{{ getTableName()
+
+ /**
+ * Gets the primary table name
+ *
+ * @return string table name
+ * @access public
+ */
+ public function getTableName()
+ {
+ return $this->tableName;
+ }
+
+ // }}}
+ // {{{ getConstant()
+
+ /**
+ * fetch a defined constant value
+ *
+ * @param string $constant constant name
+ *
+ * @return mixed constant value
+ * @acess protected
+ */
+ protected function getConstant($constant)
+ {
+ if (!defined($constant)) {
+ return PEAR::raiseError('calling undefined constant');
+ } else {
+ return constant($constant);
+ }
+ }
+
+ // }}}
+
+ // {{{ hasUploadedImage()
+
+ /**
+ * Check to see if page we are editing has an uploaded image
+ *
+ * @return boolean If page has a previously uploaded image
+ * @access protected
+ */
+ protected function hasUploadedImage()
+ {
+ if (!is_numeric($_GET['id'])) {
+ return false;
+ }
+ try {
+ $sql = "
+ SELECT *
+ FROM {$this->tableName}
+ WHERE id = :id";
+
+ $stmt = $this->dbh->prepare($sql);
+ $stmt->bindParam(':id', $_GET['id'], PDO::PARAM_INT);
+ $stmt->execute();
+ $stmt->bindColumn('image', $image);
+ $row = $stmt->fetch();
+ return !is_null($image);
+ //return !(is_null($image) || empty($image));
+ } catch (PDOException $e) {
+ return Toolkit_Common::handleError($e);
+ }
+ }
+
+ // }}}
+
+ // {{{ loadMemberCategories()
+
+ /**
+ * Loads member categories into the select list
+ *
+ * Gets an array structure of the member categories in a linear tree order
+ * Then walk through the array and load each category into the select list
+ *
+ * @return void
+ * @access public
+ */
+ public function loadMemberCategories()
+ {
+ try {
+ // Get a tree list of categories in linear order with
+ // category keys in the values and their level in the tree
+ // in the value
+ $c = Toolkit_Common::getHierarchicalTreeStructure(
+ $this->dbh,
+ 'category',
+ 'category_id',
+ 'parent_id'
+ );
+
+ // Get all the data about each category
+ $sql = "
+ SELECT *
+ FROM category
+ WHERE category_id = ?";
+
+ $stmt = $this->dbh->prepare($sql);
+ // Get the member categories select list element
+ $e =& $this->getElement('memberCat');
+ foreach ($c as $i => $j) {
+ $stmt->execute(array($i));
+ $row = $stmt->fetch();
+ // the class level is always 1 less than what is reported
+ // from our $c array
+ $x = $j - 1;
+ // Add the option data to the select list.
+ $e->addOption($row['name'], $i, array('class' => "level-$x"));
+ }
+ } catch (PDOException $e) {
+ return Toolkit_Common::handleError($e);
+ }
+ }
+
+ // }}}
+ // {{{ loadParentPages()
+
+ /**
+ * Load option elements into the parent select list
+ *
+ * These options are loaded via this seperate function vs inline w/ the
+ * element definition b/c we need a little more control defining
+ * the class names for each option so they will render nice when a user
+ * is looking at the list.
+ *
+ * @return void
+ * @throws PDOException throws exception on sql error
+ * @access public
+ */
+ public function loadParentPages()
+ {
+ try {
+ // Get a tree list of categories in linear order with
+ // category keys in the values and their level in the tree
+ // in the value
+ $c = Toolkit_Common::getHierarchicalTreeStructure(
+ $this->dbh,
+ 'bus_category',
+ 'id',
+ 'parent',
+ 'pos',
+ 0,
+ $this->maxDepth
+ );
+
+ // unset the home page, this is never an option to have children
+ // underneath it.
+ unset($c[HOME_ID]);
+
+ // If we are editing a page, then we don't want that page
+ // to show up as an option in the select list.
+ if (is_numeric($_GET['id'])) {
+ reset($c);
+ // Get us to the point in the array were this page is located
+ while (key($c) != $_GET['id'] && current($c) !== false) {
+ next($c);
+ }
+ // Make sure we didn't traverse off the end of the array
+ if (current($c) !== false) {
+ // get the starting level we are currently at
+ $sl = current($c);
+ // remove this page (the one we're editing) from the
+ // array and advance the internal array pointer
+ unset($c[key($c)]);
+ // now we need to make sure all sub pages beneath this
+ // page are also not being shown
+
+ // while we don't traverse off the end of the array
+ while (current($c) !== false) {
+ // get the current sub level we are at
+ $csl = current($c);
+ // if the current sub-level is the same as the
+ // starting level, that means we have traversed through
+ // all the sub-pages and can break out of the loop
+ if ($csl == $sl) {
+ break;
+ } else {
+ // we are still in a sub-level page, so unset
+ // this page so it doesn't show, and advance
+ // the internal array pointer
+ unset($c[key($c)]);
+ }
+ }
+ }
+ }
+
+ // Get all the data about each category
+ $sql = "
+ SELECT *
+ FROM bus_category
+ WHERE id = ?";
+
+ $stmt = $this->dbh->prepare($sql);
+ // Get the member categories select list element
+ $e =& $this->getElement('parent');
+ foreach ($c as $i => $j) {
+ $stmt->execute(array($i));
+ $row = $stmt->fetch();
+ // the class level is always 1 less than what is reported
+ // from our $c array
+ $x = $j - 1;
+ // Add the option data to the select list.
+ $e->addOption($row['category'], $i, array('class' => "level-$x"));
+ }
+ } catch (PDOException $e) {
+ return Toolkit_Common::handleError($e);
+ }
+ }
+
+ // }}}
+
+ // {{{ insertPage()
+
+ /**
+ * Create a new page in the site by inserting values into the DB
+ *
+ * @param array $values Submitted form values
+ *
+ * @return boolean Result of insertion
+ * @access protected
+ */
+ protected function insertPage($values)
+ {
+ // Get the member categories if they exists so we don't try and
+ // insert them into the wrong table.
+ $memberCats = $values['memberCat'];
+ unset($values['memberCat']);
+
+ // Get the value of the new position this page will be set to.
+ $values['pos'] = $this->getNewParentPosition($values['parent']);
+
+ // a non empty file size indicates to use an image has been uploaded.
+ if (!empty($values['image']['size'])) {
+ $values['image'] = $this->uploadImage('image');
+ if ($values['image'] === false) {
+ return PEAR::raiseError('Invalid image response');
+ }
+ } else {
+ unset($values['image']);
+ }
+
+ $sql = Toolkit_Common::createSQLInsert(
+ $this->tableName,
+ array_keys($values)
+ );
+
+ try {
+ $this->dbh->beginTransaction();
+ Toolkit_Common::processQuery(
+ $this->dbh,
+ $this->tableName,
+ $sql,
+ $values
+ );
+
+ // If we are trying to associate member categories
+ // with the toolbox page then insert them here.
+ if (is_array($memberCats) && !empty($memberCats)) {
+ // Need to get the last id inserted into the table.
+ $sql = "
+ SELECT id
+ FROM {$this->tableName}
+ ORDER BY id DESC
+ LIMIT 1";
+
+ $row = $this->dbh->query($sql)->fetch();
+ $sql = Toolkit_Common::createSQLInsert(
+ 'bus_cat_member',
+ array('catid', 'memb_type')
+ );
+
+ $stmt = $this->dbh->prepare($sql);
+ $stmt->bindParam(':catid', $row['id'], PDO::PARAM_INT);
+ // zip through all the member categories selected
+ // and insert them into the table.
+ foreach ($memberCats as $i) {
+ if (is_numeric($i)) {
+ $stmt->bindParam(':memb_type', $i, PDO::PARAM_INT);
+ $stmt->execute();
+ }
+ }
+ }
+
+ return $this->dbh->commit();
+ } catch (PDOException $e) {
+ $this->dbh->rollback();
+ return Toolkit_Common::handleError($e);
+ }
+ }
+
+ // }}}
+
+ // {{{ processData()
+
+ /**
+ * Clean unneeded form elements out of the submitted values array
+ *
+ * @param array $values QuickForm submitted elements
+ *
+ * @return boolean Result of insert/update functions
+ * @access public
+ */
+ public function processData($values)
+ {
+ foreach ($values as $k => $v) {
+ switch ($k) {
+ case 'MAX_FILE_SIZE' :
+ unset($values[$k]);
+ break;
+
+ default :
+ if (substr($k, -4) == '_rmv') {
+ unset($values[$k]);
+ }
+ break;
+ }
+ }
+
+ $function = is_numeric($_GET['id']) ? 'updatePage' : 'insertPage';
+ return $this->$function($values);
+ }
+
+ // }}}
+
+ // {{{ removeImage()
+ // @codeCoverageIgnoreStart
+
+ /**
+ * Deletes an image from the file server
+ *
+ * @param string $fileName Name of the image to delete
+ *
+ * @return void
+ * @access protected
+ */
+ protected function removeImage($fileName)
+ {
+ $is = new Toolkit_Image_Server();
+ $is->imageDelete($fileName);
+ }
+
+ // @codeCoverageIgnoreEnd
+ // }}}
+
+ // {{{ setMaxDepth()
+
+ /**
+ * Sets the max depth level that the parent page select list will show
+ *
+ * @param integer $md New max depth
+ *
+ * @return void
+ * @access public
+ */
+ public function setMaxDepth($md)
+ {
+ $this->maxDepth = $md;
+ }
+
+ // }}}
+ // {{{ setupRenderers()
+
+ /**
+ * Custom rendering templates for special fields on the form
+ *
+ * @return void
+ * @access protected
+ */
+ protected function setupRenderers()
+ {
+ parent::setupRenderers();
+ $renderer =& $this->defaultRenderer();
+ $required = ' * ';
+ $error = '\n\t\t ", 'submit_buttons');
+ $renderer->setElementTemplate("\n\t$required{label}$error{element} \n\t\n\t\t ", 'insert_rmv');
+
+ $renderer->setGroupTemplate("\n\t$required{label}$error{element} \n\t\n\t\t\n\t\t\t
", 'page_layout');
+ $renderer->setGroupElementTemplate("\n\t{content} \n\t\t\n\t\n\t\t\n\t ", 'page_layout');
+ }
+
+ // }}}
+
+ // {{{ toHtml()
+
+ /**
+ * Handles how to display the current step the user is at in the form
+ *
+ * @return string rendered html form
+ * @access public
+ */
+ public function toHtml()
+ {
+ $validated = $this->validate();
+ $this->setupRenderers();
+ if ($validated) {
+ $this->cleanForm();
+
+ $r = $this->process(
+ array(&$this, 'processData'),
+ $this->mergeFiles
+ );
+ if (PEAR::isError($r)) {
+ return Toolkit_Common::handleError($r);
+ } else {
+ $this->freeze();
+ $output = $this->successMsg;
+ }
+ } elseif ($this->isSubmitted()) {
+ $output = $this->errorMsg;
+ $output .= parent::toHTML();
+ } else {
+ $output = parent::toHTML();
+ }
+ return $output;
+ }
+
+ // }}}
+
+ // {{{ updatePage()
+
+ /**
+ * Update an existing page in the site by updating values in the DB
+ *
+ * @param array $values Submitted form values
+ *
+ * @return boolean Result of insertion
+ * @access protected
+ */
+ protected function updatePage($values)
+ {
+ // Make sure we are dealing w/ a valid page
+ if (!is_numeric($_GET['id'])) {
+ return PEAR::raiseError('Invalid page id');
+ }
+
+ // Handle user deleting the page image.
+ if (array_key_exists('remove_image', $values)) {
+ $this->removeImage($values['imagename']);
+
+ // unset value so its not included in the update sql query
+ unset($values['remove_image']);
+ // set image and imagename to null to overwrite value in db.
+ // if we are not uploading a new image.
+ if (empty($values['image']['size'])) {
+ $values['image'] = $values['imagename'] = null;
+ }
+ }
+
+ // a non empty file size indicates to use an image has been uploaded.
+ if (!empty($values['image']['size'])) {
+ $values['image'] = $is->imageUpload('image');
+ if ($values['image'] === false) {
+ return PEAR::raiseError('Invalid image response');
+ }
+ } elseif (!is_null($values['image'])) {
+ unset($values['image']);
+ }
+
+ // Get the parent id this page is currently set to in the DB.
+ $curPar = $this->getCurrentParent($_GET['id']);
+ // parents will be different if we are reassining to a new parent
+ if ($curPar != $values['parent']) {
+ // Get an updated position for the new parent page.
+ $values['pos'] = $this->getNewParentPosition($values['parent']);
+ }
+
+ try {
+ $sql = Toolkit_Common::createSQLUpdate(
+ $this->tableName,
+ array_keys($values),
+ array('id = :id')
+ );
+
+ $values['id'] = $_GET['id'];
+ return Toolkit_Common::processQuery(
+ $this->dbh,
+ $this->tableName,
+ $sql,
+ $values
+ );
+ } catch (PDOException $e) {
+ return Toolkit_Common::handleError($e);
+ }
+ }
+
+ // }}}
+ // {{{ uploadImage()
+ // @codeCoverageIgnoreStart
+
+ /**
+ * Uploads an image to the image server
+ *
+ * @param string $key name of the file upload key to find the image in the
+ * $_FILES array
+ *
+ * @return mixed file name on success, false on error
+ * @access protected
+ */
+ protected function uploadImage($key)
+ {
+ $is = new Toolkit_Image_Server();
+ return $is->imageUpload($key);
+ }
+
+ // @codeCoverageIgnoreEnd
+ // }}}
+}
+?>
diff --git a/Toolkit/Toolbox/Admin/EditParagraph.php b/Toolkit/Toolbox/Admin/EditParagraph.php
new file mode 100644
index 0000000..bc13898
--- /dev/null
+++ b/Toolkit/Toolbox/Admin/EditParagraph.php
@@ -0,0 +1,692 @@
+
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version CVS: $Id: EditParagraph.php,v 1.2 2009/12/15 20:18:16 jamie Exp $
+ * @link http://demo.gaslightmedia.com
+ */
+
+/**
+ * Short description for class
+ *
+ * Long description (if any) ...
+ *
+ * @category CategoryName
+ * @package Toolkit_Toolbox
+ * @author Jamie Kahgee ';
+
+ $d['current_image'] = sprintf($i, THUMB . $d['image']);
+
+ } catch (PDOException $e) {
+ return Toolkit_Common::handleError($e);
+ }
+ } else {
+ $d = array(
+ 'template' => 1,
+ );
+ }
+ $this->setupDefaults($d);
+ }
+
+ // }}}
+ // {{{ configureElements()
+
+ /**
+ * Form element definitions
+ *
+ * @return void
+ * @access public
+ */
+ public function configureElements()
+ {
+ $e = array();
+ // Grouped Elements are defined here.
+ $submitBtns = array();
+
+ $submitBtns[] = array(
+ 'type' => 'submit',
+ 'req' => false,
+ 'name' => 'update_rmv',
+ 'display' => 'Update'
+ );
+ $submitBtns[] = array(
+ 'type' => 'submit',
+ 'req' => false,
+ 'name' => 'cancel_rmv',
+ 'display' => 'Cancel'
+ );
+ $submitBtns[] = array(
+ 'type' => 'submit',
+ 'req' => false,
+ 'name' => 'delete_rmv',
+ 'display' => 'Delete'
+ );
+
+ // All Elements are created here.
+ // This includes group element definitions.
+ $e[] = array(
+ 'type' => 'header',
+ 'req' => false,
+ 'name' => 'paragraphAttributesHdr',
+ 'display' => 'Paragraph Attributes'
+ );
+ $e[] = array(
+ 'type' => 'select',
+ 'req' => false,
+ 'name' => 'page',
+ 'display' => 'Page',
+ 'opts' => array(),
+ );
+ $e[] = array(
+ 'type' => 'text',
+ 'req' => false,
+ 'name' => 'intro',
+ 'display' => 'Paragraph Title'
+ );
+ $e[] = array(
+ 'type' => 'textarea',
+ 'req' => false,
+ 'name' => 'description',
+ 'display' => 'Description',
+ 'opts' => array(
+ 'cols' => 70,
+ 'rows' => 25
+ ),
+ );
+ if ($this->hasUploadedImage()) {
+ $e[] = array(
+ 'type' => 'static',
+ 'req' => false,
+ 'name' => 'current_image',
+ 'display' => 'Current Image'
+ );
+ $e[] = array(
+ 'type' => 'text',
+ 'req' => false,
+ 'name' => 'imagename',
+ 'display' => 'Image Caption'
+ );
+ $e[] = array(
+ 'type' => 'checkbox',
+ 'req' => false,
+ 'name' => 'remove_image',
+ 'display' => 'Delete Image'
+ );
+ }
+ $e[] = array(
+ 'type' => 'file',
+ 'req' => false,
+ 'name' => 'image',
+ 'display' => 'New Image'
+ );
+
+ // If we are editing a page, show three submit buttons
+ // otherwise, just show one insert button.
+ if (is_numeric($_GET['id'])) {
+ $e[] = array(
+ 'type' => 'group',
+ 'req' => false,
+ 'name' => 'submit_buttons',
+ 'group' => $submitBtns,
+ 'label' => '',
+ 'seperator' => '',
+ 'appendName' => false,
+ );
+ } else {
+ $e[] = array(
+ 'type' => 'submit',
+ 'req' => false,
+ 'name' => 'insert_rmv',
+ 'display' => 'Insert'
+ );
+ }
+
+ $this->setupElements($e);
+ // Do the same for the pages
+ $this->loadParagraphPages();
+ }
+
+ // }}}
+ // {{{ configureFilters()
+
+ /**
+ * Form filter definitions
+ *
+ * Applies a data filter for the given fields when the form is submitted
+ *
+ * @return void
+ * @access public
+ */
+ public function configureFilters()
+ {
+ $f = array();
+
+ $f[] = array(
+ 'element' => '__ALL__',
+ 'filter' => 'trim'
+ );
+
+ $this->setupFilters($f);
+ }
+
+ // }}}
+ // {{{ configureForm()
+
+ /**
+ * Bundle all form configuration calls into one function call
+ *
+ * @return void
+ * @access public
+ */
+ public function configureForm()
+ {
+ $this->configureElements();
+ $this->configureRules();
+ $this->configureFilters();
+ $this->configureDefaults();
+ }
+
+ // }}}
+ // {{{ configureRules()
+
+ /**
+ * Form rule definitions
+ *
+ * Adds validation rules for the given fields
+ *
+ * @return void
+ * @access public
+ */
+ public function configureRules()
+ {
+ $r = array();
+ // Form Rules
+
+ $this->setupRules($r);
+ }
+
+ // }}}
+ // {{{ getTableName()
+
+
+ /**
+ * Short description for function
+ *
+ * Long description (if any) ...
+ *
+ * @return string Return description (if any) ...
+ * @access public
+ */
+ public function getTableName()
+ {
+ return $this->tableName;
+ }
+
+ // }}}
+
+ // {{{ hasUploadedImage()
+
+ /**
+ * Check to see if page we are editing has an uploaded image
+ *
+ * @return boolean If page has a previously uploaded image
+ * @access protected
+ */
+ protected function hasUploadedImage()
+ {
+ if (!is_numeric($_GET['id'])) {
+ return false;
+ }
+ try {
+ $sql = "
+ SELECT *
+ FROM {$this->tableName}
+ WHERE id = :id";
+
+ $stmt = $this->dbh->prepare($sql);
+ $stmt->bindParam(':id', $_GET['id'], PDO::PARAM_INT);
+ $stmt->execute();
+ $stmt->bindColumn('image', $image);
+ $row = $stmt->fetch();
+ return !is_null($image);
+ //return !(is_null($image) || empty($image));
+ } catch (PDOException $e) {
+ return Toolkit_Common::handleError($e);
+ }
+ }
+
+ // }}}
+
+ // {{{ loadParagraphPages()
+
+ /**
+ * Load option elements into the parent select list
+ *
+ * These options are loaded via this seperate function vs inline w/ the
+ * element definition b/c we need a little more control defining
+ * the class names for each option so they will render nice when a user
+ * is looking at the list.
+ *
+ * @return void
+ * @throws PDOException throws exception on sql error
+ * @access public
+ */
+ public function loadParagraphPages()
+ {
+ try {
+ // Get a tree list of categories in linear order with
+ // category keys in the values and their level in the tree
+ // in the value
+ $c = Toolkit_Common::getHierarchicalTreeStructure(
+ $this->dbh,
+ 'bus_category',
+ 'id',
+ 'parent',
+ 'pos',
+ 1,
+ $this->maxDepth
+ );
+
+ // Get all the data about each category
+ $sql = "
+ SELECT *
+ FROM bus_category
+ WHERE id = ?";
+
+ $stmt = $this->dbh->prepare($sql);
+ // Get the member categories select list element
+ $e =& $this->getElement('page');
+ foreach ($c as $i => $j) {
+ $stmt->execute(array($i));
+ $row = $stmt->fetch();
+ // the class level is always 1 less than what is reported
+ // from our $c array
+ $x = $j - 1;
+ // Add the option data to the select list.
+ $e->addOption($row['category'], $i, array('class' => "level-$x"));
+ }
+ } catch (PDOException $e) {
+ return Toolkit_Common::handleError($e);
+ }
+ }
+
+ // }}}
+
+ // {{{ insertPage()
+
+ /**
+ * Create a new page in the site by inserting values into the DB
+ *
+ * @param array $values Submitted form values
+ *
+ * @return boolean Result of insertion
+ * @access protected
+ */
+ protected function insertPage($values)
+ {
+ // Get the member categories if they exists so we don't try and
+ // insert them into the wrong table.
+ $memberCats = $values['memberCat'];
+ unset($values['memberCat']);
+
+ // Get the value of the new position this page will be set to.
+ $values['pos'] = $this->getNewParentPosition($values['parent']);
+
+ // a non empty file size indicates to use an image has been uploaded.
+ if (!empty($values['image']['size'])) {
+ $values['image'] = $this->uploadImage('image');
+ if ($values['image'] === false) {
+ return PEAR::raiseError('Invalid image response');
+ }
+ } else {
+ unset($values['image']);
+ }
+
+ $sql = Toolkit_Common::createSQLInsert(
+ $this->tableName,
+ array_keys($values)
+ );
+
+ try {
+ $this->dbh->beginTransaction();
+ Toolkit_Common::processQuery(
+ $this->dbh,
+ $this->tableName,
+ $sql,
+ $values
+ );
+
+ // If we are trying to associate member categories
+ // with the toolbox page then insert them here.
+ if (is_array($memberCats) && !empty($memberCats)) {
+ // Need to get the last id inserted into the table.
+ $sql = "
+ SELECT id
+ FROM {$this->tableName}
+ ORDER BY id DESC
+ LIMIT 1";
+
+ $row = $this->dbh->query($sql)->fetch();
+ $sql = Toolkit_Common::createSQLInsert(
+ 'bus_cat_member',
+ array('catid', 'memb_type')
+ );
+
+ $stmt = $this->dbh->prepare($sql);
+ $stmt->bindParam(':catid', $row['id'], PDO::PARAM_INT);
+ // zip through all the member categories selected
+ // and insert them into the table.
+ foreach ($memberCats as $i) {
+ if (is_numeric($i)) {
+ $stmt->bindParam(':memb_type', $i, PDO::PARAM_INT);
+ $stmt->execute();
+ }
+ }
+ }
+
+ return $this->dbh->commit();
+ } catch (PDOException $e) {
+ $this->dbh->rollback();
+ return Toolkit_Common::handleError($e);
+ }
+ }
+
+ // }}}
+
+ // {{{ processData()
+
+ /**
+ * Clean unneeded form elements out of the submitted values array
+ *
+ * @param array $values QuickForm submitted elements
+ *
+ * @return boolean Result of insert/update functions
+ * @access public
+ */
+ public function processData($values)
+ {
+ foreach ($values as $k => $v) {
+ switch ($k) {
+ case 'MAX_FILE_SIZE' :
+ unset($values[$k]);
+ break;
+
+ default :
+ if (substr($k, -4) == '_rmv') {
+ unset($values[$k]);
+ }
+ break;
+ }
+ }
+
+ $function = is_numeric($_GET['id']) ? 'updatePage' : 'insertPage';
+ return $this->$function($values);
+ }
+
+ // }}}
+ // {{{ removeImage()
+ // @codeCoverageIgnoreStart
+
+ /**
+ * Deletes an image from the file server
+ *
+ * @param string $fileName Name of the image to delete
+ *
+ * @return void
+ * @access protected
+ */
+ protected function removeImage($fileName)
+ {
+ $is = new Toolkit_Image_Server();
+ $is->imageDelete($fileName);
+ }
+
+ // @codeCoverageIgnoreEnd
+ // }}}
+
+ // {{{ setMaxDepth()
+
+ /**
+ * Sets the max depth level that the parent page select list will show
+ *
+ * @param integer $md New max depth
+ *
+ * @return void
+ * @access public
+ */
+ public function setMaxDepth($md)
+ {
+ $this->maxDepth = $md;
+ }
+
+ // }}}
+ // {{{ setupRenderers()
+
+ /**
+ * Custom rendering templates for special fields on the form
+ *
+ * @return void
+ * @access protected
+ */
+ protected function setupRenderers()
+ {
+ parent::setupRenderers();
+ $renderer =& $this->defaultRenderer();
+ $required = ' * ';
+ $error = '
\n\t\t ", 'submit_buttons');
+ $renderer->setElementTemplate("\n\t$required{label}$error{element} \n\t\n\t\t ", 'insert_rmv');
+
+ $renderer->setGroupTemplate("\n\t$required{label}$error{element} \n\t\n\t\t\n\t\t\t
", 'page_layout');
+ $renderer->setGroupElementTemplate("\n\t{content} \n\t\t\n\t\n\t\t\n\t ", 'page_layout');
+ }
+
+ // }}}
+
+ // {{{ updatePage()
+
+ /**
+ * Update an existing page in the site by updating values in the DB
+ *
+ * @param array $values Submitted form values
+ *
+ * @return boolean Result of insertion
+ * @access protected
+ */
+ protected function updatePage($values)
+ {
+ // Make sure we are dealing w/ a valid page
+ if (!is_numeric($_GET['id'])) {
+ return PEAR::raiseError('Invalid page id');
+ }
+
+ // Handle user deleting the page image.
+ if (array_key_exists('remove_image', $values)) {
+ $this->removeImage($values['imagename']);
+
+ // unset value so its not included in the update sql query
+ unset($values['remove_image']);
+ // set image and imagename to null to overwrite value in db.
+ // if we are not uploading a new image.
+ if (empty($values['image']['size'])) {
+ $values['image'] = $values['imagename'] = null;
+ }
+ }
+
+ // a non empty file size indicates to use an image has been uploaded.
+ if (!empty($values['image']['size'])) {
+ $values['image'] = $is->imageUpload('image');
+ if ($values['image'] === false) {
+ return PEAR::raiseError('Invalid image response');
+ }
+ } elseif (!is_null($values['image'])) {
+ unset($values['image']);
+ }
+
+ // Get the parent id this page is currently set to in the DB.
+ $curPar = $this->getCurrentParent($_GET['id']);
+ // parents will be different if we are reassining to a new parent
+ if ($curPar != $values['parent']) {
+ // Get an updated position for the new parent page.
+ $values['pos'] = $this->getNewParentPosition($values['parent']);
+ }
+
+ try {
+ $sql = Toolkit_Common::createSQLUpdate(
+ $this->tableName,
+ array_keys($values),
+ array('id = :id')
+ );
+
+ $values['id'] = $_GET['id'];
+ return Toolkit_Common::processQuery(
+ $this->dbh,
+ $this->tableName,
+ $sql,
+ $values
+ );
+ } catch (PDOException $e) {
+ return Toolkit_Common::handleError($e);
+ }
+ }
+
+ // }}}
+ // {{{ uploadImage()
+ // @codeCoverageIgnoreStart
+
+ /**
+ * Uploads an image to the image server
+ *
+ * @param string $key name of the file upload key to find the image in the
+ * $_FILES array
+ *
+ * @return mixed file name on success, false on error
+ * @access protected
+ */
+ protected function uploadImage($key)
+ {
+ $is = new Toolkit_Image_Server();
+ return $is->imageUpload($key);
+ }
+
+ // @codeCoverageIgnoreEnd
+ // }}}
+}
+?>
diff --git a/Toolkit/Toolbox/Admin/toolbox.sql b/Toolkit/Toolbox/Admin/toolbox.sql
new file mode 100644
index 0000000..5fc4cdb
--- /dev/null
+++ b/Toolkit/Toolbox/Admin/toolbox.sql
@@ -0,0 +1,33 @@
+CREATE TABLE bus_category (
+id SERIAL PRIMARY KEY,
+parent INTEGER,
+category TEXT,
+intro TEXT,
+description TEXT,
+image TEXT,
+imagename TEXT,
+active BOOLEAN DEFAULT FALSE,
+pos INTEGER,
+keyword TEXT,
+template INTEGER,
+featured BOOLEAN DEFAULT FALSE,
+no_search_form BOOLEAN DEFAULT FALSE,
+feature_intro TEXT,
+section_links BOOLEAN DEFAULT FALSE
+);
+
+CREATE TABLE bus (
+id SERIAL PRIMARY KEY,
+name TEXT,
+description TEXT,
+image TEXT,
+imagename TEXT,
+back_to_top BOOLEAN DEFAULT FALSE
+);
+
+CREATE TABLE bus_category_bus (
+id SERIAL PRIMARY KEY,
+busid INTEGER,
+catid INTEGER,
+pos INTEGER
+);
diff --git a/Toolkit/Toolbox/Rss.php b/Toolkit/Toolbox/Rss.php
new file mode 100644
index 0000000..3ff8979
--- /dev/null
+++ b/Toolkit/Toolbox/Rss.php
@@ -0,0 +1,123 @@
+
+ * @copyright 2009 Gaslight Media
+ * @license Gaslight Media
+ * @version CVS: $Id: Rss.php,v 1.1 2009/09/23 15:53:30 matrix Exp $
+ * @link <>
+ */
+
+/**
+ * Create Rss Feed from Toolbox data
+ *
+ * @category Toolkit
+ * @package Toolbox
+ * @author Steve Sutton '.print_r($e, true).'
';
+ die($e->getMessage);
+ }
+ }
+ // }}}
+}
+?>
diff --git a/Toolkit/Tree.php b/Toolkit/Tree.php
new file mode 100644
index 0000000..2fda674
--- /dev/null
+++ b/Toolkit/Tree.php
@@ -0,0 +1,145 @@
+
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release CVS: $Id: Tree.php,v 1.1.1.1 2009/09/17 20:08:55 matrix Exp $
+ * @link http://demo.gaslightmedia.com
+ */
+
+/**
+ * Create tree structures of database entries
+ *
+ * Base class used to setup tree objects that will render
+ * database structures into iterable PHP objects.
+ *
+ * @category Toolkit
+ * @package Toolkit_Tree
+ * @author Jamie Kahgee