Component Values

administrator map

menufaqtop

administrator/languages/en-GB.com_mycomponent.ini

# Note : All ini files need to be saved as UTF-8 - No BOM

# 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

# Note : All ini files need to be saved as UTF-8 - No BOM
COM_MYCOMPONENT=mycomponent
COM_MYCOMPONENT.ITEM=item
COM_MYCOMPONENT.CATEGORIES=Categories

menufaqtop

administrator/elements/item.php

<?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: Sun 05 February 2012 10:10
* @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

<?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: Sun 05 February 2012 10:10
* @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

<?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: Sun 05 February 2012 10:10
* @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

<?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: Sun 05 February 2012 10:10
* @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;
}
}
?>


menufaqtop

administrator/tables/item.php

<?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: Sun 05 February 2012 10:10
* @package mycomponent
* @license GNU Public License
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

// Include library dependencies
jimport('joomla.filter.input');

/**
* Mycomponent Item Table class
* @package Mycomponent
*/
class TableItem extends JTable {
/**
* Primary Key
*
* @var int
*/
var $id = null;

/**
* @var int
*/
var $catid = null;

/**
* @var string
*/
var $title = null;

/**
* @var string
*/
var $alias = null;

/**
* @var string
*/
var $text = null;

/**
* @var string
*/
var $picture = null;

/**
* @var string
*/
var $date = null;

/**
* @var datetime
*/
var $created = null;

/**
* @var int
*/
var $created_by = null;

/**
* @var string
*/
var $created_by_alias = null;

/**
* @var datetime
*/
var $modified = null;

/**
* @var int
*/
var $modified_by = null;

/**
* @var boolean
*/
var $checked_out = 0;

/**
* @var time
*/
var $checked_out_time = 0;

/**
* @var int
*/
var $published = null;

/**
* @var int
*/
var $ordering = null;

/**
* @var int
*/
var $hits = null;

/**
* Constructor
*
* @param object Database connector object
*/
function __construct(& $db) {
parent :: __construct('#__mycomponent', 'id', $db);
}

/**
* Overloaded bind function
*
* @acces public
* @param array $hash named array
* @return null|string null is operation was satisfactory, otherwise returns an error
* @see JTable:bind
*/
function bind($array, $ignore = '') {
if (key_exists('params', $array) && is_array($array['params'])) {
$registry = new JRegistry();
$registry->loadArray($array['params']);
$array['params'] = $registry->toString();
}

return parent :: bind($array, $ignore);
}

/**
* Overloaded check method to ensure data integrity
*
* @access public
* @return boolean True on success
*/
function check() {
/** check for valid name */
if (trim($this->title) == '') {
$this->_error = JText :: _('Please provide a valid title');
return false;
}

/** check for existing name */
$query = 'SELECT id FROM #__mycomponent WHERE title = ' . $this->_db->Quote($this->title) . ' AND catid = ' . (int) $this->catid;
$this->_db->setQuery($query);

$xid = intval($this->_db->loadResult());
if ($xid && $xid != intval($this->id)) {
$this->_error = JText :: sprintf('WARNNAMETRYAGAIN', JText :: _('Item'));
return false;
}
if(empty($this->alias)) {
$this->alias = $this->title;
}
$this->alias = JFilterOutput::stringURLSafe($this->alias);
if(trim(str_replace('-','',$this->alias)) == '') {
$datenow =& JFactory::getDate();
$this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S");
}

jimport('joomla.filter.output');

return true;
}
}
?>


menufaqtop

administrator/views/item/tmpl/form.php

<?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: Sun 05 February 2012 10:10
* @package mycomponent
* @license GNU Public License
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
?>

<?php JHTML::_('behavior.tooltip'); ?>

<?php
// Set toolbar items for the page
$edit = JRequest :: getVar('edit', true);
$text = !$edit ? JText :: _('New') : JText :: _('Edit');
JToolBarHelper :: title(JText :: _('Item') . ': <small>[ ' . $text . ' ]</small>');
JToolBarHelper :: save();
JToolBarHelper :: apply();
if (!$edit) {
JToolBarHelper :: cancel();
} else {
JToolBarHelper :: cancel('cancel', 'Close');
}
?>

<script language="javascript" type="text/javascript">
<!--

function submitbutton(pressbutton) {
var form = document.adminForm;
if (pressbutton == 'cancel') {
submitform( pressbutton );
return;
}

// do field validation
if (form.title.value == ""){
alert( "<?php echo JText::_( 'Please give a title', true ); ?>" );
} else if (form.catid.value == "0"){
alert( "<?php echo JText::_( 'Please select a category', true ); ?>" );
} else {
submitform( pressbutton );
}
}
-->
</script>

<form action="index.php" method="post" name="adminForm" id="adminForm">
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td width="50%" valign="top">
<fieldset class="adminform">
<legend><?php echo JText::_( 'Details' ); ?></legend>
<table class="admintable">
<tr>
<td width="100" align="right" class="key">
<label for="title">
<?php echo JText::_( 'Title' ); ?>:
</label>
</td>
<td>
<input class="text_area" type="text" name="title" id="title" size="48" maxlength="250" value="<?php echo $this->item->title;?>" />
</td>
</tr>
<tr>
<td width="100" align="right" class="key">
<label for="alias">
<?php echo JText::_( 'Alias' ); ?>:
</label>
</td>
<td>
<input class="text_area" type="text" name="alias" id="alias" size="32" maxlength="250" value="<?php echo $this->item->alias;?>" />
</td>
</tr>
<tr>
<td valign="top" align="right" class="key">
<?php echo JText::_( 'Published' ); ?>:
</td>
<td>
<?php echo $this->lists['published']; ?>
</td>
</tr>
<tr>
<td valign="top" align="right" class="key">
<label for="catid">
<?php echo JText::_( 'Category' ); ?>:
</label>
</td>
<td>
<?php echo $this->lists['catid']; ?>
</td>
</tr>
<td valign="top" align="right" class="key">
<label for="ordering">
<?php echo JText::_( 'Ordering' ); ?>:
</label>
</td>
<td>
<?php echo $this->lists['ordering']; ?>
</td>
</tr>
</table>
</fieldset>
<fieldset class="adminform">
<legend><?php echo JText::_( 'Custom Fields' ); ?></legend>
<table class="admintable" width="100%">
<tr>
<td width="100" align="right" class="key">
<label for="text">
<?php echo JText::_( 'Text' ); ?>:
</label>
</td>
<td>
<input class="text_area" type="text" name="text" id="text" size="32" maxlength="250" value="<?php echo $this->item->text;?>" />
</td>
</tr> <tr>
<td width="100" align="right" class="key">
<label for="picture">
<?php echo JText::_( 'Picture' ); ?>:
</label>
</td>
<td>
<input class="text_area" type="text" name="picture" id="picture" size="32" maxlength="250" value="<?php echo $this->item->picture;?>" />
</td>
</tr> <tr>
<td width="100" align="right" class="key">
<label for="date">
<?php echo JText::_( 'Date' ); ?>:
</label>
</td>
<td>
<input class="text_area" type="text" name="date" id="date" size="32" maxlength="250" value="<?php echo $this->item->date;?>" />
</td>
</tr>

