From dbed2ca5b00225a2b2748367c5ec47803a0bb8d2 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Mon, 28 Jul 2014 11:37:59 -0400 Subject: [PATCH] Clean up Events Updated to common apps files only. removed the other template and class files --- Toolkit/Events/AddEventForm.php | 1037 ----------- Toolkit/Events/Auxiliary.php | 79 - Toolkit/Events/Calendar.php | 750 -------- Toolkit/Events/CategoryBlocks.php | 37 - Toolkit/Events/Display.php | 116 -- Toolkit/Events/EventCalendar.php | 798 --------- Toolkit/Events/EventHomePage.php | 168 -- Toolkit/Events/Forms/Admin/EditEvent.php | 1571 ----------------- Toolkit/Events/Forms/Admin/EditTopics.php | 164 -- Toolkit/Events/HomeEvents.php | 115 -- Toolkit/Events/ListEvents.php | 287 --- Toolkit/Events/QueryBuilder.php | 220 --- Toolkit/Events/UserSearchForm.php | 113 -- Toolkit/Events/config.ini | 7 - Toolkit/Events/getEvents.php | 34 - Toolkit/Events/showCalendar.php | 10 - .../templates/currentTables/Element.tpl | 14 - .../Events/templates/currentTables/Form.tpl | 7 - .../Events/templates/currentTables/Group.tpl | 5 - .../templates/currentTables/GroupElement.tpl | 9 - .../Events/templates/currentTables/Header.tpl | 5 - .../templates/currentTables/RequiredNote.tpl | 1 - Toolkit/Events/templates/editTopics.html | 77 - Toolkit/Events/templates/emailOwner.tpl | 29 - Toolkit/Events/templates/eventDetail.html | 58 - Toolkit/Events/templates/eventFeed.html | 22 - Toolkit/Events/templates/eventHomePage.html | 90 - Toolkit/Events/templates/eventPage.html | 27 - Toolkit/Events/templates/eventSearchForm.html | 14 - Toolkit/Events/templates/events.html | 26 - 30 files changed, 5890 deletions(-) delete mode 100755 Toolkit/Events/AddEventForm.php delete mode 100644 Toolkit/Events/Auxiliary.php delete mode 100755 Toolkit/Events/Calendar.php delete mode 100644 Toolkit/Events/CategoryBlocks.php delete mode 100755 Toolkit/Events/Display.php delete mode 100755 Toolkit/Events/EventCalendar.php delete mode 100644 Toolkit/Events/EventHomePage.php delete mode 100755 Toolkit/Events/Forms/Admin/EditEvent.php delete mode 100644 Toolkit/Events/Forms/Admin/EditTopics.php delete mode 100644 Toolkit/Events/HomeEvents.php delete mode 100644 Toolkit/Events/ListEvents.php delete mode 100644 Toolkit/Events/QueryBuilder.php delete mode 100644 Toolkit/Events/UserSearchForm.php delete mode 100644 Toolkit/Events/config.ini delete mode 100644 Toolkit/Events/getEvents.php delete mode 100644 Toolkit/Events/showCalendar.php delete mode 100755 Toolkit/Events/templates/currentTables/Element.tpl delete mode 100755 Toolkit/Events/templates/currentTables/Form.tpl delete mode 100755 Toolkit/Events/templates/currentTables/Group.tpl delete mode 100755 Toolkit/Events/templates/currentTables/GroupElement.tpl delete mode 100755 Toolkit/Events/templates/currentTables/Header.tpl delete mode 100755 Toolkit/Events/templates/currentTables/RequiredNote.tpl delete mode 100644 Toolkit/Events/templates/editTopics.html delete mode 100755 Toolkit/Events/templates/emailOwner.tpl delete mode 100755 Toolkit/Events/templates/eventDetail.html delete mode 100644 Toolkit/Events/templates/eventFeed.html delete mode 100755 Toolkit/Events/templates/eventHomePage.html delete mode 100644 Toolkit/Events/templates/eventPage.html delete mode 100755 Toolkit/Events/templates/eventSearchForm.html delete mode 100755 Toolkit/Events/templates/events.html diff --git a/Toolkit/Events/AddEventForm.php b/Toolkit/Events/AddEventForm.php deleted file mode 100755 index a034874..0000000 --- a/Toolkit/Events/AddEventForm.php +++ /dev/null @@ -1,1037 +0,0 @@ - - * @license http://www.gaslightmedia.com Gaslightmedia - * @version CVS: $Id: AddEventForm.php,v 1.20 2010/07/04 23:58:22 jamie Exp $ - * @link http://demo.gaslightmedia.com - */ - -/** - * New Event Form - * - * @category Toolkit - * @package Events - * @author Steve Sutton - * @copyright 2012 Gaslight Media - * @license http://www.gaslightmedia.com Gaslightmedia - * @link http://demo.gaslightmedia.com - */ -class Toolkit_Events_AddEventForm - extends Toolkit_FormBuilder - implements Toolkit_Form -{ - // {{{ properties - - /** - * Table in Database which holds the contact data - * - * @var string - * @access public - */ - public $tableName = 'event'; - - /** - * Table meta data - * - * This is used when inserting/updating data for the records - * so the PDO's can use explicit data types for the parameters. - * - * @var array - * @access public - */ - public $tableMetaData; - - /** - * Who to send the email to when the contact form is submitted - * - * If you leave this blank, its value will get set to the OWNER_EMAIL - * in the constructor. - * - * If you ***DO NOT*** want any emails to go out when the form is submitted - * then set the value to false. Do not set it to 0 for false, because the - * check uses a strict type check to determine if the value is actually - * false. This is what allows for the empty value as an option, which sets - * the value to OWNER_EMAIL and won't override the $email property if - * this class gets subclassed and the value for this property gets set in - * the properties of the subclass and not in the constructor after this - * constructor function is called. - * - * tongue twister...I know. - * - * 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 - * - * It gets set to the constant SITENAME in the constructor if you leave - * empty here, but you can set it to something different here to override - * that if you desire. - * - * @var unknown - * @access protected - */ - protected $siteName; - - /** - * Email subject and

