0byt3m1n1-V2
Path:
/
home
/
a
/
c
/
a
/
academiac
/
www
/
[
Home
]
File: custom.php.tar
home/academiac/www/administrator/components/com_virtuemart/models/custom.php 0000604 00000021072 15137217332 0023624 0 ustar 00 <?php /** * * Description * * @package VirtueMart * @subpackage * @author Max Milbers * @link http://www.virtuemart.net * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved by the author. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * @version $Id: custom.php 3057 2011-04-19 12:59:22Z Electrocity $ */ // Check to ensure this file is included in Joomla! defined('_JEXEC') or die('Restricted access'); if(!class_exists('VmModel'))require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'vmmodel.php'); /** * Model for VirtueMart Customs Fields * * @package VirtueMart */ class VirtueMartModelCustom extends VmModel { private $plugin=null ; /** * constructs a VmModel * setMainTable defines the maintable of the model * @author Max Milbers */ function __construct() { parent::__construct('virtuemart_custom_id'); $this->setMainTable('customs'); $this->setToggleName('admin_only'); $this->setToggleName('is_hidden'); } /** * Gets a single custom by virtuemart_custom_id * . * @param string $type * @param string $mime mime type of custom, use for exampel image * @return customobject */ function getCustom(){ if(empty($this->_data)){ // JTable::addIncludePath(JPATH_VM_ADMINISTRATOR.DS.'tables'); $this->_data = $this->getTable('customs'); $this->_data->load($this->_id); $customfields = VmModel::getModel('Customfields'); $this->_data->field_types = $customfields->getField_types() ; // vmdebug('getCustom $data',$this->_data); if(!empty($this->_data->custom_jplugin_id)){ JPluginHelper::importPlugin('vmcustom'); $dispatcher = JDispatcher::getInstance(); // $varsToPushParam = $dispatcher->trigger('plgVmDeclarePluginParams',array('custom',$this->_data->custom_element,$this->_data->custom_jplugin_id)); $retValue = $dispatcher->trigger('plgVmDeclarePluginParamsCustom',array('custom',$this->_data->custom_element,$this->_data->custom_jplugin_id,&$this->_data)); } else { //Todo this is not working, because the custom is using custom_params, while the customfield is using custom_param ! //VirtueMartModelCustomfields::bindParameterableByFieldType($this->_data); } } return $this->_data; } /** * Retireve a list of customs from the database. This is meant only for backend use * * @author Kohl Patrick, Max Milbers * @return object List of custom objects */ function getCustoms($custom_parent_id,$search = false){ $query='* FROM `#__virtuemart_customs` WHERE field_type <> "R" AND field_type <> "Z" AND field_type <> "G" '; if($custom_parent_id){ $query .= 'AND `custom_parent_id` ='.(int)$custom_parent_id; } if($search){ $search = '"%' . $this->_db->getEscaped( $search, true ) . '%"' ; $query .= 'AND `custom_title` LIKE '.$search; } $datas = new stdClass(); $datas->items = $this->exeSortSearchListQuery(0, $query, '','',$this->_getOrdering()); $customfields = VmModel::getModel('Customfields'); if (!class_exists('VmHTML')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'html.php'); $datas->field_types = $customfields->getField_types() ; foreach ($datas->items as $key => & $data) { if (!empty($data->custom_parent_id)) $data->custom_parent_title = $customfields->getCustomParentTitle($data->custom_parent_id); else { $data->custom_parent_title = '-' ; } if(!empty($datas->field_types[$data->field_type ])){ $data->field_type_display = vmText::_( $datas->field_types[$data->field_type ] ); } else { $data->field_type_display = 'not valid, delete this line'; vmError('The field with id '.$data->virtuemart_custom_id.' and title '.$data->custom_title.' is not longer valid, please delete it from the list'); } } $datas->customsSelect=$customfields->displayCustomSelection(); return $datas; } /** * Creates a clone of a given custom id * * @author Max Milbers * @param int $virtuemart_product_id */ public function createClone($id){ $this->virtuemart_custom_id = $id; $row = $this->getTable('customs'); $row->load( $id ); $row->virtuemart_custom_id = 0; $row->custom_title = $row->custom_title.' Copy'; if (!$clone = $row->store()) { JError::raiseError(500, 'createClone '. $row->getError() ); } return $clone; } /* Save and delete from database * all Child product custom_fields relation * @ var $table : the xref table(eg. product,category ...) * @array $data : array of customfields * @int $id : The concerned id (eg. product_id) **/ public function saveChildCustomRelation($table,$datas) { JRequest::checkToken() or jexit( 'Invalid Token, in store customfields'); //Table whitelist $tableWhiteList = array('product','category','manufacturer'); if(!in_array($table,$tableWhiteList)) return false; $customfieldIds = array(); // delete existings from modelXref and table customfields foreach ($datas as $child_id =>$fields) { $fields['virtuemart_'.$table.'_id']=$child_id; $this->_db->setQuery( 'DELETE PC FROM `#__virtuemart_'.$table.'_customfields` as `PC`, `#__virtuemart_customs` as `C` WHERE `PC`.`virtuemart_custom_id` = `C`.`virtuemart_custom_id` AND field_type="C" and virtuemart_'.$table.'_id ='.$child_id ); if(!$this->_db->query()){ vmError('Error in deleting child relation '); //.$this->_db->getQuery()); Dont give hackers too much info } $tableCustomfields = $this->getTable($table.'_customfields'); $tableCustomfields->bindChecknStore($fields); $errors = $tableCustomfields->getErrors(); foreach($errors as $error){ vmError($error); } } } public function store(&$data){ if(!empty($data['params'])){ foreach($data['params'] as $k=>$v){ $data[$k] = $v; } } if(empty($data['virtuemart_vendor_id'])){ if(!class_exists('VirtueMartModelVendor')) require(JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'vendor.php'); $data['virtuemart_vendor_id'] = VirtueMartModelVendor::getLoggedVendor(); } else { $data['virtuemart_vendor_id'] = (int) $data['virtuemart_vendor_id']; } // missing string FIX, Bad way ? if (JVM_VERSION===1) { $tb = '#__plugins'; $ext_id = 'id'; } else { $tb = '#__extensions'; $ext_id = 'extension_id'; } $q = 'SELECT `element` FROM `' . $tb . '` WHERE `' . $ext_id . '` = "'.$data['custom_jplugin_id'].'"'; $this->_db->setQuery($q); $data['custom_element'] = $this->_db->loadResult(); // vmdebug('store custom',$data); $table = $this->getTable('customs'); if(isset($data['custom_jplugin_id'])){ vmdebug('$data store custom',$data); JPluginHelper::importPlugin('vmcustom'); $dispatcher = JDispatcher::getInstance(); // $retValue = $dispatcher->trigger('plgVmSetOnTablePluginParamsCustom',array($data['custom_value'],$data['custom_jplugin_id'],&$table)); $retValue = $dispatcher->trigger('plgVmSetOnTablePluginParamsCustom',array($data['custom_element'],$data['custom_jplugin_id'],&$table)); } $table->bindChecknStore($data); $errors = $table->getErrors(); if(!empty($errors)){ foreach($errors as $error){ vmError($error); } } JPluginHelper::importPlugin('vmcustom'); $dispatcher = JDispatcher::getInstance(); $error = $dispatcher->trigger('plgVmOnStoreInstallPluginTable', array('custom' , $data, $data['custom_element'])); return $table->virtuemart_custom_id ; } /** * Delete all record ids selected * * @author Max Milbers * @return boolean True is the delete was successful, false otherwise. */ public function remove($ids) { $table = $this->getTable($this->_maintablename); $customfields = $this->getTable ('product_customfields'); foreach($ids as $id) { if (!$table->delete((int)$id)) { vmError(get_class( $this ).'::remove '.$id.' '.$table->getError()); return false; } else { //Delete this customfield also in all product_customfield tables if (!$customfields->delete ($id, 'virtuemart_custom_id')) { vmError ('Custom delete Productcustomfield delete ' . $customfields->getError ()); $ok = FALSE; } } } return true; } } // pure php no closing tag home/academiac/www/administrator/components/com_virtuemart/controllers/custom.php 0000604 00000004540 15137243122 0024704 0 ustar 00 <?php /** * * custom controller * * @package VirtueMart * @subpackage * @author Max Milbers * @link http://www.virtuemart.net * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * @version $Id: custom.php 3039 2011-04-14 22:37:04Z Electrocity $ */ // Check to ensure this file is included in Joomla! defined('_JEXEC') or die('Restricted access'); // Load the controller framework jimport('joomla.application.component.controller'); if(!class_exists('VmController'))require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'vmcontroller.php'); /** * Product Controller * * @package VirtueMart * @author Max Milbers */ class VirtuemartControllerCustom extends VmController { /** * Method to display the view * * @access public * @author */ function __construct() { parent::__construct('virtuemart_custom_id'); } function viewJson() { // Create the view object. $view = $this->getView('custom', 'json'); // Now display the view. $view->display(null); } function save($data = 0) { $data = JRequest::get('post'); // onSaveCustom plugin; parent::save($data); } /** * Clone a product * * @author Max Milbers */ public function createClone() { $mainframe = Jfactory::getApplication(); /* Load the view object */ $view = $this->getView('custom', 'html'); $model = VmModel::getModel('custom'); $msgtype = ''; $cids = JRequest::getVar($this->_cidName, JRequest::getVar('virtuemart_custom_id',array(),'', 'ARRAY'), '', 'ARRAY'); jimport( 'joomla.utilities.arrayhelper' ); JArrayHelper::toInteger($cids); foreach ($cids as $custom_id) { if ($model->createClone($custom_id)) $msg = JText::_('COM_VIRTUEMART_CUSTOM_CLONED_SUCCESSFULLY'); else { $msg = JText::_('COM_VIRTUEMART_CUSTOM_NOT_CLONED_SUCCESSFULLY').' : '.$custom_id; $msgtype = 'error'; } } $mainframe->redirect('index.php?option=com_virtuemart&view=custom', $msg, $msgtype); } } // pure php no closing tag home/academiac/www/libraries/joomla/html/toolbar/button/custom.php 0000644 00000002333 15137261361 0021416 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage HTML * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die; /** * Renders a custom button * * @package Joomla.Platform * @subpackage HTML * @since 11.1 */ class JButtonCustom extends JButton { /** * Button type * * @var string */ protected $_name = 'Custom'; /** * Fetch the HTML for the button * * @param string $type Button type, unused string. * @param string $html HTML strng for the button * @param string $id CSS id for the button * * @return string HTML string for the button * * @since 11.1 */ public function fetchButton($type = 'Custom', $html = '', $id = 'custom') { return $html; } /** * Get the button CSS Id * * @param string $type Not used. * @param string $html Not used. * @param string $id The id prefix for the button. * * @return string Button CSS Id * * @since 11.1 */ public function fetchId($type = 'Custom', $html = '', $id = 'custom') { return $this->_parent->getName() . '-' . $id; } }
©
2018.