administrator map
menufaqtopadministrator/languages/en-GB.com_mycomponent.ini
# elements
YOU HAVE NO CATEGORIES CONFIGIRED YET=You have no categories configured yet
#Categories XML
MYCOMPONENT CATEGORY LIST LAYOUT=Mycomponent Categories List Layout
MYCOMPONENT CATEGORY LIST LAYOUT DESC=This layout shows a list of all the Mycomponent Categories.
PARAMIMAGE=Image for page must be located in the /images/stories folder. No image will mean an image is not loaded.
ALIGNMENT OF THE IMAGE=Alignment of the Image
PARAMSHOWFEEDLINK=Show a Feed Link
#Category XML
MYCOMPONENT STANDARD CATEGORY LAYOUT=Mycomponent Category List Layout
MYCOMPONENT STANDARD CATEGORY LAYOUT DESC=This layout shows a list of all the items within a particular Category.
PARAMITEMSELECT=Select a Item
#Item XML
MYCOMPONENT STANDARD ITEM LAYOUT=Mycomponent Item Layout
MYCOMPONENT STANDARD ITEM LAYOUT DESC=This layout shows 1 item.
PARAMDROPDOWN=Show items dropdown
DROPDOWN=Show dropdown
SHOWCATEGORYINBREADCRUMBS=Show Category in Breadcrumbs
SHOWCATEGORYINBREADCRUMBSDESC=Show/Hide the category in the breadcrumbs
#Admin helper
YOU HAVE NO CATEGORIES CONFIGURED YET = Please create a categorie first.
#Admin model item
RESOURCE NOT FOUND= Resource Not Found
ALERTNOTAUTH= You have no access to view this category
#Admin table
PLEASE PROVIDE A VALID TITLE = Please provide a valid title
WARNNAMETRYAGAIN= There is already an item with title
#Admin view item view
DESCBEINGEDITTED=Somebody else is editing this item, or this item is locked. Contact the Super Administrator of this website to unlock this item.
THE LIST=The List
#Admin view item form
PLEASE GIVE A TITLE=Please give a title
PLEASE SELECT A CATEGORY=Please select a category
DETAILS=Details
TITLE=Title
ALIAS=Alias
PUBLISHED=Published
CATEGORY=Category
ORDERING=Ordering
CUSTOM FIELDS=Custom Fields
NEW=New
#Your custom fields
TEXT=text
PICTURE=picture
DATE=date
#Admin view projects default
MYCOMPONENT= mycomponent
FILTER=Filter
GO=Go
RESET=Reset
NUM=Num
EDIT=Edit
EDIT CATEGORY=Edit Category
THERE ARE NO ITEMS PRESENT= There are no items present
#Admin Controller
ITEM SAVED=Item Saved
ERROR SAVING ITEM=Error Saving Item
SELECT AN ITEM TO DELETE=Select an item to delete
SELECT AN ITEM TO PUBLISHSelect an item to publish
SELECT AN ITEM TO UNPUBLISH=Select an item to unpublish
NEW ORDERING SAVED=New ordering saved
#Config.xml
SHOW/HIDE THE DESCRIPTION BELOW=Show/Hide the description below
MYCOMPONENT_INTRO_DESC=mycomponent intro description
MYCOMPONENT INTRO=mycomponent intro
PARAMWHENVIEWCAT=Show/Hide other mycomponent Categories
OTHER CATEGORIES=Other Categories
SHOW/HIDE THE HITS COLUMN=Show/Hide the hits column
SHOW/HIDE THE TABLE HEADINGS=Show/Hide the table headings
TABLE HEADINGS=Table Headings
CATEGORY LIST - SECTION=Category List (Section)
CATEGORY LIST - CATEGORY=Category List (Category)
DESCRIPTION TEXT=Description Text
DESCNEWITEMSLAST=New item default to the last position. Ordering can be changed after this item is saved.
menufaqtop
administrator/languages/en-GB.com_mycomponent.menu.ini
COM_MYCOMPONENT=mycomponent
COM_MYCOMPONENT.ITEM=item
COM_MYCOMPONENT.CATEGORIES=Categories
menufaqtop
administrator/elements/item.php
/**
* Joomla! 1.5 component mycomponent
* Code generated by :
* Danny's Joomla! 1.5 MVC Component Code Generator
* v 0.2.1 beta http://www.joomlafreak.be
* date generated: Thu 09 September 2010 16:21
* @package mycomponent
* @license GNU Public License
**/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
// Include library dependencies
jimport('joomla.filter.input');
class JElementItem extends JElement
{
/**
* Element name
*
* @access protected
* @var string
*/
var $_name = 'Item';
function fetchElement($name, $value, &$node, $control_name)
{
$db = &JFactory::getDBO();
$query = 'SELECT a.id, CONCAT( a.title ) AS text, a.catid '
. ' FROM #__mycomponent AS a'
. ' INNER JOIN #__categories AS c ON a.catid = c.id'
. ' WHERE a.published = 1'
. ' AND c.published = 1'
. ' ORDER BY a.catid, a.title'
;
$db->setQuery( $query );
$options = $db->loadObjectList( );
return JHTML::_('select.genericlist', $options, ''.$control_name.'['.$name.']', 'class="inputbox"', 'id', 'text', $value, $control_name.$name );
}
}
menufaqtop
administrator/helpers/helper.php
/**
* Joomla! 1.5 component mycomponent
* Code generated by :
* Danny's Joomla! 1.5 MVC Component Code Generator
* v 0.2.1 beta http://www.joomlafreak.be
* date generated: Thu 09 September 2010 16:21
* @package mycomponent
* @license GNU Public License
**/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
/**
* @package mycomponent
*/
class MycomponentHelper
{
function checkCategories() {
global $mainframe ;
$db =& JFactory::getDBO();
$db->setQuery( "SELECT * FROM #__categories WHERE `section`='com_mycomponent'" ) ;
$rows = $db->loadAssocList() ;
if(empty($rows)) {
$mainframe->enqueueMessage( JText::_( 'You have no categories configured yet' ), 'notice' ) ;
return false ;
}
return true ;
}
}
menufaqtop
administrator/models/mycomponent.php
/**
* Joomla! 1.5 component mycomponent
* Code generated by :
* Danny's Joomla! 1.5 MVC Component Code Generator
* v 0.2.1 beta http://www.joomlafreak.be
* date generated: Thu 09 September 2010 16:21
* @package mycomponent
* @license GNU Public License
**/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.application.component.model');
class MycomponentModelMycomponent extends JModel
{
/**
* Mycomponent array
*
* @var array
*/
var $_data = null;
/**
* Mycomponent total
*
* @var integer
*/
var $_total = null;
/**
* Pagination object
*
* @var object
*/
var $_pagination = null;
/**
* Constructor
*/
function __construct()
{
parent::__construct();
global $mainframe, $option;
// Get the pagination request variables
$limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
$limitstart = $mainframe->getUserStateFromRequest( $option.'limitstart', 'limitstart', 0, 'int' );
$this->setState('limit', $limit);
$this->setState('limitstart', $limitstart);
}
/**
* Method to get mycomponent item data
*
* @access public
* @return array
*/
function getData()
{
// Lets load the content if it doesn't already exist
if (empty($this->_data))
{
$query = $this->_buildQuery();
$this->_data = $this->_getList($query, $this->getState('limitstart'), $this->getState('limit'));
}
return $this->_data;
}
/**
* Method to get the total number of mycomponent items
*
* @access public
* @return integer
*/
function getTotal()
{
// Lets load the content if it doesn't already exist
if (empty($this->_total))
{
$query = $this->_buildQuery();
$this->_total = $this->_getListCount($query);
}
return $this->_total;
}
/**
* Method to get a pagination object for mycomponent
*
* @access public
* @return integer
*/
function getPagination()
{
// Lets load the content if it doesn't already exist
if (empty($this->_pagination))
{
jimport('joomla.html.pagination');
$this->_pagination = new JPagination( $this->getTotal(), $this->getState('limitstart'), $this->getState('limit') );
}
return $this->_pagination;
}
function _buildQuery()
{
// Get the WHERE and ORDER BY clauses for the query
$where = $this->_buildContentWhere();
$orderby = $this->_buildContentOrderBy();
$query = ' SELECT a.*, cc.title AS category, u.name AS editor '
. ' FROM #__mycomponent AS a '
. ' LEFT JOIN #__categories AS cc ON cc.id = a.catid '
. ' LEFT JOIN #__users AS u ON u.id = a.checked_out '
. $where
. $orderby
;
return $query;
}
function _buildContentOrderBy()
{
global $mainframe, $option;
$filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'a.ordering', 'cmd' );
$filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' );
if ($filter_order == 'a.ordering'){
$orderby = ' ORDER BY category, a.ordering '.$filter_order_Dir;
} else {
$orderby = ' ORDER BY '.$filter_order.' '.$filter_order_Dir.' , category, a.ordering ';
}
return $orderby;
}
function _buildContentWhere()
{
global $mainframe, $option;
$filter_state = $mainframe->getUserStateFromRequest( $option.'filter_state', 'filter_state', '', 'word' );
$filter_catid = $mainframe->getUserStateFromRequest( $option.'filter_catid', 'filter_catid', 0, 'int' );
$filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'a.ordering', 'cmd' );
$filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' );
$search = $mainframe->getUserStateFromRequest( $option.'search', 'search', '', 'string' );
$search = JString::strtolower( $search );
$where = array();
if ($filter_catid > 0) {
$where[] = 'a.catid = '.(int) $filter_catid;
}
if ($search) {
$where[] = 'LOWER(a.title) LIKE '.$this->_db->Quote('%'.$search.'%');
}
if ( $filter_state ) {
if ( $filter_state == 'P' ) {
$where[] = 'a.published = 1';
} else if ($filter_state == 'U' ) {
$where[] = 'a.published = 0';
}
}
$where = ( count( $where ) ? ' WHERE '. implode( ' AND ', $where ) : '' );
return $where;
}
}
?>
menufaqtop
administrator/models/item.php
/**
* Joomla! 1.5 component mycomponent
* Code generated by :
* Danny's Joomla! 1.5 MVC Component Code Generator
* v 0.2.1 beta http://www.joomlafreak.be
* date generated: Thu 09 September 2010 16:21
* @package mycomponent
* @license GNU Public License
**/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.application.component.model');
class MycomponentModelItem extends JModel
{
/**
* Item id
*
* @var int
*/
var $_id = null;
/**
* Item data
*
* @var array
*/
var $_data = null;
/**
* Constructor
*
*/
function __construct()
{
parent::__construct();
$array = JRequest::getVar('cid', array(0), '', 'array');
$edit = JRequest::getVar('edit',true);
if($edit)
$this->setId((int)$array[0]);
}
/**
* Method to set the item identifier
*
* @access public
* @param int Item identifier
*/
function setId($id)
{
// Set item id and wipe data
$this->_id = $id;
$this->_data = null;
}
/**
* Method to get a item
*
*/
function &getData()
{
// Load the item data
if ($this->_loadData())
{
// Initialize some variables
$user = &JFactory::getUser();
// Check to see if the category is published
if (!$this->_data->cat_pub) {
JError::raiseError( 404, JText::_("Resource Not Found") );
return;
}
// Check whether category access level allows access
if ($this->_data->cat_access > $user->get('aid', 0)) {
JError::raiseError( 403, JText::_('ALERTNOTAUTH') );
return;
}
}
else $this->_initData();
return $this->_data;
}
/**
* Tests if item is checked out
*
* @access public
* @param int A user id
* @return boolean True if checked out
*/
function isCheckedOut( $uid=0 )
{
if ($this->_loadData())
{
if ($uid) {
return ($this->_data->checked_out && $this->_data->checked_out != $uid);
} else {
return $this->_data->checked_out;
}
}
}
/**
* Method to checkin/unlock the item
*
* @access public
* @return boolean True on success
*/
function checkin()
{
if ($this->_id)
{
$item = & $this->getTable();
if(! $item->checkin($this->_id)) {
$this->setError($this->_db->getErrorMsg());
return false;
}
}
return false;
}
/**
* Method to checkout/lock the item
*
* @access public
* @param int $uid User ID of the user checking the article out
* @return boolean True on success
*/
function checkout($uid = null)
{
if ($this->_id)
{
// Make sure we have a user id to checkout the article with
if (is_null($uid)) {
$user =& JFactory::getUser();
$uid = $user->get('id');
}
// Lets get to it and checkout the thing...
$item = & $this->getTable();
if(!$item->checkout($uid, $this->_id)) {
$this->setError($this->_db->getErrorMsg());
return false;
}
return true;
}
return false;
}
/**
* Method to store the item
*
* @access public
* @return boolean True on success
*/
function store($data)
{
$row =& $this->getTable();
// Bind the form fields to the item table
if (!$row->bind($data)) {
$this->setError($this->_db->getErrorMsg());
return false;
}
// if new item, order last in appropriate group
if (!$row->id) {
$where = 'catid = ' . (int) $row->catid ;
$row->ordering = $row->getNextOrder( $where );
}
// Make sure the item table is valid
if (!$row->check()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
// Store the item table to the database
if (!$row->store()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
return true;
}
/**
* Method to remove a item
*
* @access public
* @return boolean True on success
*/
function delete($cid = array())
{
$result = false;
if (count( $cid ))
{
JArrayHelper::toInteger($cid);
$cids = implode( ',', $cid );
$query = 'DELETE FROM #__mycomponent'
. ' WHERE id IN ( '.$cids.' )';
$this->_db->setQuery( $query );
if(!$this->_db->query()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
}
return true;
}
/**
* Method to (un)publish a item
*
* @access public
* @return boolean True on success
*/
function publish($cid = array(), $publish = 1)
{
$user =& JFactory::getUser();
if (count( $cid ))
{
JArrayHelper::toInteger($cid);
$cids = implode( ',', $cid );
$query = 'UPDATE #__mycomponent'
. ' SET published = '.(int) $publish
. ' WHERE id IN ( '.$cids.' )'
. ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id').' ) )'
;
$this->_db->setQuery( $query );
if (!$this->_db->query()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
}
return true;
}
/**
* Method to move a item
*
* @access public
* @return boolean True on success
*/
function move($direction)
{
$row =& $this->getTable();
if (!$row->load($this->_id)) {
$this->setError($this->_db->getErrorMsg());
return false;
}
if (!$row->move( $direction, ' catid = '.(int) $row->catid.' AND published >= 0 ' )) {
$this->setError($this->_db->getErrorMsg());
return false;
}
return true;
}
/**
* Method to move a item
*
* @access public
* @return boolean True on success
*/
function saveorder($cid = array(), $order)
{
$row =& $this->getTable();
$groupings = array();
// update ordering values
for( $i=0; $i < count($cid); $i++ )
{
$row->load( (int) $cid[$i] );
// track categories
$groupings[] = $row->catid;
if ($row->ordering != $order[$i])
{
$row->ordering = $order[$i];
if (!$row->store()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
}
}
// execute updateOrder for each parent group
$groupings = array_unique( $groupings );
foreach ($groupings as $group){
$row->reorder('catid = '.(int) $group);
}
return true;
}
/**
* Method to load content item data
*
* @access private
* @return boolean True on success
*/
function _loadData()
{
// Lets load the item if it doesn't already exist
if (empty($this->_data))
{
$query = 'SELECT w.*, cc.title AS category,'.
' cc.published AS cat_pub, cc.access AS cat_access'.
' FROM #__mycomponent AS w' .
' LEFT JOIN #__categories AS cc ON cc.id = w.catid' .
' WHERE w.id = '.(int) $this->_id;
$this->_db->setQuery($query);
$this->_data = $this->_db->loadObject();
return (boolean) $this->_data;
}
return true;
}
/**
* Method to initialise the item data
*
* @access private
* @return boolean True on success
*/
function _initData()
{
// Lets load the item if it doesn't already exist
if (empty($this->_data))
{
$item = new stdClass();
$item->id = 0;
$item->catid = 0;
$item->sid = 0;
$item->title = null;
$item->alias = null;
$item->text = null;
$item->picture = null;
$item->date = null;
$item->created = null;
$item->created_by = 0;
$item->created_by_alias = null;
$item->modified_by = 0;
$item->checked_out = 0;
$item->checked_out_time = 0;
$item->published = 0;
$item->ordering = 0;
$item->params = null;
$item->hits = 0;
$this->_data = $item;
return (boolean) $this->_data;
}
return true;
}
}
?>