administrator/components/com_hello/controllers/hello.php class HellosControllerHello extends HellosController
{
/**
* constructor (registers additional tasks to methods)
* @return void
*/
function __construct()
{
parent::__construct();
// Register Extra tasks
$this->registerTask( 'add' , 'edit' );
}
/**
* display the edit form
* @return void
*/
function edit()
{
JRequest::setVar( 'view', 'hello' );
JRequest::setVar( 'layout', 'form' );
JRequest::setVar('hidemainmenu', 1);
parent::display();
}
/**
* save a record (and redirect to main page)
* @return void
*/
function save()
{
$model = $this->getModel('hello');
if ($model->store($post)) {
$msg = JText::_( 'Greeting Saved!' );
} else {
$msg = JText::_( 'Error Saving Greeting' );
}
// Check the table in so it can be edited.... we are done with it anyway
$link = 'index.php?option=com_hello';
$this->setRedirect($link, $msg);
}
/**
* remove record(s)
* @return void
*/
function remove()
{
$model = $this->getModel('hello');
if(!$model->delete()) {
$msg = JText::_( 'Error: One or More Greetings Could not be Deleted' );
} else {
$msg = JText::_( 'Greeting(s) Deleted' );
}
$this->setRedirect( 'index.php?option=com_hello', $msg );
}
/**
* cancel editing a record
* @return void
*/
function cancel()
{
$msg = JText::_( 'Operation Cancelled' );
$this->setRedirect( 'index.php?option=com_hello', $msg );
}
} | administrator/components/com_hello/controllers/greeting.php <?php
// we want to use the form controller instead of the default controller, so we add the class
class HelloControllerGreeting extends KControllerForm
{
}
|
administrator/components/com_hello/tables/hello.php class TableHello extends JTable
{
/**
* Primary Key
*
* @var int
*/
var $id = null;
/**
* @var string
*/
var $greeting = null;
/**
* Constructor
*
* @param object Database connector object
*/
function TableHello(& $db) {
parent::__construct('#__hello', 'id', $db);
}
} | Table automatically created by Nooku Framework |
administrator/components/com_hello/models/hello.php jimport('joomla.application.component.model');
class HellosModelHello extends JModel
{
/**
* Constructor that retrieves the ID from the request
*
* @access public
* @return void
*/
function __construct()
{
parent::__construct();
$array = JRequest::getVar('cid', 0, '', 'array');
$this->setId((int)$array[0]);
}
/**
* Method to set the hello identifier
*
* @access public
* @param int Hello identifier
* @return void
*/
function setId($id)
{
// Set id and wipe data
$this->_id = $id;
$this->_data = null;
}
/**
* Method to get a hello
* @return object with data
*/
function &getData()
{
// Load the data
if (empty( $this->_data )) {
$query = ' SELECT * FROM #__hello '.
' WHERE id = '.$this->_id;
$this->_db->setQuery( $query );
$this->_data = $this->_db->loadObject();
}
if (!$this->_data) {
$this->_data = new stdClass();
$this->_data->id = 0;
$this->_data->greeting = null;
}
return $this->_data;
}
/**
* Method to store a record
*
* @access public
* @return boolean True on success
*/
function store()
{
$row =& $this->getTable();
$data = JRequest::get( 'post' );
// Bind the form fields to the hello table
if (!$row->bind($data)) {
$this->setError($this->_db->getErrorMsg());
return false;
}
// Make sure the hello record is valid
if (!$row->check()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
// Store the web link table to the database
if (!$row->store()) {
$this->setError( $row->getErrorMsg() );
return false;
}
return true;
}
/**
* Method to delete record(s)
*
* @access public
* @return boolean True on success
*/
function delete()
{
$cids = JRequest::getVar( 'cid', array(0), 'post', 'array' );
$row =& $this->getTable();
if (count( $cids )) {
foreach($cids as $cid) {
if (!$row->delete( $cid )) {
$this->setError( $row->getErrorMsg() );
return false;
}
}
}
return true;
}
} | Model automatically created by Nooku Framework |
administrator/components/com_hello/models/hellos.php jimport( 'joomla.application.component.model' );
class HellosModelHellos extends JModel
{
/**
* Hellos data array
*
* @var array
*/
var $_data;
/**
* Returns the query
* @return string The query to be used to retrieve the rows from the database
*/
function _buildQuery()
{
$query = ' SELECT * FROM #__hello ';
return $query;
}
/**
* Retrieves the hello data
* @return array Array of objects containing the data from the database
*/
function getData()
{
// Lets load the data if it doesn't already exist
if (empty( $this->_data ))
{
$query = $this->_buildQuery();
$this->_data = $this->_getList( $query );
}
return $this->_data;
}
} | Model automatically created by Nooku Framework |
administrator/components/com_hello/views/hellos/view.html.php jimport( 'joomla.application.component.view' );
class HellosViewHellos extends JView
{
function display($tpl = null)
{
JToolBarHelper::title( JText::_( 'Hello Manager' ), 'generic.png' );
JToolBarHelper::deleteList();
JToolBarHelper::editListX();
JToolBarHelper::addNewX();
// Get data from the model
$items = & $this->get( 'Data');
$this->assignRef('items', $items);
parent::display($tpl);
}
} | Display function automatically created by Nooku Framework |
administrator/components/com_hello/views/hellos/tmpl/default.php <form action="index.php" method="post" name="adminForm">
<div id="editcell">
<table class="adminlist">
<thead>
<tr>
<th width="5">
<?php echo JText::_( 'ID' ); ?>
</th>
<th width="20">
<input type="checkbox" name="toggle" value=""
onclick="checkAll(<?php echo count( $this->items ); ?>);" />
</th>
<th>
<?php echo JText::_( 'Greeting' ); ?>
</th>
</tr>
</thead>
<?php
$k = 0;
for ($i=0, $n=count( $this->items ); $i < $n; $i++) {
$row = &$this->items[$i];
$checked = JHTML::_('grid.id', $i, $row->id );
$link=JRoute::_('index.php?option=com_hello&controller=hello&task=edit&cid[]='.$row->id);
?>
<tr class="<?php echo "row$k"; ?>">
<td>
<?php echo $row->id; ?>
</td>
<td>
<?php echo $checked; ?>
</td>
<td>
<a href="<?php echo $link; ?>"><?php echo $row->greeting; ?></a>
</td>
</tr>
<?php
$k = 1 - $k;
}
?>
</table>
</div>
<input type="hidden" name="option" value="com_hello" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="controller" value="hello" />
</form> | administrator/components/com_hello/views/greetings/tmpl/form.php <form action="<?= @route()?>" method="post" name="adminForm">
<table class="adminlist">
<thead>
<tr>
<th width="5">
<?= @text('NUM'); ?>
</th>
<th width="20">
<input type="checkbox" name="toggle" value="" onclick="checkAll(<?= count(@$greetings); ?>);" />
</th>
<th>
<?= @text('Greeting' ); ?>
</th>
</tr>
</thead>
<tbody>
<? $i = 0; $m = 0; ?>
<? foreach (@$greetings as $greeting) : ?>
<tr class="<?php echo 'row'.$m; ?>">
<td align="center"><?= $i + 1; ?></td>
<td align="center">
<?= @helper('grid.id', $i, $greeting->id); ?>
</td>
<td>
<a href="<?=@route('view=greeting&id='.$greeting->id)?>">
<?= $greeting->greeting; ?>
</a>
</td>
</tr>
<? $i = $i + 1; $m = (1 - $m); ?>
<? endforeach; ?>
</table>
<input type="hidden" name="boxchecked" value="0" />
</form> |
administrator/components/com_hello/views/hello/view.html.php jimport( 'joomla.application.component.view' );
class HellosViewHello extends JView
{
/**
* display method of Hello view
* @return void
**/
function display($tpl = null)
{
//get the hello
$hello =& $this->get('Data');
$isNew = ($hello->id < 1);
$text = $isNew ? JText::_( 'New' ) : JText::_( 'Edit' );
JToolBarHelper::title(JText::_('Hello').':<small><small>['.$text.']</small></small>');
JToolBarHelper::save();
if ($isNew) {
JToolBarHelper::cancel();
} else {
// for existing items the button is renamed `close`
JToolBarHelper::cancel( 'cancel', 'Close' );
}
$this->assignRef('hello', $hello);
parent::display();
}
} | Display function automatically created by Nooku Framework |
administrator/components/com_hello/views/hello/tmpl/form.php <form action="index.php" method="post" name="adminForm" id="adminForm">
<div class="col100">
<fieldset class="adminform">
<legend><?php echo JText::_( 'Details' ); ?></legend>
<table class="admintable">
<tr>
<td width="100" align="right" class="key">
<label for="greeting">
<?php echo JText::_( 'Greeting' ); ?>:
</label>
</td>
<td>
<input class="text_area" type="text" name="greeting"
id="greeting" size="32" maxlength="250" value="<?php echo $this->hello->greeting;?>" />
</td>
</tr>
</table>
</fieldset>
</div>
<div class="clr"></div>
<input type="hidden" name="option" value="com_hello" />
<input type="hidden" name="id" value="<?php echo $this->hello->id; ?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="controller" value="hello" />
</form>
| administrator/components/com_hello/views/hello/tmpl/form.php <form action="<?= @route('id='.@$greeting->id) ?>" method="post" class="adminform" name="adminForm">
<fieldset class="adminform">
<legend><?= @text('Details' ); ?></legend>
<table class="admintable">
<tr>
<td width="100" align="right" class="key">
<label for="greeting">
<?= @text('Greeting' ); ?>:
</label>
</td>
<td>
<input class="text_area" type="text" name="greeting"
id="greeting" size="32" maxlength="250" value="<?= @$greeting->greeting; ?>" />
</td>
</tr>
</table>
</fieldset>
<input type="hidden" name="id" value="<?= @$greeting->id; ?>" />
</form>
|
Thanks for the comparison ... but ... it's not quite apples-vs-apples. You are comparing (in part) PHP 4 compatible markup with dedicated PHP 5 framework so you should really compare it with 1.6, not 1.5.
The API seems a little out of date??
Good point Andrew.... given you know 1.6 better than most how about providing the the 1.6 version?
..... aaaaand silence.
Interesting... I'm looking for that framework to start learning.
As a joomla extension developer, I have to say it's not a fair comparison and you know this. Nooku's power and flexibility is obvious but what you are showing here is just overstatement.