From: Steve Sutton The system has encountered an un-recoverable error! ' . self::getErrorInfo($e) . '";
+ }
+
+ // }}}
+ // {{{ createLink()
+
+
+ /**
+ * Creates a folder link so we can browse to each folder
+ *
+ * @param array $row Folder information
+ *
+ * @return string anchor link for folder
+ * @access protected
+ */
+ protected function createLink(array $row)
+ {
+ $format = '%s';
+
+ $link = sprintf(
+ $format,
+ ($_GET['folder'] == $row['id']) ? 'clicked' : null,
+ $_GET['CKEditor'],
+ $_GET['CKEditorFuncNum'],
+ $_GET['langCode'],
+ $row['id'],
+ $row['name']
+ );
+
+ return $link;
+ }
+
+ // }}}
+
+ // {{{ fetchFoldersArray()
+
+
+ /**
+ * Fetches a tree hierarchy of the folder structure into a linear array
+ *
+ * @param integer $start node to start at
+ *
+ * @return array folder structure with levels
+ * @access protected
+ */
+ protected function fetchFoldersArray($start)
+ {
+ return Toolkit_Common::getHierarchicalTreeStructure(
+ $this->dbh,
+ 'ckeditor_folders',
+ 'id',
+ 'parent',
+ 'id',
+ $start
+ );
+ }
+
+ // }}}
+
+ // {{{ getFolders()
+
+
+ /**
+ * Gets the folders ul list
+ *
+ * @param integer $parent start at a certain level
+ *
+ * @return string list of folders
+ * @access public
+ */
+ public function getFolders($parent = 0)
+ {
+ $folders = $this->fetchFoldersArray($parent);
+ try {
+ $sql = "
+ SELECT *
+ FROM ckeditor_folders
+ WHERE id = :id";
+
+ $stmt = $this->dbh->prepare($sql);
+ foreach ($folders as $i => $j) {
+ $stmt->bindParam(':id', $i, PDO::PARAM_INT);
+ $stmt->execute();
+ $row = $stmt->fetch(PDO::FETCH_ASSOC);
+
+ if ($j == $this->_prevLvl) {
+ $tree .= $this->openNode($row);
+ $tree .= $this->createLink($row);
+ $this->_prevLvl = $j;
+ } elseif ($j > $this->_prevLvl) {
+ ++$this->_lvlsOpen;
+ $tree .= $this->createFolder();
+ $tree .= $this->openNode($row);
+ $tree .= $this->createLink($row);
+ $this->_prevLvl = $j;
+ } elseif ($j < $this->_prevLvl) {
+ do {
+ $tree .= $this->closeNode();
+ $tree .= $this->closeFolder();
+ } while (--$this->_lvlsOpen > $j);
+ $tree .= $this->closeNode();
+ $tree .= $this->openNode($row);
+ $tree .= $this->createLink($row);
+ $this->_prevLvl = $this->_lvlsOpen;
+ }
+ }
+ $tree .= $this->closeFolder();
+ return $tree;
+ } catch (PDOException $e) {
+ return Toolkit_Common::handleError($e);
+ }
+ }
+
+ // }}}
+
+ // {{{ openNode()
+
+
+ /**
+ * Opens a branch or leaf node
+ *
+ * @param array $row Folder information
+ *
+ * @return string opening li tag
+ * @access protected
+ */
+ protected function openNode(array $row)
+ {
+ return "\n\t
GLM Image Browser
+
+
+
+
+
+
+
+ * public function &emailRenderElement($e)
+ * {
+ * switch ($e) {
+ * case 'element_one' :
+ * case 'element_two' :
+ * case 'element_three' :
+ * $renderer =& $this->defaultRenderer();
+ * $renderer->clearAllTemplates();
+ * $renderer->setGroupTemplate('{content}', $e);
+ * $renderer->setGroupElementTemplate('{element}
+ *
+ * @param array $newLabels Assoc array of element names and new
+ * labels to be used in the email form.
+ * eg [$newLabels['element'] => 'Label']
+ * @param array $excludeList Any element that needs to be removed
+ * from the form when creating the table
+ * eg [$list = array(e1, e2, e3, etc..)]
+ *
+ * @return mixed The table body for the email.
+ */
+ public function createEmailBody(
+ array $newLabels = array(),
+ array $excludeList = array()
+ ) {
+ $this->freeze();
+ // Get the values corresponding to the elements present in the form.
+ $formData = $this->exportValues();
+ // The array keys holds all the names of the elements.
+ $elements = array_keys($formData);
+ // Remove any unwanted elements from our elements array.
+ foreach ($excludeList as $trgt) {
+ unset($elements[array_search($trgt, $elements)]);
+ }
+
+ // Which row we are at.
+ $i = 0;
+ $table = new HTML_Table(array('class' => 'data'));
+ // Auto grow the table, since the forms will by dynamic in size.
+ $table->setAutoGrow(true);
+ // Get the labels and values of the elements.
+ foreach ($elements as $name) {
+ $e =& $this->getElement($name);
+ // Get the default HTML for each element.
+ $html = $e->toHtml();
+ // If any elements need to have their html
+ // changed for an email, this function in the
+ // class should exist and will return a renderer
+ // object of how the element should be rendered.
+ if (method_exists($this, 'emailRenderElement')) {
+ $renderer =& $this->emailRenderElement($name);
+ // make sure we have an actual rendering object
+ // if the element doesn't need to be altered it should
+ // just return null.
+ if (is_object($renderer)) {
+ $e->accept($renderer);
+ $html = $renderer->toHtml($name);
+ // We have to reset the entire forms html
+ // otherwise we'll just keep adding to it everytime
+ // we render a new element.
+ // This is a bit of a hack to make this work (because
+ // the _html element is supposed to be a private
+ // property)
+ $renderer->_html = null;
+ }
+ }
+ // Get the label for the element.
+ $label = array_key_exists($name, $newLabels) ?
+ $newLabels[$name] :
+ $e->getLabel();
+
+ // Make the row and increment the row counter.
+ $table->setCellContents($i, 0, $label);
+ $table->setCellAttributes($i, 0, array('class' => 'label'));
+ $table->setCellAttributes($i, 1, array('class' => 'field'));
+ $table->setCellContents($i++, 1, $html);
+ }
+ return $table->toHtml();;
+ }
+
+ // }}}
+ // {{{ createSQLInsert()
+
+ /**
+ * Generates a properly formatted sql query to insert data into a table
+ *
+ * @param string $table Name of the table to insert into
+ * @param array $columns Array of column names you want to set in the
+ * insert statement and bind names
+ *
+ *
', $e);
+ * break;
+ *
+ * default :
+ * $renderer = null;
+ * break;
+ * }
+ *
+ * return $renderer;
+ * }
+ *
+ * Toolkit_Common::createSQLInsert('member', array('name', 'pos'));
+ * will create the sql statement
+ * INSERT INTO member (name, pos) VALUES(:name, :pos)
+ *
+ *
+ * @return string Formatted SQL string
+ * @access public
+ * @static
+ */
+ public static function createSQLInsert($table, array $columns)
+ {
+ $params = implode(', ', $columns);
+ $bindParams = ':' . implode(', :', $columns);
+
+ return "INSERT INTO $table ($params) VALUES ($bindParams)";
+ }
+
+ // }}}
+ // {{{ createSQLUpdate()
+
+ /**
+ * Generates a properly formatted sql query to update data in a table
+ *
+ *
+ * Toolkit_Common::createSQLUpdate('member',
+ * array('name', 'pos'),
+ * array('id = :id');
+ * will create the sql statement
+ * UPDATE member SET name = :name, pos = :pos WHERE id = :id
+ *
+ *
+ * @param string $table Name of the table to update
+ * @param array $columns Array of columns names you want to update
+ * @param array $constraints Constraints to apply to the table to prevent
+ * running the update on every row in the db
+ *
+ * @return string formatted query string
+ * @access public
+ * @static
+ */
+ public static function createSQLUpdate(
+ $table,
+ array $columns,
+ array $constraints = null
+ ) {
+ $length = count($columns);
+ for ($i = 0; $i < $length; ++$i) {
+ $bindParams .= "{$columns[$i]} = :{$columns[$i]}";
+ if ($i < ($length - 1)) {
+ $bindParams .= ', ';
+ }
+ }
+ $sql = "UPDATE $table SET $bindParams";
+
+ if (!empty($constraints)) {
+ $sql .= ' WHERE ' . implode(' AND ', $constraints);
+ }
+
+ return $sql;
+ }
+
+ // }}}
+ // {{{ createTables()
+
+ /**
+ * Read file from parameter and use the PDO parameter to create process file
+ *
+ * @param PDO $pdo PHP Data Object to use for DB calls
+ * @param string $file full path of file to parse
+ *
+ * @return void
+ * @access public
+ * @static
+ */
+ public static function createTables(PDO $pdo, $file)
+ {
+ $sql = file_get_contents($file);
+ // break multiple queries apart by ';'
+ $tok = strtok($sql, ';');
+ try {
+ // while we have valid tokens, execute the query
+ // and grab the next token
+ while ($tok !== false) {
+ $pdo->query($tok);
+ $tok = strtok(';');
+ }
+ } catch (PDOException $e) {
+ Toolkit_Common::handleError($e);
+ }
+ }
+
+ // }}}
+
+ // {{{ dieGracefully()
+
+ /**
+ * Gracefully exit from the script when an unrecoverable error is created
+ *
+ * @param string $msg Message to display to user
+ * @param mixed $e Error object
+ * @param boolean $moreInfo More debugging info when in development
+ *
+ * @return void
+ * @access public
+ */
+ public function dieGracefully($msg = null, $e = null, $moreInfo = false)
+ {
+ if (is_null($e)) {
+ if (is_null($msg)) {
+ die('There was an error, please try again later!');
+ } else {
+ die($msg);
+ }
+ } else {
+ echo $msg . '
';
+ echo 'Error Caught.
';
+ echo 'Error: ' . $e->getMessage() . '
';
+ if ($moreInfo) {
+ echo 'Code: ' . $e->getCode() . '
';
+ echo 'Debug Info: ' . $e->getDebugInfo() . '
';
+ }
+ }
+ }
+
+ // }}}
+
+ // {{{ errorException()
+
+ /**
+ * Stops script on Exception error
+ *
+ * Stops the script when an Exception is raised inside a
+ * try/catch block.
+ *
+ * When a site is no longer in DEVELOPMENT, ie: its live on ws3.
+ * We don't show any error info, but let the user know an unexpected
+ * error has occured and then mail the error info the the admin.
+ *
+ * Example usage:
+ *
+ * try {
+ if ($foo != $bar) {
+ throw new Exception ("Foo Doesn't equal Bar");
+ }
+ * } catch (Exception $e) {
+ * return Toolkit_Common::handleError($e);
+ * }
+ *
+ *
+ * @param Exception $e Exception Object
+ * @param Mail $mail What to use to send mail to admin
+ *
+ * @return false
+ * @access public
+ * @static
+ */
+ public static function errorException(Exception $e, Mail $mail = null)
+ {
+ if (!is_null($mail)) {
+ $subject = 'Exception Error for ' . SITENAME;
+ self::mailError($mail, $subject, $e);
+ } else {
+ echo self::getErrorInfo($e);
+ }
+
+ return false;
+ }
+
+ // }}}
+ // {{{ errorHTMLQuickFormError()
+
+ /**
+ * Handles PEAR Errors for our developers
+ *
+ * When a site is no longer in DEVELOPMENT, ie: its live on ws3.
+ * We don't show any error info, but let the user know an unexpected
+ * error has occured and then mail the error info the the admin.
+ *
+ * HTML_QuickForm Example usage:
+ *
+ * $e =& $this->getElement('elementName');
+ * if (PEAR::isError($e)) {
+ * return Toolkit_Common::handleError($e);
+ * }
+ *
+ *
+ * @param HTML_QuickForm_Error $e QuickFormError Object
+ * @param Mail $mail What to use to send mail to admin
+ *
+ * @return false
+ * @access public
+ * @since Method available since Release 1.0.1
+ * @static
+ */
+ public static function errorHTMLQuickFormError(
+ HTML_QuickForm_Error $e,
+ Mail $mail = null
+ ) {
+ if (!is_null($mail)) {
+ $subject = 'PEAR Error for ' . SITENAME;
+ self::mailError($mail, $subject);
+ } else {
+ echo self::getErrorInfo($e);
+ }
+
+ return false;
+ }
+
+ // }}}
+ // {{{ errorPDOException()
+
+ /**
+ * Stops script on database error
+ *
+ * Stops the script when a PDOException is raised inside a
+ * try/catch block.
+ *
+ * When a site is no longer in DEVELOPMENT, ie: its live on ws3.
+ * We don't show any error info, but let the user know an unexpected
+ * error has occured and then mail the error info the the admin.
+ *
+ * Example usage:
+ *
+ * try {
+ * $sql = "
+ * SELECT *
+ * FROM table_name
+ * WHERE id = :id";
+ *
+ * $stmt = $this->dbh->prepare($sql);
+ * $stmt->bindParam(':id', $id, PDO::PARAM_INT);
+ * return $stmt->execute();
+ * } catch (PDOException $e) {
+ * return Toolkit_Common::handleError($e);
+ * }
+ *
+ *
+ * @param PDOException $e PDO Error Object.
+ * @param Mail $mail Mail object used to send admin email
+ *
+ * @return false
+ * @access public
+ * @since Method available since Release 1.0.1
+ */
+ public function errorPDOException(PDOException $e, Mail $mail = null)
+ {
+ if (!is_null($mail)) {
+ $subject = 'SQL Error for ' . SITENAME;
+ self::mailError($mail, $subject, $e);
+ } else {
+ echo self::getErrorInfo($e);
+ }
+
+ return false;
+ }
+
+ // }}}
+ // {{{ errorPEARError()
+
+ /**
+ * Handles PEAR Errors for our developers
+ *
+ * When a site is no longer in DEVELOPMENT, ie: its live on ws3.
+ * We don't show any error info, but let the user know an unexpected
+ * error has occured and then mail the error info the the admin.
+ *
+ * @param PEAR_Error $e PEARError Object
+ * @param Mail $mail Mail object used to send admin email
+ *
+ * @return false
+ * @access public
+ * @since Method available since Release 1.0.1
+ */
+ public function errorPEARError(PEAR_Error $e, Mail $mail = null)
+ {
+ if (!is_null($mail)) {
+ $subject = 'PEAR Error for ' . SITENAME;
+ self::mailError($mail, $subject);
+ } else {
+ echo self::getErrorInfo($e);
+ }
+
+ return false;
+ }
+
+ // }}}
+ // {{{ errorPEARException()
+
+ /**
+ * Handles PEAR Exception for our developers
+ *
+ * When a site is no longer in DEVELOPMENT, ie: its live on ws3.
+ * We don't show any error info, but let the user know an unexpected
+ * error has occured and then mail the error info the the admin.
+ *
+ * @param PEAR_Exception $e PEARException Object
+ * @param Mail $mail Mail object used to send admin email
+ *
+ * @return false
+ * @access public
+ * @since Method available since Release 1.0.1
+ */
+ public function errorPEARException(PEAR_Exception $e, Mail $mail = null)
+ {
+ if (!is_null($mail)) {
+ $subject = 'SQL Error for ' . SITENAME;
+ self::mailError($mail, $subject, $e);
+ } else {
+ echo self::getErrorInfo($e);
+ }
+
+ return false;
+ }
+
+ // }}}
+ // {{{ errorRuntimeException()
+
+ /**
+ * Stops script on runtime error
+ *
+ * Stops the script when a runtimeException is raised inside a
+ * try/catch block.
+ *
+ * When a site is no longer in DEVELOPMENT, ie: its live on ws3.
+ * We don't show any error info, but let the user know an unexpected
+ * error has occured and then mail the error info the the admin.
+ *
+ * @param RuntimeException $e PDO Error Object.
+ * @param Mail $mail Mail object used to send admin email
+ *
+ * @return false
+ * @access public
+ * @since Method available since Release 1.0.2
+ */
+ public function errorRuntimeException(
+ RuntimeException $e,
+ Mail $mail = null
+ ) {
+ if (!is_null($mail)) {
+ $subject = 'Runtime Exception for ' . SITENAME;
+ self::mailError($mail, $subject, $e);
+ } else {
+ echo self::getErrorInfo($e);
+ }
+
+ return false;
+ }
+
+ // }}}
+ // {{{ errorBadMethodCallException()
+
+ /**
+ * Stops script on bad method call error
+ *
+ * Stops the script when a badMethodCallException is raised inside a
+ * try/catch block.
+ *
+ * When a site is no longer in DEVELOPMENT, ie: its live on ws3.
+ * We don't show any error info, but let the user know an unexpected
+ * error has occured and then mail the error info the the admin.
+ *
+ * @param BadMethodCallException $e PDO Error Object.
+ * @param Mail $mail Mail object used to send admin email
+ *
+ * @return false
+ * @access public
+ * @since Method available since Release 1.0.3
+ */
+ public function errorBadMethodCallException(
+ BadMethodCallException $e,
+ Mail $mail = null
+ ) {
+ if (!is_null($mail)) {
+ $subject = 'Bad Method Call Exception for ' . SITENAME;
+ self::mailError($mail, $subject, $e);
+ } else {
+ echo self::getErrorInfo($e);
+ }
+
+ return false;
+ }
+
+ // }}}
+
+ // {{{ filterURI()
+
+ /**
+ * Filters uri's before they are validated
+ *
+ * @param string $uri URI to filter
+ *
+ * @return mixed new uri if missing scheme
+ * @access public
+ * @static
+ */
+ public static function filterURI($uri)
+ {
+ $validProtocol = '/^https?\:\/\/.*/';
+ $invalidProtocol = '/^.*?\:\/\/.*/';
+ if (empty($uri)) {
+ // Empty field, just return
+ return $uri;
+ } elseif (preg_match($validProtocol, $uri)) {
+ // has valid protocol, return unchanged
+ // should pass validation.
+ return $uri;
+ } elseif (!preg_match($invalidProtocol, $uri)) {
+ // missing protocol, prepend default
+ // http:// protocol and return.
+ return "http://$uri";
+ } else {
+ // has invalid protocol, return unchanged
+ // validation should catch this and throw error.
+ return $uri;
+ }
+ }
+
+ // }}}
+ // {{{ filterPhone()
+
+ /**
+ * Filters phone numbers before they are validated
+ *
+ * @param string $phone number to filter
+ *
+ * @return mixed newly formatted phone number
+ * @access public
+ * @static
+ */
+ public static function filterPhone($phone)
+ {
+ // Ditch anything that is not a number
+ $number = preg_replace('/[^0-9]/', '', $phone);
+
+ // Invalid Number, validation will catch error
+ $len = strlen($number);
+ if (($len < 10) || ($len > 11)) {
+ return $phone;
+ }
+
+ // subscriber number
+ $sn = substr($number, -4);
+ // city code
+ $cc = substr($number, -7, 3);
+ // area code
+ $ac = substr($number, -10, 3);
+ if ($len == 11) {
+ // country prefix
+ $cp = $number[0];
+ }
+
+ $filteredNumber = "($ac) $cc-$sn";
+ if (!is_null($cp)) {
+ $filteredNumber = "$cp $filteredNumber";
+ }
+
+ return $filteredNumber;
+ }
+
+ // }}}
+
+ // {{{ getCities()
+
+ /**
+ * Get an array of cities from the database
+ *
+ * @param PDO $dbh Database handler
+ * @param integer $state State id the city is in
+ * @param integer $county County id the city is in
+ * @param integer $region Region id the city is in
+ *
+ * @return array states
+ * @access public
+ * @static
+ */
+ public static function getCities(
+ PDO $dbh,
+ $state = null,
+ $county = null,
+ $region = null
+ ) {
+ $param = array();
+ if (ctype_digit((string)$state)) {
+ $param[] = 'state_id = ' . $dbh->quote($state);
+ }
+ if (ctype_digit((string)$county)) {
+ $param[] = 'county_id = ' . $dbh->quote($county);
+ }
+ if (ctype_digit((string)$region)) {
+ $param[] = 'region_id = ' . $dbh->quote($region);
+ }
+
+ try {
+ $sql = "
+ SELECT *
+ FROM city";
+
+ if (!empty($param)) {
+ $sql .= ' WHERE ' . implode(' AND ', $param);
+ }
+ $sql .= ' ORDER BY city_name';
+
+ $stmt = $dbh->prepare($sql);
+ $stmt->execute();
+
+ $cities = array();
+ while ($row = $stmt->fetch()) {
+ $cities[$row['city_id']] = $row['city_name'];
+ }
+
+ return $cities;
+ } catch (PDOException $e) {
+ return Toolkit_Common::handleError($e);
+ }
+ }
+
+ // }}}
+ // {{{ getErrorInfo()
+
+ /**
+ * extract error info from error object
+ *
+ * @param mixed $obj Error object to get info for
+ *
+ * @return string formatted error information
+ * @access public
+ */
+ public function getErrorInfo($obj)
+ {
+ $state = '' . get_class($obj) . ' error: ';
+
+ $state .= '
$_SERVER[\'QUERY_STRING\']: ' . $_SERVER['QUERY_STRING']
+ . "\n";
+ $state .= '
$_SERVER[\'HTTP_REFERER\']: ' . $_SERVER['HTTP_REFERER']
+ . "\n";
+ $state .= '
$_SERVER[\'REDIRECT_QUERY_STRING\']: '
+ . $_SERVER['REDIRECT_QUERY_STRING'] . "\n";
+ $state .= '
$_SERVER[\'REQUEST_URI\']: ' . $_SERVER['REQUEST_URI']
+ . "\n";
+
+ $state .= '
$_GET: ' . print_r($_GET, true) . '
';
+ $state .= '
$_POST: ' . print_r($_POST, true) . '
';
+ $state .= '
$_SESSION: ' . print_r($_SESSION, true) . '
';
+
+ if (method_exists($obj, 'getMessage')) {
+ $state .= $obj->getMessage();
+ if (method_exists($obj, 'getDebugInfo')) {
+ $state .= '; ' . $obj->getDebugInfo();
+ }
+ }
+ if (method_exists($obj, 'getFile')) {
+ $state .= ' in ' . $obj->getFile() . '';
+ }
+ if (method_exists($obj, 'getLine')) {
+ $state .= ' on line ' . $obj->getLine() . '';
+ }
+ if (method_exists($obj, 'getBacktrace')) {
+ $backtrace = print_r($obj->getBacktrace(), true);
+
+ $state .= "$backtrace
";
+ }
+
+ return $state;
+ }
+
+ // }}}
+ // {{{ getHierarchicalTreeStructure()
+
+ /**
+ * Create a hierarchical tree stored in an linear array
+ *
+ * Produces a representation of a hierarchical tree structure into a
+ * linear array so you can iterate straight through to get the tree
+ * structure.
+ *
+ * @param PDO $pdo Database handler
+ * @param string $table Name of the source relation
+ * @param string $key Name of the key field
+ * @param string $parent Name of the parent-key field
+ * @param string $order Name of the field to order siblings by
+ * @param integer $start Key value of the row to start at
+ * @param integer $maxDepth Maximum depth to descend to, or zero
+ * for unlimited depth
+ * @param boolean $validParent exclude branches that have null
+ * parent values
+ *
+ * @return array Linear array of tree structure
+ * @access public
+ * @see http://www.postgresql.org/doc/8.3/interactive/tablefunc.html#AEN104085
+ */
+ public function getHierarchicalTreeStructure(
+ PDO $pdo,
+ $table = 'pages',
+ $key = 'id',
+ $parent = 'parent',
+ $order = 'pos',
+ $start = 0,
+ $maxDepth = 0,
+ $validParent = true
+ ) {
+ try {
+ $tree = array();
+
+ $sql = "
+ SELECT *
+ FROM connectby('{$table}', '{$key}', '{$parent}',
+ '{$order}', '{$start}', {$maxDepth})
+ as t(id text, parent text, level int, pos int)";
+ if ($validParent) {
+ $sql .= " WHERE parent is not null";
+ }
+ foreach ($pdo->query($sql) as $row) {
+ $tree[$row['id']] = $row['level'];
+ }
+
+ return $tree;
+ } catch (PDOException $e) {
+ return self::handleError($e);
+ }
+ }
+
+ // }}}
+ // {{{ getScripts()
+
+ /**
+ * Gets all scripts for the page
+ *
+ * adds version number to url for all local (non-app.glm) urls
+ * so we can use .htaccess cachebusting
+ *
+ * combines script by server id, so we can decrease http requests to fetch
+ * the needed scripts
+ *
+ * @param array $scripts The array of js scripts for the page
+ *
+ * @return string HTML markup for scripts
+ * @access public
+ * @static
+ */
+ public static function getScripts(array $scripts)
+ {
+ if (!is_array($scripts) || empty($scripts)) {
+ return false;
+ }
+
+ $uniqueScripts = array_unique($scripts);
+ // Get the main jquery file
+ $jquery = JQUERY_CDN_JS;
+ $key = array_search($jquery, $uniqueScripts);
+ // If it exists, remove it from its current location
+ // and put at front of array.
+ if ($key !== false) {
+ unset($uniqueScripts[$key]);
+ array_unshift($uniqueScripts, $jquery);
+ }
+ $format = '';
+
+ $ret = '';
+ $baseUrlStrLen = strlen(MEDIA_BASE_URL);
+ $appUrlStrLen = strlen(MEDIA_APP_BASE_URL);
+
+ // Use versioning with local scripts for cachebusting
+ $localPath = MEDIA_BASE_URL . 'v/' . VERSION . '/javascript/';
+ $appPath = MEDIA_APP_BASE_URL . 'javascript/';
+
+ $localScripts = array();
+ $appScripts = array();
+ foreach ($uniqueScripts as $origScript) {
+ $ret .= sprintf($format, $origScript) . "\n";
+ }
+
+ if (!empty($appScripts)) {
+ $appPath = $appPath . implode(',', $appScripts);
+ $ret .= sprintf($format, $appPath) . "\n";
+ }
+
+ if (!empty($localScripts)) {
+ $localPath = $localPath . implode(',', $localScripts);
+ $ret .= sprintf($format, $localPath) . "\n";
+ }
+
+ return $ret;
+ }
+
+ // }}}
+ // {{{ getStates()
+
+
+ /**
+ * Get an array of states from the database
+ *
+ * @param PDO $dbh Database handler
+ * @param boolean $unionStatesOnly If we want to only retrieve
+ * the 50 US states
+ *
+ * @return array states
+ * @access public
+ * @static
+ */
+ public static function getStates(PDO $dbh, $unionStatesOnly = false)
+ {
+ if ($unionStatesOnly) {
+ // Just grab the 50 states of the union
+ $where = "WHERE us_state = :bool";
+ }
+
+ try {
+ $sql = "
+ SELECT *
+ FROM state
+ $where
+ ORDER BY state_name";
+
+ $stmt = $dbh->prepare($sql);
+ if ($unionStatesOnly) {
+ $stmt->bindValue(':bool', 1, PDO::PARAM_BOOL);
+ }
+ $stmt->execute();
+
+ $states = array();
+ while ($row = $stmt->fetch()) {
+ $states[$row['state_id']] = $row['state_name'];
+ }
+
+ return $states;
+ } catch (PDOException $e) {
+ return Toolkit_Common::handleError($e);
+ }
+ }
+
+ // }}}
+ // {{{ getStyleSheets()
+
+ /**
+ * Gets all style sheets for the page
+ *
+ * adds version number to url for all local (non-app.glm) urls
+ * so we can use .htaccess cachebusting
+ *
+ * combines style sheets by server id, so we can decrease http
+ * requests to fetch the needed style sheets
+ *
+ * @return string HTML markup for stylesheets
+ * @access public
+ * @static
+ */
+ public static function getStyleSheets()
+ {
+ if ( !isset($GLOBALS['styleSheets'])
+ || !is_array($GLOBALS['styleSheets'])
+ || empty($GLOBALS['styleSheets'])
+ ) {
+ return false;
+ }
+
+ $uniqueStyleSheets = array_unique($GLOBALS['styleSheets']);
+ $format = '';
+
+ $baseUrlStrLen = strlen(MEDIA_BASE_URL);
+ $appUrlStrLen = strlen(MEDIA_APP_BASE_URL);
+ $ret = '';
+
+ $localPath = MEDIA_BASE_URL . 'v/' . VERSION . '/css/';
+ $appPath = MEDIA_APP_BASE_URL . 'css/';
+
+ $localStyleSheets = array();
+ $appStyleSheets = array();
+ foreach ($uniqueStyleSheets as $origStyleSheet) {
+ $ret .= sprintf($format, $origStyleSheet) . "\n";
+ }
+
+ if (!empty($appStyleSheets)) {
+ $appPath = $appPath . implode(',', $appStyleSheets);
+ $ret .= sprintf($format, $appPath) . "\n";
+ }
+ if (!empty($localStyleSheets)) {
+ $localPath = $localPath . implode(',', $localStyleSheets);
+ $ret .= sprintf($format, $localPath) . "\n";
+ }
+
+ return $ret;
+ }
+
+ // }}}
+ // {{{ getTableMetaData()
+
+ /**
+ * Gets the meta data of the calling classes table columns
+ *
+ * The table used when retrieving the meta data is defined
+ * in the class property $tableName. The class or parent class
+ * must also have a $tableMetaData property
+ *
+ * @param PDO $pdo Database Handler
+ * @param string $tableName The name of the table to get the meta data for.
+ * @param array $clauses Only retrieve meta data for certain column types
+ *
+ * @return array metadata for table
+ * @access protected
+ */
+ public function getTableMetaData(
+ PDO $pdo,
+ $tableName,
+ array $clauses = null
+ ) {
+ if (is_array($clauses)) {
+ while ($c = current($clauses)) {
+ $ands .= " data_type = '{$c}'";
+ if (false !== next($clauses)) {
+ $ands .= " OR ";
+ }
+ }
+ $ands = " AND ($ands)";
+ }
+ try {
+ $sql = "
+ SELECT column_name, data_type
+ FROM information_schema.columns
+ WHERE table_name = :tname
+ $ands";
+ $stmt = $pdo->prepare($sql);
+ $stmt->bindParam(':tname', $tableName, PDO::PARAM_STR);
+
+ $stmt->execute();
+
+ $metaData = array();
+ while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
+ $metaData[$row['column_name']] = $row['data_type'];
+ }
+
+ return $metaData;
+ } catch (PDOException $e) {
+ return self::handleError($e);
+ }
+ }
+
+ // }}}
+
+ // {{{ handleError()
+
+ /**
+ * Handles various script error
+ *
+ * @param Object $e Error Object
+ * @param boolean $developmentServer If we are on a development server
+ *
+ * @return mixed String, false, void
+ * @access public
+ * @static
+ */
+ public static function handleError($e, $developmentServer = DEVELOPMENT)
+ {
+ $errorType = str_replace('_', '', get_class($e));
+ $errorType = "error$errorType";
+
+ if (method_exists(__CLASS__, $errorType)) {
+ if (!$developmentServer) {
+ // Tell the user we encountered an Error.
+ if (file_exists(BASE . '404.html')) {
+ include_once BASE . "404.html";
+ }
+
+ $mail = Mail::factory('mail');
+ self::$errorType($e, $mail);
+ exit();
+ } else {
+ return self::$errorType($e, $mail);
+ }
+ } else {
+ echo '
+ * $rules[] = array('element' => 'phone',
+ * 'message' => 'ERROR: Invalid Phone Format!',
+ * 'type' => 'phone',
+ * 'format' => null,
+ * 'validation' => $this->validationType,
+ * 'reset' => true,
+ * 'force' => false);
+ *
+ *
+ * Zip: Validates input against US and CA zip codes, if DB check is
+ * set to true, validate zip codes against all the zip codes in the
+ * DB.
+ *
+ * $rules[] = array('element' => 'zip',
+ * 'message' => 'ERROR: Invalid Zip!',
+ * 'type' => 'zip',
+ * 'format' => array('requireDBCheck' => true),
+ * 'validation' => $this->validationType,
+ * 'reset' => true,
+ * 'force' => false);
+ *
+ *
+ * Banwords: Make sure each each doesn't contain a banned word. Checking
+ * against a DB of banned words.
+ *
+ * State: Validate input against US and CA region / province codes. If DB
+ * check is set to true, validate region / province against all the
+ * regions / provinces in the DB.
+ *
+ * $rules[] = array('element' => 'state_id',
+ * 'message' => 'ERROR: Invalid State / Province!',
+ * 'type' => 'state',
+ * 'format' => array('requireDBCheck' => true),
+ * 'validation' => $this->validationType,
+ * 'reset' => true,
+ * 'force' => false);
+ *
+ *
+ * @var array
+ * @access protected
+ * @see app.gaslightmedia.com/glmPEAR/HTML/QuickForm/Rule/Zip.php
+ * @see app.gaslightmedia.com/glmPEAR/HTML/QuickForm/Rule/Phone.php
+ * @see app.gaslightmedia.com/glmPEAR/HTML/QuickForm/Rule/Banwords.php
+ * @see app.gaslightmedia.com/glmPEAR/HTML/QuickForm/Rule/State.php
+ */
+ protected $registeredRules = array('phone', 'zip', 'state');
+
+ // }}}
+ // {{{ __construct()
+
+ /**
+ * Class constructor
+ *
+ * @param object $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
We will email you a link to the PDF version of the {brochure}.
+ORDER BY MAIL:
+{contactForm:h} diff --git a/Toolkit/Contacts/templates/contactForm.html b/Toolkit/Contacts/templates/contactForm.html new file mode 100644 index 0000000..2f2f84a --- /dev/null +++ b/Toolkit/Contacts/templates/contactForm.html @@ -0,0 +1,92 @@ ++ {sec.header:h} | +||||||||
+ | {elem.html:h} | +|||||||
+ {if:elem.required}*{end:}
+ {if:elem.error} {end:}
+ {elem.label:h} {end:}
+ {else:}
+ {if:elem.isType(#CAPTCHA_Image#)}
+ + {if:elem.error} |
+ {if:elem.required}*{end:}
+ {if:elem.error} {end:}
+ {elem.label:h}
+ {if:elem.error} {end:}
+ |
+ + {else:} + {if:elem.isType(#group#)} + |
+ {if:elem.required}*{end:}
+ {if:elem.error} {end:}
+ {elem.label:h} {end:}
+ {else:}
+ + {if:elem.error} |
+ {if:elem.required}*{end:}
+ {if:elem.error} {end:}
+ {elem.label:h}
+ {if:elem.error} {end:}
+ |
+ {if:elem.isName(#interest#)}
+ + {else:} + |
+ {end:}
+ {end:}
+ {end:}
+ {end:}
+ {if:elem.error} {elem.error} {end:}
+ {if:elem.isType(#group#)}
+ {foreach:elem.elements,gitem}
+ {gitem.label:h}
+ {gitem.html:h}{if:gitem.required}* {end:}
+ {if:elem.separator}{elem.separator:h}{end:}
+ {end:}
+ {else:}
+ {elem.html:h}
+ {if:elem.isName(#captcha_rmv#)}
+ What is this?
+
+ {end:}
+ {end:}
+ |
+
Below is the list of businesses you have added to your Trip Planner. The form below will be sent to each individual business listing that has an email address listed with their business listing. For those businesses with no email address, we have included their phone numbers for you to call directly and request additional information.
+These business listings have no current email address on file. To receive additional information please call the phone numbers listed next to each business name.
+Name + | Phone + | + |
---|---|---|
{member[memberName]} | +{member[memberPhone]} | +Remove | +
This list of businesses will receive the following information form directly to their email account.
+{member[memberName]} | +Remove | +
+ + {subject:h} + +
++ + From {fname:h} {lname:h} + +
+
+
|
+ |||
+
|
+
Dear {fname}
+Your friend {yname} has been to demo.gaslightmedia.com, and thought you might be interested in it.
+Message here.
+Thank you for requesting the {pdfName} Link. Here is the link to the Adobe PDF version: +
+Brochure ({pdfFileSize})
+Thank you for your interest in {client_info[name]:h}'!
+Sincerely,
+{client_info[name]:h}
+{client_info[url]:h}
+ + + diff --git a/Toolkit/DataGridBuilder.php b/Toolkit/DataGridBuilder.php new file mode 100644 index 0000000..ced09b6 --- /dev/null +++ b/Toolkit/DataGridBuilder.php @@ -0,0 +1,288 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @link http://demo.gaslightmedia.com + */ + +/** + * Create Datagrids for displaying data + * + * This abstract class handles all the base functionality of creating + * handeling all the details associated w/ a regular dataGrid. + * 1. Creation + * 2. Sorting (via column headers or sortform) + * 3. Pagenation + * + * @category Structures + * @package Toolkit_DataGridBuilder + * @author Jamie Kahgee
+ * protected $email = false;
+ *
+ *
+ * @var unknown
+ * @access protected
+ */
+ protected $email;
+
+ /**
+ * From header in the owner email
+ *
+ * This just sets the From header in the owner email
+ * SITENAME
+ * protected $email = false;
+ *
+ *
+ * @var unknown
+ * @access protected
+ */
+ protected $email;
+
+ /**
+ * From header in the owner email
+ *
+ * This just sets the From header in the owner email
+ * SITENAME ' . $calendar . ' ' + . (($size == 2) + ? $year + : '') . ' | +||||||
' . $prev_month . ' | +' . $calendar . ' ' + . (($size == 2) + ? $year + : '') . ' | +' . $next_month . ' | +||||
' . $week_titles[$x] . ' | + '; + } + $out .= ' +||||||
", $offset + ); + } + $offset = ($offset == 7) + ? 0 + : $offset; + // start entering in the information + for ($day = 1; $day <= $totaldays; $day++) { + $out .= ' + | '; + $datelink = $this->getEventData($month, $day, $year, $eventObj); + if ($size == 1 && $datelink) { + $out .= '' + . $day . ''; + } elseif ($datelink) { + $out .= $day . ''; + $out .= $datelink; + } else { + $out .= $day . ''; + } + $out .= ' | + '; + $offset++; + // if we're on the last day of the week, wrap to the other side + if ($offset > 6) { + $offset = 0; + $out .= ' +|||||
", $offset + ); + } + // end the table + $out .= ' + |
Goes back to color array and grabs the class for that peticular color.
+ * + * @param string $color Color to use + * + * @return string class to use for style. + */ + + function disColor($color) + { + // get style class for this color + return $this->_colorArray[$color]; + } + + // }}} + // {{{ lastDayOfMonth() + /** + * lastDayOfMonth + * + *given timestamp get the last day of the month it + * fall in
+ * + * @param string $time Timestamp + * + * @return string timestamp + */ + function lastDayOfMonth($time = '') + { + $timestamp = ($time == '') + ? time() + : $time; + $timePart = date("Y-m", $timestamp); + return strtotime($timePart . ' last day'); + } + + // }}} + // {{{ myGetTimeStamp() + + /** + * gets time stamp + * + * Long description (if any)... + * + * @param unknown $time Parameter description (if any)... + * @param boolean $all_day Parameter description (if any)... + * + * @return integer Return description (if any)... + * @access public + */ + function myGetTimeStamp($time, $all_day = false) + { + static $count, $count2; + $count = ($count) + ? $count + : 1; + $count2 = ($count2) + ? $count2 + : 1; + $pattern = "/^([0-9]{1,2}):?([0-9]{1,2})? ?([AP]M)/i"; + if (!$all_day && preg_match($pattern, trim($time), $tar1)) { + if (($tar1[3] == 'PM' || $tar1[3] == 'pm') && (int) $tar1[1] < 12) { + $a1 = (int) $tar1[1] + 12; + } else { + $a1 = (int) $tar1[1]; + } + $a2 = $tar1[2]; + $time1 = mktime($a1, $a2, $count++, 1, 1, 2000); + return $time1; + } else { + if ($all_day) { + $time1 = $count2++; + } else { + $time1 = 999999999 + $count++; + } + return $time1; + } + } + + // }}} + // {{{ ordinalDay() + /** + * ordinalDay + * get ordinal (th)day for given timestamp + * + * @param int $ord ordinal number + * @param int $day number of day + * @param int $month number of month + * @param int $year number of year + * + * @access public + * @return int + */ + + function ordinalDay($ord, $day, $month, $year) + { + $firstOfMonth = strtotime("{$month}/01/{$year}"); + $lastOfMonth = $firstOfMonth + date("t", $firstOfMonth) * 86400; + $dayOccurs = 0; + for ($i = $firstOfMonth; $i < $lastOfMonth; $i += 86400) { + if (date("w", $i) == $day) { + $dayOccurs++; + if ($dayOccurs == $ord) { + $ordDay = $i; + } + } + } + return $ordDay; + } + + // }}} + // {{{ showEventHeaders() + /** + * showEventHeaders + * + * @param string $date date string + * @param mixed $eventObj Pass the EventCalendar Obj + * + * @access public + * @return string + */ + + function showEventHeaders($date, $eventObj) + { + $pattern = "/([0-9]{1,2})[-\/]([0-9]{1,2})[-\/]([0-9]{4})/"; + if (preg_match($pattern, $date, $dpart)) { + $month = (int) $dpart[1]; + $year = (int) $dpart[3]; + } + if (is_array($this->_eventsData[$date])) { + foreach ($this->_eventsData[$date] as $num => $data) { + $btime = $this->calTime($data['btime']); + $etime = $this->calTime($data['etime']); + $all_day = ($data['all_day'] == 't') + ? 1 + : 0; + $stime = (int) $this->myGetTimeStamp($btime, $all_day); + $data2[(int) $stime] = 'Show an advanced search form
+ * + * @return string + */ + function advancedSearch() + { + $out = ''; + $out .= $this->getEventSearch(1); + $out .= ' +Search For: | ++ + | +
Search By Category: | +
+ ';
+ $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 .= '
+
+ '; + } + } + $out .= ' + |
+
From: | ++ (MM/DD/YYYY) + | +
To: | ++ (MM/DD/YYYY) + | +
+ | +
+ * protected $email = false;
+ *
+ *
+ * @var unknown
+ * @access protected
+ */
+ protected $email;
+
+ /**
+ * From header in the owner email
+ *
+ * This just sets the From header in the owner email
+ * SITENAME ' . $prevLink . ' | +' + . $monthText->thisMonthName() + . ' ' + . $Month->thisYear() + . ' | +' . $nextLink . ' | +||||
---|---|---|---|---|---|---|
\n"; + } else { + $out .= ' | '; + // if the day isSelected then create a link + if ($Day->isSelected()) { + // Calendar_Decorator_Uri for links + $dayUri = new Calendar_Decorator_Uri($Day); + $dayUri->setFragments('year', 'month', 'day'); + $out .= '' . $Day->thisDay(). ''; + } else { + $out .= $Day->thisDay(); + } + $out .= " | \n"; + } + + if ($Day->isLast()) { + $out .= "
+ * protected $email = false;
+ *
+ *
+ * @var unknown
+ * @access protected
+ */
+ protected $email;
+
+ /**
+ * From header in the owner email
+ *
+ * This just sets the From header in the owner email
+ * SITENAME Add New Category: | ++ | + |
+ | + | + | + |
{v[label]:h} | + {if:v[nowrap]} +{v[element]:h} | + {else:} +{v[element]:h} | + {end:} +
A new Event has been added to your Website from your "Add Your Event" page.
+To approve it, please go to the Pending Events page in your admin.
+ + diff --git a/Toolkit/Events/templates/eventDetail.html b/Toolkit/Events/templates/eventDetail.html new file mode 100755 index 0000000..667dd91 --- /dev/null +++ b/Toolkit/Events/templates/eventDetail.html @@ -0,0 +1,58 @@ + +{event[header]:h}
+ {else:} +No events found
+ {end:} +{event[bdate]}
+ {event[header]} +Showing {search}
+{if:events} + {foreach:events,event} + {if:event[spans]}{event[dates]}
+Ongoing Event
{end:} + {if:event[reacur]}Repeating Event
{end:} +No events were found for your search.
+{end:} +