</table>

</fieldset>
</td>
<td valign="top">
<fieldset class="adminform">
<legend><?php echo JText::_( 'More Fields' ); ?></legend>
todo...
</fieldset>
</td>
</tr>
</table>

<input type="hidden" name="option" value="com_mycomponent" />
<input type="hidden" name="cid[]" value="<?php echo $this->item->id; ?>" />
<input type="hidden" name="task" value="" />
</form>


menufaqtop

administrator/views/item/view.html.php

<?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: Sun 05 February 2012 10:10
* @package mycomponent
* @license GNU Public License
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.view');

/**
* HTML View class for the mycomponent component
*
* @static
* @package Mycomponent
*/
class MycomponentViewItem extends JView
{
function display($tpl = null)
{
global $mainframe;

if($this->getLayout() == 'form') {
$this->_displayForm( $tpl );
return;
}

//get the item
$item =& $this->get('data');

parent::display($tpl);
}

function _displayForm($tpl)
{
global $mainframe, $option;

$db =& JFactory::getDBO();
$uri =& JFactory::getURI();
$user =& JFactory::getUser();
$model =& $this->getModel( 'item' );

$lists = array();

MycomponentHelper::checkCategories() ;

//get the item
$item =& $this->get('data');
$isNew = ($item->id < 1);

// fail if checked out not by 'me'
if ($model->isCheckedOut( $user->get('id') )) {
$msg = JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The list' ), $item->title );
$mainframe->redirect( 'index.php?option='. $option, $msg );
}

// Edit or Create?
if (!$isNew)
{
$model->checkout( $user->get('id') );
}
else
{
// initialise new record

$item->published = 1;
$item->order = 0;
$item->catid = JRequest::getVar( 'catid', 0, 'post', 'int' );
}

// build the html select list for ordering
$query = 'SELECT ordering AS value, title AS text'
. ' FROM #__mycomponent'
. ' WHERE catid = ' . (int) $item->catid
. ' ORDER BY ordering';

$lists['ordering'] = JHTML::_('list.specificordering', $item, $item->id, $query, 1 );
$lists['catid'] = JHTML::_('list.category', 'catid', $option, intval( $item->catid ) );
$lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $item->published );

 

//clean item data
jimport('joomla.filter.output');
JFilterOutput::objectHTMLSafe( $item, ENT_QUOTES, 'text' );

$file = JPATH_COMPONENT.DS.'models'.DS.'item.xml';
$params = new JParameter( $item->params, $file );

$this->assignRef('lists', $lists);
$this->assignRef('item', $item);
$this->assignRef('params', $params);

parent::display($tpl);
}
}
?>


menufaqtop

administrator/views/mycomponent/tmpl/default.php

<?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: Sun 05 February 2012 10:10
* @package mycomponent
* @license GNU Public License
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
?>

<?php JHTML::_('behavior.tooltip'); ?>

<?php
// Set toolbar items for the page
JToolBarHelper::title( JText::_( 'Mycomponent' ), 'generic.png' );
JToolBarHelper::publishList();
JToolBarHelper::unpublishList();
JToolBarHelper::deleteList();
JToolBarHelper::editListX();
JToolBarHelper::addNewX();
?>
<form action="index.php" method="post" name="adminForm">
<table>
<tr>
<td align="left" width="100%">
<?php echo JText::_( 'Filter' ); ?>:
<input type="text" name="search" id="search" value="<?php echo $this->lists['search'];?>" class="text_area" onchange="document.adminForm.submit();" />
<button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
<button onclick="document.getElementById('search').value='';this.form.submit();"><?php echo JText::_( 'Reset' ); ?></button>
</td>
<td nowrap="nowrap">
<?php
echo $this->lists['catid'];
echo $this->lists['state'];
?>
</td>
</tr>
</table>
<div id="editcell">
<table class="adminlist">
<thead>
<tr>
<th width="5">
<?php echo JText::_( 'NUM' ); ?>
</th>
<th width="20">
<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->items ); ?>);" />
</th>
<th width="150" class="title">
<?php echo JHTML::_('grid.sort', 'Title', 'a.title', $this->lists['order_Dir'], $this->lists['order'] ); ?>
</th>
<th class="title">todo
</th>
<th width="5%" nowrap="nowrap">
<?php echo JHTML::_('grid.sort', 'Published', 'a.published', $this->lists['order_Dir'], $this->lists['order'] ); ?>
</th>
<th width="8%" nowrap="nowrap">
<?php echo JHTML::_('grid.sort', 'Order', 'a.ordering', $this->lists['order_Dir'], $this->lists['order'] ); ?>
<?php echo JHTML::_('grid.order', $this->items ); ?>
</th>
<th width="15%" class="title">
<?php echo JHTML::_('grid.sort', 'Category', 'category', $this->lists['order_Dir'], $this->lists['order'] ); ?>
</th>

