Location: PHPKode > projects > injooosm > administrator/components/com_injooosm/controllers/cats.php
<?php
/**
 * Joomla! 1.5 component injooosm
 *
 * @version $Id: cats.php 2009-11-22 14:03:00$
 * @author Christian Knorr
 * @package injooosm
 * @subpackage backend
 * @license GNU/GPL
 * @filesource
 *
 */

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

jimport( 'joomla.application.component.controller' );
require_once( JPATH_COMPONENT.DS.'helpers'.DS.'helper.php' );
JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_injooosm'.DS.'tables');
/**
 * Controller Class Categories
 */
class injooosmControllerCats extends injooosmController  {
    /**
     *
     */
    function display()
    {

	    parent::display();
    }


    /**
     *
     * @global object $mainframe
     * @uses injooosmModelCat::saveCat
     * @return redirect
     *
     */
    function savecat()  {

        // Check for request forgeries
        JRequest::checkToken() or jexit( 'Invalid Token' );
        
        $model = $this->getModel('cat');
        $model->saveCat();

        // redirect to cats overview
        $link = JRoute::_( "index.php?option=com_injooosm&task=cats&controller=cats",false);
        $this->setRedirect($link, JText::_('OSM_CAT_SAVED'));

    }

    /**
     * @uses injooosmModelCat::move
     * @return redirect
     */
    function orderup()  {

		// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );

		$model = $this->getModel('cat');
		$model->move(-1);

        $this->setRedirect( JRoute::_('index.php?option=com_injooosm&task=cats&controller=cats', false));
    }

    /**
     * @uses injooosmModelCat::move
     *@return redirect
     */
    function orderdown()  {

		// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );

		$model = $this->getModel('cat');
		$model->move(1);

        $this->setRedirect( JRoute::_('index.php?option=com_injooosm&task=cats&controller=cats', false));
    }

        /**
         * @uses injooosmModelCat::saveorder
         * @return redirect
         */
	function saveorder()
	{
		// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );

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

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

		$this->setRedirect( JRoute::_('index.php?option=com_injooosm&task=cats&controller=cats', false ));
	}


        /**
         * @uses injooosmModelCat::publish
         * @return redirect
         */
	function publish()
	{
		// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );

		$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('cat');
		if(!$model->publish($cid, 1)) {
			echo "<script> alert('".$model->getError(true)."'); window.history.go(-1); </script>\n";
		}

		$this->setRedirect( JRoute::_('index.php?option=com_injooosm&task=cats&controller=cats', false ));
	}

        /**
         * @uses injooosmModelCat::publish
         * @return redirect
         */
	function unpublish()
	{
		// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );

		$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('cat');
		if(!$model->publish($cid, 0)) {
			echo "<script> alert('".$model->getError(true)."'); window.history.go(-1); </script>\n";
		}

		$this->setRedirect( JRoute::_('index.php?option=com_injooosm&task=cats&controller=cats', false ));
	}

        /**
         * @uses injooosmModelCat::delete
         * @return redirect
         */
	function remove()
	{
		// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );

		$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('cat');
		if(!$model->delete($cid)) {
			echo "<script> alert('".$model->getError(true)."'); window.history.go(-1); </script>\n";
		}

		$this->setRedirect( JRoute::_('index.php?option=com_injooosm&task=cats&controller=cats', false ));
	}
    /**
     * @uses injooosmModelCat::updateCat
     * @return redirect
     */
    function updatecat()  {
        // check the token
        JRequest::checkToken() or die( 'Invalid Token' );

        $model = $this->getModel('cat');
        $model->updateCat();
        
        // redirect to cats overview
        $link = JRoute::_( "index.php?option=com_injooosm&task=cats&controller=cats",false);
        $this->setRedirect($link, JText::_('OSM_CAT_SAVED'));

    }


}
Return current item: injooosm