header in email - * - * It gets set in the constructor if you leave empty here, but you - * can set it to something different here to override that if you desire. - * - * @var string - * @access protected - */ - protected $subject = 'New Event Submission'; - - /** - * Message to display if the form is successfully submitted - * - * @var string - * @access protected - */ - protected $successMsg = ' - -
- Your event has been successfully added to the events calendar, - however will not be visible until it has been approved by - the Web site administrator. Thank You. -
'; - - /** - * Extra rules for processesing - * - * This registers the Zip validation rules (and any others listed) for - * QuickForm. - * - * Zip validation checks both US and Canadian Zip codes - * - * @var array - * @access protected - */ - protected $registeredRules = array( - 'phone', - array( - 'checkEmail', - 'callback', - 'email', - 'Validate' - ), - array( - 'checkURI', - 'callback', - 'uri', - 'Validate' - ) - ); - - /** - * Options for flexy templating engine - * - * Pulls the preset options from the setup.phtml file - * overwrites the templateDir and compileDir to match this classes needs - * - * @var array - * @access protected - */ - protected $flexyOptions; - - // }}} - // {{{ __construct() - - /** - * Class constructor - * - * @param PDO $pdo PHP Data Object - * @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
tag - * @param bool $trackSubmit (optional)Whether to track if the form was - * submitted by adding a special hidden field - * - * @access public - */ - public function __construct( - PDO $pdo, - $formName, - $method = 'post', - $action = '', - $target = '', - $attributes = null, - $trackSubmit = false - ) { - parent::__construct( - $formName, $method, $action, $target, $attributes, $trackSubmit - ); - - $this->dbh = $pdo; - - if ($this->email !== false && empty($this->email)) { - // Set to false to turn off email function. - $this->email = ADD_EVENT_EMAIL; - } - if (empty($this->siteName)) { - $this->siteName = SITENAME; - } - if (empty($this->subject)) { - $this->subject = 'Contact Request from website ' . SITENAME; - } - - $this->flexyOptions = $GLOBALS['flexyOptions']; - $this->flexyOptions['templateDir'] = dirname(__FILE__) . "/templates/"; - $this->flexyOptions['compileDir'] = dirname(__FILE__) . "/templates/compiled/"; - - $var = basename(__FILE__, '.php'); - - $callbackUrl = ($_SERVER['HTTPS'] == 'on') - ? - BASE_SECURE_URL - : MEDIA_BASE_URL; - - $this->captchaOptions = array( - 'width' => 100, - 'height' => 50, - 'callback' => "{$callbackUrl}Toolkit/qfcaptcha.php?var=$var", - 'sessionVar' => $var, - 'imageOptions' => array( - 'font_size' => 16, - 'font_path' => GLM_APP_BASE . 'glmPEAR/Image/Canvas/Fonts/', - 'font_file' => 'times.ttf', - 'background_color' => '#cccccc', - 'obfuscation' => false, - 'angle' => true, - ), - ); - } - - // }}} - // {{{ checkDate() - - /** - * Validate date input - * - * allows for empty dates to be valid - * - * @param array $date date group from form - * - * @return boolean true if valid, false if not - * @access public - */ - public function checkDate($date) - { - if (!$date) { - return true; - } else { - return Validate::date($date, array('format' => '%m/%d/%Y')); - } - } - - // }}} - // {{{ checkDateRange() - - /** - * Validate date input - * - * allows for empty end date to be valid - * - * @param array $d date group from form - * - * @return boolean true if valid, false if not - * @access public - */ - public function checkDateRange(array $d) - { - if (!$this->hasEndDate($d[1])) { - // no end date is a valid date range - return true; - } - $pattern = '/([0-9]{2})\/([0-9]{2})\/([0-9]{4})/'; - if (preg_match($pattern, $d[0], $m)) { - $t1 = mktime(0, 0, 0, (int) $m[1], (int) $m[2], (int) $m[3]); - $bdate = new Date($t1); - } - if (preg_match($pattern, $d[1], $m)) { - $t2 = mktime(0, 0, 0, (int) $m[1], (int) $m[2], (int) $m[3]); - $edate = new Date($t2); - } - if ($bdate && $edate) { - // 0 if the dates are equal - valid - // -1 if $bdate is before $edate - valid - // 1 if $bdate is after $edate - invalid - $res = Date::compare($bdate, $edate); - return ($res !== 1); - } - return true; - } - - // }}} - // {{{ configureElements() - - /** - * Form element definitions - * - * @return void - * @access public - */ - public function configureElements() - { - $e = array(); - - // All Elements are created here. This includes group element definitions. - $e[] = array( - 'type' => 'header', - 'name' => 'eventInfoHdr', - 'display' => 'Event Information' - ); - $e[] = array( - 'type' => 'text', - 'req' => true, - 'name' => 'header', - 'display' => 'Event Name' - ); - $e[] = array( - 'type' => 'text', - 'req' => true, - 'name' => 'bdate', - 'display' => 'Start Date', - 'opts' => array('id' => 'sdate') - ); - $e[] = array( - 'type' => 'text', - 'req' => true, - 'name' => 'edate', - 'display' => 'End Date', - 'opts' => array('id' => 'edate') - ); - $e[] = array( - 'type' => 'date', - 'req' => false, - 'name' => 'btime', - 'display' => 'Start Time', - 'opts' => array( - 'format' => 'h : i A', - 'addEmptyOption' => true, - 'emptyOptionValue' => '', - 'emptyOptionText' => array( - 'h' => 'hh', - 'i' => 'mm', - 'A' => 'am/pm' - ), - 'optionIncrement' => array( - 'i' => 15, - ), - ), - 'error' => 'ERROR: You must select a start time!', - ); - $e[] = array( - 'type' => 'date', - 'req' => false, - 'name' => 'etime', - 'display' => 'End Time', - 'opts' => array( - 'format' => 'h : i A', - 'addEmptyOption' => true, - 'emptyOptionValue' => '', - 'emptyOptionText' => array( - 'h' => 'hh', - 'i' => 'mm', - 'A' => 'am/pm' - ), - 'optionIncrement' => array( - 'i' => 15, - ), - ), - ); - $e[] = array( - 'type' => 'select', - 'req' => true, - 'name' => 'topicid', - 'display' => 'Category', - 'opts' => $this->getTopicFields(), - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'url', - 'display' => 'Event Website' - ); - - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'cost', - 'display' => 'Cost', - ); - $e[] = array( - 'type' => 'textarea', - 'req' => false, - 'name' => 'descr', - 'display' => 'Event Description', - 'opts' => array('id' => 'description') - ); - $e[] = array( - 'type' => 'header', - 'name' => 'eventLocationInfoHeader_rmv', - 'display' => 'Event Location Information -
-
-
- Map It' - ); - $e[] = array( - 'type' => 'hidden', - 'req' => false, - 'name' => 'lat', - 'opts' => array('id' => 'lat') - ); - $e[] = array( - 'type' => 'hidden', - 'req' => false, - 'name' => 'lon', - 'opts' => array('id' => 'lon') - ); - $e[] = array( - 'type' => 'text', - 'req' => true, - 'name' => 'loc', - 'display' => 'Place' - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'address', - 'display' => 'Address' - ); - $e[] = array( - 'type' => 'text', - 'req' => true, - 'name' => 'city', - 'display' => 'City' - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'state', - 'display' => 'State' - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'zip', - 'display' => 'ZIP' - ); - $e[] = array( - 'type' => 'header', - 'name' => 'eventContactHeader_rmv', - 'display' => 'Event Contact Information' - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'contact', - 'display' => 'Event Contact Person
(published on Web site)' - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'email', - 'display' => 'Contact Email
(published on Web site)' - ); - $e[] = array( - 'type' => 'text', - 'req' => true, - 'name' => 'phone', - 'display' => 'Contact Phone
(published on Web site)' - ); - - $e[] = array( - 'type' => 'header', - 'name' => 'adminInfoHdr', - 'display' => 'Event Admin Information' - ); - $e[] = array( - 'type' => 'text', - 'req' => true, - 'name' => 'admin_contact_name', - 'display' => 'Contact Name Submitting Event' - ); - $e[] = array( - 'type' => 'text', - 'req' => true, - 'name' => 'admin_org_name', - 'display' => 'Organization Name Submitting Event' - ); - $e[] = array( - 'type' => 'text', - 'req' => true, - 'name' => 'admin_phone', - 'display' => 'Phone' - ); - $e[] = array( - 'type' => 'text', - 'req' => true, - 'name' => 'admin_email', - 'display' => 'Email Address' - ); - - if ($this->useCaptcha) { - $e[] = array( - 'type' => 'CAPTCHA_Image', - 'req' => false, - 'name' => 'captcha_question', - 'display' => 'Verification code', - 'opts' => $this->captchaOptions - ); - $e[] = array( - 'type' => 'text', - 'req' => true, - 'name' => 'captcha_rmv', - 'display' => 'Enter verification code', - ); - } - $e[] = array( - 'type' => 'submit', - 'req' => false, - 'name' => 'submit_rmv', - 'display' => 'Submit' - ); - - $this->setupElements($e); - } - - // }}} - // {{{ 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' - ); - $f[] = array( - 'element' => 'url', - 'filter' => array('Toolkit_Common', 'filterURI') - ); - - $this->setupFilters($f); - } - - // }}} - // {{{ configureForm() - - /** - * Helper function to handle setting up the form - * - * @return void - * @access public - */ - public function configureForm() - { - $this->configureElements(); - $this->configureFilters(); - $this->configureRules(); - } - - // }}} - // {{{ configureRules() - - /** - * Form rule definitions - * - * Adds validation rules for the given fields - * - * @return void - * @access public - */ - public function configureRules() - { - // Form Rules - $r[] = array( - 'element' => 'topicid', - 'message' => 'ERROR: Invalid Category!', - 'type' => 'numeric', - 'format' => null, - 'validation' => $this->validationType, - 'reset' => true, - 'force' => false - ); - $r[] = array( - 'element' => 'email', - 'message' => 'ERROR: Invalid Email Format!', - 'type' => 'checkEmail', - 'format' => array('use_rfc822' => true), - 'validation' => $this->validationType, - 'reset' => true, - 'force' => false - ); - $r[] = array( - 'element' => array('bdate', 'edate'), - 'message' => 'ERROR: Starting Date must be before Ending Date', - 'type' => 'callback', - 'format' => array(&$this, 'checkDateRange'), - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $r[] = array( - 'element' => 'bdate', - 'message' => 'ERROR: Invalid date!', - 'type' => 'callback', - 'format' => array(&$this, 'checkDate'), - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $r[] = array( - 'element' => 'edate', - 'message' => 'ERROR: Invalid date!', - 'type' => 'callback', - 'format' => array(&$this, 'checkDate'), - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $r[] = array( - 'element' => 'url', - 'message' => 'ERROR: Invalid URL format', - 'type' => 'checkURI', - 'format' => array( - 'allowed_schemes' => array('http', 'https'), - 'strict' => true - ), - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $r[] = array( - 'element' => 'phone', - 'message' => 'ERROR: Invalid Phone Format (xxx) xxx - xxxx!', - 'type' => 'phone', - 'format' => null, - 'validation' => $this->validationType, - 'reset' => true, - 'force' => false - ); - if ($this->useCaptcha) { - $r[] = array( - 'element' => 'captcha_rmv', - 'message' => 'ERROR: What you entered didn\'t match!', - 'type' => 'CAPTCHA', - 'format' => $this->captchaQuestion, - 'validation' => $this->validationType, - 'reset' => true, - 'force' => false - ); - } - - $this->setupRules($r); - } - - // }}} - // {{{ getTopicFields() - - /** - * get event topics - * - * @return array topics - * @access protected - */ - protected function getTopicFields() - { - try { - $sql = " - SELECT * - FROM topic - ORDER BY descr"; - - $topics = array('' => '-- Select --'); - foreach ($this->dbh->query($sql) as $row) { - $topics[$row['id']] = $row['descr']; - } - - return $topics; - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } - - // }}} - // {{{ hasEndDate() - - /** - * verifies if we have a valid end date to work with - * - * @param array $d end date - * - * @return boolean if the end date is - */ - protected function hasEndDate($d) - { - $pattern = '/([0-9]{2})\/([0-9]{2})\/([0-9]{4})/'; - if (preg_match($pattern, $d, $m)) { - return checkdate((int) $m[1], (int) $m[2], (int) $m[3]); - } else { - return false; - } - } - - // }}} - // {{{ emailOwner() - - /** - * Emails the owner the submitted data from the submitted form - * - * Uses a flexy template to render a nice looking html email. - * Fills in the supplied data from the form and doesn't add the - * empty fields the user didn't fill in. - * - * @return boolean result of the mailing - * @access protected - */ - protected function emailOwner() - { - if (!$this->email) { - return; - } - - $template = new HTML_Template_Flexy($this->flexyOptions); - $page = new stdClass(); - // for comments textarea need to replace newlines with br - $this->formData['comments']['element'] = nl2br($this->getSubmitValue('comments')); - unset($this->formData['lat'], $this->formData['lon']); - - // these values are required, therefor will always be part of - // the formData array - $bdate = explode('/', $this->formData['bdate']['element']); - $foo = array_map('trim', $bdate); - $this->formatValue($foo, '%02d/%02d/%d'); - $this->formData['bdate']['element'] = $foo; - - $btime = explode('/', $this->formData['btime']['element']); - $foo = array_map('trim', $btime); - $this->formatValue($foo, '%02d:%02d %s'); - $this->formData['btime']['element'] = $foo; - - // not required, so check to make sure it exists before trying - // to format the value - if (isset($this->formData['edate'])) { - $edate = explode('/', $this->formData['edate']['element']); - $foo = array_map('trim', $edate); - $this->formatValue($foo, '%02d/%02d/%d'); - $this->formData['edate']['element'] = $foo; - } - if (isset($this->formData['etime'])) { - $etime = explode('/', $this->formData['etime']['element']); - $foo = array_map('trim', $etime); - $this->formatValue($foo, '%02d:%02d %s'); - $this->formData['etime']['element'] = $foo; - } - - try { - $sql = " - SELECT descr - FROM topic - WHERE id = :id"; - - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam( - ':id', $this->formData['topicid']['element'], PDO::PARAM_INT - ); - $stmt->execute(); - $stmt->bindColumn('descr', $this->formData['topicid']['element']); - $stmt->fetch(); - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - - $page->email_from = FROM_NEWS_EMAIL; - $page->subject = $this->subject; - $page->formData = $this->formData; - $page->eventAdminURL = MEDIA_BASE_URL . 'admin/Events/list_events.phtml?pending=t'; - - $template->compile('emailOwner.tpl'); - $htmlMsg = $template->bufferedOutputObject($page); - - // Text version can't have HTML in it - $msg = "{$page->subject}\n\n"; - $msg .= "From {$page->fname} {$page->lname}\n\n"; - $msg .= "Information\n\n"; - foreach ($page->formData as $i) { - $msg .= "{$i['label']}: {$i['element']}\n"; - } - - $crlf = "\n"; - $mimeMail = new Mail_mime($crlf); - $mimeMail->setFrom("{$this->siteName} <{$page->email_from}>"); - $mimeMail->setSubject($this->subject); - $mimeMail->setHTMLBody($htmlMsg); - $mimeMail->setTXTBody($msg); - - $mail = Mail::factory('mail'); - $body = $mimeMail->get(); - $headers = $mimeMail->headers(); - - $res = $mail->send($this->email, $headers, $body); - if (PEAR::isError($res)) { - return Toolkit_Common::handleError($res); - } else { - return $res; - } - } - - // }}} - // {{{ formatValue() - - /** - * Format an array into an acceptable string - * - * @param mixed &$i array values to format or null value for - * element that was not filled in - * @param string $format string to format values into - * - * @return string formatted string - * @access public - */ - public function formatValue(&$i, $format) - { - // Allow for 0 to be not empty. This allows for minutes in the - // time arrays to be valid if they are on the hour ie. (1:00 pm) - $notEmpty = create_function('$v', 'return strlen($v) > 0;'); - if (is_array($i) && count(array_filter($i, $notEmpty)) == 3) { - list($x, $y, $z) = array_values($i); - eval("\$i = sprintf('$format', $x, $y, $z);"); - } else { - $i = null; - } - } - - // }}} - // {{{ insertData() - - /** - * Inserts contact data into the contact db - * - * @param array $values submitted values - * - * @return object result of db insert query - * @access protected - */ - protected function insertData($values) - { - $values = $this->_geocode($values); - - try { - // need to set the dates up first - $this->formatValue($values['btime'], '%02d:%02d %s'); - $this->formatValue($values['etime'], '%02d:%02d %s'); - $values['descr'] = nl2br($values['descr']); - $values['url'] = preg_replace("/^(http:\/\/)/", "", $values['url']); - - $sql = Toolkit_Common::createSQLInsert( - $this->tableName, array_keys($values) - ); - - return Toolkit_Common::processQuery( - $this->dbh, $this->tableName, $sql, $values - ); - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } - - // }}} - private function _geocode(array $values) - { - $geocoder = new GeocodeYahoo(); - if (!$values['address'] && !$values['city'] && !$values['state']) { - return $values; - } - $address = array( - 'city' => $values['city'], - 'state' => $values['state'], - 'zip' => $values['zip'], - ); - if (!empty($values['address'])) { - $address['street'] = $values['address']; - } - try { - $response = $geocoder->geocodeAddress($address); - $responseArray = unserialize($response); - if ($responseArray['ResultSet']['Result'][0]['Latitude']) { - $values['lat'] = $responseArray['ResultSet']['Result'][0]['Latitude']; - $values['lon'] = $responseArray['ResultSet']['Result'][0]['Longitude']; - } else { - $values['lat'] = $responseArray['ResultSet']['Result']['Latitude']; - $values['lon'] = $responseArray['ResultSet']['Result']['Longitude']; - } - - return $values; - } catch (BadMethodCallException $e) { - Toolkit_Logger::logException('Invalid Arg', $e); - } catch (Exception $e) { - Toolkit_Logger::logException('Yahoo GeoCode', $e); - } - - } - // {{{ processData() - - /** - * Handles how to process the form when submitted - * - * @param array $values Form submitted values - * - * @return array Result of Insert / Update function - * @access protected - */ - public function processData($values) - { - // Form data used for the insert/update sql queries and - // the form email. - $e = array(); - $this->setFormData($e); - - // Get rid of any defined un-needed elements. - // un-needed elements after the form is submitted are defined - // by the ending _rmv name. - foreach ($values as $k => &$v) { - if (!is_array($v)) { - $values[$k] = preg_replace("/\r/", "\n", $v); - } - if (preg_match('/^.+_rmv$/', $k)) { - unset($values[$k]); - } - } - $values['create_date'] = date('m/d/Y'); - - return $this->insertData($values); - } - - // }}} - // {{{ setupRenderers() - - /** - * Custom rendering templates for special fields on the form - * - * @return void - * @access protected - */ - protected function setupRenderers() - { - parent::setupRenderers(); - $renderer = $this->defaultRenderer(); - $required = '*'; - $error = '
{error}
'; - - $renderer->setElementTemplate('' . $required . '{label}' . $error . '{element}', 'descr'); - $renderer->setElementTemplate('' . $required . '{label}' . $error . '{element}', 'submit_rmv'); - - if ($this->useCaptcha) { - $renderer->setElementTemplate('{element}', 'captcha_question'); - $renderer->setElementTemplate('' . $required . '' . $error . '{element}What is this?', 'captcha_rmv'); - } - } - - // }}} - // {{{ toHtml() - - /** - * Handles how to display the current step the user is at in the form - * - * destroying and resetting the captcha value dis-allows someone from - * re-sending a form on a previous captcha. - * - * @return string form HTML state - * @access public - */ - public function toHtml() - { - $this->setupRenderers(); - if ($this->validate()) { - $this->captchaQuestion->destroy(); - $this->cleanForm(); - - if ($this->process(array(&$this, 'processData'), $this->mergeFiles)) { - $this->freeze(); - $this->emailOwner(); - $output = $this->successMsg; - } - $this->sent = true; - } elseif ($this->isSubmitted()) { - if ($this->useCaptcha) { - $this->captchaQuestion->destroy(); - $this->captchaAnswer->setValue(''); - } - $output = $this->errorMsg; - $GLOBALS['topScripts'][] - = MEDIA_APP_BASE_URL - . 'libjs/jqueryui/1.8.13/js/jquery-ui-1.8.13.custom.min.js'; - $GLOBALS['styleSheets'][] - = MEDIA_APP_BASE_URL - . 'libjs/jqueryui/1.8.13/development-bundle/themes/base/jquery.ui.all.css'; - $GLOBALS['bottomScripts'][] = MEDIA_APP_BASE_URL . 'libjs/textlimit.js'; - $GLOBALS['topScripts'][] - = 'http://maps.googleapis.com/maps/api/js?sensor=true'; - $GLOBALS['bottomScripts'][] - = MEDIA_BASE_URL . 'Toolkit/Maps/geoCoder.js'; - $GLOBALS['bottomScripts'][] - = MEDIA_BASE_URL . 'Toolkit/Events/libjs/addEvent.js'; - $output .= parent::toHtml(); - } else { - if ($this->useCaptcha) { - $this->captchaQuestion->destroy(); - $this->captchaAnswer->setValue(''); - } - $GLOBALS['topScripts'][] - = MEDIA_APP_BASE_URL - . 'libjs/jqueryui/1.8.13/js/jquery-ui-1.8.13.custom.min.js'; - $GLOBALS['styleSheets'][] - = MEDIA_APP_BASE_URL - . 'libjs/jqueryui/1.8.13/development-bundle/themes/base/jquery.ui.all.css'; - $GLOBALS['bottomScripts'][] = MEDIA_APP_BASE_URL . 'libjs/textlimit.js'; - $GLOBALS['topScripts'][] - = 'http://maps.googleapis.com/maps/api/js?sensor=true'; - $GLOBALS['bottomScripts'][] - = MEDIA_BASE_URL . 'Toolkit/Maps/geoCoder.js'; - $GLOBALS['bottomScripts'][] - = MEDIA_BASE_URL . 'Toolkit/Events/libjs/addEvent.js'; - $output = parent::toHtml(); - } - return $output; - } - - // }}} -} - -?> diff --git a/Toolkit/Events/Auxiliary.php b/Toolkit/Events/Auxiliary.php deleted file mode 100644 index 7f2ddce..0000000 --- a/Toolkit/Events/Auxiliary.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright 2012 Gaslight Media - * @license Gaslight Media - * @version SVN: (0.1) - * @link <> - */ - -/** - * Toolkit_Events_Auxiliary - * - * Setup the event class so it can use the flexy setting for Events - * Sets up the flexyOptions for this class to use the templates directory - * in Toolkit_Events - * - * @category Toolkit - * @package Events - * @author Steve Sutton - * @copyright 2012 Gaslight Media - * @license Gaslight Media - * @release Release: (0.1) - * @link <> - */ -class Toolkit_Events_Auxiliary -{ - /** - * Database Connection - * @var PDO - * @access protected - */ - protected $dbh; - - /** - * Options for Flexy Templates - * @var array - * @access protected - */ - protected $flexyOptions; - - /** - * __construct() - * - * @param PDO $pdo Database Connection - * - * @return void - * @access public - */ - public function __construct(PDO $pdo) - { - // assign the global dbh to $this->dbh; - $this->dbh = $pdo; - $this->_setFlexyOptions(); - } - - /** - * setOptions - * - * @access public - * @return string - */ - private function _setFlexyOptions() - { - $this->flexyOptions = $GLOBALS['flexyOptions']; - // set paths for templates - $this->flexyOptions['templateDir'] = dirname(__FILE__) - . '/templates'; - $this->flexyOptions['compileDir'] = dirname(__FILE__) - . '/templates/compiled'; - } -} - diff --git a/Toolkit/Events/Calendar.php b/Toolkit/Events/Calendar.php deleted file mode 100755 index 2dfdf47..0000000 --- a/Toolkit/Events/Calendar.php +++ /dev/null @@ -1,750 +0,0 @@ - - * @license Gaslight Media - * @version Release: SVN: - * @link <> - */ - -/** - * Toolkit_Events_Calendar - * - * Display the events in a list view - * - * @category Toolkit - * @package Events - * @author Steve Sutton - * @copyright 2009 Gaslight Media - * @license Gaslight Media - * @version Release: @package_version@ - * @link <> - */ -class Toolkit_Events_Calendar -{ - - // {{{ Class Properties - /** - * Description of $_rightLink - * @var mixed - * @access private - */ - private $_rightLink; - - /** - * Description of $_leftLink - * @var mixed - * @access private - */ - private $_leftLink; - - /** - * Description of $_eventsData - * @var mixed - * @access private - */ - private $_eventsData; - - /** - * Description of $_colorArray - * @var array - * @access private - */ - private $_colorArray; - - // }}} - // {{{ __construct() - /** - * Class constructor - * - * @param PDO $pdo PDO - * - * @access protected - * @return string - */ - function __construct(PDO $pdo) - { - $this->dbh = $pdo; - $this->_leftLink = ''; - $this->_rightLink = ''; - /** - * $this->colorArray is used for the colors for this application. - * If these need to be changed then it might be better - * putting this in setup.phtml. - */ - $this->_colorArray = array( - '#FFCCCC' => 'color1', - '#CC9999' => 'color2', - '#FF9999' => 'color3', - '#FFCCFF' => 'color4', - '#CC99CC' => 'color5', - '#FF99FF' => 'color6', - '#CCCCFF' => 'color7', - '#9999CC' => 'color8', - '#9999FF' => 'color9', - '#CCFFFF' => 'color10', - '#99CCCC' => 'color11', - '#99FFFF' => 'color12', - '#CCFFCC' => 'color13', - '#99CC99' => 'color14', - '#99FF99' => 'color15', - '#FFFFCC' => 'color16', - '#CCCC99' => 'color17', - '#FFFF99' => 'color18', - '#FFCC99' => 'color19', - '#FF99CC' => 'color20', - '#CC99FF' => 'color21', - '#99CCFF' => 'color22', - '#99FFCC' => 'color23', - '#CCFF99' => 'color24', - '#CCCCCC' => 'color25' - ); - } - - // }}} - // {{{ calendar() - /** - * calendar - * - * @param int $month month of the calendar - * @param int $year year of the calendar - * @param int $size size is 1 small 2 large - * @param string $href href for the prev link - * @param string $href2 href for the next link - * @param mixed $eventObj Pass the EventCalendar Obj - * - * @access public - * @return string - */ - function calendar($month, $year, $size, $href, $href2, $eventObj) - { - // Change to month/year to display - if (!isset($month)) { - $month = date('m'); - } - if (!isset($year)) { - $year = date('Y'); - } - $this->getEvents($month, $year); - $prev = ($month - 1 < 1) - ? 12 - : $month - 1; - $prev_year = ($month - 1 < 1) - ? $year - 1 - : $year; - $next = ($month + 1 > 12) - ? 1 - : $month + 1; - $next_year = ($month + 1 > 12) - ? $year + 1 - : $year; - switch ($size) { - case 1: - // small calendar - $caltable = 'caltablesmall'; - $caldayheader = 'caldayheadersmall'; - $caltitle = 'caltitle'; - $calmonth = 'calmonthsmall'; - $calspacer = 'calspacersmall'; - $calday = 'caldaysmall'; - $calendar = ''; - $calendar .= date("F", mktime(0, 0, 0, $month + 1, 0, $year)); - $calendar .= ''; - break; - case 2: - $in_future = date('Y') + 3; - $in_past = date('Y') - 3; - if ($prev_year > $in_past) { - $prev_month = '' - . $this->_leftLink . ' Previous Month'; - } - if ($next_year < $in_future) { - $next_month = '' . $this->_rightLink . 'Next Month'; - } - // large calendar - $caltable = 'caltable'; - $caldayheader = 'caldayheader'; - $caltitle = 'caltitle'; - $calmonth = 'calmonth'; - $calspacer = 'calspacer'; - $calday = 'calday'; - $week_titles = array( - 0 => "Sunday", - 1 => "Monday", - 2 => "Tuesday", - 3 => "Wednesday", - 4 => "Thursday", - 5 => "Friday", - 6 => "Saturday" - ); - $calendar = date("F", mktime(0, 0, 0, $month + 1, 0, $year)); - break; - } - // determine total number of days in a month - $totaldays = date( - "t", mktime(0, 0, 1, $month, 1, $year) - ); - // build table - $out = ''; - $out .= ''; - if ($size == 1) { - $out .= ' - - - - '; - } else { - $out .= ' - - - - - - '; - } - if ($size == 2) { - $out .= ''; - for ($x = 0; $x < 7; $x++) { - $out .= ' - - '; - } - $out .= ' - - '; - } - /** - * ensure that a number of blanks are put in so - * that the first day of the month - * lines up with the proper day of the week - */ - $offset = date("w", mktime(0, 0, 0, $month, 0, $year)) + 1; - $out .= ' - - '; - if ($offset > 0 && $offset != 7) { - $out .= str_repeat( - "", $offset - ); - } - $offset = ($offset == 7) - ? 0 - : $offset; - // start entering in the information - for ($day = 1; $day <= $totaldays; $day++) { - $out .= ' - - '; - $offset++; - // if we're on the last day of the week, wrap to the other side - if ($offset > 6) { - $offset = 0; - $out .= ' - - '; - if ($day < $totaldays) { - $out .= ' - - '; - } - } - } - // fill in the remaining spaces for the end of the month - // , just to make it look pretty - if ($offset > 0) { - $offset = 7 - $offset; - } - if ($offset > 0) { - $out .= str_repeat( - "", $offset - ); - } - // end the table - $out .= ' -
' . $calendar . ' ' - . (($size == 2) - ? $year - : '') . '
' . $prev_month . ' ' . $calendar . ' ' - . (($size == 2) - ? $year - : '') . '' . $next_month . '
' . $week_titles[$x] . '
 '; - $datelink = $this->getEventData($month, $day, $year, $eventObj); - if ($size == 1 && $datelink) { - $out .= '' - . $day . ''; - } elseif ($datelink) { - $out .= $day . ''; - $out .= $datelink; - } else { - $out .= $day . ''; - } - $out .= '
 