<th width="1%" nowrap="nowrap">
<?php echo JHTML::_('grid.sort', 'ID', 'a.id', $this->lists['order_Dir'], $this->lists['order'] ); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="8">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php
$k = 0;
if( count( $this->items ) > 0 ) {
for ($i=0, $n=count( $this->items ); $i < $n; $i++)
{
$row = &$this->items[$i];

$link = JRoute::_( 'index.php?option=com_mycomponent&view=item&task=edit&cid[]='. $row->id );

$checked = JHTML::_('grid.checkedout', $row, $i );
$published = JHTML::_('grid.published', $row, $i );

$ordering = ($this->lists['order'] == 'a.ordering');

$row->cat_link = JRoute::_( 'index.php?option=com_categories&section=com_mycomponent&task=edit&type=other&cid[]='. $row->catid );
?>
<tr class="<?php echo "row$k"; ?>">
<td>
<?php echo $this->pagination->getRowOffset( $i ); ?>
</td>
<td>
<?php echo $checked; ?>
</td>
<td>
<?php
if ( JTable::isCheckedOut($this->user->get ('id'), $row->checked_out ) ) {
echo $row->title;
} else {
?>
<a href="<?php echo $link; ?>" title="<?php echo JText::_( 'Edit' ); ?>">
<?php echo $row->title; ?></a>
<?php
}
?>
</td>
<td align="left">&nbsp;
</td>
<td align="center">
<?php echo $published;?>
</td>
<td class="order">
<span><?php echo $this->pagination->orderUpIcon( $i, ($row->catid == @$this->items[$i-1]->catid),'orderup', 'Move Up', $ordering ); ?></span>
<span><?php echo $this->pagination->orderDownIcon( $i, $n, ($row->catid == @$this->items[$i+1]->catid), 'orderdown', 'Move Down', $ordering ); ?></span>
<?php $disabled = $ordering ? '' : 'disabled="disabled"'; ?>
<input type="text" name="order[]" size="5" value="<?php echo $row->ordering;?>" <?php echo $disabled ?> class="text_area" style="text-align: center" />
</td>
<td>
<a href="<?php echo $row->cat_link; ?>" title="<?php echo JText::_( 'Edit Category' ); ?>">
<?php echo $row->category; ?>
</a>
</td>

<td align="center">
<?php echo $row->id; ?>
</td>
</tr>
<?php
$k = 1 - $k;
}
} else {
?>
<tr>
<td colspan="7">
<?php echo JText::_( 'There are no items present' ); ?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>

<input type="hidden" name="option" value="com_mycomponent" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="" />
</form>


menufaqtop

administrator/views/mycomponent/view.html.php

<?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: Sun 05 February 2012 10:10
* @package mycomponent
* @license GNU Public License
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.view');

/**
* HTML View class for the mycomponent component
* @static
* @package Mycomponent
*/
class MycomponentViewMycomponent extends JView
{
function display($tpl = null)
{
global $mainframe, $option;

$db =& JFactory::getDBO();
$uri =& JFactory::getURI();

MycomponentHelper::checkCategories() ;

$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 );

// Get data from the model
$items = & $this->get( 'Data');
$total = & $this->get( 'Total');
$pagination = & $this->get( 'Pagination' );

// build list of categories
$javascript = 'onchange="document.adminForm.submit();"';
$lists['catid'] = JHTML::_('list.category', 'filter_catid', $option, intval( $filter_catid ), $javascript );

// state filter
$lists['state'] = JHTML::_('grid.state', $filter_state );

// table ordering
$lists['order_Dir'] = $filter_order_Dir;
$lists['order'] = $filter_order;

// search filter
$lists['search']= $search;

$this->assignRef('user', JFactory::getUser());
$this->assignRef('lists', $lists);
$this->assignRef('items', $items);
$this->assignRef('pagination', $pagination);

parent::display($tpl);
}
}
?>


menufaqtop

administrator/controller.php

<?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: Sun 05 February 2012 10:10
* @package mycomponent
* @license GNU Public License
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.controller' );
require_once( JPATH_COMPONENT.DS.'helpers'.DS.'helper.php' );

/**
* Mycomponent Controller
*
* @package Mycomponent
*/
class MycomponentController extends JController
{
function __construct()
{
parent::__construct();

// Register Extra tasks
$this->registerTask( 'add', 'display' );
$this->registerTask( 'edit', 'display' );
}

function display( )
{
switch($this->getTask())
{
case 'add' :
{
JRequest::setVar( 'hidemainmenu', 1 );
JRequest::setVar( 'layout', 'form' );
JRequest::setVar( 'view' , 'item');
JRequest::setVar( 'edit', false );

// Checkout the item
$model = $this->getModel('item');
$model->checkout();
} break;
case 'edit' :
{
JRequest::setVar( 'hidemainmenu', 1 );
JRequest::setVar( 'layout', 'form' );
JRequest::setVar( 'view' , 'item');
JRequest::setVar( 'edit', true );

// Checkout the item
$model = $this->getModel('item');
$model->checkout();
} break;
}

parent::display();
}

function store()
{
$post = JRequest::get('post');
$cid = JRequest::getVar( 'cid', array(0), 'post', 'array' );
$post['id'] = (int)$cid[0];
$this->id = $post['id'] ;
//$post['text'] = JRequest::getVar('text', '', 'post', 'string', JREQUEST_ALLOWRAW);

$model = $this->getModel('item');

if ($model->store($post)) {
$this->msg = JText::_( 'Item Saved' );
} else {
$this->msg = JText::_( 'Error Saving Item' );
}

// Check the table in so it can be edited.... we are done with it anyway
$model->checkin();
}

function save()
{
$this->store() ;
$link = 'index.php?option=com_mycomponent';
$this->setRedirect( $link, $this->msg);
}

function apply()
{
$this->store() ;
$link = 'index.php?option=com_mycomponent&view=item&task=edit&cid[]=' . $this->id ;
$this->setRedirect($link, $this->msg);
}

function remove()
{
$cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
JArrayHelper::toInteger($cid);

if (count( $cid ) < 1) {
JError::raiseError(500, JText::_( 'Select an item to delete' ) );
}

$model = $this->getModel('item');
if(!$model->delete($cid)) {
echo "<script> alert('".$model->getError(true)."'); window.history.go(-1); </script>\n";
}

$this->setRedirect( 'index.php?option=com_mycomponent' );
}

function publish()
{
$cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
JArrayHelper::toInteger($cid);

if (count( $cid ) < 1) {
JError::raiseError(500, JText::_( 'Select an item to publish' ) );
}

$model = $this->getModel('item');
if(!$model->publish($cid, 1)) {
echo "<script> alert('".$model->getError(true)."'); window.history.go(-1); </script>\n";
}

$this->setRedirect( 'index.php?option=com_mycomponent' );
}

function unpublish()
{
$cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
JArrayHelper::toInteger($cid);

if (count( $cid ) < 1) {
JError::raiseError(500, JText::_( 'Select an item to unpublish' ) );
}

$model = $this->getModel('item');
if(!$model->publish($cid, 0)) {
echo "<script> alert('".$model->getError(true)."'); window.history.go(-1); </script>\n";
}

$this->setRedirect( 'index.php?option=com_mycomponent' );
}

function cancel()
{
// Checkin the item
$model = $this->getModel('item');
$model->checkin();

$this->setRedirect( 'index.php?option=com_mycomponent' );
}

function orderup()
{
$model = $this->getModel('item');
$model->move(-1);

$this->setRedirect( 'index.php?option=com_mycomponent');
}

function orderdown()
{
$model = $this->getModel('item');
$model->move(1);

$this->setRedirect( 'index.php?option=com_mycomponent');
}

function saveorder()
{
$cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
$order = JRequest::getVar( 'order', array(), 'post', 'array' );
JArrayHelper::toInteger($cid);
JArrayHelper::toInteger($order);

$model = $this->getModel('item');
$model->saveorder($cid, $order);

$msg = 'New ordering saved';
$this->setRedirect( 'index.php?option=com_mycomponent', $msg );
}
}
?>


menufaqtop

administrator/config.xml

<?xml version="1.0" encoding="utf-8"?>
<config>
<params>
<param name="show_comp_description" type="radio" default="1" label="Description" description="Show/Hide the Description below">
<option value="0">Hide</option>
<option value="1">Show</option>
</param>
<param name="comp_description" type="textarea" default="" label="MYCOMPONENT Intro" rows="3" cols="50" description="MYCOMPONENT_INTRO_DESC" />
<param name="@spacer" type="spacer" default="" label="" description="" />
<param name="show_other_cats" type="radio" default="1" label="Other Categories" description="PARAMWHENVIEWCAT">
<option value="0">Hide</option>
<option value="1">Show</option>
</param>
<param name="show_headings" type="radio" default="1" label="Table Headings" description="Show/Hide the Table Headings">
<option value="0">Hide</option>
<option value="1">Show</option>
</param>
</params>
</config>

 


