/aamenu/code/trunk/administrator/components/com_aamenu/models/tags.php
PHP | 62 lines | 35 code | 9 blank | 18 comment | 2 complexity | 3406e44243f8084dbdad07b12e2520bc MD5 | raw file
- <?php
- /**
- * @version $Id: tags.php 255 2010-08-20 09:43:07Z eddieajau $
- * @package Artof.AAMenu
- * @subpackage com_aamenu
- * @copyright Copyright (C) 2009 New Life in IT Pty Ltd. All rights reserved.
- * @license GNU General Public License <http://www.gnu.org/copyleft/gpl.html>
- * @link http://www.theartofjoomla.com
- */
- // no direct access
- defined('_JEXEC') or die('Restricted access');
- jimport('joomla.application.component.model');
- /**
- * @package Artof.AAMenu
- * @subpackage com_aamenu
- */
- class AAMenuModelTags extends JModel
- {
- /**
- * Save the tags assigned to the components in the list
- *
- * @return boolean True if successful, false otherwise and internal error set
- */
- function save()
- {
- $request = $this->getState('request');
- $db = $this->getDBO();
- $tags = JArrayHelper::getValue($request, 'tags', array(), 'array');
- $ordering = JArrayHelper::getValue($request, 'ordering', array(), 'array');
- $ids = array_keys($tags);
- JArrayHelper::toInteger($ids);
- $query = 'DELETE FROM #__taoj_aamenu_tags' .
- ' WHERE component_id IN ('.implode(',', $ids).')';
- $db->setQuery($query);
- if (!$db->query()) {
- $this->setError($db->getErrorMsg());
- return false;
- }
- $tuples = array();
- foreach ($ids as $id)
- {
- $tuples[] = '('.(int) $id.','.$db->Quote($tags[$id]).','.(int) $ordering[$id].')';
- }
- $query = 'INSERT INTO #__taoj_aamenu_tags (component_id,tag,ordering) VALUES '.
- implode(',', $tuples);
- $db->setQuery($query);
- if (!$db->query()) {
- $this->setError($db->getErrorMsg());
- return false;
- }
- return true;
- }
- }