- '; - return $out; - } - - // }}} - // {{{ calTime() - /** - * calTime - * - * @param mixed $time timestamp - * - * @access public - * @return array - */ - - function calTime($time) - { - if (preg_match("/([0-9]{1,2}):?([0-9]{2})? ?([AP]M)/i", $time, $temp)) { - $out = (int) $temp[1]; - $out - .= (!$temp[2]) - ? ':00' - : ':' . $temp[2]; - $out .= ' ' . $temp[3]; - } else if (strtolower($time) == 'noon') { - $out = '12:00 pm'; - } - return $out; - } - - // }}} - // {{{ getEventData() - /** - * getEventData - * - * @param int $month number of monht - * @param int $day number of day - * @param int $year number of year - * @param mixed $eventObj Pass the EventCalendar Obj - * - * @access public - * @return boolean|array - */ - - function getEventData($month, $day, $year, $eventObj) - { - $month = (int) $month; - if ((int) $month < 10) { - $month = '0' . $month; - } - $day = (int) $day; - if ((int) $day < 10) { - $day = '0' . $day; - } - $date = $month . '-' . $day . '-' . $year; - if ($this->_eventsData[$date]) { - return $this->showEventHeaders($date, $eventObj); - } else { - return false; - } - } - - // }}} - // {{{ getEventDates() - /** - * getEventDates - * - * @param mixed $starttime unix timestamp start - * @param mixed $endtime unix timestamp end - * @param boolean $recur bool true or false - * @param mixed $format php date format - * - * @access public - * @return array|void - */ - - function getEventDates($starttime, $endtime, $recur, $format = 'm-d-Y') - { - $events = $eWeeks = array(); - if (is_array($recur)) { - if ($starttime == $endtime) { - return; - } - $daysow = $recur['dow']; - if ($recur['recur_week'] == 9) { - $fWeekNum = date("W", $starttime); - if (date('w', $starttime) == 0) { - $fWeekNum++; - } - $lWeekNum = date("W", $endtime); - if (date('w', $endtime) == 0) { - $lWeekNum++; - } - for ($fi = $fWeekNum; $fi <= $lWeekNum; $fi = $fi + 2) { - $eWeeks[] = $fi; - } - } - $ord = array(); - for ($i = $starttime; $i <= $endtime; $i += 86400) { - if ($recur['recur_week'] != '') { - if ($recur['dow']) { - $ri = (int) 1; - for ($r = 0; $r < 7; $r++) { - if ($daysow & $ri) { - $ord[] = $this->ordinalDay( - $recur['recur_week'], $r, date('n', $i), date('Y', $i) - ); - } - $ri = $ri << 1; - } - } - } - if ($recur['dom']) { - if (date("j", $i) == $recur['dom']) { - $events[] = date($format, $i); - } - } elseif ($daysow) { - $cur_dow = date("w", $i); - switch ($cur_dow) { - case 0: - $cur_dow = 1; - break; - case 1: - $cur_dow = 2; - break; - case 2: - $cur_dow = 4; - break; - case 3: - $cur_dow = 8; - break; - case 4: - $cur_dow = 16; - break; - case 5: - $cur_dow = 32; - break; - case 6: - $cur_dow = 64; - break; - } - if ((int) $cur_dow & $daysow) { - $cDateWeek = date("W", $i); - if (date('w', $time) == 0) { - $cDateWeek++; - } - if ($recur['recur_week'] == 9) { - if (in_array($cDateWeek, $eWeeks)) { - $events[] = date($format, $i); - } - } elseif ($recur['recur_week'] != '') { - foreach ($ord as $o) { - if ($recur['recur_week'] && $i && $o) { - if ($i == $o) { - $events[] = date($format, $i); - } - } - } - } else { - $events[] = date($format, $i); - } - } - } - } - } - return $events; - } - - // }}} - // {{{ getEvents() - /** - * getEvents - * - * @param int $month number of monht - * @param int $year number of year - * - * @access public - * @return string - */ - - function getEvents($month, $year) - { - $this->_leftLink = ''; - $this->_rightLink = ''; - - /** - * set up the month day and year vars if not already set. - */ - $month = (!isset($month) && $month != "All") - ? date("n") - : $month; - $year = (!isset($year)) - ? date("Y") - : $year; - if ($year <= 2000) { - return false; - } - $month = (preg_match("/^0([0-9]).*/", $month, $part)) - ? $part[1] - : $month; - if (!is_numeric($month) || !is_numeric($year)) { - return false; - } - $st1 = mktime(0, 0, 0, $month, 1, $year); - $st2 = mktime(0, 0, 0, $month + 1, 1, $year); - - /** - * build start and end timestamps for getting an array of events for the - * month. - */ - $starting = date("m/d/Y", $st1); - $ending = date("m/d/Y", $this->lastDayOfMonth($st2)); - - /** - * Grab the events for this month. - * NOTE: case statement in this query will order - * the ones that span more than 1 day. - */ - $query = " - SELECT e.id,e.dayom,e.header, - bdate as sdate, e.edate as edate,e.weekom, - e.btime,e.etime,e.descr,e.loc,e.contact,e.email,e.url, - e.img,e.daysow,e.reacur,t.topiccolor, - case when e.reacur = cast(1 as boolean) then 0 - when (e.edate - e.bdate) > 1 - then (e.edate - e.bdate) - else 0 - end as sortflag,e.all_day - FROM event e left outer join topic t on (t.id = e.topicid) - WHERE e.visable = cast(1 as boolean)"; - $query .= " AND e.bdate <= '$ending' - AND e.edate >= '$starting' $addpart"; - $query .= "ORDER BY sortflag desc,e.bdate DESC,e.btime ASC"; - try { - $events_data = $this->dbh->query($query)->fetchAll(PDO::FETCH_ASSOC); - } catch (PDOException $e) { - Toolkit_Common::handleError($e); - } - // {{{ selection of events part - /** - * End of query and now we have the data and must arrange - * this to place in the calendar. - * This will result in an array like the following: - * $this->_eventsData['x-date'] = $row; - * in which x-data is the date of the event (ie.)$months['08-07-2005'] - * and 4row is the $rom from the $evwents_data array - */ - if (is_array($events_data)) { - foreach ($events_data as $key => $row) { - if ($row['reacur']) { - $eData = $this->getEventDates( - $st1, $st2, array( - 'dow' => $row['daysow'], - 'recur_week' => $row['weekom'], - 'dom' => $row['dayom'] - ) - ); - if (is_array($eData) && !empty($eData)) { - - $eventStartDate = strtotime($row['sdate']); - $eventEndDate = strtotime($row['edate']); - foreach ($eData as $event) { - list($eM, $eD, $eY) = explode("-", $event); - $checkTime = strtotime("{$eM}/{$eD}/{$eY}"); - if ($checkTime >= $eventStartDate - && $checkTime <= $eventEndDate - ) { - $this->_eventsData[$event][$row['id']] = $row; - } - } - } - } else { - for ($i = 1; $i <= 31; ++$i) { - $checkTime = mktime( - 0, 0, 0, $month, $i, $year - ); - $eventStartDate = strtotime($row['sdate']); - $eventEndDate = strtotime($row['edate']); - if ($checkTime >= $eventStartDate - && $checkTime <= $eventEndDate - ) { - $date = date("m-d-Y", $checkTime); - $this->_eventsData[$date][$row['id']] = $row; - } - } - } - } - }// }}} - } - - // }}} - // {{{ disColor() - /** - * disColor - * - *

Goes back to color array and grabs the class for that peticular color.