menufaqtop

administrator/mycomponent.php

<?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: Sun 05 February 2012 10:10
* @package mycomponent
* @license GNU Public License
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

// Require the base controller
require_once (JPATH_COMPONENT.DS.'controller.php');

$controller = new MycomponentController( );

// Perform the Request task
$controller->execute( JRequest::getCmd('task'));
$controller->redirect();

?>


menufaqtop

administrator/install.mysql.sql

CREATE TABLE IF NOT EXISTS `#__mycomponent` (
`id` int(11) unsigned NOT NULL auto_increment,
`catid` int(11) unsigned NOT NULL default '0',
`sid` int(11) unsigned NOT NULL default '0',
`title` varchar(255) NOT NULL default '',
`alias` varchar(255) NOT NULL default '',
`text` varchar(255) NOT NULL default '',
`picture` varchar(255) NOT NULL default '',
`date` varchar(255) NOT NULL default '',
`created` datetime NOT NULL default '0000-00-00 00:00:00',
`created_by` int(11) unsigned NOT NULL default '0',
`created_by_alias` varchar(255) NOT NULL default '',
`modified` datetime NOT NULL default '0000-00-00 00:00:00',
`modified_by` int(11) unsigned NOT NULL default '0',
`checked_out` int(11) unsigned NOT NULL default '0',
`checked_out_time` datetime NOT NULL default '0000-00-00 00:00:00',
`published` tinyint(1) NOT NULL default '0',
`ordering` int(11) NOT NULL default '0',
`params` text NOT NULL,
`hits` int(11) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
);

menufaqtop

administrator/uninstall.mysql.sql

DROP TABLE #__mycomponent;

component map

menufaqtop

components/language/en-GB.com_mycomponent.ini

# Note : All ini files need to be saved as UTF-8 - No BOM

RESOURCE NOT FOUND= Resource Not Found
ALERTNOTAUTH= You have no access to view this category
MYCOMPONENT= mycomponent
MYCOMPONENT_DESC= mycomponent description
DISPLAY NUM=Display #
NUM=#
ALL=All
CLICK TO SORT THIS COLUMN=Click to sort by this column.
DESCNEWITEMSLAST=New items default to the last position. Ordering can be changed after this item has been saved.
DESCRIPTION=Description
HITS=Hits
NO=No
NUM=#
ORDERING=Ordering
#Your custom fields
TEXT=text
PICTURE=picture
DATE=date


menufaqtop

components/models/categories.php

<?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: Sun 05 February 2012 10:10
* @package mycomponent
* @license GNU Public License
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.application.component.model');

/**
* Mycomponent Component Categories Model
*
* @package Mycomponent
*/
class MycomponentModelCategories extends JModel
{
/**
* Categories data array
*
* @var array
*/
var $_data = null;

/**
* Categories total
*
* @var integer
*/
var $_total = null;

/**
* Constructor
*
* @since 1.5
*/

function __construct()
{
parent::__construct();

}

/**
* Method to get item item data for the category
*
* @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);
}

return $this->_data;
}

/**
* Method to get the total number of item items for the category
*
* @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;
}

function _buildQuery()
{
$user =& JFactory::getUser();
$aid = $user->get('aid', 0);

//Query to retrieve all categories that belong under the mycomponent section and that are published.
$query = 'SELECT cc.*, COUNT(a.id) AS numlinks,'
.' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(\':\', cc.id, cc.alias) ELSE cc.id END as slug'
.' FROM #__categories AS cc'
.' LEFT JOIN #__mycomponent AS a ON a.catid = cc.id'
.' WHERE a.published = 1'
.' AND section = \'com_mycomponent\''
.' AND cc.published = 1'
.' AND cc.access <= '.(int) $aid
.' GROUP BY cc.id'
.' ORDER BY cc.ordering';

return $query;
}
}
?>


menufaqtop

components/models/category.php

<?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: Sun 05 February 2012 10:10
* @package mycomponent
* @license GNU Public License
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.application.component.model');

class MycomponentModelCategory extends JModel
{
/**
* Category id
*
* @var int
*/
var $_id = null;

/**
* Category ata array
*
* @var array
*/
var $_data = null;

/**
* Category total
*
* @var integer
*/
var $_total = null;

/**
* Category data
*
* @var object
*/
var $_category = null;

/**
* Pagination object
*
* @var object
*/
var $_pagination = null;

/**
* Constructor
*
* @since 1.5
*/
function __construct()
{
parent::__construct();

global $mainframe;

$config = JFactory::getConfig();

// Get the pagination request variables
$this->setState('limit', $mainframe->getUserStateFromRequest('com_mycomponent.limit', 'limit', $config->getValue('config.list_limit'), 'int'));
$this->setState('limitstart', JRequest::getVar('limitstart', 0, '', 'int'));

// In case limit has been changed, adjust limitstart accordingly
$this->setState('limitstart', ($this->getState('limit') != 0 ? (floor($this->getState('limitstart') / $this->getState('limit')) * $this->getState('limit')) : 0));

// Get the filter request variables
$this->setState('filter_order', JRequest::getCmd('filter_order', 'ordering'));
$this->setState('filter_order_dir', JRequest::getCmd('filter_order_Dir', 'ASC'));

$id = JRequest::getVar('id', 0, '', 'int');
$this->setId((int)$id);
}

/**
* Method to set the category id
*
* @access public
* @param int category ID number
*/
function setId($id)
{
// Set category ID and wipe data
$this->_id = $id;
$this->_category = null;
}

/**
* Method to get item item data for the category
*
* @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'));

$total = count($this->_data);
for($i = 0; $i < $total; $i++)
{
$item =& $this->_data[$i];
$item->slug = $item->id.':'.$item->alias;
}
}

return $this->_data;
}

/**
* Method to get the total number of item items for the category
*
* @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 of the item items for the category
*
* @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;
}

/**
* Method to get category data for the current category
*
* @since 1.5
*/
function getCategory()
{
// Load the Category data
if ($this->_loadCategory())
{
// Initialize some variables
$user = &JFactory::getUser();

// Make sure the category is published
//if (!$this->_category->published) {
//JError::raiseError(404, JText::_("Resource Not Found"));
//return false;
//}
// check whether category access level allows access
if ($this->_category->access > $user->get('aid', 0)) {
JError::raiseError(403, JText::_("ALERTNOTAUTH"));
return false;
}
}
return $this->_category;
}

/**
* Method to load category data if it doesn't exist.
*
* @access private
* @return boolean True on success
*/
function _loadCategory()
{
if (empty($this->_category))
{
// current category info
$query = 'SELECT c.*, ' .
' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as slug '.
' FROM #__categories AS c' .
' WHERE c.id = '. (int) $this->_id .
' AND c.section = "com_mycomponent"';
$this->_db->setQuery($query, 0, 1);
$this->_category = $this->_db->loadObject();
}
return true;
}

function _buildQuery()
{
$filter_order = $this->getState('filter_order');
$filter_order_dir = $this->getState('filter_order_dir');

$filter_order = JFilterInput::clean($filter_order, 'cmd');
$filter_order_dir = JFilterInput::clean($filter_order_dir, 'word');

// We need to get a list of all items in the given category
$query = 'SELECT *' .
' FROM #__mycomponent' .
' WHERE catid = '. (int) $this->_id.
' AND published = 1' .
//' AND archived = 0'.
' ORDER BY '. $filter_order .' '. $filter_order_dir .', ordering';

return $query;
}
}


