Version 1.1.0 released

git-svn-id: svn://p-o.co.uk/p-o.co.uk/com_ajaxdemo@60 60e5ea7b-c093-dd11-ac13-000423648166
This commit is contained in:
alan
2012-03-29 11:21:27 +00:00
parent 2fead4e541
commit 6356280cb1
75 changed files with 1529 additions and 0 deletions

174
site/models/colour.php Normal file
View File

@ -0,0 +1,174 @@
<?php
/**
* Ajax demonstration component
*
* PHP version 5.3
*
* @category Joomla_Component
* @package Com_Ajaxdemo
* @author Alan Hicks <ahicks@p-o.co.uk>
* @copyright 2010-2012 Persistent Objects Ltd
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @link http://p-o.co.uk/
*/
defined('_JEXEC') or die();
jimport('joomla.application.component.model');
/**
* Model for Ajax demonstration
*
* @category Joomla_Component
* @package Com_Ajaxdemo
* @author Alan Hicks <ahicks@p-o.co.uk>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @link http://p-o.co.uk/
*/
class AjaxdemoModelColour extends JModel
{
/**
* Retrieves the colour data
*
* @return stdClass containing the data from the database
*/
function getItem()
{
JLog::add(__METHOD__ . '()', JLog::ERROR, COM_AJAXDEMO);
// Lets load the data if it doesn't already exist
if (empty( $this->_data )) {
$row =& $this->getTable();
$row->load(JRequest::getVar('id', 0, '', 'int'));
$this->_data =& $row;
}
if (!$this->_data) {
$this->_data = new stdClass();
$this->_data->id = 0;
$this->_data->ordering = 0;
$this->_data->published = 1;
$this->_data->date = '';
$this->_data->title = '';
$this->_data->alias = '';
$this->_data->url = '';
$this->_data->material = '';
$this->_data->size = '';
$this->_data->notes = '';
}
return $this->_data;
}
/**
* Retrieves the available colours in this series
*
* @return mixed The return value or null if the query failed.
*/
public function getColours()
{
// Get the current ordering
if (!$this->_data) {
$this->getItem();
}
if (!$this->_data) {
return null;
}
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('id, ordering, title, thumbnail_image');
$query->from('#__ajaxdemo_colour');
$query->where('published = 1');
$query->where('colour_id = ' . $this->_data->colour_id);
$query->order('ordering asc');
$db->setQuery($query);
$result = $db->loadObjectList();
return $result;
}
/**
* Retrieves the previous colour data
*
* @return stdClass containing the data from the database
*/
public function getPrevColour()
{
// Get the current ordering
if (!$this->_data) {
$this->getItem();
}
if (!$this->_data) {
return false;
}
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('s.id, c.id as colour_id, s.ordering, s.published');
$query->select('s.featured, s.title, s.alias, c.thumbnail_image, s.notes');
$query->from('#__ajaxdemo_colours s');
$query->innerjoin('#__ajaxdemo_colour c ON s.id = c.colour_id ');
$query->where('s.published = 1');
$query->where('c.published = 1 AND c.dflt = 1');
$query->where(
's.ordering < ('
. 'SELECT a.ordering '
. 'FROM #__ajaxdemo_colours a '
. 'INNER JOIN #__ajaxdemo_colour b '
. 'ON a.id = b.colour_id '
. 'WHERE b.id = '. $this->_data->id
. ')'
);
$query->order('s.ordering desc');
$query->limit(1);
$db->setQuery($query);
$result = $db->loadObject();
return $result;
}
/**
* Retrieves the next colour data
*
* @return stdClass containing the data from the database
*/
public function getNextColour()
{
// Get the current ordering
if (!$this->_data) {
$this->getItem();
}
if (!$this->_data) {
return false;
}
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('s.id, c.id as colour_id, s.ordering, s.published');
$query->select('s.featured, s.title, s.alias, c.thumbnail_image, s.notes');
$query->from('#__ajaxdemo_colours s');
$query->innerjoin('#__ajaxdemo_colour c ON s.id = c.colour_id ');
$query->where('s.published = 1');
$query->where('c.published = 1 AND c.dflt = 1');
$query->where(
's.ordering > ('
. 'SELECT a.ordering '
. 'FROM #__ajaxdemo_colours a '
. 'INNER JOIN #__ajaxdemo_colour b '
. 'ON a.id = b.colour_id '
. 'WHERE b.id = '. $this->_data->id
. ')'
);
$query->order('s.ordering asc');
$query->limit(1);
$db->setQuery($query);
$result = $db->loadObject();
return $result;
}
}

52
site/models/colours.php Normal file
View File

@ -0,0 +1,52 @@
<?php
/**
* Ajax demonstration component
*
* PHP version 5.3
*
* @category Joomla_Component
* @package Com_Ajaxdemo
* @author Alan Hicks <ahicks@p-o.co.uk>
* @copyright 2010-2012 Persistent Objects Ltd
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @link http://p-o.co.uk/
*/
defined('_JEXEC') or die();
jimport('joomla.application.component.modellist');
/**
* Model for Ajax demonstration
*
* @category Joomla_Component
* @package Com_Ajaxdemo
* @author Alan Hicks <ahicks@p-o.co.uk>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @link http://p-o.co.uk/
*/
class AjaxdemoModelColours extends JModelList
{
/**
* Returns list query
*
* @return string sql list query
*/
protected function getListQuery()
{
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('s.id, c.id as colour_id, s.ordering, s.published');
$query->select('s.featured, s.title, s.alias, c.thumbnail_image, s.notes');
$query->from('#__ajaxdemo_colours s');
$query->innerjoin('#__ajaxdemo_colour c ON s.id = c.colour_id ');
$query->where('s.published = 1 AND s.featured = 1');
$query->where('c.published = 1 AND c.dflt = 1');
$query->order('s.ordering asc');
return $query;
}
}

1
site/models/index.html Normal file
View File

@ -0,0 +1 @@
<html><body bgcolor="#fff"></body></html>