Dropped old Display classes
RSS isn't ported yet but I have a copy to work from
This commit is contained in:
parent
064b4d9f55
commit
6a1056306f
5 changed files with 0 additions and 549 deletions
|
@ -1,199 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Common Display Class File for PICKLES
|
|
||||||
*
|
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* Licensed under The MIT License
|
|
||||||
* Redistribution of these files must retain the above copyright notice.
|
|
||||||
*
|
|
||||||
* @author Joshua Sherman <pickles@joshtronic.com>
|
|
||||||
* @copyright Copyright 2007-2013, Joshua Sherman
|
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html
|
|
||||||
* @package PICKLES
|
|
||||||
* @link https://github.com/joshtronic/pickles
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Common Display Class
|
|
||||||
*
|
|
||||||
* This is the parent class class that each display class should be
|
|
||||||
* extending and executing parent::render()
|
|
||||||
*/
|
|
||||||
abstract class Display_Common extends Object
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Template Extension
|
|
||||||
*
|
|
||||||
* @access protected
|
|
||||||
* @var string $extension file extension for the template files
|
|
||||||
*/
|
|
||||||
protected $extension = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parent Template
|
|
||||||
*
|
|
||||||
* @access protected
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $parent_template = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Child (sub) Template
|
|
||||||
*
|
|
||||||
* @access protected
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $child_template = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CSS Class Name
|
|
||||||
*
|
|
||||||
* @access protected
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $css_class = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Javascript [Path and] Basename
|
|
||||||
*
|
|
||||||
* @access protected
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $js_basename = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Meta Data
|
|
||||||
*
|
|
||||||
* @access protected
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $meta_data = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Module Return Data
|
|
||||||
*
|
|
||||||
* @access protected
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $module_return = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* Gets those headers working
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
|
|
||||||
// Obliterates any passed in PHPSESSID (thanks Google)
|
|
||||||
if (stripos($_SERVER['REQUEST_URI'], '?PHPSESSID=') !== false)
|
|
||||||
{
|
|
||||||
list($request_uri, $phpsessid) = explode('?PHPSESSID=', $_SERVER['REQUEST_URI'], 2);
|
|
||||||
header('HTTP/1.1 301 Moved Permanently');
|
|
||||||
header('Location: ' . $request_uri);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// XHTML compliancy stuff
|
|
||||||
ini_set('arg_separator.output', '&');
|
|
||||||
ini_set('url_rewriter.tags', 'a=href,area=href,frame=src,input=src,fieldset=');
|
|
||||||
|
|
||||||
header('Content-type: text/html; charset=UTF-8');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Template
|
|
||||||
*
|
|
||||||
* Sets the template file based on passed template type. Adds path and
|
|
||||||
* extension if applicable.
|
|
||||||
*
|
|
||||||
* @param string $template template file's basename
|
|
||||||
* @param string $type template file's type (either parent or child)
|
|
||||||
*/
|
|
||||||
private function setTemplate($template, $type)
|
|
||||||
{
|
|
||||||
if ($template != null)
|
|
||||||
{
|
|
||||||
$template_name = $type . '_template';
|
|
||||||
$template_path = SITE_TEMPLATE_PATH . ($type == 'parent' ? '__shared/' : '');
|
|
||||||
$template_file = $template_path . $template . ($this->extension != false ? '.' . $this->extension : '');
|
|
||||||
|
|
||||||
if (file_exists($template_file))
|
|
||||||
{
|
|
||||||
$this->$template_name = $template_file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Template Variables
|
|
||||||
*
|
|
||||||
* Sets the variables used by the templates
|
|
||||||
*
|
|
||||||
* @param string $parent_template parent template
|
|
||||||
* @param string $child_template child (sub) template
|
|
||||||
* @param string $css_class name of the CSS class for the module
|
|
||||||
* @param string $js_basename basename for the javascript file for the module
|
|
||||||
* @param boolean $fluid whether or not use a fluid layout
|
|
||||||
*/
|
|
||||||
public function setTemplateVariables($parent_template, $child_template, $css_class, $js_basename, $fluid)
|
|
||||||
{
|
|
||||||
$this->setTemplate($parent_template, 'parent');
|
|
||||||
$this->setTemplate($child_template, 'child');
|
|
||||||
|
|
||||||
$this->css_class = $css_class;
|
|
||||||
$this->js_basename = $js_basename;
|
|
||||||
$this->fluid = $fluid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Meta Data
|
|
||||||
*
|
|
||||||
* Sets the meta data from the module so the display class can use it
|
|
||||||
*
|
|
||||||
* @param array $meta_data key/value array of data
|
|
||||||
*/
|
|
||||||
public function setMetaData($meta_data)
|
|
||||||
{
|
|
||||||
$this->meta_data = $meta_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Module Return
|
|
||||||
*
|
|
||||||
* Sets the return data from the module so the display class can display it
|
|
||||||
*
|
|
||||||
* @param array $module_return key / value pairs for the data
|
|
||||||
*/
|
|
||||||
public function setModuleReturn($module_return)
|
|
||||||
{
|
|
||||||
$this->module_return = $module_return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Template Exists
|
|
||||||
*
|
|
||||||
* Checks the templates for validity, not required by every display type so
|
|
||||||
* the return defaults to true.
|
|
||||||
*
|
|
||||||
* @return boolean whether or not the template exists
|
|
||||||
*/
|
|
||||||
public function templateExists()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rendering Method
|
|
||||||
*
|
|
||||||
* @abstract
|
|
||||||
*/
|
|
||||||
abstract public function render();
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
|
@ -1,34 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JSON Display Class File for PICKLES
|
|
||||||
*
|
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* Licensed under The MIT License
|
|
||||||
* Redistribution of these files must retain the above copyright notice.
|
|
||||||
*
|
|
||||||
* @author Joshua Sherman <pickles@joshtronic.com>
|
|
||||||
* @copyright Copyright 2007-2013, Joshua Sherman
|
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html
|
|
||||||
* @package PICKLES
|
|
||||||
* @link https://github.com/joshtronic/pickles
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JSON Display
|
|
||||||
*
|
|
||||||
* Displays data in JavaScript Object Notation.
|
|
||||||
*/
|
|
||||||
class Display_JSON extends Display_Common
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Renders the data in JSON format
|
|
||||||
*/
|
|
||||||
public function render()
|
|
||||||
{
|
|
||||||
echo json_encode($this->module_return);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
|
@ -1,136 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHP Display Class File for PICKLES
|
|
||||||
*
|
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* Licensed under The MIT License
|
|
||||||
* Redistribution of these files must retain the above copyright notice.
|
|
||||||
*
|
|
||||||
* @author Joshua Sherman <pickles@joshtronic.com>
|
|
||||||
* @copyright Copyright 2007-2013, Joshua Sherman
|
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html
|
|
||||||
* @package PICKLES
|
|
||||||
* @link https://github.com/joshtronic/pickles
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHP Display
|
|
||||||
*
|
|
||||||
* Displays the associated PHP templates for the Model.
|
|
||||||
*/
|
|
||||||
class Display_PHP extends Display_Common
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Template Extension
|
|
||||||
*
|
|
||||||
* I know there's some controversy amoungst my peers concerning the
|
|
||||||
* usage of the .phtml extension for these PHP template files. If you
|
|
||||||
* would prefer .php or .tpl extensions, feel free to void your
|
|
||||||
* warranty and change it here.
|
|
||||||
*
|
|
||||||
* @access protected
|
|
||||||
* @var string $extension file extension for the template files
|
|
||||||
*/
|
|
||||||
protected $extension = 'phtml';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Template Exists
|
|
||||||
*
|
|
||||||
* @return integer the number of templates defined
|
|
||||||
*/
|
|
||||||
public function templateExists()
|
|
||||||
{
|
|
||||||
if ($this->parent_template != null)
|
|
||||||
{
|
|
||||||
return file_exists($this->parent_template) && file_exists($this->child_template);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return file_exists($this->child_template);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Renders the PHP templated pages
|
|
||||||
*/
|
|
||||||
public function render()
|
|
||||||
{
|
|
||||||
if ($this->templateExists())
|
|
||||||
{
|
|
||||||
// Starts up the buffer
|
|
||||||
ob_start();
|
|
||||||
|
|
||||||
// Creates (possibly overwritten) objects
|
|
||||||
$dynamic_class = (class_exists('CustomDynamic') ? 'CustomDynamic' : 'Dynamic');
|
|
||||||
$form_class = (class_exists('CustomForm') ? 'CustomForm' : 'Form');
|
|
||||||
$html_class = (class_exists('CustomHTML') ? 'CustomHTML' : 'HTML');
|
|
||||||
|
|
||||||
// {{{ Old scope, magic variables
|
|
||||||
|
|
||||||
// Puts the class variables in local scope of the template
|
|
||||||
$__dynamic = new $dynamic_class();
|
|
||||||
$__form = new $form_class();
|
|
||||||
$__html = new $html_class();
|
|
||||||
$__config = $this->config;
|
|
||||||
$__meta = $this->meta_data;
|
|
||||||
$__module = $this->module_return;
|
|
||||||
$__css_class = $this->css_class;
|
|
||||||
$__js_file = $this->js_basename;
|
|
||||||
$__fluid = $this->fluid;
|
|
||||||
|
|
||||||
// }}}
|
|
||||||
// {{{ New scope, class variables
|
|
||||||
|
|
||||||
$this->dynamic = &$__dynamic;
|
|
||||||
$this->form = &$__form;
|
|
||||||
$this->html = &$__html;
|
|
||||||
$this->meta = &$__meta;
|
|
||||||
$this->module = &$__module;
|
|
||||||
$this->js_file = &$this->js_basename;
|
|
||||||
|
|
||||||
// }}}
|
|
||||||
|
|
||||||
// Loads the template
|
|
||||||
if ($this->parent_template != null)
|
|
||||||
{
|
|
||||||
if ($this->child_template == null)
|
|
||||||
{
|
|
||||||
$__template = $this->parent_template;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$__template = $this->child_template;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->template = $__template;
|
|
||||||
|
|
||||||
require_once $this->parent_template;
|
|
||||||
}
|
|
||||||
elseif ($this->child_template != null)
|
|
||||||
{
|
|
||||||
$__template = $this->child_template;
|
|
||||||
|
|
||||||
$this->template = $__template;
|
|
||||||
|
|
||||||
require_once $__template;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Grabs the buffer contents and clears it out
|
|
||||||
$buffer = ob_get_clean();
|
|
||||||
|
|
||||||
// Kills any whitespace and HTML comments
|
|
||||||
$buffer = preg_replace(array('/^[\s]+/m', '/<!--(?:(?!BuySellAds).)+-->/U'), '', $buffer);
|
|
||||||
|
|
||||||
// Note, this doesn't exit in case you want to run code after the display of the page
|
|
||||||
echo $buffer;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
echo json_encode($this->module_return, isset($_GET['pretty']) ? JSON_PRETTY_PRINT : false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
|
@ -1,146 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RSS Display Class File for PICKLES
|
|
||||||
*
|
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* Licensed under The MIT License
|
|
||||||
* Redistribution of these files must retain the above copyright notice.
|
|
||||||
*
|
|
||||||
* @author Joshua Sherman <pickles@joshtronic.com>
|
|
||||||
* @copyright Copyright 2007-2013, Joshua Sherman
|
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html
|
|
||||||
* @package PICKLES
|
|
||||||
* @link https://github.com/joshtronic/pickles
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RSS Display
|
|
||||||
*
|
|
||||||
* Displays data as an RSS formatted XML string.
|
|
||||||
*/
|
|
||||||
class Display_RSS extends Display_Common
|
|
||||||
{
|
|
||||||
// {{{ Feed Defaults
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RSS Version
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $version = '2.0';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Date Format
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $date_format = 'r';
|
|
||||||
|
|
||||||
// }}}
|
|
||||||
|
|
||||||
// {{{ Channel Defaults
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Title
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $title = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Link
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $link = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Description
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $description = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Language
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $language = 'en-us';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generator
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $generator = 'https://github.com/joshtronic/pickles';
|
|
||||||
|
|
||||||
// }}}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Renders the data in RSS format
|
|
||||||
*/
|
|
||||||
public function render()
|
|
||||||
{
|
|
||||||
// Throws off the syntax highlighter otherwise
|
|
||||||
echo '<' . '?xml version="1.0" ?' . '><rss version="' . $this->version . '"><channel>';
|
|
||||||
|
|
||||||
// Loops through the passable channel variables
|
|
||||||
$channel = array();
|
|
||||||
foreach (array('title', 'link', 'description', 'language') as $variable)
|
|
||||||
{
|
|
||||||
if (isset($this->module_return[$variable]))
|
|
||||||
{
|
|
||||||
$this->$variable = $this->module_return[$variable];
|
|
||||||
}
|
|
||||||
|
|
||||||
$channel[$variable] = $this->$variable;
|
|
||||||
}
|
|
||||||
|
|
||||||
$channel['generator'] = $this->generator;
|
|
||||||
|
|
||||||
// Loops through the items
|
|
||||||
$items = '';
|
|
||||||
$build_date = '';
|
|
||||||
if (isset($this->module_return['items']) && is_array($this->module_return['items']))
|
|
||||||
{
|
|
||||||
foreach ($this->module_return['items'] as $item)
|
|
||||||
{
|
|
||||||
// Note: time is the equivalent to pubDate, I just don't like camel case variables
|
|
||||||
$publish_date = date($this->date_format, is_numeric($item['time']) ? $item['time'] : strtotime($item['time']));
|
|
||||||
|
|
||||||
if ($build_date == '')
|
|
||||||
{
|
|
||||||
$build_date = $publish_date;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($item['link']))
|
|
||||||
{
|
|
||||||
$item['guid'] = $item['link'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$item['pubDate'] = $publish_date;
|
|
||||||
|
|
||||||
unset($item['time']);
|
|
||||||
|
|
||||||
$items .= Convert::arrayToXML($item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$channel['pubDate'] = $build_date;
|
|
||||||
$channel['lastBuildDate'] = $build_date;
|
|
||||||
|
|
||||||
echo Convert::arrayToXML($channel) . $items . '</channel></rss>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
|
@ -1,34 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* XML Display Class File for PICKLES
|
|
||||||
*
|
|
||||||
* PHP version 5
|
|
||||||
*
|
|
||||||
* Licensed under The MIT License
|
|
||||||
* Redistribution of these files must retain the above copyright notice.
|
|
||||||
*
|
|
||||||
* @author Joshua Sherman <pickles@joshtronic.com>
|
|
||||||
* @copyright Copyright 2007-2013, Joshua Sherman
|
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html
|
|
||||||
* @package PICKLES
|
|
||||||
* @link https://github.com/joshtronic/pickles
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* XML Display
|
|
||||||
*
|
|
||||||
* Displays data in XML format.
|
|
||||||
*/
|
|
||||||
class Display_XML extends Display_Common
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Renders the data in XML format
|
|
||||||
*/
|
|
||||||
public function render()
|
|
||||||
{
|
|
||||||
echo Convert::arrayToXML($this->module_return);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
Loading…
Add table
Add a link
Reference in a new issue