menufaqtop

components/models/item.php

<?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: Sun 05 February 2012 10:10
* @package mycomponent
* @license GNU Public License
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.application.component.model');

/**
* Mycomponent Component Item Model
* @package Mycomponent
*/
class MycomponentModelItem extends JModel
{
/**
* Item id
*
* @var int
*/
var $_id = null;

/**
* Item data
*
* @var array
*/
var $_data = null;

/**
* Constructor
*
* @since 1.5
*/
function __construct()
{
parent::__construct();

$id = JRequest::getVar('id', 0, '', 'int');
$this->setId((int)$id);
}

/**
* 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
*
* @since 1.5
*/
function &getData()
{
// Load the item data
if ($this->_loadData())
{
// Initialize some variables
$user = &JFactory::getUser();

// Make sure the item is published
if (!$this->_data->published) {
JError::raiseError(404, JText::_("Resource Not Found"));
return false;
}

// 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;
}

/**
* Method to increment the hit counter for the item
*
* @access public
* @return boolean True on success
* @since 1.5
*/
function hit()
{
global $mainframe;

if ($this->_id)
{
$item = & $this->getTable();
$item->hit($this->_id);
return true;
}
return false;
}

 

/**
* Method to load content item data
*
* @access private
* @return boolean True on success
*/
function _loadData()
{
// Lets load the content 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;
}

}

menufaqtop

components/views/categories/tmpl/default.php

<?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: Sun 05 February 2012 10:10
* @package mycomponent
* @license GNU Public License
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
?>
<?php if ( $this->params->def( 'show_page_title', 1 ) ) : ?>
<div class="componentheading<?php echo $this->params->get( 'pageclass_sfx' ); ?>">
<?php echo $this->escape($this->params->get('page_title')); ?>
</div>
<?php endif; ?>

<?php if ( ($this->params->def('image', -1) != -1) || $this->params->def('show_comp_description', 1) ) : ?>
<table width="100%" cellpadding="4" cellspacing="0" border="0" align="center" class="contentpane<?php echo $this->params->get( 'pageclass_sfx' ); ?>">
<tr>
<td valign="top" class="contentdescription<?php echo $this->params->get( 'pageclass_sfx' ); ?>">
<?php
if ( isset($this->image) ) : echo $this->image; endif;
echo $this->params->get('comp_description');
?>
</td>
</tr>
</table>
<?php endif; ?>
<ul>
<?php foreach ( $this->categories as $category ) : ?>
<li>
<a href="<?php echo $category->link; ?>" class="category<?php echo $this->params->get( 'pageclass_sfx' ); ?>">
<?php echo $this->escape($category->title);?></a>
&nbsp;
<span class="small">
(<?php echo $category->numlinks;?>)
</span>
</li>
<?php endforeach; ?>
</ul>


menufaqtop

components/views/category/tmpl/default.xml

<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="MYCOMPONENT CATEGORY LIST LAYOUT">
<message>
<![CDATA[MYCOMPONENT CATEGORY LIST LAYOUT DESC]]>
</message>
</layout>
<state>
<name>MYCOMPONENT CATEGORY LIST LAYOUT</name>
<description>MYCOMPONENT CATEGORY LIST LAYOUT DESC</description>
<params>
<param name="image" type="imagelist" directory="/images/stories" hide_default="1" default="" label="Image" description="PARAMIMAGE" />
<param name="image_align" type="radio" default="right" label="Image Align" description="Alignment of the image">
<option value="left">Left</option>
<option value="right">Right</option>
</param>
<param name="show_feed_link" type="radio" default="1" label="Show a feed link" description="PARAMSHOWFEEDLINK">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
</params>
</state>
</metadata>

menufaqtop

components/views/categories/view.html.php

<?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: Sun 05 February 2012 10:10
* @package mycomponent
* @license GNU Public License
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.application.component.view');

/**
* HTML View class for the mycomponent component
* @package Mycomponent
*/
class MycomponentViewCategories extends JView
{
function display( $tpl = null)
{
global $mainframe;

$document =& JFactory::getDocument();

$categories =& $this->get('data');
$total =& $this->get('total');
$state =& $this->get('state');

// Get the page/component configuration
$params = &$mainframe->getParams();

$menus = &JSite::getMenu();
$menu = $menus->getActive();

// because the application sets a default page title, we need to get it
// right from the menu item itself
if (is_object( $menu )) {
$menu_params = new JParameter( $menu->params );
if (!$menu_params->get( 'page_title')) {
$params->set('page_title', JText::_( 'MYCOMPONENT' ));
}
} else {
$params->set('page_title', JText::_( 'MYCOMPONENT' ));
}

$document->setTitle( $params->get( 'page_title' ) );

// Set some defaults if not set for params
$params->def('comp_description', JText::_('MYCOMPONENT_DESC'));

// Define image tag attributes
if ($params->get('image') != -1)
{
if($params->get('image_align')!="")
$attribs['align'] = $params->get('image_align');
else
$attribs['align'] = '';
$attribs['hspace'] = 6;

// Use the static HTML library to build the image tag
$image = JHTML::_('image', 'images/stories/'.$params->get('image'), JText::_('MYCOMPONENT'), $attribs);
}

for($i = 0; $i < count($categories); $i++)
{
$category =& $categories[$i];
$category->link = JRoute::_('index.php?option=com_mycomponent&view=category&id='. $category->slug);

// Prepare category description
$category->description = JHTML::_('content.prepare', $category->description);
}

$this->assignRef('image', $image);
$this->assignRef('params', $params);
$this->assignRef('categories', $categories);

parent::display($tpl);
}
}
?>

 


menufaqtop

components/views/item/tmpl/default.php

<?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: Sun 05 February 2012 10:10
* @package mycomponent
* @license GNU Public License
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

// uncomment to add custom css file for this view,
// save the css file to components/com_mycomponent/css/yourcss.css
//$document =& JFactory::getDocument();
//$document->addStyleSheet($this->baseurl.'/components/com_mycomponent/css/yourcss.css');
?>
<h1><?php echo $this->item->title; ?> </h1>
<div>

<?php if( $this->item->text ):?>
<h3>Text</h3>
<?php echo $this->item->text; ?>
<?php endif; ?>

<?php if( $this->item->picture ):?>
<h3>Picture</h3>
<?php echo $this->item->picture; ?>
<?php endif; ?>

<?php if( $this->item->date ):?>
<h3>Date</h3>
<?php echo $this->item->date; ?>
<?php endif; ?>


</div>

menufaqtop

components/views/item/view.html.php

<?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: Sun 05 February 2012 10:10
* @package mycomponent
* @license GNU Public License
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.application.component.view');

/**
* @package Mycomponent
*/
class MycomponentViewItem extends JView
{
function display($tpl = null)
{
global $mainframe;

$pathway = &$mainframe->getPathway();
$document = & JFactory::getDocument();
$model = &$this->getModel();

// Get the parameters of the active menu item
$menus = &JSite::getMenu();
$menu = $menus->getActive();

$pparams = &$mainframe->getParams('mycomponent');

$item =& $this->get('data');

// Set the document page title
// because the application sets a default page title, we need to get it
// right from the menu item itself
if (is_object( $menu ) && isset($menu->query['view']) && $menu->query['view'] == 'item' && isset($menu->query['id']) && $menu->query['id'] == $item->id) {
$menu_params = new JParameter( $menu->params );
if (!$menu_params->get( 'page_title')) {
$pparams->set('page_title', $item->title);
}
} else {
$pparams->set('page_title', $item->title);
}
$document->setTitle( $pparams->get( 'page_title' ) );

//set breadcrumbs
if (isset( $menu ) && isset($menu->query['view']) && $menu->query['view'] != 'item'){
$pathway->addItem($item->title, '');
}

$this->assignRef('item', $item);

parent::display($tpl);
}
}


menufaqtop

components/views/category/tmpl/default.xml

<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="MYCOMPONENT STANDARD ITEM LAYOUT">
<message>
<![CDATA[MYCOMPONENT STANDARD ITEM LAYOUT DESC]]>
</message>
</layout>
<state>
<name>MYCOMPONENT STANDARD ITEM LAYOUT</name>
<description>MYCOMPONENT STANDARD ITEM LAYOUT DESC</description>
<url addpath="/administrator/components/com_mycomponent/elements">
<param name="id" type="item" default="" label="Select Item" description="PARAMITEMSELECT" />
</url>
<params>
<param name="show_mycomponent_list" type="radio" default="0" label="DROPDOWN" description="PARAMDROPDOWN">
<option value="0">Hide</option>
<option value="1">Show</option>
</param>
<param name="show_category_crumb" type="radio" default="0" label="SHOWCATEGORYINBREADCRUMBS" description="SHOWCATEGORYINBREADCRUMBSDESC">
<option value="0">Hide</option>
<option value="1">Show</option>
</param>
</params>
</state>
</metadata>


menufaqtop

components/views/category/tmpl/default.php

<?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: Sun 05 February 2012 10:10
* @package mycomponent
* @license GNU Public License
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
?>
<?php if ( $this->params->def( 'show_page_title', 1 ) ) : ?>
<div class="componentheading<?php echo $this->params->get( 'pageclass_sfx' ); ?>">
<?php echo $this->escape($this->params->get('page_title')); ?>
</div>
<?php endif; ?>

<table width="100%" cellpadding="4" cellspacing="0" border="0" align="center" class="contentpane<?php echo $this->params->get( 'pageclass_sfx' ); ?>">
<?php if ( @$this->category->image || @$this->category->description ) : ?>
<tr>
<td valign="top" class="contentdescription<?php echo $this->params->get( 'pageclass_sfx' ); ?>">
<?php
if ( isset($this->category->image) ) : echo $this->category->image; endif;
echo $this->category->description;
?>
</td>
</tr>
<?php endif; ?>
<tr>
<td width="60%" colspan="2">
<?php echo $this->loadTemplate('items'); ?>
</td>
</tr>
<?php if ($this->params->get('show_other_cats', 1)): ?>
<tr>
<td width="60%" colspan="2">
<ul>
<?php foreach ( $this->categories as $category ) : ?>
<li>
<a href="<?php echo $category->link; ?>" class="category<?php echo $this->params->get( 'pageclass_sfx' ); ?>">
<?php echo $this->escape($category->title);?></a>
&nbsp;
<span class="small">
(<?php echo $category->numlinks;?>)
</span>
</li>
<?php endforeach; ?>
</ul>
</td>
</tr>
<?php endif; ?>
</table>


menufaqtop

components/views/category/tmpl/default_items.php

<?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: Sun 05 February 2012 10:10
* @package mycomponent
* @license GNU Public License
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
?>
<script language="javascript" type="text/javascript">
function tableOrdering( order, dir, task ) {
var form = document.adminForm;

form.filter_order.value = order;
form.filter_order_Dir.value = dir;
document.adminForm.submit( task );
}
</script>

<form action="<?php echo JFilterOutput::ampReplace($this->action); ?>" method="post" name="adminForm">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right" colspan="4">
<?php
echo JText::_('Display Num') .'&nbsp;';
echo $this->pagination->getLimitBox();
?>
</td>
</tr>
<?php if ( $this->params->def( 'show_headings', 1 ) ) : ?>
<tr>
<td width="10" style="text-align:right;" class="sectiontableheader<?php echo $this->params->get( 'pageclass_sfx' ); ?>">
<?php echo JText::_('Num'); ?>
</td>
<td width="90%" height="20" class="sectiontableheader<?php echo $this->params->get( 'pageclass_sfx' ); ?>">
<?php echo JHTML::_('grid.sort', 'mycomponent', 'title', $this->lists['order_Dir'], $this->lists['order'] ); ?>
</td>
<?php if ( $this->params->get( 'show_link_hits' ) ) : ?>

<td width="30" height="20" class="sectiontableheader<?php echo $this->params->get( 'pageclass_sfx' ); ?>" style="text-align:center;" nowrap="nowrap">
<?php echo JHTML::_('grid.sort', 'Hits', 'hits', $this->lists['order_Dir'], $this->lists['order'] ); ?>
</td>
<?php endif; ?>
</tr>
<?php endif; ?>
<?php foreach ($this->items as $item) : ?>
<tr class="sectiontableentry<?php echo $item->odd + 1; ?>">
<td align="right">
<?php echo $this->pagination->getRowOffset( $item->count ); ?>
</td>
<td height="20">
<?php echo $item->link; ?>
<?php if ( $this->params->get( 'show_link_description' ) ) : ?>
<br /><span class="description"><?php echo nl2br($item->description); ?></span>
<?php endif; ?>
</td>

<td align="center">
<?php echo $item->hits; ?>
</td>

</tr>
<?php endforeach; ?>
<tr>
<td align="center" colspan="4" class="sectiontablefooter<?php echo $this->params->get( 'pageclass_sfx' ); ?>">
<?php echo $this->pagination->getPagesLinks(); ?>
</td>
</tr>
<tr>
<td colspan="4" align="right" class="pagecounter">
<?php echo $this->pagination->getPagesCounter(); ?>
</td>
</tr>
</table>
<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="" />
</form>


menufaqtop

components/views/category/tmpl/default.xml

<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="MYCOMPONENT STANDARD CATEGORY LAYOUT">
<message>
<![CDATA[MYCOMPONENT STANDARD CATEGORY LAYOUT DESC]]>
</message>
</layout>
<state>
<name>MYCOMPONENT STANDARD CATEGORY LAYOUT</name>
<description>MYCOMPONENT STANDARD CATEGORY LAYOUT DESC</description>
<url>
<param name="id" type="category" section="com_mycomponent" default="0" label="Category" description="PARAMCATSELECT" />
</url>
<params>
<param name="show_feed_link" type="radio" default="1" label="Show a feed link" description="PARAMSHOWFEEDLINK">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
</params>
</state>
</metadata>

menufaqtop

components/views/category/view.html.php

<?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: Sun 05 February 2012 10:10
* @package mycomponent
* @license GNU Public License
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.application.component.view');

/**
* HTML View class for the mycomponent component
* @package Mycomponent
*/
class MycomponentViewCategory extends JView
{
function display( $tpl = null )
{
global $mainframe;

// Initialize some variables
$document = &JFactory::getDocument();
$uri = &JFactory::getURI();
$pathway = &$mainframe->getPathway();

// Get the parameters of the active menu item
$menus = &JSite::getMenu();
$menu = $menus->getActive();

// Get some data from the model
$items = &$this->get('data' );
$total = &$this->get('total');
$pagination = &$this->get('pagination');
$category = &$this->get('category' );
$state = &$this->get('state');


//get the categories model, so we can use it also here

$model =& JModel::getInstance('categories', 'mycomponentmodel');
$categories =& $model->getData();

// Get the page/component configuration
$params = &$mainframe->getParams();

$category->total = $total;

// Add alternate feed link
if($params->get('show_feed_link', 1) == 1)
{
$link = '&view=category&id='.$category->slug.'&format=feed&limitstart=';
$attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
$document->addHeadLink(JRoute::_($link.'&type=rss'), 'alternate', 'rel', $attribs);
$attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
$document->addHeadLink(JRoute::_($link.'&type=atom'), 'alternate', 'rel', $attribs);
}

$menus = &JSite::getMenu();
$menu = $menus->getActive();

// because the application sets a default page title, we need to get it
// right from the menu item itself
if (is_object( $menu )) {
$menu_params = new JParameter( $menu->params );
if (!$menu_params->get( 'page_title')) {
$params->set('page_title', $category->title);
}
} else {
$params->set('page_title', $category->title);
}
$document->setTitle( $params->get( 'page_title' ) );

//set breadcrumbs
if(is_object($menu) && $menu->query['view'] != 'category') {
$pathway->addItem($category->title, '');
}

// Prepare category description
$category->description = JHTML::_('content.prepare', $category->description);

// table ordering
$lists['order_Dir'] = $state->get('filter_order_dir');
$lists['order'] = $state->get('filter_order');

// Set some defaults if not set for params
$params->def('comp_description', JText::_('MYCOMPONENT_DESC'));
// Define image tag attributes
if (isset( $category->image ) && $category->image != '')
{
$attribs['align'] = $category->image_position;
$attribs['hspace'] = 6;

// Use the static HTML library to build the image tag
$category->image = JHTML::_('image', 'images/stories/'.$category->image, JText::_('MYCOMPONENT'), $attribs);
}

// icon in table display
if ( $params->get( 'link_icons' ) <> -1 ) {
$image = JHTML::_('image.site', $params->get('link_icons', 'weblink.png'), '/images/M_images/', $params->get( 'weblink_icons' ), '/images/M_images/', 'Link' );
}

$k = 0;
$count = count($items);
for($i = 0; $i < $count; $i++)
{
$item =& $items[$i];

$link = JRoute::_( 'index.php?view=item&catid='.$category->slug.'&id='. $item->slug);

$menuclass = 'category'.$params->get( 'pageclass_sfx' );

$itemParams = new JParameter($item->params);
$item->link = '<a href="'. $link .'" class="'. $menuclass .'">'. $this->escape($item->title) .'</a>';

$item->image = $image;

$item->odd = $k;
$item->count = $i;
$k = 1 - $k;
}

$count = count($categories);
for($i = 0; $i < $count; $i++)
{
$cat =& $categories[$i];
$cat->link = JRoute::_('index.php?option=com_mycomponent&view=category&id='. $cat->slug);
}

$this->assignRef('lists', $lists);
$this->assignRef('params', $params);
$this->assignRef('category', $category);
$this->assignRef('categories', $categories);
$this->assignRef('items', $items);
$this->assignRef('pagination', $pagination);

 

parent::display($tpl);
}

}


menufaqtop

components/controller.php

<?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: Sun 05 February 2012 10:10
* @package mycomponent
* @license GNU Public License
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.controller' );

class mycomponentController extends JController
{
/**
* Method to show a mycomponent view
*/
function display()
{
// Set a default view if none exists
if ( ! JRequest::getCmd( 'view' ) ) {
JRequest::setVar('view', 'categories' );
}

//update the hit count for the item
if(JRequest::getCmd('view') == 'item')
{
$model =& $this->getModel('item');
$model->hit();
}

parent::display();
}
}


menufaqtop

components/mycomponent.php

<?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: Sun 05 February 2012 10:10
* @package mycomponent
* @license GNU Public License
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.application.component.helper');

require_once(JPATH_COMPONENT.DS.'controller.php');

// Create the controller
$controller = new mycomponentController();

// Perform the Request task
$controller->execute(JRequest::getVar('task', null, 'default', 'cmd'));

// Redirect if set by the controller
$controller->redirect();


Root of the zip

menufaqtop

install.mycomponent.php

<?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: Sun 05 February 2012 10:10
* @package mycomponent
* @license GNU Public License
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

function com_install()
{
?>
<div class="header">Mycomponent is sucessfully installed </div>
<p>
description of your component
</p>
<?php
}

?>


menufaqtop

uninstall.mycomponent.php

<?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: Sun 05 February 2012 10:10
* @package mycomponent
* @license GNU Public License
**/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

function com_uninstall()
{
?>
<div class="header">Mycomponent is sucessfully removed </div>
<p>
Bye.
</p>
<?php
}

?>


menufaqtop

mycomponent.xml

<?xml version="1.0" encoding="utf-8"?>
<install type="component" version="1.5.0">
<name>Mycomponent</name>
<author>Danny Buytaert</author>
<creationDate>Sun 05 February 2012 10:10</creationDate>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<!-- The version string is recorded in the components table -->
<version>0.2 beta </version>
<!-- The description is optional and defaults to the name -->
<description>description of your component</description>
<!-- Install Database Section -->
<install>
<sql>
<file driver="mysql" charset="utf8">install.mysql.sql</file>
</sql>
</install>

<uninstall>
<sql>
<file driver="mysql" charset="utf8">uninstall.mysql.sql</file>
</sql>
</uninstall>
<!-- Custom Install Script to execute -->
<installfile>install.mycomponent.php</installfile>
<!-- Custom Uninstall Script to execute -->
<uninstallfile>uninstall.mycomponent.php</uninstallfile>

<!-- Site Main File Copy Section -->
<files folder="component">
<filename>mycomponent.php</filename>
<filename>controller.php</filename>
<filename>index.html</filename>
<folder>models</folder>
<folder>views</folder>
</files>
<!-- Language -->
<languages folder="component/language/">
<language tag="en-GB">en-GB.com_mycomponent.ini</language>
</languages>
<administration>
<menu>Mycomponent</menu>
<submenu>
<menu link="option=com_mycomponent">Mycomponent</menu>
<menu link="option=com_categories&amp;section=com_mycomponent">Categories</menu>
</submenu>

<!-- Administration Main File Copy Section -->
<files>
<filename>mycomponent.xml</filename>
</files>
<files folder="administrator">
<filename>install.mysql.sql</filename>
<filename>uninstall.mysql.sql</filename>
<filename>mycomponent.php</filename>
<filename>controller.php</filename>
<folder>helpers</folder>
<folder>models</folder>
<folder>tables</folder>
<folder>views</folder>
<folder>elements</folder>
</files>

<!-- Language Administrator-->
<languages folder="administrator/language/">
<language tag="en-GB">en-GB.com_mycomponent.menu.ini</language>
<language tag="en-GB">en-GB.com_mycomponent.ini</language>
</languages>
</administration>
</install>


Index.html

menufaqtop

index.html

Save this file in every map, for security reasons

<html><body bgcolor="#FFFFFF"></body></html>

menufaqtop

Faqs

What is Danny's Joomla! 1.5 MVC Component Code Generator ?

The idea of this project is to create in a quick way a "big sandbox" for developing Joomla! 1.5 components Which contains some nice Joomla! stuff like: pagination, search, categories ,ordering, published, hits,... It also contains some "standard" fields for your database : like title, alias,published,hits,created,modified,checked,.. You can add also some extra fields, the type of an extra field is varchar(255) , you can of course change this in the generated code.

What generates v 0.2 beta ?

the code for a complete  component with your own custom fields.

