diff --git a/Makefile b/Makefile index 62feb1f7b098ee4c1edeb436a88ada0257d51772..5bfd356a098430c583b2a27f50191ef629b604fe 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ BASE=ordernumber PLUGINTYPE=vmshopper -VERSION=2.0 +VERSION=2.1 PLUGINFILES=$(BASE).php $(BASE).script.php $(BASE).xml index.html $(BASE)/ diff --git a/ordernumber.php b/ordernumber.php index 9270fc64ee498ac67fb178f6f99a882d0418610d..5ce79983eac6607f1c2bbafad322e22c305c088b 100644 --- a/ordernumber.php +++ b/ordernumber.php @@ -182,6 +182,8 @@ class plgVmShopperOrdernumber extends vmShopperPlugin { if (isset($details->name)) $reps["[name]"] = $details->name; if (isset($details->user_is_vendor)) $reps["[user_is_vendor]"] = $details->user_is_vendor; } + JPluginHelper::importPlugin('vmshopper'); + JDispatcher::getInstance()->trigger('onVmOrdernumberGetVariables',array(&$reps, $fmt, $nrtype, $details)); return str_ireplace (array_keys($reps), array_values($reps), $fmt); } diff --git a/ordernumber.xml b/ordernumber.xml index 7caf4baf26de7671714253beac81c71d01d331ef..fdb5ba6bf01791705bd62cec17277c6b869009ac 100644 --- a/ordernumber.xml +++ b/ordernumber.xml @@ -7,8 +7,8 @@ <authorUrl>http://www.open-tools.net/</authorUrl> <copyright>Copyright (C) 2012-2014 Reinhold Kainhofer. All rights reserved.</copyright> <license>http://www.gnu.org/licenses/gpl-3.0.html GNU/GPLv3</license> - <version>1.90</version> - <releaseDate>2014-10-05</releaseDate> + <version>2.1</version> + <releaseDate>2014-12-07</releaseDate> <releaseType>Minor update</releaseType> <downloadUrl>http://www.open-tools.net/virtuemart-2-extensions/vm2-ordernumber-plugin.html</downloadUrl> diff --git a/plugins/template/Makefile b/plugins/template/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..07f453fbe73c76d9a108b0a63a3b8d75042925a4 --- /dev/null +++ b/plugins/template/Makefile @@ -0,0 +1,19 @@ +BASE=YOUR_PLUGIN_NAME +PLUGINTYPE=vmshipmentrules +ZIPBASE=opentools_vmshipmentrules +VERSION=1.0 + +PLUGINFILES=$(BASE).php $(BASE).script.php $(BASE).xml index.html + +TRANSLATIONS=$(call wildcard,language/en*/*.plg_$(PLUGINTYPE)_$(BASE).*ini) +INDEXFILES=language/index.html $(call wildcard,language/**/index.html) +ZIPFILE=plg_$(ZIPBASE)_$(BASE)_v$(VERSION).zip + +all: zip + +zip: $(PLUGINFILES) $(TRANSLATIONS) $(ADVANCEDFILES) $(INDEXFILES) + @echo "Packing all files into distribution file $(ZIPFILE):" + @zip -r $(ZIPFILE) $(PLUGINFILES) $(TRANSLATIONS) $(INDEXFILES) + +clean: + rm -f $(ZIPFILE) diff --git a/plugins/template/YOUR_PLUGIN_NAME.php b/plugins/template/YOUR_PLUGIN_NAME.php new file mode 100644 index 0000000000000000000000000000000000000000..8f4479362e2e9c7818d205240cfc563510dce50a --- /dev/null +++ b/plugins/template/YOUR_PLUGIN_NAME.php @@ -0,0 +1,50 @@ +<?php + +defined ('_JEXEC') or die('Restricted access'); + +/** + * Plugin providing Custom variables for the VM Ordernumber plugin + * + * @subpackage Plugins - VmShipmentRules + * @copyright Copyright (C) 2014 Reinhold Kainhofer, office@open-tools.net + * @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://open-tools.net/ + * + */ +if (!class_exists ('VmPlugin')) { + require(JPATH_VM_PLUGINS . DS . 'vmplugin.php'); +} + +/** Extension plugin for the Odernumber plugin for VirtueMart + */ +class plgVmShopperYOUR_PLUGIN_NAME extends VmPlugin { + /** Trigger to add variables to be used in the number formats + * You can add new variables to the $cartvals array or modify existing ones. They will be directly + * available in all formats. This trigger will be called whenever the ordernumber plugin creates a + * number. All built-in variables are already set in the $reps variable, so you can even override + * the built-in variables by changing $reps accordingly. + * $nrtype is 0 for ordernumber, 1 for invoice number, 2 for customer number and 3 for order password + * $details contains the order details + */ + function onVmOrdernumberGetVariables(&$reps, $fmt, $nrtype, $details) { + // As an example add a variable [type] that contains the number type: + switch ($nrtype) { + case 0: $reps['type'] = "Order"; break; + case 1: $reps['type'] = "Invoice"; break; + case 2: $reps['type'] = "Customer"; break; + case 3: $reps['type'] = "OrderPassword"; break; + } + // Another example: set the ip address: + if (isset($details->ip_address)) $reps["[ipaddress]"] = $details->ip_address; + // You can also modify existing variables: + $reps['[second]'] = $reps['[second]'] + 15; + } +} + +// No closing tag diff --git a/plugins/template/YOUR_PLUGIN_NAME.script.php b/plugins/template/YOUR_PLUGIN_NAME.script.php new file mode 100644 index 0000000000000000000000000000000000000000..c8f161286ab145e51059235c9269c121245e5601 --- /dev/null +++ b/plugins/template/YOUR_PLUGIN_NAME.script.php @@ -0,0 +1,88 @@ +<?php +defined('_JEXEC') or die('Restricted access'); + +/** + * Installation script for the plugin + * + * @copyright Copyright (C) 2014 Reinhold Kainhofer, office@open-tools.net + * @license GPL v3+, http://www.gnu.org/copyleft/gpl.html + */ + +// Adjust the class name. It has to be of the form: +// plgVmShopperYOUR_PLUGIN_NAMEInstallerScript +class plgVmShopperYOUR_PLUGIN_NAMEInstallerScript +{ + /** + * 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 upon installation + $db =& JFactory::getDBO(); + $db->setQuery('update #__extensions set enabled = 1 where type = "plugin" and element = "YOUR_PLUGIN_NAME" and folder = "vmshopper"'); + $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_vmshipmentrules_YOUR_PLUGIN_NAME.sys.ini"; +// if (JFile::exists($file)) JFile::delete($file); +// $file = JPATH_ROOT . DS . "administrator" . DS . "language" . DS . "de-DE" . DS . "de-DE.plg_vmshipmentrules_YOUR_PLUGIN_NAME.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 IF EXISTS `#__virtuemart_vmshipmentrulesles_YOUR_PLUGIN_NAME`;'); +// $db->query(); +// } +} diff --git a/plugins/template/YOUR_PLUGIN_NAME.xml b/plugins/template/YOUR_PLUGIN_NAME.xml new file mode 100644 index 0000000000000000000000000000000000000000..e857e9ce49c6f9b2305df641dab620f63327dadb --- /dev/null +++ b/plugins/template/YOUR_PLUGIN_NAME.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<extension version="2.5" type="plugin" group="vmshopper" method="upgrade"> + <name>VMORDERNUMBER_TEMPLATE</name> + <creationDate>2014-12-10</creationDate> + <author>Reinhold Kainhofer, Open Tools</author> + <authorUrl>http://www.open-tools.net</authorUrl> + <copyright>Copyright (C) 2014, Reinhold Kainhofer</copyright> + <license>GPL v3+</license> + <version>1.0</version> + <description>VMORDERNUMBER_TEMPLATE_DESC</description> + <files> + <filename plugin="YOUR_PLUGIN_NAME">YOUR_PLUGIN_NAME.php</filename> + <folder>language</folder> + </files> + <languages folder="language"> + <language tag="en-GB">en-GB/en-GB.plg_vmshopper_YOUR_PLUGIN_NAME.ini</language> + <language tag="en-GB">en-GB/en-GB.plg_vmshopper_YOUR_PLUGIN_NAME.sys.ini</language> + </languages> + <scriptfile>YOUR_PLUGIN_NAME.script.php</scriptfile> + + <!-- VM 3.x support (fields rather than params): --> + <vmconfig></vmconfig> + + <!-- VM 2.0 support (params rather than fields): --> + <params></params> + +</extension> diff --git a/plugins/template/create_ordernumber_plugin.sh b/plugins/template/create_ordernumber_plugin.sh new file mode 100755 index 0000000000000000000000000000000000000000..9b5f125c1b53eaa7adb075ea5b0f57d31e4e0f4a --- /dev/null +++ b/plugins/template/create_ordernumber_plugin.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +ARGC=$# +if [ $ARGC -lt 1 ]; then + echo "Usage: $0 YourPluginName" + echo "Create a proper plugin for the Ordernumber plugin from the provided template" + exit -1; +fi + +name=$1 +pluginname=${name,,} +pLUGINNAME=${name,} +Pluginname=${name^} +PLUGINNAME=${name^^} + +echo "Plugin name=$name, pluginname=$pluginname, pLUGINNAME=$pLUGINNAME, Pluginname=$Pluginname, PLUGINNAME=$PLUGINNAME" + + +mkdir -p $pluginname/language/en-GB/ + +sed "s/YOUR_PLUGIN_NAME/$Pluginname/g" $SRCDIR/YOUR_PLUGIN_NAME.php > $pluginname/$pluginname.php +sed "s/YOUR_PLUGIN_NAMEInstaller/${Pluginname}Installer/g; s/YOUR_PLUGIN_NAME/$pluginname/g" $SRCDIR/YOUR_PLUGIN_NAME.script.php > $pluginname/$pluginname.script.php +sed "s/YOUR_PLUGIN_NAME/$pluginname/g; s/VMORDERNUMBER_TEMPLATE/VMORDERNUMBER_$PLUGINNAME/g" $SRCDIR/YOUR_PLUGIN_NAME.xml > $pluginname/$pluginname.xml +sed "s/YOUR_PLUGIN_NAME/$pluginname/g" $SRCDIR/Makefile > $pluginname/Makefile +for i in $SRCDIR/language/en-GB/*.ini; do + sed "s/YOUR_PLUGIN_NAME/$pluginname/g; s/VMORDERNUMBER_TEMPLATE/VMORDERNUMBER_$PLUGINNAME/g" $i > $pluginname/${i#$SRCDIR} +done +rename "s/YOUR_PLUGIN_NAME/$pluginname/g" $pluginname/language/en-GB/* +for i in `find $SRCDIR/ -name index.html`; do + cp $i $pluginname/${i#$SRCDIR} +done + +echo "Created new plugin '$pluginname' for the Ordernumber plugin. Please adjust the plugin's onVmOrdernumberGetVariables, all copyright statements and the translations" \ No newline at end of file diff --git a/plugins/template/index.html b/plugins/template/index.html new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/plugins/template/language/en-GB/en-GB.plg_vmshopper_YOUR_PLUGIN_NAME.ini b/plugins/template/language/en-GB/en-GB.plg_vmshopper_YOUR_PLUGIN_NAME.ini new file mode 100755 index 0000000000000000000000000000000000000000..5d2f317822b520fcb142e5446368ed8e7606f40f --- /dev/null +++ b/plugins/template/language/en-GB/en-GB.plg_vmshopper_YOUR_PLUGIN_NAME.ini @@ -0,0 +1,6 @@ +; VM Ordernumber plugin: Template for extension plugins +; Copyright (C) 2014 Reinhold Kainhofer, Open Tools. All rights reserved. +; License http://www.gnu.org/licenses/gpl.html GNU/GPL +; Note : All ini files need to be saved as UTF-8 - No BOM +VMORDERNUMBER_TEMPLATE="VM Ordernumber Extension Template" +VMORDERNUMBER_TEMPLATE_DESC="This plugin is just a demo template that highlights how one can extend the Ordernumber plugin with a plugin of type vmshopper. If installed, it does not do anything useful or harmful." diff --git a/plugins/template/language/en-GB/en-GB.plg_vmshopper_YOUR_PLUGIN_NAME.sys.ini b/plugins/template/language/en-GB/en-GB.plg_vmshopper_YOUR_PLUGIN_NAME.sys.ini new file mode 100755 index 0000000000000000000000000000000000000000..5d2f317822b520fcb142e5446368ed8e7606f40f --- /dev/null +++ b/plugins/template/language/en-GB/en-GB.plg_vmshopper_YOUR_PLUGIN_NAME.sys.ini @@ -0,0 +1,6 @@ +; VM Ordernumber plugin: Template for extension plugins +; Copyright (C) 2014 Reinhold Kainhofer, Open Tools. All rights reserved. +; License http://www.gnu.org/licenses/gpl.html GNU/GPL +; Note : All ini files need to be saved as UTF-8 - No BOM +VMORDERNUMBER_TEMPLATE="VM Ordernumber Extension Template" +VMORDERNUMBER_TEMPLATE_DESC="This plugin is just a demo template that highlights how one can extend the Ordernumber plugin with a plugin of type vmshopper. If installed, it does not do anything useful or harmful." diff --git a/plugins/template/language/en-GB/index.html b/plugins/template/language/en-GB/index.html new file mode 100644 index 0000000000000000000000000000000000000000..2efb97f319a35f6bd80f1751134ed71ec11888eb --- /dev/null +++ b/plugins/template/language/en-GB/index.html @@ -0,0 +1 @@ +<!DOCTYPE html><title></title> diff --git a/plugins/template/language/index.html b/plugins/template/language/index.html new file mode 100644 index 0000000000000000000000000000000000000000..2efb97f319a35f6bd80f1751134ed71ec11888eb --- /dev/null +++ b/plugins/template/language/index.html @@ -0,0 +1 @@ +<!DOCTYPE html><title></title>