Location: PHPKode > scripts > Joomla MVC Classes > example/admin/libs/jviewlesd.php
<?php
/*
	Copyright (C) 2010 Luis Eduardo da Silva Dias. All rights reserved.
	Version Beta 1.0
    jviewlesd.php is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    jviewlesd.php is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
defined('_JEXEC') or die();
jimport('joomla.application.component.view');
class JViewLesd extends JView	{
	function display($tpl = null)
	{
		$db =& JFactory::getDBO();
		$layout = $this->getLayout();
		$model = & $this->getModel($this->getName());
		if ( $layout == 'default' ) {
			JToolBarHelper::title( JText::_( ucfirst($this->getName()) . ' Manager' ), 'generic.png' );
			JToolBarHelper::deleteList();
			JToolBarHelper::editListX();
			JToolBarHelper::addNewX();
			$lists =& $model->getOrder();
			$this->assignRef( 'lists', $lists );
			$items =& $model->getGrid();
			$pagination =& $model->getPagination();
			$this->assignRef('items', $items );
			$this->assignRef('pagination', $pagination);
			parent::display();
		};		

		if ( $layout == 'form' ) {
			$user	=& JFactory::getUser();			
			$row =& $model->getData();
			$isLockedByOther = false;
			$isNew = ($row->id < 1);
			if (!$isNew) {
				if (!$model->lock($user->get('id'),$row)) {
					$isLockedByOther = true;
					JError::raiseWarning( 0, JText::_( $model->getError() ) );					
				} else {
					$isLockedByOther = false;
				}
			}	
			$text = $isNew ? JText::_( 'New' ) : JText::_( 'Edit' );
			JToolBarHelper::title( JText::_( ucfirst($this->getName()) ).': <small><small>[ ' . $text.' ]</small></small>' );
			if (!$isLockedByOther) {
				JToolBarHelper::save();
			}
			if ($isNew) {
				JToolBarHelper::cancel();
			} else {
				JToolBarHelper::cancel( 'cancel', 'Close' );
			}
			$this->assignRef($this->getName(), $row);
			parent::display($tpl);
		};

	}
}
Return current item: Joomla MVC Classes