  • Administrator
  • 1 Table (linked with the categories table)
  • 3 Views in the frontend ( categories, category, item)
  • English language files
  • parameters (not finished)

When was the first version published?

Version 0.1 beta was published on 15 Jan 2009.

When was version 0.2 uploaded ?

Version 0.2 beta was published on 2 Feb 2009.

When will the next version be ready?

It will be ready when it's ready.

I like this script, can i download the source code of this script?

No, not yet.

Why all that copy/paste? why don't you use a PHP Class to generate the files on the fly? Or with one click to generate a zip ?

That's something that will be added in the future. If you know how to to create a zip with all the files in the right place "with a click" feel free to contact me.

i'm now working on a new version where there is no copy/paste anymore.Just fill in the fields and click. The zip will be created automatically. Thanks to Michele Lapresa [ www.mkl-tech.com ] who send me a piece of code how to do it.

The new version will be uploaded when ready ( i think it will be in march 2009 or april 2009)

Is there a Road Map ?

No, only some ideas Yes! to version 1.0 Stable

0.7 (Spring 2009)
It will be very soon.... with a lot of new functions.... From version 0.2 to 0.7 !
Too many new functions!

-The generator will be generated with the generator .( and later modified ofcourse)
-The generator will be a component .
-Your input will be saved, you get a special link where you can view the code and download as a zip!(also as reference for later use)
-view/save each generated file as a pdf ( maybe not in 0.7 but later...)


when it's 1.0 ?
- when all the parameters are used.
-when the router.php is finished ( if you know how to do with 3 views, feel free to write some code, that's a part i didn't study yet)
-submit/edit in frontend
-created date, user who created it, modified,....is used

What to fill in the form ? / How to use this Joomla! code generator ?

fill in the form, click generate, copy/paste the generated code, save the files in the same stucture as in the left column. Zip these files. Install in Joomla!

1 Name of the Component

