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

Initial import

parents
No related branches found
No related tags found
No related merge requests found
Showing
with 473 additions and 0 deletions
<?php
/**
* @package Joomla.Libraries
* @subpackage Form
*
* @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
*/
defined('_JEXEC') or die;
jimport('joomla.filesystem.folder');
JFormHelper::loadFieldClass('groupedlist');
class JFormFieldCompatFolders extends JFormFieldGroupedList
{
public $type = 'CompatFolders';
protected function getGroups()
{
$groups = array();
foreach ($this->element->children() as $dir) {
if ($dir->getName() != 'folder') continue;
$directory = (string)$dir;
if ($groupLabel = (string) $dir['label']) {
$label = JText::_($groupLabel);
} else {
$label = $directory;
}
if (!JFolder::exists($directory))
$directory = JPATH_ROOT . '/' . $directory;
if (!JFolder::exists($directory)) continue;
// Initialize the group if necessary.
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);
}
}
reset($groups);
return $groups;
}
}
; VM Version Compatibility Display custom field
; Copyright (C) 2014 Open Tools, Reinhold Kainhofer. 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
VMCUSTOM_VERSIONCOMPAT_CONFIG="Configuration"
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
; VM Version Compatibility Display custom field
; Copyright (C) 2014 Open Tools, Reinhold Kainhofer. 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
VMCUSTOM_VERSIONCOMPAT_CONFIG="Configuration"
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
<!DOCTYPE html><title></title>
<?php
/*------------------------------------------------------------------------
# versioncompat - Custom field for Virtuemart
# ------------------------------------------------------------------------
# author Reinhold Kainhofer, OpenTools
# copyright (C) 2014 OpenTools.net, Reinhold Kainhofer. All rights reserved.
#
# Based on the Joocompatibility plugin by DayCounts
# copyright Copyright (C) 2010 Daycounts.com. All Rights Reserved.
#
#
# @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
-------------------------------------------------------------------------*/
defined('_JEXEC') or die( 'Direct Access to ' . basename( __FILE__ ) . ' is not allowed.' ) ;
if (!class_exists('vmCustomPlugin')) require(JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php');
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) {
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 ;
}
/**
* @ 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;
}
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;
}
/**
* 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);
}
function plgVmSetOnTablePluginParamsCustom($name, $id, &$table){
return $this->setOnTablePluginParams($name, $id, $table);
}
function plgVmDeclarePluginParamsCustom($psType,$name,$id, &$data){
return $this->declarePluginParams('custom', $name, $id, $data);
}
/**
* Custom triggers note by Max Milbers
*/
function plgVmOnDisplayEdit($virtuemart_custom_id,&$customPlugin){
return $this->onDisplayEditBECustom($virtuemart_custom_id,$customPlugin);
}
}
// No closing tag
\ No newline at end of file
<?php
defined('_JEXEC') or die('Restricted access');
/**
* Installation script for the plugin
*
* @copyright Copyright (C) 2013-2014 Reinhold Kainhofer, office@open-tools.net
* @license GPL v3+, http://www.gnu.org/copyleft/gpl.html
*/
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
if (!class_exists( 'VmConfig' ))
require(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'config.php');
class plgVmCustomVersionCompatInstallerScript
{
/**
* 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|update|uninstall|discover_install)
* @param JAdapterInstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
// public function postflight($route, JAdapterInstance $adapter);
public function postflight ($type, $parent = null) {
// // For Shopper plugins we need to create the DB table upon installation!
// if(!class_exists( 'vmPlugin' ))
// require JPATH_VM_ADMINISTRATOR.DS.'plugins'.DS.'vmplugin.php';
// if(!class_exists( 'plgVmShopperOrdernumber' ))
// require JPATH_ROOT.DS.'plugins'.DS.'vmshopper'.DS.'ordernumber'.DS.'ordernumber.php';
// $dispatcher = new JDispatcher();
// $config = array('name' => 'ordernumber', 'type' => 'vmshopper');
// $plugin = new plgVmShopperOrdernumber($dispatcher, $config);
// $plugin->plgVmOnStoreInstallPluginTable('shopper');
// $dispatcher->trigger("plgVmOnStoreInstallPluginTable", array('vmshopper'));
}
/**
* 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 = "versioncompat" 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 IF EXISTS `#__virtuemart_shopper_plg_ordernumber`;');
// $db->query();
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<extension version="2.5" type="plugin" group="vmcustom" method="upgrade" >
<name>Version Compatibility Display for VirtueMart</name>
<author>Daycounts &amp; Open Tools, Reinhold Kainhofer</author>
<authorEmail>office@open-tools.net</authorEmail>
<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>
<description>Version compatibility custom field</description>
<files>
<filename plugin="versioncompat">versioncompat.php</filename>
<filename>versioncompat.script.php</filename>
<filename>index.html</filename>
<folder>versioncompat/</folder>
<folder>language</folder>
<folder>elements</folder>
<folder>fields</folder>
</files>
<languages folder="language">
<language tag="en-GB">en-GB/en-GB.plg_vmcustom_versioncompat.ini</language>
<language tag="en-GB">en-GB/en-GB.plg_vmcustom_versioncompat.sys.ini</language>
</languages>
<scriptfile>versioncompat.script.php</scriptfile>
<!-- 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>
</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>
</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>
</param>
</params>
</extension>
\ No newline at end of file
versioncompat/images/Joomla/j15.png

1.38 KiB

versioncompat/images/Joomla/j16.png

1.4 KiB

versioncompat/images/Joomla/j17.png

2.23 KiB

versioncompat/images/Joomla/j25.png

2.44 KiB

versioncompat/images/Joomla/j30.png

2.88 KiB

<html>
<body bgcolor="#FFFFFF">
</body>
</html>
\ No newline at end of file
<?php
/*------------------------------------------------------------------------
# joocompatibility - Custom field for Virtuemart
# ------------------------------------------------------------------------
# author Jeremy Magne
# copyright Copyright (C) 2010 Daycounts.com. All Rights Reserved.
# Websites: http://www.daycounts.com
# Technical Support: http://www.daycounts.com/en/contact/
# @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
-------------------------------------------------------------------------*/
defined('_JEXEC') or die();
// Here the plugin values
//JHTML::_('behavior.tooltip');
?>
<ul class="joocompatibility" style="list-style:none; margin-left:0;">
<?php
foreach ($this->params->selectedOptions as $compat) {
echo '<li style="float:left; margin-left:0; margin-right:10px;">'.JHTML::image(JURI::root() . $this->params->path.$compat, JText::_(basename($compat,'.png'))).'</li>';
}
?>
</ul>
<?php
/*------------------------------------------------------------------------
# joocompatibility - Custom field for Virtuemart
# ------------------------------------------------------------------------
# author Jeremy Magne
# copyright Copyright (C) 2010 Daycounts.com. All Rights Reserved.
# Websites: http://www.daycounts.com
# Technical Support: http://www.daycounts.com/en/contact/
# @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
-------------------------------------------------------------------------*/
defined('_JEXEC') or die();
// Here the plugin values
?>
<?php
echo $this->params->custom_title.'&nbsp;:&nbsp;';
foreach ($this->params->images as $image) {
if (in_array($image,$this->params->searched)) {
$checked = 'checked="checked"';
} else {
$checked = '';
}
?>
<label><input type="checkbox" value="<?php echo $image ?>" name="joocompatibility[]" <?php echo $checked; ?>><?php echo JHTML::image(JURI::root() . $this->params->path.$image, basename($image,'.png')); ?></label>
<?php
}
?>
<br />
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment