<?php
/*
 * Copyright (c) 2014-2015 Aimy Extensions, Lingua-Systems Software GmbH
 *
 * http://www.aimy-extensions.com/
 *
 * License: GNU GPLv2, see LICENSE.txt within distribution and/or
 *          http://www.aimy-extensions.com/software-license.html
 */
 defined( '_JEXEC' ) or die(); class AimySitemapModelUrl extends JModelAdmin { protected $text_prefix = 'com_AimySitemap'; public function getTable( $type = 'Url', $prefix = 'AimySitemapTable', $config = array() ) { return JTable::getInstance( $type, $prefix, $config ); } public function getForm( $data = array(), $load_data = true ) { $app = JFactory::getApplication(); $form = $this->loadForm( 'com_aimysitemap.url', 'url', array( 'control' => 'jform', 'load_data' => $load_data ) ); if ( empty( $form ) ) { return false; } return $form; } protected function loadFormData() { $data = JFactory::getApplication()->getUserState( 'com_aimysitemap.url.data', array() ); if ( empty( $data ) ) { $data = $this->getItem(); } return $data; } public function set_state( $id, $state ) { $db = $this->getDbo(); $q = $db->getQuery( true ); $q->update( '#__aimysitemap' ) ->set( $db->quoteName( 'state' ) . ' = ' . $db->quote( $state ) ) ->where( $db->quoteName( 'id' ) . ' = ' . $db->quote( $id ) ); $db->setQuery( $q ); return $db->execute(); } public function toggle_state( $id ) { $db = $this->getDbo(); $q = $db->getQuery( true ); $q->select( $db->quoteName( 'state' ) ) ->from( '#__aimysitemap' ) ->where( $db->quoteName( 'id' ) . ' = ' . $db->quote( $id ) ); $db->setQuery( $q ); $db->execute(); $o = $db->loadObject(); if ( empty( $o ) || ! is_object( $o ) || ! isset( $o->state ) ) { return false; } return $this->set_state( $id, empty( $o->state ) ? 1 : 0 ); } public function set_changefreq( $id, $freq ) { $db = $this->getDbo(); $q = $db->getQuery( true ); $q->update( '#__aimysitemap' ) ->set( $db->quoteName( 'changefreq' ) . ' = ' . $db->quote( $freq ) ) ->where( $db->quoteName( 'id' ) . ' = ' . $db->quote( $id ) ); $db->setQuery( $q ); return $db->execute(); } public function set_priority( $id, $prio ) { $db = $this->getDbo(); $q = $db->getQuery( true ); $q->update( '#__aimysitemap' ) ->set( $db->quoteName( 'priority' ) . ' = ' . $db->quote( $prio ) ) ->where( $db->quoteName( 'id' ) . ' = ' . $db->quote( $id ) ); $db->setQuery( $q ); return $db->execute(); } } 