  • Name of the component 1 word
  • In lowercase!
  • only the name without com_
  • unique, not same as Joomla! components like weblinks contact, content
  • no spaces, no underscore, only alphabetical characters

2 extra fields

  • Name of the fields, separated with a comma example : adress,image,country,brand
  • In lowercase!
  • do NOT use these names (because they will already be created) : id, catid,sid, title, alias, created, created_by, created_by_alias, modified, modified_by, checked_out, checked_out_time, hits, published, ordering
  • minimal 1 required

3 description

  • add some description about the component you want to create

What table fields are always generated ?

`id` int(11) unsigned NOT NULL auto_increment,
`catid` int(11) unsigned NOT NULL default '0',
`sid` int(11) unsigned NOT NULL default '0',
`title` varchar(255) NOT NULL default '',
`alias` varchar(255) NOT NULL default '',
`created` datetime NOT NULL default '0000-00-00 00:00:00',
`created_by` int(11) unsigned NOT NULL default '0',
`created_by_alias` varchar(255) NOT NULL default '',
`modified` datetime NOT NULL default '0000-00-00 00:00:00',
`modified_by` int(11) unsigned NOT NULL default '0',
`checked_out` int(11) unsigned NOT NULL default '0',
`checked_out_time` datetime NOT NULL default '0000-00-00 00:00:00',
`published` tinyint(1) NOT NULL default '0',
`ordering` int(11) NOT NULL default '0',
`params` text NOT NULL,
`hits` int(11) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)

Your extra fields will be of the type "varchar(255)"

Why you call it "Danny's Joomla! 1.5 MVC Component Code Generator" ?

Because it's a script which generate code for a Joomla!1.5 component, the code follows the MVC Pattern.

I want to contact you?

look at http://www.freakout.be/contact/danny-buytaert.html to contact me.

or use joomlafreak at gmail dot com

Hey i get this error : "XML Parsing Error at 18:10. Error 76: Mismatched tag" when i install my component

Yes, i know, don't know (yet) where the error comes from. But this error has no influence on the working of your component. If you found the bug in the script feel free to contact me
Error fixed 4/02/2009. In administrator/config.xml i forgot to close "<params>" . Thanx to Kevin from www.CoolNewMedia.com who found this bug.

I want to help you. What can i do ?

Now there is only 1 language included ( english),if you want to contribute feel free to translate the languages files in your language and send these to me. I'll include them in next versions.

There are 3 language files:

en-GB.com_mycomponent.ini en-GB.com_mycomponent.menu.ini en-GB.com_mycomponent.ini

There is no router.php?

That's a part of component developing what i need to study more..., feel free to send me a router.php based on this component. ( 3 views: categories, category, item)

menufaqtop