- * - * @param string $color Color to use - * - * @return string class to use for style. - */ - - function disColor($color) - { - // get style class for this color - return $this->_colorArray[$color]; - } - - // }}} - // {{{ lastDayOfMonth() - /** - * lastDayOfMonth - * - *

given timestamp get the last day of the month it - * fall in

- * - * @param string $time Timestamp - * - * @return string timestamp - */ - function lastDayOfMonth($time = '') - { - $timestamp = ($time == '') - ? time() - : $time; - $timePart = date("Y-m", $timestamp); - return strtotime($timePart . ' last day'); - } - - // }}} - // {{{ myGetTimeStamp() - - /** - * gets time stamp - * - * Long description (if any)... - * - * @param unknown $time Parameter description (if any)... - * @param boolean $all_day Parameter description (if any)... - * - * @return integer Return description (if any)... - * @access public - */ - function myGetTimeStamp($time, $all_day = false) - { - static $count, $count2; - $count = ($count) - ? $count - : 1; - $count2 = ($count2) - ? $count2 - : 1; - $pattern = "/^([0-9]{1,2}):?([0-9]{1,2})? ?([AP]M)/i"; - if (!$all_day && preg_match($pattern, trim($time), $tar1)) { - if (($tar1[3] == 'PM' || $tar1[3] == 'pm') && (int) $tar1[1] < 12) { - $a1 = (int) $tar1[1] + 12; - } else { - $a1 = (int) $tar1[1]; - } - $a2 = $tar1[2]; - $time1 = mktime($a1, $a2, $count++, 1, 1, 2000); - return $time1; - } else { - if ($all_day) { - $time1 = $count2++; - } else { - $time1 = 999999999 + $count++; - } - return $time1; - } - } - - // }}} - // {{{ ordinalDay() - /** - * ordinalDay - * get ordinal (th)day for given timestamp - * - * @param int $ord ordinal number - * @param int $day number of day - * @param int $month number of month - * @param int $year number of year - * - * @access public - * @return int - */ - - function ordinalDay($ord, $day, $month, $year) - { - $firstOfMonth = strtotime("{$month}/01/{$year}"); - $lastOfMonth = $firstOfMonth + date("t", $firstOfMonth) * 86400; - $dayOccurs = 0; - for ($i = $firstOfMonth; $i < $lastOfMonth; $i += 86400) { - if (date("w", $i) == $day) { - $dayOccurs++; - if ($dayOccurs == $ord) { - $ordDay = $i; - } - } - } - return $ordDay; - } - - // }}} - // {{{ showEventHeaders() - /** - * showEventHeaders - * - * @param string $date date string - * @param mixed $eventObj Pass the EventCalendar Obj - * - * @access public - * @return string - */ - - function showEventHeaders($date, $eventObj) - { - $pattern = "/([0-9]{1,2})[-\/]([0-9]{1,2})[-\/]([0-9]{4})/"; - if (preg_match($pattern, $date, $dpart)) { - $month = (int) $dpart[1]; - $year = (int) $dpart[3]; - } - if (is_array($this->_eventsData[$date])) { - foreach ($this->_eventsData[$date] as $num => $data) { - $btime = $this->calTime($data['btime']); - $etime = $this->calTime($data['etime']); - $all_day = ($data['all_day'] == 't') - ? 1 - : 0; - $stime = (int) $this->myGetTimeStamp($btime, $all_day); - $data2[(int) $stime] = '
- -
- '; - } - ksort($data2, SORT_REGULAR); - ob_start(); - $out = ob_get_contents(); - ob_end_clean(); - echo $out; - $output = implode(" ", $data2); - } - return $output; - } - - // }}} -} - -?> diff --git a/Toolkit/Events/CategoryBlocks.php b/Toolkit/Events/CategoryBlocks.php deleted file mode 100644 index a3fe413..0000000 --- a/Toolkit/Events/CategoryBlocks.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @copyright 2012 Gaslight Media - * @license Gaslight Media - * @version SVN: (0.1) - * @link <> - */ - -/** - * Toolkit_Events_CategoryBlocks - * - * Description of CategoryBlocks - * - * @category Toolkit - * @package Events - * @author Steve Sutton - * @copyright 2012 Gaslight Media - * @license Gaslight Media - * @release Release: (0.1) - * @link <> - */ -class Toolkit_Events_CategoryBlocks - extends Toolkit_Events_Auxiliary -{ - public function toHtml() - { - $tpl = new HTML_Template_Flexy($this->_flexyOptions); - } -} diff --git a/Toolkit/Events/Display.php b/Toolkit/Events/Display.php deleted file mode 100755 index 475f164..0000000 --- a/Toolkit/Events/Display.php +++ /dev/null @@ -1,116 +0,0 @@ - - * @copyright 2009 Gaslight Media - * @license Gaslight Media - * @version CVS: $Id: Display.php,v 1.4 2010/08/04 13:04:50 jamie Exp $ - * @link <> - */ - -/** - * Toolkit_Events_Display - * - * Display the events in a list view and optionally a calendar view - * This is set in Toolkit/Events/config.ini - * - * @category Toolkit - * @package Events - * @author Steve Sutton - * @copyright 2009 Gaslight Media - * @license Gaslight Media - * @version Release: @package_version@ - * @link <> - */ -class Toolkit_Events_Display - extends Toolkit_Events_Auxiliary -{ - /** - * toHTML() - * - * call to listEvents function for display of events - * - * @param Toolkit_Template_KeywordReplacement $keywordReplacement Reference - * - * @return void - * @access public - */ - public function toHTML( - Toolkit_Template_KeywordReplacement $keywordReplacement - ) { - $baseUrl - = ($_SERVER['HTTPS'] == 'on') - ? BASE_SECURE_URL - : MEDIA_BASE_URL; - $glmAppBaseUrl - = ($_SERVER['HTTPS'] == 'on') - ? GLM_APP_BASE_SECURE_URL - : MEDIA_APP_BASE_URL; - $GLOBALS['styleSheets'][] - = $glmAppBaseUrl . 'libjs/jqueryui/1.8.13/development-bundle/themes/base/jquery.ui.all.css'; - $GLOBALS['styleSheets'][] - = $baseUrl . 'Toolkit/Events/css/event.css'; - $GLOBALS['topScripts'][] - = $glmAppBaseUrl . 'libjs/jqueryui/1.8.13/js/jquery-ui-1.8.13.custom.min.js'; - $GLOBALS['bottomScripts'][] - = $baseUrl . 'Toolkit/Events/libjs/events.js'; - $GLOBALS['styleSheets'][] - = $glmAppBaseUrl . 'libjs/plugins/nivoslider/themes/default/default.css'; - - $template = new HTML_Template_Flexy($this->flexyOptions); - $page = new stdClass; - $page->todayUrl = MEDIA_BASE_URL . 'events/'.EVENT_PAGE.'/?t=today'; - $page->tomorrowUrl = MEDIA_BASE_URL . 'events/'.EVENT_PAGE.'/?t=tomorrow'; - $page->nextUrl = MEDIA_BASE_URL . 'events/'.EVENT_PAGE.'/?t=next'; - - $template->compile('eventPage.html'); - - // create user search form - $userSearchForm - = new Toolkit_Events_UserSearchForm($this->dbh); - $page->eventSearchForm = $userSearchForm->toHtml(); - - // add home events - $homeEvents = new Toolkit_Events_HomeEvents($this->dbh); - $page->events = $homeEvents->getHomeEvents(); - $page->hasHomeEvents = !empty($page->events); - // setup query - $queryBuilder = new Toolkit_Events_QueryBuilder(); - $eventId = filter_var($_REQUEST['eventid'], FILTER_VALIDATE_INT); - $t = filter_var($_REQUEST['t'], FILTER_SANITIZE_STRING); - - if ($eventId) { - $GLOBALS['topScripts'][] - = 'http://maps.googleapis.com/maps/api/js?sensor=true'; - $GLOBALS['topScripts'][] - = $baseUrl . 'Toolkit/Events/libjs/geoCoder.js'; - $eventList = new Toolkit_Events_ListEvents($this->dbh); - $eventList->setQuery($queryBuilder->buildQuery()); - $page->eventContent = $eventList->toHtml( - $keywordReplacement, - 'eventDetail.html' - ); - } else if ($_REQUEST['search']) { - $eventList = new Toolkit_Events_ListEvents($this->dbh); - $eventList->setQuery($queryBuilder->buildQuery()); - $eventList->setSearchFor($queryBuilder); - $page->eventContent = $eventList->toHtml($keywordReplacement); - } else if ($t) { - $eventList = new Toolkit_Events_ListEvents($this->dbh); - $eventList->setQuery($queryBuilder->buildQuery()); - $eventList->setSearchFor($queryBuilder); - $page->eventContent = $eventList->toHtml($keywordReplacement); - } else { - $homePage = new Toolkit_Events_EventHomePage($this->dbh); - $page->eventContent = $homePage->toHtml(); - } - - return $template->bufferedOutputObject($page); - } -} diff --git a/Toolkit/Events/EventCalendar.php b/Toolkit/Events/EventCalendar.php deleted file mode 100755 index db06938..0000000 --- a/Toolkit/Events/EventCalendar.php +++ /dev/null @@ -1,798 +0,0 @@ - - * @copyright 2010 Gaslight Media - * @license Gaslight Media - * @version CVS: $Id: EventCalendar.php,v 1.3 2010/08/04 14:39:58 jamie Exp $ - * @link <> - */ - -/** - * Handles the event calendar - * - * Long description (if any) ... - * - * @category Toolkit - * @package Events - * @author Steve Sutton - * @copyright 2010 Gaslight Media - * @license Gaslight Media - * @version Release: @package_version@ - * @link <> - */ -class Toolkit_Events_EventCalendar -{ - // {{{ properties - - /** - * Description of $topicid - * @access public - * @var integer - */ - public $topicid; - /* * #@+ - * @access public - * @var string - */ - - /** - * Description of $pageName - * - * @var string - * @access public - */ - public $pageName; - - /** - * Type of display flat or calendar based on weather or not a topicid exists. - * - * @var mixed - * @access public - */ - public $displayType; - - /** - * PDO - * - * @var mixed - * @access public - */ - public $dbh; - - /** - * Array of colors - * @var array - * @access public - */ - public $colorArray = array( - '#FFCCCC' => 'color1', - '#CC9999' => 'color2', - '#FF9999' => 'color3', - '#FFCCFF' => 'color4', - '#CC99CC' => 'color5', - '#FF99FF' => 'color6', - '#CCCCFF' => 'color7', - '#9999CC' => 'color8', - '#9999FF' => 'color9', - '#CCFFFF' => 'color10', - '#99CCCC' => 'color11', - '#99FFFF' => 'color12', - '#CCFFCC' => 'color13', - '#99CC99' => 'color14', - '#99FF99' => 'color15', - '#FFFFCC' => 'color16', - '#CCCC99' => 'color17', - '#FFFF99' => 'color18', - '#FFCC99' => 'color19', - '#FF99CC' => 'color20', - '#CC99FF' => 'color21', - '#99CCFF' => 'color22', - '#99FFCC' => 'color23', - '#CCFF99' => 'color24', - '#CCCCCC' => 'color25' - ); - - // }}} - // {{{ __construct() - - /** - * Class constructor - * - * @param PDO $pdo Database Instance - * - * @access public - */ - public function __construct(PDO $pdo) - { - $this->dbh = & $pdo; - $this->topicid = $GLOBALS['topicid']; - $this->pageName = MEDIA_BASE_URL . 'index.php?catid=' . $_REQUEST['catid']; - $this->displayType = $this->getType(); // Calendar or Flat - } - - // }}} - // {{{ advancedSearch() - /** - * advancedSearch - * - *

Show an advanced search form

- * - * @return string - */ - function advancedSearch() - { - $out = ''; - $out .= $this->getEventSearch(1); - $out .= ' -

Advanced Search Option:

- - - - - - - - - - - - - - - - - - - - - - - '; - return $out; - } - - // }}} - // {{{ disColor() - - /** - * Get style class for color - * - * Long description (if any) ... - * - * @param unknown $color Parameter description (if any) ... - * - * @return array Return description (if any) ... - * @access public - */ - function disColor($color) - { - // get style class for this color - return $this->colorArray[$color]; - } - - // }}} - // {{{ firstDayOfMonth() - /** - * firstDayOfMonth - * - * Given a unix timestamp return the first day of the month - * - * @param string $time unix timestamp - * - * @return string - */ - - function firstDayOfMonth($time = '') - { - $timestamp = ($time == '') - ? time() - : $time; - list($month, $day, $year) = explode("/", date('m/d/Y', $timestamp)); - return mktime(0, 0, 0, $month, 1, $year); - } - - // }}} - // {{{ toHtml() - /** - * toHtml: - * - * @param Toolkit_Template_KeywordReplacement $keywordReplacement Keyword - * - * @uses BASE - * @uses GLM_EVENT::getEventSearch() - * @uses GLM_EVENT::$displayType - * @uses calendar() - * @return mixed - * */ - - function toHtml(Toolkit_Template_KeywordReplacement $keywordReplacement) - { - if ($_GET['advance'] == 1) { - return $this->advancedSearch(); - } - $out = ''; - if ($_POST['month'] && $_POST['month'] != 'All') { - $month = (int) substr($_POST['month'], 0, 2); - $year = (int) substr($_POST['month'], 3, 6); - } elseif (preg_match("/([0-9]{1,2}) ([0-9]{4})/", $_GET['month'])) { - $month = (int) substr($_GET['month'], 0, 2); - $year = (int) substr($_GET['month'], 3, 6); - } elseif ($_GET['month'] && is_numeric($_GET['month'])) { - $month = (int) $_GET['month']; - $year = (int) $_GET['year']; - } elseif ($_REQUEST['month'] && $_REQUEST['month'] != 'All') { - $month = (int) date("m"); - $year = (int) date("Y"); - } - if (isset($year) && (int) $year < 2000) { - return false; - } - - // this runs when a user clicks on the day in one of the small calendars - if ($_GET['flat'] == 1 && $_GET['day'] && $_GET['month'] && $_GET['year']) { - $out .= $this->getEventSearch(1); - $req_timestamp = mktime( - 0, - 0, - 1, - $_GET['month'], - $_GET['day'], - $_GET['year'] - ); - $mydate = date("m-d-Y", $req_timestamp); - $myDayOw = date("w", $req_timestamp); - switch ($myDayOw) { - case 0: - $myDayOw = 1; - break; - case 1: - $myDayOw = 2; - break; - case 2: - $myDayOw = 4; - break; - case 3: - $myDayOw = 8; - break; - case 4: - $myDayOw = 16; - break; - case 5: - $myDayOw = 32; - break; - case 6: - $myDayOw = 64; - break; - } - $qs = " - SELECT e.*, - t.descr AS topicname - FROM event e LEFT OUTER JOIN topic t ON (e.topicid = t.id) - WHERE e.visable = 't' - AND ((e.reacur != 't' - AND e.edate >= '$mydate' - AND e.bdate <= '$mydate' - ) OR (e.reacur = 't' - AND e.id in ( - SELECT event_id - FROM event_recur - WHERE event_day = '$mydate') - )) - ORDER BY e.all_day desc,e.bdate,e.edate,e.btime,e.etime;"; - //$out .= $qs; - $eventList = new Toolkit_Events_ListEvents($this->dbh); - $eventList->setQuery($qs); - $out .= $eventList->toHtml($keywordReplacement); - // default calendar view - } elseif ($this->displayType == "Calendar") { - $cal = new Toolkit_Events_Calendar($this->dbh); - if (!$_REQUEST['eventid']) { - $out .= $this->getEventSearch(1); - $out .= '' . "\n"; - $out .= $cal->calendar( - $month, - $year, - 2, - $this->pageName.'&event=1&month=', - $this->pageName.'&event=1&eventid=1&month='.$month, - $this - ); - } else { - $eventid = (int) $_REQUEST['eventid']; - $qs = " - SELECT event.*,topic.descr as topicname - FROM event LEFT OUTER JOIN topic ON (topic.id = event.topicid) - WHERE event.id = {$eventid}"; - $eventList = new Toolkit_Events_ListEvents($this->dbh); - $eventList->setQuery($qs); - $out .= $this->getEventSearch(1); - $out .= $eventList->toHtml($keywordReplacement); - - $out .= '
' . "\n"; - $out .= $cal->calendar( - $month, - $year, - 2, - $this->pageName.'&event=1&month=', - $this->pageName.'&eventid=1&month='.$month, - $this - ); - } - // used when the end user does a advanced search - } else { - $noSearch = true; - $searching = ''; - $out .= $this->getEventSearch(1); - $qs = " - SELECT e.*,t.descr as topicname - FROM event e LEFT OUTER JOIN topic t ON (e.topicid = t.id) - WHERE e.visable = 't'"; - if (ctype_digit($_POST['topicid'])) { - $noSearch = false; - $query = "select descr from topic where id = " . $_POST['topicid']; - try { - $row2 = $this->dbh->query($query)->fetchAll(PDO::FETCH_ASSOC); - } catch (PDOException $e) { - Toolkit_Common::handleError($e); - } - $qs .= " and e.topicid = " . $_POST['topicid']; - if ($searching) { - $searching .= ', ' . $row2[0]['descr'] . ''; - } else { - $searching = 'Showing all ' . $row2[0]['descr'] . ''; - } - } - if ($this->displayType == 'flat' && $month && $year) { - $noSearch = false; - $timestmp = mktime( - 0, - 0, - 1, - $month, - 1, - $year - ); - $bdate = date("m/d/Y", $timestmp); - $timestmp2 = mktime( - 0, - 0, - 1, - $month, - date("t", $timestmp), - $year - ); - $edate = date("m/d/Y", $timestmp2); - if ($searching == '') { - $searching = "Searching for All events in " - . date("F, Y", $timestmp); - } else { - $searching .= " in " . date("F, Y", $timestmp); - } - $qs .= " - and e.edate > current_date - and e.edate >= '{$bdate}' - and e.bdate <= '{$edate}'"; - } - if (isset($_GET['topicid']) && $_GET['topicid'] != 'All' && ctype_digit($_GET['topicid'])) { - $noSearch = false; - $query = "select descr from topic where id = " . $_GET['topicid']; - try { - $row2 = $this->dbh->query($query)->fetchAll(PDO::FETCH_ASSOC); - } catch (PDOException $e) { - Toolkit_Common::handleError($e); - } - $qs .= " and e.topicid = " . $_GET['topicid']; - $searching .= 'Showing all ' . $row2[0]['descr'] . ''; - } - if (is_array($_POST['topics_id']) || $_POST['EventName']) { - $noSearch = false; - if ($_POST['EventName'] != '') { - $qs .= " and ( lower(e.header) like '%" - . strtolower($_POST['EventName']) . "%'"; - $qs .= " or lower(e.descr) like '%" - . strtolower($_POST['EventName']) . "%') "; - $searching .= 'Searching for "' - . $_POST['EventName'] . '" '; - } else { - $searching .= 'Searching for anything '; - } - if (is_array($_POST['topics_id']) - && count($_POST['topics_id']) > 0 - ) { - $topics_list = implode(",", $_POST['topics_id']); - $qs .= " and e.topicid in ({$topics_list})"; - $query = "select descr from topic where id in ({$topics_list})"; - $order_by = "t.descr,"; - try { - $row2 = $this->dbh->query($query) - ->fetchAll(PDO::FETCH_ASSOC); - } catch (PDOException $e) { - Toolkit_Common::handleError($e); - } - if ($row2) { - foreach ($row2 as $k => $v) { - $tps[] = $v['descr']; - } - } - if (is_array($tps)) { - $searching .= 'in ' . implode(', ', $tps) . ' '; - } - } - } - if ($_POST['EventDateTo'] && $_POST['EventDateFrom'] - && (strtotime($_POST['EventDateFrom']) != -1) - && (strtotime($_POST['EventDateTo']) != -1) - ) { - $noSearch = false; - if ($_POST['EventName'] == '' && $searching == '') { - $searching .= 'Searching for anything '; - } - $begin_time = date('n/j/Y', strtotime($_POST['EventDateFrom'])); - $end_time = date('n/j/Y', strtotime($_POST['EventDateTo'])); - $qs .= " and e.bdate <= '$end_time' and e.edate >= '$begin_time'"; - $searching .= ' between ' . $begin_time . ' and ' . $end_time; - } - if ($noSearch) { - $qs = " - SELECT e.* - FROM event e - where e.visable = 't' - and e.edate >= current_date - order by e.bdate,e.edate"; - } else { - $qs .= ' - and e.edate >= current_date - order by ' . $order_by . 'e.bdate,e.edate'; - } - if ($searching) { - $out .= '

' . $searching . '

'; - $out .= '
'; - } - $eventList = new Toolkit_Events_ListEvents($this->dbh); - $eventList->setQuery($qs); - $out .= $eventList->toHtml($keywordReplacement); - } - return $out; - } - - // }}} - // {{{ getEventSearch() - /** - * getEventSearch - * - * @uses PGSQL_ASSOC - * @uses GLM_EVENT::$pageName - * @uses calendar() - * @return string - * */ - - function getEventSearch() - { - $out = ''; - // unset($emonths); - $month_id = array( - "Jan", - "Feb", - "Mar", - "Apr", - "May", - "Jun", - "Jul", - "Aug", - "Sep", - "Oct", - "Nov", - "Dec" - ); - - // Month part do not change - $qs = " - SELECT bdate,edate - FROM event - WHERE visable = 't' - ORDER BY bdate ASC;"; - - try { - $res = $this->dbh->query($qs)->fetchAll(PDO::FETCH_ASSOC); - } catch (PDOException $e) { - Toolkit_Common::handleError($e); - } - - $page = $this->pageName; - - foreach ($res as $data) { - $beginDateParts = explode("/", $data['bdate']); - $endDateParts = explode("/", $data['edate']); - // parse the month and year out of the start and end dates - $s_month = $beginDateParts[0]; - $s_year = $beginDateParts[2]; - $e_month = $endDateParts[0]; - $e_year = $endDateParts[2]; - - // $start_time_stamp = mktime( - // 0, - // 0, - // 0, - // $s_month, - // 1, - // $s_year - // ); - $end_time_stamp = mktime( - 0, - 0, - 0, - $e_month, - 1, - $e_year - ); - $watchdog = 20; - $cur_time_stamp = mktime( - 0, - 0, - 0, - $m, - 1, - $y - ); - for ($y = $s_year, $m = $s_month; $cur_time_stamp <= $end_time_stamp;) { - if ($m == 13) { - $y++; - $m = 1; - } - - $emonth = sprintf( - "%02d %04d", - $m, - $y - ); - if (!isset($emonths["$emonth"])) { - $emonths["$emonth"] = 0; - } - $emonths["$emonth"]++; - - $cur_time_stamp = mktime( - 0, - 0, - 0, - $m, - 1, - $y - ); - if ($watchdog-- == 0) { - break 1; - } - $m++; - $cur_time_stamp = mktime( - 0, - 0, - 0, - $m, - 1, - $y - ); - } - } - $out .= ''; - // topic search part - $qs = " - SELECT distinct descr,id,topiccolor - FROM topic - WHERE id in ( - SELECT topicid - FROM event - WHERE visable = 't' - AND edate >= current_date) - ORDER BY descr;"; - try { - $result = $this->dbh->query($qs)->fetchAll(PDO::FETCH_ASSOC); - } catch (PDOException $e) { - Toolkit_Common::handleError($e); - } - if ($result) { - if ($this->displayType == 'Calendar') { - $out .= '
'; - foreach ($result as $tkey => $trow) { - $out .= ''; - } - $out .= '
'; - } else { - $out .= '
'; - $out .= ''; - } - } - - if ($_POST['month']) { - $month = (int) substr($_POST['month'], 0, 2); - $year = (int) substr($_POST['month'], 3, 6); - } elseif ($_GET['month']) { - $month = (int) $_GET['month']; - $year = (int) $_GET['year']; - } else { - $month = (int) date("m"); - $year = (int) date("Y"); - } - $out .= '
'; - $prev_month = ($month - 1 < 1) - ? 12 - : $month - 1; - $prev_year = ($month - 1 < 1) - ? $year - 1 - : $year; - $next_month = ($month + 1 > 12) - ? 1 - : $month + 1; - $next_year = ($month + 1 > 12) - ? $year + 1 - : $year; - if ($this->displayType == 'Calendar') { - $calObj = $this; - $calendar = new Toolkit_Events_Calendar($this->dbh); - // setup the calendars for the search on the top - $out .= $calendar->calendar( - $prev_month, - $prev_year, - 1, - $this->pageName.'&event=1&month=', - $this->pageName.'&event=1&eventid=1&month='.$month, - $calObj - ); - $out .= $calendar->calendar( - $month, - $year, - 1, - $this->pageName.'&event=1&month=', - $this->pageName.'&event=1&eventid=1&month='.$month, - $calObj - ); - $out .= $calendar->calendar( - $next_month, - $next_year, - 1, - $this->pageName.'&event=1&month=', - $this->pageName.'&event=1&eventid=1&month='.$month, - $calObj - ); - } - $out .= '
'; - $out .= '
'; - if ($this->displayType == 'Calendar') { - $out .= ''; - } - if ($this->displayType == 'Calendar') { - $out .= 'By Month: '; - } - if (isset($emonths) && is_array($emonths)) { - // below FOR equivalent to: foreach (array_keys($emonths) as $key) { - // assignment intentional - for (reset($emonths); $key = key($emonths); next($emonths)) { - $date = mktime( - 0, - 0, - 0, - (integer)substr($key, 0, 2), - 1, - substr($key, 3, 4) - ); - $now = mktime(0, 0, 0, date("m"), 1, date("Y")); - if ($date >= $now) { - $m = substr($key, 0, 2); - $mymonth = $month_id[$m - 1] . " " . substr($key, 3, 4); - $out .= '
'; - return $out; - } - - // }}} - // {{{ getType() - /** - * getType - * - * @return string - */ - - function getType() - { - if (($_POST['EventDateTo'] && $_POST['EventDateFrom']) - && (strtotime($_POST['EventDateTo']) != -1 - && strtotime($_POST['EventDateFrom']) != -1) - ) { - return 'flat'; - } - if ($_POST['topicid'] || $_GET['topicid'] || $_POST['topic'] - || $_POST['topics_id'] || $_POST['EventName'] - ) { - return 'flat'; - } - return 'Calendar'; - } - - // }}} - // {{{ lastDayOfMonth() - /** - * lastDayOfMonth - * - * @param string $time unix timestamp - * - * @return string - */ - function lastDayOfMonth($time = '') - { - $timestamp = ($time == '') - ? time() - : $time; - list($month, $day, $year) = explode("/", date('m/t/Y', $timestamp)); - return strtotime("$month/$day/$year"); - } - - // }}} -} diff --git a/Toolkit/Events/EventHomePage.php b/Toolkit/Events/EventHomePage.php deleted file mode 100644 index 41b0ae7..0000000 --- a/Toolkit/Events/EventHomePage.php +++ /dev/null @@ -1,168 +0,0 @@ - - * @copyright 2012 Gaslight Media - * @license Gaslight Media - * @version SVN: (0.1) - * @link <> - */ - -/** - * Toolkit_Package_EventHomePage - * - * Displays the content for Event Home Area - * - * @category Toolkit - * @package Package - * @author Steve Sutton - * @copyright 2012 Gaslight Media - * @license Gaslight Media - * @release Release: (0.1) - * @link <> - */ -class Toolkit_Events_EventHomePage - extends Toolkit_Events_Auxiliary -{ - /** - * Create the html for the Event Home Page content - * - * @return string - */ - public function toHtml() - { - $glmAppBaseUrl = MEDIA_APP_BASE_URL; - $GLOBALS['styleSheets'][] - = $glmAppBaseUrl . 'libjs/plugins/nivoslider/3.1/' . CSS_ENV - . '/nivo-slider.css'; - $GLOBALS['bottomScripts'][] - = $glmAppBaseUrl . 'libjs/plugins/nivoslider/3.1/' . LIBJS_ENV - . '/jquery.nivo.slider.js'; - $tpl = new HTML_Template_Flexy($this->flexyOptions); - $tpl->compile('eventHomePage.html'); - $page = new stdClass; - $page->url = MEDIA_BASE_URL; - $page->topicSearchUrl = MEDIA_BASE_URL . 'index.php?catid='.EVENT_PAGE.'&search=1&category=' ; - $page->events = $this->_getFeaturedEvents(); - $page->hasFeaturedEvents = !empty($page->events); - $page->blocks = $this->_getCategoryBlocks(); - return $tpl->bufferedOutputObject($page); - } - - /** - * Return array of Events that are marked featured or Home - * - * @return array - */ - private function _getFeaturedEvents() - { - $homeEvents = new Toolkit_Events_HomeEvents($this->dbh); - return $homeEvents->getHomeEvents(); - } - - /** - * Returns the Events Category Block Arrays - * - * @return array - */ - private function _getCategoryBlocks() - { - $blocks = array(); - try { - $sql = " - SELECT * - FROM topic - WHERE id IN ( - SELECT topicid - FROM event - WHERE current_date <= edate - AND visable - ) - ORDER BY descr"; - $stmt = $this->dbh->query($sql); - while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { - $blocks[$row['descr']] - = array( - 'id' => $row['id'], - 'data' => $this->_getUpcomingEventsByTopics($row['id']) - ); - } - } catch (PDOException $e) { - Toolkit_Common::handleError($e); - } - return $blocks; - } - - /** - * Returns array of events by topic (limited) - * - * @param int $topicId Topic id for the events - * - * @return array Events - */ - private function _getUpcomingEventsByTopics($topicId) - { - $events = array(); - $sql = " - SELECT event.id,header,img,descr,event.reacur, - CASE - WHEN reacur is true THEN event_day - ELSE bdate - END as event_starting_date,event.bdate,event.edate - FROM event - LEFT OUTER JOIN event_recur - ON (event.id = event_recur.event_id) - WHERE visable - AND ((reacur is true AND event_recur.event_day >= current_date) - OR - (reacur is not true AND event.edate >= current_date)) - AND event.topicid = {$topicId} - ORDER BY event_starting_date,header - LIMIT 3 - OFFSET 0"; - $result = $this->dbh->query($sql); - Zend_Date::setOptions(array('format_type' => 'php')); - while ($row = $result->fetch()) { - $eventDateUsed = new Zend_Date( - strtotime($row['event_starting_date']), - Zend_Date::TIMESTAMP - ); - $hrefFormat - = 'events/%d/%d/'; - $href = MEDIA_BASE_URL . sprintf( - $hrefFormat, - EVENT_PAGE, - $row['id'] - ); - $sdate = strtotime($row['bdate']); - $edate = strtotime($row['edate']); - $dates - = ($event_day) - ? $event_day - : GLM_TEMPLATE::get_event_date( - $sdate, - $edate, - 'timestamp' - ); - if ($row['reacur']) { - $dates = $eventDateUsed->toString('M - jS'); - } - // strip out tags and add slashes to $descr - $events[] = array( - 'href' => $href, - 'bdate' => $eventDateUsed->toString('M - jS'), - 'dates' => $dates, - 'header' => strip_tags($row['header']), - 'img' => FILE_SERVER_URL . IS_OWNER_ID . '/eventSlider/' . $row['img'], - 'descr' => substr(strip_tags($row['descr']), 0, 150) - ); - } - return $events; - } -} diff --git a/Toolkit/Events/Forms/Admin/EditEvent.php b/Toolkit/Events/Forms/Admin/EditEvent.php deleted file mode 100755 index 679f43b..0000000 --- a/Toolkit/Events/Forms/Admin/EditEvent.php +++ /dev/null @@ -1,1571 +0,0 @@ - - * @license http://www.gaslightmedia.com Gaslightmedia - * @version CVS: $Id: AddEventForm.php,v 1.20 2010/07/04 23:58:22 jamie Exp $ - * @link http://demo.gaslightmedia.com - */ -/** - * - */ -require_once BASE . 'Toolkit/Forms/Rules/Image.php'; - -/** - * Handles editing of events - * - * @category Toolkit - * @package Events - * @author Jamie Kahgee - * @copyright 2009 Jamie Kahgee - * @license http://www.gaslightmedia.com Gaslightmedia - * @link http://demo.gaslightmedia.com - */ -class Toolkit_Events_Forms_Admin_EditEvent - extends Toolkit_FormBuilder - implements Toolkit_Form -{ - - /** - * Table in Database which holds the contact data - * - * @var string - * @access public - */ - public $tableName = 'event'; - - /** - * Table meta data - * - * This is used when inserting/updating data for the records - * so the PDO's can use explicit data types for the parameters. - * - * @var array - * @access public - */ - public $tableMetaData; - - /** - * Who to send the email to when the contact form is submitted - * - * If you leave this blank, its value will get set to the OWNER_EMAIL - * in the constructor. - * - * If you ***DO NOT*** want any emails to go out when the form is submitted - * then set the value to false. Do not set it to 0 for false, because the - * check uses a strict type check to determine if the value is actually - * false. This is what allows for the empty value as an option, which sets - * the value to OWNER_EMAIL and won't override the $email property if - * this class gets subclassed and the value for this property gets set in - * the properties of the subclass and not in the constructor after this - * constructor function is called. - * - * tongue twister...I know. - * - * 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 - * - * It gets set to the constant SITENAME in the constructor if you leave - * empty here, but you can set it to something different here to override - * that if you desire. - * - * @var unknown - * @access protected - */ - protected $siteName; - - /** - * Email subject and

header in email - * - * It gets set in the constructor if you leave empty here, but you - * can set it to something different here to override that if you desire. - * - * @var string - * @access protected - */ - protected $subject = 'New Event Submission'; - - /** - * Message to display if the form is successfully submitted - * - * @var string - * @access protected - */ - protected $successMsg = ' - -
- Your event has been successfully added to the events calendar, - however will not be visible until it has been approved by - the Web site administrator. Thank You. -
'; - - /** - * Extra rules for processesing - * - * This registers the Zip validation rules (and any others listed) for - * QuickForm. - * - * Zip validation checks both US and Canadian Zip codes - * - * @var array - * @access protected - */ - protected $registeredRules = array( - 'phone', - array( - 'checkEmail', - 'callback', - 'email', - 'Validate' - ), - array( - 'checkURI', - 'callback', - 'uri', - 'Validate' - ) - ); - - /** - * Options for flexy templating engine - * - * Pulls the preset options from the setup.phtml file - * overwrites the templateDir and compileDir to match this classes needs - * - * @var array - * @access protected - */ - protected $flexyOptions; - - /** - * Class constructor - * - * @param PDO $pdo PHP Data Object - * @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
tag - * @param bool $trackSubmit (optional)Whether to track if the form was - * submitted by adding a special hidden field - * - * @access public - */ - public function __construct( - PDO $pdo, - $formName, - $method = 'post', - $action = '', - $target = '', - $attributes = null, - $trackSubmit = false - ) { - parent::__construct( - $formName, $method, $action, $target, $attributes, $trackSubmit - ); - - $this->dbh = $pdo; - - if ($this->email !== false && empty($this->email)) { - // Set to false to turn off email function. - $this->email = OWNER_EMAIL; - } - if (empty($this->siteName)) { - $this->siteName = SITENAME; - } - if (empty($this->subject)) { - $this->subject = 'Contact Request from website ' . SITENAME; - } - - $this->flexyOptions = $GLOBALS['flexyOptions']; - $this->flexyOptions['templateDir'] = dirname(__FILE__) . "/templates/"; - $this->flexyOptions['compileDir'] - = dirname(__FILE__) . "/templates/compiled/"; - - $var = basename(__FILE__, '.php'); - - $callbackUrl = ($_SERVER['HTTPS'] == 'on') - ? - BASE_SECURE_URL - : MEDIA_BASE_URL; - - $this->captchaOptions = array( - 'width' => 100, - 'height' => 50, - 'callback' => "{$callbackUrl}Toolkit/qfcaptcha.php?var=$var", - 'sessionVar' => $var, - 'imageOptions' => array( - 'font_size' => 16, - 'font_path' => GLM_APP_BASE . 'glmPEAR/Image/Canvas/Fonts/', - 'font_file' => 'times.ttf', - 'background_color' => '#cccccc', - 'obfuscation' => false, - 'angle' => true, - ), - ); - } - - /** - * Get the array of members used for the select list - * - * @param PDO $dbh Database handler - * - * @return array members used to populate a select list element - * @access protected - */ - private function _getMembers(PDO $dbh) - { - // Get only the active members from - $sql = " - SELECT * - FROM member - ORDER BY member_name"; - - $members = array(); - try { - foreach ($dbh->query($sql, PDO::FETCH_ASSOC) as $row) { - $members[$row['member_id']] = $row['member_name']; - } - } catch (PDOException $e) { - Toolkit_Common::handleError($e); - } - - return $members; - } - - /** - * Validate date input - * - * allows for empty dates to be valid - * - * @param array $date date group from form - * - * @return boolean true if valid, false if not - * @access public - */ - public function checkDate($date) - { - if (!$date) { - return true; - } else { - return Validate::date($date, array('format' => '%m/%d/%Y')); - } - } - - /** - * Validate date input - * - * allows for empty end date to be valid - * - * @param array $d date group from form - * - * @return boolean true if valid, false if not - * @access public - */ - public function checkDateRange(array $d) - { - if (!$this->hasEndDate($d[1])) { - // no end date is a valid date range - return true; - } - $pattern = '/([0-9]{2})\/([0-9]{2})\/([0-9]{4})/'; - if (preg_match($pattern, $d[0], $m)) { - $t1 = mktime(0, 0, 0, (int) $m[1], (int) $m[2], (int) $m[3]); - $bdate = new Date($t1); - } - if (preg_match($pattern, $d[1], $m)) { - $t2 = mktime(0, 0, 0, (int) $m[1], (int) $m[2], (int) $m[3]); - $edate = new Date($t2); - } - if ($bdate && $edate) { - // 0 if the dates are equal - valid - // -1 if $bdate is before $edate - valid - // 1 if $bdate is after $edate - invalid - $res = Date::compare($bdate, $edate); - return ($res !== 1); - } - return true; - } - - /** - * Form element definitions - * - * @param PDO $dbh Database handle - * - * @return void - * @access public - */ - public function configureElements(PDO $dbh) - { - $e = array(); - if (defined('MEMBERS_DB') && MEMBERS_DB) { - $members = $this->_getMembers($dbh); - $conf = new Config; - $memberDbListingType = & $conf->parseConfig( - BASE . 'Toolkit/Members/config.ini', 'IniFile' - )->getItem('section', 'listing type') - ->getItem('directive', 'singular') - ->getContent(); - } - - // All Elements are created here. This includes group element definitions. - $e[] = array( - 'type' => 'header', - 'name' => 'eventInfoHeader_rmv', - 'display' => 'Event Information' - ); - $e[] = array( - 'type' => 'text', - 'req' => true, - 'name' => 'header', - 'display' => 'Event Name' - ); - $e[] = array( - 'type' => 'select', - 'req' => false, - 'name' => 'topicid', - 'display' => 'Category', - 'opts' => $this->getTopicFields(), - ); - $e[] = array( - 'type' => 'hidden', - 'req' => false, - 'name' => 'id' - ); - $e[] = array( - 'type' => 'hidden', - 'req' => false, - 'name' => 'oldVisable' - ); - $e[] = array( - 'type' => 'advcheckbox', - 'req' => false, - 'name' => 'visable', - 'display' => 'Active?', - 'opts' => 'Yes', - 'val' => array(0, 1) - ); - if (defined('MEMBERS_DB') && MEMBERS_DB) { - $e[] = array( - 'type' => 'select', - 'req' => false, - 'name' => 'member_id', - 'display' => $memberDbListingType, - 'opts' => array('' => '-- Select --') + $members - ); - $e[] = array( - 'type' => 'hidden', - 'req' => false, - 'name' => 'pending', - ); - } - $e[] = array( - 'type' => 'text', - 'req' => true, - 'name' => 'bdate', - 'display' => 'Start Date', - 'opts' => array('id' => 'sdate') - ); - $e[] = array( - 'type' => 'text', - 'req' => true, - 'name' => 'edate', - 'display' => 'End Date', - 'opts' => array('id' => 'edate') - ); - $e[] = array( - 'type' => 'advcheckbox', - 'req' => false, - 'name' => 'all_day', - 'display' => 'All Day Event?', - 'opts' => 'Yes', - 'val' => array(0, 1) - ); - $e[] = array( - 'type' => 'date', - 'req' => false, - 'name' => 'btime', - 'display' => 'Start Time', - 'opts' => array( - 'format' => 'h : i A', - 'addEmptyOption' => true, - 'emptyOptionValue' => '', - 'emptyOptionText' => array( - 'h' => 'hh', - 'i' => 'mm', - 'A' => 'am/pm' - ), - 'optionIncrement' => array( - 'i' => 15, - ), - ), - 'error' => 'ERROR: You must select a start time!', - ); - $e[] = array( - 'type' => 'date', - 'req' => false, - 'name' => 'etime', - 'display' => 'End Time', - 'opts' => array( - 'format' => 'h : i A', - 'addEmptyOption' => true, - 'emptyOptionValue' => '', - 'emptyOptionText' => array( - 'h' => 'hh', - 'i' => 'mm', - 'A' => 'am/pm' - ), - 'optionIncrement' => array( - 'i' => 15, - ), - ), - ); - $e[] = array( - 'type' => 'advcheckbox', - 'req' => false, - 'name' => 'reacur', - 'display' => 'Recurring Event', - 'opts' => 'Is this a recurring event?', - 'val' => array(0, 1) - ); - $daysOm = array('' => ''); - for ($i = 1; $i <= 31; ++$i) { - $daysOm[$i] = $i; - } - $e[] = array( - 'type' => 'select', - 'name' => 'dayom', - 'display' => 'Every Month on', - 'opts' => $daysOm - ); - $e[] = array( - 'type' => 'select', - 'req' => false, - 'name' => 'weekom', - 'display' => 'Recurs', - 'opts' => array( - '' => 'Every Week of Month', - '9' => 'Every Other Week', - '1' => 'Every First Week of Month', - '2' => 'Every Second Week of Month', - '3' => 'Every Third Week of Month', - '4' => 'Every Fourth Week of Month' - ), - ); - $weekdays = array( - 1 => 'Sunday', - 'Monday', - 'Tuesday', - 'Wednesday', - 'Thursday', - 'Friday', - 'Saturday' - ); - $ri = 1; - for ($i = 1; $i <= 7; ++$i) { - $daysOw[] = array( - 'type' => 'advcheckbox', - 'req' => false, - 'name' => $i, - 'opts' => $weekdays[$i], - 'val' => array('', $ri) - ); - $ri = $ri << 1; - } - $e[] = array( - 'type' => 'group', - 'req' => false, - 'name' => 'daysow', - 'group' => $daysOw, - 'label' => 'Days Of Week', - 'seperator' => ' ', - 'appendName' => true - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'url', - 'display' => 'Website' - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'cost', - 'display' => 'Cost' - ); - $e[] = array( - 'type' => 'static', - 'req' => false, - 'name' => 'current_img_rmv', - 'display' => 'Current Image' - ); - $e[] = array( - 'type' => 'hidden', - 'req' => false, - 'name' => 'img' - ); - $e[] = array( - 'type' => 'file', - 'req' => false, - 'name' => 'img_file_rmv', - 'display' => 'Event Image' - ); - $e[] = array( - 'type' => 'static', - 'req' => false, - 'name' => 'img_instructions_rmv', - 'opts' => '.jpg or .gif images only' - ); - $e[] = array( - 'type' => 'textarea', - 'req' => false, - 'name' => 'descr', - 'display' => 'Description', - 'opts' => array('id' => 'descr'), - 'noCharLimit' => true - ); - $e[] = array( - 'type' => 'header', - 'name' => 'eventLocationInfoHeader_rmv', - 'display' => 'Event Location Information -
-
-
- Map It' - ); - $e[] = array( - 'type' => 'advcheckbox', - 'req' => false, - 'name' => 'hide_address', - 'display' => 'Hide Event Address', - 'opts' => 'Yes', - 'val' => array(0, 1) - ); - $e[] = array( - 'type' => 'hidden', - 'req' => false, - 'name' => 'lat', - 'opts' => array('id' => 'lat') - ); - $e[] = array( - 'type' => 'hidden', - 'req' => false, - 'name' => 'lon', - 'opts' => array('id' => 'lon') - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'loc', - 'display' => 'Place' - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'address', - 'display' => 'Address', - 'opts' => array('id' => 'address') - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'city', - 'display' => 'City', - 'opts' => array('id' => 'city') - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'state', - 'display' => 'State', - 'opts' => array('id' => 'state') - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'zip', - 'display' => 'ZIP', - 'opts' => array('id' => 'zip') - ); - $e[] = array( - 'type' => 'header', - 'name' => 'eventContactHeader_rmv', - 'display' => 'Event Contact Information' - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'contact', - 'display' => 'Contact Person' - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'email', - 'display' => 'Contact Email' - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'phone', - 'display' => 'Contact Phone' - ); - $e[] = array( - 'type' => 'static', - 'req' => false, - 'name' => 'current_file_rmv', - 'display' => 'Current File' - ); - $e[] = array( - 'type' => 'hidden', - 'req' => false, - 'name' => 'file' - ); - $e[] = array( - 'type' => 'file', - 'req' => false, - 'name' => 'file_rmv', - 'display' => 'Event File' - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'filename', - 'display' => 'File Name' - ); - $e[] = array( - 'type' => 'header', - 'name' => 'eventInfoHeader_rmv', - 'display' => 'Event Admin Information' - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'admin_contact_name', - 'display' => 'Contact Name Submitting Event' - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'admin_org_name', - 'display' => 'Organization Name Submitting Event' - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'admin_phone', - 'display' => 'Phone' - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'admin_email', - 'display' => 'Email Address' - ); - $e[] = array( - 'type' => 'textarea', - 'req' => false, - 'name' => 'notes', - 'display' => 'Notes' - ); - if ($_REQUEST['id']) { - $e[] = array( - 'type' => 'static', - 'req' => false, - 'name' => 'create_date', - 'display' => 'Create Date' - ); - $e[] = array( - 'type' => 'static', - 'req' => false, - 'name' => 'approved_date', - 'display' => 'Approved Date' - ); - } - $e[] = array( - 'type' => 'submit', - 'req' => false, - 'name' => 'submit_rmv', - 'display' => 'Submit' - ); - - $this->setupElements($e); - } - - /** - * 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' - ); - $f[] = array( - 'element' => 'url', - 'filter' => array('Toolkit_Common', 'filterURI') - ); - - $this->setupFilters($f); - } - - /** - * Helper function to handle setting up the form - * - * @param PDO $dbh PDO database connection - * - * @return void - * @access public - */ - public function configureForm(PDO $dbh) - { - $this->configureElements($dbh); - $this->configureDefaults(); - $this->configureFilters(); - $this->configureRules(); - } - - /** - * Form rule definitions - * - * Adds validation rules for the given fields - * - * @return void - * @access public - */ - public function configureRules() - { - // Form Rules - $r = array(); - - $mimeTypes = array( - 'image/jpe', - 'image/jpeg', - 'image/jpg', - 'image/jfif', - 'image/pjpeg', - 'image/pjp', - 'image/gif', - 'image/png', - 'image/x-png', - ); - - $r[] = array( - 'element' => 'topicid', - 'message' => 'ERROR: Invalid Category!', - 'type' => 'numeric', - 'format' => null, - 'validation' => $this->validationType, - 'reset' => true, - 'force' => false - ); - $r[] = array( - 'element' => 'email', - 'message' => 'ERROR: Invalid Email Format!', - 'type' => 'checkEmail', - 'format' => array('use_rfc822' => true), - 'validation' => $this->validationType, - 'reset' => true, - 'force' => false - ); - $r[] = array( - 'element' => array('bdate', 'edate'), - 'message' => 'ERROR: Starting Date must be before Ending Date', - 'type' => 'callback', - 'format' => array(&$this, 'checkDateRange'), - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $r[] = array( - 'element' => 'bdate', - 'message' => 'ERROR: Invalid date!', - 'type' => 'callback', - 'format' => array(&$this, 'checkDate'), - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $r[] = array( - 'element' => 'edate', - 'message' => 'ERROR: Invalid date!', - 'type' => 'callback', - 'format' => array(&$this, 'checkDate'), - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $r[] = array( - 'element' => 'url', - 'message' => 'ERROR: Invalid URL format', - 'type' => 'checkURI', - 'format' => array( - 'allowed_schemes' => array('http', 'https'), - 'strict' => false - ), - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - if ($this->useCaptcha) { - $r[] = array( - 'element' => 'captcha_rmv', - 'message' => 'ERROR: What you entered didn\'t match!', - 'type' => 'CAPTCHA', - 'format' => $this->captchaQuestion, - 'validation' => $this->validationType, - 'reset' => true, - 'force' => false - ); - } - if (is_uploaded_file($_FILES['img_file_rmv']['tmp_name'])) { - $r[] = array( - 'element' => 'img_file_rmv', - 'message' => 'ERROR: Incorrect File Type (.gif, .png, .jpg) only!', - 'type' => 'mimetype', - 'format' => $mimeTypes, - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - } - $r[] = array( - 'element' => 'img_file_rmv', - 'message' => 'ERROR: Error uploading image!', - 'type' => 'Image', - 'format' => array( - 'form' => $this, - 'fieldName' => 'img_file_rmv', - 'imageField' => 'img', - 'is' => new Toolkit_FileServer_ImageAdapter(), - 'deleteExistingImage' => false, - 'injectImage' => array('tgtElement' => 'current_img_rmv') - ), - 'validation' => 'server', - 'reset' => false, - 'force' => false - ); - - $this->setupRules($r); - } - - /** - * Form defaults - * - * @return void - * @access public - */ - public function configureDefaults() - { - if (ctype_digit($_GET['id'])) { - $sql = " - SELECT * - FROM event - WHERE id = :id"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(":id", $_GET['id'], PDO::PARAM_INT); - $stmt->execute(); - $d = $stmt->fetch(PDO::FETCH_ASSOC); - $d['current_file_rmv'] - = ($d['file']) - ? ' - ' . $d['file'] . ' - - Delete File?' - : 'File not yet uploaded'; - $d['current_img_rmv'] - = ($d['img']) - ? ' - - Delete Image?' - : 'Image not yet uploaded'; - $ri = 1; - for ($r = 1; $r <= 7; ++$r) { - if ($d['daysow'] & $ri) { - $daysow[$r] = $ri; - } - $ri = $ri << 1; - } - $d['daysow'] = $daysow; - $d['oldVisable'] = $d['visable']; - } else { - $d['current_img_rmv'] = 'Image not yet uploaded'; - $d['current_file_rmv'] = 'File not yet uploaded'; - } - $this->setupDefaults($d); - } - - /** - * get event topics - * - * @return array topics - * @access protected - */ - protected function getTopicFields() - { - try { - $sql = " - SELECT * - FROM topic - ORDER BY descr"; - - $topics = array('' => '-- Select --'); - foreach ($this->dbh->query($sql) as $row) { - $topics[$row['id']] = $row['descr']; - } - - return $topics; - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } - - /** - * verifies if we have a valid end date to work with - * - * @param string $d end date - * - * @return boolean if the end date is - */ - protected function hasEndDate($d) - { - $pattern = '/([0-9]{2})\/([0-9]{2})\/([0-9]{4})/'; - if (preg_match($pattern, $d, $m)) { - return checkdate((int) $m[1], (int) $m[2], (int) $m[3]); - } else { - return false; - } - } - - /** - * Format an array into an acceptable string - * - * @param mixed &$i array values to format or null value for - * element that was not filled in - * @param string $format string to format values into - * - * @return string formatted string - * @access public - */ - public function formatValue(&$i, $format) - { - // Allow for 0 to be not empty. This allows for minutes in the - // time arrays to be valid if they are on the hour ie. (1:00 pm) - $notEmpty = create_function('$v', 'return strlen($v) > 0;'); - if (is_array($i) && count(array_filter($i, $notEmpty)) == 3) { - list($x, $y, $z) = array_values($i); - eval("\$i = sprintf('$format', $x, $y, $z);"); - } else { - $i = null; - } - } - - /** - * Inserts contact data into the contact db - * - * @param array $values submitted values - * - * @return object result of db insert query - * @access protected - */ - protected function insertData($values) - { - $values = $this->_geocode($values); - - try { - // need to set the dates up first - unset($values['id'], $values['oldVisable']); - $values['visable'] = 1; - $sql = Toolkit_Common::createSQLInsert( - $this->tableName, array_keys($values) - ); - $sql .= " RETURNING id"; - $stmt = Toolkit_Common::prepareQuery( - $this->dbh, $this->tableName, $sql, $values - ); - $stmt->execute(); - return $stmt->fetchColumn(); - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } - - /** - * Handles how to process the form when submitted - * - * @param array $values Form submitted values - * - * @return boolean|void Result of Insert / Update function - * @access public - */ - public function processData($values) - { - // Form data used for the insert/update sql queries and - // the form email. - $e = array(); - $this->setFormData($e); - - unset( - $values['MAX_FILE_SIZE'], $values['pending'], $values['archived'] - ); - if ($values['del_img_rmv'] && $values['img']) { - $is = new Toolkit_Image_Server(); - $is->imageDelete($values['img']); - $values['img'] = ''; - } - if ($values['del_file_rmv'] && $values['file']) { - $is = new Toolkit_Image_Server(); - $is->imageDelete($values['file']); - $values['file'] = ''; - } - if ($values['file_rmv']['name']) { - $fs = new Toolkit_FileServer_FileAdapter(); - try { - $res = $fs->upload('file_rmv'); - } catch (Toolkit_FileServer_Exception $e) { - Toolkit_Logger::logException('File Server', $e); - echo -1; - return; - } - $values['file'] = $res['name']; - } - - // Get rid of any defined un-needed elements. - // un-needed elements after the form is submitted are defined - // by the ending _rmv name. - foreach ($values as $k => &$v) { - if (!is_array($v)) { - $values[$k] = str_replace("\r", "", $v); - } - if (preg_match('/^.+_rmv$/', $k)) { - unset($values[$k]); - } - } - $values['url'] = preg_replace("/^(http:\/\/)/", "", $values['url']); - if ($values['reacur']) { - if ($values['dayom']) { - $values['weekom'] = null; - $values['daysow'] = null; - } else { - $values['dayom'] = null; - $values['daysow'] = array_sum($values['daysow']); - } - } else { - $values['dayom'] = null; - $values['weekom'] = null; - $values['daysow'] = null; - } - if (defined('MEMBERS_DB') - && MEMBERS_DB - && !$values['member_id'] - ) { - $values['member_id'] = null; - } - if (!$values['topicid']) { - $values['topicid'] = null; - } - $bdate = $values['bdate']; - $edate = $values['edate']; - // still need to reformat the time fields - $this->formatValue($values['btime'], '%02d:%02d %s'); - $this->formatValue($values['etime'], '%02d:%02d %s'); - if ($values['reacur']) { - $recur['dow'] = $values['daysow']; - $recur['dom'] = $values['dayom']; - if ($recur['dow']) { - $recur['recur_week'] = ($values['weekom']) - ? $values['weekom'] - : null; - } else { - $recur['recur_week'] = null; - } - } - $eventId = $_REQUEST['id']; - if (ctype_digit($eventId)) { - $this->updateData($values); - } else { - $eventId = $this->insertData($values); - } - $this->insertEventRecur($bdate, $edate, $eventId, $recur); - return true; - } - - /** - * Custom rendering templates for special fields on the form - * - * @return void - * @access protected - */ - protected function setupRenderers() - { - parent::setupRenderers(); - $renderer = & $this->defaultRenderer(); - $required = '* - '; - $error = '
{error}
- '; - $recurTmpl = ' - ' . $required . ' - ' . $error . '{element}'; - $renderer->setElementTemplate($recurTmpl, 'dayom'); - $renderer->setElementTemplate($recurTmpl, 'weekom'); - $renderer->setElementTemplate($recurTmpl, 'daysow'); - $renderer->setElementTemplate( - '' . $required . '{label}' - . $error . '{element}', 'descr' - ); - $renderer->setElementTemplate( - '' - . $required . '{label}' . $error . '{element}', 'submit_rmv' - ); - } - - /** - * Handles how to display the current step the user is at in the form - * - * destroying and resetting the captcha value dis-allows someone from - * re-sending a form on a previous captcha. - * - * @return string form HTML state - * @access public - */ - public function toHtml() - { - $GLOBALS['topScripts'][] - = MEDIA_APP_BASE_URL - . 'libjs/jqueryui/1.8.13/js/jquery-ui-1.8.13.custom.min.js'; - $GLOBALS['topScripts'][] = CKEDITOR_JS . ''; - $GLOBALS['styleSheets'][] - = MEDIA_APP_BASE_URL - . 'libjs/jqueryui/1.8.13/development-bundle/themes/base/jquery.ui.all.css'; - $this->setupRenderers(); - if ($this->validate()) { - $this->cleanForm(); - if ($this->process(array(&$this, 'processData'), $this->mergeFiles)) { - $this->freeze(); - $output = $this->successMsg; - $pageUrl - = MEDIA_BASE_URL . 'admin/Events/list_events.phtml'; - $params = array(); - if ($_GET['archived']) { - $params[] = 'archived=' . $_GET['archived']; - } - if ($_GET['pending']) { - $params[] = 'pending=' . $_GET['pending']; - } - if ($_GET['start']) { - $params[] = 'start=' . $_GET['start']; - } - if ($_GET['Query']) { - $params[] = 'Query=' . urlencode($_GET['Query']); - } - if ($_GET['date_search_to']) { - $params[] = 'date_search_to=' . $_GET['date_search_to']; - } - if ($_GET['date_search_from']) { - $params[] = 'date_search_from=' . $_GET['date_search_from']; - } - if (!empty($params)) { - $pageUrl - .= '?' - . implode('&', $params); - } - header('Location: ' . $pageUrl); - exit; - } - $this->sent = true; - } elseif ($this->isSubmitted()) { - $output = $this->errorMsg; - //$GLOBALS['bottomScripts'][] = MEDIA_APP_BASE_URL . 'libjs/textlimit.js'; - $GLOBALS['bottomScripts'][] - = MEDIA_BASE_URL . 'Toolkit/Events/libjs/edit-event.js'; - $GLOBALS['topScripts'][] - = 'http://maps.googleapis.com/maps/api/js?sensor=true'; - $GLOBALS['bottomScripts'][] - = MEDIA_BASE_URL . 'Toolkit/Maps/geoCoder.js'; - $output .= parent::toHtml(); - } else { - //$GLOBALS['bottomScripts'][] = MEDIA_APP_BASE_URL . 'libjs/textlimit.js'; - $GLOBALS['topScripts'][] - = 'http://maps.googleapis.com/maps/api/js?sensor=true'; - $GLOBALS['bottomScripts'][] - = MEDIA_BASE_URL . 'Toolkit/Maps/geoCoder.js'; - $GLOBALS['bottomScripts'][] - = MEDIA_BASE_URL . 'Toolkit/Events/libjs/edit-event.js'; - $output = parent::toHtml(); - } - return $output; - } - - /** - * check to see if the address (old on) is different than the one submitted - * if the event is not found then return false - * - * @param array $values The submitted values for the edit event form - * - * @return boolean - */ - private function _didAddressChange($values) - { - $didAddressChange = false; - if (!$values['id'] && !ctype_digit($values['id'])) { - return $didAddressChange; - } - try { - $sql = " - SELECT address,city,state,zip - FROM event - WHERE id = :id"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':id', $values['id'], PDO::PARAM_INT); - $stmt->execute(); - $address = $stmt->fetch(PDO::FETCH_ASSOC); - if (!$address) { - return $didAddressChange; - } else { - if ($address['address'] != $values['address']) { - $didAddressChange = true; - } - if ($address['city'] != $values['city']) { - $didAddressChange = true; - } - if ($address['state'] != $values['state']) { - $didAddressChange = true; - } - if ($address['zip'] != $values['zip']) { - $didAddressChange = true; - } - } - } catch(PDOException $e) { - Toolkit_Common::handleError($e); - } - return $didAddressChange; - } - /** - * Check to see if the Lat Lon data changed from submittion - * - * @param array $values Form Values - * - * @return boolean - */ - private function _didLatLonChange($values) - { - $didLatLonChange = false; - if (!$values['id'] && !ctype_digit($values['id'])) { - return $didLatLonChange; - } - try { - $sql = " - SELECT lat,lon - FROM event - WHERE id = :id"; - $stmt = $this->dbh->prepare($sql); - $stmt->bindParam(':id', $values['id'], PDO::PARAM_INT); - $stmt->execute(); - $location = $stmt->fetch(PDO::FETCH_ASSOC); - if (!$location) { - return $didLatLonChange; - } else { - if ($location['lat'] != $values['lat']) { - $didLatLonChange = true; - } - if ($location['lon'] != $values['lon']) { - $didLatLonChange = true; - } - } - } catch(PDOException $e) { - Toolkit_Common::handleError($e); - } - return $didLatLonChange; - } - - /** - * Updates contact data in the contact db - * - * @param array $values submitted values - * - * @return object result of db insert query - * @access protected - */ - protected function updateData($values) - { - if (!$values['oldVisable'] && $values['visable']) { - $values['approved_date'] = date('m/d/Y'); - } - unset($values['oldVisable']); - try { - // if the address changes then get the lat lon - if ( (!$this->_didLatLonChange($values) - && $this->_didAddressChange($values)) - || (!$values['lat'] && !$values['lon']) - ) { - $values = $this->_geocode($values); - } - - $sql = Toolkit_Common::createSQLUpdate( - $this->tableName, array_keys($values), array('id = :id') - ); - - return Toolkit_Common::processQuery( - $this->dbh, $this->tableName, $sql, $values - ); - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } - - private function _geocode(array $values) - { - $geocoder = new GeocodeYahoo(); - if (!$values['address'] && !$values['city'] && !$values['state']) { - return $values; - } - $address = array( - 'city' => $values['city'], - 'state' => $values['state'], - 'zip' => $values['zip'], - ); - if (!empty($values['address'])) { - $address['street'] = $values['address']; - } - try { - $response = $geocoder->geocodeAddress($address); - $responseArray = unserialize($response); - if ($responseArray['ResultSet']['Result'][0]['Latitude']) { - $values['lat'] = $responseArray['ResultSet']['Result'][0]['Latitude']; - $values['lon'] = $responseArray['ResultSet']['Result'][0]['Longitude']; - } else { - $values['lat'] = $responseArray['ResultSet']['Result']['Latitude']; - $values['lon'] = $responseArray['ResultSet']['Result']['Longitude']; - } - - return $values; - } catch (BadMethodCallException $e) { - Toolkit_Logger::logException('Invalid Arg', $e); - } catch (Exception $e) { - Toolkit_Logger::logException('Yahoo GeoCode', $e); - } - return $values; - - } - - /** - * ordinalDay - * - * @param int $ord The ordinal 1st 2nd 3rd - * @param int $day day of the month - * @param int $month month of year - * @param int $year year - * - * @access public - * @return int - */ - function ordinalDay($ord, $day, $month, $year) - { - $firstOfMonth = mktime(0, 0, 30, $month, 1, $year); - $lastOfMonth = $firstOfMonth + date("t", $firstOfMonth) * 86400; - $dayOccurs = 0; - - for ($i = $firstOfMonth; $i < $lastOfMonth; $i += 86400) { - if (date("w", $i) == $day) { - $dayOccurs++; - if ($dayOccurs == $ord) { - $ordDay = $i; - } - } - } - return $ordDay; - } - - /** - * getEventDates - * - * @param mixed $starttime Timestamp for start - * @param mixed $endtime Timestamp for end - * @param array $recur recur array which has dow,dom,recur_week - * @param string $format date format to use - * - * @access public - * @return void|array - */ - - function getEventDates($starttime, $endtime, $recur, $format = 'm/d/Y') - { - if (!is_array($recur)) { - return; - } - if ($starttime == $endtime) { - return; - } - if (is_array($recur['dow'])) { - $daysow = array_sum($recur['dow']); - } else { - $daysow = $recur['dow']; - } - if ($recur['recur_week'] == 9) { - $fWeekNum = date("W", $starttime); - if (date('w', $starttime) == 0) { - $fWeekNum++; - } - $lWeekNum = date("W", $endtime); - if (date('w', $endtime) == 0) { - $lWeekNum++; - } - for ($fi = $fWeekNum; $fi <= $lWeekNum; $fi = $fi + 2) { - $eWeeks[] = $fi; - } - } - for ($i = $starttime; $i <= $endtime; $i += 86400) { - if ($recur['recur_week'] != '') { - if ($daysow) { - $ri = 1; - for ($r = 0; $r < 7; $r++) { - if ($daysow & $ri) { - $ord = $this->ordinalDay($recur['recur_week'], $r, date('n', $i), date('Y', $i)); - } - $ri = $ri << 1; - } - } else { - $ord = null; - } - } else { - $ord = null; - } - if ($recur['dom']) { - if (date("j", $i) == $recur['dom']) { - $events[] = date($format, $i); - } - } elseif ($daysow) { - $cur_dow = date("w", $i); - switch ($cur_dow) { - case 0: - $cur_dow = 1; - break; - case 1: - $cur_dow = 2; - break; - case 2: - $cur_dow = 4; - break; - case 3: - $cur_dow = 8; - break; - case 4: - $cur_dow = 16; - break; - case 5: - $cur_dow = 32; - break; - case 6: - $cur_dow = 64; - break; - } - if ((int) $cur_dow & $daysow) { - $cDateWeek = date("W", $i); - if (date('w', $i) == 0) { - $cDateWeek++; - } - if ($recur['recur_week'] == 9) { - if (in_array($cDateWeek, $eWeeks)) { - $events[] = date($format, $i); - } - } elseif ($recur['recur_week'] != '') { - if ($recur['recur_week'] && $i && $ord) { - $day1 = date('z', $i); - $day2 = date('z', $ord); - if ($day1 == $day2) { - $events[] = date($format, $i); - } - } - } else { - $events[] = date($format, $i); - } - } - } - } - return $events; - } - - /** - * insertEventRecur - * - * @param array $bdate start date - * @param array $edate end date - * @param int $event_id Event's id - * @param array $recur recur array - * - * @access public - * @return void - */ - - function insertEventRecur($bdate, $edate, $event_id, $recur) - { - try { - $sql = " - DELETE - FROM event_recur - WHERE event_id = :event_id"; - $del = $this->dbh->prepare($sql); - $del->bindParam(":event_id", $event_id, PDO::PARAM_INT); - $del->execute(); - } catch (PDOException $e) { - die($e->getMessage()); - } - - if (isset($recur) && is_array($recur)) { - $eventDates = $this->getEventDates( - strtotime($bdate), - strtotime($edate), - $recur - ); - $fields = array('event_id', 'event_day'); - $sql = Toolkit_Common::createSQLInsert( - 'event_recur', $fields - ); - try { - if (isset($eventDates) && is_array($eventDates)) { - foreach ($eventDates as $eventDay) { - $eventValues = array( - 'event_id' => $event_id, - 'event_day' => $eventDay - ); - $stmt = Toolkit_Common::prepareQuery( - $this->dbh, 'event_recur', $sql, $eventValues - ); - $stmt->execute(); - } - } - } catch (PDOException $e) { - Toolkit_Common::handleError($e); - } - } - } - -} diff --git a/Toolkit/Events/Forms/Admin/EditTopics.php b/Toolkit/Events/Forms/Admin/EditTopics.php deleted file mode 100644 index 0957758..0000000 --- a/Toolkit/Events/Forms/Admin/EditTopics.php +++ /dev/null @@ -1,164 +0,0 @@ - - * @copyright 2010 Steve Sutton - * @license Gaslight Media - * @version CVS: $Id:$ - * @link http://pear.php.net/package/Toolkit_Events - * @see References to other sections (if any)... - */ - -/** - * Handles editing of topics - * - * Long description (if any) ... - * - * @category Toolkit - * @package Events - * @author Steve Sutton - * @copyright 2010 Steve Sutton - * @license Gaslight Media - * @version Release: @package_version@ - * @link http://pear.php.net/package/Toolkit_Events - * @see References to other sections (if any)... - */ -class Toolkit_Events_Forms_Admin_EditTopics -{ - - /** - * Description of $_flexyOptions - * @var array - * @access private - */ - private $_flexyOptions; - - /** - * Description of $_templateFile - * @var string - * @access private - */ - private $_templateFile = 'editTopics.html'; - - /** - * Class constructor - * - * @param PDO $pdo Parameter description (if any) ... - * - * @access public - */ - public function __construct(PDO $pdo) - { - $this->dbh = $pdo; - $this->_flexyOptions = array( - 'templateDir' => BASE . 'Toolkit/Events/templates', - 'compileDir' => BASE . 'Toolkit/Events/templates/compiled', - 'flexyIgnore' => true, - 'allowPHP' => true - ); - } - - /** - * Returns the form itself in html - * - * Long description (if any) ... - * - * @return string Return description (if any) ... - * @access public - */ - public function toHtml() - { - if ($_POST['Action']) { - $this->topicAction(); - } - $GLOBALS['bottomScripts'][] - = MEDIA_BASE_URL . 'Toolkit/Events/libjs/edit-topic.js'; - $GLOBALS['styleSheets'][] - = MEDIA_BASE_URL . 'Toolkit/Events/css/edit-topic.css'; - $template = new HTML_Template_Flexy($this->_flexyOptions); - $page = new stdClass; - $sql = " - SELECT id,descr,topiccolor - FROM topic - ORDER BY descr"; - $page->data = $this->dbh->query($sql)->fetchAll(PDO::FETCH_ASSOC); - $page->topic_action_page = MEDIA_BASE_URL . 'admin/Events/editTopics.php'; - $template->compile($this->_templateFile); - return $template->bufferedOutputObject($page); - } - - /** - * Takes a selected action on a topic - * - * Long description (if any) ... - * - * @return boolean Return description (if any) ... - * @access protected - */ - protected function topicAction() - { - $args = array( - 'id' => FILTER_VALIDATE_INT, - 'descr' => FILTER_SANITIZE_STRING, - 'topiccolor' => FILTER_SANITIZE_STRING, - 'topic' => FILTER_SANITIZE_STRING - ); - $myInputs = filter_input_array(INPUT_POST, $args); - extract($myInputs); - switch ($_REQUEST['Action']) { - case "Add Topic" : - $query = " - SELECT id - FROM topic - WHERE descr = :topic"; - $stmt = $this->dbh->prepare($query); - $stmt->bindParam(':topic', $topic); - - if (!$data = $stmt->fetchAll(PDO::FETCH_ASSOC)) { - $query = " - INSERT INTO topic - (descr) - VALUES - (:topic);"; - $insert = $this->dbh->prepare($query); - $insert->bindParam(':topic', $topic); - $insert->execute(); - } - break; - - case "Delete Category" : - $sql = " - DELETE - FROM topic - WHERE id = :id"; - $delete = $this->dbh->prepare($sql); - $delete->bindParam(':id', $id, PDO::PARAM_INT); - $delete->execute(); - break; - - case "Update Topic" : - $sql = " - UPDATE topic - SET topiccolor = :topiccolor, - descr = :descr - WHERE id = :id"; - $update = $this->dbh->prepare($sql); - $update->bindParam(':topiccolor', $topiccolor); - $update->bindParam(':descr', $descr); - $update->bindParam(':id', $id, PDO::PARAM_INT); - $update->execute(); - break; - } - return true; - } - -} diff --git a/Toolkit/Events/HomeEvents.php b/Toolkit/Events/HomeEvents.php deleted file mode 100644 index 272682a..0000000 --- a/Toolkit/Events/HomeEvents.php +++ /dev/null @@ -1,115 +0,0 @@ - - * @copyright 2012 Gaslight Media - * @license Gaslight Media - * @version SVN: (0.1) - * @link <> - */ - -/** - * Toolkit_Events_HomeEvents - * - * Generate a list of events for display on home page (featured) - * - * @category Toolkit - * @package Events - * @author Steve Sutton - * @copyright 2012 Gaslight Media - * @license Gaslight Media - * @release Release: (0.1) - * @link <> - */ -class Toolkit_Events_HomeEvents -{ - /** - * Database Connection - * @var PDO - * @access protected - */ - private $_dbh; - - /** - * Creates object of HomeEvents - * - * @param PDO $pdo Database Connection - * - * @return void - * @access public - */ - public function __construct(PDO $pdo) - { - // assign the global dbh to $this->dbh; - $this->_dbh = $pdo; - } - - /** - * grab all events flaged as home = 't' - * Home events must have images with them or they don't get picked - * - * @access public - * @return string - */ - public function getHomeEvents($onlyWithImages = true) - { - $events = array(); - $sql = " - SELECT event.id,event.img,event.header, - CASE - WHEN event.reacur THEN event_recur.event_day - ELSE event.bdate - END as event_starting_date - FROM event - LEFT OUTER JOIN event_recur - ON (event.id = event_recur.event_id) - WHERE event.visable - AND ((event.reacur AND event_recur.event_day >= current_date) - OR - (reacur is not true AND event.edate >= current_date)) - AND event.home"; - if ($onlyWithImages) { - $sql .= " - AND (img != '' AND img IS NOT NULL) - "; - } - $sql .= " - ORDER BY event_starting_date,header"; - $result = $this->_dbh->query($sql); - Zend_Date::setOptions(array('format_type' => 'php')); - while ($row = $result->fetch()) { - $eventDateUsed = new Zend_Date( - strtotime($row['event_starting_date']), - Zend_Date::TIMESTAMP - ); - $hrefFormat - = 'events/%d/%d/'; - $href = MEDIA_BASE_URL . sprintf( - $hrefFormat, - EVENT_PAGE, - $row['id'] - ); - // strip out tags and add slashes to $descr - $events[] = array( - 'id' => $row['id'], - 'href' => $href, - 'bdate' => $eventDateUsed->toString('M - jS'), - 'header' => strip_tags($row['header']), - 'descr' => substr(strip_tags($row['descr']), 0, 150), - 's-img' => FILE_SERVER_URL . IS_OWNER_ID - . '/eventSlider/' . $row['img'], - 't-img' => FILE_SERVER_URL . IS_OWNER_ID - . '/eventFeaturedThumb/' . $row['img'], - 'f-img' => FILE_SERVER_URL . IS_OWNER_ID - . '/eventSlider/' . $row['img'], - ); - } - return $events; - } -} diff --git a/Toolkit/Events/ListEvents.php b/Toolkit/Events/ListEvents.php deleted file mode 100644 index ebf29f6..0000000 --- a/Toolkit/Events/ListEvents.php +++ /dev/null @@ -1,287 +0,0 @@ - - * @copyright 2010 Gaslight Media - * @license Gaslight Media - * @version CVS: $Id: ListEvents.php,v 1.5 2010/08/04 13:04:50 jamie Exp $ - * @link <> - */ - -/** - * Sub Class for listing out the events with flexy templates - * - * To use this class build the query string first then set it with - * the setQuery function then call toHtml - * - * @category Toolkit - * @package Events - * @author Steve Sutton - * @copyright 2010 Gaslight Media - * @license Gaslight Media - * @version Release: @package_version@ - * @link <> - */ -class Toolkit_Events_ListEvents - extends Toolkit_Events_Auxiliary -{ - private $_searchFor; - - public function setSearchFor(Toolkit_Events_QueryBuilder $queryBuilder) - { - $this->_searchFor = ''; - $startDate = $queryBuilder->getStartingDate(); - $endDate = $queryBuilder->getEndingDate(); - $category = $queryBuilder->getCategory($this->dbh); - $range = $queryBuilder->getT(); - if ($category) { - $this->_searchFor .= $category.' '; - } else { - $this->_searchFor .= 'All Events '; - } - if ($startDate && $endDate) { - $this->_searchFor .= "from {$startDate} to {$endDate}"; - } elseif ($startDate && !$endDate) { - $this->_searchFor .= "from {$startDate}"; - } else if ($endDate && !$startDate) { - $this->_searchFor .= "to {$endDate}"; - } - if ($range) { - $this->_searchFor = $range; - } - } - - /** - * setQuery - * - * @param mixed $sql Query string for the selection of events - * - * @access public - * @return void - */ - function setQuery($sql) - { - $this->_query = $sql; - } - - /** - * Need to sort by the header field if the date matches - * - * @param string $titleA first event header - * @param string $titleB second event header - * - * @return int - */ - public function customSortSecondLevel($titleA, $titleB) - { - if ($titleA == $titleB) { - return 0; - } - return - ($titleA < $titleB) - ? -1 - : 1; - } - - /** - * sorting function for the event data array sort by timestamp - * - * If the timestamp matches (same day) then sort by hoeader field by - * calling the - * Toolkit_Events_ListEvents::customSortSecondLevel method and returning it - * - * @param string $eventA event a - * @param string $eventB event b - * - * @return int - */ - public function customSortEvents($eventA, $eventB) - { - if ($eventA['timestamp'] == $eventB['timestamp']) { - return $this->customSortSecondLevel( - $eventA['header'], - $eventB['header'] - ); - } - return - ($eventA['timestamp'] < $eventB['timestamp']) - ? -1 - : 1; - } - - /** - * toHtml - * - * @param Toolkit_Template_KeywordReplacement $keywordReplacement Reference - * @param string $tmplFile tmpl file - * - * @access public - * @return string - */ - function toHtml( - Toolkit_Template_KeywordReplacement $keywordReplacement, - $tmplFile = 'events.html' - ) { - $template = new HTML_Template_Flexy($this->flexyOptions); - $page = new stdClass; - $page->events = $this->_getEvents($keywordReplacement); - $page->search = $this->_searchFor; - $page->uploads = UPLOADED_FILES . 'original/'; - $page->imgPathDetail = FILE_SERVER_URL . IS_OWNER_ID . '/eventDetail/'; - $page->imgPathList = FILE_SERVER_URL . IS_OWNER_ID . '/eventThumb/'; - $template->compile($tmplFile); - return $template->bufferedOutputObject($page); - } - - public function getEvents($sql) - { - $this->setQuery($sql); - $keywordReplacement = new Toolkit_Template_KeywordReplacement( - new Toolkit_Toolbox_PageGatewayPublish( - Toolkit_Database::getInstance() - ) - ); - return $this->_getEvents($keywordReplacement); - } - - /** - * Return the Events per Query - * - * @param Toolkit_Template_KeywordReplacement $keywordReplacement Reference - * - * @return array events - */ - private function _getEvents(Toolkit_Template_KeywordReplacement $keywordReplacement) - { - $data = array(); - // days array - $days[1] = "Sun"; - $days[2] = "Mon"; - $days[4] = "Tue"; - $days[8] = "Wed"; - $days[16] = "Thu"; - $days[32] = "Fri"; - $days[64] = "Sat"; - if ($this->_query) { - try { - $data = $this->dbh->query($this->_query) - ->fetchAll(PDO::FETCH_ASSOC); - if (is_array($data)) { - foreach ($data as &$row) { - $row['href'] = MEDIA_BASE_URL . "events/".EVENT_PAGE."/{$row['id']}/"; - if ($row['url'] && !preg_match('/^http:\/\/|^https:\/\//i', $row['url'])) { - $row['url'] = 'http://' . $row['url']; - } - if (is_numeric($row['region'])) { - $row['region_name'] = $regions[$row['region']]; - } - if ($row['phone']) { - $row['phone'] = Toolkit_Common::filterPhone($row['phone']); - } - if ($row['btime']) { - $timestamp = strtotime($row['bdate'].' '.$row['btime']); - $row['btime'] = date('g:i A', $timestamp); - } - if ($row['etime']) { - $timestamp = strtotime($row['bdate'].' '.$row['etime']); - $row['etime'] = date('g:i A', $timestamp); - } - $sdate = strtotime($row['bdate']); - $edate = strtotime($row['edate']); - $row['spans'] = ($sdate != $edate && !$row['reacur']); - $row['normal'] = (!$row['spans'] && !$row['reacur']); - $eventDayTimeStamp - = ($row['event_day']) - ? strtotime($row['event_day']) - : null; - $event_day - = ($row['event_day']) - ? GLM_TEMPLATE::get_event_date( - $eventDayTimeStamp, - $eventDayTimeStamp, - "timestamp" - ) - : ''; - if ($row['all_day']) { - $row['timestamp'] - = ($row['event_day']) - ? strtotime($row['event_day'].' 11:59 PM') - : strtotime($row['bdate'].' 11:59 PM'); - } else if ($row['btime']) { - $row['timestamp'] - = ($row['event_day']) - ? strtotime($row['event_day'].' '.$row['btime']) - : strtotime($row['bdate'].' '.$row['btime']); - } else if ($row['etime']) { - $row['timestamp'] - = ($row['event_day']) - ? strtotime($row['event_day'].' '.$row['etime']) - : strtotime($row['bdate'].' '.$row['etime']); - } else if ($eventDayTimeStamp) { - $row['timestamp'] - = ($eventDayTimeStamp) - ? $eventDayTimeStamp - : $sdate; - } else { - $row['timestamp'] = strtotime($row['bdate']); - } - - if ($row['descr']) { - if (!$toolbox) { - $toolbox = $GLOBALS['toolbox']; - } - $row['descr'] - = $keywordReplacement->findAndReplace($row['descr']); - } - $row['dates'] - = ($event_day && !$_REQUEST['eventid']) - ? $event_day - : GLM_TEMPLATE::get_event_date( - $sdate, - $edate, - 'timestamp' - ); - $dayRecur = array(); - if ($row['daysow']) { - $ri = 1; - for ($r=1;$r<8;$r++) { - if ($row["daysow"]&$ri) - $dayRecur[] = $days[$ri]; - $ri = $ri << 1; - } - } - if (!empty($dayRecur)) { - $row['dates'] .= ' ('.implode(', ', $dayRecur).')'; - } - $row['filename'] - = ($row['filename']) - ? $row['filename'] - : $row['file']; - $row['hasLocation'] - = ($row['loc'] - || ($row['lat'] && $row['lon']) - || $row['address']); - $row['hasLatLon'] = ($row['lat'] && $row['lon']); - $row['hasContactInfo'] - = ($row['file'] - || $row['url'] - || $row['contact'] - || $row['email'] - || $row['phone']); - } - usort($data, array($this, 'customSortEvents')); - } - } catch(PDOException $e) { - Toolkit_Common::handleError($e); - } - } - return $data; - } - -} diff --git a/Toolkit/Events/QueryBuilder.php b/Toolkit/Events/QueryBuilder.php deleted file mode 100644 index 04f61bb..0000000 --- a/Toolkit/Events/QueryBuilder.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @copyright 2012 Gaslight Media - * @license Gaslight Media - * @version SVN: (0.1) - * @link <> - */ - -/** - * Toolkit_Events_QueryBuilder - * - * Generate the Query from filtered POST and GET arrays - * - * @category Toolkit - * @package Events - * @author Steve Sutton - * @copyright 2012 Gaslight Media - * @license Gaslight Media - * @release Release: (0.1) - * @link <> - */ -class Toolkit_Events_QueryBuilder -{ - - private $_startingDate; - private $_endingDate; - private $_category; - private $_t; - - public function getStartingDate() - { - return $this->_startingDate; - } - - public function getEndingDate() - { - return $this->_endingDate; - } - - public function getT() - { - return $this->_t; - } - - public function getCategory(PDO $dbh) - { - if (!$this->_category) { - return false; - } - try { - $sql = " - SELECT descr - FROM events.topic - WHERE id = :id"; - $stmt = $dbh->prepare($sql); - $stmt->bindParam(':id', $this->_category, PDO::PARAM_INT); - $stmt->execute(); - return $stmt->fetchColumn(); - } catch (PDOException $e) { - Toolkit_Common::handleError($e); - } - } - - /** - * buildQueryNew() - * - * get the events by search criteria and show results - * - * @return mixed Return description (if any) ... - * @access public - */ - public function buildQuery() - { - $where = $this->_buildWherePart(); - // query - $sql = " - SELECT event.*,topic.descr as topicname, - event_recur.event_day - FROM event - LEFT OUTER JOIN topic - ON (topic.id = event.topicid) - LEFT OUTER JOIN event_recur - ON (event_recur.event_id = event.id)"; - if ($this->_startingDate && $this->_endingDate) { - $where[] = "((event.reacur - AND event_recur.event_day - BETWEEN DATE '{$this->_startingDate}' - AND DATE '{$this->_endingDate}') - OR event.reacur is not true)"; - } else if ($this->_startingDate) { - $where[] = "((event.reacur - AND event_recur.event_day >= DATE '{$this->_startingDate}') - OR event.reacur is not true)"; - } - if (is_array($where)) { - $sql .= "\nWHERE ".implode("\nAND ", $where); - } - $sql .= " - ORDER BY event.bdate,event.edate"; - $eventId = filter_var($_REQUEST['eventid'], FILTER_VALIDATE_INT); - if ($eventId) { - $sql .= " LIMIT 1 OFFSET 0"; - } - return $sql; - } - - /** - * Create the where part of the query - * - * @return array - */ - private function _buildWherePart() - { - $where = array(); - // where clauses - $where[] = "event.visable"; - // eventid - $eventId = filter_var($_REQUEST['eventid'], FILTER_VALIDATE_INT); - $category = filter_var($_REQUEST['category'], FILTER_VALIDATE_INT); - if ($eventId) { - $where[] = "event.id = {$eventId}"; - } else if ($category) { - $this->_category = $category; - $where[] = "event.topicid = {$category}"; - } - $currentTime = time(); - // month - if ($_REQUEST['startMonth'] || $_REQUEST['endMonth']) { - $dateFormat = '/([0-9]{2})\/([0-9]{2})\/([0-9]{4})/'; - if (preg_match($dateFormat, $_REQUEST['startMonth'], $startingMatches)) { - $isValidStart = checkdate( - $startingMatches[1], - $startingMatches[2], - $startingMatches[3] - ); - } else { - $isValidStart = false; - } - - if (preg_match($dateFormat, $_REQUEST['endMonth'], $endingMatches)) { - $isValidEnd = checkdate( - $endingMatches[1], - $endingMatches[2], - $endingMatches[3] - ); - } else { - $isValidEnd = false; - } - - // if they both are good - if ( $isValidStart && $isValidEnd) { - $this->_startingDate = $_REQUEST['startMonth']; - $this->_endingDate = $_REQUEST['endMonth']; - $where[] = " - event.edate >= DATE '{$_REQUEST['startMonth']}' - "; - $where[] = " - event.bdate <= DATE '{$_REQUEST['endMonth']}' - "; - } else if ($isValidStart && !$isValidEnd) { - $this->_startingDate = $_REQUEST['startMonth']; - $where[] = " - event.edate >= DATE '{$_REQUEST['startMonth']}' - "; - } else if (!$isValidStart && $isValidEnd) { - $this->_endingDate = $_REQUEST['endMonth']; - $where[] = " - event.bdate >= DATE '{$_REQUEST['endMonth']}' - "; - } - } else if ($_REQUEST['t'] == 'today') { - $this->_t = 'Today'; - $this->_startingDate = date('m/d/Y', $currentTime); - $this->_endingDate = $this->_startingDate; - $where[] = "current_date - BETWEEN event.bdate - AND event.edate"; - } else if ($_REQUEST['t'] == 'tomorrow') { - $this->_t = 'Tomorrow'; - $this->_startingDate = date( - 'm/d/Y', - strtotime('+1day') - ); - $this->_endingDate = $this->_startingDate; - $where[] = "current_date + INTERVAL '1 day' - BETWEEN event.bdate - AND event.edate"; - } else if ($_REQUEST['t'] == 'next') { - $this->_t = 'Next 7 Days'; - // calculate dates for this week - $this->_startingDate = date('m/d/Y'); - $this->_endingDate = date( - 'm/d/Y', - strtotime('+7 days') // 7 days out - ); - $where[] = " - (DATE '{$this->_startingDate}', DATE '{$this->_endingDate}') - OVERLAPS - (event.bdate, event.edate)"; - } else { - $startDate = date("m/d/Y", $currentTime); - $where[] = "event.edate >= DATE '$startDate'"; - $this->_startingDate = $startDate; - } - // topicid - if ($_REQUEST['topicid'] && ctype_digit($_REQUEST['topicid'])) { - $where[] = "event.topicid = {$_REQUEST['topicid']}"; - } - - return $where; - } -} diff --git a/Toolkit/Events/UserSearchForm.php b/Toolkit/Events/UserSearchForm.php deleted file mode 100644 index 3e71220..0000000 --- a/Toolkit/Events/UserSearchForm.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @copyright 2012 Gaslight Media - * @license Gaslight Media - * @version SVN: (0.1) - * @link <> - */ - -/** - * Description for require_once - */ -require_once 'HTML/Template/Flexy/Element.php'; - -/** - * Create the User Search Form for the Event Page - * - * Description of UserSearchForm - * - * @category Toolkit - * @package Events - * @author Steve Sutton - * @copyright 2012 Gaslight Media - * @license Gaslight Media - * @release Release: (0.1) - * @link <> - */ -class Toolkit_Events_UserSearchForm - extends Toolkit_Events_Auxiliary -{ - const MAX_LOOP_FOR_MONTHS = 20; - - /** - * getEventSearchForm() - * - * create the search form - * - * @return string - * @access public - */ - public function toHtml() - { - $template = new HTML_Template_Flexy($this->flexyOptions); - $page = new stdClass; - $template->compile('eventSearchForm.html'); - $elements['event-search-form'] = new HTML_Template_Flexy_Element; - // set the action for the form - $elements['event-search-form']->attributes['action'] - = MEDIA_BASE_URL . 'index.php'; - // set the catid for the form - $elements['catid'] = new HTML_Template_Flexy_Element; - $elements['catid']->setValue($_REQUEST['catid']); - // set the topicid for the form - $elements['category'] = new HTML_Template_Flexy_Element; - $elements['category']->setOptions($this->_getCategories()); - $elements['category']->setValue($_REQUEST['category']); - // setup starting month - $elements['startMonth'] = new HTML_Template_Flexy_Element; - if ($_REQUEST['startMonth']) { - $elements['startMonth']->setValue($_REQUEST['startMonth']); - } else { - $elements['startMonth']->setValue(date('m/d/Y', strtotime('now'))); - } - // setup starting month - $elements['endMonth'] = new HTML_Template_Flexy_Element; - if ($_REQUEST['endMonth']) { - $elements['endMonth']->setValue($_REQUEST['endMonth']); - } else { - $elements['endMonth']->setValue(date('m/d/Y', strtotime('+7days'))); - } - return $template->bufferedOutputObject($page, $elements); - } - - /** - * getTopics() - * - * get topics array for search form - * - * @return array Return description (if any) ... - * @access public - */ - private function _getCategories() - { - $topics[''] = 'All Categories'; - $sql = " - SELECT * - FROM topic - WHERE id IN ( - SELECT topicid - FROM event - WHERE visable = 't' - AND edate >= current_date) - ORDER BY descr"; - try { - $data = $this->dbh->query($sql)->fetchAll(); - if (is_array($data)) { - foreach ($data as $row) { - $topics[$row['id']] = $row['descr']; - } - return $topics; - } - } catch(PDOException $e) { - Toolkit_Common::handleError($e); - } - } -} diff --git a/Toolkit/Events/config.ini b/Toolkit/Events/config.ini deleted file mode 100644 index f37d5e3..0000000 --- a/Toolkit/Events/config.ini +++ /dev/null @@ -1,7 +0,0 @@ -; Event Database configuration file -[conf] -; set the display of the events to show a -; calendar at a glance -; turning this off will display the events -; as a list starting with the current month -calendarAtAGlance = Off diff --git a/Toolkit/Events/getEvents.php b/Toolkit/Events/getEvents.php deleted file mode 100644 index 01cc11f..0000000 --- a/Toolkit/Events/getEvents.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright 2012 Gaslight Media - * @license Gaslight Media - * @version SVN: (0.1) - * @link <> - */ -require '../../setup.phtml'; -$catid = EVENT_PAGE; -$_REQUEST['catid'] = $_POST['catid'] = $_GET['catid'] = $catid; -// Create a new registry so we don't pollute the global namespace -$registry = new Toolkit_Registry(); -$dbh = Toolkit_Database::getInstance(); -$registry->cacheOptions = $GLOBALS['cacheOptions']; -$registry->flexyOptions = $GLOBALS['flexyOptions']; -$registry->catid = $catid; -$registry->dbh = $dbh; -$registry->logger = Toolkit_Logger::getLogger(); -// create Event Display -$events = new Toolkit_Events_Display($registry->dbh); -$keywordReplacement = new Toolkit_Template_KeywordReplacement( - new Toolkit_Toolbox_PageGatewayPublish( - $registry->dbh - ) -); -echo $events->toHTML($keywordReplacement); diff --git a/Toolkit/Events/showCalendar.php b/Toolkit/Events/showCalendar.php deleted file mode 100644 index 8ac643a..0000000 --- a/Toolkit/Events/showCalendar.php +++ /dev/null @@ -1,10 +0,0 @@ -toHtml(); diff --git a/Toolkit/Events/templates/currentTables/Element.tpl b/Toolkit/Events/templates/currentTables/Element.tpl deleted file mode 100755 index 595457b..0000000 --- a/Toolkit/Events/templates/currentTables/Element.tpl +++ /dev/null @@ -1,14 +0,0 @@ - - - - * - - - - - -
{error}
- - {element} - - diff --git a/Toolkit/Events/templates/currentTables/Form.tpl b/Toolkit/Events/templates/currentTables/Form.tpl deleted file mode 100755 index f59286a..0000000 --- a/Toolkit/Events/templates/currentTables/Form.tpl +++ /dev/null @@ -1,7 +0,0 @@ -
- - - {content} -
- -
diff --git a/Toolkit/Events/templates/currentTables/Group.tpl b/Toolkit/Events/templates/currentTables/Group.tpl deleted file mode 100755 index cdd24cf..0000000 --- a/Toolkit/Events/templates/currentTables/Group.tpl +++ /dev/null @@ -1,5 +0,0 @@ - - - {content} - -
diff --git a/Toolkit/Events/templates/currentTables/GroupElement.tpl b/Toolkit/Events/templates/currentTables/GroupElement.tpl deleted file mode 100755 index 1a4ba27..0000000 --- a/Toolkit/Events/templates/currentTables/GroupElement.tpl +++ /dev/null @@ -1,9 +0,0 @@ - - - {element} - - * - - {label} - - diff --git a/Toolkit/Events/templates/currentTables/Header.tpl b/Toolkit/Events/templates/currentTables/Header.tpl deleted file mode 100755 index 64ac244..0000000 --- a/Toolkit/Events/templates/currentTables/Header.tpl +++ /dev/null @@ -1,5 +0,0 @@ - - - {header} - - diff --git a/Toolkit/Events/templates/currentTables/RequiredNote.tpl b/Toolkit/Events/templates/currentTables/RequiredNote.tpl deleted file mode 100755 index dad5d0b..0000000 --- a/Toolkit/Events/templates/currentTables/RequiredNote.tpl +++ /dev/null @@ -1 +0,0 @@ -* = Required Fields diff --git a/Toolkit/Events/templates/editTopics.html b/Toolkit/Events/templates/editTopics.html deleted file mode 100644 index 00b8269..0000000 --- a/Toolkit/Events/templates/editTopics.html +++ /dev/null @@ -1,77 +0,0 @@ -
-

Manage Event Categories

-
-
- - - - - - -
Add New Category:
-
-
-data as $row) { - $letter = chr($colorBoxLetter); -?> -
-
- - - - - - - - - - -
- -
-
- -
\ No newline at end of file diff --git a/Toolkit/Events/templates/emailOwner.tpl b/Toolkit/Events/templates/emailOwner.tpl deleted file mode 100755 index 944a364..0000000 --- a/Toolkit/Events/templates/emailOwner.tpl +++ /dev/null @@ -1,29 +0,0 @@ - - - - - {title:h} - - - -

{subject:h}

-

Information

- - - - - {if:v[nowrap]} - - {else:} - - {end:} - - -
{v[label]:h}{v[element]:h}{v[element]:h}
-

A new Event has been added to your Website from your "Add Your Event" page.

-

To approve it, please go to the Pending Events page in your admin.

- - diff --git a/Toolkit/Events/templates/eventDetail.html b/Toolkit/Events/templates/eventDetail.html deleted file mode 100755 index 667dd91..0000000 --- a/Toolkit/Events/templates/eventDetail.html +++ /dev/null @@ -1,58 +0,0 @@ - -
-
- {if:event[img]} -

{event[header]:h}

- {else:} -

{event[header]:h}

- {end:} -
-
-
map...
-
Loading...
-
-
-
- - - - -
-
-
-
-
{event[dates]}
-
{event[btime]} {if:event[etime]} to {event[etime]} {end:}
-
-
-
{event[loc]}
- {if:!event[hide_address]} - {event[address]} - {event[city]}, {event[state]} {event[zip]} - {end:} -
-
-
-
{event[cost]}
-
-

Contact & More Info

- - -
Contact: {event[contact]}
- -
Phone: {event[phone]}
-
-
-
-
{event[descr]:h}
-
- {if:!events} -

No events found

- {end:} -
diff --git a/Toolkit/Events/templates/eventFeed.html b/Toolkit/Events/templates/eventFeed.html deleted file mode 100644 index 59effdb..0000000 --- a/Toolkit/Events/templates/eventFeed.html +++ /dev/null @@ -1,22 +0,0 @@ -
-

{event[dates]}

-{event[times]} -
-{if:event[img]} - -{end:} -
Place: {event[loc]}
-{if:!event[hide_address]} -
{event[address]}
-
{event[city]}, {event[state]} {event[zip]}
-{end:} -
Cost: {event[cost]}
-{event[url]} -
- Contact & More Info -
Contact: {event[contact]}
- -
Phone: {event[phone]}
-
-
{event[descr]:h}
\ No newline at end of file diff --git a/Toolkit/Events/templates/eventHomePage.html b/Toolkit/Events/templates/eventHomePage.html deleted file mode 100755 index 41f4972..0000000 --- a/Toolkit/Events/templates/eventHomePage.html +++ /dev/null @@ -1,90 +0,0 @@ - -
-
-
-{foreach:events,e} - {if:e[href]} - - {end:} - {e[header]} - {if:e[href]} - - {end:} -{end:} -
-
-
- {e[header]:h} - {e[bdate]} -
- -options['strict'] || (is_array($t->blocks) || is_object($t->blocks))) { - foreach($t->blocks as $category => $events) { - if ($index % 2 == 0) { echo '
'; } ?> -
-

- -

- options['strict'] || (is_array($events['data']) || is_object($events['data']))) { - foreach($events['data'] as $event) {?> -
- - - -
- - All - -
- '; - } ?> - blocks)-1 && ($index + 1) % 2 != 0) { - echo '
'; - } ?> - - - diff --git a/Toolkit/Events/templates/eventPage.html b/Toolkit/Events/templates/eventPage.html deleted file mode 100644 index 01ab8f9..0000000 --- a/Toolkit/Events/templates/eventPage.html +++ /dev/null @@ -1,27 +0,0 @@ -
- {eventContent:h} -
-
-{eventSearchForm:h} -
-

Shortcuts

- -
- -
diff --git a/Toolkit/Events/templates/eventSearchForm.html b/Toolkit/Events/templates/eventSearchForm.html deleted file mode 100755 index e0c61c7..0000000 --- a/Toolkit/Events/templates/eventSearchForm.html +++ /dev/null @@ -1,14 +0,0 @@ - diff --git a/Toolkit/Events/templates/events.html b/Toolkit/Events/templates/events.html deleted file mode 100755 index eb71f1a..0000000 --- a/Toolkit/Events/templates/events.html +++ /dev/null @@ -1,26 +0,0 @@ - -
- -{if:events} - {foreach:events,event} - {if:event[spans]}
{end:} - {if:event[reacur]}
{end:} - {if:event[normal]}
{end:} -

{event[dates]}

-

- {event[header]} -

- {if:event[spans]}

Ongoing Event

{end:} - {if:event[reacur]}

Repeating Event

{end:} -
- {end:} -{else:} -

No events were found for your search.

-{end:} -
-- 2.17.1