PATH:
home
/
centosnipponia
/
public_html
/
nipponiacom2
/
components
/
com_djcatalog2
/
models
<?php /** * @version $Id: query.php 372 2015-02-04 06:46:47Z michal $ * @package DJ-Catalog2 * @copyright Copyright (C) 2012 DJ-Extensions.com LTD, All rights reserved. * @license http://www.gnu.org/licenses GNU/GPL * @author url: http://dj-extensions.com * @author email contact@dj-extensions.com * @developer Michal Olczyk - michal.olczyk@design-joomla.eu * * DJ-Catalog2 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. * * DJ-Catalog2 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 DJ-Catalog2. If not, see <http://www.gnu.org/licenses/>. * */ // No direct access. defined('_JEXEC') or die; jimport('joomla.application.component.modelform'); class Djcatalog2ModelQuery extends JModelForm { protected $_item = null; protected $_context = 'com_djcatalog2.query'; public function __construct($config = array()) { parent::__construct($config); } protected function populateState() { $table = $this->getTable(); $key = 'qid'; // Get the pk of the record from the request. $pk = JFactory::getApplication()->input->getInt($key); $this->setState($this->getName() . '.id', $pk); // Load the parameters. $value = JComponentHelper::getParams('com_djcatalog2'); $this->setState('params', $value); } public function getTable($type = 'Quotes', $prefix = 'Djcatalog2Table', $config = array()) { return JTable::getInstance($type, $prefix, $config); } public function getItem($pk = null) { $pk = (!empty($pk)) ? $pk : (int) $this->getState($this->getName() . '.id'); $table = $this->getTable(); if ($pk > 0) { // Attempt to load the row. $return = $table->load($pk); // Check for a table object error. if ($return === false && $table->getError()) { $this->setError($table->getError()); return false; } } // Convert to the JObject before adding other data. $properties = $table->getProperties(1); $item = JArrayHelper::toObject($properties, 'JObject'); if (!is_array($item->items)) { if (isset($item->id)) { $this->_db->setQuery('SELECT * FROM #__djc2_quote_items WHERE quote_id=\''.$item->id.'\''); $item->items = $this->_db->loadObjectList(); } else { $item->items = array(); } } if (property_exists($item, 'params')) { $registry = new JRegistry; $registry->loadString($item->params); $item->params = $registry->toArray(); } return $item; } public function getForm($data = array(), $loadData = true) { // Get the form. $form = $this->loadForm('com_djcatalog2.userprofile', 'userprofile', array('control' => 'jform', 'load_data' => $loadData)); if (empty($form)) { return false; } return $form; } protected function preprocessForm(JForm $form, $data, $group = 'content') { if (!($form instanceof JForm)) { $this->setError('JERROR_NOT_A_FORM'); return false; } $app = JFactory::getApplication(); $params = JComponentHelper::getParams('com_djcatalog2'); $user = JFactory::getUser(); $plugin = JFactory::getApplication()->getParams()->get('cart_query_captcha', JFactory::getConfig()->get('captcha')); if ($user->guest == false || ($plugin === 0 || $plugin === '0' || $plugin === '' || $plugin === null)) { $form->removeField('captcha', 'djcatalog2profile'); } else { JFactory::getApplication()->getParams()->set('captcha', $plugin); } $form->removeField('client_type', 'djcatalog2profile'); $form->removeField('customer_group_id', 'djcatalog2profile'); $fields = array('company', 'position', 'address', 'city', 'postcode', 'country_id', 'vat_id', 'phone', 'fax', 'www', 'customer_note'); $group = 'djcatalog2profile'; foreach ($fields as $field) { // in case config is broken - using defaults from XML file if ($params->get('cart_queryfield_'.$field, false) === false) { continue; } if ($params->get('cart_queryfield_'.$field, '0') == '0') { $form->removeField($field, $group); } else { if ($params->get('cart_queryfield_'.$field, '0') == '2') { $form->setFieldAttribute($field, 'required', 'required', $group); $form->setFieldAttribute($field, 'class', $form->getFieldAttribute($field, 'class').' required', $group); } else { $form->setFieldAttribute($field, 'required', false, $group); $class = $form->getFieldAttribute($field, 'class', '', $group); $class = str_replace('required', '', $class); $form->setFieldAttribute($field, 'class', $class, $group); } } } } protected function loadFormData() { $data = Djcatalog2Helper::getUserProfile(JFactory::getUser()->id); $data = JArrayHelper::fromObject($data, false); $data= array('djcatalog2profile'=> $data); $post_data = (array)JFactory::getApplication()->getUserState('com_djcatalog2.query.data', array()); if (!empty($post_data)) { foreach($post_data as $k=>$v) { $data[$k] = $v; } } $this->preprocessData('com_djcatalog2.query', $data); return $data; } protected function preprocessData($context, &$data) { // Get the dispatcher and load the users plugins. $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); // Trigger the data preparation event. $results = $dispatcher->trigger('onContentPrepareData', array($context, $data)); // Check for errors encountered while preparing the data. if (count($results) > 0 && in_array(false, $results, true)) { $this->setError($dispatcher->getError()); } } protected function getReorderConditions($table = null) { $condition = array(); return $condition; } protected function prepareTable(&$table) { } public function save($data) { $table = $this->getTable(); $key = $table->getKeyName(); $pk = (!empty($data[$key])) ? $data[$key] : (int) $this->getState($this->getName() . '.id'); $isNew = true; // Allow an exception to be thrown. try { // Load the row if saving an existing record. if ($pk > 0) { $table->load($pk); $isNew = false; } // Bind the data. if (!$table->bind($data)) { $this->setError($table->getError()); return false; } // Prepare the row for saving $this->prepareTable($table); // Check the data. if (!$table->check()) { $this->setError($table->getError()); return false; } // Store the data. if (!$table->store()) { $this->setError($table->getError()); return false; } // Clean the cache. $this->cleanCache(); } catch (Exception $e) { $this->setError($e->getMessage()); return false; } $pkName = $table->getKeyName(); if (isset($table->$pkName)) { $this->setState($this->getName() . '.id', $table->$pkName); } $this->setState($this->getName() . '.new', $isNew); return true; } }
[+]
..
[+]
forms
[-] index.html
[edit]
[-] item.php
[edit]
[-] itemform.php
[edit]
[-] items.php
[edit]
[-] modfrontpage.php
[edit]
[-] order.php
[edit]
[-] orders.php
[edit]
[-] producer.php
[edit]
[-] producers.php
[edit]
[-] query.php
[edit]
[-] .htaccess.disabled
[edit]