Updated to common apps files only.
removed the other template and class files
+++ /dev/null
-<?php
-
-// vim:set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker syntax=php:
-
-/**
- * New Event Form
- *
- * PHP version 5
- *
- * @category Toolkit
- * @package Events
- * @author Steve Sutton <steve@gaslightmedia.com>
- * @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 <steve@gaslightmedia.com>
- * @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.
- * <code>
- * protected $email = false;
- * </code>
- *
- * @var unknown
- * @access protected
- */
- protected $email;
-
- /**
- * From header in the owner email
- *
- * This just sets the From header in the owner email
- * SITENAME <from@email.com>
- *
- * 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 <h1> 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 = '
- <style type="text/css">
- #category {display:none};
- .listings {display:none};
- </style>
- <div id="form-sucess-top">
- 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.
- </div>';
-
- /**
- * 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 <form> 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
- <div id="map-dialog">
- <div id="map_canvas" style="width:500px; height:400px"></div>
- </div>
- <a id="map-it" href="#">Map It</a>'
- );
- $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<br>(published on Web site)'
- );
- $e[] = array(
- 'type' => 'text',
- 'req' => false,
- 'name' => 'email',
- 'display' => 'Contact Email<br>(published on Web site)'
- );
- $e[] = array(
- 'type' => 'text',
- 'req' => true,
- 'name' => 'phone',
- 'display' => 'Contact Phone<br>(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 = '<!-- BEGIN required --><span class="req">*</span><!-- END required -->';
- $error = '<!-- BEGIN error --><div class="req">{error}</div><!-- END error -->';
-
- $renderer->setElementTemplate('<tr><td colspan="2">' . $required . '{label}' . $error . '{element}</td></tr>', 'descr');
- $renderer->setElementTemplate('<tr align="center"><td colspan="2">' . $required . '{label}' . $error . '{element}</td></tr>', 'submit_rmv');
-
- if ($this->useCaptcha) {
- $renderer->setElementTemplate('<tr><td class="labelcell"><label>{label}</label></td><td class="fieldcell captcha">{element}</td></tr>', 'captcha_question');
- $renderer->setElementTemplate('<tr><td class="labelcell">' . $required . '<label>{label}</label></td><td class="fieldcell">' . $error . '{element}<span class="tooltip" title="Verification Code|To help us distinguish between information submitted by individuals and those automatically entered by software robots, please type the letters shown.">What is this?</span></td></tr>', '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;
- }
-
- // }}}
-}
-
-?>
+++ /dev/null
-<?php
-
-/**
- * Auxiliary.php
- *
- * PHP version 5.2
- *
- * @category Toolkit
- * @package Events
- * @author Steve Sutton <steve@gaslightmedia.com>
- * @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 <steve@gaslightmedia.com>
- * @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';
- }
-}
-
+++ /dev/null
-<?php
-/**
- * Calendar.php
- *
- * Event Calendar display
- * used by class_events.inc to display calendar output.
- *
- * PHP version 5
- *
- * @category Toolkit
- * @package Events
- * @author Steve Sutton <steve@gaslightmedia.com>
- * @license Gaslight Media
- * @version Release: SVN:<svn_id>
- * @link <>
- */
-
-/**
- * Toolkit_Events_Calendar
- *
- * Display the events in a list view
- *
- * @category Toolkit
- * @package Events
- * @author Steve Sutton <steve@gaslightmedia.com>
- * @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 = '<img src="'
- . MEDIA_BASE_URL . 'images/left.gif" class="calleftarrow" border="0">';
- $this->_rightLink = '<img src="'
- . MEDIA_BASE_URL . 'images/right.gif" class="calrightarrow" border="0">';
- /**
- * $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 = '<a href="' . $eventObj->pageName
- . '&year=' . $year . '&month=' . $month . '">';
- $calendar .= date("F", mktime(0, 0, 0, $month + 1, 0, $year));
- $calendar .= '</a>';
- break;
- case 2:
- $in_future = date('Y') + 3;
- $in_past = date('Y') - 3;
- if ($prev_year > $in_past) {
- $prev_month = '<a href="'
- . $href . $prev . '&year=' . $prev_year . '">'
- . $this->_leftLink . ' Previous Month</a>';
- }
- if ($next_year < $in_future) {
- $next_month = '<a href="' . $href . $next . '&year='
- . $next_year . '">' . $this->_rightLink . 'Next Month</a>';
- }
- // 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 .= '<table class="' . $caltable . '">';
- if ($size == 1) {
- $out .= '
- <tr>
- <td colspan="7" class="' . $calmonth . '"> ' . $calendar . ' '
- . (($size == 2)
- ? $year
- : '') . '</td>
- </tr>
- ';
- } else {
- $out .= '
- <tr>
- <td class="' . $caltitle . '" colspan="2">' . $prev_month . '</td>
- <td colspan="3" class="' . $calmonth . '"> ' . $calendar . ' '
- . (($size == 2)
- ? $year
- : '') . '</td>
- <td class="' . $caltitle . '" colspan="2">' . $next_month . '</td>
- </tr>
- ';
- }
- if ($size == 2) {
- $out .= '<tr>';
- for ($x = 0; $x < 7; $x++) {
- $out .= '
- <td class="' . $caldayheader . '">' . $week_titles[$x] . '</td>
- ';
- }
- $out .= '
- </tr>
- ';
- }
- /**
- * 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 .= '
- <tr>
- ';
- if ($offset > 0 && $offset != 7) {
- $out .= str_repeat(
- "<td class=\"" . $calspacer . "\"> </td>", $offset
- );
- }
- $offset = ($offset == 7)
- ? 0
- : $offset;
- // start entering in the information
- for ($day = 1; $day <= $totaldays; $day++) {
- $out .= '
- <td class="' . $calday . '" valign="top">';
- $datelink = $this->getEventData($month, $day, $year, $eventObj);
- if ($size == 1 && $datelink) {
- $out .= '<a href="' . $eventObj->pageName
- . '&flat=1&month=' . $month
- . '&day=' . $day . '&year=' . $year . '">'
- . $day . '</a>';
- } elseif ($datelink) {
- $out .= $day . '';
- $out .= $datelink;
- } else {
- $out .= $day . '';
- }
- $out .= '</td>
- ';
- $offset++;
- // if we're on the last day of the week, wrap to the other side
- if ($offset > 6) {
- $offset = 0;
- $out .= '
- </tr>
- ';
- if ($day < $totaldays) {
- $out .= '
- <tr>
- ';
- }
- }
- }
- // 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(
- "<td class=\"" . $calspacer . "\"> </td>", $offset
- );
- }
- // end the table
- $out .= '
- </tr></table>
- ';
- 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 = '<img src="' . MEDIA_BASE_URL
- . 'images/left.gif" class="calleftarrow" border="0">';
- $this->_rightLink = '<img src="'
- . MEDIA_BASE_URL . 'images/right.gif" class="calrightarrow" border="0">';
-
- /**
- * 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
- *
- * <p>Goes back to color array and grabs the class for that peticular color.</p>
- *
- * @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
- *
- * <p>given timestamp get the last day of the month it
- * fall in</p>
- *
- * @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] = '<div class="topic">
- <div class="' . $this->disColor($data['topiccolor'])
- . '">' . '<a href="' . $eventObj->pageName . '&month='
- . $month . '&year=' . $year . '&eventid='
- . $data['id'] . '">' . $data['header'] . '</a>' . ' </div>
- </div>
- ';
- }
- ksort($data2, SORT_REGULAR);
- ob_start();
- $out = ob_get_contents();
- ob_end_clean();
- echo $out;
- $output = implode(" ", $data2);
- }
- return $output;
- }
-
- // }}}
-}
-
-?>
+++ /dev/null
-<?php
-
-/**
- * CategoryBlocks.php
- *
- * PHP version 5.2
- *
- * @category Toolkit
- * @package Events
- * @author Steve Sutton <steve@gaslightmedia.com>
- * @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 <steve@gaslightmedia.com>
- * @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);
- }
-}
+++ /dev/null
-<?php
-
-/**
- * Display.php
- *
- * PHP version 5
- *
- * @category Toolkit
- * @package Events
- * @author Steve Sutton <steve@gaslightmedia.com>
- * @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 <steve@gaslightmedia.com>
- * @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);
- }
-}
+++ /dev/null
-<?php
-
-/**
- * Short description for file
- *
- * Long description (if any) ...
- *
- * PHP version 5
- *
- * The license text...
- *
- * @category Toolkit
- * @package Events
- * @author Steve Sutton <steve@gaslightmedia.com>
- * @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 <steve@gaslightmedia.com>
- * @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
- *
- * <p>Show an advanced search form</p>
- *
- * @return string
- */
- function advancedSearch()
- {
- $out = '';
- $out .= $this->getEventSearch(1);
- $out .= '
- <h4>Advanced Search Option:</h4>
- <form action="' . $this->pageName . '" method="post">
- <table id="event-advanced-search">
- <tr>
- <td>Search For:</td>
- <td>
- <input name="EventName" value="' . $_POST['EventName'] . '">
- </td>
- </tr>
- <tr>
- <td>Search By Category:</td>
- <td>
- ';
- $sql = "
- SELECT id,descr
- FROM topic";
- try {
- $data = $this->dbh->query($sql)->fetchAll(PDO::FETCH_ASSOC);
- } catch (PDOException $e) {
- Toolkit_Common::handleError($e);
- }
- if ($data) {
- foreach ($data as $key => $val) {
- $out .= '
- <input type="checkbox" name="topics_id[]" id="chxbox_'
- . $val["id"] . '" value="' . $val["id"] . '">
- <label for="chxbox_' . $val["id"] . '">'
- . $val["descr"] . '</label><br>';
- }
- }
- $out .= '
- </td>
- </tr>
- <tr>
- <td>From:</td>
- <td>
- <input name="EventDateFrom" value="'
- . $_POST['EventDateFrom'] . '"> (MM/DD/YYYY)
- </td>
- </tr>
- <tr>
- <td>To:</td>
- <td>
- <input name="EventDateTo" value="'
- . $_POST['EventDateTo'] . '"> (MM/DD/YYYY)
- </td>
- </tr>
- <tr>
- <td colspan="2" align="right">
- <input type="submit" value="Search"></td>
- </tr>
- </table>
- </form>';
- 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 .= '<div class="clearer"></div>' . "\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 .= '<div id="searching"><h4>' . $searching . '</h4>';
- $out .= '</div>';
- }
- $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 .= '<a name="event"></a>';
- // 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 .= '<div class="clearer"></div><div id="topicsearch">';
- foreach ($result as $tkey => $trow) {
- $out .= '<div class="topicsearchrow"><div class="'
- . $this->discolor($trow['topiccolor'])
- . ' topicsearchheader"> </div>
- <a href="'
- . $this->pageName . '&topicid='
- . $trow['id'] . '">'
- . $trow['descr'] . '</a></div>';
- }
- $out .= '</div>';
- } else {
- $out .= '<form action="' . $page . '#event" method="POST">';
- $out .= '<select name="topicid">';
- $out .= '<option value="">All Categories</option>';
- foreach ($result as $tkey => $trow) {
- $out .= '<option value="' . $trow["id"] . '"';
- if ($_POST['topicid'] == $trow['id']) {
- $out .= ' selected';
- }
- $out .= '>' . $trow["descr"] . '</option>';
- }
- $out .= '</select>';
- }
- }
-
- 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 .= '<div id="smallcals">';
- $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 .= '</div>';
- $out .= '<div id="monthsearch">';
- if ($this->displayType == 'Calendar') {
- $out .= '<form action="'
- . $page . '#event" method="POST" name="glm-cal-search">';
- }
- if ($this->displayType == 'Calendar') {
- $out .= 'By Month: <select name="month">';
- } else {
- $out .= '<select name="month"><option value="All">All Months</option>';
- }
- 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 .= '<option value="' . $key . '"';
- $out .= ($_POST['month'] == $key)
- ? 'selected'
- : '';
- $out .= '>';
- $out .= $mymonth;
- $out .= '</option>';
- }
- }
- }
- $out .= '</select>';
- $out .= '<input type="SUBMIT" value="GO" name="SUBMIT">';
- $out .= '<a href="' . $this->pageName . '&advance=1">Advanced Search</a>';
- $out .= '</form><div class="clearer"></div></div>';
- 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");
- }
-
- // }}}
-}
+++ /dev/null
-<?php
-
-/**
- * EventHomePage.php
- *
- * PHP version 5.2
- *
- * @category Toolkit
- * @package Package
- * @author Steve Sutton <steve@gaslightmedia.com>
- * @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 <steve@gaslightmedia.com>
- * @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;
- }
-}
+++ /dev/null
-<?php
-
-/**
- * Handles editing of events
- *
- * PHP version 5
- *
- * @category Toolkit
- * @package Events
- * @author Jamie Kahgee <steve@gaslightmedia.com>
- * @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 <steve@gaslightmedia.com>
- * @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.
- * <code>
- * protected $email = false;
- * </code>
- *
- * @var unknown
- * @access protected
- */
- protected $email;
-
- /**
- * From header in the owner email
- *
- * This just sets the From header in the owner email
- * SITENAME <from@email.com>
- *
- * 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 <h1> 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 = '
- <style type="text/css">
- #category {display:none};
- .listings {display:none};
- </style>
- <div id="form-sucess-top">
- 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.
- </div>';
-
- /**
- * 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 <form> 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
- <div id="map-dialog">
- <div id="map_canvas" style="width:500px; height:400px"></div>
- </div>
- <a id="map-it" href="#">Map It</a>'
- );
- $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'])
- ? '<a href="' . UPLOADED_FILES . 'original/' . $d['file'] . '">
- ' . $d['file'] . '</a>
- <input type="hidden" name="del_file_rmv" value="0">
- <input type="checkbox" name="del_file_rmv" value="1">Delete File?'
- : 'File not yet uploaded';
- $d['current_img_rmv']
- = ($d['img'])
- ? '<img src="' . THUMB . $d['img'] . '">
- <input type="hidden" name="del_img_rmv" value="0">
- <input type="checkbox" name="del_img_rmv" value="1">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 = '<!-- BEGIN required --><span class="req">*</span>
- <!-- END required -->';
- $error = '<!-- BEGIN error --><div class="req">{error}</div>
- <!-- END error -->';
- $recurTmpl = '<tr class="recur-event">
- <td class="labelcell">' . $required . '<label>{label}</label></td>
- <td class="fieldcell">' . $error . '{element}</td></tr>';
- $renderer->setElementTemplate($recurTmpl, 'dayom');
- $renderer->setElementTemplate($recurTmpl, 'weekom');
- $renderer->setElementTemplate($recurTmpl, 'daysow');
- $renderer->setElementTemplate(
- '<tr><td colspan="2">' . $required . '{label}'
- . $error . '{element}</td></tr>', 'descr'
- );
- $renderer->setElementTemplate(
- '<tr align="center"><td colspan="2">'
- . $required . '{label}' . $error . '{element}</td></tr>', '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);
- }
- }
- }
-
-}
+++ /dev/null
-<?php
-/**
- * Handles editing of topics
- *
- * Long description (if any) ...
- *
- * PHP version 5
- *
- * The license text...
- *
- * @category Toolkit
- * @package Events
- * @author Steve Sutton <steve@gaslightmedia.com>
- * @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 <steve@gaslightmedia.com>
- * @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;
- }
-
-}
+++ /dev/null
-<?php
-
-/**
- * HomeEvents.php
- *
- * PHP version 5.2
- *
- * @category Toolkit
- * @package Events
- * @author Steve Sutton <steve@gaslightmedia.com>
- * @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 <steve@gaslightmedia.com>
- * @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;
- }
-}
+++ /dev/null
-<?php
-
-/**
- * ListEvents.php
- *
- * PHP version 5
- *
- * @category Toolkit
- * @package Events
- * @author Steve Sutton <steve@gaslightmedia.com>
- * @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 <steve@gaslightmedia.com>
- * @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;
- }
-
-}
+++ /dev/null
-<?php
-
-/**
- * QueryBuilder.php
- *
- * PHP version 5.3
- *
- * @category Toolkit
- * @package Events
- * @author Steve Sutton <steve@gaslightmedia.com>
- * @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 <steve@gaslightmedia.com>
- * @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;
- }
-}
+++ /dev/null
-<?php
-
-/**
- * UserSearchForm.php
- *
- * PHP version 5.3
- *
- * @category Toolkit
- * @package Events
- * @author Steve Sutton <steve@gaslightmedia.com>
- * @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 <steve@gaslightmedia.com>
- * @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);
- }
- }
-}
+++ /dev/null
-; 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
+++ /dev/null
-<?php
-
-/**
- * getEvents.php
- *
- * PHP version 5.3
- *
- * @category Toolkit
- * @package Events
- * @author Steve Sutton <steve@gaslightmedia.com>
- * @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);
+++ /dev/null
-<?php
-require_once '../../setup.phtml';
-$month = filter_var($_REQUEST['month'], FILTER_VALIDATE_INT);
-$year = filter_var($_REQUEST['year'], FILTER_VALIDATE_INT);
-$cal = new Toolkit_Events_SmallCal(
- Toolkit_Database::getInstance(),
- $month,
- $year
-);
-echo $cal->toHtml();
+++ /dev/null
-<tr>
- <td class="labelcell">
- <!-- BEGIN required -->
- <span class="req">*</span>
- <!-- END required -->
- <label>{label}</label>
- </td>
- <td class="fieldcell">
- <!-- BEGIN error -->
- <div class="req"> {error} </div>
- <!-- END error -->
- {element}
- </td>
-</tr>
+++ /dev/null
-<div id="contact">
- <form{attributes}>
- <table>
- {content}
- </table>
- </form>
-</div>
+++ /dev/null
-<table class="group">
- <tbody>
- {content}
- </tbody>
-</table>
+++ /dev/null
-<tr>
- <td>
- {element}
- <!-- BEGIN required -->
- <span class="req">*</span>
- <!-- END required -->
- {label}
- </td>
-</tr>
+++ /dev/null
-<tr class="hdr">
- <td colspan="2">
- {header}
- </td>
-</tr>
+++ /dev/null
-<span class="req">* = Required Fields</span>
+++ /dev/null
-<div id="topic-list">
- <h1>Manage Event Categories</h1>
- <div class="topic-row">
- <form action="{topic_action_page:h}" method="post">
- <table>
- <tr>
- <td>Add New Category:</td>
- <td><input name="topic" value=""></td>
- <td><input type="hidden" name="Action" value="Add Topic"><input type="submit" value="Create Category"></td>
- </tr>
- </table>
- </form>
- </div>
-<?php
-$colorBoxLetter = ord('a');
-foreach ($t->data as $row) {
- $letter = chr($colorBoxLetter);
-?>
- <div class="topic-row">
- <form name="form<?php echo $letter;?>" action="{topic_action_page:h}" method="post">
- <input type="hidden" name="Action" value="Update Topic">
- <input type="hidden" name="id" value="<?php echo $row['id'];?>">
- <input type="hidden" id="topiccolor<?php echo $letter;?>" name="topiccolor" value="<?php echo $row['topiccolor'];?>">
- <table>
- <tr>
- <td><div id="square<?php echo $letter;?>" class="colorsquare" style="background-color: <?php echo $row['topiccolor'];?>;" onclick="document.getElementById('colorbox-<?php echo $letter;?>').style.display = 'block';"></div></td>
- <td><div class="topic-name"><input name="descr" value="<?php echo $row['descr'];?>"></div></td>
- <td><div class="topic-save"><input type="button" value="Save" onClick="form<?php echo $letter;?>.submit();"></div></td>
- <td><div class="topic-delete"><input type="button" value="Delete" onClick="myDelete(this.form);"></div></td>
- </tr>
- </table>
- <div id="colorbox-<?php echo $letter;?>" class="colorbox" style="display:none;">
- <table summary="color picker">
- <tr>
- <td class="color1" onclick="grabcolor('<?php echo $letter;?>','#FFCCCC')"></td>
- <td class="color2" onclick="grabcolor('<?php echo $letter;?>','#CC9999')"></td>
- <td class="color3" onclick="grabcolor('<?php echo $letter;?>','#FF9999')"></td>
- <td class="color4" onclick="grabcolor('<?php echo $letter;?>','#FFCCFF')"></td>
- <td class="color5" onclick="grabcolor('<?php echo $letter;?>','#CC99CC')"></td>
- </tr>
- <tr>
- <td class="color6" onclick="grabcolor('<?php echo $letter;?>','#FF99FF')"></td>
- <td class="color7" onclick="grabcolor('<?php echo $letter;?>','#CCCCFF')"></td>
- <td class="color8" onclick="grabcolor('<?php echo $letter;?>','#9999CC')"></td>
- <td class="color9" onclick="grabcolor('<?php echo $letter;?>','#9999FF')"></td>
- <td class="color10" onclick="grabcolor('<?php echo $letter;?>','#CCFFFF')"></td>
- </tr>
- <tr>
- <td class="color11" onclick="grabcolor('<?php echo $letter;?>','#99CCCC')"></td>
- <td class="color12" onclick="grabcolor('<?php echo $letter;?>','#99FFFF')"></td>
- <td class="color13" onclick="grabcolor('<?php echo $letter;?>','#CCFFCC')"></td>
- <td class="color14" onclick="grabcolor('<?php echo $letter;?>','#99CC99')"></td>
- <td class="color15" onclick="grabcolor('<?php echo $letter;?>','#99FF99')"></td>
- </tr>
- <tr>
- <td class="color16" onclick="grabcolor('<?php echo $letter;?>','#FFFFCC')"></td>
- <td class="color17" onclick="grabcolor('<?php echo $letter;?>','#CCCC99')"></td>
- <td class="color18" onclick="grabcolor('<?php echo $letter;?>','#FFFF99')"></td>
- <td class="color19" onclick="grabcolor('<?php echo $letter;?>','#FFCC99')"></td>
- <td class="color20" onclick="grabcolor('<?php echo $letter;?>','#FF99CC')"></td>
- </tr>
- <tr>
- <td class="color21" onclick="grabcolor('<?php echo $letter;?>','#CC99FF')"></td>
- <td class="color22" onclick="grabcolor('<?php echo $letter;?>','#99CCFF')"></td>
- <td class="color23" onclick="grabcolor('<?php echo $letter;?>','#99FFCC')"></td>
- <td class="color24" onclick="grabcolor('<?php echo $letter;?>','#CCFF99')"></td>
- <td class="color25" onclick="grabcolor('<?php echo $letter;?>','#CCCCCC')"></td>
- </tr>
- </table>
- </div>
- </form>
- </div>
-<?php
- $colorBoxLetter++;
-}
-?>
-</div>
\ No newline at end of file
+++ /dev/null
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
- <meta http-equiv="content-type" content="text/html;charset=utf-8">
- <title>{title:h}</title>
-</head>
-<body>
- <style>
- td {line-height:13px;}
- body {font-size: 14px;}
- </style>
- <h2>{subject:h}</h2>
- <h3>Information</h3>
- <table cellspacing="0" cellpadding="0" width="500" style="border:1px solid #ccc;border-collapse:collapse;">
- <tbody>
- <tr flexy:foreach="formData,v">
- <td flexy:if="v[element]" style="font-weight:bold;width:200px;padding:5px;border:1px solid #ccc;" align="right">{v[label]:h}</td>
- {if:v[nowrap]}
- <td flexy:if="v[element]" nowrap style="padding:3px;border:1px solid #ccc;">{v[element]:h}</td>
- {else:}
- <td flexy:if="v[element]" style="padding:3px;border:1px solid #ccc;">{v[element]:h}</td>
- {end:}
- </tr>
- </tbody>
- </table>
- <p>A new Event has been added to your Website from your "Add Your Event" page.</p>
- <p>To approve it, please go to the <a href="{eventAdminURL}">Pending Events</a> page in your admin.</p>
-</body>
-</html>
+++ /dev/null
-<style type="text/css">
-<!--
-#category, .listing {
- display: none;
- }
--->
-</style>
-<div id="eventDetail">
- <div flexy:foreach="events,event">
- {if:event[img]}
- <h2 style="background: url({imgPathDetail}{event[img]}); height: 210px;"><p>{event[header]:h}</p></h2>
- {else:}
- <h2>{event[header]:h}</h2>
- {end:}
- <div id="eventDetailTop">
- <div id="eventDetailMap" flexy:if="event[hasLatLon]">
- <div id="eventDetail-map" flexy:if="event[lat]" title="Click to enlarge">map...</div>
- <div id="map-dialog" flexy:if="event[lat]"><div id="map_canvas" style="width:500px; height:400px">Loading...</div></div>
- </div><!-- /#eventDetailMap -->
- <div id="EventDrivingDirectionsContainer" flexy:if="event[lat]">
- <form id="EventDrivingDirectionsForm" name="EventDrivingDirectionsForm" flexy:ignore="yes" method="post" action="">
- <input type="hidden" id="EventLocation" name="EventLocation" value="{event[loc]:h}">
- <input type="hidden" id="EventLat" name="EventLat" value="{event[lat]}">
- <input type="hidden" id="EventLon" name="EventLon" value="{event[lon]}">
- <input type="submit" id="EventDrivingDirectionSubmit" name="EventDrivingDirectionSubmit" value="Get Driving Directions">
- </form>
- </div>
- <div id="eventDetailInfo">
- <div id="eventDetailTime">
- <div id="eventDetailDate">{event[dates]}</div>
- <div id="eventDetailHour" flexy:if="event[btime]">{event[btime]} {if:event[etime]} to {event[etime]} {end:} </div>
- </div><!-- /#eventDetailTime -->
- <div id="eventDetailPlace" flexy:if="event[hasLocation]">
- <div id="eventDetailLocation" flexy:if="event[loc]">{event[loc]}</div>
- {if:!event[hide_address]}
- <span id="eventDetailAddress" flexy:if="event[address]">{event[address]}</span>
- <span id="eventDetailCity" flexy:if="event[city]">{event[city]}, {event[state]} {event[zip]}</span>
- {end:}
- <div id="event-lat" rel="{event[lat]}" flexy:if="event[lat]"></div>
- <div id="event-lon" rel="{event[lon]}" flexy:if="event[lon]"></div>
- </div><!-- /#eventDetailPlace -->
- <div id="eventCost" flexy:if="event[cost]">{event[cost]}</div>
- <div id="eventDetailContact" flexy:if="event[hasContactInfo]">
- <h3>Contact & More Info</h3>
- <div class="eventurl" flexy:if="event[url]"><a href="{event[url]}">{event[url]}</a></div>
- <div class="eventurl" flexy:if="event[file]">File: <a href="{uploads}{event[file]}">{event[filename]:h}</a></div>
- <div class="eventcontact" flexy:if="event[contact]">Contact: {event[contact]}</div>
- <div class="eventemail" flexy:if="event[email]">Email: <a href="mailto:{event[email]}">{event[email]}</a></div>
- <div class="eventphone" flexy:if="event[phone]">Phone: {event[phone]}</div>
- </div><!-- /#eventDetailContact -->
- </div><!-- /#eventDetailInfo -->
- </div><!-- /#eventDetailTop -->
- <div id="eventDetailDesc" flexy:if="event[descr]">{event[descr]:h}</div>
- </div>
- {if:!events}
- <p>No events found</p>
- {end:}
-</div>
+++ /dev/null
-<div>
-<h2>{event[dates]}</h2>
-<b flexy:if="event[times]">{event[times]}</b>
-</div>
-{if:event[img]}
- <img src="{imgPathDetail:h}{event[img]}" />
-{end:}
-<div flexy:if="event[loc]"><b>Place:</b> {event[loc]}</div>
-{if:!event[hide_address]}
-<div flexy:if="event[address]">{event[address]}</div>
-<div flexy:if="event[city]">{event[city]}, {event[state]} {event[zip]}</div>
-{end:}
-<div flexy:if="event[cost]"><b>Cost:</b> {event[cost]}</div>
-<a href="{event[url]}" flexy:if="event[url]">{event[url]}</a>
-<div flexy:if="event[hasContactInfo]">
- <b>Contact & More Info</b>
- <div flexy:if="event[contact]">Contact: {event[contact]}</div>
- <div flexy:if="event[email]">Email:
- <a href="mailto:{event[email]}">{event[email]}</a></div>
- <div flexy:if="event[phone]">Phone: {event[phone]}</div>
-</div><!-- /#eventDetailContact -->
-<div flexy:if="event[descr]">{event[descr]:h}</div>
\ No newline at end of file
+++ /dev/null
-<style>
-/* .slider-wrapper .nivoSlider {
- position:relative;
- height: 250px;
- }
-.nivoSlider img {
- position: absolute;
- top: 0;
- left: 0;
- display: none;
-}
-.nivoSlider a {
- border: 0;
- display: block;
-}
-.nivo-controlNav {
- display: none;
- }
-.nivo-caption span {
- float: right;
- }
- */
-</style>
-<div class="slider-wrapper theme-default" flexy:if="hasFeaturedEvents">
- <div class="ribbon"></div>
- <div id="slider" class="nivoSlider">
-{foreach:events,e}
- {if:e[href]}
- <a href="{e[href]:h}">
- {end:}
- <img src="{e[s-img]:h}" alt="{e[header]}" title="#event-{e[id]}">
- {if:e[href]}
- </a>
- {end:}
-{end:}
- </div>
-</div>
-<div flexy:foreach="events,e" id="event-{e[id]}" class="nivo-html-caption">
- <strong>{e[header]:h}</strong>
- <span>{e[bdate]}</span>
-</div>
-<script type="text/javascript">
-$(window).load(function() {
- $('#slider').nivoSlider({
- effect: 'fade',
- animSpeed: 1000,
- pauseTime: 5000
- });
- if ( $('#slider').children('a').size() <= 1 ) {
- $('.nivo-prevNav').css('display', 'none');
- $('.nivo-nextNav').css('display', 'none');
- }
-});
-</script>
-<?php
- $index = 0;
- if ($this->options['strict'] || (is_array($t->blocks) || is_object($t->blocks))) {
- foreach($t->blocks as $category => $events) {
- if ($index % 2 == 0) { echo '<div class="eventrow">'; } ?>
- <div class="event-category-block<?php
- if ($index % 2 != 0) {
- echo ' event-category-2';
- } echo ' topic' . $events['id']; ?>">
- <h2><a href="<?php echo $t->topicSearchUrl.$events['id'];?>">
- <?php echo htmlspecialchars($category);?></a>
- </h2>
- <?php
- if ($this->options['strict'] || (is_array($events['data']) || is_object($events['data']))) {
- foreach($events['data'] as $event) {?>
- <div>
- <b><?php echo htmlspecialchars($event['dates']);?></b>
- <a href="<?php echo $event['href'];?>">
- <?php echo htmlspecialchars($event['header']);?></a>
- </div>
- <?php }
- }?>
- <a href="<?php echo $t->topicSearchUrl.$events['id'];?>" class="event-more">All
- <?php echo htmlspecialchars($category);?></a>
- </div>
- <?php
- if ($index % 2 != 0) {
- echo '</div><!-- /.eventrow -->';
- } ?>
- <?php
- if ($index == count($t->blocks)-1 && ($index + 1) % 2 != 0) {
- echo '</div><!-- /.eventrow -->';
- } ?>
- <?php $index++; }?>
- <?php }?>
-
+++ /dev/null
-<div id="event-main-column">
- {eventContent:h}
-</div>
-<div id="event-second-column">
-{eventSearchForm:h}
- <div id="event-shortcuts">
- <h3>Shortcuts</h3>
- <ul class="ulCr">
- <li>
- <a href="{todayUrl:h}">Today's Events</a>
- </li>
- <li>
- <a href="{tomorrowUrl:h}">Tomorrow's Events</a>
- </li>
- <li>
- <a href="{nextUrl:h}">Next 7 Days</a>
- </li>
- </ul>
- </div>
- <div id="event-featured" flexy:if="hasHomeEvents">
- <h3>Featured</h3>
- <div flexy:foreach="events,event" style="background-image: url({event[t-img]:h})">
- <p>{event[bdate]}</p>
- <a href="{event[href]:h}">{event[header]}</a>
- </div>
- </div>
-</div>
+++ /dev/null
-<div id="event-search">
- <h3>Find Events</h3>
- <form name="event-search-form">
- <input type="hidden" name="catid">
- <input type="hidden" name="search" value="1">
- <span>From:</span>
- <div id="startMonthWrapper"><input name="startMonth" id="startMonth" size="10"></div>
- <span>To:</span>
- <div id="endMonthWrapper"><input name="endMonth" id="endMonth" size="10"></div>
- <span>Type:</span>
- <select name="category"></select>
- <input type="image" src="baseurl/Toolkit/Events/assets/go.png" alt="Search Events">
- </form>
-</div>
+++ /dev/null
-<style type="text/css">
-<!--
-#category, .listing {
- display: none;
- }
--->
-</style>
-<div id="eventsList">
-<p class="event-search" flexy:if="search">Showing {search}</p>
-{if:events}
- {foreach:events,event}
- {if:event[spans]}<div class="event-list ongoing">{end:}
- {if:event[reacur]}<div class="event-list reacur">{end:}
- {if:event[normal]}<div class="event-list">{end:}
- <p class="event-list-date">{event[dates]}</p>
- <h3>
- <a href="{event[href]}">{event[header]}</a>
- </h3>
- {if:event[spans]}<p class="event-list-Frequency">Ongoing Event</p>{end:}
- {if:event[reacur]}<p class="event-list-Frequency">Repeating Event</p>{end:}
- </div>
- {end:}
-{else:}
- <p>No events were found for your search. </p>
-{end:}
-</div><!-- /#eventsList -->