Skip to content
Snippets Groups Projects
Commit 5cccb2a2 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
.svn
*~
cache
*.kate-swp
logs
tmp
Makefile 0 → 100644
BASE=donation
PLUGINTYPE=vmcustom
VERSION=0.1
PLUGINFILES=$(BASE).php $(BASE).script.php $(BASE).xml index.html
TRANSLATIONS=$(call wildcard,language/*/*.plg_$(PLUGINTYPE)_$(BASE).*ini)
INDEXFILES=language/index.html $(call wildcard,language/*/index.html)
TMPLFILES=$(call wildcard,$(BASE)/tmpl/*.php)
ASSETS=
ZIPFILE=plg_$(PLUGINTYPE)_$(BASE)_v$(VERSION).zip
zip: $(PLUGINFILES) $(TRANSLATIONS) $(ELEMENTS) $(INDEXFILES) $(TMPLFILES) $(ASSETS)
@echo "Packing all files into distribution file $(ZIPFILE):"
@zip -r $(ZIPFILE) $(PLUGINFILES) $(TRANSLATIONS) $(ELEMENTS) $(INDEXFILES) $(TMPLFILES) $(ASSETS)
clean:
rm -f $(ZIPFILE)
<?php
defined('_JEXEC') or die( 'Direct Access to ' . basename( __FILE__ ) . ' is not allowed.' ) ;
/**
* A custom field plugin for downloadable files
* @author Reinhold Kainhofer
* @package VirtueMart
* @subpackage vmcustom
* @copyright Copyright (C) 2013 Reinhold Kainhofer - 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.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://kainhofer.com
*/
if (!class_exists('vmCustomPlugin')) require(JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php');
// if(!class_exists('VmTable'))require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'vmtable.php');
if (JVM_VERSION === 2) {
if (!defined('VMDONATION_PLUGINPATH')) define('VMDONATION_PLUGINPATH', JPATH_SITE.DS.'plugins'.DS.'vmcustom'.DS.'set_price');
if (!defined('VMDONATION_PLUGINWEBROOT')) define('VMDONATION_PLUGINWEBROOT', 'plugins/vmcustom/set_price');
} else {
if (!defined('VMDONATION_PLUGINPATH')) define('VMDONATION_PLUGINPATH', JPATH_SITE.DS.'plugins'.DS.'vmcustom');
if (!defined('VMDONATION_PLUGINWEBROOT')) define('VMDONATION_PLUGINWEBROOT', 'plugins/vmcustom');
}
class plgVmCustomDonation extends vmCustomPlugin {
function __construct(& $subject, $config) {
parent::__construct($subject, $config);
$varsToPush = array(
);
$this->setConfigParameterable('custom_params',$varsToPush);
}
/**
* @see Form displayed in the product edit page in the BE, configure the download file
* @author Reinhold Kainhofer
*/
function plgVmOnProductEdit($field, $product_id, &$row,&$retValue) {
if ($field->custom_element != $this->_name) return '';
// $this->parseCustomParams($field);
// $html = '';
//
// $retValue .= $html;
// $row++;
// return true ;
}
/**
* plgVmOnDisplayProductVariantFE ... Called for product variant custom fields to display on the product details page
*/
function plgVmOnDisplayProductVariantFE($field,&$row,&$group) {
// default return if it's not this plugin
if ($field->custom_element != $this->_name) return '';
$this->getCustomParams($field);
$group->display .= $this->renderByLayout('default',array($field,&$idx,&$group ) );
return true;
}
/**
* @see components/com_virtuemart/helpers/vmCustomPlugin::plgVmOnViewCartModule()
* @author Patrick Kohl
*/
function plgVmOnViewCartModule( $product,$row,&$html) {
return $this->plgVmOnViewCart($product,$row,$html);
}
/**
* @see components/com_virtuemart/helpers/vmCustomPlugin::plgVmOnViewCart()
* @author Patrick Kohl
*/
function plgVmOnViewCart($product,$row,&$html) {
if (empty($product->productCustom->custom_element) or $product->productCustom->custom_element != $this->_name) return '';
if (!$plgParam = $this->GetPluginInCart($product)) return '' ;
foreach($plgParam as $k => $item){
if(!empty($item['customprice']) && ($product->productCustom->virtuemart_customfield_id==$k)){
$html .='<span>'.JText::_($product->productCustom->custom_title).' '.$item['customprice'].'</span>';
}
}
return true;
}
/**
* vendor order display BE
*/
function plgVmDisplayInOrderBE($item, $row, &$html) {
if (empty($item->productCustom->custom_element) or $item->productCustom->custom_element != $this->_name) return '';
$this->plgVmOnViewCart($item,$row,$html); //same render as cart
}
/**
*
* shopper order display FE
*/
function plgVmDisplayInOrderFE($item, $row, &$html) {
if (empty($item->productCustom->custom_element) or $item->productCustom->custom_element != $this->_name) return '';
$this->plgVmOnViewCart($item,$row,$html); //same render as cart
}
/**
* We must reimplement this triggers for joomla 1.7
* vmplugin triggers note by Max Milbers
*/
public function plgVmOnStoreInstallPluginTable($psType, $name) {
//Should the textinput use an own internal variable or store it in the params?
//Here is no getVmPluginCreateTableSQL defined
// return $this->onStoreInstallPluginTable($psType);
}
function plgVmDeclarePluginParamsCustom($psType,$name,$id, &$data){
return $this->declarePluginParams('custom', $name, $id, $data);
}
function plgVmSetOnTablePluginParamsCustom($name, $id, &$table){
return $this->setOnTablePluginParams($name, $id, $table);
}
/**
* Custom triggers note by Max Milbers
*/
function plgVmOnDisplayEdit($virtuemart_custom_id,&$customPlugin){
return $this->onDisplayEditBECustom($virtuemart_custom_id,$customPlugin);
}
public function plgVmCalculateCustomVariant($product, &$productCustomsPrice, $selected){
if ($productCustomsPrice->custom_element !==$this->_name) return ;
$customVariant = $this->getCustomVariant($product, $productCustomsPrice, $selected);
if (!empty($customVariant['customprice'])) {
$productCustomsPrice->custom_price = $customVariant['customprice'];
} else {
$productCustomsPrice->custom_price = 0.0;
}
return true;
}
public function plgVmDisplayInOrderCustom(&$html,$item, $param,$productCustom, $row ,$view='FE'){
$this->plgVmDisplayInOrderCustom($html,$item, $param,$productCustom, $row ,$view);
}
public function plgVmCreateOrderLinesCustom(&$html,$item,$productCustom, $row ){
// $this->createOrderLinesCustom($html,$item,$productCustom, $row );
}
function plgVmOnSelfCallFE($type,$name,&$render) {
$render->html = '';
}
// /**
// * Create the database table for this plugin.
// */
// public function getVmPluginCreateTableSQL() {
// return $this->createTableSQL('Downloads for Sale tracking');
// }
//
// function getTableSQLFields() {
// $SQLfields = array(
// 'id' => 'int(1) UNSIGNED NOT NULL AUTO_INCREMENT',
// 'virtuemart_customfield_id' => 'int(11) UNSIGNED NOT NULL DEFAULT 0',
// 'virtuemart_order_item_id' => 'int(11) UNSIGNED NULL DEFAULT 0',
// 'downloaded' => 'int(11) UNSIGNED NOT NULL DEFAULT 0',
// );
// return $SQLfields;
// }
}
// No closing tag
\ No newline at end of file
<?php
defined('_JEXEC') or die('Restricted access');
class plgVmCustomDownloads_for_SaleInstallerScript
{
/**
* Constructor
*
* @param JAdapterInstance $adapter The object responsible for running this script
*/
// public function __constructor(JAdapterInstance $adapter);
/**
* Called before any type of action
*
* @param string $route Which action is happening (install|uninstall|discover_install)
* @param JAdapterInstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
// public function preflight($route, JAdapterInstance $adapter);
/**
* Called after any type of action
*
* @param string $route Which action is happening (install|uninstall|discover_install)
* @param JAdapterInstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
// public function postflight($route, JAdapterInstance $adapter);
/**
* Called on installation
*
* @param JAdapterInstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
public function install(JAdapterInstance $adapter)
{
// enabling plugin
$db =& JFactory::getDBO();
$db->setQuery('update #__extensions set enabled = 1 where type = "plugin" and element = "donation" and folder = "vmcustom"');
$db->query();
return True;
}
/**
* Called on update
*
* @param JAdapterInstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
// public function update(JAdapterInstance $adapter)
// {
// jimport( 'joomla.filesystem.file' );
// $file = JPATH_ROOT . DS . "administrator" . DS . "language" . DS . "en-GB" . DS . "en-GB.plg_vmshopper_ordernumber.sys.ini";
// if (JFile::exists($file)) JFile::delete($file);
// $file = JPATH_ROOT . DS . "administrator" . DS . "language" . DS . "de-DE" . DS . "de-DE.plg_vmshopper_ordernumber.sys.ini";
// if (JFile::exists($file)) JFile::delete($file);
// return true;
// }
/**
* Called on uninstallation
*
* @param JAdapterInstance $adapter The object responsible for running this script
*/
public function uninstall(JAdapterInstance $adapter)
{
// Remove plugin table
// $db =& JFactory::getDBO();
// $db->setQuery('DROP TABLE `#__virtuemart_shipment_plg_rules_shipping`;');
// $db->query();
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<install version="1.5" type="plugin" group="vmcustom" method="upgrade">
<name>VMCUSTOM_SETPRICE</name>
<creationDate>2013-03-02</creationDate>
<author>Reinhold Kainhofer</author>
<authorUrl>http://www.kainhofer.com/</authorUrl>
<copyright>Copyright (C) 2013 Reinhold Kainhofer. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl.html GNU/GPL v3+</license>
<version>0.1.0</version>
<description>VMCUSTOM_SETPRICE_DESC</description>
<files>
<filename plugin="set_price">set_price.php</filename>
<filename>set_price.script.php</filename>
<folder>language</folder>
<filename>index.html</filename>
</files>
<languages folder="language">
<language tag="en-GB">en-GB/en-GB.plg_vmcustom_set_price.ini</language>
<language tag="en-GB">en-GB/en-GB.plg_vmcustom_set_price.sys.ini</language>
</languages>
<scriptfile>set_price.script.php</scriptfile>
<params addpath="/administrator/components/com_virtuemart/elements">
<param type="vmjpluginwarning" />
</params>
</install>
<?php
defined('_JEXEC') or die();
$class='vmcustom-settext';
//vmdebug('$this',$viewData[0]);
//if ($field->custom_price_by_letter) $class='vmcustom-textinput';?>
<input class="<?php echo $class ?>" type="text" value="" name="customPlugin[<?php echo $viewData[0]->virtuemart_customfield_id ?>][<?php echo $this->_name?>][customprice]"><br />
<?php
// preventing 2 x load javascript
static $textinputjs;
if ($textinputjs) return true;
$textinputjs = true ;
//javascript to update price
$document = JFactory::getDocument();
$document->addScriptDeclaration('
/* <![CDATA[ */
jQuery(document).ready( function($) {
jQuery(".vmcustom-textinput").keyup(function() {
formProduct = $(this).parents("form.product");
virtuemart_product_id = formProduct.find(\'input[name="virtuemart_product_id[]"]\').val();
Virtuemart.setproducttype(formProduct,virtuemart_product_id);
});
});
/* ]]> */
');
\ No newline at end of file
; Virtuemart! Project
; Copyright (C) 2011 Virtuemart Team. All rights reserved.
; License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php
; Note : All ini files need to be saved as UTF-8 - No BOM
VMCUSTOM_DONATION="VM Donation Plugin"
VMCUSTOM_DONATION_DESC="VirtueMart customfield plugin to let the user add a donation or set the price of a product."
; Virtuemart! Project
; Copyright (C) 2011 Virtuemart Team. All rights reserved.
; License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php
; Note : All ini files need to be saved as UTF-8 - No BOM
VMCUSTOM_DONATION="VM Donation Plugin"
VMCUSTOM_DONATION_DESC="VirtueMart customfield plugin to let the user add a donation or set the price of a product."
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment