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

V0.2: Initial version, including text version list display

parent 24efd549
No related branches found
No related tags found
No related merge requests found
Showing
with 265 additions and 169 deletions
Makefile 0 → 100644
BASE=versioncompat
PLUGINTYPE=vmcustom
VERSION=0.2
PLUGINFILES=$(BASE).php $(BASE).script.php $(BASE).xml index.html $(BASE)/
SYSTRANSLATIONS=$(call wildcard,language/*/*.plg_$(PLUGINTYPE)_$(BASE).*sys.ini)
NONSYSTRANSLATIONS=${SYSTRANSLATIONS:%.sys.ini=%.ini}
TRANSLATIONS=$(SYSTRANSLATIONS) $(NONSYSTRANSLATIONS) $(call wildcard,language/*/index.html) language/index.html
FIELDS=fields/ elements/
ZIPFILE=plg_$(PLUGINTYPE)_$(BASE)_v$(VERSION).zip
all: zip
$(NONSYSTRANSLATIONS): %.ini: %.sys.ini
cp $< $@
zip: $(PLUGINFILES) $(TRANSLATIONS) $(SYSTRANSLATIONS) $(NONSYSTRANSLATIONS)
@echo "Packing all files into distribution file $(ZIPFILE):"
@zip -r $(ZIPFILE) $(PLUGINFILES) $(TRANSLATIONS) $(FIELDS)
clean:
rm -f $(ZIPFILE)
<?php
defined ('_JEXEC') or die();
/**
*
* @package VirtueMart
* @subpackage Plugins - Elements
* @author Reinhold Kainhofer
* @link http://www.open-tools.net
* @copyright Copyright (C) 2014 Open Tools, Reinhold Kainhofer. All rights reserved.
* Based on Joomla core files:
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*
* VirtueMart and this plugin are 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.
*
*/
if (!class_exists('VmConfig')) require(JPATH_VM_ADMINISTRATOR.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'config.php');
if(!class_exists('VmModel')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'vmmodel.php');
jimport('joomla.filesystem.folder');
/*
* This class is used by VirtueMart Payment or Shipment Plugins
* which uses JParameter
* So It should be an extension of JElement
* Those plugins cannot be configured througth the Plugin Manager anyway.
*/
class JElementCompatFolders extends JElement {
/**
* Element name
*
* @access protected
* @var string
*/
var $_name = 'CompatFolders';
protected function getGroups($node)
{
$groups = array(''=>JHtml::_('select.option', '', '---'));
foreach ($node->children() as $dir) {
if ($dir->name() != 'folder') continue;
$directory = (string)$dir->data();
if ($groupLabel = (string) $dir->attributes('label')) {
$label = JText::_($groupLabel);
} else {
$label = $directory;
}
if (!JFolder::exists($directory))
$directory = JPATH_ROOT . DS . $directory;
if (!JFolder::exists($directory)) continue;
// Initialize the group if necessary.
if (!isset($groups[$label])) {
$groups[$label]['id'] = $label;
$groups[$label]['text'] = $label;
$groups[$label]['items'] = array();
}
// List all subfolders of the given directory:
$folders = JFolder::folders($directory, (string)$dir->attributes('filter'));
foreach ($folders as $option) {
$groups[$label]['items'][] = JHtml::_('select.option', (string)$dir->data().$option, $option);
}
}
reset($groups);
return $groups;
}
function fetchElement ($name, $value, &$node, $control_name) {
$dirs = $this->getGroups($node);
$class = ($node->attributes('class') ? 'class="' . $node->attributes('class') . '"' : '');
return JHTML::_ ('select.groupedlist', $dirs, '' . $control_name . '[' . $name . ']',
array('id' => $control_name . $name, 'list.attr' => $class, 'list.select' => array($value)));
}
}
<html>
<body bgcolor="#FFFFFF">
</body>
</html>
\ No newline at end of file
......@@ -20,10 +20,10 @@ class JFormFieldCompatFolders extends JFormFieldGroupedList
protected function getGroups()
{
$groups = array();
$groups = array(JHtml::_('select.option', '', '---'));
foreach ($this->element->children() as $dir) {
if ($dir->getName() != 'folder') continue;
$directory = (string)$dir;
if ($groupLabel = (string) $dir['label']) {
$label = JText::_($groupLabel);
......@@ -31,18 +31,18 @@ class JFormFieldCompatFolders extends JFormFieldGroupedList
$label = $directory;
}
if (!JFolder::exists($directory))
$directory = JPATH_ROOT . '/' . $directory;
$directory = JPATH_ROOT . DS . $directory;
if (!JFolder::exists($directory)) continue;
// Initialize the group if necessary.
if (!isset($groups[$label]))
if (!isset($groups[$label]))
$groups[$label] = array();
// List all subfolders of the given directory:
$folders = JFolder::folders($directory, (string)$dir['filter']);
foreach ($folders as $option) {
$groups[$label][] = JHtml::_('select.option', (string)$dir.'/'.$option, $option);
$groups[$label][] = JHtml::_('select.option', (string)$dir.DS.$option, $option);
}
}
reset($groups);
......
<html>
<body bgcolor="#FFFFFF">
</body>
</html>
\ No newline at end of file
<html>
<body bgcolor="#FFFFFF">
</body>
</html>
\ No newline at end of file
......@@ -8,4 +8,9 @@ VMCUSTOM_VERSIONCOMPAT_FOLDER="Folder containing choices"
VMCUSTOM_VERSIONCOMPAT_FOLDER_PLUGIN="Plugin's directory"
VMCUSTOM_VERSIONCOMPAT_FOLDER_JOOMLA="Joomla Media directory"
VMCUSTOM_VERSIONCOMPAT_FOLDER_IMAGES="Joomla Image directory"
VMCUSTOM_VERSIONCOMPAT_SEARCHABLE="Searchable"
\ No newline at end of file
VMCUSTOM_VERSIONCOMPAT_SEARCHABLE="Searchable"
VMCUSTOM_VERSIONCOMPAT_NONE="(None)"
VMCUSTOM_VERSIONCOMPAT_TEXTVERSIONS="Text versions"
VMCUSTOM_VERSIONCOMPAT="Version compatibility"
VMCUSTOM_VERSIONCOMPAT_IMAGES="Images"
VMCUSTOM_VERSIONCOMPAT_TEXTS="Text versions"
......@@ -8,4 +8,9 @@ VMCUSTOM_VERSIONCOMPAT_FOLDER="Folder containing choices"
VMCUSTOM_VERSIONCOMPAT_FOLDER_PLUGIN="Plugin's directory"
VMCUSTOM_VERSIONCOMPAT_FOLDER_JOOMLA="Joomla Media directory"
VMCUSTOM_VERSIONCOMPAT_FOLDER_IMAGES="Joomla Image directory"
VMCUSTOM_VERSIONCOMPAT_SEARCHABLE="Searchable"
\ No newline at end of file
VMCUSTOM_VERSIONCOMPAT_SEARCHABLE="Searchable"
VMCUSTOM_VERSIONCOMPAT_NONE="(None)"
VMCUSTOM_VERSIONCOMPAT_TEXTVERSIONS="Text versions"
VMCUSTOM_VERSIONCOMPAT="Version compatibility"
VMCUSTOM_VERSIONCOMPAT_IMAGES="Images"
VMCUSTOM_VERSIONCOMPAT_TEXTS="Text versions"
<html>
<body bgcolor="#FFFFFF">
</body>
</html>
\ No newline at end of file
File added
......@@ -18,170 +18,133 @@ if (!class_exists('vmCustomPlugin')) require(JPATH_VM_PLUGINS . DS . 'vmcustompl
class plgVmCustomVersionCompat extends vmCustomPlugin {
function __construct(& $subject, $config) {
parent::__construct($subject, $config);
$this->_tablepkey = 'id';
$this->tableFields = array_keys($this->getTableSQLFields());
$this->varsToPush = array('compatibility'=> array('', 'string'),'searchable'=>array(0,'int'));
$this->setConfigParameterable('custom_params',$this->varsToPush);
}
/**
* Create the table for this plugin if it does not yet exist.
*/
public function getVmPluginCreateTableSQL() {
return $this->createTableSQL('Joomla Compatibility Table');
}
function getTableSQLFields() {
$SQLfields = array(
'id' => 'bigint(20) unsigned NOT NULL AUTO_INCREMENT',
'virtuemart_custom_id' => 'int(11) UNSIGNED DEFAULT NULL',
'virtuemart_product_id' => 'int(11) UNSIGNED DEFAULT NULL',
'compatibility' => 'varchar(50) NOT NULL DEFAULT \'\' ',
);
return $SQLfields;
}
function getImages() {
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
$path = __DIR__.DS.'joocompatibility';
$images = JFolder::files($path,'.png');
return $images;
}
// get product param for this plugin on edit
function plgVmOnProductEdit($field, $product_id, &$row,&$retValue) {
function __construct(& $subject, $config) {
parent::__construct($subject, $config);
$this->varsToPush = array(
'compatibility'=>array(array(), 'array'),
'versions'=>array(array(), 'array'),
'searchable'=>array(0,'int'),
'directory'=>array('', 'string'),
'textversions'=>array('', 'string'),
);
if(!defined('VM_VERSION') or VM_VERSION < 3){
$this->setConfigParameterable ('custom_params', $this->varsToPush);
} else {
$this->setConfigParameterable ('customfield_params', $this->varsToPush);
}
}
function getImages($path) {
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
if (!JFolder::exists($path))
$path = JPATH_ROOT . DS . $path;
if (!JFolder::exists($path)) continue;
$images = JFolder::files($path, '.png');
return $images;
}
// get product param for this plugin on edit
function plgVmOnProductEdit($field, $product_id, &$row, &$retValue) {
if ($field->custom_element != $this->_name) return '';
$this->getCustomParams($field);
$this->getPluginCustomData($field, $product_id);
$images = $this->getImages();
$logos = array();
foreach ($images as $logo) {
$logos[] = JHTML::_('select.option', $logo, strtoupper(basename($logo,'.png')));
}
$id = $this->getIdForCustomIdProduct ($product_id, $field->virtuemart_custom_id);
$datas = $this->getPluginInternalData ($id);
$selectedOptions = explode($this->glue,$datas->compatibility);
$html ='<div>';
$html .= '<input type="hidden" name="plugin_param['.$row.']['.$this->_name.'][virtuemart_custom_id]" value="'.$field->virtuemart_custom_id.'" />';
$html .= JHTML::_('select.genericlist', $logos, 'plugin_param['.$row.']['.$this->_name.'][compatibility][]', ' size="5" multiple="multiple"', 'value', 'text', $selectedOptions );
$html .='</div>';
$retValue .= $html ;
$row++;
return true ;
}
if(!defined('VM_VERSION') or VM_VERSION < 3){
$this->parseCustomParams ($field); // Not needed in VM3!
$paramName = 'custom_param';
} else {
$paramName = 'customfield_params';
}
$html = '';
$html .='<fieldset>';
// $html .= '<legend>'. JText::_('VMCUSTOM_VERSIONCOMPAT') .'</legend>';
$html .= '<table class="admintable">
';
if (!empty($field->directory)) {
$images = $this->getImages($field->directory);
$logos = array();
foreach ($images as $logo) {
$logos[] = JHTML::_('select.option', $logo, strtoupper(basename($logo,'.png')));
}
$html .= VmHTML::row('genericlist', 'VMCUSTOM_VERSIONCOMPAT_IMAGES', $logos, $paramName.'['.$row.'][compatibility][]', ' size="5" multiple data-placeholder="' . JText::_('VMCUSTOM_VERSIONCOMPAT_NONE') . '" ', 'value', 'text', $field->compatibility);
}
if (!empty($field->textversions)) {
$textversions = explode(",", $field->textversions);
$logos = array();
foreach ($textversions as $ver) {
$v = trim($ver);
$versions[] = JHTML::_('select.option', $v, $v);
}
$html .= VmHTML::row('genericlist', 'VMCUSTOM_VERSIONCOMPAT_TEXTS', $versions, $paramName.'['.$row.'][versions][]', ' size="5" multiple data-placeholder="' . JText::_('VMCUSTOM_VERSIONCOMPAT_NONE') . '" ', 'value', 'text', $field->versions);
}
$html .= '</table></fieldset>';
$retValue .= $html;
$row++;
return true;
}
function displayProductFE ($product, &$group) {
// default return if it's not this plugin
if ($group->custom_element != $this->_name) return '';
if (!defined('VM_VERSION') or VM_VERSION < 3) { // VM2
$this->parseCustomParams($group);
}
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
$group->display .= $this->renderByLayout('default',array($group->directory, $group->compatibility, $group->versions) );
return true;
}
/**
* @ idx plugin index
* @see components/com_virtuemart/helpers/vmCustomPlugin::onDisplayProductFE()
* @author Patrick Kohl
* Display product
*/
function plgVmOnDisplayProductFE($product,&$idx,&$group) {
// default return if it's not this plugin
if ($group->custom_element != $this->_name) return '';
$this->_tableChecked = true;
$this->getCustomParams($group);
$this->getPluginCustomData($group, $product->virtuemart_product_id);
$id = $this->getIdForCustomIdProduct ($product->virtuemart_product_id, $group->virtuemart_custom_id);
$datas = $this->getPluginInternalData ($id);
$this->params->selectedOptions = explode($this->glue,$datas->compatibility);
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
$this->params->path = 'plugins/vmcustom/joocompatibility/';
if (JFolder::exists(JPATH_SITE.DS.'plugins'.DS.'vmcustom'.DS.'joocompatibility'.DS.'joocompatibility')) {
$this->params->path = 'plugins/vmcustom/joocompatibility/joocompatibility/';
}
$group->display .= $this->renderByLayout('default',array($this->params,&$idx,&$group ) );
return true;
}
function plgVmOnStoreProduct($data,$plugin_param){
if (key ($plugin_param) == $this->_name) {
if (is_array($plugin_param[$this->_name]['compatibility'])) {
$compatibility = implode($this->glue,$plugin_param[$this->_name]['compatibility']);
} else {
$compatibility = $plugin_param[$this->_name]['compatibility'];
}
$plugin_param[$this->_name]['compatibility'] = $compatibility;
}
return $this->OnStoreProduct($data,$plugin_param);
}
public function plgVmSelectSearchableCustom(&$selectList,&$searchCustomValues,$virtuemart_custom_id)
{
$db =JFactory::getDBO();
$db->setQuery('SELECT `virtuemart_custom_id`, `custom_title`, custom_params FROM `#__virtuemart_customs` WHERE `custom_element` ="'.$this->_name.'"');
$custom_param = $db->loadObject();
$this->selectList = $db->loadAssocList();
VmTable::bindParameterable ($custom_param, 'custom_params', $this->_varsToPushParam);
if (!$custom_param->searchable) {
return;
}
$this->params->custom_title = $custom_param->custom_title;
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
$this->params->path = 'plugins/vmcustom/joocompatibility/';
if (JFolder::exists(JPATH_SITE.DS.'plugins'.DS.'vmcustom'.DS.'joocompatibility'.DS.'joocompatibility')) {
$this->params->path = 'plugins/vmcustom/joocompatibility/joocompatibility/';
}
$this->params->images = $this->getImages();
$this->params->searched = JRequest::getVar('joocompatibility',array());
$selectList = array_merge((array)$this->selectList,$selectList);
$searchCustomValues .= $this->renderByLayout('search',array($this->params) );
return true;
}
function plgVmOnDisplayProductFE($product, &$idx, &$group) {
return $this->displayProductFE($product, $group);
}
public function plgVmAddToSearch(&$where,&$PluginJoinTables,$custom_id)
{
$searched = JRequest::getVar('joocompatibility',array());
$conditions = array();
if (count($searched)) {
foreach ($searched as $searchOption) {
$conditions[] = $this->_name .'.`compatibility` LIKE "%'.$searchOption.'%"';
}
$where[] = implode(' OR ', $conditions);
$PluginJoinTables[] = $this->_name ;
}
return true;
}
function plgVmOnDisplayProductFEVM3(&$product, &$group) {
return $this->displayProductFE($product, $group);
}
/**
* We must reimplement this triggers for joomla 1.7
* vmplugin triggers note by Max Milbers
*/
public function plgVmOnStoreInstallPluginTable($psType,$name) {
return $this->onStoreInstallPluginTable($psType,$name);
}
// public function plgVmOnStoreInstallPluginTable($psType,$name) {
// return $this->onStoreInstallPluginTable($psType,$name);
// }
function plgVmSetOnTablePluginParamsCustom($name, $id, &$table){
return $this->setOnTablePluginParams($name, $id, $table);
}
function plgVmDeclarePluginParamsCustom($psType,$name,$id, &$data){
return $this->declarePluginParams('custom', $name, $id, $data);
}
function plgVmDeclarePluginParamsCustom($psType,$name,$id, &$data){
return $this->declarePluginParams('custom', $name, $id, $data);
}
/**
* Custom triggers note by Max Milbers
*/
function plgVmDeclarePluginParamsCustomVM3(&$data){
return $this->declarePluginParams('custom', $data);
}
function plgVmGetTablePluginParams($psType, $name, $id, &$xParams, &$varsToPush){
return $this->getTablePluginParams($psType, $name, $id, $xParams, $varsToPush);
}
// /**
// * Custom triggers note by Max Milbers
// */
function plgVmOnDisplayEdit($virtuemart_custom_id,&$customPlugin){
return $this->onDisplayEditBECustom($virtuemart_custom_id,$customPlugin);
}
......
......@@ -6,7 +6,7 @@
<authorUrl>http://www.open-tools.net/</authorUrl>
<creationDate>2014-12-16</creationDate>
<copyright>2010 Daycounts.com, 2014 OpenTools.net</copyright>
<version>2.0.0</version>
<version>0.2</version>
<description>Version compatibility custom field</description>
<files>
<filename plugin="versioncompat">versioncompat.php</filename>
......@@ -25,26 +25,23 @@
<!-- VM 3.x support (fields rather than params): -->
<vmconfig>
<fields name="params" addfieldpath="/administrator/components/com_virtuemart/fields">
<fieldset name="customfield" label="VMCUSTOM_VERSIONCOMPAT_CONFIG" addfieldpath="/plugins/vmcustom/versioncompat/fields">
<field name="directory" size="500" type="compatfolders" scope="com_virtuemart" label="VMCUSTOM_VERSIONCOMPAT_FOLDER">
<folder label="VMCUSTOM_VERSIONCOMPAT_FOLDER_PLUGIN">/plugins/vmcustom/versioncompat/versioncompat/images/</folder>
<folder label="VMCUSTOM_VERSIONCOMPAT_FOLDER_JOOMLA">/media/plg_vmcustom_versioncompat/</folder>
<folder label="VMCUSTOM_VERSIONCOMPAT_FOLDER_IMAGES">/images/versioncompat/</folder>
<fieldset name="versioncompat" addfieldpath="/plugins/vmcustom/versioncompat/fields">
<field name="directory" type="compatfolders" scope="com_virtuemart" label="VMCUSTOM_VERSIONCOMPAT_FOLDER">
<folder label="VMCUSTOM_VERSIONCOMPAT_FOLDER_PLUGIN">plugins/vmcustom/versioncompat/versioncompat/images/</folder>
<folder label="VMCUSTOM_VERSIONCOMPAT_FOLDER_JOOMLA">media/plg_vmcustom_versioncompat/</folder>
<folder label="VMCUSTOM_VERSIONCOMPAT_FOLDER_IMAGES">images/versioncompat/</folder>
</field>
<field name="searchable" type="radio" scope="com_virtuemart" default="1" class="btn-group btn-group-yesno" label="VMCUSTOM_VERSIONCOMPAT_SEARCHABLE">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="textversions" type="text" size="70" label="VMCUSTOM_VERSIONCOMPAT_TEXTVERSIONS" />
</fieldset>
</fields>
</vmconfig>
<params addpath="/administrator/components/com_virtuemart/elements">
<param type="vmjpluginwarning" />
<param name="searchable" type="radio" default="1" label="searchable">
<option value="1">Yes</option>
<option value="0">No</option>
<params name="params" addpath="/plugins/vmcustom/versioncompat/elements">
<param name="directory" type="compatfolders" scope="com_virtuemart" label="VMCUSTOM_VERSIONCOMPAT_FOLDER">
<folder label="VMCUSTOM_VERSIONCOMPAT_FOLDER_PLUGIN">plugins/vmcustom/versioncompat/versioncompat/images/</folder>
<folder label="VMCUSTOM_VERSIONCOMPAT_FOLDER_JOOMLA">media/plg_vmcustom_versioncompat/</folder>
<folder label="VMCUSTOM_VERSIONCOMPAT_FOLDER_IMAGES">images/versioncompat/</folder>
</param>
<param name="textversions" type="text" size="70" label="VMCUSTOM_VERSIONCOMPAT_TEXTVERSIONS" />
</params>
</extension>
\ No newline at end of file
versioncompat/images/ExtensionTypes/component.png

667 B

versioncompat/images/ExtensionTypes/hack.png

967 B

<html>
<body bgcolor="#FFFFFF">
</body>
</html>
\ No newline at end of file
versioncompat/images/ExtensionTypes/language.png

488 B

versioncompat/images/ExtensionTypes/module.png

601 B

versioncompat/images/ExtensionTypes/plugin.png

538 B

versioncompat/images/ExtensionTypes/specific.png

669 B

versioncompat/images/ExtensionTypes/template.png

542 B

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment