Spade
Mini Shell
| Directory:~$ /home/lmsyaran/public_html/joomla4/ |
| [Home] [System Details] [Kill Me] |
associations.php000064400000005706151156170470007773 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_menus
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Association\AssociationExtensionHelper;
/**
* Menu associations helper.
*
* @since 3.7.0
*/
class MenusAssociationsHelper extends AssociationExtensionHelper
{
/**
* The extension name
*
* @var array $extension
*
* @since 3.7.0
*/
protected $extension = 'com_menus';
/**
* Array of item types
*
* @var array $itemTypes
*
* @since 3.7.0
*/
protected $itemTypes = array('item');
/**
* Has the extension association support
*
* @var boolean $associationsSupport
*
* @since 3.7.0
*/
protected $associationsSupport = true;
/**
* Get the associated items for an item
*
* @param string $typeName The item type
* @param int $id The id of item for which we need the
associated items
*
* @return array
*
* @since 3.7.0
*/
public function getAssociations($typeName, $id)
{
$type = $this->getType($typeName);
$context = $this->extension . '.item';
// Get the associations.
$associations = JLanguageAssociations::getAssociations(
$this->extension,
$type['tables']['a'],
$context,
$id,
'id',
'alias',
''
);
return $associations;
}
/**
* Get item information
*
* @param string $typeName The item type
* @param int $id The id of item for which we need the
associated items
*
* @return JTable|null
*
* @since 3.7.0
*/
public function getItem($typeName, $id)
{
if (empty($id))
{
return null;
}
$table = null;
switch ($typeName)
{
case 'item':
$table = JTable::getInstance('menu');
break;
}
if (is_null($table))
{
return null;
}
$table->load($id);
return $table;
}
/**
* Get information about the type
*
* @param string $typeName The item type
*
* @return array Array of item types
*
* @since 3.7.0
*/
public function getType($typeName = '')
{
$fields = $this->getFieldsTemplate();
$tables = array();
$joins = array();
$support = $this->getSupportTemplate();
$title = '';
if (in_array($typeName, $this->itemTypes))
{
switch ($typeName)
{
case 'item':
$fields['ordering'] = 'a.lft';
$fields['level'] = 'a.level';
$fields['catid'] = '';
$fields['state'] = 'a.published';
$fields['created_user_id'] = '';
$fields['menutype'] = 'a.menutype';
$support['state'] = true;
$support['acl'] = true;
$support['checkout'] = true;
$support['level'] = true;
$tables = array(
'a' => '#__menu'
);
$title = 'menu';
break;
}
}
return array(
'fields' => $fields,
'support' => $support,
'tables' => $tables,
'joins' => $joins,
'title' => $title
);
}
}
contact.php000064400000007277151156170470006734 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_contact
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Contact component helper.
*
* @since 1.6
*/
class ContactHelper extends JHelperContent
{
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since 1.6
*/
public static function addSubmenu($vName)
{
JHtmlSidebar::addEntry(
JText::_('COM_CONTACT_SUBMENU_CONTACTS'),
'index.php?option=com_contact&view=contacts',
$vName == 'contacts'
);
JHtmlSidebar::addEntry(
JText::_('COM_CONTACT_SUBMENU_CATEGORIES'),
'index.php?option=com_categories&extension=com_contact',
$vName == 'categories'
);
if (JComponentHelper::isEnabled('com_fields') &&
JComponentHelper::getParams('com_contact')->get('custom_fields_enable',
'1'))
{
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_FIELDS'),
'index.php?option=com_fields&context=com_contact.contact',
$vName == 'fields.fields'
);
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_FIELD_GROUPS'),
'index.php?option=com_fields&view=groups&context=com_contact.contact',
$vName == 'fields.groups'
);
}
}
/**
* Adds Count Items for Category Manager.
*
* @param stdClass[] &$items The category objects
*
* @return stdClass[]
*
* @since 3.5
*/
public static function countItems(&$items)
{
$config = (object) array(
'related_tbl' => 'contact_details',
'state_col' => 'published',
'group_col' => 'catid',
'relation_type' => 'category_or_group',
);
return parent::countRelations($items, $config);
}
/**
* Adds Count Items for Tag Manager.
*
* @param stdClass[] &$items The tag objects
* @param string $extension The name of the active view.
*
* @return stdClass[]
*
* @since 3.6
*/
public static function countTagItems(&$items, $extension)
{
$parts = explode('.', $extension);
$section = count($parts) > 1 ? $parts[1] : null;
$config = (object) array(
'related_tbl' => ($section === 'category' ?
'categories' : 'contact_details'),
'state_col' => 'published',
'group_col' => 'tag_id',
'extension' => $extension,
'relation_type' => 'tag_assigments',
);
return parent::countRelations($items, $config);
}
/**
* Returns a valid section for contacts. If it is not valid then null
* is returned.
*
* @param string $section The section to get the mapping for
* @param object $item optional item object
*
* @return string|null The new section
*
* @since 3.7.0
*/
public static function validateSection($section, $item)
{
if (JFactory::getApplication()->isClient('site') &&
$section == 'contact' && $item instanceof JForm)
{
// The contact form needs to be the mail section
$section = 'mail';
}
if (JFactory::getApplication()->isClient('site') &&
$section == 'category')
{
// The contact form needs to be the mail section
$section = 'contact';
}
if ($section != 'mail' && $section !=
'contact')
{
// We don't know other sections
return null;
}
return $section;
}
/**
* Returns valid contexts
*
* @return array
*
* @since 3.7.0
*/
public static function getContexts()
{
JFactory::getLanguage()->load('com_contact',
JPATH_ADMINISTRATOR);
$contexts = array(
'com_contact.contact' =>
JText::_('COM_CONTACT_FIELDS_CONTEXT_CONTACT'),
'com_contact.mail' =>
JText::_('COM_CONTACT_FIELDS_CONTEXT_MAIL'),
'com_contact.categories' => JText::_('JCATEGORY')
);
return $contexts;
}
}
html/contact.php000064400000007444151156170470007674 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_contact
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
JLoader::register('ContactHelper', JPATH_ADMINISTRATOR .
'/components/com_contact/helpers/contact.php');
/**
* Contact HTML helper class.
*
* @since 1.6
*/
abstract class JHtmlContact
{
/**
* Get the associated language flags
*
* @param integer $contactid The item id to search associations
*
* @return string The language HTML
*
* @throws Exception
*/
public static function association($contactid)
{
// Defaults
$html = '';
// Get the associations
if ($associations =
JLanguageAssociations::getAssociations('com_contact',
'#__contact_details', 'com_contact.item', $contactid))
{
foreach ($associations as $tag => $associated)
{
$associations[$tag] = (int) $associated->id;
}
// Get the associated contact items
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('c.id, c.name as title')
->select('l.sef as lang_sef, lang_code')
->from('#__contact_details as c')
->select('cat.title as category_title')
->join('LEFT', '#__categories as cat ON
cat.id=c.catid')
->where('c.id IN (' . implode(',',
array_values($associations)) . ')')
->where('c.id != ' . $contactid)
->join('LEFT', '#__languages as l ON
c.language=l.lang_code')
->select('l.image')
->select('l.title as language_title');
$db->setQuery($query);
try
{
$items = $db->loadObjectList('id');
}
catch (RuntimeException $e)
{
throw new Exception($e->getMessage(), 500, $e);
}
if ($items)
{
foreach ($items as &$item)
{
$text = strtoupper($item->lang_sef);
$url =
JRoute::_('index.php?option=com_contact&task=contact.edit&id='
. (int) $item->id);
$tooltip = htmlspecialchars($item->title, ENT_QUOTES,
'UTF-8') . '<br />' .
JText::sprintf('JCATEGORY_SPRINTF', $item->category_title);
$classes = 'hasPopover label label-association label-' .
$item->lang_sef;
$item->link = '<a href="' . $url . '"
title="' . $item->language_title . '"
class="' . $classes
. '" data-content="' . $tooltip . '"
data-placement="top">'
. $text . '</a>';
}
}
JHtml::_('bootstrap.popover');
$html = JLayoutHelper::render('joomla.content.associations',
$items);
}
return $html;
}
/**
* Show the featured/not-featured icon.
*
* @param integer $value The featured value.
* @param integer $i Id of the item.
* @param boolean $canChange Whether the value can be changed or not.
*
* @return string The anchor tag to toggle featured/unfeatured contacts.
*
* @since 1.6
*/
public static function featured($value = 0, $i = 0, $canChange = true)
{
// Array of image, task, title, action
$states = array(
0 => array('unfeatured', 'contacts.featured',
'COM_CONTACT_UNFEATURED', 'JGLOBAL_TOGGLE_FEATURED'),
1 => array('featured', 'contacts.unfeatured',
'JFEATURED', 'JGLOBAL_TOGGLE_FEATURED'),
);
$state = ArrayHelper::getValue($states, (int) $value, $states[1]);
$icon = $state[0];
if ($canChange)
{
$html = '<a href="#" onclick="return
listItemTask(\'cb' . $i . '\',\'' . $state[1]
. '\')" class="btn btn-micro hasTooltip'
. ($value == 1 ? ' active' : '') . '"
title="' . JHtml::_('tooltipText', $state[3])
. '"><span class="icon-' . $icon .
'" aria-hidden="true"></span></a>';
}
else
{
$html = '<a class="btn btn-micro hasTooltip disabled'
. ($value == 1 ? ' active' : '') . '"
title="'
. JHtml::_('tooltipText', $state[2]) .
'"><span class="icon-' . $icon . '"
aria-hidden="true"></span></a>';
}
return $html;
}
}
content.php000064400000010350151156617270006741 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_content
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Content component helper.
*
* @since 1.6
*/
class ContentHelper extends JHelperContent
{
public static $extension = 'com_content';
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since 1.6
*/
public static function addSubmenu($vName)
{
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_ARTICLES'),
'index.php?option=com_content&view=articles',
$vName == 'articles'
);
JHtmlSidebar::addEntry(
JText::_('COM_CONTENT_SUBMENU_CATEGORIES'),
'index.php?option=com_categories&extension=com_content',
$vName == 'categories'
);
JHtmlSidebar::addEntry(
JText::_('COM_CONTENT_SUBMENU_FEATURED'),
'index.php?option=com_content&view=featured',
$vName == 'featured'
);
if (JComponentHelper::isEnabled('com_fields') &&
JComponentHelper::getParams('com_content')->get('custom_fields_enable',
'1'))
{
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_FIELDS'),
'index.php?option=com_fields&context=com_content.article',
$vName == 'fields.fields'
);
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_FIELD_GROUPS'),
'index.php?option=com_fields&view=groups&context=com_content.article',
$vName == 'fields.groups'
);
}
}
/**
* Applies the content tag filters to arbitrary text as per settings for
current user group
*
* @param text $text The string to filter
*
* @return string The filtered string
*
* @deprecated 4.0 Use JComponentHelper::filterText() instead.
*/
public static function filterText($text)
{
try
{
JLog::add(
sprintf('%s() is deprecated. Use JComponentHelper::filterText()
instead', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
return JComponentHelper::filterText($text);
}
/**
* Adds Count Items for Category Manager.
*
* @param stdClass[] &$items The category objects
*
* @return stdClass[]
*
* @since 3.5
*/
public static function countItems(&$items)
{
$config = (object) array(
'related_tbl' => 'content',
'state_col' => 'state',
'group_col' => 'catid',
'relation_type' => 'category_or_group',
);
return parent::countRelations($items, $config);
}
/**
* Adds Count Items for Tag Manager.
*
* @param stdClass[] &$items The tag objects
* @param string $extension The name of the active view.
*
* @return stdClass[]
*
* @since 3.6
*/
public static function countTagItems(&$items, $extension)
{
$parts = explode('.', $extension);
$section = count($parts) > 1 ? $parts[1] : null;
$config = (object) array(
'related_tbl' => ($section === 'category' ?
'categories' : 'content'),
'state_col' => ($section === 'category' ?
'published' : 'state'),
'group_col' => 'tag_id',
'extension' => $extension,
'relation_type' => 'tag_assigments',
);
return parent::countRelations($items, $config);
}
/**
* Returns a valid section for articles. If it is not valid then null
* is returned.
*
* @param string $section The section to get the mapping for
*
* @return string|null The new section
*
* @since 3.7.0
*/
public static function validateSection($section)
{
if (JFactory::getApplication()->isClient('site'))
{
// On the front end we need to map some sections
switch ($section)
{
// Editing an article
case 'form':
// Category list view
case 'featured':
case 'category':
$section = 'article';
}
}
if ($section != 'article')
{
// We don't know other sections
return null;
}
return $section;
}
/**
* Returns valid contexts
*
* @return array
*
* @since 3.7.0
*/
public static function getContexts()
{
JFactory::getLanguage()->load('com_content',
JPATH_ADMINISTRATOR);
$contexts = array(
'com_content.article' =>
JText::_('COM_CONTENT'),
'com_content.categories' => JText::_('JCATEGORY')
);
return $contexts;
}
}
html/contentadministrator.php000064400000007377151156617270012525
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_content
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
JLoader::register('ContentHelper', JPATH_ADMINISTRATOR .
'/components/com_content/helpers/content.php');
/**
* Content HTML helper
*
* @since 3.0
*/
abstract class JHtmlContentAdministrator
{
/**
* Render the list of associated items
*
* @param integer $articleid The article item id
*
* @return string The language HTML
*
* @throws Exception
*/
public static function association($articleid)
{
// Defaults
$html = '';
// Get the associations
if ($associations =
JLanguageAssociations::getAssociations('com_content',
'#__content', 'com_content.item', $articleid))
{
foreach ($associations as $tag => $associated)
{
$associations[$tag] = (int) $associated->id;
}
// Get the associated menu items
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('c.*')
->select('l.sef as lang_sef')
->select('l.lang_code')
->from('#__content as c')
->select('cat.title as category_title')
->join('LEFT', '#__categories as cat ON
cat.id=c.catid')
->where('c.id IN (' . implode(',',
array_values($associations)) . ')')
->where('c.id != ' . $articleid)
->join('LEFT', '#__languages as l ON
c.language=l.lang_code')
->select('l.image')
->select('l.title as language_title');
$db->setQuery($query);
try
{
$items = $db->loadObjectList('id');
}
catch (RuntimeException $e)
{
throw new Exception($e->getMessage(), 500, $e);
}
if ($items)
{
foreach ($items as &$item)
{
$text = $item->lang_sef ? strtoupper($item->lang_sef) :
'XX';
$url =
JRoute::_('index.php?option=com_content&task=article.edit&id='
. (int) $item->id);
$tooltip = htmlspecialchars($item->title, ENT_QUOTES,
'UTF-8') . '<br />' .
JText::sprintf('JCATEGORY_SPRINTF', $item->category_title);
$classes = 'hasPopover label label-association label-' .
$item->lang_sef;
$item->link = '<a href="' . $url . '"
title="' . $item->language_title . '"
class="' . $classes
. '" data-content="' . $tooltip . '"
data-placement="top">'
. $text . '</a>';
}
}
JHtml::_('bootstrap.popover');
$html = JLayoutHelper::render('joomla.content.associations',
$items);
}
return $html;
}
/**
* Show the feature/unfeature links
*
* @param integer $value The state value
* @param integer $i Row number
* @param boolean $canChange Is user allowed to change?
*
* @return string HTML code
*/
public static function featured($value = 0, $i = 0, $canChange = true)
{
JHtml::_('bootstrap.tooltip');
// Array of image, task, title, action
$states = array(
0 => array('unfeatured', 'articles.featured',
'COM_CONTENT_UNFEATURED', 'JGLOBAL_TOGGLE_FEATURED'),
1 => array('featured', 'articles.unfeatured',
'COM_CONTENT_FEATURED', 'JGLOBAL_TOGGLE_FEATURED'),
);
$state = ArrayHelper::getValue($states, (int) $value, $states[1]);
$icon = $state[0];
if ($canChange)
{
$html = '<a href="#" onclick="return
listItemTask(\'cb' . $i . '\',\'' . $state[1]
. '\')" class="btn btn-micro hasTooltip'
. ($value == 1 ? ' active' : '') . '"
title="' . JHtml::_('tooltipText', $state[3])
. '"><span class="icon-' . $icon .
'" aria-hidden="true"></span></a>';
}
else
{
$html = '<a class="btn btn-micro hasTooltip disabled'
. ($value == 1 ? ' active' : '') . '"
title="'
. JHtml::_('tooltipText', $state[2]) .
'"><span class="icon-' . $icon . '"
aria-hidden="true"></span></a>';
}
return $html;
}
}
banners.php000064400000011155151156665530006725 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_banners
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Banners component helper.
*
* @since 1.6
*/
class BannersHelper extends JHelperContent
{
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since 1.6
*/
public static function addSubmenu($vName)
{
JHtmlSidebar::addEntry(
JText::_('COM_BANNERS_SUBMENU_BANNERS'),
'index.php?option=com_banners&view=banners',
$vName == 'banners'
);
JHtmlSidebar::addEntry(
JText::_('COM_BANNERS_SUBMENU_CATEGORIES'),
'index.php?option=com_categories&extension=com_banners',
$vName == 'categories'
);
JHtmlSidebar::addEntry(
JText::_('COM_BANNERS_SUBMENU_CLIENTS'),
'index.php?option=com_banners&view=clients',
$vName == 'clients'
);
JHtmlSidebar::addEntry(
JText::_('COM_BANNERS_SUBMENU_TRACKS'),
'index.php?option=com_banners&view=tracks',
$vName == 'tracks'
);
}
/**
* Update / reset the banners
*
* @return boolean
*
* @since 1.6
*/
public static function updateReset()
{
$db = JFactory::getDbo();
$nullDate = $db->getNullDate();
$query = $db->getQuery(true)
->select('*')
->from('#__banners')
->where($db->quote(JFactory::getDate()) . ' >= ' .
$db->quote('reset'))
->where($db->quoteName('reset') . ' != ' .
$db->quote($nullDate) . ' AND ' .
$db->quoteName('reset') . '!= NULL')
->where(
'(' . $db->quoteName('checked_out') . ' = 0
OR ' . $db->quoteName('checked_out') . ' = '
. (int) $db->quote(JFactory::getUser()->id) . ')'
);
$db->setQuery($query);
try
{
$rows = $db->loadObjectList();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
return false;
}
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR .
'/tables');
foreach ($rows as $row)
{
$purchaseType = $row->purchase_type;
if ($purchaseType < 0 && $row->cid)
{
/** @var BannersTableClient $client */
$client = JTable::getInstance('Client',
'BannersTable');
$client->load($row->cid);
$purchaseType = $client->purchase_type;
}
if ($purchaseType < 0)
{
$params = JComponentHelper::getParams('com_banners');
$purchaseType = $params->get('purchase_type');
}
switch ($purchaseType)
{
case 1:
$reset = $nullDate;
break;
case 2:
$date = JFactory::getDate('+1 year ' .
date('Y-m-d'));
$reset = $db->quote($date->toSql());
break;
case 3:
$date = JFactory::getDate('+1 month ' .
date('Y-m-d'));
$reset = $db->quote($date->toSql());
break;
case 4:
$date = JFactory::getDate('+7 day ' .
date('Y-m-d'));
$reset = $db->quote($date->toSql());
break;
case 5:
$date = JFactory::getDate('+1 day ' .
date('Y-m-d'));
$reset = $db->quote($date->toSql());
break;
}
// Update the row ordering field.
$query->clear()
->update($db->quoteName('#__banners'))
->set($db->quoteName('reset') . ' = ' .
$db->quote($reset))
->set($db->quoteName('impmade') . ' = ' .
$db->quote(0))
->set($db->quoteName('clicks') . ' = ' .
$db->quote(0))
->where($db->quoteName('id') . ' = ' .
$db->quote($row->id));
$db->setQuery($query);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $db->getMessage());
return false;
}
}
return true;
}
/**
* Get client list in text/value format for a select field
*
* @return array
*/
public static function getClientOptions()
{
$options = array();
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('id AS value, name AS text')
->from('#__banner_clients AS a')
->where('a.state = 1')
->order('a.name');
// Get the options.
$db->setQuery($query);
try
{
$options = $db->loadObjectList();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
}
array_unshift($options, JHtml::_('select.option',
'0', JText::_('COM_BANNERS_NO_CLIENT')));
return $options;
}
/**
* Adds Count Items for Category Manager.
*
* @param stdClass[] &$items The category objects
*
* @return stdClass[]
*
* @since 3.5
*/
public static function countItems(&$items)
{
$config = (object) array(
'related_tbl' => 'banners',
'state_col' => 'state',
'group_col' => 'catid',
'relation_type' => 'category_or_group',
);
return parent::countRelations($items, $config);
}
}
html/banner.php000064400000005350151156665530007506 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_banners
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Banner HTML class.
*
* @since 2.5
*/
abstract class JHtmlBanner
{
/**
* Display a batch widget for the client selector.
*
* @return string The necessary HTML for the widget.
*
* @since 2.5
*/
public static function clients()
{
JHtml::_('bootstrap.tooltip');
// Create the batch selector to change the client on a selection list.
return implode(
"\n",
array(
'<label id="batch-client-lbl"
for="batch-client" class="hasTooltip"
title="'
. JHtml::_('tooltipText',
'COM_BANNERS_BATCH_CLIENT_LABEL',
'COM_BANNERS_BATCH_CLIENT_LABEL_DESC')
. '">',
JText::_('COM_BANNERS_BATCH_CLIENT_LABEL'),
'</label>',
'<select name="batch[client_id]"
id="batch-client-id">',
'<option value="">' .
JText::_('COM_BANNERS_BATCH_CLIENT_NOCHANGE') .
'</option>',
'<option value="0">' .
JText::_('COM_BANNERS_NO_CLIENT') . '</option>',
JHtml::_('select.options', static::clientlist(),
'value', 'text'),
'</select>'
)
);
}
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 1.6
*/
public static function clientlist()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('id As value, name As text')
->from('#__banner_clients AS a')
->order('a.name');
// Get the options.
$db->setQuery($query);
try
{
$options = $db->loadObjectList();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
}
return $options;
}
/**
* Returns a pinned state on a grid
*
* @param integer $value The state value.
* @param integer $i The row index
* @param boolean $enabled An optional setting for access control on
the action.
* @param string $checkbox An optional prefix for checkboxes.
*
* @return string The Html code
*
* @see JHtmlJGrid::state
* @since 2.5.5
*/
public static function pinned($value, $i, $enabled = true, $checkbox =
'cb')
{
$states = array(
1 => array(
'sticky_unpublish',
'COM_BANNERS_BANNERS_PINNED',
'COM_BANNERS_BANNERS_HTML_PIN_BANNER',
'COM_BANNERS_BANNERS_PINNED',
true,
'publish',
'publish'
),
0 => array(
'sticky_publish',
'COM_BANNERS_BANNERS_UNPINNED',
'COM_BANNERS_BANNERS_HTML_UNPIN_BANNER',
'COM_BANNERS_BANNERS_UNPINNED',
true,
'unpublish',
'unpublish'
),
);
return JHtml::_('jgrid.state', $states, $value, $i,
'banners.', $enabled, true, $checkbox);
}
}
finder.php000064400000004520151156756060006541 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Helper class for Finder.
*
* @since 2.5
*/
class FinderHelper
{
/**
* The extension name.
*
* @var string
* @since 2.5
*/
public static $extension = 'com_finder';
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since 2.5
*/
public static function addSubmenu($vName)
{
JHtmlSidebar::addEntry(
JText::_('COM_FINDER_SUBMENU_INDEX'),
'index.php?option=com_finder&view=index',
$vName === 'index'
);
JHtmlSidebar::addEntry(
JText::_('COM_FINDER_SUBMENU_MAPS'),
'index.php?option=com_finder&view=maps',
$vName === 'maps'
);
JHtmlSidebar::addEntry(
JText::_('COM_FINDER_SUBMENU_FILTERS'),
'index.php?option=com_finder&view=filters',
$vName === 'filters'
);
}
/**
* Gets the finder system plugin extension id.
*
* @return integer The finder system plugin extension id.
*
* @since 3.6.0
*/
public static function getFinderPluginId()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('extension_id'))
->from($db->quoteName('#__extensions'))
->where($db->quoteName('folder') . ' = ' .
$db->quote('content'))
->where($db->quoteName('element') . ' = ' .
$db->quote('finder'));
$db->setQuery($query);
try
{
$result = (int) $db->loadResult();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
}
return $result;
}
/**
* Gets a list of the actions that can be performed.
*
* @return JObject A JObject containing the allowed actions.
*
* @since 2.5
* @deprecated 3.2 Use JHelperContent::getActions() instead
*/
public static function getActions()
{
// Log usage of deprecated function
try
{
JLog::add(
sprintf('%s() is deprecated. Use JHelperContent::getActions() with
new arguments order instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
// Get list of actions
return JHelperContent::getActions('com_finder');
}
}
html/finder.php000064400000006242151156756060007510 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('FinderHelperLanguage', JPATH_ADMINISTRATOR .
'/components/com_finder/helpers/language.php');
use Joomla\Utilities\ArrayHelper;
/**
* HTML behavior class for Finder.
*
* @since 2.5
*/
abstract class JHtmlFinder
{
/**
* Creates a list of types to filter on.
*
* @return array An array containing the types that can be selected.
*
* @since 2.5
*/
public static function typeslist()
{
// Load the finder types.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('DISTINCT t.title AS text, t.id AS value')
->from($db->quoteName('#__finder_types') . ' AS
t')
->join('LEFT',
$db->quoteName('#__finder_links') . ' AS l ON l.type_id =
t.id')
->order('t.title ASC');
$db->setQuery($query);
try
{
$rows = $db->loadObjectList();
}
catch (RuntimeException $e)
{
return array();
}
// Compile the options.
$options = array();
$lang = JFactory::getLanguage();
foreach ($rows as $row)
{
$key =
$lang->hasKey(FinderHelperLanguage::branchPlural($row->text)) ?
FinderHelperLanguage::branchPlural($row->text) : $row->text;
$options[] = JHtml::_('select.option', $row->value,
JText::sprintf('COM_FINDER_ITEM_X_ONLY', JText::_($key)));
}
return $options;
}
/**
* Creates a list of maps.
*
* @return array An array containing the maps that can be selected.
*
* @since 2.5
*/
public static function mapslist()
{
// Load the finder types.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('title', 'text'))
->select($db->quoteName('id', 'value'))
->from($db->quoteName('#__finder_taxonomy'))
->where($db->quoteName('parent_id') . ' = 1');
$db->setQuery($query);
try
{
$branches = $db->loadObjectList();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $db->getMessage());
}
// Translate.
$lang = JFactory::getLanguage();
foreach ($branches as $branch)
{
$key = FinderHelperLanguage::branchPlural($branch->text);
$branch->translatedText = $lang->hasKey($key) ? JText::_($key) :
$branch->text;
}
// Order by title.
$branches = ArrayHelper::sortObjects($branches,
'translatedText', 1, true, true);
// Compile the options.
$options = array();
$options[] = JHtml::_('select.option', '',
JText::_('COM_FINDER_MAPS_SELECT_BRANCH'));
// Convert the values to options.
foreach ($branches as $branch)
{
$options[] = JHtml::_('select.option', $branch->value,
$branch->translatedText);
}
return $options;
}
/**
* Creates a list of published states.
*
* @return array An array containing the states that can be selected.
*
* @since 2.5
*/
public static function statelist()
{
return array(
JHtml::_('select.option', '1',
JText::sprintf('COM_FINDER_ITEM_X_ONLY',
JText::_('JPUBLISHED'))),
JHtml::_('select.option', '0',
JText::sprintf('COM_FINDER_ITEM_X_ONLY',
JText::_('JUNPUBLISHED')))
);
}
}
indexer/adapter.php000064400000052707151156756060010362 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
JLoader::register('FinderIndexer', __DIR__ .
'/indexer.php');
JLoader::register('FinderIndexerHelper', __DIR__ .
'/helper.php');
JLoader::register('FinderIndexerResult', __DIR__ .
'/result.php');
JLoader::register('FinderIndexerTaxonomy', __DIR__ .
'/taxonomy.php');
/**
* Prototype adapter class for the Finder indexer package.
*
* @since 2.5
*/
abstract class FinderIndexerAdapter extends JPlugin
{
/**
* The context is somewhat arbitrary but it must be unique or there will
be
* conflicts when managing plugin/indexer state. A good best practice is
to
* use the plugin name suffix as the context. For example, if the plugin
is
* named 'plgFinderContent', the context could be
'Content'.
*
* @var string
* @since 2.5
*/
protected $context;
/**
* The extension name.
*
* @var string
* @since 2.5
*/
protected $extension;
/**
* The sublayout to use when rendering the results.
*
* @var string
* @since 2.5
*/
protected $layout;
/**
* The mime type of the content the adapter indexes.
*
* @var string
* @since 2.5
*/
protected $mime;
/**
* The access level of an item before save.
*
* @var integer
* @since 2.5
*/
protected $old_access;
/**
* The access level of a category before save.
*
* @var integer
* @since 2.5
*/
protected $old_cataccess;
/**
* The type of content the adapter indexes.
*
* @var string
* @since 2.5
*/
protected $type_title;
/**
* The type id of the content.
*
* @var integer
* @since 2.5
*/
protected $type_id;
/**
* The database object.
*
* @var object
* @since 2.5
*/
protected $db;
/**
* The table name.
*
* @var string
* @since 2.5
*/
protected $table;
/**
* The indexer object.
*
* @var FinderIndexer
* @since 3.0
*/
protected $indexer;
/**
* The field the published state is stored in.
*
* @var string
* @since 2.5
*/
protected $state_field = 'state';
/**
* Method to instantiate the indexer adapter.
*
* @param object $subject The object to observe.
* @param array $config An array that holds the plugin
configuration.
*
* @since 2.5
*/
public function __construct(&$subject, $config)
{
// Get the database object.
$this->db = JFactory::getDbo();
// Call the parent constructor.
parent::__construct($subject, $config);
// Get the type id.
$this->type_id = $this->getTypeId();
// Add the content type if it doesn't exist and is set.
if (empty($this->type_id) && !empty($this->type_title))
{
$this->type_id =
FinderIndexerHelper::addContentType($this->type_title, $this->mime);
}
// Check for a layout override.
if ($this->params->get('layout'))
{
$this->layout = $this->params->get('layout');
}
// Get the indexer object
$this->indexer = FinderIndexer::getInstance();
}
/**
* Method to get the adapter state and push it into the indexer.
*
* @return void
*
* @since 2.5
* @throws Exception on error.
*/
public function onStartIndex()
{
// Get the indexer state.
$iState = FinderIndexer::getState();
// Get the number of content items.
$total = (int) $this->getContentCount();
// Add the content count to the total number of items.
$iState->totalItems += $total;
// Populate the indexer state information for the adapter.
$iState->pluginState[$this->context]['total'] = $total;
$iState->pluginState[$this->context]['offset'] = 0;
// Set the indexer state.
FinderIndexer::setState($iState);
}
/**
* Method to prepare for the indexer to be run. This method will often
* be used to include dependencies and things of that nature.
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on error.
*/
public function onBeforeIndex()
{
// Get the indexer and adapter state.
$iState = FinderIndexer::getState();
$aState = $iState->pluginState[$this->context];
// Check the progress of the indexer and the adapter.
if ($iState->batchOffset == $iState->batchSize ||
$aState['offset'] == $aState['total'])
{
return true;
}
// Run the setup method.
return $this->setup();
}
/**
* Method to index a batch of content items. This method can be called by
* the indexer many times throughout the indexing process depending on how
* much content is available for indexing. It is important to track the
* progress correctly so we can display it to the user.
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on error.
*/
public function onBuildIndex()
{
// Get the indexer and adapter state.
$iState = FinderIndexer::getState();
$aState = $iState->pluginState[$this->context];
// Check the progress of the indexer and the adapter.
if ($iState->batchOffset == $iState->batchSize ||
$aState['offset'] == $aState['total'])
{
return true;
}
// Get the batch offset and size.
$offset = (int) $aState['offset'];
$limit = (int) ($iState->batchSize - $iState->batchOffset);
// Get the content items to index.
$items = $this->getItems($offset, $limit);
// Iterate through the items and index them.
for ($i = 0, $n = count($items); $i < $n; $i++)
{
// Index the item.
$this->index($items[$i]);
// Adjust the offsets.
$offset++;
$iState->batchOffset++;
$iState->totalItems--;
}
// Update the indexer state.
$aState['offset'] = $offset;
$iState->pluginState[$this->context] = $aState;
FinderIndexer::setState($iState);
return true;
}
/**
* Method to change the value of a content item's property in the
links
* table. This is used to synchronize published and access states that
* are changed when not editing an item directly.
*
* @param string $id The ID of the item to change.
* @param string $property The property that is being changed.
* @param integer $value The new value of that property.
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
protected function change($id, $property, $value)
{
// Check for a property we know how to handle.
if ($property !== 'state' && $property !==
'access')
{
return true;
}
// Get the URL for the content id.
$item = $this->db->quote($this->getUrl($id, $this->extension,
$this->layout));
// Update the content items.
$query = $this->db->getQuery(true)
->update($this->db->quoteName('#__finder_links'))
->set($this->db->quoteName($property) . ' = ' . (int)
$value)
->where($this->db->quoteName('url') . ' = '
. $item);
$this->db->setQuery($query);
$this->db->execute();
return true;
}
/**
* Method to index an item.
*
* @param FinderIndexerResult $item The item to index as a
FinderIndexerResult object.
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
abstract protected function index(FinderIndexerResult $item);
/**
* Method to reindex an item.
*
* @param integer $id The ID of the item to reindex.
*
* @return void
*
* @since 2.5
* @throws Exception on database error.
*/
protected function reindex($id)
{
// Run the setup method.
$this->setup();
// Remove the old item.
$this->remove($id);
// Get the item.
$item = $this->getItem($id);
// Index the item.
$this->index($item);
}
/**
* Method to remove an item from the index.
*
* @param string $id The ID of the item to remove.
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
protected function remove($id)
{
// Get the item's URL
$url = $this->db->quote($this->getUrl($id, $this->extension,
$this->layout));
// Get the link ids for the content items.
$query = $this->db->getQuery(true)
->select($this->db->quoteName('link_id'))
->from($this->db->quoteName('#__finder_links'))
->where($this->db->quoteName('url') . ' = '
. $url);
$this->db->setQuery($query);
$items = $this->db->loadColumn();
// Check the items.
if (empty($items))
{
return true;
}
// Remove the items.
foreach ($items as $item)
{
$this->indexer->remove($item);
}
return true;
}
/**
* Method to setup the adapter before indexing.
*
* @return boolean True on success, false on failure.
*
* @since 2.5
* @throws Exception on database error.
*/
abstract protected function setup();
/**
* Method to update index data on category access level changes
*
* @param JTable $row A JTable object
*
* @return void
*
* @since 2.5
*/
protected function categoryAccessChange($row)
{
$query = clone $this->getStateQuery();
$query->where('c.id = ' . (int) $row->id);
// Get the access level.
$this->db->setQuery($query);
$items = $this->db->loadObjectList();
// Adjust the access level for each item within the category.
foreach ($items as $item)
{
// Set the access level.
$temp = max($item->access, $row->access);
// Update the item.
$this->change((int) $item->id, 'access', $temp);
// Reindex the item
$this->reindex($row->id);
}
}
/**
* Method to update index data on category access level changes
*
* @param array $pks A list of primary key ids of the content that
has changed state.
* @param integer $value The value of the state that the content has
been changed to.
*
* @return void
*
* @since 2.5
*/
protected function categoryStateChange($pks, $value)
{
/*
* The item's published state is tied to the category
* published state so we need to look up all published states
* before we change anything.
*/
foreach ($pks as $pk)
{
$query = clone $this->getStateQuery();
$query->where('c.id = ' . (int) $pk);
// Get the published states.
$this->db->setQuery($query);
$items = $this->db->loadObjectList();
// Adjust the state for each item within the category.
foreach ($items as $item)
{
// Translate the state.
$temp = $this->translateState($item->state, $value);
// Update the item.
$this->change($item->id, 'state', $temp);
// Reindex the item
$this->reindex($item->id);
}
}
}
/**
* Method to check the existing access level for categories
*
* @param JTable $row A JTable object
*
* @return void
*
* @since 2.5
*/
protected function checkCategoryAccess($row)
{
$query = $this->db->getQuery(true)
->select($this->db->quoteName('access'))
->from($this->db->quoteName('#__categories'))
->where($this->db->quoteName('id') . ' = '
. (int) $row->id);
$this->db->setQuery($query);
// Store the access level to determine if it changes
$this->old_cataccess = $this->db->loadResult();
}
/**
* Method to check the existing access level for items
*
* @param JTable $row A JTable object
*
* @return void
*
* @since 2.5
*/
protected function checkItemAccess($row)
{
$query = $this->db->getQuery(true)
->select($this->db->quoteName('access'))
->from($this->db->quoteName($this->table))
->where($this->db->quoteName('id') . ' = '
. (int) $row->id);
$this->db->setQuery($query);
// Store the access level to determine if it changes
$this->old_access = $this->db->loadResult();
}
/**
* Method to get the number of content items available to index.
*
* @return integer The number of content items available to index.
*
* @since 2.5
* @throws Exception on database error.
*/
protected function getContentCount()
{
$return = 0;
// Get the list query.
$query = $this->getListQuery();
// Check if the query is valid.
if (empty($query))
{
return $return;
}
// Tweak the SQL query to make the total lookup faster.
if ($query instanceof JDatabaseQuery)
{
$query = clone $query;
$query->clear('select')
->select('COUNT(*)')
->clear('order');
}
// Get the total number of content items to index.
$this->db->setQuery($query);
return (int) $this->db->loadResult();
}
/**
* Method to get a content item to index.
*
* @param integer $id The id of the content item.
*
* @return FinderIndexerResult A FinderIndexerResult object.
*
* @since 2.5
* @throws Exception on database error.
*/
protected function getItem($id)
{
// Get the list query and add the extra WHERE clause.
$query = $this->getListQuery();
$query->where('a.id = ' . (int) $id);
// Get the item to index.
$this->db->setQuery($query);
$row = $this->db->loadAssoc();
// Convert the item to a result object.
$item = ArrayHelper::toObject((array) $row,
'FinderIndexerResult');
// Set the item type.
$item->type_id = $this->type_id;
// Set the item layout.
$item->layout = $this->layout;
return $item;
}
/**
* Method to get a list of content items to index.
*
* @param integer $offset The list offset.
* @param integer $limit The list limit.
* @param JDatabaseQuery $query A JDatabaseQuery object. [optional]
*
* @return array An array of FinderIndexerResult objects.
*
* @since 2.5
* @throws Exception on database error.
*/
protected function getItems($offset, $limit, $query = null)
{
$items = array();
// Get the content items to index.
$this->db->setQuery($this->getListQuery($query), $offset,
$limit);
$rows = $this->db->loadAssocList();
// Convert the items to result objects.
foreach ($rows as $row)
{
// Convert the item to a result object.
$item = ArrayHelper::toObject((array) $row,
'FinderIndexerResult');
// Set the item type.
$item->type_id = $this->type_id;
// Set the mime type.
$item->mime = $this->mime;
// Set the item layout.
$item->layout = $this->layout;
// Set the extension if present
if (isset($row->extension))
{
$item->extension = $row->extension;
}
// Add the item to the stack.
$items[] = $item;
}
return $items;
}
/**
* Method to get the SQL query used to retrieve the list of content items.
*
* @param mixed $query A JDatabaseQuery object. [optional]
*
* @return JDatabaseQuery A database object.
*
* @since 2.5
*/
protected function getListQuery($query = null)
{
// Check if we can use the supplied SQL query.
return $query instanceof JDatabaseQuery ? $query :
$this->db->getQuery(true);
}
/**
* Method to get the plugin type
*
* @param integer $id The plugin ID
*
* @return string The plugin type
*
* @since 2.5
*/
protected function getPluginType($id)
{
// Prepare the query
$query = $this->db->getQuery(true)
->select($this->db->quoteName('element'))
->from($this->db->quoteName('#__extensions'))
->where($this->db->quoteName('extension_id') . '
= ' . (int) $id);
$this->db->setQuery($query);
return $this->db->loadResult();
}
/**
* Method to get a SQL query to load the published and access states for
* an article and category.
*
* @return JDatabaseQuery A database object.
*
* @since 2.5
*/
protected function getStateQuery()
{
$query = $this->db->getQuery(true);
// Item ID
$query->select('a.id');
// Item and category published state
$query->select('a.' . $this->state_field . ' AS
state, c.published AS cat_state');
// Item and category access levels
$query->select('a.access, c.access AS cat_access')
->from($this->table . ' AS a')
->join('LEFT', '#__categories AS c ON c.id =
a.catid');
return $query;
}
/**
* Method to get the query clause for getting items to update by time.
*
* @param string $time The modified timestamp.
*
* @return JDatabaseQuery A database object.
*
* @since 2.5
*/
protected function getUpdateQueryByTime($time)
{
// Build an SQL query based on the modified time.
$query = $this->db->getQuery(true)
->where('a.modified >= ' .
$this->db->quote($time));
return $query;
}
/**
* Method to get the query clause for getting items to update by id.
*
* @param array $ids The ids to load.
*
* @return JDatabaseQuery A database object.
*
* @since 2.5
*/
protected function getUpdateQueryByIds($ids)
{
// Build an SQL query based on the item ids.
$query = $this->db->getQuery(true)
->where('a.id IN(' . implode(',', $ids) .
')');
return $query;
}
/**
* Method to get the type id for the adapter content.
*
* @return integer The numeric type id for the content.
*
* @since 2.5
* @throws Exception on database error.
*/
protected function getTypeId()
{
// Get the type id from the database.
$query = $this->db->getQuery(true)
->select($this->db->quoteName('id'))
->from($this->db->quoteName('#__finder_types'))
->where($this->db->quoteName('title') . ' =
' . $this->db->quote($this->type_title));
$this->db->setQuery($query);
return (int) $this->db->loadResult();
}
/**
* Method to get the URL for the item. The URL is how we look up the link
* in the Finder index.
*
* @param integer $id The id of the item.
* @param string $extension The extension the category is in.
* @param string $view The view for the URL.
*
* @return string The URL of the item.
*
* @since 2.5
*/
protected function getUrl($id, $extension, $view)
{
return 'index.php?option=' . $extension .
'&view=' . $view . '&id=' . $id;
}
/**
* Method to get the page title of any menu item that is linked to the
* content item, if it exists and is set.
*
* @param string $url The URL of the item.
*
* @return mixed The title on success, null if not found.
*
* @since 2.5
* @throws Exception on database error.
*/
protected function getItemMenuTitle($url)
{
$return = null;
// Set variables
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
// Build a query to get the menu params.
$query = $this->db->getQuery(true)
->select($this->db->quoteName('params'))
->from($this->db->quoteName('#__menu'))
->where($this->db->quoteName('link') . ' =
' . $this->db->quote($url))
->where($this->db->quoteName('published') . ' =
1')
->where($this->db->quoteName('access') . ' IN
(' . $groups . ')');
// Get the menu params from the database.
$this->db->setQuery($query);
$params = $this->db->loadResult();
// Check the results.
if (empty($params))
{
return $return;
}
// Instantiate the params.
$params = json_decode($params);
// Get the page title if it is set.
if (isset($params->page_title) && $params->page_title)
{
$return = $params->page_title;
}
return $return;
}
/**
* Method to update index data on access level changes
*
* @param JTable $row A JTable object
*
* @return void
*
* @since 2.5
*/
protected function itemAccessChange($row)
{
$query = clone $this->getStateQuery();
$query->where('a.id = ' . (int) $row->id);
// Get the access level.
$this->db->setQuery($query);
$item = $this->db->loadObject();
// Set the access level.
$temp = max($row->access, $item->cat_access);
// Update the item.
$this->change((int) $row->id, 'access', $temp);
}
/**
* Method to update index data on published state changes
*
* @param array $pks A list of primary key ids of the content that
has changed state.
* @param integer $value The value of the state that the content has
been changed to.
*
* @return void
*
* @since 2.5
*/
protected function itemStateChange($pks, $value)
{
/*
* The item's published state is tied to the category
* published state so we need to look up all published states
* before we change anything.
*/
foreach ($pks as $pk)
{
$query = clone $this->getStateQuery();
$query->where('a.id = ' . (int) $pk);
// Get the published states.
$this->db->setQuery($query);
$item = $this->db->loadObject();
// Translate the state.
$temp = $this->translateState($value, $item->cat_state);
// Update the item.
$this->change($pk, 'state', $temp);
// Reindex the item
$this->reindex($pk);
}
}
/**
* Method to update index data when a plugin is disabled
*
* @param array $pks A list of primary key ids of the content that has
changed state.
*
* @return void
*
* @since 2.5
*/
protected function pluginDisable($pks)
{
// Since multiple plugins may be disabled at a time, we need to check
first
// that we're handling the appropriate one for the context
foreach ($pks as $pk)
{
if ($this->getPluginType($pk) == strtolower($this->context))
{
// Get all of the items to unindex them
$query = clone $this->getStateQuery();
$this->db->setQuery($query);
$items = $this->db->loadColumn();
// Remove each item
foreach ($items as $item)
{
$this->remove($item);
}
}
}
}
/**
* Method to translate the native content states into states that the
* indexer can use.
*
* @param integer $item The item state.
* @param integer $category The category state. [optional]
*
* @return integer The translated indexer state.
*
* @since 2.5
*/
protected function translateState($item, $category = null)
{
// If category is present, factor in its states as well
if ($category !== null && $category == 0)
{
$item = 0;
}
// Translate the state
switch ($item)
{
// Published and archived items only should return a published state
case 1;
case 2:
return 1;
// All other states should return an unpublished state
default:
case 0:
return 0;
}
}
}
indexer/driver/mysql.php000064400000045676151156756060011411
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
jimport('joomla.filesystem.file');
/**
* Indexer class supporting MySQL(i) for the Finder indexer package.
*
* The indexer class provides the core functionality of the Finder
* search engine. It is responsible for adding and updating the
* content links table; extracting and scoring tokens; and maintaining
* all referential information for the content.
*
* Note: All exceptions thrown from within this class should be caught
* by the controller.
*
* @since 3.0
*/
class FinderIndexerDriverMysql extends FinderIndexer
{
/**
* Method to index a content item.
*
* @param FinderIndexerResult $item The content item to index.
* @param string $format The format of the content.
[optional]
*
* @return integer The ID of the record in the links table.
*
* @since 3.0
* @throws Exception on database error.
*/
public function index($item, $format = 'html')
{
// Mark beforeIndexing in the profiler.
static::$profiler ?
static::$profiler->mark('beforeIndexing') : null;
$db = $this->db;
$nd = $db->getNullDate();
// Check if the item is in the database.
$query = $db->getQuery(true)
->select($db->quoteName('link_id') . ', ' .
$db->quoteName('md5sum'))
->from($db->quoteName('#__finder_links'))
->where($db->quoteName('url') . ' = ' .
$db->quote($item->url));
// Load the item from the database.
$db->setQuery($query);
$link = $db->loadObject();
// Get the indexer state.
$state = static::getState();
// Get the signatures of the item.
$curSig = static::getSignature($item);
$oldSig = isset($link->md5sum) ? $link->md5sum : null;
// Get the other item information.
$linkId = empty($link->link_id) ? null : $link->link_id;
$isNew = empty($link->link_id) ? true : false;
// Check the signatures. If they match, the item is up to date.
if (!$isNew && $curSig == $oldSig)
{
return $linkId;
}
/*
* If the link already exists, flush all the term maps for the item.
* Maps are stored in 16 tables so we need to iterate through and flush
* each table one at a time.
*/
if (!$isNew)
{
for ($i = 0; $i <= 15; $i++)
{
// Flush the maps for the link.
$query->clear()
->delete($db->quoteName('#__finder_links_terms' .
dechex($i)))
->where($db->quoteName('link_id') . ' = ' .
(int) $linkId);
$db->setQuery($query);
$db->execute();
}
// Remove the taxonomy maps.
FinderIndexerTaxonomy::removeMaps($linkId);
}
// Mark afterUnmapping in the profiler.
static::$profiler ?
static::$profiler->mark('afterUnmapping') : null;
// Perform cleanup on the item data.
$item->publish_start_date = (int) $item->publish_start_date != 0 ?
$item->publish_start_date : $nd;
$item->publish_end_date = (int) $item->publish_end_date != 0 ?
$item->publish_end_date : $nd;
$item->start_date = (int) $item->start_date != 0 ?
$item->start_date : $nd;
$item->end_date = (int) $item->end_date != 0 ? $item->end_date :
$nd;
// Prepare the item description.
$item->description = FinderIndexerHelper::parse($item->summary);
/*
* Now, we need to enter the item into the links table. If the item
* already exists in the database, we need to use an UPDATE query.
* Otherwise, we need to use an INSERT to get the link id back.
*/
if ($isNew)
{
$columnsArray = array(
$db->quoteName('url'),
$db->quoteName('route'), $db->quoteName('title'),
$db->quoteName('description'),
$db->quoteName('indexdate'),
$db->quoteName('published'),
$db->quoteName('state'),
$db->quoteName('access'),
$db->quoteName('language'),
$db->quoteName('type_id'),
$db->quoteName('object'),
$db->quoteName('publish_start_date'),
$db->quoteName('publish_end_date'),
$db->quoteName('start_date'),
$db->quoteName('end_date'),
$db->quoteName('list_price'),
$db->quoteName('sale_price')
);
// Insert the link.
$query->clear()
->insert($db->quoteName('#__finder_links'))
->columns($columnsArray)
->values(
$db->quote($item->url) . ', '
. $db->quote($item->route) . ', '
. $db->quote($item->title) . ', '
. $db->quote($item->description) . ', '
. $query->currentTimestamp() . ', '
. '1, '
. (int) $item->state . ', '
. (int) $item->access . ', '
. $db->quote($item->language) . ', '
. (int) $item->type_id . ', '
. $db->quote(serialize($item)) . ', '
. $db->quote($item->publish_start_date) . ', '
. $db->quote($item->publish_end_date) . ', '
. $db->quote($item->start_date) . ', '
. $db->quote($item->end_date) . ', '
. (double) ($item->list_price ?: 0) . ', '
. (double) ($item->sale_price ?: 0)
);
$db->setQuery($query);
$db->execute();
// Get the link id.
$linkId = (int) $db->insertid();
}
else
{
// Update the link.
$query->clear()
->update($db->quoteName('#__finder_links'))
->set($db->quoteName('route') . ' = ' .
$db->quote($item->route))
->set($db->quoteName('title') . ' = ' .
$db->quote($item->title))
->set($db->quoteName('description') . ' = ' .
$db->quote($item->description))
->set($db->quoteName('indexdate') . ' = ' .
$query->currentTimestamp())
->set($db->quoteName('state') . ' = ' . (int)
$item->state)
->set($db->quoteName('access') . ' = ' .
(int) $item->access)
->set($db->quoteName('language') . ' = ' .
$db->quote($item->language))
->set($db->quoteName('type_id') . ' = ' .
(int) $item->type_id)
->set($db->quoteName('object') . ' = ' .
$db->quote(serialize($item)))
->set($db->quoteName('publish_start_date') . ' =
' . $db->quote($item->publish_start_date))
->set($db->quoteName('publish_end_date') . ' =
' . $db->quote($item->publish_end_date))
->set($db->quoteName('start_date') . ' = ' .
$db->quote($item->start_date))
->set($db->quoteName('end_date') . ' = ' .
$db->quote($item->end_date))
->set($db->quoteName('list_price') . ' = ' .
(double) ($item->list_price ?: 0))
->set($db->quoteName('sale_price') . ' = ' .
(double) ($item->sale_price ?: 0))
->where('link_id = ' . (int) $linkId);
$db->setQuery($query);
$db->execute();
}
// Set up the variables we will need during processing.
$count = 0;
// Mark afterLinking in the profiler.
static::$profiler ? static::$profiler->mark('afterLinking')
: null;
// Truncate the tokens tables.
$db->truncateTable('#__finder_tokens');
// Truncate the tokens aggregate table.
$db->truncateTable('#__finder_tokens_aggregate');
/*
* Process the item's content. The items can customize their
* processing instructions to define extra properties to process
* or rearrange how properties are weighted.
*/
foreach ($item->getInstructions() as $group => $properties)
{
// Iterate through the properties of the group.
foreach ($properties as $property)
{
// Check if the property exists in the item.
if (empty($item->$property))
{
continue;
}
// Tokenize the property.
if (is_array($item->$property))
{
// Tokenize an array of content and add it to the database.
foreach ($item->$property as $ip)
{
/*
* If the group is path, we need to a few extra processing
* steps to strip the extension and convert slashes and dashes
* to spaces.
*/
if ($group === static::PATH_CONTEXT)
{
$ip = JFile::stripExt($ip);
$ip = str_replace(array('/', '-'), '
', $ip);
}
// Tokenize a string of content and add it to the database.
$count += $this->tokenizeToDb($ip, $group, $item->language,
$format);
// Check if we're approaching the memory limit of the token
table.
if ($count >
static::$state->options->get('memory_table_limit', 30000))
{
$this->toggleTables(false);
}
}
}
else
{
/*
* If the group is path, we need to a few extra processing
* steps to strip the extension and convert slashes and dashes
* to spaces.
*/
if ($group === static::PATH_CONTEXT)
{
$item->$property = JFile::stripExt($item->$property);
$item->$property = str_replace('/', ' ',
$item->$property);
$item->$property = str_replace('-', ' ',
$item->$property);
}
// Tokenize a string of content and add it to the database.
$count += $this->tokenizeToDb($item->$property, $group,
$item->language, $format);
// Check if we're approaching the memory limit of the token
table.
if ($count >
static::$state->options->get('memory_table_limit', 30000))
{
$this->toggleTables(false);
}
}
}
}
/*
* Process the item's taxonomy. The items can customize their
* taxonomy mappings to define extra properties to map.
*/
foreach ($item->getTaxonomy() as $branch => $nodes)
{
// Iterate through the nodes and map them to the branch.
foreach ($nodes as $node)
{
// Add the node to the tree.
$nodeId = FinderIndexerTaxonomy::addNode($branch, $node->title,
$node->state, $node->access);
// Add the link => node map.
FinderIndexerTaxonomy::addMap($linkId, $nodeId);
}
}
// Mark afterProcessing in the profiler.
static::$profiler ?
static::$profiler->mark('afterProcessing') : null;
/*
* At this point, all of the item's content has been parsed,
tokenized
* and inserted into the #__finder_tokens table. Now, we need to
* aggregate all the data into that table into a more usable form. The
* aggregated data will be inserted into #__finder_tokens_aggregate
* table.
*/
$query = 'INSERT INTO ' .
$db->quoteName('#__finder_tokens_aggregate') .
' (' . $db->quoteName('term_id') .
', ' . $db->quoteName('map_suffix') .
', ' . $db->quoteName('term') .
', ' . $db->quoteName('stem') .
', ' . $db->quoteName('common') .
', ' . $db->quoteName('phrase') .
', ' . $db->quoteName('term_weight') .
', ' . $db->quoteName('context') .
', ' . $db->quoteName('context_weight') .
', ' . $db->quoteName('total_weight') .
', ' . $db->quoteName('language') .
')' .
' SELECT' .
' COALESCE(t.term_id, 0), \'\', t1.term, t1.stem,
t1.common, t1.phrase, t1.weight, t1.context,' .
' ROUND( t1.weight * COUNT( t2.term ) * %F, 8 ) AS context_weight,
0, t1.language' .
' FROM (' .
' SELECT DISTINCT t1.term, t1.stem, t1.common, t1.phrase,
t1.weight, t1.context, t1.language' .
' FROM ' . $db->quoteName('#__finder_tokens') .
' AS t1' .
' WHERE t1.context = %d' .
' ) AS t1' .
' JOIN ' . $db->quoteName('#__finder_tokens') .
' AS t2 ON t2.term = t1.term' .
' LEFT JOIN ' . $db->quoteName('#__finder_terms')
. ' AS t ON t.term = t1.term' .
' WHERE t2.context = %d' .
' GROUP BY t1.term, t.term_id, t1.term, t1.stem, t1.common,
t1.phrase, t1.weight, t1.context, t1.language' .
' ORDER BY t1.term DESC';
// Iterate through the contexts and aggregate the tokens per context.
foreach ($state->weights as $context => $multiplier)
{
// Run the query to aggregate the tokens for this context..
$db->setQuery(sprintf($query, $multiplier, $context, $context));
$db->execute();
}
// Mark afterAggregating in the profiler.
static::$profiler ?
static::$profiler->mark('afterAggregating') : null;
/*
* When we pulled down all of the aggregate data, we did a LEFT JOIN
* over the terms table to try to find all the term ids that
* already exist for our tokens. If any of the rows in the aggregate
* table have a term of 0, then no term record exists for that
* term so we need to add it to the terms table.
*/
$db->setQuery(
'INSERT IGNORE INTO ' .
$db->quoteName('#__finder_terms') .
' (' . $db->quoteName('term') .
', ' . $db->quoteName('stem') .
', ' . $db->quoteName('common') .
', ' . $db->quoteName('phrase') .
', ' . $db->quoteName('weight') .
', ' . $db->quoteName('soundex') .
', ' . $db->quoteName('language') . ')'
.
' SELECT ta.term, ta.stem, ta.common, ta.phrase, ta.term_weight,
SOUNDEX(ta.term), ta.language' .
' FROM ' .
$db->quoteName('#__finder_tokens_aggregate') . ' AS
ta' .
' WHERE ta.term_id = 0' .
' GROUP BY ta.term, ta.stem, ta.common, ta.phrase, ta.term_weight,
SOUNDEX(ta.term), ta.language'
);
$db->execute();
/*
* Now, we just inserted a bunch of new records into the terms table
* so we need to go back and update the aggregate table with all the
* new term ids.
*/
$query = $db->getQuery(true)
->update($db->quoteName('#__finder_tokens_aggregate') .
' AS ta')
->join('INNER',
$db->quoteName('#__finder_terms') . ' AS t ON t.term =
ta.term')
->set('ta.term_id = t.term_id')
->where('ta.term_id = 0');
$db->setQuery($query);
$db->execute();
// Mark afterTerms in the profiler.
static::$profiler ? static::$profiler->mark('afterTerms') :
null;
/*
* After we've made sure that all of the terms are in the terms
table
* and the aggregate table has the correct term ids, we need to update
* the links counter for each term by one.
*/
$query->clear()
->update($db->quoteName('#__finder_terms') . ' AS
t')
->join('INNER',
$db->quoteName('#__finder_tokens_aggregate') . ' AS ta ON
ta.term_id = t.term_id')
->set('t.' . $db->quoteName('links') . '
= t.links + 1');
$db->setQuery($query);
$db->execute();
// Mark afterTerms in the profiler.
static::$profiler ? static::$profiler->mark('afterTerms') :
null;
/*
* Before we can insert all of the mapping rows, we have to figure out
* which mapping table the rows need to be inserted into. The mapping
* table for each term is based on the first character of the md5 of
* the first character of the term. In php, it would be expressed as
* substr(md5(substr($token, 0, 1)), 0, 1)
*/
$query->clear()
->update($db->quoteName('#__finder_tokens_aggregate'))
->set($db->quoteName('map_suffix') . ' =
SUBSTR(MD5(SUBSTR(' . $db->quoteName('term') . ', 1,
1)), 1, 1)');
$db->setQuery($query);
$db->execute();
/*
* At this point, the aggregate table contains a record for each
* term in each context. So, we're going to pull down all of that
* data while grouping the records by term and add all of the
* sub-totals together to arrive at the final total for each token for
* this link. Then, we insert all of that data into the appropriate
* mapping table.
*/
for ($i = 0; $i <= 15; $i++)
{
// Get the mapping table suffix.
$suffix = dechex($i);
/*
* We have to run this query 16 times, one for each link => term
* mapping table.
*/
$db->setQuery(
'INSERT INTO ' .
$db->quoteName('#__finder_links_terms' . $suffix) .
' (' . $db->quoteName('link_id') .
', ' . $db->quoteName('term_id') .
', ' . $db->quoteName('weight') . ')'
.
' SELECT ' . (int) $linkId . ', ' .
$db->quoteName('term_id') . ',' .
' ROUND(SUM(' . $db->quoteName('context_weight')
. '), 8)' .
' FROM ' .
$db->quoteName('#__finder_tokens_aggregate') .
' WHERE ' . $db->quoteName('map_suffix') .
' = ' . $db->quote($suffix) .
' GROUP BY ' . $db->quoteName('term') . ',
' . $db->quoteName('term_id') .
' ORDER BY ' . $db->quoteName('term') . '
DESC'
);
$db->execute();
}
// Mark afterMapping in the profiler.
static::$profiler ? static::$profiler->mark('afterMapping')
: null;
// Update the signature.
$query->clear()
->update($db->quoteName('#__finder_links'))
->set($db->quoteName('md5sum') . ' = ' .
$db->quote($curSig))
->where($db->quoteName('link_id') . ' = ' .
$db->quote($linkId));
$db->setQuery($query);
$db->execute();
// Mark afterSigning in the profiler.
static::$profiler ? static::$profiler->mark('afterSigning')
: null;
// Truncate the tokens tables.
$db->truncateTable('#__finder_tokens');
// Truncate the tokens aggregate table.
$db->truncateTable('#__finder_tokens_aggregate');
// Toggle the token tables back to memory tables.
$this->toggleTables(true);
// Mark afterTruncating in the profiler.
static::$profiler ?
static::$profiler->mark('afterTruncating') : null;
return $linkId;
}
/**
* Method to optimize the index. We use this method to remove unused terms
* and any other optimizations that might be necessary.
*
* @return boolean True on success.
*
* @since 3.0
* @throws Exception on database error.
*/
public function optimize()
{
// Get the database object.
$db = $this->db;
$query = $db->getQuery(true);
// Delete all orphaned terms.
$query->delete($db->quoteName('#__finder_terms'))
->where($db->quoteName('links') . ' <= 0');
$db->setQuery($query);
$db->execute();
// Optimize the links table.
$db->setQuery('OPTIMIZE TABLE ' .
$db->quoteName('#__finder_links'));
$db->execute();
for ($i = 0; $i <= 15; $i++)
{
// Optimize the terms mapping table.
$db->setQuery('OPTIMIZE TABLE ' .
$db->quoteName('#__finder_links_terms' . dechex($i)));
$db->execute();
}
// Optimize the filters table.
$db->setQuery('OPTIMIZE TABLE ' .
$db->quoteName('#__finder_filters'));
$db->execute();
// Optimize the terms common table.
$db->setQuery('OPTIMIZE TABLE ' .
$db->quoteName('#__finder_terms_common'));
$db->execute();
// Optimize the types table.
$db->setQuery('OPTIMIZE TABLE ' .
$db->quoteName('#__finder_types'));
$db->execute();
// Remove the orphaned taxonomy nodes.
FinderIndexerTaxonomy::removeOrphanNodes();
// Optimize the taxonomy mapping table.
$db->setQuery('OPTIMIZE TABLE ' .
$db->quoteName('#__finder_taxonomy_map'));
$db->execute();
// Optimize the taxonomy table.
$db->setQuery('OPTIMIZE TABLE ' .
$db->quoteName('#__finder_taxonomy'));
$db->execute();
return true;
}
/**
* Method to switch the token tables from Memory tables to MyISAM tables
* when they are close to running out of memory.
*
* @param boolean $memory Flag to control how they should be toggled.
*
* @return boolean True on success.
*
* @since 3.0
* @throws Exception on database error.
*/
protected function toggleTables($memory)
{
static $state;
// Get the database adapter.
$db = $this->db;
// Check if we are setting the tables to the Memory engine.
if ($memory === true && $state !== true)
{
// Set the tokens table to Memory.
$db->setQuery('ALTER TABLE ' .
$db->quoteName('#__finder_tokens') . ' ENGINE =
MEMORY');
$db->execute();
// Set the tokens aggregate table to Memory.
$db->setQuery('ALTER TABLE ' .
$db->quoteName('#__finder_tokens_aggregate') . ' ENGINE =
MEMORY');
$db->execute();
// Set the internal state.
$state = $memory;
}
// We must be setting the tables to the MyISAM engine.
elseif ($memory === false && $state !== false)
{
// Set the tokens table to MyISAM.
$db->setQuery('ALTER TABLE ' .
$db->quoteName('#__finder_tokens') . ' ENGINE =
MYISAM');
$db->execute();
// Set the tokens aggregate table to MyISAM.
$db->setQuery('ALTER TABLE ' .
$db->quoteName('#__finder_tokens_aggregate') . ' ENGINE =
MYISAM');
$db->execute();
// Set the internal state.
$state = $memory;
}
return true;
}
}
indexer/driver/postgresql.php000064400000037645151156756060012444
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\String\StringHelper;
jimport('joomla.filesystem.file');
/**
* Indexer class supporting PostgreSQL for the Finder indexer package.
*
* @since 3.0
*/
class FinderIndexerDriverPostgresql extends FinderIndexer
{
/**
* Method to index a content item.
*
* @param FinderIndexerResult $item The content item to index.
* @param string $format The format of the content.
[optional]
*
* @return integer The ID of the record in the links table.
*
* @since 3.0
* @throws Exception on database error.
*/
public function index($item, $format = 'html')
{
// Mark beforeIndexing in the profiler.
static::$profiler ?
static::$profiler->mark('beforeIndexing') : null;
$db = $this->db;
$nd = $db->getNullDate();
// Check if the item is in the database.
$query = $db->getQuery(true)
->select($db->quoteName('link_id') . ', ' .
$db->quoteName('md5sum'))
->from($db->quoteName('#__finder_links'))
->where($db->quoteName('url') . ' = ' .
$db->quote($item->url));
// Load the item from the database.
$db->setQuery($query);
$link = $db->loadObject();
// Get the indexer state.
$state = static::getState();
// Get the signatures of the item.
$curSig = static::getSignature($item);
$oldSig = isset($link->md5sum) ? $link->md5sum : null;
// Get the other item information.
$linkId = empty($link->link_id) ? null : $link->link_id;
$isNew = empty($link->link_id) ? true : false;
// Check the signatures. If they match, the item is up to date.
if (!$isNew && $curSig === $oldSig)
{
return $linkId;
}
/*
* If the link already exists, flush all the term maps for the item.
* Maps are stored in 16 tables so we need to iterate through and flush
* each table one at a time.
*/
if (!$isNew)
{
for ($i = 0; $i <= 15; $i++)
{
// Flush the maps for the link.
$query->clear()
->delete($db->quoteName('#__finder_links_terms' .
dechex($i)))
->where($db->quoteName('link_id') . ' = ' .
(int) $linkId);
$db->setQuery($query);
$db->execute();
}
// Remove the taxonomy maps.
FinderIndexerTaxonomy::removeMaps($linkId);
}
// Mark afterUnmapping in the profiler.
static::$profiler ?
static::$profiler->mark('afterUnmapping') : null;
// Perform cleanup on the item data.
$item->publish_start_date = (int) $item->publish_start_date != 0 ?
$item->publish_start_date : $nd;
$item->publish_end_date = (int) $item->publish_end_date != 0 ?
$item->publish_end_date : $nd;
$item->start_date = (int) $item->start_date != 0 ?
$item->start_date : $nd;
$item->end_date = (int) $item->end_date != 0 ? $item->end_date :
$nd;
// Prepare the item description.
$item->description = FinderIndexerHelper::parse($item->summary);
/*
* Now, we need to enter the item into the links table. If the item
* already exists in the database, we need to use an UPDATE query.
* Otherwise, we need to use an INSERT to get the link id back.
*/
$entry = new stdClass;
$entry->url = $item->url;
$entry->route = $item->route;
$entry->title = $item->title;
// We are shortening the description in order to not run into length
issues with this field
$entry->description = StringHelper::substr($item->description, 0,
32000);
$entry->indexdate = Factory::getDate()->toSql();
$entry->state = (int) $item->state;
$entry->access = (int) $item->access;
$entry->language = $item->language;
$entry->type_id = (int) $item->type_id;
$entry->object = '';
$entry->publish_start_date = $item->publish_start_date;
$entry->publish_end_date = $item->publish_end_date;
$entry->start_date = $item->start_date;
$entry->end_date = $item->end_date;
$entry->list_price = (double) ($item->list_price ?: 0);
$entry->sale_price = (double) ($item->sale_price ?: 0);
if ($isNew)
{
// Insert the link and get its id.
$db->insertObject('#__finder_links', $entry);
$linkId = (int) $db->insertid();
}
else
{
// Update the link.
$entry->link_id = $linkId;
$db->updateObject('#__finder_links', $entry,
'link_id');
}
// Set up the variables we will need during processing.
$count = 0;
// Mark afterLinking in the profiler.
static::$profiler ? static::$profiler->mark('afterLinking')
: null;
// Truncate the tokens tables.
$db->truncateTable('#__finder_tokens');
// Truncate the tokens aggregate table.
$db->truncateTable('#__finder_tokens_aggregate');
/*
* Process the item's content. The items can customize their
* processing instructions to define extra properties to process
* or rearrange how properties are weighted.
*/
foreach ($item->getInstructions() as $group => $properties)
{
// Iterate through the properties of the group.
foreach ($properties as $property)
{
// Check if the property exists in the item.
if (empty($item->$property))
{
continue;
}
// Tokenize the property.
if (is_array($item->$property))
{
// Tokenize an array of content and add it to the database.
foreach ($item->$property as $ip)
{
/*
* If the group is path, we need to a few extra processing
* steps to strip the extension and convert slashes and dashes
* to spaces.
*/
if ($group === static::PATH_CONTEXT)
{
$ip = JFile::stripExt($ip);
$ip = str_replace(array('/', '-'), '
', $ip);
}
// Tokenize a string of content and add it to the database.
$count += $this->tokenizeToDb($ip, $group, $item->language,
$format);
// Check if we're approaching the memory limit of the token
table.
if ($count >
static::$state->options->get('memory_table_limit', 30000))
{
$this->toggleTables(false);
}
}
}
else
{
/*
* If the group is path, we need to a few extra processing
* steps to strip the extension and convert slashes and dashes
* to spaces.
*/
if ($group === static::PATH_CONTEXT)
{
$item->$property = JFile::stripExt($item->$property);
$item->$property = str_replace('/', ' ',
$item->$property);
$item->$property = str_replace('-', ' ',
$item->$property);
}
// Tokenize a string of content and add it to the database.
$count += $this->tokenizeToDb($item->$property, $group,
$item->language, $format);
// Check if we're approaching the memory limit of the token
table.
if ($count >
static::$state->options->get('memory_table_limit', 30000))
{
$this->toggleTables(false);
}
}
}
}
/*
* Process the item's taxonomy. The items can customize their
* taxonomy mappings to define extra properties to map.
*/
foreach ($item->getTaxonomy() as $branch => $nodes)
{
// Iterate through the nodes and map them to the branch.
foreach ($nodes as $node)
{
// Add the node to the tree.
$nodeId = FinderIndexerTaxonomy::addNode($branch, $node->title,
$node->state, $node->access);
// Add the link => node map.
FinderIndexerTaxonomy::addMap($linkId, $nodeId);
}
}
// Mark afterProcessing in the profiler.
static::$profiler ?
static::$profiler->mark('afterProcessing') : null;
/*
* At this point, all of the item's content has been parsed,
tokenized
* and inserted into the #__finder_tokens table. Now, we need to
* aggregate all the data into that table into a more usable form. The
* aggregated data will be inserted into #__finder_tokens_aggregate
* table.
*/
$query = 'INSERT INTO ' .
$db->quoteName('#__finder_tokens_aggregate') .
' (' . $db->quoteName('term_id') .
', ' . $db->quoteName('term') .
', ' . $db->quoteName('stem') .
', ' . $db->quoteName('common') .
', ' . $db->quoteName('phrase') .
', ' . $db->quoteName('term_weight') .
', ' . $db->quoteName('context') .
', ' . $db->quoteName('context_weight') .
', ' . $db->quoteName('language') .
')' .
' SELECT' .
' t.term_id, t1.term, t1.stem, t1.common, t1.phrase, t1.weight,
t1.context,' .
' ROUND( t1.weight * COUNT( t2.term ) * %F, 8 ) AS context_weight,
t1.language' .
' FROM (' .
' SELECT DISTINCT t1.term, t1.stem, t1.common, t1.phrase,
t1.weight, t1.context, t1.language' .
' FROM ' . $db->quoteName('#__finder_tokens')
. ' AS t1' .
' WHERE t1.context = %d' .
' ) AS t1' .
' JOIN ' . $db->quoteName('#__finder_tokens') .
' AS t2 ON t2.term = t1.term' .
' LEFT JOIN ' .
$db->quoteName('#__finder_terms') . ' AS t ON t.term =
t1.term' .
' WHERE t2.context = %d AND t.term_id IS NOT NULL' .
' GROUP BY t1.term, t.term_id, t1.term, t1.stem, t1.common,
t1.phrase, t1.weight, t1.context, t1.language' .
' ORDER BY t1.term DESC';
// Iterate through the contexts and aggregate the tokens per context.
foreach ($state->weights as $context => $multiplier)
{
// Run the query to aggregate the tokens for this context..
$db->setQuery(sprintf($query, $multiplier, $context, $context));
$db->execute();
}
// Mark afterAggregating in the profiler.
static::$profiler ?
static::$profiler->mark('afterAggregating') : null;
/*
* When we pulled down all of the aggregate data, we did a LEFT JOIN
* over the terms table to try to find all the term ids that
* already exist for our tokens. If any of the rows in the aggregate
* table have a term of 0, then no term record exists for that
* term so we need to add it to the terms table.
*/
// Emulation of IGNORE INTO behaviour
$db->setQuery(
' SELECT ta.term' .
' FROM ' .
$db->quoteName('#__finder_tokens_aggregate') . ' AS
ta' .
' WHERE ta.term_id = 0'
);
if ($db->loadRow() === null)
{
$db->setQuery(
'INSERT INTO ' .
$db->quoteName('#__finder_terms') .
' (' . $db->quoteName('term') .
', ' . $db->quoteName('stem') .
', ' . $db->quoteName('common') .
', ' . $db->quoteName('phrase') .
', ' . $db->quoteName('weight') .
', ' . $db->quoteName('soundex') .
', ' . $db->quoteName('language') .
')' .
' SELECT ta.term, ta.stem, ta.common, ta.phrase, ta.term_weight,
SOUNDEX(ta.term), ta.language' .
' FROM ' .
$db->quoteName('#__finder_tokens_aggregate') . ' AS
ta' .
' WHERE ta.term_id = 0' .
' GROUP BY ta.term, ta.stem, ta.common, ta.phrase, ta.term_weight,
SOUNDEX(ta.term), ta.language'
);
$db->execute();
}
/*
* Now, we just inserted a bunch of new records into the terms table
* so we need to go back and update the aggregate table with all the
* new term ids.
*/
$query = $db->getQuery(true)
->update($db->quoteName('#__finder_tokens_aggregate') .
' AS ta')
->join('INNER',
$db->quoteName('#__finder_terms') . ' AS t ON t.term =
ta.term')
->set('term_id = t.term_id')
->where('ta.term_id = 0');
$db->setQuery($query);
$db->execute();
// Mark afterTerms in the profiler.
static::$profiler ? static::$profiler->mark('afterTerms') :
null;
/*
* After we've made sure that all of the terms are in the terms
table
* and the aggregate table has the correct term ids, we need to update
* the links counter for each term by one.
*/
$query->clear()
->update($db->quoteName('#__finder_terms') . ' AS
t')
->join('INNER',
$db->quoteName('#__finder_tokens_aggregate') . ' AS ta ON
ta.term_id = t.term_id')
->set($db->quoteName('links') . ' = t.links +
1');
$db->setQuery($query);
$db->execute();
// Mark afterTerms in the profiler.
static::$profiler ? static::$profiler->mark('afterTerms') :
null;
/*
* Before we can insert all of the mapping rows, we have to figure out
* which mapping table the rows need to be inserted into. The mapping
* table for each term is based on the first character of the md5 of
* the first character of the term. In php, it would be expressed as
* substr(md5(substr($token, 0, 1)), 0, 1)
*/
$query->clear()
->update($db->quoteName('#__finder_tokens_aggregate'))
->set($db->quoteName('map_suffix') . ' =
SUBSTR(MD5(SUBSTR(' . $db->quoteName('term') . ', 1,
1)), 1, 1)');
$db->setQuery($query);
$db->execute();
/*
* At this point, the aggregate table contains a record for each
* term in each context. So, we're going to pull down all of that
* data while grouping the records by term and add all of the
* sub-totals together to arrive at the final total for each token for
* this link. Then, we insert all of that data into the appropriate
* mapping table.
*/
for ($i = 0; $i <= 15; $i++)
{
// Get the mapping table suffix.
$suffix = dechex($i);
/*
* We have to run this query 16 times, one for each link => term
* mapping table.
*/
$db->setQuery(
'INSERT INTO ' .
$db->quoteName('#__finder_links_terms' . $suffix) .
' (' . $db->quoteName('link_id') .
', ' . $db->quoteName('term_id') .
', ' . $db->quoteName('weight') . ')'
.
' SELECT ' . (int) $linkId . ', ' .
$db->quoteName('term_id') . ',' .
' ROUND(SUM(' . $db->quoteName('context_weight')
. '), 8)' .
' FROM ' .
$db->quoteName('#__finder_tokens_aggregate') .
' WHERE ' . $db->quoteName('map_suffix') .
' = ' . $db->quote($suffix) .
' GROUP BY ' . $db->quoteName('term') . ',
' . $db->quoteName('term_id') .
' ORDER BY ' . $db->quoteName('term') . '
DESC'
);
$db->execute();
}
// Mark afterMapping in the profiler.
static::$profiler ? static::$profiler->mark('afterMapping')
: null;
// Update the signature.
$query->clear()
->update($db->quoteName('#__finder_links'))
->set($db->quoteName('md5sum') . ' = ' .
$db->quote($curSig))
->where($db->quoteName('link_id') . ' = ' .
$db->quote($linkId));
$db->setQuery($query);
$db->execute();
// Mark afterSigning in the profiler.
static::$profiler ? static::$profiler->mark('afterSigning')
: null;
// Truncate the tokens tables.
$db->truncateTable('#__finder_tokens');
// Truncate the tokens aggregate table.
$db->truncateTable('#__finder_tokens_aggregate');
// Toggle the token tables back to memory tables.
$this->toggleTables(true);
// Mark afterTruncating in the profiler.
static::$profiler ?
static::$profiler->mark('afterTruncating') : null;
return $linkId;
}
/**
* Method to optimize the index. We use this method to remove unused terms
* and any other optimizations that might be necessary.
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function optimize()
{
// Get the database object.
$db = $this->db;
$query = $db->getQuery(true);
// Delete all orphaned terms.
$query->delete($db->quoteName('#__finder_terms'))
->where($db->quoteName('links') . ' <= 0');
$db->setQuery($query);
$db->execute();
// Optimize the links table.
$db->setQuery('VACUUM ' .
$db->quoteName('#__finder_links'));
$db->execute();
$db->setQuery('REINDEX TABLE ' .
$db->quoteName('#__finder_links'));
$db->execute();
for ($i = 0; $i <= 15; $i++)
{
// Optimize the terms mapping table.
$db->setQuery('VACUUM ' .
$db->quoteName('#__finder_links_terms' . dechex($i)));
$db->execute();
$db->setQuery('REINDEX TABLE ' .
$db->quoteName('#__finder_links_terms' . dechex($i)));
$db->execute();
}
// Optimize the filters table.
$db->setQuery('REINDEX TABLE ' .
$db->quoteName('#__finder_filters'));
$db->execute();
// Optimize the terms common table.
$db->setQuery('REINDEX TABLE ' .
$db->quoteName('#__finder_terms_common'));
$db->execute();
// Optimize the types table.
$db->setQuery('REINDEX TABLE ' .
$db->quoteName('#__finder_types'));
$db->execute();
// Remove the orphaned taxonomy nodes.
FinderIndexerTaxonomy::removeOrphanNodes();
// Optimize the taxonomy mapping table.
$db->setQuery('REINDEX TABLE ' .
$db->quoteName('#__finder_taxonomy_map'));
$db->execute();
// Optimize the taxonomy table.
$db->setQuery('REINDEX TABLE ' .
$db->quoteName('#__finder_taxonomy'));
$db->execute();
return true;
}
}
indexer/driver/sqlsrv.php000064400000043507151156756060011565
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
jimport('joomla.filesystem.file');
/**
* Indexer class supporting SQL Server for the Finder indexer package.
*
* The indexer class provides the core functionality of the Finder
* search engine. It is responsible for adding and updating the
* content links table; extracting and scoring tokens; and maintaining
* all referential information for the content.
*
* Note: All exceptions thrown from within this class should be caught
* by the controller.
*
* @since 3.1
*/
class FinderIndexerDriverSqlsrv extends FinderIndexer
{
/**
* Method to index a content item.
*
* @param FinderIndexerResult $item The content item to index.
* @param string $format The format of the content.
[optional]
*
* @return integer The ID of the record in the links table.
*
* @since 3.1
* @throws Exception on database error.
*/
public function index($item, $format = 'html')
{
// Mark beforeIndexing in the profiler.
static::$profiler ?
static::$profiler->mark('beforeIndexing') : null;
$db = $this->db;
$nd = $db->getNullDate();
// Check if the item is in the database.
$query = $db->getQuery(true)
->select($db->quoteName('link_id') . ', ' .
$db->quoteName('md5sum'))
->from($db->quoteName('#__finder_links'))
->where($db->quoteName('url') . ' = ' .
$db->quote($item->url));
// Load the item from the database.
$db->setQuery($query);
$link = $db->loadObject();
// Get the indexer state.
$state = static::getState();
// Get the signatures of the item.
$curSig = static::getSignature($item);
$oldSig = isset($link->md5sum) ? $link->md5sum : null;
// Get the other item information.
$linkId = empty($link->link_id) ? null : $link->link_id;
$isNew = empty($link->link_id) ? true : false;
// Check the signatures. If they match, the item is up to date.
if (!$isNew && $curSig === $oldSig)
{
return $linkId;
}
/*
* If the link already exists, flush all the term maps for the item.
* Maps are stored in 16 tables so we need to iterate through and flush
* each table one at a time.
*/
if (!$isNew)
{
for ($i = 0; $i <= 15; $i++)
{
// Flush the maps for the link.
$query->clear()
->delete($db->quoteName('#__finder_links_terms' .
dechex($i)))
->where($db->quoteName('link_id') . ' = ' .
(int) $linkId);
$db->setQuery($query);
$db->execute();
}
// Remove the taxonomy maps.
FinderIndexerTaxonomy::removeMaps($linkId);
}
// Mark afterUnmapping in the profiler.
static::$profiler ?
static::$profiler->mark('afterUnmapping') : null;
// Perform cleanup on the item data.
$item->publish_start_date = (int) $item->publish_start_date != 0 ?
$item->publish_start_date : $nd;
$item->publish_end_date = (int) $item->publish_end_date != 0 ?
$item->publish_end_date : $nd;
$item->start_date = (int) $item->start_date != 0 ?
$item->start_date : $nd;
$item->end_date = (int) $item->end_date != 0 ? $item->end_date :
$nd;
// Prepare the item description.
$item->description = FinderIndexerHelper::parse($item->summary);
/*
* Now, we need to enter the item into the links table. If the item
* already exists in the database, we need to use an UPDATE query.
* Otherwise, we need to use an INSERT to get the link id back.
*/
if ($isNew)
{
$columnsArray = array(
$db->quoteName('url'),
$db->quoteName('route'), $db->quoteName('title'),
$db->quoteName('description'),
$db->quoteName('indexdate'),
$db->quoteName('published'),
$db->quoteName('state'),
$db->quoteName('access'),
$db->quoteName('language'),
$db->quoteName('type_id'),
$db->quoteName('object'),
$db->quoteName('publish_start_date'),
$db->quoteName('publish_end_date'),
$db->quoteName('start_date'),
$db->quoteName('end_date'),
$db->quoteName('list_price'),
$db->quoteName('sale_price')
);
// Insert the link.
$query->clear()
->insert($db->quoteName('#__finder_links'))
->columns($columnsArray)
->values(
$db->quote($item->url) . ', '
. $db->quote($item->route) . ', '
. $db->quote($item->title) . ', '
. $db->quote($item->description) . ', '
. $query->currentTimestamp() . ', '
. '1, '
. (int) $item->state . ', '
. (int) $item->access . ', '
. $db->quote($item->language) . ', '
. (int) $item->type_id . ', '
. $db->quote(serialize($item)) . ', '
. $db->quote($item->publish_start_date) . ', '
. $db->quote($item->publish_end_date) . ', '
. $db->quote($item->start_date) . ', '
. $db->quote($item->end_date) . ', '
. (double) ($item->list_price ?: 0) . ', '
. (double) ($item->sale_price ?: 0)
);
$db->setQuery($query);
$db->execute();
// Get the link id.
$linkId = (int) $db->insertid();
}
else
{
// Update the link.
$query->clear()
->update($db->quoteName('#__finder_links'))
->set($db->quoteName('route') . ' = ' .
$db->quote($item->route))
->set($db->quoteName('title') . ' = ' .
$db->quote($item->title))
->set($db->quoteName('description') . ' = ' .
$db->quote($item->description))
->set($db->quoteName('indexdate') . ' = ' .
$query->currentTimestamp())
->set($db->quoteName('state') . ' = ' . (int)
$item->state)
->set($db->quoteName('access') . ' = ' .
(int) $item->access)
->set($db->quoteName('language') . ' = ' .
$db->quote($item->language))
->set($db->quoteName('type_id') . ' = ' .
(int) $item->type_id)
->set($db->quoteName('object') . ' = ' .
$db->quote(serialize($item)))
->set($db->quoteName('publish_start_date') . ' =
' . $db->quote($item->publish_start_date))
->set($db->quoteName('publish_end_date') . ' =
' . $db->quote($item->publish_end_date))
->set($db->quoteName('start_date') . ' = ' .
$db->quote($item->start_date))
->set($db->quoteName('end_date') . ' = ' .
$db->quote($item->end_date))
->set($db->quoteName('list_price') . ' = ' .
(double) ($item->list_price ?: 0))
->set($db->quoteName('sale_price') . ' = ' .
(double) ($item->sale_price ?: 0))
->where('link_id = ' . (int) $linkId);
$db->setQuery($query);
$db->execute();
}
// Set up the variables we will need during processing.
$count = 0;
// Mark afterLinking in the profiler.
static::$profiler ? static::$profiler->mark('afterLinking')
: null;
// Truncate the tokens tables.
$db->truncateTable('#__finder_tokens');
// Truncate the tokens aggregate table.
$db->truncateTable('#__finder_tokens_aggregate');
/*
* Process the item's content. The items can customize their
* processing instructions to define extra properties to process
* or rearrange how properties are weighted.
*/
foreach ($item->getInstructions() as $group => $properties)
{
// Iterate through the properties of the group.
foreach ($properties as $property)
{
// Check if the property exists in the item.
if (empty($item->$property))
{
continue;
}
// Tokenize the property.
if (is_array($item->$property))
{
// Tokenize an array of content and add it to the database.
foreach ($item->$property as $ip)
{
/*
* If the group is path, we need to a few extra processing
* steps to strip the extension and convert slashes and dashes
* to spaces.
*/
if ($group === static::PATH_CONTEXT)
{
$ip = JFile::stripExt($ip);
$ip = str_replace(array('/', '-'), '
', $ip);
}
// Tokenize a string of content and add it to the database.
$count += $this->tokenizeToDb($ip, $group, $item->language,
$format);
// Check if we're approaching the memory limit of the token
table.
if ($count >
static::$state->options->get('memory_table_limit', 30000))
{
$this->toggleTables(false);
}
}
}
else
{
/*
* If the group is path, we need to a few extra processing
* steps to strip the extension and convert slashes and dashes
* to spaces.
*/
if ($group === static::PATH_CONTEXT)
{
$item->$property = JFile::stripExt($item->$property);
$item->$property = str_replace('/', ' ',
$item->$property);
$item->$property = str_replace('-', ' ',
$item->$property);
}
// Tokenize a string of content and add it to the database.
$count += $this->tokenizeToDb($item->$property, $group,
$item->language, $format);
// Check if we're approaching the memory limit of the token
table.
if ($count >
static::$state->options->get('memory_table_limit', 30000))
{
$this->toggleTables(false);
}
}
}
}
/*
* Process the item's taxonomy. The items can customize their
* taxonomy mappings to define extra properties to map.
*/
foreach ($item->getTaxonomy() as $branch => $nodes)
{
// Iterate through the nodes and map them to the branch.
foreach ($nodes as $node)
{
// Add the node to the tree.
$nodeId = FinderIndexerTaxonomy::addNode($branch, $node->title,
$node->state, $node->access);
// Add the link => node map.
FinderIndexerTaxonomy::addMap($linkId, $nodeId);
}
}
// Mark afterProcessing in the profiler.
static::$profiler ?
static::$profiler->mark('afterProcessing') : null;
/*
* At this point, all of the item's content has been parsed,
tokenized
* and inserted into the #__finder_tokens table. Now, we need to
* aggregate all the data into that table into a more usable form. The
* aggregated data will be inserted into #__finder_tokens_aggregate
* table.
*/
$query = 'INSERT INTO ' .
$db->quoteName('#__finder_tokens_aggregate') .
' (' . $db->quoteName('term_id') .
', ' . $db->quoteName('term') .
', ' . $db->quoteName('stem') .
', ' . $db->quoteName('common') .
', ' . $db->quoteName('phrase') .
', ' . $db->quoteName('term_weight') .
', ' . $db->quoteName('context') .
', ' . $db->quoteName('context_weight') .
', ' . $db->quoteName('language') .
')' .
' SELECT' .
' t.term_id, t1.term, t1.stem, t1.common, t1.phrase, t1.weight,
t1.context,' .
' ROUND( t1.weight * COUNT( t2.term ) * %F, 8 ) AS context_weight,
t1.language' .
' FROM (' .
' SELECT DISTINCT t1.term, t1.stem, t1.common, t1.phrase,
t1.weight, t1.context, t1.language' .
' FROM ' . $db->quoteName('#__finder_tokens')
. ' AS t1' .
' WHERE t1.context = %d' .
' ) AS t1' .
' JOIN ' . $db->quoteName('#__finder_tokens') .
' AS t2 ON t2.term = t1.term' .
' LEFT JOIN ' .
$db->quoteName('#__finder_terms') . ' AS t ON t.term =
t1.term' .
' WHERE t2.context = %d' .
' GROUP BY t1.term, t.term_id, t1.term, t1.stem, t1.common,
t1.phrase, t1.weight, t1.context, t1.language' .
' ORDER BY t1.term DESC';
// Iterate through the contexts and aggregate the tokens per context.
foreach ($state->weights as $context => $multiplier)
{
// Run the query to aggregate the tokens for this context..
$db->setQuery(sprintf($query, $multiplier, $context, $context));
$db->execute();
}
// Mark afterAggregating in the profiler.
static::$profiler ?
static::$profiler->mark('afterAggregating') : null;
/*
* When we pulled down all of the aggregate data, we did a LEFT JOIN
* over the terms table to try to find all the term ids that
* already exist for our tokens. If any of the rows in the aggregate
* table have a term of 0, then no term record exists for that
* term so we need to add it to the terms table.
*/
$db->setQuery(
'INSERT INTO ' .
$db->quoteName('#__finder_terms') .
' (' . $db->quoteName('term') .
', ' . $db->quoteName('stem') .
', ' . $db->quoteName('common') .
', ' . $db->quoteName('phrase') .
', ' . $db->quoteName('weight') .
', ' . $db->quoteName('soundex') . ')'
.
' SELECT ta.term, ta.stem, ta.common, ta.phrase, ta.term_weight,
SOUNDEX(ta.term)' .
' FROM ' .
$db->quoteName('#__finder_tokens_aggregate') . ' AS
ta' .
' WHERE ta.term_id IS NULL' .
' GROUP BY ta.term, ta.stem, ta.common, ta.phrase,
ta.term_weight'
);
$db->execute();
/*
* Now, we just inserted a bunch of new records into the terms table
* so we need to go back and update the aggregate table with all the
* new term ids.
*/
$query = $db->getQuery(true)
->update('ta')
->set('ta.term_id = t.term_id from #__finder_tokens_aggregate AS
ta INNER JOIN #__finder_terms AS t ON t.term = ta.term')
->where('ta.term_id IS NULL');
$db->setQuery($query);
$db->execute();
// Mark afterTerms in the profiler.
static::$profiler ? static::$profiler->mark('afterTerms') :
null;
/*
* After we've made sure that all of the terms are in the terms
table
* and the aggregate table has the correct term ids, we need to update
* the links counter for each term by one.
*/
$query->clear()
->update('t')
->set('t.links = t.links + 1 FROM #__finder_terms AS t INNER
JOIN #__finder_tokens_aggregate AS ta ON ta.term_id = t.term_id');
$db->setQuery($query);
$db->execute();
// Mark afterTerms in the profiler.
static::$profiler ? static::$profiler->mark('afterTerms') :
null;
/*
* Before we can insert all of the mapping rows, we have to figure out
* which mapping table the rows need to be inserted into. The mapping
* table for each term is based on the first character of the md5 of
* the first character of the term. In php, it would be expressed as
* substr(md5(substr($token, 0, 1)), 0, 1)
*/
$query->clear()
->update($db->quoteName('#__finder_tokens_aggregate'))
->set($db->quoteName('map_suffix') . " =
SUBSTRING(HASHBYTES('MD5', SUBSTRING(" .
$db->quoteName('term') . ', 1, 1)), 1, 1)');
$db->setQuery($query);
$db->execute();
/*
* At this point, the aggregate table contains a record for each
* term in each context. So, we're going to pull down all of that
* data while grouping the records by term and add all of the
* sub-totals together to arrive at the final total for each token for
* this link. Then, we insert all of that data into the appropriate
* mapping table.
*/
for ($i = 0; $i <= 15; $i++)
{
// Get the mapping table suffix.
$suffix = dechex($i);
/*
* We have to run this query 16 times, one for each link => term
* mapping table.
*/
$db->setQuery(
'INSERT INTO ' .
$db->quoteName('#__finder_links_terms' . $suffix) .
' (' . $db->quoteName('link_id') .
', ' . $db->quoteName('term_id') .
', ' . $db->quoteName('weight') . ')'
.
' SELECT ' . (int) $linkId . ', ' .
$db->quoteName('term_id') . ',' .
' ROUND(SUM(' . $db->quoteName('context_weight')
. '), 8)' .
' FROM ' .
$db->quoteName('#__finder_tokens_aggregate') .
' WHERE ' . $db->quoteName('map_suffix') .
' = ' . $db->quote($suffix) .
' GROUP BY term, term_id' .
' ORDER BY ' . $db->quoteName('term') . '
DESC'
);
$db->execute();
}
// Mark afterMapping in the profiler.
static::$profiler ? static::$profiler->mark('afterMapping')
: null;
// Update the signature.
$query->clear()
->update($db->quoteName('#__finder_links'))
->set($db->quoteName('md5sum') . ' = ' .
$db->quote($curSig))
->where($db->quoteName('link_id') . ' = ' .
$db->quote($linkId));
$db->setQuery($query);
$db->execute();
// Mark afterSigning in the profiler.
static::$profiler ? static::$profiler->mark('afterSigning')
: null;
// Truncate the tokens tables.
$db->truncateTable('#__finder_tokens');
// Truncate the tokens aggregate table.
$db->truncateTable('#__finder_tokens_aggregate');
// Toggle the token tables back to memory tables.
$this->toggleTables(true);
// Mark afterTruncating in the profiler.
static::$profiler ?
static::$profiler->mark('afterTruncating') : null;
return $linkId;
}
/**
* Method to remove a link from the index.
*
* @param integer $linkId The id of the link.
*
* @return boolean True on success.
*
* @since 3.1
* @throws Exception on database error.
*/
public function remove($linkId)
{
$db = $this->db;
$query = $db->getQuery(true);
// Update the link counts and remove the mapping records.
for ($i = 0; $i <= 15; $i++)
{
// Update the link counts for the terms.
$query->update('t')
->set('t.links = t.links - 1 from #__finder_terms AS t INNER
JOIN #__finder_links_terms' . dechex($i) . ' AS m ON m.term_id =
t.term_id')
->where('m.link_id = ' . $db->quote((int) $linkId));
$db->setQuery($query);
$db->execute();
// Remove all records from the mapping tables.
$query->clear()
->delete($db->quoteName('#__finder_links_terms' .
dechex($i)))
->where($db->quoteName('link_id') . ' = ' .
(int) $linkId);
$db->setQuery($query);
$db->execute();
}
// Delete all orphaned terms.
$query->clear()
->delete($db->quoteName('#__finder_terms'))
->where($db->quoteName('links') . ' <= 0');
$db->setQuery($query);
$db->execute();
// Delete the link from the index.
$query->clear()
->delete($db->quoteName('#__finder_links'))
->where($db->quoteName('link_id') . ' = ' .
$db->quote((int) $linkId));
$db->setQuery($query);
$db->execute();
// Remove the taxonomy maps.
FinderIndexerTaxonomy::removeMaps($linkId);
// Remove the orphaned taxonomy nodes.
FinderIndexerTaxonomy::removeOrphanNodes();
return true;
}
/**
* Method to optimize the index. We use this method to remove unused terms
* and any other optimizations that might be necessary.
*
* @return boolean True on success.
*
* @since 3.1
* @throws Exception on database error.
*/
public function optimize()
{
// Get the database object.
$db = $this->db;
$query = $db->getQuery(true);
// Delete all orphaned terms.
$query->delete($db->quoteName('#__finder_terms'))
->where($db->quoteName('links') . ' <= 0');
$db->setQuery($query);
$db->execute();
// Remove the orphaned taxonomy nodes.
FinderIndexerTaxonomy::removeOrphanNodes();
return true;
}
}
indexer/helper.php000064400000034264151156756060010217 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
JLoader::register('FinderIndexerParser', __DIR__ .
'/parser.php');
JLoader::register('FinderIndexerStemmer', __DIR__ .
'/stemmer.php');
JLoader::register('FinderIndexerToken', __DIR__ .
'/token.php');
/**
* Helper class for the Finder indexer package.
*
* @since 2.5
*/
class FinderIndexerHelper
{
/**
* The token stemmer object. The stemmer is set by whatever class
* wishes to use it but it must be an instance of FinderIndexerStemmer.
*
* @var FinderIndexerStemmer
* @since 2.5
*/
public static $stemmer;
/**
* A state flag, in order to not constantly check if the stemmer is an
instance of FinderIndexerStemmer
*
* @var boolean
* @since 3.7.0
*/
protected static $stemmerOK;
/**
* Method to parse input into plain text.
*
* @param string $input The raw input.
* @param string $format The format of the input. [optional]
*
* @return string The parsed input.
*
* @since 2.5
* @throws Exception on invalid parser.
*/
public static function parse($input, $format = 'html')
{
// Get a parser for the specified format and parse the input.
return FinderIndexerParser::getInstance($format)->parse($input);
}
/**
* Method to tokenize a text string.
*
* @param string $input The input to tokenize.
* @param string $lang The language of the input.
* @param boolean $phrase Flag to indicate whether input could be a
phrase. [optional]
*
* @return array|FinderIndexerToken An array of FinderIndexerToken
objects or a single FinderIndexerToken object.
*
* @since 2.5
*/
public static function tokenize($input, $lang, $phrase = false)
{
static $cache;
$store = StringHelper::strlen($input) < 128 ? md5($input .
'::' . $lang . '::' . $phrase) : null;
// Check if the string has been tokenized already.
if ($store && isset($cache[$store]))
{
return $cache[$store];
}
$tokens = array();
$quotes = html_entity_decode('‘’'',
ENT_QUOTES, 'UTF-8');
// Get the simple language key.
$lang = static::getPrimaryLanguage($lang);
/*
* Parsing the string input into terms is a multi-step process.
*
* Regexes:
* 1. Remove everything except letters, numbers, quotes, apostrophe,
plus, dash, period, and comma.
* 2. Remove plus, dash, period, and comma characters located before
letter characters.
* 3. Remove plus, dash, period, and comma characters located after
other characters.
* 4. Remove plus, period, and comma characters enclosed in alphabetical
characters. Ungreedy.
* 5. Remove orphaned apostrophe, plus, dash, period, and comma
characters.
* 6. Remove orphaned quote characters.
* 7. Replace the assorted single quotation marks with the ASCII
standard single quotation.
* 8. Remove multiple space characters and replaces with a single space.
*/
$input = StringHelper::strtolower($input);
$input =
preg_replace('#[^\pL\pM\pN\p{Pi}\p{Pf}\'+-.,]+#mui', '
', $input);
$input = preg_replace('#(^|\s)[+-.,]+([\pL\pM]+)#mui', '
$1', $input);
$input = preg_replace('#([\pL\pM\pN]+)[+-.,]+(\s|$)#mui',
'$1 ', $input);
$input = preg_replace('#([\pL\pM]+)[+.,]+([\pL\pM]+)#muiU',
'$1 $2', $input);
$input = preg_replace('#(^|\s)[\'+-.,]+(\s|$)#mui', '
', $input);
$input = preg_replace('#(^|\s)[\p{Pi}\p{Pf}]+(\s|$)#mui',
' ', $input);
$input = preg_replace('#[' . $quotes . ']+#mui',
'\'', $input);
$input = preg_replace('#\s+#mui', ' ', $input);
$input = trim($input);
// Explode the normalized string to get the terms.
$terms = explode(' ', $input);
/*
* If we have Unicode support and are dealing with Chinese text, Chinese
* has to be handled specially because there are not necessarily any
spaces
* between the "words". So, we have to test if the words belong
to the Chinese
* character set and if so, explode them into single glyphs or
"words".
*/
if ($lang === 'zh')
{
// Iterate through the terms and test if they contain Chinese.
for ($i = 0, $n = count($terms); $i < $n; $i++)
{
$charMatches = array();
$charCount = preg_match_all('#[\p{Han}]#mui', $terms[$i],
$charMatches);
// Split apart any groups of Chinese characters.
for ($j = 0; $j < $charCount; $j++)
{
$tSplit = StringHelper::str_ireplace($charMatches[0][$j],
'', $terms[$i], false);
if ((bool) $tSplit)
{
$terms[$i] = $tSplit;
}
else
{
unset($terms[$i]);
}
$terms[] = $charMatches[0][$j];
}
}
// Reset array keys.
$terms = array_values($terms);
}
/*
* If we have to handle the input as a phrase, that means we don't
* tokenize the individual terms and we do not create the two and three
* term combinations. The phrase must contain more than one word!
*/
if ($phrase === true && count($terms) > 1)
{
// Create tokens from the phrase.
$tokens[] = new FinderIndexerToken($terms, $lang);
}
else
{
// Create tokens from the terms.
for ($i = 0, $n = count($terms); $i < $n; $i++)
{
$tokens[] = new FinderIndexerToken($terms[$i], $lang);
}
// Create two and three word phrase tokens from the individual words.
for ($i = 0, $n = count($tokens); $i < $n; $i++)
{
// Setup the phrase positions.
$i2 = $i + 1;
$i3 = $i + 2;
// Create the two word phrase.
if ($i2 < $n && isset($tokens[$i2]))
{
// Tokenize the two word phrase.
$token = new FinderIndexerToken(
array(
$tokens[$i]->term,
$tokens[$i2]->term
), $lang, $lang === 'zh' ? '' : ' '
);
$token->derived = true;
// Add the token to the stack.
$tokens[] = $token;
}
// Create the three word phrase.
if ($i3 < $n && isset($tokens[$i3]))
{
// Tokenize the three word phrase.
$token = new FinderIndexerToken(
array(
$tokens[$i]->term,
$tokens[$i2]->term,
$tokens[$i3]->term
), $lang, $lang === 'zh' ? '' : ' '
);
$token->derived = true;
// Add the token to the stack.
$tokens[] = $token;
}
}
}
if ($store)
{
$cache[$store] = count($tokens) > 1 ? $tokens : array_shift($tokens);
return $cache[$store];
}
else
{
return count($tokens) > 1 ? $tokens : array_shift($tokens);
}
}
/**
* Method to get the base word of a token. This method uses the public
* {@link FinderIndexerHelper::$stemmer} object if it is set. If no
stemmer is set,
* the original token is returned.
*
* @param string $token The token to stem.
* @param string $lang The language of the token.
*
* @return string The root token.
*
* @since 2.5
*/
public static function stem($token, $lang)
{
// Trim apostrophes at either end of the token.
$token = trim($token, '\'');
// Trim everything after any apostrophe in the token.
if ($res = explode('\'', $token))
{
$token = $res[0];
}
if (static::$stemmerOK === true)
{
return static::$stemmer->stem($token, $lang);
}
else
{
// Stem the token if we have a valid stemmer to use.
if (static::$stemmer instanceof FinderIndexerStemmer)
{
static::$stemmerOK = true;
return static::$stemmer->stem($token, $lang);
}
}
return $token;
}
/**
* Method to add a content type to the database.
*
* @param string $title The type of content. For example: PDF
* @param string $mime The mime type of the content. For example: PDF
[optional]
*
* @return integer The id of the content type.
*
* @since 2.5
* @throws Exception on database error.
*/
public static function addContentType($title, $mime = null)
{
static $types;
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Check if the types are loaded.
if (empty($types))
{
// Build the query to get the types.
$query->select('*')
->from($db->quoteName('#__finder_types'));
// Get the types.
$db->setQuery($query);
$types = $db->loadObjectList('title');
}
// Check if the type already exists.
if (isset($types[$title]))
{
return (int) $types[$title]->id;
}
// Add the type.
$query->clear()
->insert($db->quoteName('#__finder_types'))
->columns(array($db->quoteName('title'),
$db->quoteName('mime')))
->values($db->quote($title) . ', ' .
$db->quote($mime));
$db->setQuery($query);
$db->execute();
// Return the new id.
return (int) $db->insertid();
}
/**
* Method to check if a token is common in a language.
*
* @param string $token The token to test.
* @param string $lang The language to reference.
*
* @return boolean True if common, false otherwise.
*
* @since 2.5
*/
public static function isCommon($token, $lang)
{
static $data;
static $default;
$langCode = $lang;
// If language requested is wildcard, use the default language.
if ($default === null && $lang === '*')
{
$default = strstr(self::getDefaultLanguage(), '-', true);
$langCode = $default;
}
// Load the common tokens for the language if necessary.
if (!isset($data[$langCode]))
{
$data[$langCode] = self::getCommonWords($langCode);
}
// Check if the token is in the common array.
return in_array($token, $data[$langCode], true);
}
/**
* Method to get an array of common terms for a language.
*
* @param string $lang The language to use.
*
* @return array Array of common terms.
*
* @since 2.5
* @throws Exception on database error.
*/
public static function getCommonWords($lang)
{
$db = JFactory::getDbo();
// Create the query to load all the common terms for the language.
$query = $db->getQuery(true)
->select($db->quoteName('term'))
->from($db->quoteName('#__finder_terms_common'))
->where($db->quoteName('language') . ' = ' .
$db->quote($lang));
// Load all of the common terms for the language.
$db->setQuery($query);
return $db->loadColumn();
}
/**
* Method to get the default language for the site.
*
* @return string The default language string.
*
* @since 2.5
*/
public static function getDefaultLanguage()
{
static $lang;
// We need to go to com_languages to get the site default language,
it's the best we can guess.
if (empty($lang))
{
$lang =
JComponentHelper::getParams('com_languages')->get('site',
'en-GB');
}
return $lang;
}
/**
* Method to parse a language/locale key and return a simple language
string.
*
* @param string $lang The language/locale key. For example: en-GB
*
* @return string The simple language string. For example: en
*
* @since 2.5
*/
public static function getPrimaryLanguage($lang)
{
static $data;
// Only parse the identifier if necessary.
if (!isset($data[$lang]))
{
if (is_callable(array('Locale',
'getPrimaryLanguage')))
{
// Get the language key using the Locale package.
$data[$lang] = Locale::getPrimaryLanguage($lang);
}
else
{
// Get the language key using string position.
$data[$lang] = StringHelper::substr($lang, 0,
StringHelper::strpos($lang, '-'));
}
}
return $data[$lang];
}
/**
* Method to get the path (SEF route) for a content item.
*
* @param string $url The non-SEF route to the content item.
*
* @return string The path for the content item.
*
* @since 2.5
* @deprecated 4.0
*/
public static function getContentPath($url)
{
static $router;
// Only get the router once.
if (!($router instanceof JRouter))
{
// Get and configure the site router.
$config = JFactory::getConfig();
$router = JRouter::getInstance('site');
$router->setMode($config->get('sef', 1));
}
// Build the relative route.
$uri = $router->build($url);
$route = $uri->toString(array('path', 'query',
'fragment'));
$route = str_replace(JUri::base(true) . '/', '',
$route);
return $route;
}
/**
* Method to get extra data for a content before being indexed. This is
how
* we add Comments, Tags, Labels, etc. that should be available to Finder.
*
* @param FinderIndexerResult $item The item to index as a
FinderIndexerResult object.
*
* @return boolean True on success, false on failure.
*
* @since 2.5
* @throws Exception on database error.
*/
public static function getContentExtras(FinderIndexerResult $item)
{
// Get the event dispatcher.
$dispatcher = JEventDispatcher::getInstance();
// Load the finder plugin group.
JPluginHelper::importPlugin('finder');
// Trigger the event.
$results = $dispatcher->trigger('onPrepareFinderContent',
array(&$item));
// Check the returned results. This is for plugins that don't throw
// exceptions when they encounter serious errors.
if (in_array(false, $results))
{
throw new Exception($dispatcher->getError(), 500);
}
return true;
}
/**
* Method to process content text using the onContentPrepare event
trigger.
*
* @param string $text The content to process.
* @param Registry $params The parameters object.
[optional]
* @param FinderIndexerResult $item The item which get prepared.
[optional]
*
* @return string The processed content.
*
* @since 2.5
*/
public static function prepareContent($text, $params = null,
FinderIndexerResult $item = null)
{
static $loaded;
// Get the dispatcher.
$dispatcher = JEventDispatcher::getInstance();
// Load the content plugins if necessary.
if (empty($loaded))
{
JPluginHelper::importPlugin('content');
$loaded = true;
}
// Instantiate the parameter object if necessary.
if (!($params instanceof Registry))
{
$registry = new Registry($params);
$params = $registry;
}
// Create a mock content object.
$content = JTable::getInstance('Content');
$content->text = $text;
if ($item)
{
$content->bind((array) $item);
$content->bind($item->getElements());
}
if ($item && !empty($item->context))
{
$content->context = $item->context;
}
// Fire the onContentPrepare event.
$dispatcher->trigger('onContentPrepare',
array('com_finder.indexer', &$content, &$params, 0));
return $content->text;
}
}
indexer/indexer.php000064400000035254151156756060010376 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\String\StringHelper;
JLoader::register('FinderIndexerHelper', __DIR__ .
'/helper.php');
JLoader::register('FinderIndexerParser', __DIR__ .
'/parser.php');
JLoader::register('FinderIndexerStemmer', __DIR__ .
'/stemmer.php');
JLoader::register('FinderIndexerTaxonomy', __DIR__ .
'/taxonomy.php');
JLoader::register('FinderIndexerToken', __DIR__ .
'/token.php');
jimport('joomla.filesystem.file');
/**
* Main indexer class for the Finder indexer package.
*
* The indexer class provides the core functionality of the Finder
* search engine. It is responsible for adding and updating the
* content links table; extracting and scoring tokens; and maintaining
* all referential information for the content.
*
* Note: All exceptions thrown from within this class should be caught
* by the controller.
*
* @since 2.5
*/
abstract class FinderIndexer
{
/**
* The title context identifier.
*
* @var integer
* @since 2.5
*/
const TITLE_CONTEXT = 1;
/**
* The text context identifier.
*
* @var integer
* @since 2.5
*/
const TEXT_CONTEXT = 2;
/**
* The meta context identifier.
*
* @var integer
* @since 2.5
*/
const META_CONTEXT = 3;
/**
* The path context identifier.
*
* @var integer
* @since 2.5
*/
const PATH_CONTEXT = 4;
/**
* The misc context identifier.
*
* @var integer
* @since 2.5
*/
const MISC_CONTEXT = 5;
/**
* The indexer state object.
*
* @var JObject
* @since 2.5
*/
public static $state;
/**
* The indexer profiler object.
*
* @var JProfiler
* @since 2.5
*/
public static $profiler;
/**
* Database driver cache.
*
* @var JDatabaseDriver
* @since 3.8.0
*/
protected $db;
/**
* Reusable Query Template. To be used with clone.
*
* @var JDatabaseQuery
* @since 3.8.0
*/
protected $addTokensToDbQueryTemplate;
/**
* FinderIndexer constructor.
*
* @since 3.8.0
*/
public function __construct()
{
$this->db = JFactory::getDbo();
$db = $this->db;
/**
* Set up query template for addTokensToDb, we will be cloning this
template when needed.
* This is about twice as fast as calling the clear function or setting
up a new object.
*/
$this->addTokensToDbQueryTemplate =
$db->getQuery(true)->insert($db->quoteName('#__finder_tokens'))
->columns(
array(
$db->quoteName('term'),
$db->quoteName('stem'),
$db->quoteName('common'),
$db->quoteName('phrase'),
$db->quoteName('weight'),
$db->quoteName('context'),
$db->quoteName('language')
)
);
}
/**
* Returns a reference to the FinderIndexer object.
*
* @return FinderIndexer instance based on the database driver
*
* @since 3.0
* @throws RuntimeException if driver class for indexer not present.
*/
public static function getInstance()
{
// Setup the adapter for the indexer.
$serverType = JFactory::getDbo()->getServerType();
// For `mssql` server types, convert the type to `sqlsrv`
if ($serverType === 'mssql')
{
$serverType = 'sqlsrv';
}
$path = __DIR__ . '/driver/' . $serverType . '.php';
$class = 'FinderIndexerDriver' . ucfirst($serverType);
// Check if a parser exists for the format.
if (file_exists($path))
{
// Instantiate the parser.
JLoader::register($class, $path);
return new $class;
}
// Throw invalid format exception.
throw new
RuntimeException(JText::sprintf('COM_FINDER_INDEXER_INVALID_DRIVER',
$serverType));
}
/**
* Method to get the indexer state.
*
* @return object The indexer state object.
*
* @since 2.5
*/
public static function getState()
{
// First, try to load from the internal state.
if ((bool) static::$state)
{
return static::$state;
}
// If we couldn't load from the internal state, try the session.
$session = JFactory::getSession();
$data = $session->get('_finder.state', null);
// If the state is empty, load the values for the first time.
if (empty($data))
{
$data = new JObject;
// Load the default configuration options.
$data->options = JComponentHelper::getParams('com_finder');
// Setup the weight lookup information.
$data->weights = array(
self::TITLE_CONTEXT =>
round($data->options->get('title_multiplier', 1.7), 2),
self::TEXT_CONTEXT =>
round($data->options->get('text_multiplier', 0.7), 2),
self::META_CONTEXT =>
round($data->options->get('meta_multiplier', 1.2), 2),
self::PATH_CONTEXT =>
round($data->options->get('path_multiplier', 2.0), 2),
self::MISC_CONTEXT =>
round($data->options->get('misc_multiplier', 0.3), 2)
);
// Set the current time as the start time.
$data->startTime = JFactory::getDate()->toSql();
// Set the remaining default values.
$data->batchSize = (int)
$data->options->get('batch_size', 50);
$data->batchOffset = 0;
$data->totalItems = 0;
$data->pluginState = array();
}
// Setup the profiler if debugging is enabled.
if (JFactory::getApplication()->get('debug'))
{
static::$profiler = JProfiler::getInstance('FinderIndexer');
}
// Setup the stemmer.
if ($data->options->get('stem', 1) &&
$data->options->get('stemmer', 'porter_en'))
{
FinderIndexerHelper::$stemmer =
FinderIndexerStemmer::getInstance($data->options->get('stemmer',
'porter_en'));
}
// Set the state.
static::$state = $data;
return static::$state;
}
/**
* Method to set the indexer state.
*
* @param object $data A new indexer state object.
*
* @return boolean True on success, false on failure.
*
* @since 2.5
*/
public static function setState($data)
{
// Check the state object.
if (empty($data) || !$data instanceof JObject)
{
return false;
}
// Set the new internal state.
static::$state = $data;
// Set the new session state.
JFactory::getSession()->set('_finder.state', $data);
return true;
}
/**
* Method to reset the indexer state.
*
* @return void
*
* @since 2.5
*/
public static function resetState()
{
// Reset the internal state to null.
self::$state = null;
// Reset the session state to null.
JFactory::getSession()->set('_finder.state', null);
}
/**
* Method to index a content item.
*
* @param FinderIndexerResult $item The content item to index.
* @param string $format The format of the content.
[optional]
*
* @return integer The ID of the record in the links table.
*
* @since 2.5
* @throws Exception on database error.
*/
abstract public function index($item, $format = 'html');
/**
* Method to remove a link from the index.
*
* @param integer $linkId The id of the link.
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function remove($linkId)
{
$db = $this->db;
$query = $db->getQuery(true);
// Update the link counts and remove the mapping records.
for ($i = 0; $i <= 15; $i++)
{
// Update the link counts for the terms.
$query->clear()
->update($db->quoteName('#__finder_terms',
't'))
->join('INNER',
$db->quoteName('#__finder_links_terms' . dechex($i),
'm') .
' ON ' . $db->quoteName('m.term_id') . ' =
' . $db->quoteName('t.term_id')
)
->set($db->quoteName('links') . ' = ' .
$db->quoteName('links') . ' - 1')
->where($db->quoteName('m.link_id') . ' = ' .
(int) $linkId);
$db->setQuery($query)->execute();
// Remove all records from the mapping tables.
$query->clear()
->delete($db->quoteName('#__finder_links_terms' .
dechex($i)))
->where($db->quoteName('link_id') . ' = ' .
(int) $linkId);
$db->setQuery($query)->execute();
}
// Delete all orphaned terms.
$query->clear()
->delete($db->quoteName('#__finder_terms'))
->where($db->quoteName('links') . ' <= 0');
$db->setQuery($query)->execute();
// Delete the link from the index.
$query->clear()
->delete($db->quoteName('#__finder_links'))
->where($db->quoteName('link_id') . ' = ' .
(int) $linkId);
$db->setQuery($query)->execute();
// Remove the taxonomy maps.
FinderIndexerTaxonomy::removeMaps($linkId);
// Remove the orphaned taxonomy nodes.
FinderIndexerTaxonomy::removeOrphanNodes();
return true;
}
/**
* Method to optimize the index. We use this method to remove unused terms
* and any other optimizations that might be necessary.
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
abstract public function optimize();
/**
* Method to get a content item's signature.
*
* @param object $item The content item to index.
*
* @return string The content item's signature.
*
* @since 2.5
*/
protected static function getSignature($item)
{
// Get the indexer state.
$state = static::getState();
// Get the relevant configuration variables.
$config = array(
$state->weights,
$state->options->get('stem', 1),
$state->options->get('stemmer', 'porter_en')
);
return md5(serialize(array($item, $config)));
}
/**
* Method to parse input, tokenize it, and then add it to the database.
*
* @param mixed $input String or resource to use as input. A
resource input will automatically be chunked to conserve
* memory. Strings will be chunked if longer
than 2K in size.
* @param integer $context The context of the input. See context
constants.
* @param string $lang The language of the input.
* @param string $format The format of the input.
*
* @return integer The number of tokens extracted from the input.
*
* @since 2.5
*/
protected function tokenizeToDb($input, $context, $lang, $format)
{
$count = 0;
$buffer = null;
if (empty($input))
{
return $count;
}
// If the input is a resource, batch the process out.
if (is_resource($input))
{
// Batch the process out to avoid memory limits.
while (!feof($input))
{
// Read into the buffer.
$buffer .= fread($input, 2048);
/*
* If we haven't reached the end of the file, seek to the last
* space character and drop whatever is after that to make sure
* we didn't truncate a term while reading the input.
*/
if (!feof($input))
{
// Find the last space character.
$ls = strrpos($buffer, ' ');
// Adjust string based on the last space character.
if ($ls)
{
// Truncate the string to the last space character.
$string = substr($buffer, 0, $ls);
// Adjust the buffer based on the last space for the next iteration
and trim.
$buffer = StringHelper::trim(substr($buffer, $ls));
}
// No space character was found.
else
{
$string = $buffer;
}
}
// We've reached the end of the file, so parse whatever remains.
else
{
$string = $buffer;
}
// Parse, tokenise and add tokens to the database.
$count = $this->tokenizeToDbShort($string, $context, $lang, $format,
$count);
unset($string, $tokens);
}
return $count;
}
// Parse, tokenise and add tokens to the database.
$count = $this->tokenizeToDbShort($input, $context, $lang, $format,
$count);
return $count;
}
/**
* Method to parse input, tokenise it, then add the tokens to the
database.
*
* @param string $input String to parse, tokenise and add to
database.
* @param integer $context The context of the input. See context
constants.
* @param string $lang The language of the input.
* @param string $format The format of the input.
* @param integer $count The number of tokens processed so far.
*
* @return integer Cumulative number of tokens extracted from the input
so far.
*
* @since 3.7.0
*/
private function tokenizeToDbShort($input, $context, $lang, $format,
$count)
{
// Parse the input.
$input = FinderIndexerHelper::parse($input, $format);
// Check the input.
if (empty($input))
{
return $count;
}
// Tokenize the input.
$tokens = FinderIndexerHelper::tokenize($input, $lang);
// Add the tokens to the database.
$count += $this->addTokensToDb($tokens, $context);
// Check if we're approaching the memory limit of the token table.
if ($count >
static::$state->options->get('memory_table_limit', 30000))
{
$this->toggleTables(false);
}
return $count;
}
/**
* Method to add a set of tokens to the database.
*
* @param mixed $tokens An array or single FinderIndexerToken object.
* @param mixed $context The context of the tokens. See context
constants. [optional]
*
* @return integer The number of tokens inserted into the database.
*
* @since 2.5
* @throws Exception on database error.
*/
protected function addTokensToDb($tokens, $context = '')
{
// Get the database object.
$db = $this->db;
// Count the number of token values.
$values = 0;
if (($tokens instanceof FinderIndexerToken) === false)
{
// Break into chunks of no more than 1000 items
$chunks = count($tokens) > 1000
? array_chunk($tokens, 1000)
: array($tokens);
foreach ($chunks as $chunkTokens)
{
// Cloning a new query template is twice as fast as calling the clear
function
$query = clone $this->addTokensToDbQueryTemplate;
// Iterate through the tokens to create SQL value sets.
foreach ($chunkTokens as $token)
{
$query->values(
$db->quote($token->term) . ', '
. $db->quote($token->stem) . ', '
. (int) $token->common . ', '
. (int) $token->phrase . ', '
. $db->escape((float) $token->weight) . ', '
. (int) $context . ', '
. $db->quote($token->language)
);
++$values;
}
$db->setQuery($query)->execute();
}
}
else
{
$query = clone $this->addTokensToDbQueryTemplate;
$query->values(
$db->quote($tokens->term) . ', '
. $db->quote($tokens->stem) . ', '
. (int) $tokens->common . ', '
. (int) $tokens->phrase . ', '
. $db->escape((float) $tokens->weight) . ', '
. (int) $context . ', '
. $db->quote($tokens->language)
);
++$values;
$db->setQuery($query)->execute();
}
return $values;
}
/**
* Method to switch the token tables from Memory tables to Disk tables
* when they are close to running out of memory.
* Since this is not supported/implemented in all DB-drivers, the default
is a stub method, which simply returns true.
*
* @param boolean $memory Flag to control how they should be toggled.
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
protected function toggleTables($memory)
{
return true;
}
}
indexer/parser/html.php000064400000010573151156756060011175
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('FinderIndexerParser', dirname(__DIR__) .
'/parser.php');
/**
* HTML Parser class for the Finder indexer package.
*
* @since 2.5
*/
class FinderIndexerParserHtml extends FinderIndexerParser
{
/**
* Method to parse input and extract the plain text. Because this method
is
* called from both inside and outside the indexer, it needs to be able to
* batch out its parsing functionality to deal with the inefficiencies of
* regular expressions. We will parse recursively in 2KB chunks.
*
* @param string $input The input to parse.
*
* @return string The plain text input.
*
* @since 2.5
*/
public function parse($input)
{
// Strip invalid UTF-8 characters.
$input = iconv('utf-8', 'utf-8//IGNORE', $input);
// Remove anything between <head> and </head> tags. Do this
first
// because there might be <script> or <style> tags nested
inside.
$input = $this->removeBlocks($input, '<head>',
'</head>');
// Convert <style> and <noscript> tags to <script> tags
// so we can remove them efficiently.
$search = array(
'<style', '</style',
'<noscript', '</noscript',
);
$replace = array(
'<script', '</script',
'<script', '</script',
);
$input = str_replace($search, $replace, $input);
// Strip all script blocks.
$input = $this->removeBlocks($input, '<script',
'</script>');
// Decode HTML entities.
$input = html_entity_decode($input, ENT_QUOTES, 'UTF-8');
// Convert entities equivalent to spaces to actual spaces.
$input = str_replace(array(' ',
' '), ' ', $input);
// Add a space before both the OPEN and CLOSE tags of BLOCK and LINE
BREAKING elements,
// e.g. 'all<h1><em>m</em>obile
List</h1>' will become 'all mobile List'
$input = preg_replace('/(<|<\/)(' .
'address|article|aside|blockquote|br|canvas|dd|div|dl|dt|' .
'fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hgroup|hr|li|'
.
'main|nav|noscript|ol|output|p|pre|section|table|tfoot|ul|video'
.
')\b/i', ' $1$2', $input
);
// Strip HTML tags.
$input = strip_tags($input);
return parent::parse($input);
}
/**
* Method to process HTML input and extract the plain text.
*
* @param string $input The input to process.
*
* @return string The plain text input.
*
* @since 2.5
*/
protected function process($input)
{
// Replace any amount of white space with a single space.
return preg_replace('#\s+#u', ' ', $input);
}
/**
* Method to remove blocks of text between a start and an end tag.
* Each block removed is effectively replaced by a single space.
*
* Note: The start tag and the end tag must be different.
* Note: Blocks must not be nested.
* Note: This method will function correctly with multi-byte strings.
*
* @param string $input String to be processed.
* @param string $startTag String representing the start tag.
* @param string $endTag String representing the end tag.
*
* @return string with blocks removed.
*
* @since 3.4
*/
private function removeBlocks($input, $startTag, $endTag)
{
$return = '';
$offset = 0;
$startTagLength = strlen($startTag);
$endTagLength = strlen($endTag);
// Find the first start tag.
$start = stripos($input, $startTag);
// If no start tags were found, return the string unchanged.
if ($start === false)
{
return $input;
}
// Look for all blocks defined by the start and end tags.
while ($start !== false)
{
// Accumulate the substring up to the start tag.
$return .= substr($input, $offset, $start - $offset) . ' ';
// Look for an end tag corresponding to the start tag.
$end = stripos($input, $endTag, $start + $startTagLength);
// If no corresponding end tag, leave the string alone.
if ($end === false)
{
// Fix the offset so part of the string is not duplicated.
$offset = $start;
break;
}
// Advance the start position.
$offset = $end + $endTagLength;
// Look for the next start tag and loop.
$start = stripos($input, $startTag, $offset);
}
// Add in the final substring after the last end tag.
$return .= substr($input, $offset);
return $return;
}
}
indexer/parser/rtf.php000064400000002055151156756060011020 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('FinderIndexerParser', dirname(__DIR__) .
'/parser.php');
/**
* RTF Parser class for the Finder indexer package.
*
* @since 2.5
*/
class FinderIndexerParserRtf extends FinderIndexerParser
{
/**
* Method to process RTF input and extract the plain text.
*
* @param string $input The input to process.
*
* @return string The plain text input.
*
* @since 2.5
*/
protected function process($input)
{
// Remove embedded pictures.
$input = preg_replace('#{\\\pict[^}]*}#mi', '',
$input);
// Remove control characters.
$input = str_replace(array('{', '}',
"\\\n"), array(' ', ' ', "\n"),
$input);
$input = preg_replace('#\\\([^;]+?);#m', ' ',
$input);
$input = preg_replace('#\\\[\'a-zA-Z0-9]+#mi', '
', $input);
return $input;
}
}
indexer/parser/txt.php000064400000001353151156756060011044 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('FinderIndexerParser', dirname(__DIR__) .
'/parser.php');
/**
* Text Parser class for the Finder indexer package.
*
* @since 2.5
*/
class FinderIndexerParserTxt extends FinderIndexerParser
{
/**
* Method to process Text input and extract the plain text.
*
* @param string $input The input to process.
*
* @return string The plain text input.
*
* @since 2.5
*/
protected function process($input)
{
return $input;
}
}
indexer/parser.php000064400000005734151156756060010234 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Parser base class for the Finder indexer package.
*
* @since 2.5
*/
abstract class FinderIndexerParser
{
/**
* Method to get a parser, creating it if necessary.
*
* @param string $format The type of parser to load.
*
* @return FinderIndexerParser A FinderIndexerParser instance.
*
* @since 2.5
* @throws Exception on invalid parser.
*/
public static function getInstance($format)
{
static $instances;
// Only create one parser for each format.
if (isset($instances[$format]))
{
return $instances[$format];
}
// Create an array of instances if necessary.
if (!is_array($instances))
{
$instances = array();
}
// Setup the adapter for the parser.
$format = JFilterInput::getInstance()->clean($format,
'cmd');
$path = __DIR__ . '/parser/' . $format . '.php';
$class = 'FinderIndexerParser' . ucfirst($format);
// Check if a parser exists for the format.
if (!file_exists($path))
{
// Throw invalid format exception.
throw new
Exception(JText::sprintf('COM_FINDER_INDEXER_INVALID_PARSER',
$format));
}
// Instantiate the parser.
JLoader::register($class, $path);
$instances[$format] = new $class;
return $instances[$format];
}
/**
* Method to parse input and extract the plain text. Because this method
is
* called from both inside and outside the indexer, it needs to be able to
* batch out its parsing functionality to deal with the inefficiencies of
* regular expressions. We will parse recursively in 2KB chunks.
*
* @param string $input The input to parse.
*
* @return string The plain text input.
*
* @since 2.5
*/
public function parse($input)
{
// If the input is less than 2KB we can parse it in one go.
if (strlen($input) <= 2048)
{
return $this->process($input);
}
// Input is longer than 2Kb so parse it in chunks of 2Kb or less.
$start = 0;
$end = strlen($input);
$chunk = 2048;
$return = null;
while ($start < $end)
{
// Setup the string.
$string = substr($input, $start, $chunk);
// Find the last space character if we aren't at the end.
$ls = (($start + $chunk) < $end ? strrpos($string, ' ') :
false);
// Truncate to the last space character.
if ($ls !== false)
{
$string = substr($string, 0, $ls);
}
// Adjust the start position for the next iteration.
$start += ($ls !== false ? ($ls + 1 - $chunk) + $chunk : $chunk);
// Parse the chunk.
$return .= $this->process($string);
}
return $return;
}
/**
* Method to process input and extract the plain text.
*
* @param string $input The input to process.
*
* @return string The plain text input.
*
* @since 2.5
*/
abstract protected function process($input);
}
indexer/query.php000064400000105714151156756060010104 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
JLoader::register('FinderIndexerHelper', __DIR__ .
'/helper.php');
JLoader::register('FinderIndexerTaxonomy', __DIR__ .
'/taxonomy.php');
JLoader::register('FinderHelperRoute', JPATH_SITE .
'/components/com_finder/helpers/route.php');
JLoader::register('FinderHelperLanguage', JPATH_ADMINISTRATOR .
'/components/com_finder/helpers/language.php');
/**
* Query class for the Finder indexer package.
*
* @since 2.5
*/
class FinderIndexerQuery
{
/**
* Flag to show whether the query can return results.
*
* @var boolean
* @since 2.5
*/
public $search;
/**
* The query input string.
*
* @var string
* @since 2.5
*/
public $input;
/**
* The language of the query.
*
* @var string
* @since 2.5
*/
public $language;
/**
* The query string matching mode.
*
* @var string
* @since 2.5
*/
public $mode;
/**
* The included tokens.
*
* @var array
* @since 2.5
*/
public $included = array();
/**
* The excluded tokens.
*
* @var array
* @since 2.5
*/
public $excluded = array();
/**
* The tokens to ignore because no matches exist.
*
* @var array
* @since 2.5
*/
public $ignored = array();
/**
* The operators used in the query input string.
*
* @var array
* @since 2.5
*/
public $operators = array();
/**
* The terms to highlight as matches.
*
* @var array
* @since 2.5
*/
public $highlight = array();
/**
* The number of matching terms for the query input.
*
* @var integer
* @since 2.5
*/
public $terms;
/**
* The static filter id.
*
* @var string
* @since 2.5
*/
public $filter;
/**
* The taxonomy filters. This is a multi-dimensional array of taxonomy
* branches as the first level and then the taxonomy nodes as the values.
*
* For example:
* $filters = array(
* 'Type' = array(10, 32, 29, 11, ...);
* 'Label' = array(20, 314, 349, 91, 82, ...);
* ...
* );
*
* @var array
* @since 2.5
*/
public $filters = array();
/**
* The start date filter.
*
* @var string
* @since 2.5
*/
public $date1;
/**
* The end date filter.
*
* @var string
* @since 2.5
*/
public $date2;
/**
* The start date filter modifier.
*
* @var string
* @since 2.5
*/
public $when1;
/**
* The end date filter modifier.
*
* @var string
* @since 2.5
*/
public $when2;
/**
* Method to instantiate the query object.
*
* @param array $options An array of query options.
*
* @since 2.5
* @throws Exception on database error.
*/
public function __construct($options)
{
// Get the input string.
$this->input = isset($options['input']) ?
$options['input'] : null;
// Get the empty query setting.
$this->empty = isset($options['empty']) ? (bool)
$options['empty'] : false;
// Get the input language.
$this->language = !empty($options['language']) ?
$options['language'] : FinderIndexerHelper::getDefaultLanguage();
$this->language =
FinderIndexerHelper::getPrimaryLanguage($this->language);
// Get the matching mode.
$this->mode = 'AND';
// Initialize the temporary date storage.
$this->dates = new Registry;
// Populate the temporary date storage.
if (!empty($options['date1']))
{
$this->dates->set('date1', $options['date1']);
}
if (!empty($options['date2']))
{
$this->dates->set('date2', $options['date2']);
}
if (!empty($options['when1']))
{
$this->dates->set('when1', $options['when1']);
}
if (!empty($options['when2']))
{
$this->dates->set('when2', $options['when2']);
}
// Process the static taxonomy filters.
if (!empty($options['filter']))
{
$this->processStaticTaxonomy($options['filter']);
}
// Process the dynamic taxonomy filters.
if (!empty($options['filters']))
{
$this->processDynamicTaxonomy($options['filters']);
}
// Get the date filters.
$d1 = $this->dates->get('date1');
$d2 = $this->dates->get('date2');
$w1 = $this->dates->get('when1');
$w2 = $this->dates->get('when2');
// Process the date filters.
if (!empty($d1) || !empty($d2))
{
$this->processDates($d1, $d2, $w1, $w2);
}
// Process the input string.
$this->processString($this->input, $this->language,
$this->mode);
// Get the number of matching terms.
foreach ($this->included as $token)
{
$this->terms += count($token->matches);
}
// Remove the temporary date storage.
unset($this->dates);
// Lastly, determine whether this query can return a result set.
// Check if we have a query string.
if (!empty($this->input))
{
$this->search = true;
}
// Check if we can search without a query string.
elseif ($this->empty && (!empty($this->filter) ||
!empty($this->filters) || !empty($this->date1) ||
!empty($this->date2)))
{
$this->search = true;
}
// We do not have a valid search query.
else
{
$this->search = false;
}
}
/**
* Method to convert the query object into a URI string.
*
* @param string $base The base URI. [optional]
*
* @return string The complete query URI.
*
* @since 2.5
*/
public function toUri($base = '')
{
// Set the base if not specified.
if ($base === '')
{
$base = 'index.php?option=com_finder&view=search';
}
// Get the base URI.
$uri = JUri::getInstance($base);
// Add the static taxonomy filter if present.
if ((bool) $this->filter)
{
$uri->setVar('f', $this->filter);
}
// Get the filters in the request.
$t =
JFactory::getApplication()->input->request->get('t',
array(), 'array');
// Add the dynamic taxonomy filters if present.
if ((bool) $this->filters)
{
foreach ($this->filters as $nodes)
{
foreach ($nodes as $node)
{
if (!in_array($node, $t))
{
continue;
}
$uri->setVar('t[]', $node);
}
}
}
// Add the input string if present.
if (!empty($this->input))
{
$uri->setVar('q', $this->input);
}
// Add the start date if present.
if (!empty($this->date1))
{
$uri->setVar('d1', $this->date1);
}
// Add the end date if present.
if (!empty($this->date2))
{
$uri->setVar('d2', $this->date2);
}
// Add the start date modifier if present.
if (!empty($this->when1))
{
$uri->setVar('w1', $this->when1);
}
// Add the end date modifier if present.
if (!empty($this->when2))
{
$uri->setVar('w2', $this->when2);
}
// Add a menu item id if one is not present.
if (!$uri->getVar('Itemid'))
{
// Get the menu item id.
$query = array(
'view' => $uri->getVar('view'),
'f' => $uri->getVar('f'),
'q' => $uri->getVar('q'),
);
$item = FinderHelperRoute::getItemid($query);
// Add the menu item id if present.
if ($item !== null)
{
$uri->setVar('Itemid', $item);
}
}
return $uri->toString(array('path', 'query'));
}
/**
* Method to get a list of excluded search term ids.
*
* @return array An array of excluded term ids.
*
* @since 2.5
*/
public function getExcludedTermIds()
{
$results = array();
// Iterate through the excluded tokens and compile the matching terms.
for ($i = 0, $c = count($this->excluded); $i < $c; $i++)
{
$results = array_merge($results, $this->excluded[$i]->matches);
}
// Sanitize the terms.
$results = array_unique($results);
return ArrayHelper::toInteger($results);
}
/**
* Method to get a list of included search term ids.
*
* @return array An array of included term ids.
*
* @since 2.5
*/
public function getIncludedTermIds()
{
$results = array();
// Iterate through the included tokens and compile the matching terms.
for ($i = 0, $c = count($this->included); $i < $c; $i++)
{
// Check if we have any terms.
if (empty($this->included[$i]->matches))
{
continue;
}
// Get the term.
$term = $this->included[$i]->term;
// Prepare the container for the term if necessary.
if (!array_key_exists($term, $results))
{
$results[$term] = array();
}
// Add the matches to the stack.
$results[$term] = array_merge($results[$term],
$this->included[$i]->matches);
}
// Sanitize the terms.
foreach ($results as $key => $value)
{
$results[$key] = array_unique($results[$key]);
$results[$key] = ArrayHelper::toInteger($results[$key]);
}
return $results;
}
/**
* Method to get a list of required search term ids.
*
* @return array An array of required term ids.
*
* @since 2.5
*/
public function getRequiredTermIds()
{
$results = array();
// Iterate through the included tokens and compile the matching terms.
for ($i = 0, $c = count($this->included); $i < $c; $i++)
{
// Check if the token is required.
if ($this->included[$i]->required)
{
// Get the term.
$term = $this->included[$i]->term;
// Prepare the container for the term if necessary.
if (!array_key_exists($term, $results))
{
$results[$term] = array();
}
// Add the matches to the stack.
$results[$term] = array_merge($results[$term],
$this->included[$i]->matches);
}
}
// Sanitize the terms.
foreach ($results as $key => $value)
{
$results[$key] = array_unique($results[$key]);
$results[$key] = ArrayHelper::toInteger($results[$key]);
}
return $results;
}
/**
* Method to process the static taxonomy input. The static taxonomy input
* comes in the form of a pre-defined search filter that is assigned to
the
* search form.
*
* @param integer $filterId The id of static filter.
*
* @return boolean True on success, false on failure.
*
* @since 2.5
* @throws Exception on database error.
*/
protected function processStaticTaxonomy($filterId)
{
// Get the database object.
$db = JFactory::getDbo();
// Initialize user variables
$groups = implode(',',
JFactory::getUser()->getAuthorisedViewLevels());
// Load the predefined filter.
$query = $db->getQuery(true)
->select('f.data, f.params')
->from($db->quoteName('#__finder_filters') . ' AS
f')
->where('f.filter_id = ' . (int) $filterId);
$db->setQuery($query);
$return = $db->loadObject();
// Check the returned filter.
if (empty($return))
{
return false;
}
// Set the filter.
$this->filter = (int) $filterId;
// Get a parameter object for the filter date options.
$registry = new Registry($return->params);
$params = $registry;
// Set the dates if not already set.
$this->dates->def('d1', $params->get('d1'));
$this->dates->def('d2', $params->get('d2'));
$this->dates->def('w1', $params->get('w1'));
$this->dates->def('w2', $params->get('w2'));
// Remove duplicates and sanitize.
$filters = explode(',', $return->data);
$filters = array_unique($filters);
$filters = ArrayHelper::toInteger($filters);
// Remove any values of zero.
if (in_array(0, $filters, true) !== false)
{
unset($filters[array_search(0, $filters, true)]);
}
// Check if we have any real input.
if (empty($filters))
{
return true;
}
/*
* Create the query to get filters from the database. We do this for
* two reasons: one, it allows us to ensure that the filters being used
* are real; two, we need to sort the filters by taxonomy branch.
*/
$query->clear()
->select('t1.id, t1.title, t2.title AS branch')
->from($db->quoteName('#__finder_taxonomy') . ' AS
t1')
->join('INNER',
$db->quoteName('#__finder_taxonomy') . ' AS t2 ON t2.id =
t1.parent_id')
->where('t1.state = 1')
->where('t1.access IN (' . $groups . ')')
->where('t1.id IN (' . implode(',', $filters) .
')')
->where('t2.state = 1')
->where('t2.access IN (' . $groups . ')');
// Load the filters.
$db->setQuery($query);
$results = $db->loadObjectList();
// Sort the filter ids by branch.
foreach ($results as $result)
{
$this->filters[$result->branch][$result->title] = (int)
$result->id;
}
return true;
}
/**
* Method to process the dynamic taxonomy input. The dynamic taxonomy
input
* comes in the form of select fields that the user chooses from. The
* dynamic taxonomy input is processed AFTER the static taxonomy input
* because the dynamic options can be used to further narrow a static
* taxonomy filter.
*
* @param array $filters An array of taxonomy node ids.
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
protected function processDynamicTaxonomy($filters)
{
// Initialize user variables
$groups = implode(',',
JFactory::getUser()->getAuthorisedViewLevels());
// Remove duplicates and sanitize.
$filters = array_unique($filters);
$filters = ArrayHelper::toInteger($filters);
// Remove any values of zero.
if (in_array(0, $filters, true) !== false)
{
unset($filters[array_search(0, $filters, true)]);
}
// Check if we have any real input.
if (empty($filters))
{
return true;
}
// Get the database object.
$db = JFactory::getDbo();
$query = $db->getQuery(true);
/*
* Create the query to get filters from the database. We do this for
* two reasons: one, it allows us to ensure that the filters being used
* are real; two, we need to sort the filters by taxonomy branch.
*/
$query->select('t1.id, t1.title, t2.title AS branch')
->from($db->quoteName('#__finder_taxonomy') . ' AS
t1')
->join('INNER',
$db->quoteName('#__finder_taxonomy') . ' AS t2 ON t2.id =
t1.parent_id')
->where('t1.state = 1')
->where('t1.access IN (' . $groups . ')')
->where('t1.id IN (' . implode(',', $filters) .
')')
->where('t2.state = 1')
->where('t2.access IN (' . $groups . ')');
// Load the filters.
$db->setQuery($query);
$results = $db->loadObjectList();
// Cleared filter branches.
$cleared = array();
/*
* Sort the filter ids by branch. Because these filters are designed to
* override and further narrow the items selected in the static filter,
* we will clear the values from the static filter on a branch by
* branch basis before adding the dynamic filters. So, if the static
* filter defines a type filter of "articles" and three
"category"
* filters but the user only limits the category further, the category
* filters will be flushed but the type filters will not.
*/
foreach ($results as $result)
{
// Check if the branch has been cleared.
if (!in_array($result->branch, $cleared, true))
{
// Clear the branch.
$this->filters[$result->branch] = array();
// Add the branch to the cleared list.
$cleared[] = $result->branch;
}
// Add the filter to the list.
$this->filters[$result->branch][$result->title] = (int)
$result->id;
}
return true;
}
/**
* Method to process the query date filters to determine start and end
* date limitations.
*
* @param string $date1 The first date filter.
* @param string $date2 The second date filter.
* @param string $when1 The first date modifier.
* @param string $when2 The second date modifier.
*
* @return boolean True on success.
*
* @since 2.5
*/
protected function processDates($date1, $date2, $when1, $when2)
{
// Clean up the inputs.
$date1 = trim(StringHelper::strtolower($date1));
$date2 = trim(StringHelper::strtolower($date2));
$when1 = trim(StringHelper::strtolower($when1));
$when2 = trim(StringHelper::strtolower($when2));
// Get the time offset.
$offset = JFactory::getApplication()->get('offset');
// Array of allowed when values.
$whens = array('before', 'after', 'exact');
// The value of 'today' is a special case that we need to
handle.
if ($date1 ===
StringHelper::strtolower(JText::_('COM_FINDER_QUERY_FILTER_TODAY')))
{
$date1 = JFactory::getDate('now',
$offset)->format('%Y-%m-%d');
}
// Try to parse the date string.
$date = JFactory::getDate($date1, $offset);
// Check if the date was parsed successfully.
if ($date->toUnix() !== null)
{
// Set the date filter.
$this->date1 = $date->toSql();
$this->when1 = in_array($when1, $whens, true) ? $when1 :
'before';
}
// The value of 'today' is a special case that we need to
handle.
if ($date2 ===
StringHelper::strtolower(JText::_('COM_FINDER_QUERY_FILTER_TODAY')))
{
$date2 = JFactory::getDate('now',
$offset)->format('%Y-%m-%d');
}
// Try to parse the date string.
$date = JFactory::getDate($date2, $offset);
// Check if the date was parsed successfully.
if ($date->toUnix() !== null)
{
// Set the date filter.
$this->date2 = $date->toSql();
$this->when2 = in_array($when2, $whens, true) ? $when2 :
'before';
}
return true;
}
/**
* Method to process the query input string and extract required,
optional,
* and excluded tokens; taxonomy filters; and date filters.
*
* @param string $input The query input string.
* @param string $lang The query input language.
* @param string $mode The query matching mode.
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
protected function processString($input, $lang, $mode)
{
// Clean up the input string.
$input = html_entity_decode($input, ENT_QUOTES, 'UTF-8');
$input = StringHelper::strtolower($input);
$input = preg_replace('#\s+#mi', ' ', $input);
$input = trim($input);
$debug = JFactory::getConfig()->get('debug_lang');
/*
* First, we need to handle string based modifiers. String based
* modifiers could potentially include things like
"category:blah" or
* "before:2009-10-21" or "type:article", etc.
*/
$patterns = array(
'before' =>
JText::_('COM_FINDER_FILTER_WHEN_BEFORE'),
'after' =>
JText::_('COM_FINDER_FILTER_WHEN_AFTER'),
);
// Add the taxonomy branch titles to the possible patterns.
foreach (FinderIndexerTaxonomy::getBranchTitles() as $branch)
{
// Add the pattern.
$patterns[$branch] =
StringHelper::strtolower(JText::_(FinderHelperLanguage::branchSingular($branch)));
}
// Container for search terms and phrases.
$terms = array();
$phrases = array();
// Cleared filter branches.
$cleared = array();
/*
* Compile the suffix pattern. This is used to match the values of the
* filter input string. Single words can be input directly, multi-word
* values have to be wrapped in double quotes.
*/
$quotes = html_entity_decode('‘’'',
ENT_QUOTES, 'UTF-8');
$suffix = '(([\w\d' . $quotes .
'-]+)|\"([\w\d\s' . $quotes . '-]+)\")';
/*
* Iterate through the possible filter patterns and search for matches.
* We need to match the key, colon, and a value pattern for the match
* to be valid.
*/
foreach ($patterns as $modifier => $pattern)
{
$matches = array();
if ($debug)
{
$pattern = substr($pattern, 2, -2);
}
// Check if the filter pattern is in the input string.
if (preg_match('#' . $pattern . '\s*:\s*' . $suffix
. '#mi', $input, $matches))
{
// Get the value given to the modifier.
$value = isset($matches[3]) ? $matches[3] : $matches[1];
// Now we have to handle the filter string.
switch ($modifier)
{
// Handle a before and after date filters.
case 'before':
case 'after':
{
// Get the time offset.
$offset = JFactory::getApplication()->get('offset');
// Array of allowed when values.
$whens = array('before', 'after',
'exact');
// The value of 'today' is a special case that we need to
handle.
if ($value ===
StringHelper::strtolower(JText::_('COM_FINDER_QUERY_FILTER_TODAY')))
{
$value = JFactory::getDate('now',
$offset)->format('%Y-%m-%d');
}
// Try to parse the date string.
$date = JFactory::getDate($value, $offset);
// Check if the date was parsed successfully.
if ($date->toUnix() !== null)
{
// Set the date filter.
$this->date1 = $date->toSql();
$this->when1 = in_array($modifier, $whens, true) ? $modifier :
'before';
}
break;
}
// Handle a taxonomy branch filter.
default:
{
// Try to find the node id.
$return = FinderIndexerTaxonomy::getNodeByTitle($modifier, $value);
// Check if the node id was found.
if ($return)
{
// Check if the branch has been cleared.
if (!in_array($modifier, $cleared, true))
{
// Clear the branch.
$this->filters[$modifier] = array();
// Add the branch to the cleared list.
$cleared[] = $modifier;
}
// Add the filter to the list.
$this->filters[$modifier][$return->title] = (int)
$return->id;
}
break;
}
}
// Clean up the input string again.
$input = str_replace($matches[0], '', $input);
$input = preg_replace('#\s+#mi', ' ', $input);
$input = trim($input);
}
}
/*
* Extract the tokens enclosed in double quotes so that we can handle
* them as phrases.
*/
if (StringHelper::strpos($input, '"') !== false)
{
$matches = array();
// Extract the tokens enclosed in double quotes.
if (preg_match_all('#\"([^"]+)\"#m', $input,
$matches))
{
/*
* One or more phrases were found so we need to iterate through
* them, tokenize them as phrases, and remove them from the raw
* input string before we move on to the next processing step.
*/
foreach ($matches[1] as $key => $match)
{
// Find the complete phrase in the input string.
$pos = StringHelper::strpos($input, $matches[0][$key]);
$len = StringHelper::strlen($matches[0][$key]);
// Add any terms that are before this phrase to the stack.
if (trim(StringHelper::substr($input, 0, $pos)))
{
$terms = array_merge($terms, explode(' ',
trim(StringHelper::substr($input, 0, $pos))));
}
// Strip out everything up to and including the phrase.
$input = StringHelper::substr($input, $pos + $len);
// Clean up the input string again.
$input = preg_replace('#\s+#mi', ' ', $input);
$input = trim($input);
// Get the number of words in the phrase.
$parts = explode(' ', $match);
// Check if the phrase is longer than three words.
if (count($parts) > 3)
{
/*
* If the phrase is longer than three words, we need to
* break it down into smaller chunks of phrases that
* are less than or equal to three words. We overlap
* the chunks so that we can ensure that a match is
* found for the complete phrase and not just portions
* of it.
*/
for ($i = 0, $c = count($parts); $i < $c; $i += 2)
{
// Set up the chunk.
$chunk = array();
// The chunk has to be assembled based on how many
// pieces are available to use.
switch ($c - $i)
{
/*
* If only one word is left, we can break from
* the switch and loop because the last word
* was already used at the end of the last
* chunk.
*/
case 1:
break 2;
// If there words are left, we use them both as
// the last chunk of the phrase and we're done.
case 2:
$chunk[] = $parts[$i];
$chunk[] = $parts[$i + 1];
break;
// If there are three or more words left, we
// build a three word chunk and continue on.
default:
$chunk[] = $parts[$i];
$chunk[] = $parts[$i + 1];
$chunk[] = $parts[$i + 2];
break;
}
// If the chunk is not empty, add it as a phrase.
if (count($chunk))
{
$phrases[] = implode(' ', $chunk);
$terms[] = implode(' ', $chunk);
}
}
}
else
{
// The phrase is <= 3 words so we can use it as is.
$phrases[] = $match;
$terms[] = $match;
}
}
}
}
// Add the remaining terms if present.
if ((bool) $input)
{
$terms = array_merge($terms, explode(' ', $input));
}
// An array of our boolean operators. $operator => $translation
$operators = array(
'AND' =>
StringHelper::strtolower(JText::_('COM_FINDER_QUERY_OPERATOR_AND')),
'OR' =>
StringHelper::strtolower(JText::_('COM_FINDER_QUERY_OPERATOR_OR')),
'NOT' =>
StringHelper::strtolower(JText::_('COM_FINDER_QUERY_OPERATOR_NOT')),
);
// If language debugging is enabled you need to ignore the debug strings
in matching.
if (JDEBUG)
{
$debugStrings = array('**', '??');
$operators = str_replace($debugStrings, '', $operators);
}
/*
* Iterate through the terms and perform any sorting that needs to be
* done based on boolean search operators. Terms that are before an
* and/or/not modifier have to be handled in relation to their operator.
*/
for ($i = 0, $c = count($terms); $i < $c; $i++)
{
// Check if the term is followed by an operator that we understand.
if (isset($terms[$i + 1]) && in_array($terms[$i + 1],
$operators, true))
{
// Get the operator mode.
$op = array_search($terms[$i + 1], $operators, true);
// Handle the AND operator.
if ($op === 'AND' && isset($terms[$i + 2]))
{
// Tokenize the current term.
$token = FinderIndexerHelper::tokenize($terms[$i], $lang, true);
// Todo: The previous function call may return an array, which seems
not to be handled by the next one, which expects an object
$token = $this->getTokenData($token);
// Set the required flag.
$token->required = true;
// Add the current token to the stack.
$this->included[] = $token;
$this->highlight = array_merge($this->highlight,
array_keys($token->matches));
// Skip the next token (the mode operator).
$this->operators[] = $terms[$i + 1];
// Tokenize the term after the next term (current plus two).
$other = FinderIndexerHelper::tokenize($terms[$i + 2], $lang, true);
$other = $this->getTokenData($other);
// Set the required flag.
$other->required = true;
// Add the token after the next token to the stack.
$this->included[] = $other;
$this->highlight = array_merge($this->highlight,
array_keys($other->matches));
// Remove the processed phrases if possible.
if (($pk = array_search($terms[$i], $phrases, true)) !== false)
{
unset($phrases[$pk]);
}
if (($pk = array_search($terms[$i + 2], $phrases, true)) !== false)
{
unset($phrases[$pk]);
}
// Remove the processed terms.
unset($terms[$i], $terms[$i + 1], $terms[$i + 2]);
// Adjust the loop.
$i += 2;
continue;
}
// Handle the OR operator.
elseif ($op === 'OR' && isset($terms[$i + 2]))
{
// Tokenize the current term.
$token = FinderIndexerHelper::tokenize($terms[$i], $lang, true);
$token = $this->getTokenData($token);
// Set the required flag.
$token->required = false;
// Add the current token to the stack.
if ((bool) $token->matches)
{
$this->included[] = $token;
$this->highlight = array_merge($this->highlight,
array_keys($token->matches));
}
else
{
$this->ignored[] = $token;
}
// Skip the next token (the mode operator).
$this->operators[] = $terms[$i + 1];
// Tokenize the term after the next term (current plus two).
$other = FinderIndexerHelper::tokenize($terms[$i + 2], $lang, true);
$other = $this->getTokenData($other);
// Set the required flag.
$other->required = false;
// Add the token after the next token to the stack.
if ((bool) $other->matches)
{
$this->included[] = $other;
$this->highlight = array_merge($this->highlight,
array_keys($other->matches));
}
else
{
$this->ignored[] = $other;
}
// Remove the processed phrases if possible.
if (($pk = array_search($terms[$i], $phrases, true)) !== false)
{
unset($phrases[$pk]);
}
if (($pk = array_search($terms[$i + 2], $phrases, true)) !== false)
{
unset($phrases[$pk]);
}
// Remove the processed terms.
unset($terms[$i], $terms[$i + 1], $terms[$i + 2]);
// Adjust the loop.
$i += 2;
continue;
}
}
// Handle an orphaned OR operator.
elseif (isset($terms[$i + 1]) && array_search($terms[$i],
$operators, true) === 'OR')
{
// Skip the next token (the mode operator).
$this->operators[] = $terms[$i];
// Tokenize the next term (current plus one).
$other = FinderIndexerHelper::tokenize($terms[$i + 1], $lang, true);
$other = $this->getTokenData($other);
// Set the required flag.
$other->required = false;
// Add the token after the next token to the stack.
if ((bool) $other->matches)
{
$this->included[] = $other;
$this->highlight = array_merge($this->highlight,
array_keys($other->matches));
}
else
{
$this->ignored[] = $other;
}
// Remove the processed phrase if possible.
if (($pk = array_search($terms[$i + 1], $phrases, true)) !== false)
{
unset($phrases[$pk]);
}
// Remove the processed terms.
unset($terms[$i], $terms[$i + 1]);
// Adjust the loop.
$i++;
continue;
}
// Handle the NOT operator.
elseif (isset($terms[$i + 1]) && array_search($terms[$i],
$operators, true) === 'NOT')
{
// Skip the next token (the mode operator).
$this->operators[] = $terms[$i];
// Tokenize the next term (current plus one).
$other = FinderIndexerHelper::tokenize($terms[$i + 1], $lang, true);
$other = $this->getTokenData($other);
// Set the required flag.
$other->required = false;
// Add the next token to the stack.
if ((bool) $other->matches)
{
$this->excluded[] = $other;
}
else
{
$this->ignored[] = $other;
}
// Remove the processed phrase if possible.
if (($pk = array_search($terms[$i + 1], $phrases, true)) !== false)
{
unset($phrases[$pk]);
}
// Remove the processed terms.
unset($terms[$i], $terms[$i + 1]);
// Adjust the loop.
$i++;
continue;
}
}
/*
* Iterate through any search phrases and tokenize them. We handle
* phrases as autonomous units and do not break them down into two and
* three word combinations.
*/
for ($i = 0, $c = count($phrases); $i < $c; $i++)
{
// Tokenize the phrase.
$token = FinderIndexerHelper::tokenize($phrases[$i], $lang, true);
$token = $this->getTokenData($token);
// Set the required flag.
$token->required = true;
// Add the current token to the stack.
$this->included[] = $token;
$this->highlight = array_merge($this->highlight,
array_keys($token->matches));
// Remove the processed term if possible.
if (($pk = array_search($phrases[$i], $terms, true)) !== false)
{
unset($terms[$pk]);
}
// Remove the processed phrase.
unset($phrases[$i]);
}
/*
* Handle any remaining tokens using the standard processing mechanism.
*/
if ((bool) $terms)
{
// Tokenize the terms.
$terms = implode(' ', $terms);
$tokens = FinderIndexerHelper::tokenize($terms, $lang, false);
// Make sure we are working with an array.
$tokens = is_array($tokens) ? $tokens : array($tokens);
// Get the token data and required state for all the tokens.
foreach ($tokens as $token)
{
// Get the token data.
$token = $this->getTokenData($token);
// Set the required flag for the token.
$token->required = $mode === 'AND' ? (!$token->phrase)
: false;
// Add the token to the appropriate stack.
if ($token->required || (bool) $token->matches)
{
$this->included[] = $token;
$this->highlight = array_merge($this->highlight,
array_keys($token->matches));
}
else
{
$this->ignored[] = $token;
}
}
}
return true;
}
/**
* Method to get the base and similar term ids and, if necessary,
suggested
* term data from the database. The terms ids are identified based on a
* 'like' match in MySQL and/or a common stem. If no term ids
could be
* found, then we know that we will not be able to return any results for
* that term and we should try to find a similar term to use that we can
* match so that we can suggest the alternative search query to the user.
*
* @param FinderIndexerToken $token A FinderIndexerToken object.
*
* @return FinderIndexerToken A FinderIndexerToken object.
*
* @since 2.5
* @throws Exception on database error.
*/
protected function getTokenData($token)
{
// Get the database object.
$db = JFactory::getDbo();
// Create a database query to build match the token.
$query = $db->getQuery(true)
->select('t.term, t.term_id')
->from('#__finder_terms AS t');
/*
* If the token is a phrase, the lookup process is fairly simple. If
* the token is a word, it is a little more complicated. We have to
* create two queries to lookup the term and the stem respectively,
* then union the result sets together. This is MUCH faster than using
* an or condition in the database query.
*/
if ($token->phrase)
{
// Add the phrase to the query.
$query->where('t.term = ' . $db->quote($token->term))
->where('t.phrase = 1');
}
else
{
// Add the term to the query.
$query->where('t.term = ' . $db->quote($token->term))
->where('t.phrase = 0');
// Clone the query, replace the WHERE clause.
$sub = clone $query;
$sub->clear('where');
$sub->where('t.stem = ' . $db->quote($token->stem));
$sub->where('t.phrase = 0');
// Union the two queries.
$query->union($sub);
}
// Get the terms.
$db->setQuery($query);
$matches = $db->loadObjectList();
// Check the matching terms.
if ((bool) $matches)
{
// Add the matches to the token.
for ($i = 0, $c = count($matches); $i < $c; $i++)
{
$token->matches[$matches[$i]->term] = (int)
$matches[$i]->term_id;
}
}
// If no matches were found, try to find a similar but better token.
if (empty($token->matches))
{
// Create a database query to get the similar terms.
// TODO: PostgreSQL doesn't support SOUNDEX out of the box
$query->clear()
->select('DISTINCT t.term_id AS id, t.term AS term')
->from('#__finder_terms AS t')
// ->where('t.soundex = ' .
soundex($db->quote($token->term)))
->where('t.soundex = SOUNDEX(' .
$db->quote($token->term) . ')')
->where('t.phrase = ' . (int) $token->phrase);
// Get the terms.
$db->setQuery($query);
$results = $db->loadObjectList();
// Check if any similar terms were found.
if (empty($results))
{
return $token;
}
// Stack for sorting the similar terms.
$suggestions = array();
// Get the levnshtein distance for all suggested terms.
foreach ($results as $sk => $st)
{
// Get the levenshtein distance between terms.
$distance = levenshtein($st->term, $token->term);
// Make sure the levenshtein distance isn't over 50.
if ($distance < 50)
{
$suggestions[$sk] = $distance;
}
}
// Sort the suggestions.
asort($suggestions, SORT_NUMERIC);
// Get the closest match.
$keys = array_keys($suggestions);
$key = $keys[0];
// Add the suggested term.
$token->suggestion = $results[$key]->term;
}
return $token;
}
}
indexer/result.php000064400000021036151156756060010247 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('FinderIndexer', __DIR__ .
'/indexer.php');
/**
* Result class for the Finder indexer package.
*
* This class uses magic __get() and __set() methods to prevent properties
* being added that might confuse the system. All properties not explicitly
* declared will be pushed into the elements array and can be accessed
* explicitly using the getElement() method.
*
* @since 2.5
*/
class FinderIndexerResult
{
/**
* An array of extra result properties.
*
* @var array
* @since 2.5
*/
protected $elements = array();
/**
* This array tells the indexer which properties should be indexed and
what
* weights to use for those properties.
*
* @var array
* @since 2.5
*/
protected $instructions = array(
FinderIndexer::TITLE_CONTEXT => array('title',
'subtitle', 'id'),
FinderIndexer::TEXT_CONTEXT => array('summary',
'body'),
FinderIndexer::META_CONTEXT => array('meta',
'list_price', 'sale_price'),
FinderIndexer::PATH_CONTEXT => array('path',
'alias'),
FinderIndexer::MISC_CONTEXT => array('comments'),
);
/**
* The indexer will use this data to create taxonomy mapping entries for
* the item so that it can be filtered by type, label, category,
* or whatever.
*
* @var array
* @since 2.5
*/
protected $taxonomy = array();
/**
* The content URL.
*
* @var string
* @since 2.5
*/
public $url;
/**
* The content route.
*
* @var string
* @since 2.5
*/
public $route;
/**
* The content title.
*
* @var string
* @since 2.5
*/
public $title;
/**
* The content description.
*
* @var string
* @since 2.5
*/
public $description;
/**
* The published state of the result.
*
* @var integer
* @since 2.5
*/
public $published;
/**
* The content published state.
*
* @var integer
* @since 2.5
*/
public $state;
/**
* The content access level.
*
* @var integer
* @since 2.5
*/
public $access;
/**
* The content language.
*
* @var string
* @since 2.5
*/
public $language = '*';
/**
* The publishing start date.
*
* @var string
* @since 2.5
*/
public $publish_start_date;
/**
* The publishing end date.
*
* @var string
* @since 2.5
*/
public $publish_end_date;
/**
* The generic start date.
*
* @var string
* @since 2.5
*/
public $start_date;
/**
* The generic end date.
*
* @var string
* @since 2.5
*/
public $end_date;
/**
* The item list price.
*
* @var mixed
* @since 2.5
*/
public $list_price;
/**
* The item sale price.
*
* @var mixed
* @since 2.5
*/
public $sale_price;
/**
* The content type id. This is set by the adapter.
*
* @var integer
* @since 2.5
*/
public $type_id;
/**
* The default language for content.
*
* @var string
* @since 3.0.2
*/
public $defaultLanguage;
/**
* Constructor
*
* @since 3.0.3
*/
public function __construct()
{
$this->defaultLanguage =
JComponentHelper::getParams('com_languages')->get('site',
'en-GB');
}
/**
* The magic set method is used to push additional values into the
elements
* array in order to preserve the cleanliness of the object.
*
* @param string $name The name of the element.
* @param mixed $value The value of the element.
*
* @return void
*
* @since 2.5
*/
public function __set($name, $value)
{
$this->setElement($name, $value);
}
/**
* The magic get method is used to retrieve additional element values from
the elements array.
*
* @param string $name The name of the element.
*
* @return mixed The value of the element if set, null otherwise.
*
* @since 2.5
*/
public function __get($name)
{
return $this->getElement($name);
}
/**
* The magic isset method is used to check the state of additional element
values in the elements array.
*
* @param string $name The name of the element.
*
* @return boolean True if set, false otherwise.
*
* @since 2.5
*/
public function __isset($name)
{
return isset($this->elements[$name]);
}
/**
* The magic unset method is used to unset additional element values in
the elements array.
*
* @param string $name The name of the element.
*
* @return void
*
* @since 2.5
*/
public function __unset($name)
{
unset($this->elements[$name]);
}
/**
* Method to retrieve additional element values from the elements array.
*
* @param string $name The name of the element.
*
* @return mixed The value of the element if set, null otherwise.
*
* @since 2.5
*/
public function getElement($name)
{
// Get the element value if set.
if (array_key_exists($name, $this->elements))
{
return $this->elements[$name];
}
return null;
}
/**
* Method to retrieve all elements.
*
* @return array The elements
*
* @since 3.8.3
*/
public function getElements()
{
return $this->elements;
}
/**
* Method to set additional element values in the elements array.
*
* @param string $name The name of the element.
* @param mixed $value The value of the element.
*
* @return void
*
* @since 2.5
*/
public function setElement($name, $value)
{
$this->elements[$name] = $value;
}
/**
* Method to get all processing instructions.
*
* @return array An array of processing instructions.
*
* @since 2.5
*/
public function getInstructions()
{
return $this->instructions;
}
/**
* Method to add a processing instruction for an item property.
*
* @param string $group The group to associate the property with.
* @param string $property The property to process.
*
* @return void
*
* @since 2.5
*/
public function addInstruction($group, $property)
{
// Check if the group exists. We can't add instructions for unknown
groups.
// Check if the property exists in the group.
if (array_key_exists($group, $this->instructions) &&
!in_array($property, $this->instructions[$group], true))
{
// Add the property to the group.
$this->instructions[$group][] = $property;
}
}
/**
* Method to remove a processing instruction for an item property.
*
* @param string $group The group to associate the property with.
* @param string $property The property to process.
*
* @return void
*
* @since 2.5
*/
public function removeInstruction($group, $property)
{
// Check if the group exists. We can't remove instructions for
unknown groups.
if (array_key_exists($group, $this->instructions))
{
// Search for the property in the group.
$key = array_search($property, $this->instructions[$group]);
// If the property was found, remove it.
if ($key !== false)
{
unset($this->instructions[$group][$key]);
}
}
}
/**
* Method to get the taxonomy maps for an item.
*
* @param string $branch The taxonomy branch to get. [optional]
*
* @return array An array of taxonomy maps.
*
* @since 2.5
*/
public function getTaxonomy($branch = null)
{
// Get the taxonomy branch if available.
if ($branch !== null && isset($this->taxonomy[$branch]))
{
// Filter the input.
$branch =
preg_replace('#[^\pL\pM\pN\p{Pi}\p{Pf}\'+-.,_]+#mui', '
', $branch);
return $this->taxonomy[$branch];
}
return $this->taxonomy;
}
/**
* Method to add a taxonomy map for an item.
*
* @param string $branch The title of the taxonomy branch to add the
node to.
* @param string $title The title of the taxonomy node.
* @param integer $state The published state of the taxonomy node.
[optional]
* @param integer $access The access level of the taxonomy node.
[optional]
*
* @return void
*
* @since 2.5
*/
public function addTaxonomy($branch, $title, $state = 1, $access = 1)
{
// Filter the input.
$branch =
preg_replace('#[^\pL\pM\pN\p{Pi}\p{Pf}\'+-.,_]+#mui', '
', $branch);
// Create the taxonomy node.
$node = new JObject;
$node->title = $title;
$node->state = (int) $state;
$node->access = (int) $access;
// Add the node to the taxonomy branch.
$this->taxonomy[$branch][$node->title] = $node;
}
/**
* Method to set the item language
*
* @return void
*
* @since 3.0
*/
public function setLanguage()
{
if ($this->language == '')
{
$this->language = $this->defaultLanguage;
}
}
}
indexer/stemmer/fr.php000064400000024150151156756060011014 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('FinderIndexerStemmer', dirname(__DIR__) .
'/stemmer.php');
/**
* French stemmer class for Smart Search indexer.
*
* First contributed by Eric Sanou (bobotche@hotmail.fr)
* This class is inspired in Alexis Ulrich's French stemmer code
(http://alx2002.free.fr)
*
* @since 3.0
*/
class FinderIndexerStemmerFr extends FinderIndexerStemmer
{
/**
* Stemming rules.
*
* @var array
* @since 3.0
*/
private static $stemRules;
/**
* Method to stem a token and return the root.
*
* @param string $token The token to stem.
* @param string $lang The language of the token.
*
* @return string The root token.
*
* @since 3.0
*/
public function stem($token, $lang)
{
// Check if the token is long enough to merit stemming.
if (strlen($token) <= 2)
{
return $token;
}
// Check if the language is French or All.
if ($lang !== 'fr' && $lang !== '*')
{
return $token;
}
// Stem the token if it is not in the cache.
if (!isset($this->cache[$lang][$token]))
{
// Stem the token.
$result = self::getStem($token);
// Add the token to the cache.
$this->cache[$lang][$token] = $result;
}
return $this->cache[$lang][$token];
}
/**
* French stemmer rules variables.
*
* @return array The rules
*
* @since 3.0
*/
protected static function getStemRules()
{
if (self::$stemRules)
{
return self::$stemRules;
}
$vars = array();
// French accented letters in ISO-8859-1 encoding
$vars['accents'] = chr(224) . chr(226) . chr(232) . chr(233) .
chr(234) . chr(235) . chr(238) . chr(239)
. chr(244) . chr(251) . chr(249) . chr(231);
// The rule patterns include all accented words for french language
$vars['rule_pattern'] = '/^([a-z' .
$vars['accents'] . ']*)(\*){0,1}(\d)([a-z' .
$vars['accents'] . ']*)([.|>])/';
// French vowels (including y) in ISO-8859-1 encoding
$vars['vowels'] = chr(97) . chr(224) . chr(226) . chr(101) .
chr(232) . chr(233) . chr(234) . chr(235)
. chr(105) . chr(238) . chr(239) . chr(111) . chr(244) . chr(117) .
chr(251) . chr(249) . chr(121);
// The French rules in ISO-8859-1 encoding
$vars['rules'] = array(
'esre1>', 'esio1>', 'siol1.',
'siof0.', 'sioe0.', 'sio3>',
'st1>', 'sf1>', 'sle1>',
'slo1>', 's' . chr(233) . '1>',
chr(233) . 'tuae5.',
chr(233) . 'tuae2.', 'tnia0.', 'tniv1.',
'tni3>', 'suor1.', 'suo0.',
'sdrail5.', 'sdrai4.', 'er' . chr(232) .
'i1>', 'sesue3x>',
'esuey5i.', 'esue2x>', 'se1>',
'er' . chr(232) . 'g3.', 'eca1>',
'esiah0.', 'esi1>', 'siss2.',
'sir2>', 'sit2>', 'egan' . chr(233) .
'1.',
'egalli6>', 'egass1.', 'egas0.',
'egat3.', 'ega3>', 'ette4>',
'ett2>', 'etio1.', 'tio' . chr(231) .
'4c.', 'tio0.', 'et1>',
'eb1>',
'snia1>', 'eniatnau8>', 'eniatn4.',
'enia1>', 'niatnio3.', 'niatg3.',
'e' . chr(233) . '1>', chr(233) .
'hcat1.', chr(233) . 'hca4.',
chr(233) . 'tila5>', chr(233) . 'tici5.',
chr(233) . 'tir1.', chr(233) . 'ti3>', chr(233) .
'gan1.', chr(233) . 'ga3>',
chr(233) . 'tehc1.', chr(233) . 'te3>', chr(233)
. 'it0.', chr(233) . '1>', 'eire4.',
'eirue5.', 'eio1.', 'eia1.',
'ei1>', 'eng1.',
'xuaessi7.', 'xuae1>', 'uaes0.',
'uae3.', 'xuave2l.', 'xuav2li>',
'xua3la>', 'ela1>', 'lart2.',
'lani2>', 'la' . chr(233) . '2>',
'siay4i.', 'siassia7.', 'siarv1*.',
'sia1>', 'tneiayo6i.', 'tneiay6i.',
'tneiassia9.', 'tneiareio7.', 'tneia5>',
'tneia4>', 'tiario4.',
'tiarim3.', 'tiaria3.', 'tiaris3.',
'tiari5.', 'tiarve6>', 'tiare5>',
'iare4>', 'are3>', 'tiay4i.',
'tia3>', 'tnay4i.',
'em' . chr(232) . 'iu5>', 'em' .
chr(232) . 'i4>', 'tnaun3.', 'tnauqo3.',
'tnau4>', 'tnaf0.', 'tnat' . chr(233) .
'2>', 'tna3>', 'tno3>',
'zeiy4i.', 'zey3i.', 'zeire5>',
'zeird4.', 'zeirio4.', 'ze2>',
'ssiab0.', 'ssia4.', 'ssi3.',
'tnemma6>', 'tnemesuey9i.',
'tnemesue8>',
'tnemevi7.', 'tnemessia5.', 'tnemessi8.',
'tneme5>', 'tnemia4.', 'tnem' . chr(233) .
'5>', 'el2l>', 'lle3le>',
'let' . chr(244) . '0.',
'lepp0.', 'le2>', 'srei1>',
'reit3.', 'reila2.', 'rei3>',
'ert' . chr(226) . 'e5.', 'ert' . chr(226) .
chr(233) . '1.',
'ert' . chr(226) . '4.', 'drai4.',
'erdro0.', 'erute5.', 'ruta0.',
'eruta1.', 'erutiov1.', 'erub3.',
'eruh3.', 'erul3.', 'er2r>',
'nn1>',
'r' . chr(232) . 'i3.', 'srev0.',
'sr1>', 'rid2>', 're2>',
'xuei4.', 'esuei5.', 'lbati3.',
'lba3>', 'rueis0.', 'ruehcn4.',
'ecirta6.',
'ruetai6.', 'rueta5.', 'rueir0.',
'rue3>', 'esseti6.', 'essere6>',
'esserd1.', 'esse4>', 'essiab1.',
'essia5.', 'essio1.', 'essi4.',
'essal4.', 'essa1>', 'ssab1.',
'essurp1.', 'essu4.', 'essi1.',
'ssor1.', 'essor2.', 'esso1>',
'ess2>', 'tio3.', 'r' . chr(232) .
's2re.',
'r' . chr(232) . '0e.', 'esn1.',
'eu1>', 'sua0.', 'su1>',
'utt1>', 'tu' . chr(231) . '3c.',
'u' . chr(231) . '2c.', 'ur1.',
'ehcn2>',
'ehcu1>', 'snorr3.', 'snoru3.',
'snorua3.', 'snorv3.', 'snorio4.',
'snori5.', 'snore5>', 'snortt4>',
'snort' . chr(238) . 'a7.', 'snort3.',
'snor4.', 'snossi6.', 'snoire6.',
'snoird5.', 'snoitai7.', 'snoita6.',
'snoits1>', 'noits0.', 'snoi4>',
'noitaci7>', 'noitai6.', 'noita5.',
'noitu4.', 'noi3>', 'snoya0.',
'snoy4i.', 'sno' . chr(231) . 'a1.',
'sno' . chr(231) . 'r1.', 'snoe4.',
'snosiar1>', 'snola1.', 'sno3>',
'sno1>', 'noll2.', 'tnennei4.',
'ennei2>', 'snei1>', 'sne' . chr(233) .
'1>', 'enne' . chr(233) . '5e.',
'ne' . chr(233) . '3e.', 'neic0.',
'neiv0.', 'nei3.', 'sc1.',
'sd1.', 'sg1.', 'sni1.', 'tiu0.',
'ti2.', 'sp1>', 'sna1>',
'sue1.', 'enn2>', 'nong2.',
'noss2.', 'rioe4.',
'riot0.', 'riorc1.', 'riovec5.',
'rio3.', 'ric2.', 'ril2.',
'tnerim3.', 'tneris3>', 'tneri5.',
't' . chr(238) . 'a3.', 'riss2.',
't' . chr(238) . '2.', 't' . chr(226) .
'2>', 'ario2.', 'arim1.',
'ara1.', 'aris1.', 'ari3.',
'art1>', 'ardn2.', 'arr1.',
'arua1.',
'aro1.', 'arv1.', 'aru1.',
'ar2.', 'rd1.', 'ud1.', 'ul1.',
'ini1.', 'rin2.', 'tnessiab3.',
'tnessia7.', 'tnessi6.', 'tnessni4.',
'sini2.',
'sl1.', 'iard3.', 'iario3.',
'ia2>', 'io0.', 'iule2.',
'i1>', 'sid2.', 'sic2.',
'esoi4.', 'ed1.', 'ai2>',
'a1>', 'adr1.',
'tner' . chr(232) . '5>', 'evir1.',
'evio4>', 'evi3.', 'fita4.',
'fi2>', 'enie1.', 'sare4>',
'sari4>', 'sard3.', 'sart2>',
'sa2.',
'tnessa6>', 'tnessu6>', 'tnegna3.',
'tnegi3.', 'tneg0.', 'tneru5>',
'tnemg0.', 'tnerni4.', 'tneiv1.',
'tne3>', 'une1.', 'en1>',
'nitn2.',
'ecnay5i.', 'ecnal1.', 'ecna4.',
'ec1>', 'nn1.', 'rit2>',
'rut2>', 'rud2.', 'ugn1>',
'eg1>', 'tuo0.', 'tul2>', 't'
. chr(251) . '2>',
'ev1>', 'v' . chr(232) . '2ve>',
'rtt1>', 'emissi6.', 'em1.',
'ehc1.', 'c' . chr(233) . 'i2c' . chr(232) .
'.', 'libi2l.', 'llie1.',
'liei4i.', 'xuev1.', 'xuey4i.',
'xueni5>', 'xuell4.', 'xuere5.',
'xue3>', 'rb' . chr(233) . '3rb' .
chr(232) . '.', 'tur2.',
'rir' . chr(233) . '4re.', 'rir2.',
'c' . chr(226) . '2ca.', 'snu1.',
'rt' . chr(238) . 'a4.', 'long2.',
'vec2.', chr(231) . '1c>',
'ssilp3.', 'silp2.', 't' . chr(232) .
'hc2te.', 'n' . chr(232) . 'm2ne.',
'llepp1.', 'tan2.', 'rv' . chr(232) .
'3rve.',
'rv' . chr(233) . '3rve.', 'r' . chr(232)
. '2re.', 'r' . chr(233) . '2re.',
't' . chr(232) . '2te.', 't' . chr(233) .
'2te.', 'epp1.',
'eya2i.', 'ya1i.', 'yo1i.',
'esu1.', 'ugi1.', 'tt1.', 'end0.'
);
self::$stemRules = $vars;
return self::$stemRules;
}
/**
* Returns the number of the first rule from the rule number
* that can be applied to the given reversed input.
* returns -1 if no rule can be applied, ie the stem has been found
*
* @param string $reversedInput The input to check in reversed order
* @param integer $ruleNumber The rule number to check
*
* @return integer Number of the first rule
*
* @since 3.0
*/
private static function getFirstRule($reversedInput, $ruleNumber)
{
$vars = static::getStemRules();
$nb_rules = count($vars['rules']);
for ($i = $ruleNumber; $i < $nb_rules; $i++)
{
// Gets the letters from the current rule
$rule = $vars['rules'][$i];
$rule = preg_replace($vars['rule_pattern'], "\\1",
$rule);
if (strncasecmp(utf8_decode($rule), $reversedInput,
strlen(utf8_decode($rule))) == 0)
{
return $i;
}
}
return -1;
}
/**
* Check the acceptability of a stem for French language
*
* @param string $reversedStem The stem to check in reverse form
*
* @return boolean True if stem is acceptable
*
* @since 3.0
*/
private static function check($reversedStem)
{
$vars = static::getStemRules();
if (preg_match('/[' . $vars['vowels'] .
']$/', utf8_encode($reversedStem)))
{
// If the form starts with a vowel then at least two letters must remain
after stemming (e.g.: "etaient" --> "et")
return (strlen($reversedStem) > 2);
}
else
{
// If the reversed stem starts with a consonant then at least two
letters must remain after stemming
if (strlen($reversedStem) <= 2)
{
return false;
}
// And at least one of these must be a vowel or "y"
return preg_match('/[' . $vars['vowels'] .
']/', utf8_encode($reversedStem));
}
}
/**
* Paice/Husk stemmer which returns a stem for the given $input
*
* @param string $input The word for which we want the stem in UTF-8
*
* @return string The stem
*
* @since 3.0
*/
private static function getStem($input)
{
$vars = static::getStemRules();
$reversed_input = strrev(utf8_decode($input));
$rule_number = 0;
// This loop goes through the rules' array until it finds an ending
one (ending by '.') or the last one ('end0.')
while (true)
{
$rule_number = self::getFirstRule($reversed_input, $rule_number);
if ($rule_number === -1)
{
// No other rule can be applied => the stem has been found
break;
}
$rule = $vars['rules'][$rule_number];
preg_match($vars['rule_pattern'], $rule, $matches);
$reversed_stem = utf8_decode($matches[4]) . substr($reversed_input,
$matches[3]);
if (self::check($reversed_stem))
{
$reversed_input = $reversed_stem;
if ($matches[5] === '.')
{
break;
}
}
else
{
// Go to another rule
$rule_number++;
}
}
return utf8_encode(strrev($reversed_input));
}
}
indexer/stemmer/porter_en.php000064400000023430151156756060012402
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('FinderIndexerStemmer', dirname(__DIR__) .
'/stemmer.php');
/**
* Porter English stemmer class for the Finder indexer package.
*
* This class was adapted from one written by Richard Heyes.
* See copyright and link information above.
*
* @since 2.5
*/
class FinderIndexerStemmerPorter_En extends FinderIndexerStemmer
{
/**
* Regex for matching a consonant.
*
* @var string
* @since 2.5
*/
private static $regex_consonant =
'(?:[bcdfghjklmnpqrstvwxz]|(?<=[aeiou])y|^y)';
/**
* Regex for matching a vowel
*
* @var string
* @since 2.5
*/
private static $regex_vowel = '(?:[aeiou]|(?<![aeiou])y)';
/**
* Method to stem a token and return the root.
*
* @param string $token The token to stem.
* @param string $lang The language of the token.
*
* @return string The root token.
*
* @since 2.5
*/
public function stem($token, $lang)
{
// Check if the token is long enough to merit stemming.
if (strlen($token) <= 2)
{
return $token;
}
// Check if the language is English or All.
if ($lang !== 'en' && $lang !== '*')
{
return $token;
}
// Stem the token if it is not in the cache.
if (!isset($this->cache[$lang][$token]))
{
// Stem the token.
$result = $token;
$result = self::step1ab($result);
$result = self::step1c($result);
$result = self::step2($result);
$result = self::step3($result);
$result = self::step4($result);
$result = self::step5($result);
// Add the token to the cache.
$this->cache[$lang][$token] = $result;
}
return $this->cache[$lang][$token];
}
/**
* Step 1
*
* @param string $word The token to stem.
*
* @return string
*
* @since 2.5
*/
private static function step1ab($word)
{
// Part a
if (substr($word, -1) === 's')
{
self::replace($word, 'sses', 'ss')
|| self::replace($word, 'ies', 'i')
|| self::replace($word, 'ss', 'ss')
|| self::replace($word, 's', '');
}
// Part b
if (substr($word, -2, 1) !== 'e' || !self::replace($word,
'eed', 'ee', 0))
{
// First rule
$v = self::$regex_vowel;
// Words ending with ing and ed
// Note use of && and OR, for precedence reasons
if (preg_match("#$v+#", substr($word, 0, -3)) &&
self::replace($word, 'ing', '')
|| preg_match("#$v+#", substr($word, 0, -2)) &&
self::replace($word, 'ed', ''))
{
// If one of above two test successful
if (!self::replace($word, 'at', 'ate') &&
!self::replace($word, 'bl', 'ble') &&
!self::replace($word, 'iz', 'ize'))
{
// Double consonant ending
$wordSubStr = substr($word, -2);
if ($wordSubStr !== 'll' && $wordSubStr !==
'ss' && $wordSubStr !== 'zz' &&
self::doubleConsonant($word))
{
$word = substr($word, 0, -1);
}
elseif (self::m($word) === 1 && self::cvc($word))
{
$word .= 'e';
}
}
}
}
return $word;
}
/**
* Step 1c
*
* @param string $word The token to stem.
*
* @return string
*
* @since 2.5
*/
private static function step1c($word)
{
$v = self::$regex_vowel;
if (substr($word, -1) === 'y' &&
preg_match("#$v+#", substr($word, 0, -1)))
{
self::replace($word, 'y', 'i');
}
return $word;
}
/**
* Step 2
*
* @param string $word The token to stem.
*
* @return string
*
* @since 2.5
*/
private static function step2($word)
{
switch (substr($word, -2, 1))
{
case 'a':
self::replace($word, 'ational', 'ate', 0)
|| self::replace($word, 'tional', 'tion', 0);
break;
case 'c':
self::replace($word, 'enci', 'ence', 0)
|| self::replace($word, 'anci', 'ance', 0);
break;
case 'e':
self::replace($word, 'izer', 'ize', 0);
break;
case 'g':
self::replace($word, 'logi', 'log', 0);
break;
case 'l':
self::replace($word, 'entli', 'ent', 0)
|| self::replace($word, 'ousli', 'ous', 0)
|| self::replace($word, 'alli', 'al', 0)
|| self::replace($word, 'bli', 'ble', 0)
|| self::replace($word, 'eli', 'e', 0);
break;
case 'o':
self::replace($word, 'ization', 'ize', 0)
|| self::replace($word, 'ation', 'ate', 0)
|| self::replace($word, 'ator', 'ate', 0);
break;
case 's':
self::replace($word, 'iveness', 'ive', 0)
|| self::replace($word, 'fulness', 'ful', 0)
|| self::replace($word, 'ousness', 'ous', 0)
|| self::replace($word, 'alism', 'al', 0);
break;
case 't':
self::replace($word, 'biliti', 'ble', 0)
|| self::replace($word, 'aliti', 'al', 0)
|| self::replace($word, 'iviti', 'ive', 0);
break;
}
return $word;
}
/**
* Step 3
*
* @param string $word The token to stem.
*
* @return string
*
* @since 2.5
*/
private static function step3($word)
{
switch (substr($word, -2, 1))
{
case 'a':
self::replace($word, 'ical', 'ic', 0);
break;
case 's':
self::replace($word, 'ness', '', 0);
break;
case 't':
self::replace($word, 'icate', 'ic', 0)
|| self::replace($word, 'iciti', 'ic', 0);
break;
case 'u':
self::replace($word, 'ful', '', 0);
break;
case 'v':
self::replace($word, 'ative', '', 0);
break;
case 'z':
self::replace($word, 'alize', 'al', 0);
break;
}
return $word;
}
/**
* Step 4
*
* @param string $word The token to stem.
*
* @return string
*
* @since 2.5
*/
private static function step4($word)
{
switch (substr($word, -2, 1))
{
case 'a':
self::replace($word, 'al', '', 1);
break;
case 'c':
self::replace($word, 'ance', '', 1)
|| self::replace($word, 'ence', '', 1);
break;
case 'e':
self::replace($word, 'er', '', 1);
break;
case 'i':
self::replace($word, 'ic', '', 1);
break;
case 'l':
self::replace($word, 'able', '', 1)
|| self::replace($word, 'ible', '', 1);
break;
case 'n':
self::replace($word, 'ant', '', 1)
|| self::replace($word, 'ement', '', 1)
|| self::replace($word, 'ment', '', 1)
|| self::replace($word, 'ent', '', 1);
break;
case 'o':
$wordSubStr = substr($word, -4);
if ($wordSubStr === 'tion' || $wordSubStr ===
'sion')
{
self::replace($word, 'ion', '', 1);
}
else
{
self::replace($word, 'ou', '', 1);
}
break;
case 's':
self::replace($word, 'ism', '', 1);
break;
case 't':
self::replace($word, 'ate', '', 1)
|| self::replace($word, 'iti', '', 1);
break;
case 'u':
self::replace($word, 'ous', '', 1);
break;
case 'v':
self::replace($word, 'ive', '', 1);
break;
case 'z':
self::replace($word, 'ize', '', 1);
break;
}
return $word;
}
/**
* Step 5
*
* @param string $word The token to stem.
*
* @return string
*
* @since 2.5
*/
private static function step5($word)
{
// Part a
if (substr($word, -1) === 'e')
{
if (self::m(substr($word, 0, -1)) > 1)
{
self::replace($word, 'e', '');
}
elseif (self::m(substr($word, 0, -1)) === 1)
{
if (!self::cvc(substr($word, 0, -1)))
{
self::replace($word, 'e', '');
}
}
}
// Part b
if (self::m($word) > 1 && self::doubleConsonant($word)
&& substr($word, -1) === 'l')
{
$word = substr($word, 0, -1);
}
return $word;
}
/**
* Replaces the first string with the second, at the end of the string. If
third
* arg is given, then the preceding string must match that m count at
least.
*
* @param string $str String to check
* @param string $check Ending to check for
* @param string $repl Replacement string
* @param integer $m Optional minimum number of m() to meet
*
* @return boolean Whether the $check string was at the end
* of the $str string. True does not necessarily mean
* that it was replaced.
*
* @since 2.5
*/
private static function replace(&$str, $check, $repl, $m = null)
{
$len = 0 - strlen($check);
if (substr($str, $len) === $check)
{
$substr = substr($str, 0, $len);
if ($m === null || self::m($substr) > $m)
{
$str = $substr . $repl;
}
return true;
}
return false;
}
/**
* m() measures the number of consonant sequences in $str. if c is
* a consonant sequence and v a vowel sequence, and <..> indicates
arbitrary
* presence,
*
* <c><v> gives 0
* <c>vc<v> gives 1
* <c>vcvc<v> gives 2
* <c>vcvcvc<v> gives 3
*
* @param string $str The string to return the m count for
*
* @return integer The m count
*
* @since 2.5
*/
private static function m($str)
{
$c = self::$regex_consonant;
$v = self::$regex_vowel;
$str = preg_replace("#^$c+#", '', $str);
$str = preg_replace("#$v+$#", '', $str);
preg_match_all("#($v+$c+)#", $str, $matches);
return count($matches[1]);
}
/**
* Returns true/false as to whether the given string contains two
* of the same consonant next to each other at the end of the string.
*
* @param string $str String to check
*
* @return boolean Result
*
* @since 2.5
*/
private static function doubleConsonant($str)
{
$c = self::$regex_consonant;
return preg_match("#$c{2}$#", $str, $matches) &&
$matches[0][0] === $matches[0][1];
}
/**
* Checks for ending CVC sequence where second C is not W, X or Y
*
* @param string $str String to check
*
* @return boolean Result
*
* @since 2.5
*/
private static function cvc($str)
{
$c = self::$regex_consonant;
$v = self::$regex_vowel;
return preg_match("#($c$v$c)$#", $str, $matches) &&
strlen($matches[1]) === 3 && $matches[1][2] !== 'w'
&& $matches[1][2] !== 'x'
&& $matches[1][2] !== 'y';
}
}
indexer/stemmer/snowball.php000064400000005335151156756060012232
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('FinderIndexerStemmer', dirname(__DIR__) .
'/stemmer.php');
/**
* Snowball stemmer class for the Finder indexer package.
*
* @since 2.5
*/
class FinderIndexerStemmerSnowball extends FinderIndexerStemmer
{
/**
* Method to stem a token and return the root.
*
* @param string $token The token to stem.
* @param string $lang The language of the token.
*
* @return string The root token.
*
* @since 2.5
*/
public function stem($token, $lang)
{
// Language to use if All is specified.
static $defaultLang = '';
// If language is All then try to get site default language.
if ($lang === '*' && $defaultLang === '')
{
$languages = JLanguageHelper::getLanguages();
$defaultLang = isset($languages[0]->sef) ? $languages[0]->sef :
'*';
$lang = $defaultLang;
}
// Stem the token if it is not in the cache.
if (!isset($this->cache[$lang][$token]))
{
// Get the stem function from the language string.
switch ($lang)
{
// Danish stemmer.
case 'da':
$function = 'stem_danish';
break;
// German stemmer.
case 'de':
$function = 'stem_german';
break;
// English stemmer.
default:
case 'en':
$function = 'stem_english';
break;
// Spanish stemmer.
case 'es':
$function = 'stem_spanish';
break;
// Finnish stemmer.
case 'fi':
$function = 'stem_finnish';
break;
// French stemmer.
case 'fr':
$function = 'stem_french';
break;
// Hungarian stemmer.
case 'hu':
$function = 'stem_hungarian';
break;
// Italian stemmer.
case 'it':
$function = 'stem_italian';
break;
// Norwegian stemmer.
case 'nb':
$function = 'stem_norwegian';
break;
// Dutch stemmer.
case 'nl':
$function = 'stem_dutch';
break;
// Portuguese stemmer.
case 'pt':
$function = 'stem_portuguese';
break;
// Romanian stemmer.
case 'ro':
$function = 'stem_romanian';
break;
// Russian stemmer.
case 'ru':
$function = 'stem_russian_unicode';
break;
// Swedish stemmer.
case 'sv':
$function = 'stem_swedish';
break;
// Turkish stemmer.
case 'tr':
$function = 'stem_turkish_unicode';
break;
}
// Stem the word if the stemmer method exists.
$this->cache[$lang][$token] = function_exists($function) ?
$function($token) : $token;
}
return $this->cache[$lang][$token];
}
}
indexer/stemmer.php000064400000003603151156756060010405 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Stemmer base class for the Finder indexer package.
*
* @since 2.5
*/
abstract class FinderIndexerStemmer
{
/**
* An internal cache of stemmed tokens.
*
* @var array
* @since 2.5
*/
public $cache = array();
/**
* Method to get a stemmer, creating it if necessary.
*
* @param string $adapter The type of stemmer to load.
*
* @return FinderIndexerStemmer A FinderIndexerStemmer instance.
*
* @since 2.5
* @throws Exception on invalid stemmer.
*/
public static function getInstance($adapter)
{
static $instances;
// Only create one stemmer for each adapter.
if (isset($instances[$adapter]))
{
return $instances[$adapter];
}
// Create an array of instances if necessary.
if (!is_array($instances))
{
$instances = array();
}
// Setup the adapter for the stemmer.
$adapter = JFilterInput::getInstance()->clean($adapter,
'cmd');
$path = __DIR__ . '/stemmer/' . $adapter . '.php';
$class = 'FinderIndexerStemmer' . ucfirst($adapter);
// Check if a stemmer exists for the adapter.
if (!file_exists($path))
{
// Throw invalid adapter exception.
throw new
Exception(JText::sprintf('COM_FINDER_INDEXER_INVALID_STEMMER',
$adapter));
}
// Instantiate the stemmer.
JLoader::register($class, $path);
$instances[$adapter] = new $class;
return $instances[$adapter];
}
/**
* Method to stem a token and return the root.
*
* @param string $token The token to stem.
* @param string $lang The language of the token.
*
* @return string The root token.
*
* @since 2.5
*/
abstract public function stem($token, $lang);
}
indexer/taxonomy.php000064400000023552151156756060010614 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Stemmer base class for the Finder indexer package.
*
* @since 2.5
*/
class FinderIndexerTaxonomy
{
/**
* An internal cache of taxonomy branch data.
*
* @var array
* @since 2.5
*/
public static $branches = array();
/**
* An internal cache of taxonomy node data.
*
* @var array
* @since 2.5
*/
public static $nodes = array();
/**
* Method to add a branch to the taxonomy tree.
*
* @param string $title The title of the branch.
* @param integer $state The published state of the branch.
[optional]
* @param integer $access The access state of the branch. [optional]
*
* @return integer The id of the branch.
*
* @since 2.5
* @throws Exception on database error.
*/
public static function addBranch($title, $state = 1, $access = 1)
{
// Check to see if the branch is in the cache.
if (isset(static::$branches[$title]))
{
return static::$branches[$title]->id;
}
// Check to see if the branch is in the table.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('*')
->from($db->quoteName('#__finder_taxonomy'))
->where($db->quoteName('parent_id') . ' = 1')
->where($db->quoteName('title') . ' = ' .
$db->quote($title));
$db->setQuery($query);
// Get the result.
$result = $db->loadObject();
// Check if the database matches the input data.
if ((bool) $result && $result->state == $state &&
$result->access == $access)
{
// The data matches, add the item to the cache.
static::$branches[$title] = $result;
return static::$branches[$title]->id;
}
/*
* The database did not match the input. This could be because the
* state has changed or because the branch does not exist. Let's
figure
* out which case is true and deal with it.
*/
$branch = new JObject;
if (empty($result))
{
// Prepare the branch object.
$branch->parent_id = 1;
$branch->title = $title;
$branch->state = (int) $state;
$branch->access = (int) $access;
}
else
{
// Prepare the branch object.
$branch->id = (int) $result->id;
$branch->parent_id = (int) $result->parent_id;
$branch->title = $result->title;
$branch->state = (int) $result->title;
$branch->access = (int) $result->access;
$branch->ordering = (int) $result->ordering;
}
// Store the branch.
static::storeNode($branch);
// Add the branch to the cache.
static::$branches[$title] = $branch;
return static::$branches[$title]->id;
}
/**
* Method to add a node to the taxonomy tree.
*
* @param string $branch The title of the branch to store the node
in.
* @param string $title The title of the node.
* @param integer $state The published state of the node. [optional]
* @param integer $access The access state of the node. [optional]
*
* @return integer The id of the node.
*
* @since 2.5
* @throws Exception on database error.
*/
public static function addNode($branch, $title, $state = 1, $access = 1)
{
// Check to see if the node is in the cache.
if (isset(static::$nodes[$branch][$title]))
{
return static::$nodes[$branch][$title]->id;
}
// Get the branch id, insert it if it does not exist.
$branchId = static::addBranch($branch);
// Check to see if the node is in the table.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('*')
->from($db->quoteName('#__finder_taxonomy'))
->where($db->quoteName('parent_id') . ' = ' .
$db->quote($branchId))
->where($db->quoteName('title') . ' = ' .
$db->quote($title));
$db->setQuery($query);
// Get the result.
$result = $db->loadObject();
// Check if the database matches the input data.
if ((bool) $result && $result->state == $state &&
$result->access == $access)
{
// The data matches, add the item to the cache.
static::$nodes[$branch][$title] = $result;
return static::$nodes[$branch][$title]->id;
}
/*
* The database did not match the input. This could be because the
* state has changed or because the node does not exist. Let's
figure
* out which case is true and deal with it.
*/
$node = new JObject;
if (empty($result))
{
// Prepare the node object.
$node->parent_id = (int) $branchId;
$node->title = $title;
$node->state = (int) $state;
$node->access = (int) $access;
}
else
{
// Prepare the node object.
$node->id = (int) $result->id;
$node->parent_id = (int) $result->parent_id;
$node->title = $result->title;
$node->state = (int) $result->title;
$node->access = (int) $result->access;
$node->ordering = (int) $result->ordering;
}
// Store the node.
static::storeNode($node);
// Add the node to the cache.
static::$nodes[$branch][$title] = $node;
return static::$nodes[$branch][$title]->id;
}
/**
* Method to add a map entry between a link and a taxonomy node.
*
* @param integer $linkId The link to map to.
* @param integer $nodeId The node to map to.
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public static function addMap($linkId, $nodeId)
{
// Insert the map.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('link_id'))
->from($db->quoteName('#__finder_taxonomy_map'))
->where($db->quoteName('link_id') . ' = ' .
(int) $linkId)
->where($db->quoteName('node_id') . ' = ' .
(int) $nodeId);
$db->setQuery($query);
$db->execute();
$id = (int) $db->loadResult();
$map = new JObject;
$map->link_id = (int) $linkId;
$map->node_id = (int) $nodeId;
if ($id)
{
$db->updateObject('#__finder_taxonomy_map', $map,
array('link_id', 'node_id'));
}
else
{
$db->insertObject('#__finder_taxonomy_map', $map);
}
return true;
}
/**
* Method to get the title of all taxonomy branches.
*
* @return array An array of branch titles.
*
* @since 2.5
* @throws Exception on database error.
*/
public static function getBranchTitles()
{
$db = JFactory::getDbo();
// Set user variables
$groups = implode(',',
JFactory::getUser()->getAuthorisedViewLevels());
// Create a query to get the taxonomy branch titles.
$query = $db->getQuery(true)
->select($db->quoteName('title'))
->from($db->quoteName('#__finder_taxonomy'))
->where($db->quoteName('parent_id') . ' = 1')
->where($db->quoteName('state') . ' = 1')
->where($db->quoteName('access') . ' IN (' .
$groups . ')');
// Get the branch titles.
$db->setQuery($query);
return $db->loadColumn();
}
/**
* Method to find a taxonomy node in a branch.
*
* @param string $branch The branch to search.
* @param string $title The title of the node.
*
* @return mixed Integer id on success, null on no match.
*
* @since 2.5
* @throws Exception on database error.
*/
public static function getNodeByTitle($branch, $title)
{
$db = JFactory::getDbo();
// Set user variables
$groups = implode(',',
JFactory::getUser()->getAuthorisedViewLevels());
// Create a query to get the node.
$query = $db->getQuery(true)
->select('t1.*')
->from($db->quoteName('#__finder_taxonomy') . ' AS
t1')
->join('INNER',
$db->quoteName('#__finder_taxonomy') . ' AS t2 ON t2.id =
t1.parent_id')
->where('t1.access IN (' . $groups . ')')
->where('t1.state = 1')
->where('t1.title LIKE ' .
$db->quote($db->escape($title) . '%'))
->where('t2.access IN (' . $groups . ')')
->where('t2.state = 1')
->where('t2.title = ' . $db->quote($branch));
// Get the node.
$db->setQuery($query, 0, 1);
return $db->loadObject();
}
/**
* Method to remove map entries for a link.
*
* @param integer $linkId The link to remove.
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public static function removeMaps($linkId)
{
// Delete the maps.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->delete($db->quoteName('#__finder_taxonomy_map'))
->where($db->quoteName('link_id') . ' = ' .
(int) $linkId);
$db->setQuery($query);
$db->execute();
return true;
}
/**
* Method to remove orphaned taxonomy nodes and branches.
*
* @return integer The number of deleted rows.
*
* @since 2.5
* @throws Exception on database error.
*/
public static function removeOrphanNodes()
{
// Delete all orphaned nodes.
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$subquery = $db->getQuery(true);
$subquery1 = $db->getQuery(true);
$subquery1->select($db->quoteName('t.id'))
->from($db->quoteName('#__finder_taxonomy',
't'))
->join('LEFT',
$db->quoteName('#__finder_taxonomy_map', 'm') .
' ON ' . $db->quoteName('m.node_id') . '='
. $db->quoteName('t.id'))
->where($db->quoteName('t.parent_id') . ' > 1
')
->where($db->quoteName('m.link_id') . ' IS
NULL');
$subquery->select($db->quoteName('id'))
->from('(' . $subquery1 . ') temp');
$query->delete($db->quoteName('#__finder_taxonomy'))
->where($db->quoteName('id') . ' IN (' .
$subquery . ')');
$db->setQuery($query);
$db->execute();
return $db->getAffectedRows();
}
/**
* Method to store a node to the database. This method will accept either
a branch or a node.
*
* @param object $item The item to store.
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
protected static function storeNode($item)
{
$db = JFactory::getDbo();
// Check if we are updating or inserting the item.
if (empty($item->id))
{
// Insert the item.
$db->insertObject('#__finder_taxonomy', $item,
'id');
}
else
{
// Update the item.
$db->updateObject('#__finder_taxonomy', $item,
'id');
}
return true;
}
}
indexer/token.php000064400000007674151156756060010065 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\String\StringHelper;
/**
* Token class for the Finder indexer package.
*
* @since 2.5
*/
class FinderIndexerToken
{
/**
* This is the term that will be referenced in the terms table and the
* mapping tables.
*
* @var string
* @since 2.5
*/
public $term;
/**
* The stem is used to match the root term and produce more potential
* matches when searching the index.
*
* @var string
* @since 2.5
*/
public $stem;
/**
* If the token is numeric, it is likely to be short and uncommon so the
* weight is adjusted to compensate for that situation.
*
* @var boolean
* @since 2.5
*/
public $numeric;
/**
* If the token is a common term, the weight is adjusted to compensate for
* the higher frequency of the term in relation to other terms.
*
* @var boolean
* @since 2.5
*/
public $common;
/**
* Flag for phrase tokens.
*
* @var boolean
* @since 2.5
*/
public $phrase;
/**
* The length is used to calculate the weight of the token.
*
* @var integer
* @since 2.5
*/
public $length;
/**
* The weight is calculated based on token size and whether the token is
* considered a common term.
*
* @var integer
* @since 2.5
*/
public $weight;
/**
* The simple language identifier for the token.
*
* @var string
* @since 2.5
*/
public $language;
/**
* The container for matches.
*
* @var array
* @since 3.8.12
*/
public $matches = array();
/**
* Is derived token (from individual words)
*
* @var boolean
* @since 3.8.12
*/
public $derived;
/**
* The suggested term
*
* @var string
* @since 3.8.12
*/
public $suggestion;
/**
* Method to construct the token object.
*
* @param mixed $term The term as a string for words or an array
for phrases.
* @param string $lang The simple language identifier.
* @param string $spacer The space separator for phrases. [optional]
*
* @since 2.5
*/
public function __construct($term, $lang, $spacer = ' ')
{
$this->language = $lang;
// Tokens can be a single word or an array of words representing a
phrase.
if (is_array($term))
{
// Populate the token instance.
$this->term = implode($spacer, $term);
$this->stem = implode($spacer,
array_map(array('FinderIndexerHelper', 'stem'), $term,
array($lang)));
$this->numeric = false;
$this->common = false;
$this->phrase = true;
$this->length = StringHelper::strlen($this->term);
/*
* Calculate the weight of the token.
*
* 1. Length of the token up to 30 and divide by 30, add 1.
* 2. Round weight to 4 decimal points.
*/
$this->weight = (($this->length >= 30 ? 30 : $this->length)
/ 30) + 1;
$this->weight = round($this->weight, 4);
}
else
{
// Populate the token instance.
$this->term = $term;
$this->stem = FinderIndexerHelper::stem($this->term, $lang);
$this->numeric = (is_numeric($this->term) || (bool)
preg_match('#^[0-9,.\-\+]+$#', $this->term));
$this->common = $this->numeric ? false :
FinderIndexerHelper::isCommon($this->term, $lang);
$this->phrase = false;
$this->length = StringHelper::strlen($this->term);
/*
* Calculate the weight of the token.
*
* 1. Length of the token up to 15 and divide by 15.
* 2. If common term, divide weight by 8.
* 3. If numeric, multiply weight by 1.5.
* 4. Round weight to 4 decimal points.
*/
$this->weight = ($this->length >= 15 ? 15 : $this->length) /
15;
$this->weight = $this->common === true ? $this->weight / 8 :
$this->weight;
$this->weight = $this->numeric === true ? $this->weight * 1.5 :
$this->weight;
$this->weight = round($this->weight, 4);
}
}
}
language.php000064400000006043151156756060007057 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Finder language helper class.
*
* @since 2.5
*/
class FinderHelperLanguage
{
/**
* Method to return a plural language code for a taxonomy branch.
*
* @param string $branchName Branch title.
*
* @return string Language key code.
*
* @since 2.5
*/
public static function branchPlural($branchName)
{
$return = preg_replace('/[^a-zA-Z0-9]+/', '_',
strtoupper($branchName));
if ($return !== '_')
{
return 'PLG_FINDER_QUERY_FILTER_BRANCH_P_' . $return;
}
return $branchName;
}
/**
* Method to return a singular language code for a taxonomy branch.
*
* @param string $branchName Branch name.
*
* @return string Language key code.
*
* @since 2.5
*/
public static function branchSingular($branchName)
{
$return = preg_replace('/[^a-zA-Z0-9]+/', '_',
strtoupper($branchName));
return 'PLG_FINDER_QUERY_FILTER_BRANCH_S_' . $return;
}
/**
* Method to return the language name for a language taxonomy branch.
*
* @param string $branchName Language branch name.
*
* @return string The language title.
*
* @since 3.6.0
*/
public static function branchLanguageTitle($branchName)
{
$title = $branchName;
if ($branchName === '*')
{
$title = JText::_('JALL_LANGUAGE');
}
else
{
$languages = JLanguageHelper::getLanguages('lang_code');
if (isset($languages[$branchName]))
{
$title = $languages[$branchName]->title;
}
}
return $title;
}
/**
* Method to load Smart Search component language file.
*
* @return void
*
* @since 2.5
*/
public static function loadComponentLanguage()
{
JFactory::getLanguage()->load('com_finder', JPATH_SITE);
}
/**
* Method to load Smart Search plugin language files.
*
* @return void
*
* @since 2.5
*/
public static function loadPluginLanguage()
{
static $loaded = false;
// If already loaded, don't load again.
if ($loaded)
{
return;
}
$loaded = true;
// Get array of all the enabled Smart Search plugin names.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select(array($db->qn('name'),
$db->qn('element')))
->from($db->quoteName('#__extensions'))
->where($db->quoteName('type') . ' = ' .
$db->quote('plugin'))
->where($db->quoteName('folder') . ' = ' .
$db->quote('finder'))
->where($db->quoteName('enabled') . ' = 1');
$db->setQuery($query);
$plugins = $db->loadObjectList();
if (empty($plugins))
{
return;
}
// Load generic language strings.
$lang = JFactory::getLanguage();
$lang->load('plg_content_finder', JPATH_ADMINISTRATOR);
// Load language file for each plugin.
foreach ($plugins as $plugin)
{
$lang->load($plugin->name, JPATH_ADMINISTRATOR)
|| $lang->load($plugin->name, JPATH_PLUGINS .
'/finder/' . $plugin->element);
}
}
}
headercheck.php000064400000004333151157644400007515 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
@build 10th April, 2021
@created 10th April, 2021
@package Blank
@subpackage headercheck.php
@author Mojtaba Taheri <http://lmskaran.com/>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
class blankHeaderCheck
{
function js_loaded($script_name)
{
// UIkit check point
if (strpos($script_name,'uikit') !== false)
{
$app = JFactory::getApplication();
$getTemplateName =
$app->getTemplate('template')->template;
if (strpos($getTemplateName,'yoo') !== false)
{
return true;
}
}
$document = JFactory::getDocument();
$head_data = $document->getHeadData();
foreach (array_keys($head_data['scripts']) as $script)
{
if (stristr($script, $script_name))
{
return true;
}
}
return false;
}
function css_loaded($script_name)
{
// UIkit check point
if (strpos($script_name,'uikit') !== false)
{
$app = JFactory::getApplication();
$getTemplateName =
$app->getTemplate('template')->template;
if (strpos($getTemplateName,'yoo') !== false)
{
return true;
}
}
$document = JFactory::getDocument();
$head_data = $document->getHeadData();
foreach (array_keys($head_data['styleSheets']) as $script)
{
if (stristr($script, $script_name))
{
return true;
}
}
return false;
}
}html/batch_.php000064400000005107151157644410007454 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
@build 10th April, 2021
@created 10th April, 2021
@package Blank
@subpackage batch_.php
@author Mojtaba Taheri <http://lmskaran.com/>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('JPATH_PLATFORM') or die;
/**
* Utility class to render a list view batch selection options
*
* @since 3.0
*/
abstract class JHtmlBatch_
{
/**
* ListSelection
*
* @var array
* @since 3.0
*/
protected static $ListSelection = array();
/**
* Render the batch selection options.
*
* @return string The necessary HTML to display the batch selection
options
*
* @since 3.0
*/
public static function render()
{
// Collect display data
$data = new stdClass;
$data->ListSelection = static::getListSelection();
// Create a layout object and ask it to render the batch selection
options
$layout = new JLayoutFile('batchselection');
$batchHtml = $layout->render($data);
return $batchHtml;
}
/**
* Method to add a list selection to the batch modal
*
* @param string $label Label for the menu item.
* @param string $name Name for the filter. Also used as id.
* @param string $options Options for the select field.
* @param bool $noDefault Don't the label as the empty option
*
* @return void
*
* @since 3.0
*/
public static function addListSelection($label, $name, $options,
$noDefault = false)
{
array_push(static::$ListSelection, array('label' => $label,
'name' => $name, 'options' => $options,
'noDefault' => $noDefault));
}
/**
* Returns an array of all ListSelection
*
* @return array
*
* @since 3.0
*/
public static function getListSelection()
{
return static::$ListSelection;
}
}
html/index.html000064400000000054151157644410007514
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>index.html000064400000000054151157644410006550
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>moojla.php000064400000300027151157644410006550
0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.77
@build 6th April, 2022
@created 22nd July, 2020
@package Moojla
@subpackage moojla.php
@author Lmskaran <http://Lmskaran.com>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Language\Language;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
/**
* Moojla component helper.
*/
abstract class MoojlaHelper
{
/**
* Composer Switch
*
* @var array
*/
protected static $composer = array();
/**
* The Main Active Language
*
* @var string
*/
public static $langTag;
/***[JCBGUI.joomla_component.php_helper_both.29.$$$$]***/
public static function get_role_by_remoteid($remoteid, $role)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('mc.id as id, shortname, remoteid, cat_name,
catid, cost, summary_files, summary, fullname, e.jid, e.role');
$query->from($db->quoteName('#__moojla_enrolment',
'e'));
$query->join('inner',$db->quoteName('#__moojla_enrolment','ee').'
on
'.$db->quoteName('e.jid').'='.$db->quoteName('ee.jid'));
$query->join('inner',$db->quoteName('#__moojla_course','mc').'
on
'.$db->quoteName('mc.remoteid').'='.$db->quoteName('ee.moojlacourse'));
$query->where($db->quoteName('ee.moojlacourse').'!='.$remoteid);
$query->where($db->quoteName('e.moojlacourse').'='.$remoteid);
$query->where($db->quoteName('ee.role').'='.
$role);
$db->setQuery($query);
$result = $db->loadObjectList('remoteid');
return $result;
}
public static function addJoomlaUser($data) {
// $file_name = __DIR__. "/addJoomlaUser.txt";
// file_put_contents($file_name, print_r($data, true)."\n",
FILE_APPEND);
$result = new stdClass();
$result->id = 0;
// $app = JFactory::getApplication();
jimport('joomla.user.helper');
$userdata = array(
"name"=>trim(strval($data['name'])),
"username"=>trim(strval($data['username'])),
"password"=>trim(strval($data['password'])),
"password2"=>trim(strval($data['password'])),
"email"=>trim(strval($data['email'])),
"block"=>0,
);
foreach($userdata as $d)
{
if(trim(strval($d)) == "" || !$d)
unset($d);
}
$userdata["groups"] = array("2");
$user = new JUser;
//Write to database
if(!$user->bind($userdata)) {
$result->status = $user->getError();
return $result;
// $app->enqueueMessage($user->getError(), 'error');
// $app->redirect(JRoute::_($_SERVER['HTTP_REFERER'],
false));
}
//before save
$user->from_moodle = true;
if (!$user->save()) {
$result->status = $user->getError();
return $result;
// $app->enqueueMessage($user->getError(), 'error');
// $app->redirect(JRoute::_($_SERVER['HTTP_REFERER'],
false));
}
if(isset($data["moodle"]))
{
JPluginHelper::importPlugin("moojlaaditionalfields");
$dispatcher = JEventDispatcher::getInstance();
$dispatch_res = $dispatcher->trigger("addUserToJoomla",
array($data["moodle"], $user->id));
}
$userdata['userid'] = $user->id;
$result->status = "ok";
$result->id = $user->id;
return $result;
}
public static function updateJoomlaUser($data, $id) {
$result = new stdClass();
$result->id = $id;
jimport('joomla.user.helper');
$userdata = array(
"name"=>trim(strval($data['name'])),
"username"=>trim(strval($data['username'])),
"password"=>trim(strval($data['password'])),
"password2"=>trim(strval($data['password'])),
"email"=>trim(strval($data['email'])),
"block"=>0,
);
foreach($userdata as $d)
{
if(trim(strval($d)) == "" || !$d)
unset($d);
}
$userdata["groups"] = array("2");
$user = new JUser;
$user->load($id);
//Write to database
if(!$user->bind($userdata)) {
$result->status = $user->getError();
return $result;
}
$user->from_moodle = true;
if (!$user->save()) {
$result->status = $user->getError();
return $result;
}
$params = JComponentHelper::getParams('com_moojla');
$ads = trim($params->get('additional_data_source'));
if(isset($data["post"]))
{
$newdata = isset($data["moodle"]) ?
$data["moodle"] : $data["post"];
// if($ads == "jf")
// {
JPluginHelper::importPlugin("moojlaaditionalfields");
$dispatcher = JEventDispatcher::getInstance();
$dispatch_res = $dispatcher->trigger("addUserToJoomla",
array($newdata, $id));
// }
// else if($ads == "cb")
// {
// $file_name = __DIR__. "/updateJoomlaUser111111111.txt";
// file_put_contents($file_name, 'dispatch_res = ' .
print_r($dispatch_res, true)."\n", FILE_APPEND);
// }
}
$result->status = "ok";
return $result;
}
public static function deleteJoomlaUser($id) {
$result = new stdClass();
jimport('joomla.user.helper');
$user = new JUser;
$user->load($id);
if (!$user->delete()) {
$result->status = $user->getError();
return $result;
}
$result->status = "ok";
return $result;
}
/**
*
*
*
* $data and body are array with keys and values
*/
public static function sendRequestToMoodle($data, $body=array())
{
/*
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL =>
"http://atwh.ir/lms/webservice/rest/server.php?wsfunction=moojla_trigger_create_users&moodlewsrestformat=json&wstoken=1b7d4d04a7bff9cd676ae5e20cba6260&userids%5B0%5D%5Bid%5D=428",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>"{}",
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
*/
/*
*/
$postField = new stdClass();
$postField->from_joomla = 1;
foreach($body as $key => $value)
{
$postField->$key = $value;
if(!$value)
unset($postField->$key);
}
$postField = json_encode($postField);
$params = JComponentHelper::getParams('com_moojla');
$moodle_url= trim($params->get('moodle_url'));
$moodle_token = trim($params->get('moodle_token'));
$data["wstoken"] = $moodle_token;
$url = $moodle_url . "webservice/rest/server.php?" .
http_build_query($data);
//$url = urldecode($url);
// dump($url, "url");
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $postField,
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$error = curl_error($curl);
curl_close($curl);
$output = new stdClass();
$output->response = $response;
$output->error = $error;
return $output;
}
public static function addToUserMap($data){
if(!$data['jid'])
$data['jid'] = 0;
if(!$data['mid'])
$data['mid'] = 0;
require_once JPATH_ADMINISTRATOR .
"/components/com_moojla/models/user_map.php";
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query = "SELECT * FROM `#__moojla_user_map` WHERE ((jid > 0
AND jid = '{$data['jid']}') OR (mid > 0 AND mid =
'{$data['mid']}')) AND published = 1";
$db->setQuery($query);
$usermapres = $db->loadAssocList()[0];
if(isset($usermapres['id']))
$id = $usermapres['id'];
else
$id = '';
if($data['jid'] || $data['mid'])
{
if($id)
$data['id'] = $id;
$usermap = new MoojlaModelUser_map();
$usermap->save($data);
}
if($data['jid'] != 0 && $data['mid'] != 0)
{
require_once JPATH_ADMINISTRATOR .
"/components/com_moojla/models/user_map.php";
$query = $db->getQuery(true);
$query->select('id');
$query->from($db->quoteName('#__moojla_user_map'));
$query->where($db->quoteName('jid') .' = '
. $db->quote($data['jid']));
$query->where($db->quoteName('mid') .' =
0');
$db->setQuery($query);
$rowToDel = $db->loadResult();
if($rowToDel)
{
$usermap = new MoojlaModelUser_map();
$usermap->myDelete($rowToDel);
}
$query = $db->getQuery(true);
$query->select('id');
$query->from($db->quoteName('#__moojla_user_map'));
$query->where($db->quoteName('mid') .' = '
. $db->quote($data['mid']));
$query->where($db->quoteName('jid') .' =
0');
$db->setQuery($query);
$rowToDel = $db->loadResult();
if($rowToDel)
{
$usermap = new MoojlaModelUser_map();
$usermap->myDelete($rowToDel);
}
}
}
public static function deleteFromUserMap($id){
/*
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$conditions = array($db->quoteName('jid') . ' =
' . $db->quote($id));
$query->delete($db->quoteName('#__moojla_user_map'));
$query->where($conditions);
$db->setQuery($query);
$result = $db->execute();
*/
require_once JPATH_ADMINISTRATOR .
"/components/com_moojla/models/user_map.php";
$usermap = new MoojlaModelUser_map();
$usermap->myDelete($id);
}
public static function joomlaToMoodleID($id){
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('mid')));
$query->from($db->quoteName('#__moojla_user_map'));
$query->where($db->quoteName('jid') . ' = ' .
$db->quote($id));
$db->setQuery($query);
$mid = $db->loadResult();
return $mid;
}
public static function loginToJoomla($username, $password,
$from_moodle=0){
$mainframe = JFactory::getApplication('site');
$user_id = JUserHelper::getUserId($username);
$user = JFactory::getUser($user_id);
if (!$user)
return false;
if ($user->block)
return false;
$options = array ( 'remember' => '1',
'silent' => 1);
$credentials = array ( 'username' => $username,
'password' => $password, "from_moodle" =>
$from_moodle);
if ($mainframe->login( $credentials, $options ))
return true;
return false;
}
public static function logoutFromJoomla($username, $from_moodle=0){
$mainframe = JFactory::getApplication('site');
$id = JUserHelper::getUserId($username);
$error = $mainframe->logout($id, array ('clientid' =>
0, "from_moodle" => $from_moodle));
$session = JFactory::getSession();
$sessid = $session->getId();
return $sessid;
}
public static function loginToMoodle($username, $token)
{
$params = JComponentHelper::getParams('com_moojla');
$moodle_url = trim($params->get('moodle_url'));
$moodle_cookie_path =
trim($params->get('moodle_cookie_path'));
$config = JFactory::getConfig();
$temppath = $config->get('tmp_path');
$file = $temppath . "/" . JUserHelper::genRandomPassword() .
".txt";
$postField = array ( 'username' => $username,
'token' => $token, "from_joomla" => 1);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $moodle_url .
"auth/moojla/loginHandler.php",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_COOKIEJAR => $file,
CURLOPT_HEADER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $postField,
));
$response = curl_exec($curl);
$error = curl_error($curl);
curl_close($curl);
$output = new stdClass();
$output->response = $response;
$output->error = $error;
preg_match_all('/^Set-Cookie: (.*?); path=(.*)/m', $response,
$match);
$cookie_options = array (
// 'path' => $moodle_url,
'path' => $moodle_cookie_path,
// 'secure' => true,
'secure' => false,
'httponly' => false,
// 'samesite' => 'None'
);
foreach($match[1] as $key => $m)
{
$cookie = explode('=', $m);
setcookie($cookie[0], $cookie[1], $cookie_options);
}
if (file_exists($file))
unlink ($file);
return $output;
}
public static function logoutFromMoodle($username){
$app = JFactory::getApplication('site');
$cookieName = 'joomla_remember_me_' .
JUserHelper::getShortHashedUserAgent();
if (!$app->input->cookie->get($cookieName))
{
$cookieName = JUserHelper::getShortHashedUserAgent();
}
$cookieValue = $app->input->cookie->get($cookieName);
if ($cookieValue)
{
$cookieArray = explode('.', $cookieValue);
$filter = new JFilterInput;
$series = $filter->clean($cookieArray[1], 'ALNUM');
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query
->delete('#__user_keys')
->where($db->quoteName('series') . ' = '
. $db->quote($series));
$app->input->cookie->set(
$cookieName,
false,
time() - 42000,
$app->get('cookie_path', '/'),
$app->get('cookie_domain')
);
}
$params = JComponentHelper::getParams('com_moojla');
$moodle_url = trim($params->get('moodle_url'));
$moodle_cookie_path=
trim($params->get('moodle_cookie_path'));
//session_get_cookie_params
unset($_SESSION['USER']);
unset($_SESSION['SESSION']);
$cookie_options = array (
//'path' => $moodle_url,
'path' => $moodle_cookie_path,
//'secure' => true,
'httponly' => false,
//'samesite' => 'None',
'expires'=> time() - 3600
);
setcookie('MoodleSession', '',$cookie_options);
unset($_SESSION);
}
public static function changeObjectKey($object, $oldkey, $newkey)
{
if(isset($object->$oldkey))
{
$object->$newkey = $object->$oldkey;
unset($object->$oldkey);
}
else{
$object->$newkey = false;
}
}
public static function getLoginUrl($return)
{
$loginUrl = 'index.php?option=com_users&view=login' .
($return ? ('&return=' . base64_encode($return)) :
'');
return $loginUrl;
}
public static function updateCourseContents($sections, $courseid)
{
require_once JPATH_ADMINISTRATOR .
"/components/com_moojla/models/section.php";
require_once JPATH_ADMINISTRATOR .
"/components/com_moojla/models/module.php";
require_once JPATH_ADMINISTRATOR .
"/components/com_moojla/models/content.php";
require_once JPATH_ADMINISTRATOR .
"/components/com_moojla/models/module.php";
foreach($sections as $section)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id')))
->from($db->quoteName('#__moojla_section'))
->where($db->quoteName('section_id') . ' =
' . $db->quote($section->id));
$db->setQuery($query);
$sectionResult = $db->loadResult();
$sectionData = array(
"courseid" => $courseid,
"name" => $section->name,
"section_id" => $section->id,
"summary" => $section->summary,
"visible" => $section->visible,
"published" => $section->visible,
"uservisible" => $section->uservisible
);
if($sectionResult)
{
$sectionData["id"] = $sectionResult; //for update
}
$sectionModel = new MoojlaModelsection;
$sectionModel->save($sectionData);
foreach($section->modules as $module)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id')))
->from($db->quoteName('#__moojla_module'))
->where($db->quoteName('module_id') . ' =
' . $db->quote($module->id));
$db->setQuery($query);
$moduleResult = $db->loadResult();
$moduleData = array(
"module_section_id" => $section->id,
"name" => $module->name,
"module_id" => $module->id,
"description" => isset($module->description) ?
$module->description : "",
"visible" => $module->visible,
"published" => $module->visible,
"uservisible" => $module->uservisible,
"modname" => $module->modname,
"url" => $module->url,
"modicon" => $module->modicon,
);
if($moduleResult)
{
$moduleData["id"] = $moduleResult;
}
$moduleModel = new MoojlaModelmodule;
$moduleModel->save($moduleData);
if(isset($module->contents))
{
$contents = current($module->contents);
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id')))
->from($db->quoteName('#__moojla_content'))
->where($db->quoteName('contents_module_id') .
' = ' . $db->quote($module->id));
$db->setQuery($query);
$contentResult = $db->loadResult();
$contentData = array(
"contents_module_id" => $module->id,
"type" => $contents->type,
"filename" => isset($contents->filename) ?
$contents->filename : "",
"filesize" => isset($contents->filesize) ?
$contents->filesize : 0,
"fileurl" => isset($contents->fileurl) ?
$contents->fileurl : "",
"mimetype" => isset($contents->mimetype) ?
$contents->mimetype : "",
);
if($contentResult)
{
$contentData["id"] = $contentResult;
}
$contentModel = new MoojlaModelcontent;
$contentModel->save($contentData);
}
}
}
}
public static function createButton($label, $id, $loginurl,
$registrationurl)
{
return "<input type='button'
class='moojla-login-button' id='moojla-start-modal'
value='".$label."'>
<div id='moojla-modal'
class='moojla-login-modal'>
<div class='moojla-login-modal-content animate'>
<span id='logintabbtn'
class='modal_tab_button_login_registration
active_tab_login_registration'>
Ù۱ÙŰŻ
</span>
<span id='regtabbtn'
class='modal_tab_button_login_registration'>
۫ۚŰȘ ÙۧÙ
</span>
<div id='moojla-login-modal-content'
class='display_content_log_reg show_content'>
<img
src='/components/com_moojla/assets/images/loading-modal.gif'
id='loadinggif'>
</div>
<div id='moojla-reg-modal-content'
class='display_content_log_reg'>
<img
src='/components/com_moojla/assets/images/loading-modal.gif'
id='loadinggif'>
</div>
</div>
</div>
<script>
loginbtn = jQuery('#logintabbtn');
regbtn = jQuery('#regtabbtn');
l = jQuery('#moojla-login-modal-content');
r = jQuery('#moojla-reg-modal-content');
var moojla_login_modal =
document.getElementById('moojla-modal');
loginbtn.click(function(e){
// l.show();
// r.hide();
});
regbtn.click(function(e){
// r.show();
// l.hide();
jQuery('#member-registration > div > div >
a').click(function(e) {
moojla_login_modal.style.display = 'none';
return false;
});
});
window.onclick = function(event) {
if (event.target == moojla_login_modal) {
moojla_login_modal.style.display = 'none';
}
}
document.getElementById('moojla-start-modal').onclick =
function() {
moojla_login_modal.style.display ='block';
l = jQuery('#moojla-login-modal-content');
l.load('".$loginurl."&return=".base64_encode('index.php?option=com_moojla&view=coursedetail&id='.$id)."',
function(){
loadinggif = jQuery('#loadinggif');
loadinggif.hide();
});
r = jQuery('#moojla-reg-modal-content');
r.load('".$registrationurl."&return=".base64_encode('index.php?option=com_moojla&view=coursedetail&id='.$id)."',
function(){
loadinggif = jQuery('#loadinggif');
loadinggif.hide();
regform = jQuery('#member-registration');
oldaction = regform[0].getAttribute('action')
regform[0].setAttribute('action', oldaction +
'&return=' +
'".base64_encode('index.php?option=com_moojla&view=coursedetail&id='.$id)."')
});
// r.hide();
}
jQuery('#member-registration > div > div >
a').click(function(e) {
moojla_login_modal.style.display = 'none';
return false;
});
</script>";
}
public static function pageModal($btntitle, $courseid, $modid,
$pageheader, $content, $pagefooter)
{
$jid = JFactory::getUser()->id;
$mid = MoojlaHelper::joomlaToMoodleID($jid);
return "<style>
/* The Modal (background) */
.pageModal-$modid {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 10000; /* Sit on top */
padding-top: 100px; /* Location of the box */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}
/* Modal Content */
.pageModal-content-$modid {
position: relative;
background-color: #fefefe;
margin: auto;
padding: 0 20px;
border: 1px solid #888;
width: 80%;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0
rgba(0,0,0,0.19);
-webkit-animation-name: animatetop;
-webkit-animation-duration: 0.4s;
animation-name: animatetop;
animation-duration: 0.4s
}
/* Add Animation */
@-webkit-keyframes animatetop {
from {top:-300px; opacity:0}
to {top:0; opacity:1}
}
@keyframes animatetop {
from {top:-300px; opacity:0}
to {top:0; opacity:1}
}
/* The Close Button */
.close {
color: gray;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
.lmskaran-closeModal {
display: inline-flex;
margin-top: 10px;
cursor: pointer;
}
.lmskaran-closeModal > i {
color: red;
font-size: 30px;
}
</style>
<!-- Trigger/Open The Modal -->
<button id='page-$modid'>$btntitle</button>
<!-- The Modal -->
<div id='pageModal-$modid'
class='pageModal-$modid'>
<!-- Modal content -->
<div class='pageModal-content-$modid'>
<div class='pageModal-header-$modid'>
<div class='lmskaran-closeModal'><i
class='fas fa-times'></i></div>
<h2>$pageheader</h2>
</div>
<div id='pageModal-body-$modid'
class='pageModal-body-$modid'>
$content
</div>
<div class='pageModal-footer-$modid'>
<h3>$pagefooter</h3>
</div>
</div>
</div>
<script>
var span = document.getElementsByClassName('close')[0];
document.getElementById('page-$modid').onclick = function()
{
var content =
document.getElementById('pageModal-body-$modid');
jQuery.ajax({
url:
'/?option=com_moojla&view=coursedetail&task=coursedetail.getPageContent&pageid=$modid&courseid=$courseid',
}).done(function(e){
modal = document.getElementById('pageModal-$modid');
content.innerHTML = e;
viewActivity($mid, $modid)
modal.style.display = 'block';
});
}
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = 'none';
}
}
jQuery(document).ready(function($) {
$('.lmskaran-closeModal').click(function() {
modal.style.display = 'none';
});
});
</script>";
}
public static function getCurrentPriceByProductCode($product_code) {
require_once(JPATH_ADMINISTRATOR.'/components/com_hikashop/helpers/helper.php'
);
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName('product_id'));
$query->from($db->quoteName('#__hikashop_product'));
$query->where($db->quoteName('product_code') . ' =
' . $db->quote($product_code));
$query->where($db->quoteName('product_published') .
' = 1');
$db->setQuery($query);
$productid = $db->loadResult();
// dump($query->__toString());
if(!$productid)
return 0;
$user = JFactory::getUser();
$productClass = hikashop_get('class.product');
$product=$productClass->get($productid);
$currencyClass = hikashop_get('class.currency');
$config = hikashop_config();
if(is_object($product))
{
$parent = $productClass->get($product->product_parent_id);
if(!is_object($parent))
{
$parent = new stdClass;
$parent->product_id = $product->product_parent_id;
}
$ids = array($product->product_id, $parent->product_id);
$parent->variants = array($product);
$p = $currencyClass->getPrices($product, $ids,
hikashop_getCurrency(), $config->get('main_currency'),
hikashop_getZone(), $config->get('discount_before_tax'));
if(property_exists($product, 'prices'))
{
$prices = $product->prices;
if(is_array($prices))
{
$price = current($prices);
return $currencyClass->format($price->price_value_with_tax,
$price->price_currency_id);
}
}
else
return 0;
}
return 0;
}
public static function newActionButton($course, $is_enrolled, $module=null,
$returnurl='', $moodleurl='')
{
$params = JComponentHelper::getParams('com_moojla');
$sp = '-';
$jsp = '_';
$btn_index = $course->id.($module ? $sp.$module->id :
"");
$elm_index = $course->id.($module ? $jsp.$module->id :
"");
$moodle_url= $moodleurl ? $moodleurl :
trim($params->get('moodle_url'));
$loginurl = trim($course->loginurl);
if($loginurl == '')
{
$loginurl = trim($params->get('loginurl',
'index.php?option=com_users&task=login&tmpl=component'));
}
$loginurl = JRoute::_($loginurl, false);
$showlogintab = $course->showlogintab;
if($showlogintab == '' || $showlogintab == 2)
{
$showlogintab = $params->get('showlogintab', 1);
}
$showregtab = $course->showregtab;
if($showregtab == '' || $showregtab == 2)
{
$showregtab = $params->get('showregtab', 1);
}
$registrationurl = trim($course->registrationurl);
if($registrationurl == '')
{
$registrationurl = trim($params->get('registrationurl',
'index.php?option=com_users&view=registration&tmpl=component'));
}
$registrationurl = JRoute::_($registrationurl, false);
$uri = JUri::getInstance();
$returnurl = ($returnurl == '' ? $uri->toString() :
$returnurl);
$returnurl = base64_encode($returnurl);
if(trim($course->loginlbl) == '')
$btnlbl = trim($params->get('loginlbl'));
else
$btnlbl = trim($course->loginlbl);
$user = JFactory::getUser();
$is_enrolled = property_exists($course, "is_enrolled") ?
$course->is_enrolled : $is_enrolled;
$self_enrolment = $course->self_enrolment;
$guest = $course->guest;
$cost = $course->cost;
$remoteid = $course->remoteid;
$courseid = $course->id;
$btnclass = 'loginbtn';
$html =
"<style>.moojla-login-modal{display:none;position:fixed;z-index:1000;left:0;top:0;width:100%;height:100%;overflow:auto;background-color:rgb(0,0,0);background-color:rgba(0,0,0,.4);padding-top:60px}.moojla-login-modal-content{background-color:#fefefe;margin:0
auto 15% auto;border:1px solid
#888;width:40%;border-radius:20px;padding-top:20px}.close{position:absolute;right:25px;top:0;color:#000;font-size:35px;font-weight:700}.close:hover,.close:focus{color:red;cursor:pointer}.animate{-webkit-animation:animatezoom
0.8s;animation:animatezoom 0.8s}@-webkit-keyframes
animatezoom{from{-webkit-transform:scale(0)}to{-webkit-transform:scale(1)}}@keyframes
animatezoom{from{transform:scale(0)}to{transform:scale(1)}}@media screen
and
(max-width:300px){span.psw{display:block;float:none}.cancelbtn{width:100%}}.moojla-login-modal-content{background-color:transparent;border:unset;width:40%}.moojla-login-modal{background-color:rgb(0
0 0 / 69%)}ul.nav.nav-tabs.nav-stacked li
a{color:#000;padding:20px}form.form-validate.form-horizontal.well{border-bottom:unset;background:#fff}.form-horizontal
.control-label{width:100%!important}.form-horizontal
.controls{margin-right:unset!important}</style>";
if(!$user->id && $guest == 0)
{
$flag=true;
$html .= "
<a id='moojla-start-modal-$btn_index'
class='moojla-login-button $btnclass'><span
class='actionbtn-$btn_index' >$btnlbl</span></a>
<div id='moojla-modal-$btn_index'
class='moojla-login-modal' >
<div class='moojla-login-modal-content
animate'>".($showlogintab == 0 ? "" :
"<span id='logintabbtn-$btn_index'
class='active'>
Ù۱ÙŰŻ
</span>
<div
id='moojla-login-modal-content-$btn_index'>
<img
src='/components/com_moojla/assets/images/loading-modal.svg'
id='loadinggif-$btn_index'>
</div>").($showregtab == 0 ? "" :
"<span id='regtabbtn-$btn_index'>
۫ۚŰȘ ÙۧÙ
</span>
<div id='moojla-reg-modal-content-$btn_index'
class='active'>
<img
src='/components/com_moojla/assets/images/loading-modal.svg'
id='loadinggif-$btn_index'>
</div>").
"</div>
</div>
<script>
loginbtn$elm_index =
jQuery('#logintabbtn-$btn_index');
regbtn$elm_index =
jQuery('#regtabbtn-$btn_index');
l$elm_index =
jQuery('#moojla-login-modal-content-$btn_index');
r$elm_index =
jQuery('#moojla-reg-modal-content-$btn_index');
var moojla_login_modal$elm_index =
document.getElementById('moojla-modal-$btn_index');
loginbtn$elm_index.click(function(e){
l$elm_index.show();
r$elm_index.hide();
});
regbtn$elm_index.click(function(e){
r$elm_index.show();
l$elm_index.hide();
jQuery('#member-registration-$btn_index > div >
div > a').click(function(e) {
moojla_login_modal$elm_index.style.display =
'none';
return false;
});
});
document.getElementById('moojla-start-modal-$btn_index').onclick
= function() {
moojla_login_modal$elm_index.style.display
='block';
if(r$elm_index.hasClass('loaded')) {
r$elm_index.css('display', 'block');
}
l$elm_index.load('$loginurl&return=$returnurl', function(){
loadinggif$elm_index =
jQuery('#loadinggif-$btn_index');
if(loadinggif$elm_index) {
loadinggif$elm_index.hide();
l$elm_index.addClass('loaded');
}
});
r$elm_index.load('$registrationurl&return=$returnurl',
function(){
loadinggif$elm_index =
jQuery('#loadinggif-$btn_index');
if(loadinggif$elm_index) {
loadinggif$elm_index.hide();
r$elm_index.addClass('loaded');
}
regform$elm_index =
jQuery('#member-registration-$btn_index');
regf = regform$elm_index;
if(regf[0]) {
oldaction$elm_index =
regf[0].getAttribute('action')
regf[0].setAttribute('action',
oldaction$elm_index + '&return=' + '$returnurl')
}
});
// r$elm_index.hide();
// l$elm_index.hide();
".($showlogintab == 0 ?
"l$elm_index.hide();" : "r$elm_index.hide();").
"}
jQuery('#member-registration-$btn_index > div >
div > a').click(function(e) {
moojla_login_modal$elm_index.style.display =
'none';
return false;
});
window.addEventListener('click', function(e){
if(e.target == moojla_login_modal$elm_index) {
moojla_login_modal$elm_index.style.display =
'none';
l$elm_index.removeClass('hidden');
r$elm_index.removeClass('hidden');
}
});
</script>
<style>/*div#moojla-login-modal-content-$btn_index{display:flex;justify-content:center;align-items:center;background:#fff;padding:10px}input#modlgn-passwd-$btn_index,input#modlgn-username-$btn_index{margin:unset!important}span#logintabbtn-$btn_index{background:#fff;padding:15px
20px;display:inline-flex;margin-left:10px;border-radius:10px 10px 0
0;cursor:pointer}span#regtabbtn-$btn_index{background:#fff;padding:15px
20px;border-radius:10px 10px 0
0;cursor:pointer}div#moojla-reg-modal-content-$btn_index{display:block;background:#fff}
*/</style>";
}
else
{
$flag = false;
if($course->cangotomoodle == 2)
$cangotomoodle = $params->get('cangotomoodle', 0);
else
$cangotomoodle = $course->cangotomoodle;
if($is_enrolled)
{
if($cangotomoodle == 1)
{
$redirect_url = $moodle_url . 'course/view.php?id=' .
$remoteid;
$flag = true;
}
else
{
$redirect_url = '#';
$flag = false;
}
if(trim($course->enterlbl) == '')
$label = trim($params->get('enterlbl'));
else
$label = trim($course->enterlbl);
$btnclass = 'enterbtn';
$html .= "<a id='moojla-start-modal-$btn_index'
class='moojla-login-button $btnclass'
href='$redirect_url'> <span class='actionbtn'
> $label </span> </a>";
}
elseif($guest == 1)
{
if($cangotomoodle == 1)
{
$redirect_url = $moodle_url . 'course/view.php?id=' .
$remoteid;
$flag = true;
}
else
{
$redirect_url = '#';
$flag = false;
}
if(trim($course->freeenterlbl) == '')
$label = trim($params->get('freeenterlbl'));
else
$label = trim($course->freeenterlbl);
$btnclass = 'freebtn';
$html .= "<a id='moojla-start-modal-$btn_index'
class='moojla-login-button $btnclass'
href='$redirect_url'> <span class='actionbtn'
> $label </span> </a>";
}
else if($cost != 0)
{
if(trim($course->buylbl) == '')
$label = trim($params->get('buylbl'));
else
$label = trim($course->buylbl);
$btnclass = 'buybtn';
$flag = true;
$shop_integration =
trim($params->get('shop_integration'));
if($shop_integration == '0')
{
$redirect_url =
JRoute::_('index.php?option=com_moojla&view=coursedetail&id='.$tcourse->id,
false);
$app = JFactory::getApplication();
$app->enqueueMessage(JText::_('MOOJLA_NO_SHOP_INTEGRATION_SELECTED'));
// translate need
}
else if($shop_integration == 'hk') // hikashop
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName('product_id'));
$query->from($db->quoteName('#__hikashop_product'));
$query->where($db->quoteName('product_code') .
' = ' . $db->quote($remoteid));
$db->setQuery($query);
$product_id = $db->loadResult();
$redirect_url =
JRoute::_('index.php?option=com_hikashop&ctrl=product&task=show&cid='
. $product_id, false);
// $html .= "<a
id='moojla-start-modal-$btn_index'
class='moojla-login-button $btnclass'
href='$redirect_url'> <span class='actionbtn'
> $label </span> </a>";
$html .= "<a class='hikabtn hikacart'
rel='nofollow'
href='/index.php?option=com_hikashop&ctrl=product&task=updatecart&add=1&product_id=$product_id'
onclick='if(window.hikashop.addToCart){return
window.hikashop.addToCart(this);}'data-addtocart='$product_id'data-addto-class='add_in_progress'><span>$label</span></a>";
}
}
elseif($self_enrolment)
{
$redirect_url =
JRoute::_('index.php?option=com_moojla&task=coursedetail.enrol&itemid='
. $courseid . '&type=self', false);
if(trim($course->enrollbl) == '')
$label = trim($params->get('enrollbl'));
else
$label = trim($course->enrollbl);
$btnclass = 'enrolbtn';
$flag = true;
$html .= "<a id='moojla-start-modal-$btn_index'
class='moojla-login-button $btnclass'
href='$redirect_url'> <span class='actionbtn'
> $label </span> </a>";
}
}
$css = "
<style>
/*login tab */
#logintabbtn-$btn_index {
position: absolute;
right: 0px;
top: -36px;
}
#regtabbtn-$btn_index {
position: absolute;
right: 70px;
top: -36px;
}
#logintabbtn-$btn_index,#regtabbtn-$btn_index {
background: #fff;
padding: 15px 20px;
border-radius: 10px 10px 0 0;
cursor: pointer;
font-size: 16px;
font-weight:100;
color: black;
}
.moojla-login-modal-content{
position:relative;
}
/* preloader */
div#moojla-login-modal-content-$btn_index,div#moojla-reg-modal-content-$btn_index
{
background: white;
border-radius: 10px 0 10px 10px;
}
div#moojla-login-modal-content-$btn_index{
display:flex;
justify-content:center;
}
.customizedbyMJT {
padding:10px 50px;
}
.moojla-login-modal-content{
background-color: transparent;
border: unset;
width:40%;
}
.moojla-login-modal{
background-color: rgb(0 0 0 / 69%);
}
input#modlgn-username,input#modlgn-passwd {
margin: unset !important;
width: 100%;
}
.input-prepend {
width: 100%;
display: flex !important;
}
.add-on [class^='icon-'], .add-on [class*='
icon-']{
margin-left:unset !Important;
}
/*ul in tab login*/
ul.nav.nav-tabs.nav-stacked li a {
color: black;
padding: 20px;
}
/* margin unset input */
.form-horizontal .controls{
margin-right:unset !important;
}
div#form-login-submit .controls {
display: flex;
justify-content: center;
align-items: center;
}
div#form-login-submit .controls button{
width: 30%;
padding: 10px;
font-size: 1rem;
font-weight: 100;
background: #3ea2e2;
}
#moojla-reg-modal-content #cbcheckedadminForm
#registrationTable{
color:black;
}
ul#form-login-links {
font-size: 15px;
font-weight: 100;
margin-bottom: unset;
}
ul#form-login-links li {
text-align: right;
}
ul#form-login-links li a {
color: black;
}
ul#form-login-links li a:hover {
color: black;
}
#moojla-login-modal-content .image_head_modal_login {
width: 100%;
}
div#form-login-remember {
display: flex;
align-items: center;
flex-direction: row-reverse;
justify-content: flex-end;
}
div#form-login-remember label {
color: black;
font-size: 15px;
font-weight: 100;
margin-right: 5px;
}
/*moojla modal*/
#moojla-modal{
cursor: auto;
}
@media screen and (max-width: 1200px) and (min-width: 768px){
.moojla-login-modal-content{
width:60%;
}
}
@media screen and (max-width: 768px) and (min-width: 500px){
.moojla-login-modal-content{
width:80%;
}
}
@media only screen and (max-width: 500px){
.moojla-login-modal-content{
width:99%;
}
}
.lmskaran_reg_download > input{
background-color: #4ece3d;
border: unset;
}
</style>
";
$html .=$css;
return array($flag, $html);
}
public static function fileActionButton(array $options, int $type)
{
/*
type {
1 -> Modal
2 -> Embed
3 -> Scrol to top
*/
$src = $options["src"];
$id = $options["id"];
$name = $options["name"];
$course = $options["course"];
$mimetype = $options["mimetype"];
$onclick = isset($options["onclick"]) ?
$options["onclick"] :
"location.href='$src'";
$onclick = htmlspecialchars_decode($onclick);
$tagname = "";
$endigtag = "";
$jid = JFactory::getUser()->id;
$mid = MoojlaHelper::joomlaToMoodleID($jid);
$params = JComponentHelper::getParams('com_moojla');
if($course->useglobalvideo == 1)
{
$preventdownload = $params->get('preventdownload', 0);
$addcontrols = $params->get('addcontrols', 1);
$preloadvideo = $params->get('preloadvideo', 0);
$autoplay = $params->get('autoplay', 0);
$muted = $params->get('muted', 0);
}
else
{
$preventdownload = $course->preventdownload ?
$course->preventdownload : 0;
$addcontrols = $course->addcontrols ? $course->addcontrols :
1;
$preloadvideo = $course->preloadvideo ? $course->preloadvideo :
0;
$autoplay = $course->autoplay ? $course->autoplay : 0;
$muted = $course->muted ? $course->muted : 0;
$type = $course->videotype ? $course->videotype : $type;
}
switch($mimetype)
{
case 'video':
$tagname = 'video';
$endigtag = "</video>";
break;
case 'image':
$tagname = 'img';
break;
case 'audio':
$tagname = 'audio';
$endigtag = "</audio>";
break;
}
if($tagname == "")
{
$src = $onclick ? "#" : $src;
return "<a href='$src'
onclick='onClickFunction$id()' class='btn btn-primary
file-btn' id='file-btn-$id' >$name</a>
<script>
function onClickFunction$id(){
viewActivity($mid, $id);
$onclick;
}
</script>
";
}
if($tagname == 'audio')
{
$type = '2';
$addcontrols = 1;
if($course->useglobalaudio == 1)
{
$preventdownload =
$params->get('preventdownloadaudio', 0);
$preloadvideo = $params->get('preloadaudio', 0);
$autoplay = $params->get('autoplayaudio', 0);
}
else
{
$preventdownload = $course->preventdownloadaudio ?
$course->preventdownloadaudio : 0;
$preloadvideo = $course->preloadaudio ? $course->preloadaudio
: 0;
$autoplay = $course->autoplayaudio ? $course->autoplayaudio :
0;
}
}
switch($type)
{
case 1:
$html = "<button type='button' class='btn
btn-primary file-btn' id='file-btn-$id'
data-toggle='modal' data-src='$src'
data-target='#myModal-$id'>
$name
</button>
<!-- Modal -->
<div class='modal fade' id='myModal-$id'
tabindex='-1' role='dialog'
aria-labelledby='exampleModalLabel'
aria-hidden='true'>
<div class='modal-dialog'
role='document'>
<div class='modal-content'>
<div class='modal-body'>
<button type='button'
class='close' data-dismiss='modal'
aria-label='Close'>
<span
aria-hidden='true'>×</span>
</button>
<!-- 16:9 aspect ratio -->
<div class='embed-responsive
embed-responsive-16by9'>
<$tagname class='embed-responsive-item'
src=''
id='modalfile-$id'
allowscriptaccess='always' allow='autoplay'
" . ($addcontrols ? 'controls' :
'') .
" preload='" . ($preloadvideo ?
'true' : 'none') .
"' " . ($muted ? 'muted' :
''). " "
. ($preventdownload ?
'controlsList="nodownload"' : '') .
" "
. ($autoplay ? 'autoplay' : '') .
" >$endigtag
</div>
</div>
</div>
</div>
</div>
<script>
jQuery(document).ready(function($) {
// Gets the file src from the data-src on each button
var fileSrc;
$('#file-btn-$id').click(function() {
fileSrc = $(this).data('src');
});
// when the modal is opened autoplay it
$('#myModal-$id').on('shown.bs.modal',
function(e) {
// set the file src to autoplay and not to show related file.
Youtube related file is like a box of chocolates... you never know what
you're gonna get
$('#modalfile-$id').attr('src',
fileSrc);
viewActivity($mid, $id);
})
// stop playing the youtube file when I close the modal
$('#myModal-$id').on('hide.bs.modal',
function(e) {
$('#modalfile-$id').attr('src',
fileSrc);
body = $('body');
body.removeClass('modal-open');
modalback =
document.getElementsByClassName('modal-backdrop');
try
{
document.getElementById('modalfile-$id').pause();
}
catch
{
}
for (let item of modalback) {
item.remove();
}
})
});
".($preventdownload?'noRightClicks=document.getElementsByTagName(`'.$tagname.'`);for(i
= 0; i < noRightClicks.length;
i++){noRightClicks[i].addEventListener(`contextmenu`, e =>
e.preventDefault());}':'')."
</script>
<style>
.modal-dialog {
max-width: 800px;
margin: 30px auto;
}
.modal-body {
position: relative;
padding: 0px;
}
.close {
position: absolute;
right: 5px;
top: 5px;
z-index: 999;
font-size: 2rem;
font-weight: normal;
color: #fff;
opacity: 1;
text-shadow: 0 0 5px #ff0000;
}
</style>";
break;
case 2:
$html = "<button type='button' class='btn
btn-primary file-btn' onclick='show$mimetype(this, $id,
\"$src \")'>$name</button>
<script>
function show$mimetype(elm, id, src){
par = elm.parentElement;
elementExist =
par.querySelector('$tagname.resource-$mimetype');
if(!elementExist){
fileElement = document.createElement('$tagname');
fileElement.setAttribute('src', src);
if($addcontrols)
fileElement.setAttribute('controls',
'');
fileElement.setAttribute('class',
'resource-$mimetype')
if($preloadvideo == 0)
fileElement.setAttribute('preload',
'none');
if($muted)
fileElement.setAttribute('muted', '');
if($autoplay)
fileElement.setAttribute('autoplay',
'');
if($preventdownload)
fileElement.setAttribute('controlsList',
'nodownload');
par.append(fileElement);
viewActivity($mid, $id);
}
}
".($preventdownload?'noRightClicks=document.getElementsByTagName(`'.$tagname.'`);for(i
= 0; i < noRightClicks.length;
i++){noRightClicks[i].addEventListener(`contextmenu`, e =>
e.preventDefault());}':'')."
</script>";
break;
case 3:
$html = "<button type='button' class='btn
btn-primary file-btn' onclick='show$mimetype(this, $id,
\"$src \")'>$name</button>
<script>
function show$mimetype(elm, id, src){
par =
document.getElementById('lmskaran_course_image');
console.log(par);
elementExist =
par.querySelector('$tagname.resource-$mimetype');
// if(!elementExist){
fileElement = document.createElement('$tagname');
fileElement.setAttribute('src', src);
if($addcontrols)
fileElement.setAttribute('controls',
'');
fileElement.setAttribute('class',
'resource-$mimetype')
if($preloadvideo == 0)
fileElement.setAttribute('preload',
'none');
if($muted)
fileElement.setAttribute('muted', '');
if($autoplay)
fileElement.setAttribute('autoplay',
'');
if($preventdownload)
fileElement.setAttribute('controlsList',
'nodownload');
par.innerHTML = ''
par.append(fileElement);
jQuery('html, body').animate({
scrollTop: jQuery('#lmskaran_course_image').offset().top
- 100
}, 700);
viewActivity($mid, $id);
// }
}
".($preventdownload?'noRightClicks=document.getElementsByTagName(`'.$tagname.'`);for(i
= 0; i < noRightClicks.length;
i++){noRightClicks[i].addEventListener(`contextmenu`, e =>
e.preventDefault());}':'')."
</script>";
break;
}
$videowidth = trim($params->get('videowidth',
'100%'));
$videoheight = trim($params->get('videoheight',
'100%'));
$css = "
<style>
#lmskaran_course_image video.resource-video {
width: $videowidth;
height: $videoheight;
}
</style>
";
return $html . $css;
}
public static function getHierarchialTemplate($params, $templateField,
$default='default')
{
$param = $params->get($templateField);
if (!$param) {
$tmpl =
JComponentHelper::getParams('com_moojla')->get($templateField,
$default);
} else {
$tmpl = $param;
}
$tmpl = preg_replace('/\.php$/', '', $tmpl);
return $tmpl;
}
/***[/JCBGUI$$$$]***/
/**
* Load the Composer Vendors
*/
public static function composerAutoload($target)
{
// insure we load the composer vendor only once
if (!isset(self::$composer[$target]))
{
// get the function name
$functionName = self::safeString('compose' . $target);
// check if method exist
if (method_exists(__CLASS__, $functionName))
{
return self::{$functionName}();
}
return false;
}
return self::$composer[$target];
}
/**
* Load the Component xml manifest.
*/
public static function manifest()
{
$manifestUrl =
JPATH_ADMINISTRATOR."/components/com_moojla/moojla.xml";
return simplexml_load_file($manifestUrl);
}
/**
* Joomla version object
*/
protected static $JVersion;
/**
* set/get Joomla version
*/
public static function jVersion()
{
// check if set
if (!self::checkObject(self::$JVersion))
{
self::$JVersion = new JVersion();
}
return self::$JVersion;
}
/**
* Load the Contributors details.
*/
public static function getContributors()
{
// get params
$params = JComponentHelper::getParams('com_moojla');
// start contributors array
$contributors = array();
// get all Contributors (max 20)
$searchArray = range('0','20');
foreach($searchArray as $nr)
{
if ((NULL !== $params->get("showContributor".$nr))
&& ($params->get("showContributor".$nr) == 1 ||
$params->get("showContributor".$nr) == 3))
{
// set link based of selected option
if($params->get("useContributor".$nr) == 1)
{
$link_front = '<a
href="mailto:'.$params->get("emailContributor".$nr).'"
target="_blank">';
$link_back = '</a>';
}
elseif($params->get("useContributor".$nr) == 2)
{
$link_front = '<a
href="'.$params->get("linkContributor".$nr).'"
target="_blank">';
$link_back = '</a>';
}
else
{
$link_front = '';
$link_back = '';
}
$contributors[$nr]['title'] =
self::htmlEscape($params->get("titleContributor".$nr));
$contributors[$nr]['name'] =
$link_front.self::htmlEscape($params->get("nameContributor".$nr)).$link_back;
}
}
return $contributors;
}
/**
* Can be used to build help urls.
**/
public static function getHelpUrl($view)
{
return false;
}
/**
* Configure the Linkbar.
*/
public static function addSubmenu($submenu)
{
// load user for access menus
$user = JFactory::getUser();
// load the submenus to sidebar
JHtmlSidebar::addEntry(JText::_('COM_MOOJLA_SUBMENU_DASHBOARD'),
'index.php?option=com_moojla&view=moojla', $submenu ===
'moojla');
if ($user->authorise('course.access',
'com_moojla') &&
$user->authorise('course.submenu', 'com_moojla'))
{
JHtmlSidebar::addEntry(JText::_('COM_MOOJLA_SUBMENU_COURSES'),
'index.php?option=com_moojla&view=courses', $submenu ===
'courses');
JHtmlSidebar::addEntry(JText::_('COM_MOOJLA_COURSE_COURSES_CATEGORIES'),
'index.php?option=com_categories&view=categories&extension=com_moojla.course',
$submenu === 'categories.course');
}
if (JComponentHelper::isEnabled('com_fields'))
{
JHtmlSidebar::addEntry(JText::_('COM_MOOJLA_SUBMENU_COURSES_FIELDS'),
'index.php?option=com_fields&context=com_moojla.course',
$submenu === 'fields.fields');
JHtmlSidebar::addEntry(JText::_('COM_MOOJLA_SUBMENU_COURSES_FIELDS_GROUPS'),
'index.php?option=com_fields&view=groups&context=com_moojla.course',
$submenu === 'fields.groups');
}
if ($user->authorise('course_field_mapper.access',
'com_moojla') &&
$user->authorise('course_field_mapper.submenu',
'com_moojla'))
{
JHtmlSidebar::addEntry(JText::_('COM_MOOJLA_SUBMENU_COURSE_FIELDS_MAPPER'),
'index.php?option=com_moojla&view=course_fields_mapper',
$submenu === 'course_fields_mapper');
}
JHtmlSidebar::addEntry(JText::_('COM_MOOJLA_SUBMENU_USER_MAPS'),
'index.php?option=com_moojla&view=user_maps', $submenu ===
'user_maps');
JHtmlSidebar::addEntry(JText::_('COM_MOOJLA_SUBMENU_USER_FIELDS_MAP'),
'index.php?option=com_moojla&view=user_fields_map', $submenu
=== 'user_fields_map');
JHtmlSidebar::addEntry(JText::_('COM_MOOJLA_SUBMENU_COURSE_GROUP_MAPS'),
'index.php?option=com_moojla&view=course_group_maps',
$submenu === 'course_group_maps');
JHtmlSidebar::addEntry(JText::_('COM_MOOJLA_SUBMENU_ENROLMENTS'),
'index.php?option=com_moojla&view=enrolments', $submenu ===
'enrolments');
if ($user->authorise('tag.access', 'com_moojla')
&& $user->authorise('tag.submenu',
'com_moojla'))
{
JHtmlSidebar::addEntry(JText::_('COM_MOOJLA_SUBMENU_TAGS'),
'index.php?option=com_moojla&view=tags', $submenu ===
'tags');
}
if ($user->authorise('tag_instance.access',
'com_moojla') &&
$user->authorise('tag_instance.submenu',
'com_moojla'))
{
JHtmlSidebar::addEntry(JText::_('COM_MOOJLA_SUBMENU_TAG_INSTANCES'),
'index.php?option=com_moojla&view=tag_instances', $submenu
=== 'tag_instances');
}
// Access control (healthcheck.submenu).
if ($user->authorise('healthcheck.submenu',
'com_moojla'))
{
JHtmlSidebar::addEntry(JText::_('COM_MOOJLA_SUBMENU_HEALTHCHECK'),
'index.php?option=com_moojla&view=healthcheck', $submenu ===
'healthcheck');
}
JHtmlSidebar::addEntry(JText::_('COM_MOOJLA_SUBMENU_COHORTS'),
'index.php?option=com_moojla&view=cohorts', $submenu ===
'cohorts');
if ($user->authorise('language_translation.submenu',
'com_moojla'))
{
JHtmlSidebar::addEntry(JText::_('COM_MOOJLA_SUBMENU_LANGUAGETRANSLATION'),
'index.php?option=com_moojla&view=languagetranslation',
$submenu === 'languagetranslation');
}
}
/**
* Prepares the xml document
*/
public static function xls($rows, $fileName = null, $title = null,
$subjectTab = null, $creator = 'Lmskaran', $description = null,
$category = null,$keywords = null, $modified = null)
{
// set the user
$user = JFactory::getUser();
// set fileName if not set
if (!$fileName)
{
$fileName =
'exported_'.JFactory::getDate()->format('jS_F_Y');
}
// set modified if not set
if (!$modified)
{
$modified = $user->name;
}
// set title if not set
if (!$title)
{
$title = 'Book1';
}
// set tab name if not set
if (!$subjectTab)
{
$subjectTab = 'Sheet1';
}
// make sure we have the composer classes loaded
self::composerAutoload('phpspreadsheet');
// Create new Spreadsheet object
$spreadsheet = new Spreadsheet();
// Set document properties
$spreadsheet->getProperties()
->setCreator($creator)
->setCompany('Lmskaran')
->setLastModifiedBy($modified)
->setTitle($title)
->setSubject($subjectTab);
// The file type
$file_type = 'Xls';
// set description
if ($description)
{
$spreadsheet->getProperties()->setDescription($description);
}
// set keywords
if ($keywords)
{
$spreadsheet->getProperties()->setKeywords($keywords);
}
// set category
if ($category)
{
$spreadsheet->getProperties()->setCategory($category);
}
// Some styles
$headerStyles = array(
'font' => array(
'bold' => true,
'color' => array('rgb' =>
'1171A3'),
'size' => 12,
'name' => 'Verdana'
));
$sideStyles = array(
'font' => array(
'bold' => true,
'color' => array('rgb' =>
'444444'),
'size' => 11,
'name' => 'Verdana'
));
$normalStyles = array(
'font' => array(
'color' => array('rgb' =>
'444444'),
'size' => 11,
'name' => 'Verdana'
));
// Add some data
if (($size = self::checkArray($rows)) !== false)
{
$i = 1;
// Based on data size we adapt the behaviour.
$xls_mode = 1;
if ($size > 3000)
{
$xls_mode = 3;
$file_type = 'Csv';
}
elseif ($size > 2000)
{
$xls_mode = 2;
}
// Set active sheet and get it.
$active_sheet = $spreadsheet->setActiveSheetIndex(0);
foreach ($rows as $array)
{
$a = 'A';
foreach ($array as $value)
{
$active_sheet->setCellValue($a.$i, $value);
if ($xls_mode != 3)
{
if ($i == 1)
{
$active_sheet->getColumnDimension($a)->setAutoSize(true);
$active_sheet->getStyle($a.$i)->applyFromArray($headerStyles);
$active_sheet->getStyle($a.$i)->getAlignment()->setHorizontal(PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
}
elseif ($a === 'A')
{
$active_sheet->getStyle($a.$i)->applyFromArray($sideStyles);
}
elseif ($xls_mode == 1)
{
$active_sheet->getStyle($a.$i)->applyFromArray($normalStyles);
}
}
$a++;
}
$i++;
}
}
else
{
return false;
}
// Rename worksheet
$spreadsheet->getActiveSheet()->setTitle($subjectTab);
// Set active sheet index to the first sheet, so Excel opens this as the
first sheet
$spreadsheet->setActiveSheetIndex(0);
// Redirect output to a client's web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="' .
$fileName . '.' . strtolower($file_type) .'"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be
needed
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in
the past
header ('Last-Modified: '.gmdate('D, d M Y
H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0
$writer = IOFactory::createWriter($spreadsheet, $file_type);
$writer->save('php://output');
jexit();
}
/**
* Get CSV Headers
*/
public static function getFileHeaders($dataType)
{
// make sure we have the composer classes loaded
self::composerAutoload('phpspreadsheet');
// get session object
$session = JFactory::getSession();
$package = $session->get('package', null);
$package = json_decode($package, true);
// set the headers
if(isset($package['dir']))
{
// only load first three rows
$chunkFilter = new PhpOffice\PhpSpreadsheet\Reader\chunkReadFilter(2,1);
// identify the file type
$inputFileType = IOFactory::identify($package['dir']);
// create the reader for this file type
$excelReader = IOFactory::createReader($inputFileType);
// load the limiting filter
$excelReader->setReadFilter($chunkFilter);
$excelReader->setReadDataOnly(true);
// load the rows (only first three)
$excelObj = $excelReader->load($package['dir']);
$headers = array();
foreach ($excelObj->getActiveSheet()->getRowIterator() as $row)
{
if($row->getRowIndex() == 1)
{
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false);
foreach ($cellIterator as $cell)
{
if (!is_null($cell))
{
$headers[$cell->getColumn()] = $cell->getValue();
}
}
$excelObj->disconnectWorksheets();
unset($excelObj);
break;
}
}
return $headers;
}
return false;
}
/**
* Load the Composer Vendor phpspreadsheet
*/
protected static function composephpspreadsheet()
{
// load the autoloader for phpspreadsheet
require_once JPATH_SITE .
'/libraries/phpspreadsheet/vendor/autoload.php';
// do not load again
self::$composer['phpspreadsheet'] = true;
return true;
}
/**
* Get a Variable
*
* @param string $table The table from which to get the
variable
* @param string $where The value where
* @param string $whereString The target/field string where/name
* @param string $what The return field
* @param string $operator The operator between $whereString/field
and $where/value
* @param string $main The component in which the table is
found
*
* @return mix string/int/float
*
*/
public static function getVar($table, $where = null, $whereString =
'user', $what = 'id', $operator = '=', $main
= 'moojla')
{
if(!$where)
{
$where = JFactory::getUser()->id;
}
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__'.$main));
}
else
{
$query->from($db->quoteName('#__'.$main.'_'.$table));
}
if (is_numeric($where))
{
$query->where($db->quoteName($whereString) . '
'.$operator.' '.(int) $where);
}
elseif (is_string($where))
{
$query->where($db->quoteName($whereString) . '
'.$operator.' '. $db->quote((string)$where));
}
else
{
return false;
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
return $db->loadResult();
}
return false;
}
/**
* Get array of variables
*
* @param string $table The table from which to get the
variables
* @param string $where The value where
* @param string $whereString The target/field string where/name
* @param string $what The return field
* @param string $operator The operator between $whereString/field
and $where/value
* @param string $main The component in which the table is
found
* @param bool $unique The switch to return a unique array
*
* @return array
*
*/
public static function getVars($table, $where = null, $whereString =
'user', $what = 'id', $operator = 'IN', $main
= 'moojla', $unique = true)
{
if(!$where)
{
$where = JFactory::getUser()->id;
}
if (!self::checkArray($where) && $where > 0)
{
$where = array($where);
}
if (self::checkArray($where))
{
// prep main <-- why? well if $main='' is empty then $table
can be categories or users
if (self::checkString($main))
{
$main = '_'.ltrim($main, '_');
}
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__'.$main));
}
else
{
$query->from($db->quoteName('#_'.$main.'_'.$table));
}
// add strings to array search
if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS'
=== $operator)
{
$query->where($db->quoteName($whereString) . ' ' .
str_replace('_STRINGS', '', $operator) . '
("' . implode('","',$where) .
'")');
}
else
{
$query->where($db->quoteName($whereString) . ' ' .
$operator . ' (' . implode(',',$where) .
')');
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
if ($unique)
{
return array_unique($db->loadColumn());
}
return $db->loadColumn();
}
}
return false;
}
public static function jsonToString($value, $sperator = ", ",
$table = null, $id = 'id', $name = 'name')
{
// do some table foot work
$external = false;
if (strpos($table, '#__') !== false)
{
$external = true;
$table = str_replace('#__', '', $table);
}
// check if string is JSON
$result = json_decode($value, true);
if (json_last_error() === JSON_ERROR_NONE)
{
// is JSON
if (self::checkArray($result))
{
if (self::checkString($table))
{
$names = array();
foreach ($result as $val)
{
if ($external)
{
if ($_name = self::getVar(null, $val, $id, $name, '=',
$table))
{
$names[] = $_name;
}
}
else
{
if ($_name = self::getVar($table, $val, $id, $name))
{
$names[] = $_name;
}
}
}
if (self::checkArray($names))
{
return (string) implode($sperator,$names);
}
}
return (string) implode($sperator,$result);
}
return (string) json_decode($value);
}
return $value;
}
public static function isPublished($id,$type)
{
if ($type == 'raw')
{
$type = 'item';
}
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select(array('a.published'));
$query->from('#__moojla_'.$type.' AS a');
$query->where('a.id = '. (int) $id);
$query->where('a.published = 1');
$db->setQuery($query);
$db->execute();
$found = $db->getNumRows();
if($found)
{
return true;
}
return false;
}
public static function getGroupName($id)
{
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select(array('a.title'));
$query->from('#__usergroups AS a');
$query->where('a.id = '. (int) $id);
$db->setQuery($query);
$db->execute();
$found = $db->getNumRows();
if($found)
{
return $db->loadResult();
}
return $id;
}
/**
* Get the action permissions
*
* @param string $view The related view name
* @param int $record The item to act upon
* @param string $views The related list view name
* @param mixed $target Only get this permission (like edit,
create, delete)
* @param string $component The target component
* @param object $user The user whose permissions we are loading
*
* @return object The JObject of permission/authorised actions
*
*/
public static function getActions($view, &$record = null, $views =
null, $target = null, $component = 'moojla', $user =
'null')
{
// load the user if not given
if (!self::checkObject($user))
{
// get the user object
$user = JFactory::getUser();
}
// load the JObject
$result = new JObject;
// make view name safe (just incase)
$view = self::safeString($view);
if (self::checkString($views))
{
$views = self::safeString($views);
}
// get all actions from component
$actions = JAccess::getActionsFromFile(
JPATH_ADMINISTRATOR . '/components/com_' . $component .
'/access.xml',
"/access/section[@name='component']/"
);
// if non found then return empty JObject
if (empty($actions))
{
return $result;
}
// get created by if not found
if (self::checkObject($record) && !isset($record->created_by)
&& isset($record->id))
{
$record->created_by = self::getVar($view, $record->id,
'id', 'created_by', '=', $component);
}
// set actions only set in component settings
$componentActions = array('core.admin',
'core.manage', 'core.options',
'core.export');
// check if we have a target
$checkTarget = false;
if ($target)
{
// convert to an array
if (self::checkString($target))
{
$target = array($target);
}
// check if we are good to go
if (self::checkArray($target))
{
$checkTarget = true;
}
}
// loop the actions and set the permissions
foreach ($actions as $action)
{
// check target action filter
if ($checkTarget && self::filterActions($view, $action->name,
$target))
{
continue;
}
// set to use component default
$fallback = true;
// reset permission per/action
$permission = false;
$catpermission = false;
// set area
$area = 'comp';
// check if the record has an ID and the action is item related (not a
component action)
if (self::checkObject($record) && isset($record->id)
&& $record->id > 0 && !in_array($action->name,
$componentActions) &&
(strpos($action->name, 'core.') !== false ||
strpos($action->name, $view . '.') !== false))
{
// we are in item
$area = 'item';
// The record has been set. Check the record permissions.
$permission = $user->authorise($action->name, 'com_' .
$component . '.' . $view . '.' . (int) $record->id);
// if no permission found, check edit own
if (!$permission)
{
// With edit, if the created_by matches current user then dig deeper.
if (($action->name === 'core.edit' || $action->name
=== $view . '.edit') && $record->created_by > 0
&& ($record->created_by == $user->id))
{
// the correct target
$coreCheck = (array) explode('.', $action->name);
// check that we have both local and global access
if ($user->authorise($coreCheck[0] . '.edit.own',
'com_' . $component . '.' . $view . '.' .
(int) $record->id) &&
$user->authorise($coreCheck[0] . '.edit.own',
'com_' . $component))
{
// allow edit
$result->set($action->name, true);
// set not to use global default
// because we already validated it
$fallback = false;
}
else
{
// do not allow edit
$result->set($action->name, false);
$fallback = false;
}
}
}
elseif (self::checkString($views) && isset($record->catid)
&& $record->catid > 0)
{
// we are in item
$area = 'category';
// set the core check
$coreCheck = explode('.', $action->name);
$core = $coreCheck[0];
// make sure we use the core. action check for the categories
if (strpos($action->name, $view) !== false &&
strpos($action->name, 'core.') === false )
{
$coreCheck[0] = 'core';
$categoryCheck = implode('.', $coreCheck);
}
else
{
$categoryCheck = $action->name;
}
// The record has a category. Check the category permissions.
$catpermission = $user->authorise($categoryCheck, 'com_'
. $component . '.' . $views . '.category.' . (int)
$record->catid);
if (!$catpermission && !is_null($catpermission))
{
// With edit, if the created_by matches current user then dig deeper.
if (($action->name === 'core.edit' || $action->name
=== $view . '.edit') && $record->created_by > 0
&& ($record->created_by == $user->id))
{
// check that we have both local and global access
if ($user->authorise('core.edit.own', 'com_'
. $component . '.' . $views . '.category.' . (int)
$record->catid) &&
$user->authorise($core . '.edit.own', 'com_'
. $component))
{
// allow edit
$result->set($action->name, true);
// set not to use global default
// because we already validated it
$fallback = false;
}
else
{
// do not allow edit
$result->set($action->name, false);
$fallback = false;
}
}
}
}
}
// if allowed then fallback on component global settings
if ($fallback)
{
// if item/category blocks access then don't fall back on global
if ((($area === 'item') && !$permission) || (($area
=== 'category') && !$catpermission))
{
// do not allow
$result->set($action->name, false);
}
// Finally remember the global settings have the final say. (even if
item allow)
// The local item permissions can block, but it can't open and
override of global permissions.
// Since items are created by users and global permissions is set by
system admin.
else
{
$result->set($action->name,
$user->authorise($action->name, 'com_' . $component));
}
}
}
return $result;
}
/**
* Filter the action permissions
*
* @param string $action The action to check
* @param array $targets The array of target actions
*
* @return boolean true if action should be filtered out
*
*/
protected static function filterActions(&$view, &$action,
&$targets)
{
foreach ($targets as $target)
{
if (strpos($action, $view . '.' . $target) !== false ||
strpos($action, 'core.' . $target) !== false)
{
return false;
break;
}
}
return true;
}
/**
* Get any component's model
*/
public static function getModel($name, $path =
JPATH_COMPONENT_ADMINISTRATOR, $Component = 'Moojla', $config =
array())
{
// fix the name
$name = self::safeString($name);
// full path to models
$fullPathModels = $path . '/models';
// load the model file
JModelLegacy::addIncludePath($fullPathModels, $Component .
'Model');
// make sure the table path is loaded
if (!isset($config['table_path']) ||
!self::checkString($config['table_path']))
{
// This is the JCB default path to tables in Joomla 3.x
$config['table_path'] = JPATH_ADMINISTRATOR .
'/components/com_' . strtolower($Component) .
'/tables';
}
// get instance
$model = JModelLegacy::getInstance($name, $Component . 'Model',
$config);
// if model not found (strange)
if ($model == false)
{
jimport('joomla.filesystem.file');
// get file path
$filePath = $path . '/' . $name . '.php';
$fullPathModel = $fullPathModels . '/' . $name .
'.php';
// check if it exists
if (File::exists($filePath))
{
// get the file
require_once $filePath;
}
elseif (File::exists($fullPathModel))
{
// get the file
require_once $fullPathModel;
}
// build class names
$modelClass = $Component . 'Model' . $name;
if (class_exists($modelClass))
{
// initialize the model
return new $modelClass($config);
}
}
return $model;
}
/**
* Add to asset Table
*/
public static function setAsset($id, $table, $inherit = true)
{
$parent = JTable::getInstance('Asset');
$parent->loadByName('com_moojla');
$parentId = $parent->id;
$name = 'com_moojla.'.$table.'.'.$id;
$title = '';
$asset = JTable::getInstance('Asset');
$asset->loadByName($name);
// Check for an error.
$error = $asset->getError();
if ($error)
{
return false;
}
else
{
// Specify how a new or moved node asset is inserted into the tree.
if ($asset->parent_id != $parentId)
{
$asset->setLocation($parentId, 'last-child');
}
// Prepare the asset to be stored.
$asset->parent_id = $parentId;
$asset->name = $name;
$asset->title = $title;
// get the default asset rules
$rules = self::getDefaultAssetRules('com_moojla', $table,
$inherit);
if ($rules instanceof JAccessRules)
{
$asset->rules = (string) $rules;
}
if (!$asset->check() || !$asset->store())
{
JFactory::getApplication()->enqueueMessage($asset->getError(),
'warning');
return false;
}
else
{
// Create an asset_id or heal one that is corrupted.
$object = new stdClass();
// Must be a valid primary key value.
$object->id = $id;
$object->asset_id = (int) $asset->id;
// Update their asset_id to link to the asset table.
return
JFactory::getDbo()->updateObject('#__moojla_'.$table, $object,
'id');
}
}
return false;
}
/**
* Gets the default asset Rules for a component/view.
*/
protected static function getDefaultAssetRules($component, $view, $inherit
= true)
{
// if new or inherited
$assetId = 0;
// Only get the actual item rules if not inheriting
if (!$inherit)
{
// Need to find the asset id by the name of the component.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__assets'))
->where($db->quoteName('name') . ' = ' .
$db->quote($component));
$db->setQuery($query);
$db->execute();
// check that there is a value
if ($db->getNumRows())
{
// asset already set so use saved rules
$assetId = (int) $db->loadResult();
}
}
// get asset rules
$result = JAccess::getAssetRules($assetId);
if ($result instanceof JAccessRules)
{
$_result = (string) $result;
$_result = json_decode($_result);
foreach ($_result as $name => &$rule)
{
$v = explode('.', $name);
if ($view !== $v[0])
{
// remove since it is not part of this view
unset($_result->$name);
}
elseif ($inherit)
{
// clear the value since we inherit
$rule = array();
}
}
// check if there are any view values remaining
if (count((array) $_result))
{
$_result = json_encode($_result);
$_result = array($_result);
// Instantiate and return the JAccessRules object for the asset rules.
$rules = new JAccessRules($_result);
// return filtered rules
return $rules;
}
}
return $result;
}
/**
* xmlAppend
*
* @param SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param mixed $node A SimpleXMLElement node to append
to the XML element reference, or a stdClass object containing a comment
attribute to be injected before the XML node and a fieldXML attribute
containing a SimpleXMLElement
*
* @return null
*
*/
public static function xmlAppend(&$xml, $node)
{
if (!$node)
{
// element was not returned
return;
}
switch (get_class($node))
{
case 'stdClass':
if (property_exists($node, 'comment'))
{
self::xmlComment($xml, $node->comment);
}
if (property_exists($node, 'fieldXML'))
{
self::xmlAppend($xml, $node->fieldXML);
}
break;
case 'SimpleXMLElement':
$domXML = dom_import_simplexml($xml);
$domNode = dom_import_simplexml($node);
$domXML->appendChild($domXML->ownerDocument->importNode($domNode,
true));
$xml = simplexml_import_dom($domXML);
break;
}
}
/**
* xmlComment
*
* @param SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param string $comment The comment to inject
*
* @return null
*
*/
public static function xmlComment(&$xml, $comment)
{
$domXML = dom_import_simplexml($xml);
$domComment = new DOMComment($comment);
$nodeTarget = $domXML->ownerDocument->importNode($domComment,
true);
$domXML->appendChild($nodeTarget);
$xml = simplexml_import_dom($domXML);
}
/**
* xmlAddAttributes
*
* @param SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param array $attributes The attributes to apply to
the XML element
*
* @return null
*
*/
public static function xmlAddAttributes(&$xml, $attributes = array())
{
foreach ($attributes as $key => $value)
{
$xml->addAttribute($key, $value);
}
}
/**
* xmlAddOptions
*
* @param SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param array $options The options to apply to the
XML element
*
* @return void
*
*/
public static function xmlAddOptions(&$xml, $options = array())
{
foreach ($options as $key => $value)
{
$addOption = $xml->addChild('option');
$addOption->addAttribute('value', $key);
$addOption[] = $value;
}
}
/**
* get the field object
*
* @param array $attributes The array of attributes
* @param string $default The default of the field
* @param array $options The options to apply to the XML
element
*
* @return object
*
*/
public static function getFieldObject(&$attributes, $default =
'', $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes) &&
isset($attributes['type']))
{
// make sure the form helper class is loaded
if (!method_exists('JFormHelper', 'loadFieldType'))
{
jimport('joomla.form.form');
}
// get field type
$field = JFormHelper::loadFieldType($attributes['type'],
true);
// get field xml
$XML = self::getFieldXML($attributes, $options);
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
}
return false;
}
/**
* get the field xml
*
* @param array $attributes The array of attributes
* @param array $options The options to apply to the XML
element
*
* @return object
*
*/
public static function getFieldXML(&$attributes, $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes))
{
// start field xml
$XML = new SimpleXMLElement('<field/>');
// load the attributes
self::xmlAddAttributes($XML, $attributes);
// check if we have options
if (self::checkArray($options))
{
// load the options
self::xmlAddOptions($XML, $options);
}
// return the field xml
return $XML;
}
return false;
}
/**
* Render Bool Button
*
* @param array $args All the args for the button
* 0) name
* 1) additional (options class) // not used
at this time
* 2) default
* 3) yes (name)
* 4) no (name)
*
* @return string The input html of the button
*
*/
public static function renderBoolButton()
{
$args = func_get_args();
// check if there is additional button class
$additional = isset($args[1]) ? (string) $args[1] : ''; // not
used at this time
// button attributes
$buttonAttributes = array(
'type' => 'radio',
'name' => isset($args[0]) ? self::htmlEscape($args[0]) :
'bool_button',
'label' => isset($args[0]) ?
self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool
Button', // not seen anyway
'class' => 'btn-group',
'filter' => 'INT',
'default' => isset($args[2]) ? (int) $args[2] : 0);
// set the button options
$buttonOptions = array(
'1' => isset($args[3]) ? self::htmlEscape($args[3]) :
'JYES',
'0' => isset($args[4]) ? self::htmlEscape($args[4]) :
'JNO');
// return the input
return self::getFieldObject($buttonAttributes,
$buttonAttributes['default'], $buttonOptions)->input;
}
/**
* Check if have an json string
*
* @input string The json string to check
*
* @returns bool true on success
*/
public static function checkJson($string)
{
if (self::checkString($string))
{
json_decode($string);
return (json_last_error() === JSON_ERROR_NONE);
}
return false;
}
/**
* Check if have an object with a length
*
* @input object The object to check
*
* @returns bool true on success
*/
public static function checkObject($object)
{
if (isset($object) && is_object($object))
{
return count((array)$object) > 0;
}
return false;
}
/**
* Check if have an array with a length
*
* @input array The array to check
*
* @returns bool/int number of items in array on success
*/
public static function checkArray($array, $removeEmptyString = false)
{
if (isset($array) && is_array($array) && ($nr =
count((array)$array)) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
{
foreach ($array as $key => $string)
{
if (empty($string))
{
unset($array[$key]);
}
}
return self::checkArray($array, false);
}
return $nr;
}
return false;
}
/**
* Check if have a string with a length
*
* @input string The string to check
*
* @returns bool true on success
*/
public static function checkString($string)
{
if (isset($string) && is_string($string) &&
strlen($string) > 0)
{
return true;
}
return false;
}
/**
* Check if we are connected
* Thanks https://stackoverflow.com/a/4860432/1429677
*
* @returns bool true on success
*/
public static function isConnected()
{
// If example.com is down, then probably the whole internet is down,
since IANA maintains the domain. Right?
$connected = @fsockopen("www.example.com", 80);
// website, port (try 80 or 443)
if ($connected)
{
//action when connected
$is_conn = true;
fclose($connected);
}
else
{
//action in connection failure
$is_conn = false;
}
return $is_conn;
}
/**
* Merge an array of array's
*
* @input array The arrays you would like to merge
*
* @returns array on success
*/
public static function mergeArrays($arrays)
{
if(self::checkArray($arrays))
{
$arrayBuket = array();
foreach ($arrays as $array)
{
if (self::checkArray($array))
{
$arrayBuket = array_merge($arrayBuket, $array);
}
}
return $arrayBuket;
}
return false;
}
// typo sorry!
public static function sorten($string, $length = 40, $addTip = true)
{
return self::shorten($string, $length, $addTip);
}
/**
* Shorten a string
*
* @input string The you would like to shorten
*
* @returns string on success
*/
public static function shorten($string, $length = 40, $addTip = true)
{
if (self::checkString($string))
{
$initial = strlen($string);
$words = preg_split('/([\s\n\r]+)/', $string, null,
PREG_SPLIT_DELIM_CAPTURE);
$words_count = count((array)$words);
$word_length = 0;
$last_word = 0;
for (; $last_word < $words_count; ++$last_word)
{
$word_length += strlen($words[$last_word]);
if ($word_length > $length)
{
break;
}
}
$newString = implode(array_slice($words, 0, $last_word));
$final = strlen($newString);
if ($initial != $final && $addTip)
{
$title = self::shorten($string, 400 , false);
return '<span class="hasTip"
title="'.$title.'"
style="cursor:help">'.trim($newString).'...</span>';
}
elseif ($initial != $final && !$addTip)
{
return trim($newString).'...';
}
}
return $string;
}
/**
* Making strings safe (various ways)
*
* @input string The you would like to make safe
*
* @returns string on success
*/
public static function safeString($string, $type = 'L', $spacer
= '_', $replaceNumbers = true, $keepOnlyCharacters = true)
{
if ($replaceNumbers === true)
{
// remove all numbers and replace with english text version (works well
only up to millions)
$string = self::replaceNumbers($string);
}
// 0nly continue if we have a string
if (self::checkString($string))
{
// create file name without the extention that is safe
if ($type === 'filename')
{
// make sure VDM is not in the string
$string = str_replace('VDM', 'vDm', $string);
// Remove anything which isn't a word, whitespace, number
// or any of the following caracters -_()
// If you don't need to handle multi-byte characters
// you can use preg_replace rather than mb_ereg_replace
// Thanks @Ćukasz Rysiak!
// $string = mb_ereg_replace("([^\w\s\d\-_\(\)])",
'', $string);
$string = preg_replace("([^\w\s\d\-_\(\)])", '',
$string);
// http://stackoverflow.com/a/2021729/1429677
return preg_replace('/\s+/', ' ', $string);
}
// remove all other characters
$string = trim($string);
$string = preg_replace('/'.$spacer.'+/', '
', $string);
$string = preg_replace('/\s+/', ' ', $string);
// Transliterate string
$string = self::transliterate($string);
// remove all and keep only characters
if ($keepOnlyCharacters)
{
$string = preg_replace("/[^A-Za-z ]/", '',
$string);
}
// keep both numbers and characters
else
{
$string = preg_replace("/[^A-Za-z0-9 ]/", '',
$string);
}
// select final adaptations
if ($type === 'L' || $type === 'strtolower')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// default is to return lower
return strtolower($string);
}
elseif ($type === 'W')
{
// return a string with all first letter of each word uppercase(no
undersocre)
return ucwords(strtolower($string));
}
elseif ($type === 'w' || $type === 'word')
{
// return a string with all lowercase(no undersocre)
return strtolower($string);
}
elseif ($type === 'Ww' || $type === 'Word')
{
// return a string with first letter of the first word uppercase and
all the rest lowercase(no undersocre)
return ucfirst(strtolower($string));
}
elseif ($type === 'WW' || $type === 'WORD')
{
// return a string with all the uppercase(no undersocre)
return strtoupper($string);
}
elseif ($type === 'U' || $type === 'strtoupper')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return all upper
return strtoupper($string);
}
elseif ($type === 'F' || $type === 'ucfirst')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return with first caracter to upper
return ucfirst(strtolower($string));
}
elseif ($type === 'cA' || $type === 'cAmel' || $type
=== 'camelcase')
{
// convert all words to first letter uppercase
$string = ucwords(strtolower($string));
// remove white space
$string = preg_replace('/\s+/', '', $string);
// now return first letter lowercase
return lcfirst($string);
}
// return string
return $string;
}
// not a string
return '';
}
public static function transliterate($string)
{
// set tag only once
if (!self::checkString(self::$langTag))
{
// get global value
self::$langTag =
JComponentHelper::getParams('com_moojla')->get('language',
'en-GB');
}
// Transliterate on the language requested
$lang = Language::getInstance(self::$langTag);
return $lang->transliterate($string);
}
public static function htmlEscape($var, $charset = 'UTF-8',
$shorten = false, $length = 40)
{
if (self::checkString($var))
{
$filter = new JFilterInput();
$string = $filter->clean(html_entity_decode(htmlentities($var,
ENT_COMPAT, $charset)), 'HTML');
if ($shorten)
{
return self::shorten($string,$length);
}
return $string;
}
else
{
return '';
}
}
public static function replaceNumbers($string)
{
// set numbers array
$numbers = array();
// first get all numbers
preg_match_all('!\d+!', $string, $numbers);
// check if we have any numbers
if (isset($numbers[0]) && self::checkArray($numbers[0]))
{
foreach ($numbers[0] as $number)
{
$searchReplace[$number] = self::numberToString((int)$number);
}
// now replace numbers in string
$string = str_replace(array_keys($searchReplace),
array_values($searchReplace),$string);
// check if we missed any, strange if we did.
return self::replaceNumbers($string);
}
// return the string with no numbers remaining.
return $string;
}
/**
* Convert an integer into an English word string
* Thanks to Tom Nicholson
<http://php.net/manual/en/function.strval.php#41988>
*
* @input an int
* @returns a string
*/
public static function numberToString($x)
{
$nwords = array( "zero", "one", "two",
"three", "four", "five", "six",
"seven",
"eight", "nine", "ten",
"eleven", "twelve", "thirteen",
"fourteen", "fifteen", "sixteen",
"seventeen", "eighteen",
"nineteen", "twenty", 30 => "thirty",
40 => "forty",
50 => "fifty", 60 => "sixty", 70 =>
"seventy", 80 => "eighty",
90 => "ninety" );
if(!is_numeric($x))
{
$w = $x;
}
elseif(fmod($x, 1) != 0)
{
$w = $x;
}
else
{
if($x < 0)
{
$w = 'minus ';
$x = -$x;
}
else
{
$w = '';
// ... now $x is a non-negative integer.
}
if($x < 21) // 0 to 20
{
$w .= $nwords[$x];
}
elseif($x < 100) // 21 to 99
{
$w .= $nwords[10 * floor($x/10)];
$r = fmod($x, 10);
if($r > 0)
{
$w .= ' '. $nwords[$r];
}
}
elseif($x < 1000) // 100 to 999
{
$w .= $nwords[floor($x/100)] .' hundred';
$r = fmod($x, 100);
if($r > 0)
{
$w .= ' and '. self::numberToString($r);
}
}
elseif($x < 1000000) // 1000 to 999999
{
$w .= self::numberToString(floor($x/1000)) .' thousand';
$r = fmod($x, 1000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::numberToString($r);
}
}
else // millions
{
$w .= self::numberToString(floor($x/1000000)) .' million';
$r = fmod($x, 1000000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::numberToString($r);
}
}
}
return $w;
}
/**
* Random Key
*
* @returns a string
*/
public static function randomkey($size)
{
$bag =
"abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ";
$key = array();
$bagsize = strlen($bag) - 1;
for ($i = 0; $i < $size; $i++)
{
$get = rand(0, $bagsize);
$key[] = $bag[$get];
}
return implode($key);
}
}
moojlaRequestHandler.php000064400000036370151157644410011426
0ustar00<?php
define( '_JEXEC', 1 );
define( 'JPATH_BASE',
realpath(dirname(__FILE__).'/../../../..' ));
require_once ( JPATH_BASE. '/includes/defines.php' );
require_once ( JPATH_BASE. '/includes/framework.php' );
$mainframe = JFactory::getApplication('site');
$params = JComponentHelper::getParams('com_moojla');
$joomla_token = trim($params->get('joomla_token'));
$filename = __DIR__ . "/moojlaRequestHandler.txt";
// file_put_contents($filename, "joomla_token =
".print_r($joomla_token, true)."\n", FILE_APPEND);
// file_put_contents($filename, "joomla_token form moodle =
".print_r($_POST["joomla_token"], true)."\n",
FILE_APPEND);
if(!isset($_POST["joomla_token"]) || $joomla_token !=
$_POST["joomla_token"] || $joomla_token == '')
{
echo '{"status":"nok",
"result":"invalid joomla token"}';
die();
}
if(isset($_POST["moojlaFunction"]))
{
$moojlaFunction = $_POST["moojlaFunction"];
switch($moojlaFunction)
{
case "onMoojlaUserCreated":
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$filename = __DIR__ . "/onMoojlaUserCreated.txt";
$postArray = json_decode($_POST["data"], true);
$data = $postArray["data"];
// file_put_contents($filename, "data = ".print_r($data,
true)."\n", FILE_APPEND);
$results = $dispatcher->trigger("onMoojlaUserCreated",
array($data));
if($results[0]->status == "ok")
{
$object = new stdClass();
$object->id = $results[0]->id;
$object->password = $data["password"];
$result = JFactory::getDbo()->updateObject('#__users',
$object, 'id');
}
echo json_encode($results[0]); // output
break;
case "onMoojlaUserDeleted":
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$postArray = json_decode($_POST["data"], true);
$id = $postArray["id"];
$results = $dispatcher->trigger("onMoojlaUserDeleted",
array($id));
echo json_encode($results[0]); // output
break;
case "onMoojlaUserUpdated":
$filename = __DIR__ . "/onMoojlaUserUpdated.txt";
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$postArray = json_decode($_POST["data"], true);
// file_put_contents($filename, "postArray =
".print_r($postArray, true)."\n", FILE_APPEND);
$id = $postArray["id"];
$data = $postArray["data"];
$results = $dispatcher->trigger("onMoojlaUserUpdated",
array($data, $id));
if($results[0]->status == "ok")
{
$object = new stdClass();
$object->id = $results[0]->id;
$object->password = $data["password"];
$result = JFactory::getDbo()->updateObject('#__users',
$object, 'id');
$results[0]->rawpassword = $data["password"];
}
echo json_encode($results[0]); // output
break;
case "onMoojlaUserLogin":
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$postArray = json_decode($_POST["data"], true);
$username = $postArray["username"];
$password = $postArray["password"];
$from_joomla = $postArray["from_joomla"];
$results = $dispatcher->trigger("onMoojlaUserLogin",
array($username, $password, $from_joomla));
echo json_encode($results); // output
break;
case "onMoojlaUserLogout":
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$postArray = json_decode($_POST["data"], true);
$username = $postArray["username"];
$from_moodle = $postArray["from_moodle"];
$results = $dispatcher->trigger("onMoojlaUserLogout",
array($username, $from_moodle));
echo json_encode($results); // output
break;
case "onMoojlaCourseCreated":
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$postArray = json_decode($_POST["data"], true);
$filename = __DIR__ . "/onMoojlaCourseCreated.txt";
// file_put_contents($filename, "postArray =
".print_r($postArray, true)."\n", FILE_APPEND);
$results = $dispatcher->trigger("onMoojlaCourseCreated",
array($postArray));
echo json_encode($results); // output
break;
case "onMoojlaCourseUpdated":
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$postArray = json_decode($_POST["data"], true);
$filename = __DIR__ . "/onMoojlaCourseUpdated.txt";
// file_put_contents($filename, "data = ".print_r($postArray,
true)."\n", FILE_APPEND);
$dispatcher->trigger("updateCourseGroups",
array($postArray["course_id"],
$postArray["course_shortname"]));
$results = $dispatcher->trigger("onMoojlaCourseUpdated",
array($postArray));
echo json_encode($results); // output
break;
case "onMoojlaCreateGroup":
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$postArray = json_decode($_POST["data"], true);
$filename = __DIR__ . "/onMoojlaCreateGroup.txt";
// file_put_contents($filename, "data = ".print_r($postArray,
true)."\n", FILE_APPEND);
$results = $dispatcher->trigger("addCourseGroups",
array($postArray["course_id"],
$postArray["course_shortname"]));
echo json_encode($results); // output
break;
case "onMoojlaCourseDeleted":
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$postArray = json_decode($_POST["data"], true);
$filename = __DIR__ . "/onMoojlaCourseDeleted.txt";
// file_put_contents($filename, "data = ".print_r($postArray,
true)."\n", FILE_APPEND);
$results = $dispatcher->trigger("onMoojlaCourseDeleted",
array($postArray["course_id"]));
echo json_encode($results); // output
break;
case "onMoojlaCourseContentCreated":
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$postArray = json_decode($_POST["data"]);
$data = $postArray->data;
$id = $postArray->id;
$filename = __DIR__ . "/onMoojlaCourseContentCreated.txt";
// file_put_contents($filename, "data = ".print_r($postArray,
true)."\n", FILE_APPEND);
$results =
$dispatcher->trigger("onMoojlaCourseContentCreated",
array($data, $id));
echo json_encode($results); // output
break;
case "onMoojlaEnrolInstanceCreated":
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$postArray = json_decode($_POST["data"], true);
$data = $postArray["data"];
$filename = __DIR__ . "/coures_data.txt";
// file_put_contents($filename, "data = ".print_r($postArray,
true)."\n", FILE_APPEND);
$results = $dispatcher->trigger("onEnrolmentMethodAdded",
array($data));
echo json_encode($results); // output
break;
case "onMoojlaEnrolInstanceUpdated":
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$postArray = json_decode($_POST["data"], true);
$data = $postArray["data"];
$filename = __DIR__ . "/onMoojlaEnrolInstanceUpdated.txt";
// file_put_contents($filename, "postArray =
".print_r($postArray, true)."\n", FILE_APPEND);
$results =
$dispatcher->trigger("onEnrolmentMethodUpdated",
array($data));
echo json_encode($results); // output
break;
case "onMoojlaEnrolInstanceDeleted":
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$postArray = json_decode($_POST["data"], true);
$data = $postArray["data"];
// $filename = __DIR__ . "/coures_data.txt";
// file_put_contents($filename, "data = ".print_r($postArray,
true)."\n", FILE_APPEND);
$results =
$dispatcher->trigger("onEnrolmentMethodDeleted",
array($data));
echo json_encode($results); // output
break;
case "onMoojlaRoleAssigned":
$filename = __DIR__ . "/onMoojlaRoleAssigned.txt";
$postArray = json_decode($_POST["data"], true);
$course_id = $postArray["course_id"];
$user_id = $postArray["userid"];
$roleid = $postArray["roleid"];
// file_put_contents($filename, "data = ".print_r($postArray,
true)."\n", FILE_APPEND);
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$results = $dispatcher->trigger("addGroupMember",
array($course_id, $user_id, $roleid));
// file_put_contents($filename, "results =
".print_r($results, true)."\n", FILE_APPEND);
echo json_encode($results); // output
break;
case "onMoojlaRoleUnassigned":
$filename = __DIR__ . "/onMoojlaRoleUnassigned.txt";
$postArray = json_decode($_POST["data"], true);
$course_id = $postArray["course_id"];
$user_id = $postArray["userid"];
$roleid = $postArray["roleid"];
// file_put_contents($filename, "data = ".print_r($postArray,
true)."\n", FILE_APPEND);
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$results = $dispatcher->trigger("removeGroupMember",
array($course_id, $user_id, $roleid));
echo json_encode($results); // output
break;
case "onMoojlaTagAdded":
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$filename = __DIR__ . "/onMoojlaTagAdded.txt";
$postArray = json_decode($_POST["data"], true);
// file_put_contents($filename, "postArray =
".print_r($postArray, true)."\n", FILE_APPEND);
$data = $postArray["data"];
$course_id = $data['itemid'];
$tag_id = $data['tagid'];
$tag_name = $data['tagname'];
$is_standard = $data['isstandard'];
$results = $dispatcher->trigger("onMoojlaTagAdded",
array($course_id, $tag_id, $tag_name, $is_standard));
echo json_encode($results); // output
break;
case "onMoojlaTagRemoved":
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$filename = __DIR__ . "/onMoojlaTagRemoved.txt";
$postArray = json_decode($_POST["data"], true);
// file_put_contents($filename, "postArray =
".print_r($postArray, true)."\n", FILE_APPEND);
$data = $postArray["data"];
$course_id = $data['itemid'];
$tag_id = $data['tagid'];
$tag_name = $data['tagname'];
$results = $dispatcher->trigger("onMoojlaTagRemoved",
array($course_id, $tag_id, $tag_name));
echo json_encode($results); // output
break;
case "onMoojlaTagUpdated":
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$filename = __DIR__ . "/onMoojlaTagUpdated.txt";
$postArray = json_decode($_POST["data"], true);
// file_put_contents($filename, "postArray =
".print_r($postArray, true)."\n", FILE_APPEND);
$data = $postArray["data"];
$tag_id = $data['tagid'];
$tag_name = $data['tagname'];
$is_standard = $data['isstandard'];
$results = $dispatcher->trigger("onMoojlaTagUpdated",
array($tag_id, $tag_name, $is_standard));
echo json_encode($results); // output
break;
case "onMoojlaTagDeleted":
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$filename = __DIR__ . "/onMoojlaTagDeleted.txt";
$postArray = json_decode($_POST["data"], true);
// file_put_contents($filename, "postArray =
".print_r($postArray, true)."\n", FILE_APPEND);
$data = $postArray["data"];
$tag_id = $data['tagid'];
$results = $dispatcher->trigger("onMoojlaTagDeleted",
array($tag_id));
echo json_encode($results); // output
break;
case "onMoojlaEnrolled":
$filename = __DIR__ . "/onMoojlaEnrolled.txt";
$postArray = json_decode($_POST["data"], true);
$course_id = $postArray["course_id"];
$user_id = $postArray["userid"];
$roleid = $postArray["roleid"];
$timecreated = $postArray["timecreated"];
file_put_contents($filename, "data = ".print_r($postArray,
true)."\n", FILE_APPEND);
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$results = $dispatcher->trigger("addEnrolment",
array($course_id, $user_id, $roleid, $timecreated));
// file_put_contents($filename, "results =
".print_r($results, true)."\n", FILE_APPEND);
echo json_encode($results); // output
JPluginHelper::importPlugin("notifly");
$dispatcher = JEventDispatcher::getInstance();
$args = array('com_moojla.enrol', $postArray, true);
$dispatcher->trigger("onContentAfterSave", $args);
break;
case "onMoojlaUnenrolled":
$filename = __DIR__ . "/onMoojlaUnenrolled.txt";
$postArray = json_decode($_POST["data"], true);
$course_id = $postArray["course_id"];
$user_id = $postArray["userid"];
$roleid = $postArray["roleid"];
// file_put_contents($filename, "data = ".print_r($postArray,
true)."\n", FILE_APPEND);
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$results = $dispatcher->trigger("removeEnrolment",
array($course_id, $user_id, $roleid));
echo json_encode($results); // output
break;
case "onMoojlaCourseCategoryCreated":
$filename = __DIR__ . "/onMoojlaCourseCategoryCreated.txt";
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$postArray = json_decode($_POST["data"], true);
$filename = __DIR__ . "/onMoojlaCourseCreated.txt";
// file_put_contents($filename, "postArray =
".print_r($postArray, true)."\n", FILE_APPEND);
$results =
$dispatcher->trigger("createCourseCategoryWithParents",
array($postArray));
echo json_encode($results); // output
break;
case "onMoojlaCourseCategoryUpdated":
$filename = __DIR__ . "/onMoojlaCourseCategoryUpdated.txt";
JPluginHelper::importPlugin("moojlaevents");
$dispatcher = JEventDispatcher::getInstance();
$postArray = json_decode($_POST["data"], true);
// file_put_contents($filename, "postArray =
".print_r($postArray, true)."\n", FILE_APPEND);
$results = $dispatcher->trigger("updateCourseCategory",
array($postArray));
echo json_encode($results); // output
break;
case "onMoojlaSubmitted":
$filename = __DIR__ . "/onMoojlaSubmitted.txt";
JPluginHelper::importPlugin("moojlaquiz");
$dispatcher = JEventDispatcher::getInstance();
$postArray = json_decode($_POST["data"])->data;
$quizid = $postArray->quizid;
$quiztype = $postArray->quiztype;
// file_put_contents($filename, "postArray =
".print_r($postArray, true)."\n", FILE_APPEND);
if(is_array($postArray->result) &&
!empty($postArray->result))
{
$result = $postArray->result[0];
$dispatcher->trigger("addQuizAttempt", array($quiztype,
$result, $quizid));
}
// echo json_encode($results); // output
break;
default: //onMoojlaEnrolInstanceDeleted
$filename = __DIR__ . "/switch_result.txt";
// file_put_contents($filename, "moojlaFunction =
$moojlaFunction\n", FILE_APPEND);
}
}
?>hilation.php000064400000123321151157714450007100 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
@build 13th July, 2022
@created 13th July, 2022
@package Hilation
@subpackage hilation.php
@author farhad shahbazi <http://lmskaran.ir>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Language\Language;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
/**
* Hilation component helper.
*/
abstract class HilationHelper
{
/**
* Composer Switch
*
* @var array
*/
protected static $composer = array();
/**
* The Main Active Language
*
* @var string
*/
public static $langTag;
/**
* Load the Composer Vendors
*/
public static function composerAutoload($target)
{
// insure we load the composer vendor only once
if (!isset(self::$composer[$target]))
{
// get the function name
$functionName = self::safeString('compose' . $target);
// check if method exist
if (method_exists(__CLASS__, $functionName))
{
return self::{$functionName}();
}
return false;
}
return self::$composer[$target];
}
/**
* Load the Component xml manifest.
*/
public static function manifest()
{
$manifestUrl =
JPATH_ADMINISTRATOR."/components/com_hilation/hilation.xml";
return simplexml_load_file($manifestUrl);
}
/**
* Joomla version object
*/
protected static $JVersion;
/**
* set/get Joomla version
*/
public static function jVersion()
{
// check if set
if (!self::checkObject(self::$JVersion))
{
self::$JVersion = new JVersion();
}
return self::$JVersion;
}
/**
* Load the Contributors details.
*/
public static function getContributors()
{
// get params
$params = JComponentHelper::getParams('com_hilation');
// start contributors array
$contributors = array();
// get all Contributors (max 20)
$searchArray = range('0','20');
foreach($searchArray as $nr)
{
if ((NULL !== $params->get("showContributor".$nr))
&& ($params->get("showContributor".$nr) == 1 ||
$params->get("showContributor".$nr) == 3))
{
// set link based of selected option
if($params->get("useContributor".$nr) == 1)
{
$link_front = '<a
href="mailto:'.$params->get("emailContributor".$nr).'"
target="_blank">';
$link_back = '</a>';
}
elseif($params->get("useContributor".$nr) == 2)
{
$link_front = '<a
href="'.$params->get("linkContributor".$nr).'"
target="_blank">';
$link_back = '</a>';
}
else
{
$link_front = '';
$link_back = '';
}
$contributors[$nr]['title'] =
self::htmlEscape($params->get("titleContributor".$nr));
$contributors[$nr]['name'] =
$link_front.self::htmlEscape($params->get("nameContributor".$nr)).$link_back;
}
}
return $contributors;
}
/**
* Can be used to build help urls.
**/
public static function getHelpUrl($view)
{
return false;
}
/**
* Configure the Linkbar.
*/
public static function addSubmenu($submenu)
{
// load user for access menus
$user = JFactory::getUser();
// load the submenus to sidebar
JHtmlSidebar::addEntry(JText::_('COM_HILATION_SUBMENU_DASHBOARD'),
'index.php?option=com_hilation&view=hilation', $submenu ===
'hilation');
if ($user->authorise('relation.access',
'com_hilation') &&
$user->authorise('relation.submenu',
'com_hilation'))
{
JHtmlSidebar::addEntry(JText::_('COM_HILATION_SUBMENU_RELATIONS'),
'index.php?option=com_hilation&view=relations', $submenu ===
'relations');
}
}
/**
* Prepares the xml document
*/
public static function xls($rows, $fileName = null, $title = null,
$subjectTab = null, $creator = 'lmskaran', $description = null,
$category = null,$keywords = null, $modified = null)
{
// set the user
$user = JFactory::getUser();
// set fileName if not set
if (!$fileName)
{
$fileName =
'exported_'.JFactory::getDate()->format('jS_F_Y');
}
// set modified if not set
if (!$modified)
{
$modified = $user->name;
}
// set title if not set
if (!$title)
{
$title = 'Book1';
}
// set tab name if not set
if (!$subjectTab)
{
$subjectTab = 'Sheet1';
}
// make sure we have the composer classes loaded
self::composerAutoload('phpspreadsheet');
// Create new Spreadsheet object
$spreadsheet = new Spreadsheet();
// Set document properties
$spreadsheet->getProperties()
->setCreator($creator)
->setCompany('lmskaran')
->setLastModifiedBy($modified)
->setTitle($title)
->setSubject($subjectTab);
// The file type
$file_type = 'Xls';
// set description
if ($description)
{
$spreadsheet->getProperties()->setDescription($description);
}
// set keywords
if ($keywords)
{
$spreadsheet->getProperties()->setKeywords($keywords);
}
// set category
if ($category)
{
$spreadsheet->getProperties()->setCategory($category);
}
// Some styles
$headerStyles = array(
'font' => array(
'bold' => true,
'color' => array('rgb' =>
'1171A3'),
'size' => 12,
'name' => 'Verdana'
));
$sideStyles = array(
'font' => array(
'bold' => true,
'color' => array('rgb' =>
'444444'),
'size' => 11,
'name' => 'Verdana'
));
$normalStyles = array(
'font' => array(
'color' => array('rgb' =>
'444444'),
'size' => 11,
'name' => 'Verdana'
));
// Add some data
if (($size = self::checkArray($rows)) !== false)
{
$i = 1;
// Based on data size we adapt the behaviour.
$xls_mode = 1;
if ($size > 3000)
{
$xls_mode = 3;
$file_type = 'Csv';
}
elseif ($size > 2000)
{
$xls_mode = 2;
}
// Set active sheet and get it.
$active_sheet = $spreadsheet->setActiveSheetIndex(0);
foreach ($rows as $array)
{
$a = 'A';
foreach ($array as $value)
{
$active_sheet->setCellValue($a.$i, $value);
if ($xls_mode != 3)
{
if ($i == 1)
{
$active_sheet->getColumnDimension($a)->setAutoSize(true);
$active_sheet->getStyle($a.$i)->applyFromArray($headerStyles);
$active_sheet->getStyle($a.$i)->getAlignment()->setHorizontal(PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
}
elseif ($a === 'A')
{
$active_sheet->getStyle($a.$i)->applyFromArray($sideStyles);
}
elseif ($xls_mode == 1)
{
$active_sheet->getStyle($a.$i)->applyFromArray($normalStyles);
}
}
$a++;
}
$i++;
}
}
else
{
return false;
}
// Rename worksheet
$spreadsheet->getActiveSheet()->setTitle($subjectTab);
// Set active sheet index to the first sheet, so Excel opens this as the
first sheet
$spreadsheet->setActiveSheetIndex(0);
// Redirect output to a client's web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="' .
$fileName . '.' . strtolower($file_type) .'"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be
needed
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in
the past
header ('Last-Modified: '.gmdate('D, d M Y
H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0
$writer = IOFactory::createWriter($spreadsheet, $file_type);
$writer->save('php://output');
jexit();
}
/**
* Get CSV Headers
*/
public static function getFileHeaders($dataType)
{
// make sure we have the composer classes loaded
self::composerAutoload('phpspreadsheet');
// get session object
$session = JFactory::getSession();
$package = $session->get('package', null);
$package = json_decode($package, true);
// set the headers
if(isset($package['dir']))
{
// only load first three rows
$chunkFilter = new PhpOffice\PhpSpreadsheet\Reader\chunkReadFilter(2,1);
// identify the file type
$inputFileType = IOFactory::identify($package['dir']);
// create the reader for this file type
$excelReader = IOFactory::createReader($inputFileType);
// load the limiting filter
$excelReader->setReadFilter($chunkFilter);
$excelReader->setReadDataOnly(true);
// load the rows (only first three)
$excelObj = $excelReader->load($package['dir']);
$headers = array();
foreach ($excelObj->getActiveSheet()->getRowIterator() as $row)
{
if($row->getRowIndex() == 1)
{
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false);
foreach ($cellIterator as $cell)
{
if (!is_null($cell))
{
$headers[$cell->getColumn()] = $cell->getValue();
}
}
$excelObj->disconnectWorksheets();
unset($excelObj);
break;
}
}
return $headers;
}
return false;
}
/**
* Load the Composer Vendor phpspreadsheet
*/
protected static function composephpspreadsheet()
{
// load the autoloader for phpspreadsheet
require_once JPATH_SITE .
'/libraries/phpspreadsheet/vendor/autoload.php';
// do not load again
self::$composer['phpspreadsheet'] = true;
return true;
}
/**
* Get a Variable
*
* @param string $table The table from which to get the
variable
* @param string $where The value where
* @param string $whereString The target/field string where/name
* @param string $what The return field
* @param string $operator The operator between $whereString/field
and $where/value
* @param string $main The component in which the table is
found
*
* @return mix string/int/float
*
*/
public static function getVar($table, $where = null, $whereString =
'user', $what = 'id', $operator = '=', $main
= 'hilation')
{
if(!$where)
{
$where = JFactory::getUser()->id;
}
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__'.$main));
}
else
{
$query->from($db->quoteName('#__'.$main.'_'.$table));
}
if (is_numeric($where))
{
$query->where($db->quoteName($whereString) . '
'.$operator.' '.(int) $where);
}
elseif (is_string($where))
{
$query->where($db->quoteName($whereString) . '
'.$operator.' '. $db->quote((string)$where));
}
else
{
return false;
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
return $db->loadResult();
}
return false;
}
/**
* Get array of variables
*
* @param string $table The table from which to get the
variables
* @param string $where The value where
* @param string $whereString The target/field string where/name
* @param string $what The return field
* @param string $operator The operator between $whereString/field
and $where/value
* @param string $main The component in which the table is
found
* @param bool $unique The switch to return a unique array
*
* @return array
*
*/
public static function getVars($table, $where = null, $whereString =
'user', $what = 'id', $operator = 'IN', $main
= 'hilation', $unique = true)
{
if(!$where)
{
$where = JFactory::getUser()->id;
}
if (!self::checkArray($where) && $where > 0)
{
$where = array($where);
}
if (self::checkArray($where))
{
// prep main <-- why? well if $main='' is empty then $table
can be categories or users
if (self::checkString($main))
{
$main = '_'.ltrim($main, '_');
}
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__'.$main));
}
else
{
$query->from($db->quoteName('#_'.$main.'_'.$table));
}
// add strings to array search
if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS'
=== $operator)
{
$query->where($db->quoteName($whereString) . ' ' .
str_replace('_STRINGS', '', $operator) . '
("' . implode('","',$where) .
'")');
}
else
{
$query->where($db->quoteName($whereString) . ' ' .
$operator . ' (' . implode(',',$where) .
')');
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
if ($unique)
{
return array_unique($db->loadColumn());
}
return $db->loadColumn();
}
}
return false;
}
public static function jsonToString($value, $sperator = ", ",
$table = null, $id = 'id', $name = 'name')
{
// do some table foot work
$external = false;
if (strpos($table, '#__') !== false)
{
$external = true;
$table = str_replace('#__', '', $table);
}
// check if string is JSON
$result = json_decode($value, true);
if (json_last_error() === JSON_ERROR_NONE)
{
// is JSON
if (self::checkArray($result))
{
if (self::checkString($table))
{
$names = array();
foreach ($result as $val)
{
if ($external)
{
if ($_name = self::getVar(null, $val, $id, $name, '=',
$table))
{
$names[] = $_name;
}
}
else
{
if ($_name = self::getVar($table, $val, $id, $name))
{
$names[] = $_name;
}
}
}
if (self::checkArray($names))
{
return (string) implode($sperator,$names);
}
}
return (string) implode($sperator,$result);
}
return (string) json_decode($value);
}
return $value;
}
public static function isPublished($id,$type)
{
if ($type == 'raw')
{
$type = 'item';
}
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select(array('a.published'));
$query->from('#__hilation_'.$type.' AS a');
$query->where('a.id = '. (int) $id);
$query->where('a.published = 1');
$db->setQuery($query);
$db->execute();
$found = $db->getNumRows();
if($found)
{
return true;
}
return false;
}
public static function getGroupName($id)
{
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select(array('a.title'));
$query->from('#__usergroups AS a');
$query->where('a.id = '. (int) $id);
$db->setQuery($query);
$db->execute();
$found = $db->getNumRows();
if($found)
{
return $db->loadResult();
}
return $id;
}
/**
* Get the action permissions
*
* @param string $view The related view name
* @param int $record The item to act upon
* @param string $views The related list view name
* @param mixed $target Only get this permission (like edit,
create, delete)
* @param string $component The target component
* @param object $user The user whose permissions we are loading
*
* @return object The JObject of permission/authorised actions
*
*/
public static function getActions($view, &$record = null, $views =
null, $target = null, $component = 'hilation', $user =
'null')
{
// load the user if not given
if (!self::checkObject($user))
{
// get the user object
$user = JFactory::getUser();
}
// load the JObject
$result = new JObject;
// make view name safe (just incase)
$view = self::safeString($view);
if (self::checkString($views))
{
$views = self::safeString($views);
}
// get all actions from component
$actions = JAccess::getActionsFromFile(
JPATH_ADMINISTRATOR . '/components/com_' . $component .
'/access.xml',
"/access/section[@name='component']/"
);
// if non found then return empty JObject
if (empty($actions))
{
return $result;
}
// get created by if not found
if (self::checkObject($record) && !isset($record->created_by)
&& isset($record->id))
{
$record->created_by = self::getVar($view, $record->id,
'id', 'created_by', '=', $component);
}
// set actions only set in component settings
$componentActions = array('core.admin',
'core.manage', 'core.options',
'core.export');
// check if we have a target
$checkTarget = false;
if ($target)
{
// convert to an array
if (self::checkString($target))
{
$target = array($target);
}
// check if we are good to go
if (self::checkArray($target))
{
$checkTarget = true;
}
}
// loop the actions and set the permissions
foreach ($actions as $action)
{
// check target action filter
if ($checkTarget && self::filterActions($view, $action->name,
$target))
{
continue;
}
// set to use component default
$fallback = true;
// reset permission per/action
$permission = false;
$catpermission = false;
// set area
$area = 'comp';
// check if the record has an ID and the action is item related (not a
component action)
if (self::checkObject($record) && isset($record->id)
&& $record->id > 0 && !in_array($action->name,
$componentActions) &&
(strpos($action->name, 'core.') !== false ||
strpos($action->name, $view . '.') !== false))
{
// we are in item
$area = 'item';
// The record has been set. Check the record permissions.
$permission = $user->authorise($action->name, 'com_' .
$component . '.' . $view . '.' . (int) $record->id);
// if no permission found, check edit own
if (!$permission)
{
// With edit, if the created_by matches current user then dig deeper.
if (($action->name === 'core.edit' || $action->name
=== $view . '.edit') && $record->created_by > 0
&& ($record->created_by == $user->id))
{
// the correct target
$coreCheck = (array) explode('.', $action->name);
// check that we have both local and global access
if ($user->authorise($coreCheck[0] . '.edit.own',
'com_' . $component . '.' . $view . '.' .
(int) $record->id) &&
$user->authorise($coreCheck[0] . '.edit.own',
'com_' . $component))
{
// allow edit
$result->set($action->name, true);
// set not to use global default
// because we already validated it
$fallback = false;
}
else
{
// do not allow edit
$result->set($action->name, false);
$fallback = false;
}
}
}
elseif (self::checkString($views) && isset($record->catid)
&& $record->catid > 0)
{
// we are in item
$area = 'category';
// set the core check
$coreCheck = explode('.', $action->name);
$core = $coreCheck[0];
// make sure we use the core. action check for the categories
if (strpos($action->name, $view) !== false &&
strpos($action->name, 'core.') === false )
{
$coreCheck[0] = 'core';
$categoryCheck = implode('.', $coreCheck);
}
else
{
$categoryCheck = $action->name;
}
// The record has a category. Check the category permissions.
$catpermission = $user->authorise($categoryCheck, 'com_'
. $component . '.' . $views . '.category.' . (int)
$record->catid);
if (!$catpermission && !is_null($catpermission))
{
// With edit, if the created_by matches current user then dig deeper.
if (($action->name === 'core.edit' || $action->name
=== $view . '.edit') && $record->created_by > 0
&& ($record->created_by == $user->id))
{
// check that we have both local and global access
if ($user->authorise('core.edit.own', 'com_'
. $component . '.' . $views . '.category.' . (int)
$record->catid) &&
$user->authorise($core . '.edit.own', 'com_'
. $component))
{
// allow edit
$result->set($action->name, true);
// set not to use global default
// because we already validated it
$fallback = false;
}
else
{
// do not allow edit
$result->set($action->name, false);
$fallback = false;
}
}
}
}
}
// if allowed then fallback on component global settings
if ($fallback)
{
// if item/category blocks access then don't fall back on global
if ((($area === 'item') && !$permission) || (($area
=== 'category') && !$catpermission))
{
// do not allow
$result->set($action->name, false);
}
// Finally remember the global settings have the final say. (even if
item allow)
// The local item permissions can block, but it can't open and
override of global permissions.
// Since items are created by users and global permissions is set by
system admin.
else
{
$result->set($action->name,
$user->authorise($action->name, 'com_' . $component));
}
}
}
return $result;
}
/**
* Filter the action permissions
*
* @param string $action The action to check
* @param array $targets The array of target actions
*
* @return boolean true if action should be filtered out
*
*/
protected static function filterActions(&$view, &$action,
&$targets)
{
foreach ($targets as $target)
{
if (strpos($action, $view . '.' . $target) !== false ||
strpos($action, 'core.' . $target) !== false)
{
return false;
break;
}
}
return true;
}
/**
* Get any component's model
*/
public static function getModel($name, $path =
JPATH_COMPONENT_ADMINISTRATOR, $Component = 'Hilation', $config =
array())
{
// fix the name
$name = self::safeString($name);
// full path to models
$fullPathModels = $path . '/models';
// load the model file
JModelLegacy::addIncludePath($fullPathModels, $Component .
'Model');
// make sure the table path is loaded
if (!isset($config['table_path']) ||
!self::checkString($config['table_path']))
{
// This is the JCB default path to tables in Joomla 3.x
$config['table_path'] = JPATH_ADMINISTRATOR .
'/components/com_' . strtolower($Component) .
'/tables';
}
// get instance
$model = JModelLegacy::getInstance($name, $Component . 'Model',
$config);
// if model not found (strange)
if ($model == false)
{
jimport('joomla.filesystem.file');
// get file path
$filePath = $path . '/' . $name . '.php';
$fullPathModel = $fullPathModels . '/' . $name .
'.php';
// check if it exists
if (File::exists($filePath))
{
// get the file
require_once $filePath;
}
elseif (File::exists($fullPathModel))
{
// get the file
require_once $fullPathModel;
}
// build class names
$modelClass = $Component . 'Model' . $name;
if (class_exists($modelClass))
{
// initialize the model
return new $modelClass($config);
}
}
return $model;
}
/**
* Add to asset Table
*/
public static function setAsset($id, $table, $inherit = true)
{
$parent = JTable::getInstance('Asset');
$parent->loadByName('com_hilation');
$parentId = $parent->id;
$name = 'com_hilation.'.$table.'.'.$id;
$title = '';
$asset = JTable::getInstance('Asset');
$asset->loadByName($name);
// Check for an error.
$error = $asset->getError();
if ($error)
{
return false;
}
else
{
// Specify how a new or moved node asset is inserted into the tree.
if ($asset->parent_id != $parentId)
{
$asset->setLocation($parentId, 'last-child');
}
// Prepare the asset to be stored.
$asset->parent_id = $parentId;
$asset->name = $name;
$asset->title = $title;
// get the default asset rules
$rules = self::getDefaultAssetRules('com_hilation', $table,
$inherit);
if ($rules instanceof JAccessRules)
{
$asset->rules = (string) $rules;
}
if (!$asset->check() || !$asset->store())
{
JFactory::getApplication()->enqueueMessage($asset->getError(),
'warning');
return false;
}
else
{
// Create an asset_id or heal one that is corrupted.
$object = new stdClass();
// Must be a valid primary key value.
$object->id = $id;
$object->asset_id = (int) $asset->id;
// Update their asset_id to link to the asset table.
return
JFactory::getDbo()->updateObject('#__hilation_'.$table,
$object, 'id');
}
}
return false;
}
/**
* Gets the default asset Rules for a component/view.
*/
protected static function getDefaultAssetRules($component, $view, $inherit
= true)
{
// if new or inherited
$assetId = 0;
// Only get the actual item rules if not inheriting
if (!$inherit)
{
// Need to find the asset id by the name of the component.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__assets'))
->where($db->quoteName('name') . ' = ' .
$db->quote($component));
$db->setQuery($query);
$db->execute();
// check that there is a value
if ($db->getNumRows())
{
// asset already set so use saved rules
$assetId = (int) $db->loadResult();
}
}
// get asset rules
$result = JAccess::getAssetRules($assetId);
if ($result instanceof JAccessRules)
{
$_result = (string) $result;
$_result = json_decode($_result);
foreach ($_result as $name => &$rule)
{
$v = explode('.', $name);
if ($view !== $v[0])
{
// remove since it is not part of this view
unset($_result->$name);
}
elseif ($inherit)
{
// clear the value since we inherit
$rule = array();
}
}
// check if there are any view values remaining
if (count((array) $_result))
{
$_result = json_encode($_result);
$_result = array($_result);
// Instantiate and return the JAccessRules object for the asset rules.
$rules = new JAccessRules($_result);
// return filtered rules
return $rules;
}
}
return $result;
}
/**
* xmlAppend
*
* @param SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param mixed $node A SimpleXMLElement node to append
to the XML element reference, or a stdClass object containing a comment
attribute to be injected before the XML node and a fieldXML attribute
containing a SimpleXMLElement
*
* @return null
*
*/
public static function xmlAppend(&$xml, $node)
{
if (!$node)
{
// element was not returned
return;
}
switch (get_class($node))
{
case 'stdClass':
if (property_exists($node, 'comment'))
{
self::xmlComment($xml, $node->comment);
}
if (property_exists($node, 'fieldXML'))
{
self::xmlAppend($xml, $node->fieldXML);
}
break;
case 'SimpleXMLElement':
$domXML = dom_import_simplexml($xml);
$domNode = dom_import_simplexml($node);
$domXML->appendChild($domXML->ownerDocument->importNode($domNode,
true));
$xml = simplexml_import_dom($domXML);
break;
}
}
/**
* xmlComment
*
* @param SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param string $comment The comment to inject
*
* @return null
*
*/
public static function xmlComment(&$xml, $comment)
{
$domXML = dom_import_simplexml($xml);
$domComment = new DOMComment($comment);
$nodeTarget = $domXML->ownerDocument->importNode($domComment,
true);
$domXML->appendChild($nodeTarget);
$xml = simplexml_import_dom($domXML);
}
/**
* xmlAddAttributes
*
* @param SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param array $attributes The attributes to apply to
the XML element
*
* @return null
*
*/
public static function xmlAddAttributes(&$xml, $attributes = array())
{
foreach ($attributes as $key => $value)
{
$xml->addAttribute($key, $value);
}
}
/**
* xmlAddOptions
*
* @param SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param array $options The options to apply to the
XML element
*
* @return void
*
*/
public static function xmlAddOptions(&$xml, $options = array())
{
foreach ($options as $key => $value)
{
$addOption = $xml->addChild('option');
$addOption->addAttribute('value', $key);
$addOption[] = $value;
}
}
/**
* get the field object
*
* @param array $attributes The array of attributes
* @param string $default The default of the field
* @param array $options The options to apply to the XML
element
*
* @return object
*
*/
public static function getFieldObject(&$attributes, $default =
'', $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes) &&
isset($attributes['type']))
{
// make sure the form helper class is loaded
if (!method_exists('JFormHelper', 'loadFieldType'))
{
jimport('joomla.form.form');
}
// get field type
$field = JFormHelper::loadFieldType($attributes['type'],
true);
// get field xml
$XML = self::getFieldXML($attributes, $options);
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
}
return false;
}
/**
* get the field xml
*
* @param array $attributes The array of attributes
* @param array $options The options to apply to the XML
element
*
* @return object
*
*/
public static function getFieldXML(&$attributes, $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes))
{
// start field xml
$XML = new SimpleXMLElement('<field/>');
// load the attributes
self::xmlAddAttributes($XML, $attributes);
// check if we have options
if (self::checkArray($options))
{
// load the options
self::xmlAddOptions($XML, $options);
}
// return the field xml
return $XML;
}
return false;
}
/**
* Render Bool Button
*
* @param array $args All the args for the button
* 0) name
* 1) additional (options class) // not used
at this time
* 2) default
* 3) yes (name)
* 4) no (name)
*
* @return string The input html of the button
*
*/
public static function renderBoolButton()
{
$args = func_get_args();
// check if there is additional button class
$additional = isset($args[1]) ? (string) $args[1] : ''; // not
used at this time
// button attributes
$buttonAttributes = array(
'type' => 'radio',
'name' => isset($args[0]) ? self::htmlEscape($args[0]) :
'bool_button',
'label' => isset($args[0]) ?
self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool
Button', // not seen anyway
'class' => 'btn-group',
'filter' => 'INT',
'default' => isset($args[2]) ? (int) $args[2] : 0);
// set the button options
$buttonOptions = array(
'1' => isset($args[3]) ? self::htmlEscape($args[3]) :
'JYES',
'0' => isset($args[4]) ? self::htmlEscape($args[4]) :
'JNO');
// return the input
return self::getFieldObject($buttonAttributes,
$buttonAttributes['default'], $buttonOptions)->input;
}
/**
* Check if have an json string
*
* @input string The json string to check
*
* @returns bool true on success
*/
public static function checkJson($string)
{
if (self::checkString($string))
{
json_decode($string);
return (json_last_error() === JSON_ERROR_NONE);
}
return false;
}
/**
* Check if have an object with a length
*
* @input object The object to check
*
* @returns bool true on success
*/
public static function checkObject($object)
{
if (isset($object) && is_object($object))
{
return count((array)$object) > 0;
}
return false;
}
/**
* Check if have an array with a length
*
* @input array The array to check
*
* @returns bool/int number of items in array on success
*/
public static function checkArray($array, $removeEmptyString = false)
{
if (isset($array) && is_array($array) && ($nr =
count((array)$array)) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
{
foreach ($array as $key => $string)
{
if (empty($string))
{
unset($array[$key]);
}
}
return self::checkArray($array, false);
}
return $nr;
}
return false;
}
/**
* Check if have a string with a length
*
* @input string The string to check
*
* @returns bool true on success
*/
public static function checkString($string)
{
if (isset($string) && is_string($string) &&
strlen($string) > 0)
{
return true;
}
return false;
}
/**
* Check if we are connected
* Thanks https://stackoverflow.com/a/4860432/1429677
*
* @returns bool true on success
*/
public static function isConnected()
{
// If example.com is down, then probably the whole internet is down,
since IANA maintains the domain. Right?
$connected = @fsockopen("www.example.com", 80);
// website, port (try 80 or 443)
if ($connected)
{
//action when connected
$is_conn = true;
fclose($connected);
}
else
{
//action in connection failure
$is_conn = false;
}
return $is_conn;
}
/**
* Merge an array of array's
*
* @input array The arrays you would like to merge
*
* @returns array on success
*/
public static function mergeArrays($arrays)
{
if(self::checkArray($arrays))
{
$arrayBuket = array();
foreach ($arrays as $array)
{
if (self::checkArray($array))
{
$arrayBuket = array_merge($arrayBuket, $array);
}
}
return $arrayBuket;
}
return false;
}
// typo sorry!
public static function sorten($string, $length = 40, $addTip = true)
{
return self::shorten($string, $length, $addTip);
}
/**
* Shorten a string
*
* @input string The you would like to shorten
*
* @returns string on success
*/
public static function shorten($string, $length = 40, $addTip = true)
{
if (self::checkString($string))
{
$initial = strlen($string);
$words = preg_split('/([\s\n\r]+)/', $string, null,
PREG_SPLIT_DELIM_CAPTURE);
$words_count = count((array)$words);
$word_length = 0;
$last_word = 0;
for (; $last_word < $words_count; ++$last_word)
{
$word_length += strlen($words[$last_word]);
if ($word_length > $length)
{
break;
}
}
$newString = implode(array_slice($words, 0, $last_word));
$final = strlen($newString);
if ($initial != $final && $addTip)
{
$title = self::shorten($string, 400 , false);
return '<span class="hasTip"
title="'.$title.'"
style="cursor:help">'.trim($newString).'...</span>';
}
elseif ($initial != $final && !$addTip)
{
return trim($newString).'...';
}
}
return $string;
}
/**
* Making strings safe (various ways)
*
* @input string The you would like to make safe
*
* @returns string on success
*/
public static function safeString($string, $type = 'L', $spacer
= '_', $replaceNumbers = true, $keepOnlyCharacters = true)
{
if ($replaceNumbers === true)
{
// remove all numbers and replace with english text version (works well
only up to millions)
$string = self::replaceNumbers($string);
}
// 0nly continue if we have a string
if (self::checkString($string))
{
// create file name without the extention that is safe
if ($type === 'filename')
{
// make sure VDM is not in the string
$string = str_replace('VDM', 'vDm', $string);
// Remove anything which isn't a word, whitespace, number
// or any of the following caracters -_()
// If you don't need to handle multi-byte characters
// you can use preg_replace rather than mb_ereg_replace
// Thanks @Ćukasz Rysiak!
// $string = mb_ereg_replace("([^\w\s\d\-_\(\)])",
'', $string);
$string = preg_replace("([^\w\s\d\-_\(\)])", '',
$string);
// http://stackoverflow.com/a/2021729/1429677
return preg_replace('/\s+/', ' ', $string);
}
// remove all other characters
$string = trim($string);
$string = preg_replace('/'.$spacer.'+/', '
', $string);
$string = preg_replace('/\s+/', ' ', $string);
// Transliterate string
$string = self::transliterate($string);
// remove all and keep only characters
if ($keepOnlyCharacters)
{
$string = preg_replace("/[^A-Za-z ]/", '',
$string);
}
// keep both numbers and characters
else
{
$string = preg_replace("/[^A-Za-z0-9 ]/", '',
$string);
}
// select final adaptations
if ($type === 'L' || $type === 'strtolower')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// default is to return lower
return strtolower($string);
}
elseif ($type === 'W')
{
// return a string with all first letter of each word uppercase(no
undersocre)
return ucwords(strtolower($string));
}
elseif ($type === 'w' || $type === 'word')
{
// return a string with all lowercase(no undersocre)
return strtolower($string);
}
elseif ($type === 'Ww' || $type === 'Word')
{
// return a string with first letter of the first word uppercase and
all the rest lowercase(no undersocre)
return ucfirst(strtolower($string));
}
elseif ($type === 'WW' || $type === 'WORD')
{
// return a string with all the uppercase(no undersocre)
return strtoupper($string);
}
elseif ($type === 'U' || $type === 'strtoupper')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return all upper
return strtoupper($string);
}
elseif ($type === 'F' || $type === 'ucfirst')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return with first caracter to upper
return ucfirst(strtolower($string));
}
elseif ($type === 'cA' || $type === 'cAmel' || $type
=== 'camelcase')
{
// convert all words to first letter uppercase
$string = ucwords(strtolower($string));
// remove white space
$string = preg_replace('/\s+/', '', $string);
// now return first letter lowercase
return lcfirst($string);
}
// return string
return $string;
}
// not a string
return '';
}
public static function transliterate($string)
{
// set tag only once
if (!self::checkString(self::$langTag))
{
// get global value
self::$langTag =
JComponentHelper::getParams('com_hilation')->get('language',
'en-GB');
}
// Transliterate on the language requested
$lang = Language::getInstance(self::$langTag);
return $lang->transliterate($string);
}
public static function htmlEscape($var, $charset = 'UTF-8',
$shorten = false, $length = 40)
{
if (self::checkString($var))
{
$filter = new JFilterInput();
$string = $filter->clean(html_entity_decode(htmlentities($var,
ENT_COMPAT, $charset)), 'HTML');
if ($shorten)
{
return self::shorten($string,$length);
}
return $string;
}
else
{
return '';
}
}
public static function replaceNumbers($string)
{
// set numbers array
$numbers = array();
// first get all numbers
preg_match_all('!\d+!', $string, $numbers);
// check if we have any numbers
if (isset($numbers[0]) && self::checkArray($numbers[0]))
{
foreach ($numbers[0] as $number)
{
$searchReplace[$number] = self::numberToString((int)$number);
}
// now replace numbers in string
$string = str_replace(array_keys($searchReplace),
array_values($searchReplace),$string);
// check if we missed any, strange if we did.
return self::replaceNumbers($string);
}
// return the string with no numbers remaining.
return $string;
}
/**
* Convert an integer into an English word string
* Thanks to Tom Nicholson
<http://php.net/manual/en/function.strval.php#41988>
*
* @input an int
* @returns a string
*/
public static function numberToString($x)
{
$nwords = array( "zero", "one", "two",
"three", "four", "five", "six",
"seven",
"eight", "nine", "ten",
"eleven", "twelve", "thirteen",
"fourteen", "fifteen", "sixteen",
"seventeen", "eighteen",
"nineteen", "twenty", 30 => "thirty",
40 => "forty",
50 => "fifty", 60 => "sixty", 70 =>
"seventy", 80 => "eighty",
90 => "ninety" );
if(!is_numeric($x))
{
$w = $x;
}
elseif(fmod($x, 1) != 0)
{
$w = $x;
}
else
{
if($x < 0)
{
$w = 'minus ';
$x = -$x;
}
else
{
$w = '';
// ... now $x is a non-negative integer.
}
if($x < 21) // 0 to 20
{
$w .= $nwords[$x];
}
elseif($x < 100) // 21 to 99
{
$w .= $nwords[10 * floor($x/10)];
$r = fmod($x, 10);
if($r > 0)
{
$w .= ' '. $nwords[$r];
}
}
elseif($x < 1000) // 100 to 999
{
$w .= $nwords[floor($x/100)] .' hundred';
$r = fmod($x, 100);
if($r > 0)
{
$w .= ' and '. self::numberToString($r);
}
}
elseif($x < 1000000) // 1000 to 999999
{
$w .= self::numberToString(floor($x/1000)) .' thousand';
$r = fmod($x, 1000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::numberToString($r);
}
}
else // millions
{
$w .= self::numberToString(floor($x/1000000)) .' million';
$r = fmod($x, 1000000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::numberToString($r);
}
}
}
return $w;
}
/**
* Random Key
*
* @returns a string
*/
public static function randomkey($size)
{
$bag =
"abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ";
$key = array();
$bagsize = strlen($bag) - 1;
for ($i = 0; $i < $size; $i++)
{
$get = rand(0, $bagsize);
$key[] = $bag[$get];
}
return implode($key);
}
}
search.php000064400000013547151160016300006525 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/**
* BASE ON JOOMLA CORE FILE:
* /components/com_search/models/search.php
*/
/**
* @package Joomla.Site
* @subpackage com_search
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\MVC\Model\BaseDatabaseModel as JModel;
use Joomla\CMS\Pagination\Pagination as JPagination;
use Joomla\CMS\Plugin\PluginHelper as JPluginHelper;
/**
* Search Component Search Model
*
* @since 1.5
*/
class SearchModelSearch extends JModel
{
/**
* Search data array
*
* @var array
*/
protected $_data = null;
/**
* Search total
*
* @var integer
*/
protected $_total = null;
/**
* Search areas
*
* @var integer
*/
protected $_areas = null;
/**
* Pagination object
*
* @var object
*/
protected $_pagination = null;
/**
* Constructor
*
* @since 1.5
*/
public function __construct()
{
parent::__construct();
// Get configuration
$app = JFactory::getApplication();
$config = JFactory::getConfig();
// Get the pagination request variables
$this->setState('limit',
$app->getUserStateFromRequest('com_search.limit',
'limit', $config->get('list_limit'),
'uint'));
$this->setState('limitstart',
$app->input->get('limitstart', 0, 'uint'));
// Get parameters.
$params = $app->getParams();
if ($params->get('searchphrase') == 1)
{
$searchphrase = 'any';
}
elseif ($params->get('searchphrase') == 2)
{
$searchphrase = 'exact';
}
else
{
$searchphrase = 'all';
}
// Set the search parameters
$keyword =
urldecode($app->input->getString('searchword'));
$match = $app->input->get('searchphrase',
$searchphrase, 'word');
$ordering = $app->input->get('ordering',
$params->get('ordering', 'newest'),
'word');
$this->setSearch($keyword, $match, $ordering);
// Set the search areas
$areas = $app->input->get('areas', null,
'array');
$this->setAreas($areas);
}
/**
* Method to set the search parameters
*
* @param string $keyword string search string
* @param string $match matching option, exact|any|all
* @param string $ordering option, newest|oldest|popular|alpha|category
*
* @return void
*
* @access public
*/
public function setSearch($keyword, $match = 'all', $ordering =
'newest')
{
if (isset($keyword))
{
$this->setState('origkeyword', $keyword);
if ($match !== 'exact')
{
$keyword = preg_replace('#\xE3\x80\x80#s', ' ',
$keyword);
}
$this->setState('keyword', $keyword);
}
if (isset($match))
{
$this->setState('match', $match);
}
if (isset($ordering))
{
$this->setState('ordering', $ordering);
}
}
/**
* Method to get weblink item data for the category
*
* @access public
* @return array
*/
public function getData()
{
// Lets load the content if it doesn't already exist
if (empty($this->_data))
{
$areas = $this->getAreas();
JPluginHelper::importPlugin('search');
$dispatcher = JEventDispatcher::getInstance();
$results = $dispatcher->trigger('onContentSearch', [
$this->getState('keyword'),
$this->getState('match'),
$this->getState('ordering'),
$areas['active'],
]
);
$rows = [];
foreach ($results as $result)
{
$rows = array_merge((array) $rows, (array) $result);
}
$this->_total = count($rows);
if ($this->getState('limit') > 0)
{
$this->_data = array_splice($rows,
$this->getState('limitstart'),
$this->getState('limit'));
}
else
{
$this->_data = $rows;
}
/* >>> ADDED: Run content plugins over results */
$params =
JFactory::getApplication()->getParams('com_content');
$params->set('rl_search', 1);
foreach ($this->_data as $item)
{
if (empty($item->text))
{
continue;
}
$dispatcher->trigger('onContentPrepare',
['com_search.search.article', &$item, &$params, 0]);
if (empty($item->title))
{
continue;
}
// strip html tags from title
$item->title = strip_tags($item->title);
}
/* <<< */
}
return $this->_data;
}
/**
* Method to get the total number of weblink items for the category
*
* @access public
*
* @return integer
*/
public function getTotal()
{
return $this->_total;
}
/**
* Method to set the search areas
*
* @param array $active areas
* @param array $search areas
*
* @return void
*
* @access public
*/
public function setAreas($active = [], $search = [])
{
$this->_areas['active'] = $active;
$this->_areas['search'] = $search;
}
/**
* Method to get a pagination object of the weblink items for the category
*
* @access public
* @return integer
*/
public function getPagination()
{
// Lets load the content if it doesn't already exist
if (empty($this->_pagination))
{
$this->_pagination = new JPagination($this->getTotal(),
$this->getState('limitstart'),
$this->getState('limit'));
}
return $this->_pagination;
}
/**
* Method to get the search areas
*
* @return int
*
* @since 1.5
*/
public function getAreas()
{
// Load the Category data
if (empty($this->_areas['search']))
{
$areas = [];
JPluginHelper::importPlugin('search');
$dispatcher = JEventDispatcher::getInstance();
$searchareas =
$dispatcher->trigger('onContentSearchAreas');
foreach ($searchareas as $area)
{
if (is_array($area))
{
$areas = array_merge($areas, $area);
}
}
$this->_areas['search'] = $areas;
}
return $this->_areas;
}
}
site.php000064400000001402151160016300006207 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_search
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Mock JSite class used to fool the frontend search plugins because they
route the results.
*
* @since 1.5
*/
class JSite extends JObject
{
/**
* False method to fool the frontend search plugins.
*
* @return JSite
*
* @since 1.5
*/
public function getMenu()
{
$result = new JSite;
return $result;
}
/**
* False method to fool the frontend search plugins.
*
* @return array
*
* @since 1.5
*/
public function getItems()
{
return array();
}
}
molation.php000064400000123333151160230140007075 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
@build 24th July, 2022
@created 13th July, 2022
@package Molation
@subpackage molation.php
@author farhad shahbazi <http://lmskaran.ir>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Language\Language;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
/**
* Molation component helper.
*/
abstract class MolationHelper
{
/**
* Composer Switch
*
* @var array
*/
protected static $composer = array();
/**
* The Main Active Language
*
* @var string
*/
public static $langTag;
/**
* Load the Composer Vendors
*/
public static function composerAutoload($target)
{
// insure we load the composer vendor only once
if (!isset(self::$composer[$target]))
{
// get the function name
$functionName = self::safeString('compose' . $target);
// check if method exist
if (method_exists(__CLASS__, $functionName))
{
return self::{$functionName}();
}
return false;
}
return self::$composer[$target];
}
/**
* Load the Component xml manifest.
*/
public static function manifest()
{
$manifestUrl =
JPATH_ADMINISTRATOR."/components/com_molation/molation.xml";
return simplexml_load_file($manifestUrl);
}
/**
* Joomla version object
*/
protected static $JVersion;
/**
* set/get Joomla version
*/
public static function jVersion()
{
// check if set
if (!self::checkObject(self::$JVersion))
{
self::$JVersion = new JVersion();
}
return self::$JVersion;
}
/**
* Load the Contributors details.
*/
public static function getContributors()
{
// get params
$params = JComponentHelper::getParams('com_molation');
// start contributors array
$contributors = array();
// get all Contributors (max 20)
$searchArray = range('0','20');
foreach($searchArray as $nr)
{
if ((NULL !== $params->get("showContributor".$nr))
&& ($params->get("showContributor".$nr) == 1 ||
$params->get("showContributor".$nr) == 3))
{
// set link based of selected option
if($params->get("useContributor".$nr) == 1)
{
$link_front = '<a
href="mailto:'.$params->get("emailContributor".$nr).'"
target="_blank">';
$link_back = '</a>';
}
elseif($params->get("useContributor".$nr) == 2)
{
$link_front = '<a
href="'.$params->get("linkContributor".$nr).'"
target="_blank">';
$link_back = '</a>';
}
else
{
$link_front = '';
$link_back = '';
}
$contributors[$nr]['title'] =
self::htmlEscape($params->get("titleContributor".$nr));
$contributors[$nr]['name'] =
$link_front.self::htmlEscape($params->get("nameContributor".$nr)).$link_back;
}
}
return $contributors;
}
/**
* Can be used to build help urls.
**/
public static function getHelpUrl($view)
{
return false;
}
/**
* Configure the Linkbar.
*/
public static function addSubmenu($submenu)
{
// load user for access menus
$user = JFactory::getUser();
// load the submenus to sidebar
JHtmlSidebar::addEntry(JText::_('COM_MOLATION_SUBMENU_DASHBOARD'),
'index.php?option=com_molation&view=molation', $submenu ===
'molation');
if ($user->authorise('m_relation.access',
'com_molation') &&
$user->authorise('m_relation.submenu',
'com_molation'))
{
JHtmlSidebar::addEntry(JText::_('COM_MOLATION_SUBMENU_M_RELATIONS'),
'index.php?option=com_molation&view=m_relations', $submenu
=== 'm_relations');
}
}
/**
* Prepares the xml document
*/
public static function xls($rows, $fileName = null, $title = null,
$subjectTab = null, $creator = 'lmskaran', $description = null,
$category = null,$keywords = null, $modified = null)
{
// set the user
$user = JFactory::getUser();
// set fileName if not set
if (!$fileName)
{
$fileName =
'exported_'.JFactory::getDate()->format('jS_F_Y');
}
// set modified if not set
if (!$modified)
{
$modified = $user->name;
}
// set title if not set
if (!$title)
{
$title = 'Book1';
}
// set tab name if not set
if (!$subjectTab)
{
$subjectTab = 'Sheet1';
}
// make sure we have the composer classes loaded
self::composerAutoload('phpspreadsheet');
// Create new Spreadsheet object
$spreadsheet = new Spreadsheet();
// Set document properties
$spreadsheet->getProperties()
->setCreator($creator)
->setCompany('lmskaran')
->setLastModifiedBy($modified)
->setTitle($title)
->setSubject($subjectTab);
// The file type
$file_type = 'Xls';
// set description
if ($description)
{
$spreadsheet->getProperties()->setDescription($description);
}
// set keywords
if ($keywords)
{
$spreadsheet->getProperties()->setKeywords($keywords);
}
// set category
if ($category)
{
$spreadsheet->getProperties()->setCategory($category);
}
// Some styles
$headerStyles = array(
'font' => array(
'bold' => true,
'color' => array('rgb' =>
'1171A3'),
'size' => 12,
'name' => 'Verdana'
));
$sideStyles = array(
'font' => array(
'bold' => true,
'color' => array('rgb' =>
'444444'),
'size' => 11,
'name' => 'Verdana'
));
$normalStyles = array(
'font' => array(
'color' => array('rgb' =>
'444444'),
'size' => 11,
'name' => 'Verdana'
));
// Add some data
if (($size = self::checkArray($rows)) !== false)
{
$i = 1;
// Based on data size we adapt the behaviour.
$xls_mode = 1;
if ($size > 3000)
{
$xls_mode = 3;
$file_type = 'Csv';
}
elseif ($size > 2000)
{
$xls_mode = 2;
}
// Set active sheet and get it.
$active_sheet = $spreadsheet->setActiveSheetIndex(0);
foreach ($rows as $array)
{
$a = 'A';
foreach ($array as $value)
{
$active_sheet->setCellValue($a.$i, $value);
if ($xls_mode != 3)
{
if ($i == 1)
{
$active_sheet->getColumnDimension($a)->setAutoSize(true);
$active_sheet->getStyle($a.$i)->applyFromArray($headerStyles);
$active_sheet->getStyle($a.$i)->getAlignment()->setHorizontal(PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
}
elseif ($a === 'A')
{
$active_sheet->getStyle($a.$i)->applyFromArray($sideStyles);
}
elseif ($xls_mode == 1)
{
$active_sheet->getStyle($a.$i)->applyFromArray($normalStyles);
}
}
$a++;
}
$i++;
}
}
else
{
return false;
}
// Rename worksheet
$spreadsheet->getActiveSheet()->setTitle($subjectTab);
// Set active sheet index to the first sheet, so Excel opens this as the
first sheet
$spreadsheet->setActiveSheetIndex(0);
// Redirect output to a client's web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="' .
$fileName . '.' . strtolower($file_type) .'"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be
needed
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in
the past
header ('Last-Modified: '.gmdate('D, d M Y
H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0
$writer = IOFactory::createWriter($spreadsheet, $file_type);
$writer->save('php://output');
jexit();
}
/**
* Get CSV Headers
*/
public static function getFileHeaders($dataType)
{
// make sure we have the composer classes loaded
self::composerAutoload('phpspreadsheet');
// get session object
$session = JFactory::getSession();
$package = $session->get('package', null);
$package = json_decode($package, true);
// set the headers
if(isset($package['dir']))
{
// only load first three rows
$chunkFilter = new PhpOffice\PhpSpreadsheet\Reader\chunkReadFilter(2,1);
// identify the file type
$inputFileType = IOFactory::identify($package['dir']);
// create the reader for this file type
$excelReader = IOFactory::createReader($inputFileType);
// load the limiting filter
$excelReader->setReadFilter($chunkFilter);
$excelReader->setReadDataOnly(true);
// load the rows (only first three)
$excelObj = $excelReader->load($package['dir']);
$headers = array();
foreach ($excelObj->getActiveSheet()->getRowIterator() as $row)
{
if($row->getRowIndex() == 1)
{
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false);
foreach ($cellIterator as $cell)
{
if (!is_null($cell))
{
$headers[$cell->getColumn()] = $cell->getValue();
}
}
$excelObj->disconnectWorksheets();
unset($excelObj);
break;
}
}
return $headers;
}
return false;
}
/**
* Load the Composer Vendor phpspreadsheet
*/
protected static function composephpspreadsheet()
{
// load the autoloader for phpspreadsheet
require_once JPATH_SITE .
'/libraries/phpspreadsheet/vendor/autoload.php';
// do not load again
self::$composer['phpspreadsheet'] = true;
return true;
}
/**
* Get a Variable
*
* @param string $table The table from which to get the
variable
* @param string $where The value where
* @param string $whereString The target/field string where/name
* @param string $what The return field
* @param string $operator The operator between $whereString/field
and $where/value
* @param string $main The component in which the table is
found
*
* @return mix string/int/float
*
*/
public static function getVar($table, $where = null, $whereString =
'user', $what = 'id', $operator = '=', $main
= 'molation')
{
if(!$where)
{
$where = JFactory::getUser()->id;
}
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__'.$main));
}
else
{
$query->from($db->quoteName('#__'.$main.'_'.$table));
}
if (is_numeric($where))
{
$query->where($db->quoteName($whereString) . '
'.$operator.' '.(int) $where);
}
elseif (is_string($where))
{
$query->where($db->quoteName($whereString) . '
'.$operator.' '. $db->quote((string)$where));
}
else
{
return false;
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
return $db->loadResult();
}
return false;
}
/**
* Get array of variables
*
* @param string $table The table from which to get the
variables
* @param string $where The value where
* @param string $whereString The target/field string where/name
* @param string $what The return field
* @param string $operator The operator between $whereString/field
and $where/value
* @param string $main The component in which the table is
found
* @param bool $unique The switch to return a unique array
*
* @return array
*
*/
public static function getVars($table, $where = null, $whereString =
'user', $what = 'id', $operator = 'IN', $main
= 'molation', $unique = true)
{
if(!$where)
{
$where = JFactory::getUser()->id;
}
if (!self::checkArray($where) && $where > 0)
{
$where = array($where);
}
if (self::checkArray($where))
{
// prep main <-- why? well if $main='' is empty then $table
can be categories or users
if (self::checkString($main))
{
$main = '_'.ltrim($main, '_');
}
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__'.$main));
}
else
{
$query->from($db->quoteName('#_'.$main.'_'.$table));
}
// add strings to array search
if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS'
=== $operator)
{
$query->where($db->quoteName($whereString) . ' ' .
str_replace('_STRINGS', '', $operator) . '
("' . implode('","',$where) .
'")');
}
else
{
$query->where($db->quoteName($whereString) . ' ' .
$operator . ' (' . implode(',',$where) .
')');
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
if ($unique)
{
return array_unique($db->loadColumn());
}
return $db->loadColumn();
}
}
return false;
}
public static function jsonToString($value, $sperator = ", ",
$table = null, $id = 'id', $name = 'name')
{
// do some table foot work
$external = false;
if (strpos($table, '#__') !== false)
{
$external = true;
$table = str_replace('#__', '', $table);
}
// check if string is JSON
$result = json_decode($value, true);
if (json_last_error() === JSON_ERROR_NONE)
{
// is JSON
if (self::checkArray($result))
{
if (self::checkString($table))
{
$names = array();
foreach ($result as $val)
{
if ($external)
{
if ($_name = self::getVar(null, $val, $id, $name, '=',
$table))
{
$names[] = $_name;
}
}
else
{
if ($_name = self::getVar($table, $val, $id, $name))
{
$names[] = $_name;
}
}
}
if (self::checkArray($names))
{
return (string) implode($sperator,$names);
}
}
return (string) implode($sperator,$result);
}
return (string) json_decode($value);
}
return $value;
}
public static function isPublished($id,$type)
{
if ($type == 'raw')
{
$type = 'item';
}
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select(array('a.published'));
$query->from('#__molation_'.$type.' AS a');
$query->where('a.id = '. (int) $id);
$query->where('a.published = 1');
$db->setQuery($query);
$db->execute();
$found = $db->getNumRows();
if($found)
{
return true;
}
return false;
}
public static function getGroupName($id)
{
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select(array('a.title'));
$query->from('#__usergroups AS a');
$query->where('a.id = '. (int) $id);
$db->setQuery($query);
$db->execute();
$found = $db->getNumRows();
if($found)
{
return $db->loadResult();
}
return $id;
}
/**
* Get the action permissions
*
* @param string $view The related view name
* @param int $record The item to act upon
* @param string $views The related list view name
* @param mixed $target Only get this permission (like edit,
create, delete)
* @param string $component The target component
* @param object $user The user whose permissions we are loading
*
* @return object The JObject of permission/authorised actions
*
*/
public static function getActions($view, &$record = null, $views =
null, $target = null, $component = 'molation', $user =
'null')
{
// load the user if not given
if (!self::checkObject($user))
{
// get the user object
$user = JFactory::getUser();
}
// load the JObject
$result = new JObject;
// make view name safe (just incase)
$view = self::safeString($view);
if (self::checkString($views))
{
$views = self::safeString($views);
}
// get all actions from component
$actions = JAccess::getActionsFromFile(
JPATH_ADMINISTRATOR . '/components/com_' . $component .
'/access.xml',
"/access/section[@name='component']/"
);
// if non found then return empty JObject
if (empty($actions))
{
return $result;
}
// get created by if not found
if (self::checkObject($record) && !isset($record->created_by)
&& isset($record->id))
{
$record->created_by = self::getVar($view, $record->id,
'id', 'created_by', '=', $component);
}
// set actions only set in component settings
$componentActions = array('core.admin',
'core.manage', 'core.options',
'core.export');
// check if we have a target
$checkTarget = false;
if ($target)
{
// convert to an array
if (self::checkString($target))
{
$target = array($target);
}
// check if we are good to go
if (self::checkArray($target))
{
$checkTarget = true;
}
}
// loop the actions and set the permissions
foreach ($actions as $action)
{
// check target action filter
if ($checkTarget && self::filterActions($view, $action->name,
$target))
{
continue;
}
// set to use component default
$fallback = true;
// reset permission per/action
$permission = false;
$catpermission = false;
// set area
$area = 'comp';
// check if the record has an ID and the action is item related (not a
component action)
if (self::checkObject($record) && isset($record->id)
&& $record->id > 0 && !in_array($action->name,
$componentActions) &&
(strpos($action->name, 'core.') !== false ||
strpos($action->name, $view . '.') !== false))
{
// we are in item
$area = 'item';
// The record has been set. Check the record permissions.
$permission = $user->authorise($action->name, 'com_' .
$component . '.' . $view . '.' . (int) $record->id);
// if no permission found, check edit own
if (!$permission)
{
// With edit, if the created_by matches current user then dig deeper.
if (($action->name === 'core.edit' || $action->name
=== $view . '.edit') && $record->created_by > 0
&& ($record->created_by == $user->id))
{
// the correct target
$coreCheck = (array) explode('.', $action->name);
// check that we have both local and global access
if ($user->authorise($coreCheck[0] . '.edit.own',
'com_' . $component . '.' . $view . '.' .
(int) $record->id) &&
$user->authorise($coreCheck[0] . '.edit.own',
'com_' . $component))
{
// allow edit
$result->set($action->name, true);
// set not to use global default
// because we already validated it
$fallback = false;
}
else
{
// do not allow edit
$result->set($action->name, false);
$fallback = false;
}
}
}
elseif (self::checkString($views) && isset($record->catid)
&& $record->catid > 0)
{
// we are in item
$area = 'category';
// set the core check
$coreCheck = explode('.', $action->name);
$core = $coreCheck[0];
// make sure we use the core. action check for the categories
if (strpos($action->name, $view) !== false &&
strpos($action->name, 'core.') === false )
{
$coreCheck[0] = 'core';
$categoryCheck = implode('.', $coreCheck);
}
else
{
$categoryCheck = $action->name;
}
// The record has a category. Check the category permissions.
$catpermission = $user->authorise($categoryCheck, 'com_'
. $component . '.' . $views . '.category.' . (int)
$record->catid);
if (!$catpermission && !is_null($catpermission))
{
// With edit, if the created_by matches current user then dig deeper.
if (($action->name === 'core.edit' || $action->name
=== $view . '.edit') && $record->created_by > 0
&& ($record->created_by == $user->id))
{
// check that we have both local and global access
if ($user->authorise('core.edit.own', 'com_'
. $component . '.' . $views . '.category.' . (int)
$record->catid) &&
$user->authorise($core . '.edit.own', 'com_'
. $component))
{
// allow edit
$result->set($action->name, true);
// set not to use global default
// because we already validated it
$fallback = false;
}
else
{
// do not allow edit
$result->set($action->name, false);
$fallback = false;
}
}
}
}
}
// if allowed then fallback on component global settings
if ($fallback)
{
// if item/category blocks access then don't fall back on global
if ((($area === 'item') && !$permission) || (($area
=== 'category') && !$catpermission))
{
// do not allow
$result->set($action->name, false);
}
// Finally remember the global settings have the final say. (even if
item allow)
// The local item permissions can block, but it can't open and
override of global permissions.
// Since items are created by users and global permissions is set by
system admin.
else
{
$result->set($action->name,
$user->authorise($action->name, 'com_' . $component));
}
}
}
return $result;
}
/**
* Filter the action permissions
*
* @param string $action The action to check
* @param array $targets The array of target actions
*
* @return boolean true if action should be filtered out
*
*/
protected static function filterActions(&$view, &$action,
&$targets)
{
foreach ($targets as $target)
{
if (strpos($action, $view . '.' . $target) !== false ||
strpos($action, 'core.' . $target) !== false)
{
return false;
break;
}
}
return true;
}
/**
* Get any component's model
*/
public static function getModel($name, $path =
JPATH_COMPONENT_ADMINISTRATOR, $Component = 'Molation', $config =
array())
{
// fix the name
$name = self::safeString($name);
// full path to models
$fullPathModels = $path . '/models';
// load the model file
JModelLegacy::addIncludePath($fullPathModels, $Component .
'Model');
// make sure the table path is loaded
if (!isset($config['table_path']) ||
!self::checkString($config['table_path']))
{
// This is the JCB default path to tables in Joomla 3.x
$config['table_path'] = JPATH_ADMINISTRATOR .
'/components/com_' . strtolower($Component) .
'/tables';
}
// get instance
$model = JModelLegacy::getInstance($name, $Component . 'Model',
$config);
// if model not found (strange)
if ($model == false)
{
jimport('joomla.filesystem.file');
// get file path
$filePath = $path . '/' . $name . '.php';
$fullPathModel = $fullPathModels . '/' . $name .
'.php';
// check if it exists
if (File::exists($filePath))
{
// get the file
require_once $filePath;
}
elseif (File::exists($fullPathModel))
{
// get the file
require_once $fullPathModel;
}
// build class names
$modelClass = $Component . 'Model' . $name;
if (class_exists($modelClass))
{
// initialize the model
return new $modelClass($config);
}
}
return $model;
}
/**
* Add to asset Table
*/
public static function setAsset($id, $table, $inherit = true)
{
$parent = JTable::getInstance('Asset');
$parent->loadByName('com_molation');
$parentId = $parent->id;
$name = 'com_molation.'.$table.'.'.$id;
$title = '';
$asset = JTable::getInstance('Asset');
$asset->loadByName($name);
// Check for an error.
$error = $asset->getError();
if ($error)
{
return false;
}
else
{
// Specify how a new or moved node asset is inserted into the tree.
if ($asset->parent_id != $parentId)
{
$asset->setLocation($parentId, 'last-child');
}
// Prepare the asset to be stored.
$asset->parent_id = $parentId;
$asset->name = $name;
$asset->title = $title;
// get the default asset rules
$rules = self::getDefaultAssetRules('com_molation', $table,
$inherit);
if ($rules instanceof JAccessRules)
{
$asset->rules = (string) $rules;
}
if (!$asset->check() || !$asset->store())
{
JFactory::getApplication()->enqueueMessage($asset->getError(),
'warning');
return false;
}
else
{
// Create an asset_id or heal one that is corrupted.
$object = new stdClass();
// Must be a valid primary key value.
$object->id = $id;
$object->asset_id = (int) $asset->id;
// Update their asset_id to link to the asset table.
return
JFactory::getDbo()->updateObject('#__molation_'.$table,
$object, 'id');
}
}
return false;
}
/**
* Gets the default asset Rules for a component/view.
*/
protected static function getDefaultAssetRules($component, $view, $inherit
= true)
{
// if new or inherited
$assetId = 0;
// Only get the actual item rules if not inheriting
if (!$inherit)
{
// Need to find the asset id by the name of the component.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__assets'))
->where($db->quoteName('name') . ' = ' .
$db->quote($component));
$db->setQuery($query);
$db->execute();
// check that there is a value
if ($db->getNumRows())
{
// asset already set so use saved rules
$assetId = (int) $db->loadResult();
}
}
// get asset rules
$result = JAccess::getAssetRules($assetId);
if ($result instanceof JAccessRules)
{
$_result = (string) $result;
$_result = json_decode($_result);
foreach ($_result as $name => &$rule)
{
$v = explode('.', $name);
if ($view !== $v[0])
{
// remove since it is not part of this view
unset($_result->$name);
}
elseif ($inherit)
{
// clear the value since we inherit
$rule = array();
}
}
// check if there are any view values remaining
if (count((array) $_result))
{
$_result = json_encode($_result);
$_result = array($_result);
// Instantiate and return the JAccessRules object for the asset rules.
$rules = new JAccessRules($_result);
// return filtered rules
return $rules;
}
}
return $result;
}
/**
* xmlAppend
*
* @param SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param mixed $node A SimpleXMLElement node to append
to the XML element reference, or a stdClass object containing a comment
attribute to be injected before the XML node and a fieldXML attribute
containing a SimpleXMLElement
*
* @return null
*
*/
public static function xmlAppend(&$xml, $node)
{
if (!$node)
{
// element was not returned
return;
}
switch (get_class($node))
{
case 'stdClass':
if (property_exists($node, 'comment'))
{
self::xmlComment($xml, $node->comment);
}
if (property_exists($node, 'fieldXML'))
{
self::xmlAppend($xml, $node->fieldXML);
}
break;
case 'SimpleXMLElement':
$domXML = dom_import_simplexml($xml);
$domNode = dom_import_simplexml($node);
$domXML->appendChild($domXML->ownerDocument->importNode($domNode,
true));
$xml = simplexml_import_dom($domXML);
break;
}
}
/**
* xmlComment
*
* @param SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param string $comment The comment to inject
*
* @return null
*
*/
public static function xmlComment(&$xml, $comment)
{
$domXML = dom_import_simplexml($xml);
$domComment = new DOMComment($comment);
$nodeTarget = $domXML->ownerDocument->importNode($domComment,
true);
$domXML->appendChild($nodeTarget);
$xml = simplexml_import_dom($domXML);
}
/**
* xmlAddAttributes
*
* @param SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param array $attributes The attributes to apply to
the XML element
*
* @return null
*
*/
public static function xmlAddAttributes(&$xml, $attributes = array())
{
foreach ($attributes as $key => $value)
{
$xml->addAttribute($key, $value);
}
}
/**
* xmlAddOptions
*
* @param SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param array $options The options to apply to the
XML element
*
* @return void
*
*/
public static function xmlAddOptions(&$xml, $options = array())
{
foreach ($options as $key => $value)
{
$addOption = $xml->addChild('option');
$addOption->addAttribute('value', $key);
$addOption[] = $value;
}
}
/**
* get the field object
*
* @param array $attributes The array of attributes
* @param string $default The default of the field
* @param array $options The options to apply to the XML
element
*
* @return object
*
*/
public static function getFieldObject(&$attributes, $default =
'', $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes) &&
isset($attributes['type']))
{
// make sure the form helper class is loaded
if (!method_exists('JFormHelper', 'loadFieldType'))
{
jimport('joomla.form.form');
}
// get field type
$field = JFormHelper::loadFieldType($attributes['type'],
true);
// get field xml
$XML = self::getFieldXML($attributes, $options);
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
}
return false;
}
/**
* get the field xml
*
* @param array $attributes The array of attributes
* @param array $options The options to apply to the XML
element
*
* @return object
*
*/
public static function getFieldXML(&$attributes, $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes))
{
// start field xml
$XML = new SimpleXMLElement('<field/>');
// load the attributes
self::xmlAddAttributes($XML, $attributes);
// check if we have options
if (self::checkArray($options))
{
// load the options
self::xmlAddOptions($XML, $options);
}
// return the field xml
return $XML;
}
return false;
}
/**
* Render Bool Button
*
* @param array $args All the args for the button
* 0) name
* 1) additional (options class) // not used
at this time
* 2) default
* 3) yes (name)
* 4) no (name)
*
* @return string The input html of the button
*
*/
public static function renderBoolButton()
{
$args = func_get_args();
// check if there is additional button class
$additional = isset($args[1]) ? (string) $args[1] : ''; // not
used at this time
// button attributes
$buttonAttributes = array(
'type' => 'radio',
'name' => isset($args[0]) ? self::htmlEscape($args[0]) :
'bool_button',
'label' => isset($args[0]) ?
self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool
Button', // not seen anyway
'class' => 'btn-group',
'filter' => 'INT',
'default' => isset($args[2]) ? (int) $args[2] : 0);
// set the button options
$buttonOptions = array(
'1' => isset($args[3]) ? self::htmlEscape($args[3]) :
'JYES',
'0' => isset($args[4]) ? self::htmlEscape($args[4]) :
'JNO');
// return the input
return self::getFieldObject($buttonAttributes,
$buttonAttributes['default'], $buttonOptions)->input;
}
/**
* Check if have an json string
*
* @input string The json string to check
*
* @returns bool true on success
*/
public static function checkJson($string)
{
if (self::checkString($string))
{
json_decode($string);
return (json_last_error() === JSON_ERROR_NONE);
}
return false;
}
/**
* Check if have an object with a length
*
* @input object The object to check
*
* @returns bool true on success
*/
public static function checkObject($object)
{
if (isset($object) && is_object($object))
{
return count((array)$object) > 0;
}
return false;
}
/**
* Check if have an array with a length
*
* @input array The array to check
*
* @returns bool/int number of items in array on success
*/
public static function checkArray($array, $removeEmptyString = false)
{
if (isset($array) && is_array($array) && ($nr =
count((array)$array)) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
{
foreach ($array as $key => $string)
{
if (empty($string))
{
unset($array[$key]);
}
}
return self::checkArray($array, false);
}
return $nr;
}
return false;
}
/**
* Check if have a string with a length
*
* @input string The string to check
*
* @returns bool true on success
*/
public static function checkString($string)
{
if (isset($string) && is_string($string) &&
strlen($string) > 0)
{
return true;
}
return false;
}
/**
* Check if we are connected
* Thanks https://stackoverflow.com/a/4860432/1429677
*
* @returns bool true on success
*/
public static function isConnected()
{
// If example.com is down, then probably the whole internet is down,
since IANA maintains the domain. Right?
$connected = @fsockopen("www.example.com", 80);
// website, port (try 80 or 443)
if ($connected)
{
//action when connected
$is_conn = true;
fclose($connected);
}
else
{
//action in connection failure
$is_conn = false;
}
return $is_conn;
}
/**
* Merge an array of array's
*
* @input array The arrays you would like to merge
*
* @returns array on success
*/
public static function mergeArrays($arrays)
{
if(self::checkArray($arrays))
{
$arrayBuket = array();
foreach ($arrays as $array)
{
if (self::checkArray($array))
{
$arrayBuket = array_merge($arrayBuket, $array);
}
}
return $arrayBuket;
}
return false;
}
// typo sorry!
public static function sorten($string, $length = 40, $addTip = true)
{
return self::shorten($string, $length, $addTip);
}
/**
* Shorten a string
*
* @input string The you would like to shorten
*
* @returns string on success
*/
public static function shorten($string, $length = 40, $addTip = true)
{
if (self::checkString($string))
{
$initial = strlen($string);
$words = preg_split('/([\s\n\r]+)/', $string, null,
PREG_SPLIT_DELIM_CAPTURE);
$words_count = count((array)$words);
$word_length = 0;
$last_word = 0;
for (; $last_word < $words_count; ++$last_word)
{
$word_length += strlen($words[$last_word]);
if ($word_length > $length)
{
break;
}
}
$newString = implode(array_slice($words, 0, $last_word));
$final = strlen($newString);
if ($initial != $final && $addTip)
{
$title = self::shorten($string, 400 , false);
return '<span class="hasTip"
title="'.$title.'"
style="cursor:help">'.trim($newString).'...</span>';
}
elseif ($initial != $final && !$addTip)
{
return trim($newString).'...';
}
}
return $string;
}
/**
* Making strings safe (various ways)
*
* @input string The you would like to make safe
*
* @returns string on success
*/
public static function safeString($string, $type = 'L', $spacer
= '_', $replaceNumbers = true, $keepOnlyCharacters = true)
{
if ($replaceNumbers === true)
{
// remove all numbers and replace with english text version (works well
only up to millions)
$string = self::replaceNumbers($string);
}
// 0nly continue if we have a string
if (self::checkString($string))
{
// create file name without the extention that is safe
if ($type === 'filename')
{
// make sure VDM is not in the string
$string = str_replace('VDM', 'vDm', $string);
// Remove anything which isn't a word, whitespace, number
// or any of the following caracters -_()
// If you don't need to handle multi-byte characters
// you can use preg_replace rather than mb_ereg_replace
// Thanks @Ćukasz Rysiak!
// $string = mb_ereg_replace("([^\w\s\d\-_\(\)])",
'', $string);
$string = preg_replace("([^\w\s\d\-_\(\)])", '',
$string);
// http://stackoverflow.com/a/2021729/1429677
return preg_replace('/\s+/', ' ', $string);
}
// remove all other characters
$string = trim($string);
$string = preg_replace('/'.$spacer.'+/', '
', $string);
$string = preg_replace('/\s+/', ' ', $string);
// Transliterate string
$string = self::transliterate($string);
// remove all and keep only characters
if ($keepOnlyCharacters)
{
$string = preg_replace("/[^A-Za-z ]/", '',
$string);
}
// keep both numbers and characters
else
{
$string = preg_replace("/[^A-Za-z0-9 ]/", '',
$string);
}
// select final adaptations
if ($type === 'L' || $type === 'strtolower')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// default is to return lower
return strtolower($string);
}
elseif ($type === 'W')
{
// return a string with all first letter of each word uppercase(no
undersocre)
return ucwords(strtolower($string));
}
elseif ($type === 'w' || $type === 'word')
{
// return a string with all lowercase(no undersocre)
return strtolower($string);
}
elseif ($type === 'Ww' || $type === 'Word')
{
// return a string with first letter of the first word uppercase and
all the rest lowercase(no undersocre)
return ucfirst(strtolower($string));
}
elseif ($type === 'WW' || $type === 'WORD')
{
// return a string with all the uppercase(no undersocre)
return strtoupper($string);
}
elseif ($type === 'U' || $type === 'strtoupper')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return all upper
return strtoupper($string);
}
elseif ($type === 'F' || $type === 'ucfirst')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return with first caracter to upper
return ucfirst(strtolower($string));
}
elseif ($type === 'cA' || $type === 'cAmel' || $type
=== 'camelcase')
{
// convert all words to first letter uppercase
$string = ucwords(strtolower($string));
// remove white space
$string = preg_replace('/\s+/', '', $string);
// now return first letter lowercase
return lcfirst($string);
}
// return string
return $string;
}
// not a string
return '';
}
public static function transliterate($string)
{
// set tag only once
if (!self::checkString(self::$langTag))
{
// get global value
self::$langTag =
JComponentHelper::getParams('com_molation')->get('language',
'en-GB');
}
// Transliterate on the language requested
$lang = Language::getInstance(self::$langTag);
return $lang->transliterate($string);
}
public static function htmlEscape($var, $charset = 'UTF-8',
$shorten = false, $length = 40)
{
if (self::checkString($var))
{
$filter = new JFilterInput();
$string = $filter->clean(html_entity_decode(htmlentities($var,
ENT_COMPAT, $charset)), 'HTML');
if ($shorten)
{
return self::shorten($string,$length);
}
return $string;
}
else
{
return '';
}
}
public static function replaceNumbers($string)
{
// set numbers array
$numbers = array();
// first get all numbers
preg_match_all('!\d+!', $string, $numbers);
// check if we have any numbers
if (isset($numbers[0]) && self::checkArray($numbers[0]))
{
foreach ($numbers[0] as $number)
{
$searchReplace[$number] = self::numberToString((int)$number);
}
// now replace numbers in string
$string = str_replace(array_keys($searchReplace),
array_values($searchReplace),$string);
// check if we missed any, strange if we did.
return self::replaceNumbers($string);
}
// return the string with no numbers remaining.
return $string;
}
/**
* Convert an integer into an English word string
* Thanks to Tom Nicholson
<http://php.net/manual/en/function.strval.php#41988>
*
* @input an int
* @returns a string
*/
public static function numberToString($x)
{
$nwords = array( "zero", "one", "two",
"three", "four", "five", "six",
"seven",
"eight", "nine", "ten",
"eleven", "twelve", "thirteen",
"fourteen", "fifteen", "sixteen",
"seventeen", "eighteen",
"nineteen", "twenty", 30 => "thirty",
40 => "forty",
50 => "fifty", 60 => "sixty", 70 =>
"seventy", 80 => "eighty",
90 => "ninety" );
if(!is_numeric($x))
{
$w = $x;
}
elseif(fmod($x, 1) != 0)
{
$w = $x;
}
else
{
if($x < 0)
{
$w = 'minus ';
$x = -$x;
}
else
{
$w = '';
// ... now $x is a non-negative integer.
}
if($x < 21) // 0 to 20
{
$w .= $nwords[$x];
}
elseif($x < 100) // 21 to 99
{
$w .= $nwords[10 * floor($x/10)];
$r = fmod($x, 10);
if($r > 0)
{
$w .= ' '. $nwords[$r];
}
}
elseif($x < 1000) // 100 to 999
{
$w .= $nwords[floor($x/100)] .' hundred';
$r = fmod($x, 100);
if($r > 0)
{
$w .= ' and '. self::numberToString($r);
}
}
elseif($x < 1000000) // 1000 to 999999
{
$w .= self::numberToString(floor($x/1000)) .' thousand';
$r = fmod($x, 1000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::numberToString($r);
}
}
else // millions
{
$w .= self::numberToString(floor($x/1000000)) .' million';
$r = fmod($x, 1000000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::numberToString($r);
}
}
}
return $w;
}
/**
* Random Key
*
* @returns a string
*/
public static function randomkey($size)
{
$bag =
"abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ";
$key = array();
$bagsize = strlen($bag) - 1;
for ($i = 0; $i < $size; $i++)
{
$get = rand(0, $bagsize);
$key[] = $bag[$get];
}
return implode($key);
}
}
events.php000064400000002504151160360150006560 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_notifly
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Notifly component helper.
*
* @since 1.6
*/
class NotiflyEventsHelper
{
public static function getList($random = false)
{
$events = NotiflyEventsHelper::getEvents($random);
$results = [];
foreach ($events as $key => $event) {
$item = [];
$item['message'] =
NotiflyMessageHelper::parseMessage($event->message, $event);
$item['image'] = $event->image_url;
$item['url'] = $event->url;
$results[] = $item;
}
// print_r($results);die;
return $results;
}
public static function getEvents($random = false)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select("a.*, m.message")
->from('#__notifly_events as a')
->join('LEFT', '#__notifly_templates AS m ON m.id =
a.template_id')
->where($db->quoteName('a.published') . ' =
1');
if($random){
$query->order('rand() DESC');
}else{
$query->order($db->quoteName('a.id') . '
DESC');
}
// get the setLimit form config
$query->setLimit('20');
$db->setQuery($query);
$result = $db->loadObjectList();
return $result;
}
}
message.php000064400000011654151160360150006706 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_notifly
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Notifly component helper.
*
* @since 1.6
*/
class NotiflyMessageHelper
{
/**
* Returns valid contexts
* @param time of action
*
* @return array
*
* @since 1.0.0
*/
public static function parseMessage($msg, $event)
{
$title = isset($event->title) && !empty($event->title) ?
$event->title : JText::_('COM_NOTIFLY_MESSAGE_TITLE');
$url = isset($event->url) && !empty($event->url) ?
JRoute::_($event->url) : Juri::root();
$m = new Mustache_Engine;
$data = array(
'name' => isset($event->name) &&
!empty($event->name) ? $event->name :
JText::_('COM_NOTIFLY_MESSAGE_SOMEONE'),
'city' => isset($event->city) &&
!empty($event->city) ? $event->city :
JText::_('COM_NOTIFLY_MESSAGE_CITY_UNKNOWN'),
'province' => isset($event->province) &&
!empty($event->province) ? $event->province :
JText::_('COM_NOTIFLY_MESSAGE_PROVINCE_UNKNOWN'),
'country' => isset($event->country) &&
!empty($event->country) ? $event->country :
JText::_('COM_NOTIFLY_MESSAGE_COUNTRY_UNKNOWN'),
'title' => $title,
'url' => $url,
'title_with_link' =>
'['.$title.']('.$url.')', //'<a
href="'.$url.'">'.$title.'</a>',
'time_ago' => isset($event->created) &&
!empty($event->created) ?
NotiflyMessageHelper::getFormatedTime($event->created) :
JText::_('COM_NOTIFLY_MESSAGE_CREATED')
);
return $m->render($msg, $data);
}
/**
* Returns valid contexts
* @param ip
*
* @return array
*
* @since 1.0.0
*/
public static function getLocation($ip)
{
//
http://api.db-ip.com/v2/e9a901d2b1df53e77ab70dc79a74d11558d3bdb9/61.6.1.39
// http://freegeoip.net/json/?q=119.148.0.0
try {
// Set up custom headers for a single request.
$headers = array('Accept' => 'application/json');
$http = JHttpFactory::getHttp();
// In this case, the Accept header in $headers will override the options
header.
$response = $http->get('http://freegeoip.net/json/' . $ip,
$headers);
if($response->code == '200'){
$data = json_decode($response->body, true);
return $data;
}
} catch (Exception $e) {
// Add a message to the message queue
JFactory::getApplication()->enqueueMessage(JText::_('COM_NOTIFLY_ERROR_LOCATION'),
'error');
}
}
/**
* Get either a Gravatar URL or complete image tag for a specified email
address.
*
* @param string $email The email address
* @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ]
* @param string $d Default imageset to use [ 404 | mm | identicon |
monsterid | wavatar ]
* @param string $r Maximum rating (inclusive) [ g | pg | r | x ]
* @param boole $img True to return a complete IMG tag False for just the
URL
* @param array $atts Optional, additional key/value attributes to include
in the IMG tag
* @return String containing either just a URL or a complete image tag
* @source https://gravatar.com/site/implement/images/php/
*/
public static function getGravater( $email, $s = 80, $d = 'mm',
$r = 'g', $img = false, $atts = array() ) {
$url = 'https://www.gravatar.com/avatar/';
$url .= md5( strtolower( trim( $email ) ) );
$url .= "?s=$s&d=$d&r=$r";
if ( $img ) {
$url = '<img src="' . $url . '"';
foreach ( $atts as $key => $val )
$url .= ' ' . $key . '="' . $val .
'"';
$url .= ' />';
}
return $url;
}
public static function getRealIpAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from
share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to
check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}
//https://stackoverflow.com/questions/1416697/converting-timestamp-to-time-ago-in-php-e-g-1-day-ago-2-days-ago
public static function getFormatedTime($datetime, $full = false)
{
$zone = JFactory::getConfig()->get('offset');
$now = JFactory::getDate( 'now' , $zone );
$ago = JFactory::getDate( $datetime , $zone );
$diff = $now->diff($ago);
$diff->w = floor($diff->d / 7);
$diff->d -= $diff->w * 7;
$string = array(
'y' => 'year',
'm' => 'month',
'w' => 'week',
'd' => 'day',
'h' => 'hour',
'i' => 'minute',
's' => 'second',
);
foreach ($string as $k => &$v) {
if ($diff->$k) {
$v = $diff->$k . ' ' . $v . ($diff->$k > 1
? 's' : '');
} else {
unset($string[$k]);
}
}
if (!$full) $string = array_slice($string, 0, 1);
return $string ? implode(', ', $string) . ' '.
JText::_('COM_NOTIFLY_MESSAGE_AGO') :
JText::_('COM_NOTIFLY_MESSAGE_NOW');
}
}
notifly.php000064400000011026151160360150006737 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_notifly
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Notifly component helper.
*
* @since 1.6
*/
class NotiflyHelper extends JHelperContent
{
public static $extension = 'com_notifly';
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since 1.6
*/
public static function addSubmenu($vName)
{
JHtmlSidebar::addEntry(
JText::_('COM_NOTIFLY_SUBMENU_DASHBOARD'),
'index.php?option=com_notifly&view=dashboard',
$vName == 'dashboard'
);
JHtmlSidebar::addEntry(
JText::_('COM_NOTIFLY_SUBMENU_TEMPLATES'),
'index.php?option=com_notifly&view=templates',
$vName == 'templates'
);
JHtmlSidebar::addEntry(
JText::_('COM_NOTIFLY_SUBMENU_INTEGRATIONS'),
'index.php?option=com_notifly&view=integrations',
$vName == 'integrations'
);
JHtmlSidebar::addEntry(
JText::_('COM_NOTIFLY_SUBMENU_EVENTS'),
'index.php?option=com_notifly&view=events',
$vName == 'events'
);
JHtmlSidebar::addEntry(
JText::_('COM_NOTIFLY_SUBMENU_DESIGN'),
'index.php?option=com_notifly&view=design',
$vName == 'design'
);
}
/**
* Applies the content tag filters to arbitrary text as per settings for
current user group
*
* @param text $text The string to filter
*
* @return string The filtered string
*
* @deprecated 4.0 Use JComponentHelper::filterText() instead.
*/
public static function filterText($text)
{
try
{
JLog::add(
sprintf('%s() is deprecated. Use JComponentHelper::filterText()
instead', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
return JComponentHelper::filterText($text);
}
/**
* Returns valid contexts
*
* @return array
*
* @since 3.7.0
*/
public static function getContexts()
{
JFactory::getLanguage()->load('com_notifly',
JPATH_ADMINISTRATOR);
$contexts = array(
'com_notifly.template' =>
JText::_('COM_NOTIFLY_SUBMENU_TEMPLATES'),
'com_notifly.integration' =>
JText::_('COM_NOTIFLY_SUBMENU_INTEGRATIONS')
);
return $contexts;
}
/**
* Returns all notifly group plugins list
*
* @return object
*
* @since 1.0.0
*/
public static function getGroupPlugins()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select("*")
->from('#__extensions')
->where($db->quoteName('type') . ' = ' .
$db->quote('plugin'))
->where($db->quoteName('folder') . ' = ' .
$db->quote('notifly'))
->setLimit('20');
$db->setQuery($query);
$result = $db->loadObjectList();
return $result;
}
/*
* to get update info
* use layout to get alert structure
*/
public static function getUpdateStatus(){
$update = self::checkUpdate();
// if(isset($update->update_id) && $update->update_id)
// {
// $credentials = self::hasCredentials();
// // Instantiate a new JLayoutFile instance and render the layout
// $layout = new JLayoutFile('toolbar.update');
// return $layout->render(array('info' => $update,
'credentials' => $credentials));
// }
return $update;
}
/*
* to get update info
* use layout to get alert structure
*/
public static function checkUpdate(){
// Get a database object.
$return = [];
$db = JFactory::getDbo();
// get extensionid
$query = $db->getQuery(true)
->select('*')
->from('#__extensions')
->where($db->quoteName('type') . ' = ' .
$db->quote('package'))
->where($db->quoteName('element') . ' = ' .
$db->quote('pkg_notifly'));
$db->setQuery($query);
$result1 = $db->loadObject();
$extensionid = $result1->extension_id;
$manifest_cache = json_decode($result1->manifest_cache);
$return['old'] = $manifest_cache->version;
// get update_site_id
$query = $db->getQuery(true)
->select('*')
->from('#__updates')
->where($db->quoteName('extension_id') . ' =
' . $db->quote($extensionid))
->where($db->quoteName('element') . ' = ' .
$db->quote('pkg_notifly'))
->where($db->quoteName('type') . ' = ' .
$db->quote('package'));
$db->setQuery($query);
$return2 = $db->loadObject();
$return['new'] = (isset($return2->version) ?
$return2->version : $manifest_cache->version);
return $return;
}
public static function showWarning()
{
$layout = new JLayoutFile('notifly.warning');
return $layout->render();
}
}
html/redirect.php000064400000003514151160517420010027 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_redirect
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Utility class for creating HTML Grids.
*
* @since 1.6
*/
class JHtmlRedirect
{
/**
* Display the published or unpublished state of an item.
*
* @param int $value The state value.
* @param int $i The ID of the item.
* @param boolean $canChange An optional prefix for the task.
*
* @return string
*
* @since 1.6
*
* @throws InvalidArgumentException
*/
public static function published($value = 0, $i = null, $canChange = true)
{
// Note: $i is required but has to be an optional argument in the
function call due to argument order
if (null === $i)
{
throw new InvalidArgumentException('$i is a required argument in
JHtmlRedirect::published');
}
// Array of image, task, title, action
$states = array(
1 => array('publish', 'links.unpublish',
'JENABLED', 'COM_REDIRECT_DISABLE_LINK'),
0 => array('unpublish', 'links.publish',
'JDISABLED', 'COM_REDIRECT_ENABLE_LINK'),
2 => array('archive', 'links.unpublish',
'JARCHIVED', 'JUNARCHIVE'),
-2 => array('trash', 'links.publish',
'JTRASHED', 'COM_REDIRECT_ENABLE_LINK'),
);
$state = ArrayHelper::getValue($states, (int) $value, $states[0]);
$icon = $state[0];
if ($canChange)
{
$html = '<a href="#" onclick="return
listItemTask(\'cb' . $i . '\',\'' . $state[1]
. '\')" class="btn btn-micro hasTooltip'
. ($value == 1 ? ' active' : '') . '"
title="' . JHtml::_('tooltipText', $state[3])
. '"><span class="icon-' . $icon .
'" aria-hidden="true"></span></a>';
}
return $html;
}
}
redirect.php000064400000005603151160517420007064 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_redirect
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
/**
* Redirect component helper.
*
* @since 1.6
*/
class RedirectHelper
{
public static $extension = 'com_redirect';
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since 1.6
*/
public static function addSubmenu($vName)
{
// No submenu for this component.
}
/**
* Gets a list of the actions that can be performed.
*
* @return JObject
*
* @deprecated 3.2 Use JHelperContent::getActions() instead
*/
public static function getActions()
{
// Log usage of deprecated function
try
{
JLog::add(
sprintf('%s() is deprecated. Use JHelperContent::getActions() with
new arguments order instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
// Get list of actions
return JHelperContent::getActions('com_redirect');
}
/**
* Returns an array of standard published state filter options.
*
* @return array An array containing the options
*
* @since 1.6
*/
public static function publishedOptions()
{
// Build the active state filter options.
$options = array();
$options[] = JHtml::_('select.option', '*',
'JALL');
$options[] = JHtml::_('select.option', '1',
'JENABLED');
$options[] = JHtml::_('select.option', '0',
'JDISABLED');
$options[] = JHtml::_('select.option', '2',
'JARCHIVED');
$options[] = JHtml::_('select.option', '-2',
'JTRASHED');
return $options;
}
/**
* Gets the redirect system plugin extension id.
*
* @return integer The redirect system plugin extension id.
*
* @since 3.6.0
*/
public static function getRedirectPluginId()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('extension_id'))
->from($db->quoteName('#__extensions'))
->where($db->quoteName('folder') . ' = ' .
$db->quote('system'))
->where($db->quoteName('element') . ' = ' .
$db->quote('redirect'));
$db->setQuery($query);
try
{
$result = (int) $db->loadResult();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
}
return $result;
}
/**
* Checks whether the option "Collect URLs" is enabled for the
output message
*
* @return boolean
*
* @since 3.4
*/
public static function collectUrlsEnabled()
{
$collect_urls = false;
if (JPluginHelper::isEnabled('system', 'redirect'))
{
$params = new
Registry(JPluginHelper::getPlugin('system',
'redirect')->params);
$collect_urls = (bool) $params->get('collect_urls', 1);
}
return $collect_urls;
}
}
debug.php000064400000007530151160561410006350 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Users component debugging helper.
*
* @since 1.6
*/
class UsersHelperDebug
{
/**
* Get a list of the components.
*
* @return array
*
* @since 1.6
*/
public static function getComponents()
{
// Initialise variable.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('name AS text, element AS value')
->from('#__extensions')
->where('enabled >= 1')
->where('type =' . $db->quote('component'));
$items = $db->setQuery($query)->loadObjectList();
if (count($items))
{
$lang = JFactory::getLanguage();
foreach ($items as &$item)
{
// Load language
$extension = $item->value;
$source = JPATH_ADMINISTRATOR . '/components/' . $extension;
$lang->load("$extension.sys", JPATH_ADMINISTRATOR, null,
false, true)
|| $lang->load("$extension.sys", $source, null, false,
true);
// Translate component name
$item->text = JText::_($item->text);
}
// Sort by component name
$items = ArrayHelper::sortObjects($items, 'text', 1, true,
true);
}
return $items;
}
/**
* Get a list of the actions for the component or code actions.
*
* @param string $component The name of the component.
*
* @return array
*
* @since 1.6
*/
public static function getDebugActions($component = null)
{
$actions = array();
// Try to get actions for the component
if (!empty($component))
{
$component_actions = JAccess::getActions($component);
if (!empty($component_actions))
{
foreach ($component_actions as &$action)
{
$actions[$action->title] = array($action->name,
$action->description);
}
}
}
// Use default actions from configuration if no component selected or
component doesn't have actions
if (empty($actions))
{
$filename = JPATH_ADMINISTRATOR .
'/components/com_config/model/form/application.xml';
if (is_file($filename))
{
$xml = simplexml_load_file($filename);
foreach ($xml->children()->fieldset as $fieldset)
{
if ('permissions' == (string) $fieldset['name'])
{
foreach ($fieldset->children() as $field)
{
if ('rules' == (string) $field['name'])
{
foreach ($field->children() as $action)
{
$actions[(string) $action['title']] = array(
(string) $action['name'],
(string) $action['description']
);
}
break;
}
}
}
}
// Load language
$lang = JFactory::getLanguage();
$extension = 'com_config';
$source = JPATH_ADMINISTRATOR . '/components/' . $extension;
$lang->load($extension, JPATH_ADMINISTRATOR, null, false, false)
|| $lang->load($extension, $source, null, false, false)
|| $lang->load($extension, JPATH_ADMINISTRATOR,
$lang->getDefault(), false, false)
|| $lang->load($extension, $source, $lang->getDefault(), false,
false);
}
}
return $actions;
}
/**
* Get a list of filter options for the levels.
*
* @return array An array of JHtmlOption elements.
*/
public static function getLevelsOptions()
{
// Build the filter options.
$options = array();
$options[] = JHtml::_('select.option', '1',
JText::sprintf('COM_USERS_OPTION_LEVEL_COMPONENT', 1));
$options[] = JHtml::_('select.option', '2',
JText::sprintf('COM_USERS_OPTION_LEVEL_CATEGORY', 2));
$options[] = JHtml::_('select.option', '3',
JText::sprintf('COM_USERS_OPTION_LEVEL_DEEPER', 3));
$options[] = JHtml::_('select.option', '4',
'4');
$options[] = JHtml::_('select.option', '5',
'5');
$options[] = JHtml::_('select.option', '6',
'6');
return $options;
}
}
html/users.php000064400000013716151160561410007372 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Extended Utility class for the Users component.
*
* @since 2.5
*/
class JHtmlUsers
{
/**
* Display an image.
*
* @param string $src The source of the image
*
* @return string A <img> element if the specified file exists,
otherwise, a null string
*
* @since 2.5
*/
public static function image($src)
{
$src = preg_replace('#[^A-Z0-9\-_\./]#i', '', $src);
$file = JPATH_SITE . '/' . $src;
jimport('joomla.filesystem.path');
JPath::check($file);
if (!file_exists($file))
{
return '';
}
return '<img src="' . JUri::root() . $src .
'" alt="" />';
}
/**
* Displays an icon to add a note for this user.
*
* @param integer $userId The user ID
*
* @return string A link to add a note
*
* @since 2.5
*/
public static function addNote($userId)
{
$title = JText::_('COM_USERS_ADD_NOTE');
return '<a href="' .
JRoute::_('index.php?option=com_users&task=note.add&u_id='
. (int) $userId) . '" class="hasTooltip btn btn-mini"
title="'
. $title . '"><span class="icon-vcard"
aria-hidden="true"></span><span
class="hidden-phone">' . $title .
'</span></a>';
}
/**
* Displays an icon to filter the notes list on this user.
*
* @param integer $count The number of notes for the user
* @param integer $userId The user ID
*
* @return string A link to apply a filter
*
* @since 2.5
*/
public static function filterNotes($count, $userId)
{
if (empty($count))
{
return '';
}
$title = JText::_('COM_USERS_FILTER_NOTES');
return '<a href="' .
JRoute::_('index.php?option=com_users&view=notes&filter[search]=uid:'
. (int) $userId)
. '" class="hasTooltip btn btn-mini"
title="' . $title . '"><span
class="icon-filter"></span></a>';
}
/**
* Displays a note icon.
*
* @param integer $count The number of notes for the user
* @param integer $userId The user ID
*
* @return string A link to a modal window with the user notes
*
* @since 2.5
*/
public static function notes($count, $userId)
{
if (empty($count))
{
return '';
}
$title = JText::plural('COM_USERS_N_USER_NOTES', $count);
return '<button type="button"
data-target="#userModal_' . (int) $userId . '"
id="modal-' . (int) $userId . '"
data-toggle="modal"'
. ' class="hasTooltip btn btn-mini" title="' .
$title . '">'
. '<span class="icon-drawer-2"
aria-hidden="true"></span><span
class="hidden-phone">' . $title .
'</span></button>';
}
/**
* Renders the modal html.
*
* @param integer $count The number of notes for the user
* @param integer $userId The user ID
*
* @return string The html for the rendered modal
*
* @since 3.4.1
*/
public static function notesModal($count, $userId)
{
if (empty($count))
{
return '';
}
$title = JText::plural('COM_USERS_N_USER_NOTES', $count);
$footer = '<button type="button" class="btn"
data-dismiss="modal">'
. JText::_('JTOOLBAR_CLOSE') . '</button>';
return JHtml::_(
'bootstrap.renderModal',
'userModal_' . (int) $userId,
array(
'title' => $title,
'backdrop' => 'static',
'keyboard' => true,
'closeButton' => true,
'footer' => $footer,
'url' =>
JRoute::_('index.php?option=com_users&view=notes&tmpl=component&layout=modal&filter[user_id]='
. (int) $userId),
'height' => '300px',
'width' => '800px',
)
);
}
/**
* Build an array of block/unblock user states to be used by jgrid.state,
* State options will be different for any user
* and for currently logged in user
*
* @param boolean $self True if state array is for currently logged in
user
*
* @return array a list of possible states to display
*
* @since 3.0
*/
public static function blockStates( $self = false)
{
if ($self)
{
$states = array(
1 => array(
'task' => 'unblock',
'text' => '',
'active_title' =>
'COM_USERS_USER_FIELD_BLOCK_DESC',
'inactive_title' => '',
'tip' => true,
'active_class' => 'unpublish',
'inactive_class' => 'unpublish',
),
0 => array(
'task' => 'block',
'text' => '',
'active_title' => '',
'inactive_title' =>
'COM_USERS_USERS_ERROR_CANNOT_BLOCK_SELF',
'tip' => true,
'active_class' => 'publish',
'inactive_class' => 'publish',
)
);
}
else
{
$states = array(
1 => array(
'task' => 'unblock',
'text' => '',
'active_title' =>
'COM_USERS_TOOLBAR_UNBLOCK',
'inactive_title' => '',
'tip' => true,
'active_class' => 'unpublish',
'inactive_class' => 'unpublish',
),
0 => array(
'task' => 'block',
'text' => '',
'active_title' =>
'COM_USERS_USER_FIELD_BLOCK_DESC',
'inactive_title' => '',
'tip' => true,
'active_class' => 'publish',
'inactive_class' => 'publish',
)
);
}
return $states;
}
/**
* Build an array of activate states to be used by jgrid.state,
*
* @return array a list of possible states to display
*
* @since 3.0
*/
public static function activateStates()
{
$states = array(
1 => array(
'task' => 'activate',
'text' => '',
'active_title' =>
'COM_USERS_TOOLBAR_ACTIVATE',
'inactive_title' => '',
'tip' => true,
'active_class' => 'unpublish',
'inactive_class' => 'unpublish',
),
0 => array(
'task' => '',
'text' => '',
'active_title' => '',
'inactive_title' => 'COM_USERS_ACTIVATED',
'tip' => true,
'active_class' => 'publish',
'inactive_class' => 'publish',
)
);
return $states;
}
}
users.php000064400000015426151160561410006426 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Users component helper.
*
* @since 1.6
*/
class UsersHelper
{
/**
* @var JObject A cache for the available actions.
* @since 1.6
*/
protected static $actions;
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since 1.6
*/
public static function addSubmenu($vName)
{
JHtmlSidebar::addEntry(
JText::_('COM_USERS_SUBMENU_USERS'),
'index.php?option=com_users&view=users',
$vName == 'users'
);
// Groups and Levels are restricted to core.admin
$canDo = JHelperContent::getActions('com_users');
if ($canDo->get('core.admin'))
{
JHtmlSidebar::addEntry(
JText::_('COM_USERS_SUBMENU_GROUPS'),
'index.php?option=com_users&view=groups',
$vName == 'groups'
);
JHtmlSidebar::addEntry(
JText::_('COM_USERS_SUBMENU_LEVELS'),
'index.php?option=com_users&view=levels',
$vName == 'levels'
);
}
if (JComponentHelper::isEnabled('com_fields') &&
JComponentHelper::getParams('com_users')->get('custom_fields_enable',
'1'))
{
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_FIELDS'),
'index.php?option=com_fields&context=com_users.user',
$vName == 'fields.fields'
);
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_FIELD_GROUPS'),
'index.php?option=com_fields&view=groups&context=com_users.user',
$vName == 'fields.groups'
);
}
JHtmlSidebar::addEntry(
JText::_('COM_USERS_SUBMENU_NOTES'),
'index.php?option=com_users&view=notes',
$vName == 'notes'
);
JHtmlSidebar::addEntry(
JText::_('COM_USERS_SUBMENU_NOTE_CATEGORIES'),
'index.php?option=com_categories&extension=com_users',
$vName == 'categories'
);
}
/**
* Gets a list of the actions that can be performed.
*
* @return JObject
*
* @deprecated 3.2 Use JHelperContent::getActions() instead
*/
public static function getActions()
{
// Log usage of deprecated function
try
{
JLog::add(
sprintf('%s() is deprecated. Use JHelperContent::getActions() with
new arguments order instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
// Get list of actions
return JHelperContent::getActions('com_users');
}
/**
* Get a list of filter options for the blocked state of a user.
*
* @return array An array of JHtmlOption elements.
*
* @since 1.6
*/
public static function getStateOptions()
{
// Build the filter options.
$options = array();
$options[] = JHtml::_('select.option', '0',
JText::_('JENABLED'));
$options[] = JHtml::_('select.option', '1',
JText::_('JDISABLED'));
return $options;
}
/**
* Get a list of filter options for the activated state of a user.
*
* @return array An array of JHtmlOption elements.
*
* @since 1.6
*/
public static function getActiveOptions()
{
// Build the filter options.
$options = array();
$options[] = JHtml::_('select.option', '0',
JText::_('COM_USERS_ACTIVATED'));
$options[] = JHtml::_('select.option', '1',
JText::_('COM_USERS_UNACTIVATED'));
return $options;
}
/**
* Get a list of the user groups for filtering.
*
* @return array An array of JHtmlOption elements.
*
* @since 1.6
*/
public static function getGroups()
{
$options = JHelperUsergroups::getInstance()->getAll();
foreach ($options as &$option)
{
$option->value = $option->id;
$option->text = str_repeat('- ', $option->level) .
$option->title;
}
return $options;
}
/**
* Creates a list of range options used in filter select list
* used in com_users on users view
*
* @return array
*
* @since 2.5
*/
public static function getRangeOptions()
{
$options = array(
JHtml::_('select.option', 'today',
JText::_('COM_USERS_OPTION_RANGE_TODAY')),
JHtml::_('select.option', 'past_week',
JText::_('COM_USERS_OPTION_RANGE_PAST_WEEK')),
JHtml::_('select.option', 'past_1month',
JText::_('COM_USERS_OPTION_RANGE_PAST_1MONTH')),
JHtml::_('select.option', 'past_3month',
JText::_('COM_USERS_OPTION_RANGE_PAST_3MONTH')),
JHtml::_('select.option', 'past_6month',
JText::_('COM_USERS_OPTION_RANGE_PAST_6MONTH')),
JHtml::_('select.option', 'past_year',
JText::_('COM_USERS_OPTION_RANGE_PAST_YEAR')),
JHtml::_('select.option', 'post_year',
JText::_('COM_USERS_OPTION_RANGE_POST_YEAR')),
);
return $options;
}
/**
* Creates a list of two factor authentication methods used in com_users
* on user view
*
* @return array
*
* @since 3.2.0
*/
public static function getTwoFactorMethods()
{
FOFPlatform::getInstance()->importPlugin('twofactorauth');
$identities =
FOFPlatform::getInstance()->runPlugins('onUserTwofactorIdentify',
array());
$options = array(
JHtml::_('select.option', 'none',
JText::_('JGLOBAL_OTPMETHOD_NONE'), 'value',
'text'),
);
if (!empty($identities))
{
foreach ($identities as $identity)
{
if (!is_object($identity))
{
continue;
}
$options[] = JHtml::_('select.option', $identity->method,
$identity->title, 'value', 'text');
}
}
return $options;
}
/**
* Get a list of the User Groups for Viewing Access Levels
*
* @param string $rules User Groups in JSON format
*
* @return string $groups Comma separated list of User Groups
*
* @since 3.6
*/
public static function getVisibleByGroups($rules)
{
$rules = json_decode($rules);
if (!$rules)
{
return false;
}
$rules = implode(',', $rules);
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.title AS text')
->from('#__usergroups as a')
->where('a.id IN (' . $rules . ')');
$db->setQuery($query);
$groups = $db->loadColumn();
$groups = implode(', ', $groups);
return $groups;
}
/**
* Returns a valid section for users. If it is not valid then null
* is returned.
*
* @param string $section The section to get the mapping for
*
* @return string|null The new section
*
* @since 3.7.0
*/
public static function validateSection($section)
{
if (JFactory::getApplication()->isClient('site'))
{
switch ($section)
{
case 'registration':
case 'profile':
$section = 'user';
}
}
if ($section != 'user')
{
// We don't know other sections
return null;
}
return $section;
}
/**
* Returns valid contexts
*
* @return array
*
* @since 3.7.0
*/
public static function getContexts()
{
JFactory::getLanguage()->load('com_users',
JPATH_ADMINISTRATOR);
$contexts = array(
'com_users.user' => JText::_('COM_USERS'),
);
return $contexts;
}
}
plugins.php000064400000006537151160776510006762 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_plugins
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Plugins component helper.
*
* @since 1.6
*/
class PluginsHelper
{
public static $extension = 'com_plugins';
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*/
public static function addSubmenu($vName)
{
// No submenu for this component.
}
/**
* Gets a list of the actions that can be performed.
*
* @return JObject
*
* @deprecated 3.2 Use JHelperContent::getActions() instead
*/
public static function getActions()
{
// Log usage of deprecated function.
try
{
JLog::add(
sprintf('%s() is deprecated. Use JHelperContent::getActions() with
new arguments order instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
// Get list of actions.
return JHelperContent::getActions('com_plugins');
}
/**
* Returns an array of standard published state filter options.
*
* @return array The HTML code for the select tag
*/
public static function publishedOptions()
{
// Build the active state filter options.
$options = array();
$options[] = JHtml::_('select.option', '1',
'JENABLED');
$options[] = JHtml::_('select.option', '0',
'JDISABLED');
return $options;
}
/**
* Returns a list of folders filter options.
*
* @return string The HTML code for the select tag
*/
public static function folderOptions()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('DISTINCT(folder) AS value, folder AS text')
->from('#__extensions')
->where($db->quoteName('type') . ' = ' .
$db->quote('plugin'))
->order('folder');
$db->setQuery($query);
try
{
$options = $db->loadObjectList();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
}
return $options;
}
/**
* Returns a list of elements filter options.
*
* @return string The HTML code for the select tag
*/
public static function elementOptions()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('DISTINCT(element) AS value, element AS text')
->from('#__extensions')
->where($db->quoteName('type') . ' = ' .
$db->quote('plugin'))
->order('element');
$db->setQuery($query);
try
{
$options = $db->loadObjectList();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
}
return $options;
}
/**
* Parse the template file.
*
* @param string $templateBaseDir Base path to the template directory.
* @param string $templateDir Template directory.
*
* @return JObject
*/
public function parseXMLTemplateFile($templateBaseDir, $templateDir)
{
$data = new JObject;
// Check of the xml file exists.
$filePath = JPath::clean($templateBaseDir . '/templates/' .
$templateDir . '/templateDetails.xml');
if (is_file($filePath))
{
$xml = JInstaller::parseXMLInstallFile($filePath);
if ($xml['type'] != 'template')
{
return false;
}
foreach ($xml as $key => $value)
{
$data->set($key, $value);
}
}
return $data;
}
}
main.php000064400000000527151161031210006174 0ustar00<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined('_JEXEC') or die;
?>color.php000064400000035546151161622270006413 0ustar00<?php
/**
* mod_vertical_menu - Vertical Menu
*
* @author Balint Polgarfi
* @copyright 2014-2019 Offlajn.com
* @license https://gnu.org/licenses/gpl-2.0.html
* @link https://offlajn.com
*/
?><?php
// no direct access
defined('_JEXEC') or die('Restricted access');
if(!class_exists('OfflajnColorHelper')){
class OfflajnColorHelper
{
/**
*
* Converts hexadecimal colors to RGB.
*
* @param string $hex Hexadecimal value. Accepts values with 3 or 6
numbers,
* with or without #, e.g., CCC, #CCC, CCCCCC or #CCCCCC.
*
* @return array RGB values: 0 => R, 1 => G, 2 => B
*
*/
public function hex2rgb($hex)
{
// Remove #.
if (strpos($hex, '#') === 0) {
$hex = substr($hex, 1);
}
if (strlen($hex) == 3) {
$hex .= $hex;
}
if (strlen($hex) != 6) {
return false;
}
// Convert each tuple to decimal.
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));
return array($r, $g, $b);
}
public function hex2rgba($hex)
{
// Remove #.
if (strpos($hex, '#') === 0) {
$hex = substr($hex, 1);
}
if (strlen($hex) == 6) {
$hex.='ff';
}
if (strlen($hex) != 8) {
return false;
}
// Convert each tuple to decimal.
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));
$a = intval(hexdec(substr($hex, 6, 2))/2);
return array($r, $g, $b, $a);
}
public function hex82hex($hex)
{
// Remove #.
if (strpos($hex, '#') === 0) {
$hex = substr($hex, 1);
}
if (strlen($hex) == 6) {
$hex.='ff';
}
if (strlen($hex) != 8) {
return false;
}
return array(substr($hex, 0, 6), substr($hex, 6, 2));
}
/**
*
* Converts hexadecimal colors to HSV.
*
* @param string $hex Hexadecimal value. Accepts values with 3 or 6
numbers,
* with or without #, e.g., CCC, #CCC, CCCCCC or #CCCCCC.
*
* @return array HSV values: 0 => H, 1 => S, 2 => V
*
*/
public function hex2hsv($hex)
{
return $this->rgb2hsv($this->hex2rgb($hex));
}
/**
*
* Converts hexadecimal colors to HSL.
*
* @param string $hex Hexadecimal value. Accepts values with 3 or 6
numbers,
* with or without #, e.g., CCC, #CCC, CCCCCC or #CCCCCC.
*
* @return array HSL values: 0 => H, 1 => S, 2 => L
*
*/
public function hex2hsl($hex)
{
return $this->rgb2hsl($this->hex2rgb($hex));
}
/**
*
* Converts RGB colors to hexadecimal.
*
* @param array $rgb RGB values: 0 => R, 1 => G, 2 => B
*
* @return string Hexadecimal value with six digits, e.g., CCCCCC.
*
*/
public function rgb2hex($rgb)
{
if(count($rgb) < 3) {
return false;
}
list($r, $g, $b) = $rgb;
// From php.net.
$r = 0x10000 * max(0, min(255, $r));
$g = 0x100 * max(0, min(255, $g));
$b = max(0, min(255, $b));
return strtoupper(str_pad(dechex($r + $g + $b), 6, 0,
STR_PAD_LEFT));
}
/**
*
* Converts RGB to HSV.
*
* @param array $rgb RGB values: 0 => R, 1 => G, 2 => B
*
* @return array HSV values: 0 => H, 1 => S, 2 => V
*
*/
public function rgb2hsv($rgb)
{
// RGB values = 0 ?Ë 255
$var_R = ($rgb[0] / 255);
$var_G = ($rgb[1] / 255);
$var_B = ($rgb[2] / 255);
// Min. value of RGB
$var_Min = min($var_R, $var_G, $var_B);
// Max. value of RGB
$var_Max = max($var_R, $var_G, $var_B);
// Delta RGB value
$del_Max = $var_Max - $var_Min;
$V = $var_Max;
// This is a gray, no chroma...
if ( $del_Max == 0 ) {
// HSV results = 0 ?Ë 1
$H = 0;
$S = 0;
} else {
// Chromatic data...
$S = $del_Max / $var_Max;
$del_R = ((($var_Max - $var_R) / 6) + ($del_Max / 2)) /
$del_Max;
$del_G = ((($var_Max - $var_G) / 6) + ($del_Max / 2)) /
$del_Max;
$del_B = ((($var_Max - $var_B) / 6) + ($del_Max / 2)) /
$del_Max;
if ($var_R == $var_Max) {
$H = $del_B - $del_G;
} else if ($var_G == $var_Max) {
$H = (1 / 3) + $del_R - $del_B;
} else if ($var_B == $var_Max) {
$H = (2 / 3) + $del_G - $del_R;
}
if ($H < 0) {
$H += 1;
}
if ($H > 1) {
$H -= 1;
}
}
// Returns agnostic values.
// Range will depend on the application: e.g. $H*360, $S*100,
$V*100.
return array($H, $S, $V);
}
/**
*
* Converts RGB to HSL.
*
* @param array $rgb RGB values: 0 => R, 1 => G, 2 => B
*
* @return array HSL values: 0 => H, 1 => S, 2 => L
*
*/
public function rgb2hsl($rgb)
{
// Where RGB values = 0 ?Ë 255.
$var_R = $rgb[0] / 255;
$var_G = $rgb[1] / 255;
$var_B = $rgb[2] / 255;
// Min. value of RGB
$var_Min = min($var_R, $var_G, $var_B);
// Max. value of RGB
$var_Max = max($var_R, $var_G, $var_B);
// Delta RGB value
$del_Max = $var_Max - $var_Min;
$L = ($var_Max + $var_Min) / 2;
if ( $del_Max == 0 ) {
// This is a gray, no chroma...
// HSL results = 0 ?Ë 1
$H = 0;
$S = 0;
} else {
// Chromatic data...
if ($L < 0.5) {
$S = $del_Max / ($var_Max + $var_Min);
} else {
$S = $del_Max / ( 2 - $var_Max - $var_Min );
}
$del_R = ((($var_Max - $var_R) / 6) + ($del_Max / 2)) /
$del_Max;
$del_G = ((($var_Max - $var_G) / 6) + ($del_Max / 2)) /
$del_Max;
$del_B = ((($var_Max - $var_B) / 6) + ($del_Max / 2)) /
$del_Max;
if ($var_R == $var_Max) {
$H = $del_B - $del_G;
} else if ($var_G == $var_Max) {
$H = ( 1 / 3 ) + $del_R - $del_B;
} else if ($var_B == $var_Max) {
$H = ( 2 / 3 ) + $del_G - $del_R;
}
if ($H < 0) {
$H += 1;
}
if ($H > 1) {
$H -= 1;
}
}
return array($H, $S, $L);
}
/**
*
* Converts HSV colors to hexadecimal.
*
* @param array $hsv HSV values: 0 => H, 1 => S, 2 => V
*
* @return string Hexadecimal value with six digits, e.g., CCCCCC.
*
*/
public function hsv2hex($hsv)
{
return $this->rgb2hex($this->hsv2rgb($hsv));
}
/**
*
* Converts HSV to RGB.
*
* @param array $hsv HSV values: 0 => H, 1 => S, 2 => V
*
* @return array RGB values: 0 => R, 1 => G, 2 => B
*
*/
public function hsv2rgb($hsv)
{
$H = $hsv[0];
$S = $hsv[1];
$V = $hsv[2];
// HSV values = 0 ?Ë 1
if ($S == 0) {
$R = $V * 255;
$G = $V * 255;
$B = $V * 255;
} else {
$var_h = $H * 6;
// H must be < 1
if ( $var_h == 6 ) {
$var_h = 0;
}
// Or ... $var_i = floor( $var_h )
$var_i = floor( $var_h );
$var_1 = $V * ( 1 - $S );
$var_2 = $V * ( 1 - $S * ( $var_h - $var_i ) );
$var_3 = $V * ( 1 - $S * ( 1 - ( $var_h - $var_i ) ) );
switch($var_i) {
case 0:
$var_r = $V;
$var_g = $var_3;
$var_b = $var_1;
break;
case 1:
$var_r = $var_2;
$var_g = $V;
$var_b = $var_1;
break;
case 2:
$var_r = $var_1;
$var_g = $V;
$var_b = $var_3;
break;
case 3:
$var_r = $var_1;
$var_g = $var_2;
$var_b = $V;
break;
case 4:
$var_r = $var_3;
$var_g = $var_1;
$var_b = $V;
break;
default:
$var_r = $V;
$var_g = $var_1;
$var_b = $var_2;
}
//RGB results = 0 ?Ë 255
$R = $var_r * 255;
$G = $var_g * 255;
$B = $var_b * 255;
}
return array($R, $G, $B);
}
/**
*
* Converts HSV colors to HSL.
*
* @param array $hsv HSV values: 0 => H, 1 => S, 2 => V
*
* @return array HSL values: 0 => H, 1 => S, 2 => L
*
*/
public function hsv2hsl($hsv)
{
return $this->rgb2hsl($this->hsv2rgb($hsv));
}
/**
*
* Converts hexadecimal colors to HSL.
*
* @param array $hsl HSL values: 0 => H, 1 => S, 2 => L
*
* @return string Hexadecimal value. Accepts values with 3 or 6
numbers,
* with or without #, e.g., CCC, #CCC, CCCCCC or #CCCCCC.
*
*/
public function hsl2hex($hsl)
{
return $this->rgb2hex($this->hsl2rgb($hsl));
}
/**
*
* Converts HSL to RGB.
*
* @param array $hsv HSL values: 0 => H, 1 => S, 2 => L
*
* @return array RGB values: 0 => R, 1 => G, 2 => B
*
*/
public function hsl2rgb($hsl)
{
list($H, $S, $L) = $hsl;
if ($S == 0) {
// HSL values = 0 ?Ë 1
// RGB results = 0 ?Ë 255
$R = $L * 255;
$G = $L * 255;
$B = $L * 255;
} else {
if ($L < 0.5) {
$var_2 = $L * (1 + $S);
} else {
$var_2 = ($L + $S) - ($S * $L);
}
$var_1 = 2 * $L - $var_2;
$R = 255 * $this->_hue2rgb($var_1, $var_2, $H + (1 / 3));
$G = 255 * $this->_hue2rgb($var_1, $var_2, $H);
$B = 255 * $this->_hue2rgb($var_1, $var_2, $H - (1 / 3));
}
return array($R, $G, $B);
}
/**
*
* Support method for hsl2rgb(): converts hue ro RGB.
*
* @param
*
* @param
*
* @param
*
* @return int
*
*/
protected function _hue2rgb($v1, $v2, $vH)
{
if ($vH < 0) {
$vH += 1;
}
if ($vH > 1) {
$vH -= 1;
}
if ((6 * $vH) < 1) {
return ($v1 + ($v2 - $v1) * 6 * $vH);
}
if ((2 * $vH) < 1) {
return $v2;
}
if ((3 * $vH) < 2) {
return ($v1 + ($v2 - $v1) * (( 2 / 3) - $vH) * 6);
}
return $v1;
}
/**
*
* Converts hexadecimal colors to HSL.
*
* @param array $hsl HSL values: 0 => H, 1 => S, 2 => L
*
* @return array HSV values: 0 => H, 1 => S, 2 => V
*
*/
public function hsl2hsv($hsl)
{
return $this->rgb2hsv($this->hsl2rgb($hsl));
}
/**
*
* Updates HSV values.
*
* @param array $hsv HSV values: 0 => H, 1 => S, 2 => V
*
* @param array $values Values to update: 0 => value to add to H
(0 to 360),
* 1 and 2 => values to multiply S and V (0 to 100). Example:
*
* {{{code:php
* // Update saturation to 80% in the provided HSV.
* $hsv = array(120, 0.75, 0.75);
* $new_hsv = $color->updateHsv($hsv, array(null, 80, null));
* }}}
*
*/
public function updateHsv($hsv, $values)
{
if (isset($values[0])) {
$hsv[0] = max(0, min(360, ($hsv[0] + $values[0])));
}
if (isset($values[1])) {
$hsv[1] = max(0, min(1, ($hsv[1] * ($values[1] / 100))));
}
if (isset($values[2])) {
$hsv[2] = max(0, min(1, ($hsv[2] * ($values[2] / 100))));
}
return $hsv;
}
/**
*
* Updates HSL values.
*
* @param array $hsl HSL values: 0 => H, 1 => S, 2 => L
*
* @param array $values Values to update: 0 => value to add to H
(0 to 360),
* 1 and 2 => values to multiply S and V (0 to 100). Example:
*
* {{{code:php
* // Update saturation to 80% in the provided HSL.
* $hsl = array(120, 0.75, 0.75);
* $new_hsl = $color->updateHsl($hsl, array(null, 80, null));
* }}}
*
*/
public function updateHsl($hsl, $values)
{
if (isset($values[0])) {
$hsl[0] = max(0, min(1, ($hsl[0] + $values[0]/360)));
}
if (isset($values[1])) {
$hsl[1] = max(0, min(1, ($hsl[1] * ($values[1] / 100))));
}
if (isset($values[2])) {
$hsl[2] = max(0, min(1, ($hsl[2] * ($values[2] / 100))));
}
return $hsl;
}
function rgb2array($rgb) {
return array(
base_convert(substr($rgb, 0, 2), 16, 10),
base_convert(substr($rgb, 2, 2), 16, 10),
base_convert(substr($rgb, 4, 2), 16, 10),
);
}
}
}
?>functions.php000064400000010562151161622270007274 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use RegularLabs\Library\Document as RL_Document;
use RegularLabs\Library\Extension as RL_Extension;
use RegularLabs\Library\File as RL_File;
use RegularLabs\Library\Http as RL_Http;
use RegularLabs\Library\Language as RL_Language;
use RegularLabs\Library\Xml as RL_Xml;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
/**
* Framework Functions
*/
class RLFunctions
{
public static function getContents($url, $timeout = 20)
{
return ! class_exists('RegularLabs\Library\Http') ?
'' : RL_Http::get($url, $timeout);
}
public static function getByUrl($url, $timeout = 20)
{
return ! class_exists('RegularLabs\Library\Http') ?
'' : RL_Http::getFromServer($url, $timeout);
}
public static function isFeed()
{
return class_exists('RegularLabs\Library\Document') &&
RL_Document::isFeed();
}
public static function script($file, $version = '')
{
class_exists('RegularLabs\Library\Document') &&
RL_Document::script($file, $version);
}
public static function stylesheet($file, $version = '')
{
class_exists('RegularLabs\Library\Document') &&
RL_Document::stylesheet($file, $version);
}
public static function addScriptVersion($url)
{
jimport('joomla.filesystem.file');
$version = '';
if (file_exists(JPATH_SITE . $url))
{
$version = filemtime(JPATH_SITE . $url);
}
self::script($url, $version);
}
public static function addStyleSheetVersion($url)
{
jimport('joomla.filesystem.file');
$version = '';
if (file_exists(JPATH_SITE . $url))
{
$version = filemtime(JPATH_SITE . $url);
}
self::stylesheet($url, $version);
}
protected static function getFileByFolder($folder, $file)
{
return ! class_exists('RegularLabs\Library\File') ?
'' : RL_File::getMediaFile($folder, $file);
}
public static function getComponentBuffer()
{
return ! class_exists('RegularLabs\Library\Document') ?
'' : RL_Document::getBuffer();
}
public static function getAliasAndElement(&$name)
{
return ! class_exists('RegularLabs\Library\Extension') ?
'' : RL_Extension::getAliasAndElement($name);
}
public static function getNameByAlias($alias)
{
return ! class_exists('RegularLabs\Library\Extension') ?
'' : RL_Extension::getNameByAlias($alias);
}
public static function getAliasByName($name)
{
return ! class_exists('RegularLabs\Library\Extension') ?
'' : RL_Extension::getAliasByName($name);
}
public static function getElementByAlias($alias)
{
return ! class_exists('RegularLabs\Library\Extension') ?
'' : RL_Extension::getElementByAlias($alias);
}
public static function getXMLValue($key, $alias, $type =
'component', $folder = 'system')
{
return ! class_exists('RegularLabs\Library\Extension') ?
'' : RL_Extension::getXMLValue($key, $alias, $type, $folder);
}
public static function getXML($alias, $type = 'component',
$folder = 'system')
{
return ! class_exists('RegularLabs\Library\Extension') ?
'' : RL_Extension::getXML($alias, $type, $folder);
}
public static function getXMLFile($alias, $type = 'component',
$folder = 'system')
{
return ! class_exists('RegularLabs\Library\Extension') ?
'' : RL_Extension::getXMLFile($alias, $type, $folder);
}
public static function extensionInstalled($extension, $type =
'component', $folder = 'system')
{
return ! class_exists('RegularLabs\Library\Extension') ?
'' : RL_Extension::isInstalled($extension, $type, $folder);
}
public static function getExtensionPath($extension =
'plg_system_regularlabs', $basePath = JPATH_ADMINISTRATOR,
$check_folder = '')
{
return ! class_exists('RegularLabs\Library\Extension') ?
'' : RL_Extension::getPath($extension, $basePath, $check_folder);
}
public static function loadLanguage($extension =
'plg_system_regularlabs', $basePath = '', $reload =
false)
{
return class_exists('RegularLabs\Library\Language') &&
RL_Language::load($extension, $basePath, $reload);
}
public static function xmlToObject($url, $root = '')
{
return ! class_exists('RegularLabs\Library\Xml') ? ''
: RL_Xml::toObject($url, $root);
}
}
minifont.php000064400000024073151161622270007111 0ustar00<?php
/**
* mod_vertical_menu - Vertical Menu
*
* @author Balint Polgarfi
* @copyright 2014-2019 Offlajn.com
* @license https://gnu.org/licenses/gpl-2.0.html
* @link https://offlajn.com
*/
?><?php
// no direct access
defined('_JEXEC') or die('Restricted access');
if (!class_exists('OfflajnMiniFontHelper')) {
class OfflajnMiniFontHelper
{
public function __construct($params)
{
$this->_params = &$params;
$this->_parser = new OfflajnParser();
}
public function parseFonts()
{
$fonts = array();
foreach ($this->_params->toArray() as $k => $f) {
if (strpos($k, 'font') !== false && isset($f[0])
&& $f[0] == '{') {
$f = json_decode($f, true);
$tabs = array_keys($f);
$default_tab = $tabs[0];
$f['default_tab'] = $default_tab;
if (version_compare(JVERSION, '3.0', 'ge'))
{
$this->_params->set($k, $f);
} else {
$this->_params->setValue($k, $f);
}
// if(!isset($f[$default_tab]['bold']))
$f[$default_tab]['bold'] = 400;
// $weight = $f[$default_tab]['bold'] ? 700 : 400;
// $weight =
(strtoupper($t['textdecor'])=='LIGHTER') ? 300 :
((strtoupper($t['textdecor'])=='NORMAL') ? 400 : 700);
$weight = @$f[$default_tab]['textdecor'];
if (!isset($f[$default_tab]['italic'])) {
$f[$default_tab]['italic'] = '';
}
$italic = $f[$default_tab]['italic'] ?
'italic' : '';
$subset =
$this->_getSubset(isset($f[$default_tab]['subset']) ?
$f[$default_tab]['subset'] : 'latin');
foreach ($f as $k => $t) {
if ($k == 'default_tab') {
continue;
}
if (isset($t['type']) && $t['type']
== '0' || !isset($t['type']) &&
$f[$default_tab]['type'] == '0') {
continue;
}
$_family = isset($t['family']) ?
$t['family'] : $f[$default_tab]['family'];
$_subset = (isset($t['subset']) ?
$this->_getSubset($t['subset']) : $subset);
// $_weight = (isset($t['bold']) ?
($t['bold'] ? 700 : 400) : $weight);
// $_weight = (isset($t['textdecor']) ?
((strtoupper($t['textdecor'])=='LIGHTER') ? 300 :
((strtoupper($t['textdecor'])=='NORMAL') ? 400 : 700))
: $weight);
$_weight = @$t['textdecor'];
$_italic = (isset($t['italic']) ?
($t['italic'] ? 'italic' : '') : $italic);
if (!isset($fonts[$_family])) {
$fonts[$_family] = array('subset' => array());
}
$fonts[$_family]['subset'][] = $_subset;
$fonts[$_family]['options'][] = $_weight . $_italic;
}
}
}
$query = '';
foreach ($fonts as $k => $font) {
if ($k == '') continue;
if ($query != '') $query .= '|';
$query .= $k . ':' . implode(',',
array_unique(array_filter($font['options'])));
}
if ($query == '') return '';
$url = 'https://fonts.googleapis.com/css?family=' .
$query;
return "@import url('" . $url .
"');\n";
}
/*
Ha $loadDefaultTab true, akkor az aktuålis tab hiånyzó értékeibe
beletölti a default tabból az értékeket.
Ha a $justValue true, akkor csak az adott css tulajdonsåg értékét
jelenĂti meg.
*/
public function _printFont($name, $tab, $excl = null, $incl = null,
$loadDefaultTab = false, $justValue = false)
{
global $ratio;
if (!$ratio) {
$ratio = 1;
}
$f = $this->_params->get($name);
if (!$tab) {
$tab = $f['default_tab'];
}
$t = $f[$tab];
if ($loadDefaultTab && $tab != $f['default_tab'])
{
foreach ($f[$f['default_tab']] as $k => $v) {
if (!isset($t[$k])) {
$t[$k] = $v;
}
}
}
$family = '';
if (isset($t['type']) && $t['type'] !=
'0' && isset($t['family'])) {
$family = "'" . $t['family'] .
"'";
}
if (isset($t['afont']) && $t['afont'] !=
'') {
$afont = OfflajnParser::parse($t['afont']);
if ($afont[1]) {
if ($family != '') {
$family .= ',';
}
$family .= $afont[0];
}
}
if ((!$excl || !in_array('font-family', $excl)) &&
(!$incl || in_array('font-family', $incl))) {
if ($family != '') {
if (!$justValue) {
echo 'font-family: ' . $family . ";\n";
} else {
echo $family;
}
}
}
if ((!$excl || !in_array('font-size', $excl)) &&
(!$incl || in_array('font-size', $incl))) {
if (isset($t['size']) && $t['size'] !=
'') {
if (!$justValue) {
$s = OfflajnParser::parse($t['size']);
$s[0] = intval($s[0] * $ratio);
echo 'font-size: ' . implode('', $s) .
";\n";
} else {
$s = OfflajnParser::parse($t['size']);
$s[0] = intval($s[0] * $ratio);
echo implode('', $s);
}
}
}
if ((!$excl || !in_array('color', $excl)) &&
(!$incl || in_array('color', $incl))) {
if (isset($t['color']) && $t['color']
!= '') {
echo "color: " . $t['color'] .
";\n";
}
}
if ((!$excl || !in_array('font-weight', $excl)) &&
(!$incl || in_array('font-weight', $incl))) {
if (isset($t['bold'])) {
if (!$justValue) {
echo 'font-weight: ' . ($t['bold'] ==
'1' ? 'bold' : 'normal') . ";\n";
} else {
echo ($t['bold'] == '1' ? 'bold'
: 'normal');
}
}
}
if ((!$excl || !in_array('font-weight', $excl)) &&
(!$incl || in_array('font-weight', $incl))) {
if (isset($t['textdecor'])) {
if (!$justValue) {
echo 'font-weight: ' . $t['textdecor'] .
";\n";
} else {
echo $t['textdecor'];
}
}
}
if ((!$excl || !in_array('font-style', $excl)) &&
(!$incl || in_array('font-style', $incl))) {
if (isset($t['italic'])) {
if (!$justValue) {
echo 'font-style: ' . ($t['italic'] ==
'1' ? 'italic' : 'normal') .
";\n";
} else {
echo ($t['italic'] == '1' ?
'italic' : 'normal');
}
}
}
if ((!$excl || !in_array('text-decoration', $excl))
&& (!$incl || in_array('text-decoration', $incl))) {
if (isset($t['underline'])) {
if (!$justValue) {
echo 'text-decoration: ' . ($t['underline']
== '1' ? 'underline' : 'none') .
";\n";
} else {
echo ($t['underline'] == '1' ?
'underline' : 'none');
}
}
if (isset($t['linethrough'])) {
if (!$justValue) {
echo 'text-decoration: ' .
($t['linethrough'] == '1' ? 'linethrough' :
'none') . ";\n";
} else {
echo ($t['linethrough'] == '1' ?
'linethrough' : 'none');
}
}
}
if ((!$excl || !in_array('text-transform', $excl))
&& (!$incl || in_array('text-transform', $incl))) {
if (isset($t['uppercase'])) {
if (!$justValue) {
echo 'text-transform: ' . ($t['uppercase']
== '1' ? 'uppercase' : 'none') .
";\n";
} else {
echo ($t['uppercase'] == '1' ?
'uppercase' : 'none');
}
}
}
if ((!$excl || !in_array('text-align', $excl)) &&
(!$incl || in_array('text-align', $incl))) {
if (isset($t['align'])) {
if (!$justValue) {
echo 'text-align: ' . $t['align'] .
";\n";
} else {
echo $t['align'];
}
}
}
if ((!$excl || !in_array('text-shadow', $excl)) &&
(!$incl || in_array('text-shadow', $incl))) {
echo isset($t['tshadow']) ?
$this->getTextShadow($t['tshadow']) : '';
}
if ((!$excl || !in_array('line-height', $excl)) &&
(!$incl || in_array('line-height', $incl))) {
if (isset($t['lineheight'])) {
if (!$justValue) {
if ($ratio == 1) {
echo 'line-height: ' . $t['lineheight'] .
";\n";
} else {
$lht = $t['lineheight'];
$lh = intval($t['lineheight']);
if ($lh > 0) {
$lhu = str_replace($lh, '',
$t['lineheight']);
$lh = intval($lh * $ratio);
echo 'line-height: ' . $lh . $lhu .
";\n";
} else {
echo 'line-height: ' . $t['lineheight']
. ";\n";
}
}
} else {
echo $t['lineheight'];
}
}
}
}
public function printFont($name, $tab, $loadDefaultTab = false)
{
$this->_printFont($name, $tab, null, null, $loadDefaultTab);
}
public function printFontExcl($name, $tab, $excl, $loadDefaultTab =
false)
{
$this->_printFont($name, $tab, $excl, null, $loadDefaultTab);
}
public function printFontIncl($name, $tab, $incl, $loadDefaultTab =
false)
{
$this->_printFont($name, $tab, null, $incl, $loadDefaultTab);
}
public function getTextShadow($s)
{
$ts = OfflajnParser::parse($s);
if (!$ts[4]) {
return "text-shadow: none;\n";
}
while (count($ts) > 4) {
array_pop($ts);
}
foreach ($ts as &$v) {
if (!is_string($v)) {
$v = implode('', $v);
}
}
return 'text-shadow: ' . implode(' ', $ts) .
";\n";
}
public function _getSubset($subset)
{
if ($subset == 'LatinExtended') {
$subset = 'latin,latin-ext';
} elseif ($subset == 'CyrillicExtended') {
$subset = 'cyrillic,cyrillic-ext';
} elseif ($subset == 'GreekExtended') {
$subset = 'greek,greek-ext';
}
return $subset;
}
public function printPropertyValue($name, $tab, $prop, $loadDefaultTab
= false)
{
$this->_printFont($name, $tab, null, array($prop),
$loadDefaultTab, true);
}
}
}
miniimage.php000064400000013712151161622270007223 0ustar00<?php
/**
* mod_vertical_menu - Vertical Menu
*
* @author Balint Polgarfi
* @copyright 2014-2019 Offlajn.com
* @license https://gnu.org/licenses/gpl-2.0.html
* @link https://offlajn.com
*/
?><?php
// no direct access
defined('_JEXEC') or die('Restricted access');
if(!class_exists('OfflajnMiniImageHelper')){
require_once(dirname(__FILE__).'/color.php');
class OfflajnMiniImageHelper{
var $cache;
var $cacheUrl;
var $step = 1;
var $c;
function __construct($cacheDir, $cacheUrl){
$this->cache = $cacheDir;
$this->cacheUrl = $cacheUrl;
$this->c = new OfflajnColorHelper();
}
function colorizeImage($img, $targetColor, $baseColor){
preg_match('/(\d+),\s*(\d+),\s*(\d+),\s*(\d\.?\d*)/',
$targetColor, $m);
$targetColor = count($m) ? dechex($m[1]).dechex($m[2]).dechex($m[3]) :
substr($targetColor, 1);
$alpha = count($m) ? (float)$m[4] : 1;
$c1 = $this->c->hex2hsl($baseColor);
$c2 = $this->c->hex2hsl($targetColor);
$im = imagecreatefrompng($img);
$height = imagesy($im);
$width = imagesx($im);
$imnew = imagecreatetruecolor($width, $height);
imagesavealpha($imnew, true);
imagealphablending($imnew, false);
$transparent = imagecolorallocatealpha($imnew, 255, 255, 255,
127);
imagefilledrectangle($imnew, 0, 0, $width, $height,
$transparent);
$rgb = $this->c->rgb2array($targetColor);
for($x=0; $x<$width; $x++){
for($y=0; $y<$height; $y++){
$rgba = ImageColorAt($im, $x, $y);
$rgb = array(($rgba >> 16) & 0xFF, ($rgba
>> 8) & 0xFF, $rgba & 0xFF);
$hsl = $this->c->rgb2hsl($rgb);
$a[0] = $hsl[0] + ($c2[0] - $c1[0]);
$a[1] = $hsl[1] * ($c2[1] / $c1[1]);
if($a[1] > 1) $a[1] = 1;
$a[2] = exp(log($hsl[2]) * log($c2[2]) / log($c1[2]) );
if($a[2] > 1) $a[2] = 1;
$rgb = $this->c->hsl2rgb($a);
$A = 0xFF-(($rgba >> 24)*2) & 0xFF;
$A = (int)($A * $alpha);
if($A > 0xFF) $A = 0xFF;
$A = (int)((0xFF-$A)/2);
imagesetpixel($imnew, $x, $y,
imagecolorallocatealpha($imnew, $rgb[0], $rgb[1], $rgb[2], $A));
}
}
$hash = md5($img.$targetColor.$alpha).'.png';
imagepng($imnew, $this->cache.'/'.$hash);
imagedestroy($imnew);
imagedestroy($im);
return $this->cacheUrl.$hash;
}
function colorizeImages($img, $color1, $color2, $baseColor){
//if ($color1 == color2) return $this->colorizeImage($img, $color1,
$baseColor);
preg_match('/(\d+),\s*(\d+),\s*(\d+),\s*(\d\.?\d*)/',
$color1, $m);
$color1 = count($m) ? dechex($m[1]).dechex($m[2]).dechex($m[3]) :
substr($color1, 1);
$alpha1 = count($m) ? (float)$m[4] : 1;
preg_match('/(\d+),\s*(\d+),\s*(\d+),\s*(\d\.?\d*)/',
$color2, $m);
$color2 = count($m) ? dechex($m[1]).dechex($m[2]).dechex($m[3]) :
substr($color2, 1);
$alpha2 = count($m) ? (float)$m[4] : 1;
$c = $this->c->hex2hsl($baseColor);
$c1 = $this->c->hex2hsl($color1);
$c2 = $this->c->hex2hsl($color2);
$im = imagecreatefrompng($img);
$height = imagesy($im);
$width = imagesx($im);
$imnew = imagecreatetruecolor(2 * $width, $height);
imagesavealpha($imnew, true);
imagealphablending($imnew, false);
$transparent = imagecolorallocatealpha($imnew, 255, 255, 255,
127);
imagefilledrectangle($imnew, 0, 0, 2 * $width, $height,
$transparent);
$rgb = $this->c->rgb2array($color1);
for($x=0; $x<$width; $x++){
for($y=0; $y<$height; $y++){
$rgba = ImageColorAt($im, $x, $y);
$rgb = array(($rgba >> 16) & 0xFF, ($rgba
>> 8) & 0xFF, $rgba & 0xFF);
$hsl = $this->c->rgb2hsl($rgb);
$a[0] = $hsl[0] + ($c1[0] - $c[0]);
$a[1] = $hsl[1] * ($c1[1] / $c[1]);
if($a[1] > 1) $a[1] = 1;
$a[2] = exp(log($hsl[2]) * log($c1[2]) / log($c[2]) );
if($a[2] > 1) $a[2] = 1;
$rgb = $this->c->hsl2rgb($a);
$A = 0xFF-(($rgba >> 24)*2) & 0xFF;
$A = (int)($A * $alpha1);
if($A > 0xFF) $A = 0xFF;
$A = (int)((0xFF-$A)/2);
imagesetpixel($imnew, $x, $y,
imagecolorallocatealpha($imnew, $rgb[0], $rgb[1], $rgb[2], $A));
}
}
$rgb = $this->c->rgb2array($color2);
for($x=$width; $x<2*$width; $x++){
for($y=0; $y<$height; $y++){
$rgba = ImageColorAt($im, $x - $width, $y);
$rgb = array(($rgba >> 16) & 0xFF, ($rgba
>> 8) & 0xFF, $rgba & 0xFF);
$hsl = $this->c->rgb2hsl($rgb);
$a[0] = $hsl[0] + ($c2[0] - $c[0]);
$a[1] = $hsl[1] * ($c2[1] / $c[1]);
if($a[1] > 1) $a[1] = 1;
$a[2] = exp(log($hsl[2]) * log($c2[2]) / log($c[2]) );
if($a[2] > 1) $a[2] = 1;
$rgb = $this->c->hsl2rgb($a);
$A = 0xFF-(($rgba >> 24)*2) & 0xFF;
$A = (int)($A * $alpha2);
if($A > 0xFF) $A = 0xFF;
$A = (int)((0xFF-$A)/2);
imagesetpixel($imnew, $x, $y,
imagecolorallocatealpha($imnew, $rgb[0], $rgb[1], $rgb[2], $A));
}
}
$hash =
md5($img.$color1.$alpha1.$color2.$alpha2).'.png';
imagepng($imnew, $this->cache.'/'.$hash);
imagedestroy($imnew);
imagedestroy($im);
return $this->cacheUrl.$hash;
}
}
}
?>miniparser.php000064400000004206151161622270007433 0ustar00<?php
/**
* mod_vertical_menu - Vertical Menu
*
* @author Balint Polgarfi
* @copyright 2014-2019 Offlajn.com
* @license https://gnu.org/licenses/gpl-2.0.html
* @link https://offlajn.com
*/
?><?php
// no direct access
defined('_JEXEC') or die('Restricted access');
if (!class_exists('OfflajnParser')) {
class OfflajnParser
{
public static function parse($s, $def = null)
{
$v = explode("|*|", is_string($s) ? $s : $def);
if ($v[count($v) - 1] == '') {
unset($v[count($v) - 1]);
}
if (is_string($s) && is_string($def)) {
$d = explode("|*|", $def);
if (!is_string($v) && !is_string($d)) {
for ($i = count($v); $i--;) {
array_shift($d);
}
$v = array_merge($v, $d);
}
}
for ($i = 0; $i < count($v); $i++) {
if (strpos($v[$i], "||") !== false) {
$v[$i] = explode("||", $v[$i]);
}
}
// if ($def=='#eeeeee|*|rgba(0, 0, 0,
0.53)|*|50||px|*|0||px|*|0||px'){
// echo'<pre>';print_r(count($v) == 1 ? $v[0] :
$v);exit;
// }
return count($v) == 1 ? $v[0] : $v;
}
public static function parseUnit($v, $concat = '')
{
if (!is_array($v)) {
$v = self::parse($v);
}
$unit = @$v[count($v) - 1];
unset($v[count($v) - 1]);
$r = '';
foreach ($v as $m) {
$r .= $m . $unit . $concat;
}
return $r;
}
public static function parseBorder($s)
{
$v = self::parse($s);
return array(self::parseUnit(array_splice($v, 0, 5), ' '),
$v[0], $v[1]);
}
public static function parseColorizedImage($s)
{
global $MiniImageHelper;
$v = self::parse($s);
$img = '';
$v[0] = JPATH_SITE . preg_replace('#^.*?(/modules/)#',
'$1', $v[0]);
if (file_exists($v[0])) {
if ($v[2] == '#000000') $v[2] = '#000001';
if ($v[3] == '#000000') $v[3] = '#000001';
$img = $MiniImageHelper->colorizeImages($v[0], $v[2], $v[3],
'548722');
}
return array($img, $v[1]);
}
}
}
assignment.php000064400000002561151161676250007443 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
class RLAssignment
extends \RegularLabs\Library\Condition
{
function pass($pass = true, $include_type = null)
{
return $this->_($pass, $include_type);
}
public function passByPageTypes($option, $selection = [], $assignment =
'all', $add_view = false, $get_task = false, $get_layout = true)
{
return $this->passByPageType($option, $selection, $assignment,
$add_view, $get_task, $get_layout);
}
public function passContentIds()
{
return $this->passContentId();
}
public function passContentKeywords($fields = ['title',
'introtext', 'fulltext'], $text = '')
{
return $this->passContentKeyword($fields, $text);
}
public function passMetaKeywords($field = 'metakey', $keywords =
'')
{
return $this->passMetaKeyword($field, $keywords);
}
public function passAuthors($field = 'created_by', $author =
'')
{
return $this->passAuthors($field, $author);
}
}
assignments/agents.php000064400000007077151161676250011116 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
require_once dirname(__DIR__) . '/text.php';
require_once dirname(__DIR__) . '/mobile_detect.php';
class RLAssignmentsAgents extends RLAssignment
{
var $agent = null;
var $device = null;
/**
* passBrowsers
*/
public function passBrowsers()
{
if (empty($this->selection))
{
return $this->pass(false);
}
foreach ($this->selection as $browser)
{
if ( ! $this->passBrowser($browser))
{
continue;
}
return $this->pass(true);
}
return $this->pass(false);
}
/**
* passOS
*/
public function passOS()
{
return self::passBrowsers();
}
/**
* passDevices
*/
public function passDevices()
{
$pass = (in_array('mobile', $this->selection) &&
$this->isMobile())
|| (in_array('tablet', $this->selection) &&
$this->isTablet())
|| (in_array('desktop', $this->selection) &&
$this->isDesktop());
return $this->pass($pass);
}
/**
* isPhone
*/
public function isPhone()
{
return $this->isMobile();
}
/**
* isMobile
*/
public function isMobile()
{
return $this->getDevice() == 'mobile';
}
/**
* isTablet
*/
public function isTablet()
{
return $this->getDevice() == 'tablet';
}
/**
* isDesktop
*/
public function isDesktop()
{
return $this->getDevice() == 'desktop';
}
/**
* setDevice
*/
private function getDevice()
{
if ( ! is_null($this->device))
{
return $this->device;
}
$detect = new RLMobile_Detect;
$this->is_mobile = $detect->isMobile();
switch (true)
{
case($detect->isTablet()):
$this->device = 'tablet';
break;
case ($detect->isMobile()):
$this->device = 'mobile';
break;
default:
$this->device = 'desktop';
}
return $this->device;
}
/**
* getAgent
*/
private function getAgent()
{
if ( ! is_null($this->agent))
{
return $this->agent;
}
$detect = new RLMobile_Detect;
$agent = $detect->getUserAgent();
switch (true)
{
case (stripos($agent, 'Trident') !== false):
// Add MSIE to IE11
$agent = preg_replace('#(Trident/[0-9\.]+;
rv:([0-9\.]+))#is', '\1 MSIE \2', $agent);
break;
case (stripos($agent, 'Chrome') !== false):
// Remove Safari from Chrome
$agent = preg_replace('#(Chrome/.*)Safari/[0-9\.]*#is',
'\1', $agent);
// Add MSIE to IE Edge and remove Chrome from IE Edge
$agent = preg_replace('#Chrome/.*(Edge/[0-9])#is', 'MSIE
\1', $agent);
break;
case (stripos($agent, 'Opera') !== false):
$agent = preg_replace('#(Opera/.*)Version/#is',
'\1Opera/', $agent);
break;
}
$this->agent = $agent;
return $this->agent;
}
/**
* passBrowser
*/
private function passBrowser($browser = '')
{
if ( ! $browser)
{
return false;
}
if ($browser == 'mobile')
{
return $this->isMobile();
}
if ( ! (strpos($browser, '#') === 0))
{
$browser = '#' . RLText::pregQuote($browser) . '#';
}
// also check for _ instead of .
$browser = preg_replace('#\\\.([^\]])#', '[\._]\1',
$browser);
$browser = str_replace('\.]', '\._]', $browser);
return preg_match($browser . 'i', $this->getAgent());
}
}
assignments/akeebasubs.php000064400000002606151161676250011733
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
class RLAssignmentsAkeebaSubs extends RLAssignment
{
public function init()
{
if ( ! $this->request->id && $this->request->view ==
'level')
{
$slug =
JFactory::getApplication()->input->getString('slug',
'');
if ($slug)
{
$query = $this->db->getQuery(true)
->select('l.akeebasubs_level_id')
->from('#__akeebasubs_levels AS l')
->where('l.slug = ' . $this->db->quote($slug));
$this->db->setQuery($query);
$this->request->id = $this->db->loadResult();
}
}
}
public function passPageTypes()
{
return $this->passByPageTypes('com_akeebasubs',
$this->selection, $this->assignment);
}
public function passLevels()
{
if ( ! $this->request->id || $this->request->option !=
'com_akeebasubs' || $this->request->view !=
'level')
{
return $this->pass(false);
}
return $this->passSimple($this->request->id);
}
}
assignments/components.php000064400000001321151161676250012004
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsComponents extends RLAssignment
{
public function passComponents()
{
return $this->passSimple(strtolower($this->request->option));
}
}
assignments/content.php000064400000013030151161676250011271
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\MVC\Model\BaseDatabaseModel as JModel;
use Joomla\CMS\Table\Table as JTable;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsContent extends RLAssignment
{
public function passPageTypes()
{
$components = ['com_content', 'com_contentsubmit'];
if ( ! in_array($this->request->option, $components))
{
return $this->pass(false);
}
if ($this->request->view == 'category' &&
$this->request->layout == 'blog')
{
$view = 'categoryblog';
}
else
{
$view = $this->request->view;
}
return $this->passSimple($view);
}
public function passCategories()
{
// components that use the com_content secs/cats
$components = ['com_content', 'com_flexicontent',
'com_contentsubmit'];
if ( ! in_array($this->request->option, $components))
{
return $this->pass(false);
}
if (empty($this->selection))
{
return $this->pass(false);
}
$is_content = in_array($this->request->option,
['com_content', 'com_flexicontent']);
$is_category = in_array($this->request->view,
['category']);
$is_item = in_array($this->request->view, ['',
'article', 'item', 'form']);
if (
$this->request->option != 'com_contentsubmit'
&& ! ($this->params->inc_categories && $is_content
&& $is_category)
&& ! ($this->params->inc_articles && $is_content
&& $is_item)
&& ! ($this->params->inc_others && ! ($is_content
&& ($is_category || $is_item)))
)
{
return $this->pass(false);
}
if ($this->request->option == 'com_contentsubmit')
{
// Content Submit
$contentsubmit_params = new ContentsubmitModelArticle;
if (in_array($contentsubmit_params->_id, $this->selection))
{
return $this->pass(true);
}
return $this->pass(false);
}
$pass = false;
if (
$this->params->inc_others
&& ! ($is_content && ($is_category || $is_item))
&& $this->article
)
{
if ( ! isset($this->article->id) &&
isset($this->article->slug))
{
$this->article->id = (int) $this->article->slug;
}
if ( ! isset($this->article->catid) &&
isset($this->article->catslug))
{
$this->article->catid = (int) $this->article->catslug;
}
$this->request->id = $this->article->id;
$this->request->view = 'article';
}
$catids = $this->getCategoryIds($is_category);
foreach ($catids as $catid)
{
if ( ! $catid)
{
continue;
}
$pass = in_array($catid, $this->selection);
if ($pass && $this->params->inc_children == 2)
{
$pass = false;
continue;
}
if ( ! $pass && $this->params->inc_children)
{
$parent_ids = $this->getCatParentIds($catid);
$parent_ids = array_diff($parent_ids, [1]);
foreach ($parent_ids as $id)
{
if (in_array($id, $this->selection))
{
$pass = true;
break;
}
}
unset($parent_ids);
}
}
return $this->pass($pass);
}
private function getCategoryIds($is_category = false)
{
if ($is_category)
{
return (array) $this->request->id;
}
if ( ! $this->article && $this->request->id)
{
$this->article = JTable::getInstance('content');
$this->article->load($this->request->id);
}
if ($this->article && $this->article->catid)
{
return (array) $this->article->catid;
}
$catid =
JFactory::getApplication()->input->getInt('catid',
JFactory::getApplication()->getUserState('com_content.articles.filter.category_id'));
$menuparams = $this->getMenuItemParams($this->request->Itemid);
if ($this->request->view == 'featured')
{
$menuparams = $this->getMenuItemParams($this->request->Itemid);
return isset($menuparams->featured_categories) ? (array)
$menuparams->featured_categories : (array) $catid;
}
return isset($menuparams->catid) ? (array) $menuparams->catid :
(array) $catid;
}
public function passArticles()
{
if ( ! $this->request->id
|| ! (($this->request->option == 'com_content'
&& $this->request->view == 'article')
|| ($this->request->option == 'com_flexicontent'
&& $this->request->view == 'item')
)
)
{
return $this->pass(false);
}
$pass = false;
// Pass Article Id
if ( ! $this->passItemByType($pass, 'ContentIds'))
{
return $this->pass(false);
}
// Pass Content Keywords
if ( ! $this->passItemByType($pass, 'ContentKeywords'))
{
return $this->pass(false);
}
// Pass Meta Keywords
if ( ! $this->passItemByType($pass, 'MetaKeywords'))
{
return $this->pass(false);
}
// Pass Authors
if ( ! $this->passItemByType($pass, 'Authors'))
{
return $this->pass(false);
}
return $this->pass($pass);
}
public function getItem($fields = [])
{
if ($this->article)
{
return $this->article;
}
if ( ! class_exists('ContentModelArticle'))
{
require_once JPATH_SITE .
'/components/com_content/models/article.php';
}
$model = JModel::getInstance('article',
'contentModel');
if ( ! method_exists($model, 'getItem'))
{
return null;
}
$this->article = $model->getItem($this->request->id);
return $this->article;
}
private function getCatParentIds($id = 0)
{
return $this->getParentIds($id, 'categories');
}
}
assignments/cookieconfirm.php000064400000001477151161676250012462
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsCookieConfirm extends RLAssignment
{
public function passCookieConfirm()
{
require_once JPATH_PLUGINS . '/system/cookieconfirm/core.php';
$pass = PlgSystemCookieconfirmCore::getInstance()->isCookiesAllowed();
return $this->pass($pass);
}
}
assignments/datetime.php000064400000014107151161676250011421
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsDateTime extends RLAssignment
{
var $timezone = null;
var $dates = [];
public function passDate()
{
if ( ! $this->params->publish_up && !
$this->params->publish_down)
{
// no date range set
return ($this->assignment == 'include');
}
require_once dirname(__DIR__) . '/text.php';
RLText::fixDate($this->params->publish_up);
RLText::fixDate($this->params->publish_down);
$now = $this->getNow();
$up = $this->getDate($this->params->publish_up);
$down = $this->getDate($this->params->publish_down);
if (isset($this->params->recurring) &&
$this->params->recurring)
{
if ( ! (int) $this->params->publish_up || ! (int)
$this->params->publish_down)
{
// no date range set
return ($this->assignment == 'include');
}
$up = strtotime(date('Y') . $up->format('-m-d
H:i:s', true));
$down = strtotime(date('Y') . $down->format('-m-d
H:i:s', true));
// pass:
// 1) now is between up and down
// 2) up is later in year than down and:
// 2a) now is after up
// 2b) now is before down
if (
($up < $now && $down > $now)
|| ($up > $down
&& (
$up < $now
|| $down > $now
)
)
)
{
return ($this->assignment == 'include');
}
// outside date range
return $this->pass(false);
}
if (
(
(int) $this->params->publish_up
&& strtotime($up->format('Y-m-d H:i:s', true))
> $now
)
|| (
(int) $this->params->publish_down
&& strtotime($down->format('Y-m-d H:i:s', true))
< $now
)
)
{
// outside date range
return $this->pass(false);
}
// pass
return ($this->assignment == 'include');
}
public function passSeasons()
{
$season = self::getSeason($this->date,
$this->params->hemisphere);
return $this->passSimple($season);
}
public function passMonths()
{
$month = $this->date->format('m', true); // 01 (for
January) through 12 (for December)
return $this->passSimple((int) $month);
}
public function passDays()
{
$day = $this->date->format('N', true); // 1 (for Monday)
though 7 (for Sunday )
return $this->passSimple($day);
}
public function passTime()
{
$now = $this->getNow();
$up = strtotime($this->date->format('Y-m-d ', true) .
$this->params->publish_up);
$down = strtotime($this->date->format('Y-m-d ', true) .
$this->params->publish_down);
if ($up > $down)
{
// publish up is after publish down (spans midnight)
// current time should be:
// - after publish up
// - OR before publish down
if ($now >= $up || $now < $down)
{
return $this->pass(true);
}
return $this->pass(false);
}
// publish down is after publish up (simple time span)
// current time should be:
// - after publish up
// - AND before publish down
if ($now >= $up && $now < $down)
{
return $this->pass(true);
}
return $this->pass(false);
}
private function getSeason(&$d, $hemisphere = 'northern')
{
// Set $date to today
$date = strtotime($d->format('Y-m-d H:i:s', true));
// Get year of date specified
$date_year = $d->format('Y', true); // Four digit
representation for the year
// Specify the season names
$season_names = ['winter', 'spring',
'summer', 'fall'];
// Declare season date ranges
switch (strtolower($hemisphere))
{
case 'southern':
if (
$date < strtotime($date_year . '-03-21')
|| $date >= strtotime($date_year . '-12-21')
)
{
return $season_names[2]; // Must be in Summer
}
if ($date >= strtotime($date_year . '-09-23'))
{
return $season_names[1]; // Must be in Spring
}
if ($date >= strtotime($date_year . '-06-21'))
{
return $season_names[0]; // Must be in Winter
}
if ($date >= strtotime($date_year . '-03-21'))
{
return $season_names[3]; // Must be in Fall
}
break;
case 'australia':
if (
$date < strtotime($date_year . '-03-01')
|| $date >= strtotime($date_year . '-12-01')
)
{
return $season_names[2]; // Must be in Summer
}
if ($date >= strtotime($date_year . '-09-01'))
{
return $season_names[1]; // Must be in Spring
}
if ($date >= strtotime($date_year . '-06-01'))
{
return $season_names[0]; // Must be in Winter
}
if ($date >= strtotime($date_year . '-03-01'))
{
return $season_names[3]; // Must be in Fall
}
break;
default: // northern
if (
$date < strtotime($date_year . '-03-21')
|| $date >= strtotime($date_year . '-12-21')
)
{
return $season_names[0]; // Must be in Winter
}
if ($date >= strtotime($date_year . '-09-23'))
{
return $season_names[3]; // Must be in Fall
}
if ($date >= strtotime($date_year . '-06-21'))
{
return $season_names[2]; // Must be in Summer
}
if ($date >= strtotime($date_year . '-03-21'))
{
return $season_names[1]; // Must be in Spring
}
break;
}
return 0;
}
private function getNow()
{
return strtotime($this->date->format('Y-m-d H:i:s',
true));
}
private function getDate($date = '')
{
$id = 'date_' . $date;
if (isset($this->dates[$id]))
{
return $this->dates[$id];
}
$this->dates[$id] = JFactory::getDate($date);
if (empty($this->params->ignore_time_zone))
{
$this->dates[$id]->setTimeZone($this->getTimeZone());
}
return $this->dates[$id];
}
private function getTimeZone()
{
if ( ! is_null($this->timezone))
{
return $this->timezone;
}
$this->timezone = new
DateTimeZone(JFactory::getApplication()->getCfg('offset'));
return $this->timezone;
}
}
assignments/easyblog.php000064400000010007151161676250011425
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsEasyBlog extends RLAssignment
{
public function passPageTypes()
{
return $this->passByPageTypes('com_easyblog',
$this->selection, $this->assignment);
}
public function passCategories()
{
if ($this->request->option != 'com_easyblog')
{
return $this->pass(false);
}
$pass = (
($this->params->inc_categories &&
$this->request->view == 'categories')
|| ($this->params->inc_items && $this->request->view
== 'entry')
);
if ( ! $pass)
{
return $this->pass(false);
}
$cats = $this->makeArray($this->getCategories());
$pass = $this->passSimple($cats, 'include');
if ($pass && $this->params->inc_children == 2)
{
return $this->pass(false);
}
else if ( ! $pass && $this->params->inc_children)
{
foreach ($cats as $cat)
{
$cats = array_merge($cats, $this->getCatParentIds($cat));
}
}
return $this->passSimple($cats);
}
private function getCategories()
{
switch ($this->request->view)
{
case 'entry' :
return $this->getCategoryIDFromItem();
break;
case 'categories' :
return $this->request->id;
break;
default:
return '';
}
}
private function getCategoryIDFromItem()
{
$query = $this->db->getQuery(true)
->select('i.category_id')
->from('#__easyblog_post AS i')
->where('i.id = ' . (int) $this->request->id);
$this->db->setQuery($query);
return $this->db->loadResult();
}
public function passTags()
{
if ($this->request->option != 'com_easyblog')
{
return $this->pass(false);
}
$pass = (
($this->params->inc_tags && $this->request->layout
== 'tag')
|| ($this->params->inc_items && $this->request->view
== 'entry')
);
if ( ! $pass)
{
return $this->pass(false);
}
if ($this->params->inc_tags && $this->request->layout
== 'tag')
{
$query = $this->db->getQuery(true)
->select('t.alias')
->from('#__easyblog_tag AS t')
->where('t.id = ' . (int) $this->request->id)
->where('t.published = 1');
$this->db->setQuery($query);
$tags = $this->db->loadColumn();
return $this->passSimple($tags, true);
}
$query = $this->db->getQuery(true)
->select('t.alias')
->from('#__easyblog_post_tag AS x')
->join('LEFT', '#__easyblog_tag AS t ON t.id =
x.tag_id')
->where('x.post_id = ' . (int) $this->request->id)
->where('t.published = 1');
$this->db->setQuery($query);
$tags = $this->db->loadColumn();
return $this->passSimple($tags, true);
}
public function passItems()
{
if ( ! $this->request->id || $this->request->option !=
'com_easyblog' || $this->request->view !=
'entry')
{
return $this->pass(false);
}
$pass = false;
// Pass Article Id
if ( ! $this->passItemByType($pass, 'ContentIds'))
{
return $this->pass(false);
}
// Pass Content Keywords
if ( ! $this->passItemByType($pass, 'ContentKeywords'))
{
return $this->pass(false);
}
// Pass Authors
if ( ! $this->passItemByType($pass, 'Authors'))
{
return $this->pass(false);
}
return $this->pass($pass);
}
public function passContentKeywords($fields = ['title',
'intro', 'content'], $text = '')
{
parent::passContentKeywords($fields);
}
public function getItem($fields = [])
{
$query = $this->db->getQuery(true)
->select($fields)
->from('#__easyblog_post')
->where('id = ' . (int) $this->request->id);
$this->db->setQuery($query);
return $this->db->loadObject();
}
private function getCatParentIds($id = 0)
{
return $this->getParentIds($id, 'easyblog_category',
'parent_id');
}
}
assignments/flexicontent.php000064400000004622151161676250012330
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsFlexiContent extends RLAssignment
{
public function passPageTypes()
{
return $this->passByPageTypes('com_flexicontent',
$this->selection, $this->assignment);
}
public function passTags()
{
if ($this->request->option != 'com_flexicontent')
{
return $this->pass(false);
}
$pass = (
($this->params->inc_tags && $this->request->view ==
'tags')
|| ($this->params->inc_items &&
in_array($this->request->view, ['item',
'items']))
);
if ( ! $pass)
{
return $this->pass(false);
}
if ($this->params->inc_tags && $this->request->view
== 'tags')
{
$query = $this->db->getQuery(true)
->select('t.name')
->from('#__flexicontent_tags AS t')
->where('t.id = ' . (int)
trim(JFactory::getApplication()->input->getInt('id', 0)))
->where('t.published = 1');
$this->db->setQuery($query);
$tag = $this->db->loadResult();
$tags = [$tag];
}
else
{
$query = $this->db->getQuery(true)
->select('t.name')
->from('#__flexicontent_tags_item_relations AS x')
->join('LEFT', '#__flexicontent_tags AS t ON t.id =
x.tid')
->where('x.itemid = ' . (int) $this->request->id)
->where('t.published = 1');
$this->db->setQuery($query);
$tags = $this->db->loadColumn();
}
return $this->passSimple($tags, true);
}
public function passTypes()
{
if ($this->request->option != 'com_flexicontent')
{
return $this->pass(false);
}
$pass = in_array($this->request->view, ['item',
'items']);
if ( ! $pass)
{
return $this->pass(false);
}
$query = $this->db->getQuery(true)
->select('x.type_id')
->from('#__flexicontent_items_ext AS x')
->where('x.item_id = ' . (int) $this->request->id);
$this->db->setQuery($query);
$type = $this->db->loadResult();
$types = $this->makeArray($type);
return $this->passSimple($types);
}
}
assignments/form2content.php000064400000002062151161676250012242
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsForm2Content extends RLAssignment
{
public function passProjects()
{
if ($this->request->option != 'com_content' &&
$this->request->view == 'article')
{
return $this->pass(false);
}
$query = $this->db->getQuery(true)
->select('c.projectid')
->from('#__f2c_form AS c')
->where('c.reference_id = ' . (int)
$this->request->id);
$this->db->setQuery($query);
$type = $this->db->loadResult();
$types = $this->makeArray($type);
return $this->passSimple($types);
}
}
assignments/geo.php000064400000005162151161676250010400 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Log\Log as JLog;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsGeo extends RLAssignment
{
var $geo = null;
/**
* passContinents
*/
public function passContinents()
{
if ( ! $this->getGeo() || empty($this->geo->continentCode))
{
return $this->pass(false);
}
return $this->passSimple([$this->geo->continent,
$this->geo->continentCode]);
}
/**
* passCountries
*/
public function passCountries()
{
$this->getGeo();
if ( ! $this->getGeo() || empty($this->geo->countryCode))
{
return $this->pass(false);
}
return $this->passSimple([$this->geo->country,
$this->geo->countryCode]);
}
/**
* passRegions
*/
public function passRegions()
{
if ( ! $this->getGeo() || empty($this->geo->countryCode) ||
empty($this->geo->regionCodes))
{
return $this->pass(false);
}
$regions = $this->geo->regionCodes;
array_walk($regions, function (&$value) {
$value = $this->geo->countryCode . '-' . $value;
});
return $this->passSimple($regions);
}
/**
* passPostalcodes
*/
public function passPostalcodes()
{
if ( ! $this->getGeo() || empty($this->geo->postalCode))
{
return $this->pass(false);
}
// replace dashes with dots: 730-0011 => 730.0011
$postalcode = str_replace('-', '.',
$this->geo->postalCode);
return $this->passInRange($postalcode);
}
public function getGeo($ip = '')
{
if ($this->geo !== null)
{
return $this->geo;
}
$geo = $this->getGeoObject($ip);
if (empty($geo))
{
return false;
}
$this->geo = $geo->get();
if (JFactory::getApplication()->get('debug'))
{
JLog::addLogger(['text_file' =>
'regularlabs_geoip.log.php'], JLog::ALL,
['regularlabs_geoip']);
JLog::add(json_encode($this->geo), JLog::DEBUG,
'regularlabs_geoip');
}
return $this->geo;
}
private function getGeoObject($ip)
{
if ( ! file_exists(JPATH_LIBRARIES . '/geoip/geoip.php'))
{
return false;
}
require_once JPATH_LIBRARIES . '/geoip/geoip.php';
if ( ! class_exists('RegularLabs_GeoIp'))
{
return new GeoIp($ip);
}
return new RegularLabs_GeoIp($ip);
}
}
assignments/hikashop.php000064400000005775151161676250011446
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsHikaShop extends RLAssignment
{
public function passPageTypes()
{
if ($this->request->option != 'com_hikashop')
{
return $this->pass(false);
}
$type = $this->request->view;
if (
($type == 'product' &&
in_array($this->request->layout, ['contact',
'show']))
|| ($type == 'user' &&
in_array($this->request->layout, ['cpanel']))
)
{
$type .= '_' . $this->request->layout;
}
return $this->passSimple($type);
}
public function passCategories()
{
if ($this->request->option != 'com_hikashop')
{
return $this->pass(false);
}
$pass = (
($this->params->inc_categories
&& ($this->request->view == 'category' ||
$this->request->layout == 'listing')
)
|| ($this->params->inc_items && $this->request->view
== 'product')
);
if ( ! $pass)
{
return $this->pass(false);
}
$cats = $this->getCategories();
$pass = $this->passSimple($cats, 'include');
if ($pass && $this->params->inc_children == 2)
{
return $this->pass(false);
}
else if ( ! $pass && $this->params->inc_children)
{
foreach ($cats as $cat)
{
$cats = array_merge($cats, $this->getCatParentIds($cat));
}
}
return $this->passSimple($cats);
}
public function passProducts()
{
if ( ! $this->request->id || $this->request->option !=
'com_hikashop' || $this->request->view !=
'product')
{
return $this->pass(false);
}
return $this->passSimple($this->request->id);
}
private function getCategories()
{
switch (true)
{
case (($this->request->view == 'category' ||
$this->request->layout == 'listing') &&
$this->request->id):
return [$this->request->id];
case ($this->request->view == 'category' ||
$this->request->layout == 'listing'):
include_once JPATH_ADMINISTRATOR .
'/components/com_hikashop/helpers/helper.php';
$menuClass = hikashop_get('class.menus');
$menuData = $menuClass->get($this->request->Itemid);
return
$this->makeArray($menuData->hikashop_params['selectparentlisting']);
case ($this->request->id):
$query = $this->db->getQuery(true)
->select('c.category_id')
->from('#__hikashop_product_category AS c')
->where('c.product_id = ' . (int)
$this->request->id);
$this->db->setQuery($query);
$cats = $this->db->loadColumn();
return $this->makeArray($cats);
default:
return [];
}
}
private function getCatParentIds($id = 0)
{
return $this->getParentIds($id, 'hikashop_category',
'category_parent_id', 'category_id');
}
}
assignments/homepage.php000064400000011606151161676250011413
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Language\LanguageHelper as JLanguageHelper;
use Joomla\CMS\Uri\Uri as JUri;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/text.php';
require_once dirname(__DIR__) . '/string.php';
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsHomePage extends RLAssignment
{
public function passHomePage()
{
$home =
JFactory::getApplication()->getMenu('site')->getDefault(JFactory::getLanguage()->getTag());
// return if option or other set values do not match the homepage menu
item values
if ($this->request->option)
{
// check if option is different to home menu
if ( ! $home || ! isset($home->query['option']) ||
$home->query['option'] != $this->request->option)
{
return $this->pass(false);
}
if ( ! $this->request->option)
{
// set the view/task/layout in the menu item to empty if not set
$home->query['view'] =
isset($home->query['view']) ?
$home->query['view'] : '';
$home->query['task'] =
isset($home->query['task']) ?
$home->query['task'] : '';
$home->query['layout'] =
isset($home->query['layout']) ?
$home->query['layout'] : '';
}
// check set values against home menu query items
foreach ($home->query as $k => $v)
{
if ((isset($this->request->{$k}) &&
$this->request->{$k} != $v)
|| (
( ! isset($this->request->{$k}) || in_array($v,
['virtuemart', 'mijoshop']))
&& JFactory::getApplication()->input->get($k) != $v
)
)
{
return $this->pass(false);
}
}
// check post values against home menu params
foreach ($home->params->toObject() as $k => $v)
{
if (($v && isset($_POST[$k]) && $_POST[$k] != $v)
|| ( ! $v && isset($_POST[$k]) && $_POST[$k])
)
{
return $this->pass(false);
}
}
}
$pass = $this->checkPass($home);
if ( ! $pass)
{
$pass = $this->checkPass($home, 1);
}
return $this->pass($pass);
}
private function checkPass(&$home, $addlang = 0)
{
$uri = JUri::getInstance();
if ($addlang)
{
$sef = $uri->getVar('lang');
if (empty($sef))
{
$langs = array_keys(JLanguageHelper::getLanguages('sef'));
$path = RLString::substr(
$uri->toString(['scheme', 'user',
'pass', 'host', 'port', 'path']),
RLString::strlen($uri->base())
);
$path = preg_replace('#^index\.php/?#', '',
$path);
$parts = explode('/', $path);
$part = reset($parts);
if (in_array($part, $langs))
{
$sef = $part;
}
}
if (empty($sef))
{
return false;
}
}
$query = $uri->toString(['query']);
if (strpos($query, 'option=') === false &&
strpos($query, 'Itemid=') === false)
{
$url = $uri->toString(['host', 'path']);
}
else
{
$url = $uri->toString(['host', 'path',
'query']);
}
// remove the www.
$url = preg_replace('#^www\.#', '', $url);
// replace ampersand chars
$url = str_replace('&', '&', $url);
// remove any language vars
$url =
preg_replace('#((\?)lang=[a-z-_]*(&|$)|&lang=[a-z-_]*)#',
'\2', $url);
// remove trailing nonsense
$url = trim(preg_replace('#/?\??&?$#', '',
$url));
// remove the index.php/
$url = preg_replace('#/index\.php(/|$)#', '/', $url);
// remove trailing /
$url = trim(preg_replace('#/$#', '', $url));
$root = JUri::root();
// remove the http(s)
$root = preg_replace('#^.*?://#', '', $root);
// remove the www.
$root = preg_replace('#^www\.#', '', $root);
//remove the port
$root = preg_replace('#:[0-9]+#', '', $root);
// so also passes on urls with trailing /, ?, &, /?, etc...
$root = preg_replace('#(Itemid=[0-9]*).*^#', '\1',
$root);
// remove trailing /
$root = trim(preg_replace('#/$#', '', $root));
if ($addlang)
{
$root .= '/' . $sef;
}
/* Pass urls:
* [root]
*/
$regex = '#^' . $root . '$#i';
if (preg_match($regex, $url))
{
return true;
}
/* Pass urls:
* [root]?Itemid=[menu-id]
* [root]/?Itemid=[menu-id]
* [root]/index.php?Itemid=[menu-id]
* [root]/[menu-alias]
* [root]/[menu-alias]?Itemid=[menu-id]
* [root]/index.php?[menu-alias]
* [root]/index.php?[menu-alias]?Itemid=[menu-id]
* [root]/[menu-link]
* [root]/[menu-link]&Itemid=[menu-id]
*/
$regex = '#^' . $root
. '(/('
. 'index\.php'
. '|'
. '(index\.php\?)?' . RLText::pregQuote($home->alias)
. '|'
. RLText::pregQuote($home->link)
. ')?)?'
. '(/?[\?&]Itemid=' . (int) $home->id . ')?'
. '$#i';
return preg_match($regex, $url);
}
}
assignments/ips.php000064400000005742151161676250010425 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsIPs extends RLAssignment
{
public function passIPs()
{
if (is_array($this->selection))
{
$this->selection = implode(',', $this->selection);
}
$this->selection = explode(',', str_replace([' ',
"\r", "\n"], ['', '',
','], $this->selection));
$pass = $this->checkIPList();
return $this->pass($pass);
}
private function checkIPList()
{
foreach ($this->selection as $range)
{
// Check next range if this one doesn't match
if ( ! $this->checkIP($range))
{
continue;
}
// Match found, so return true!
return true;
}
// No matches found, so return false
return false;
}
private function checkIP($range)
{
if (empty($range))
{
return false;
}
if (strpos($range, '-') !== false)
{
// Selection is an IP range
return $this->checkIPRange($range);
}
// Selection is a single IP (part)
return $this->checkIPPart($range);
}
private function checkIPRange($range)
{
$ip = $_SERVER['REMOTE_ADDR'];
// Return if no IP address can be found (shouldn't happen, but who
knows)
if (empty($ip))
{
return false;
}
// check if IP is between or equal to the from and to IP range
list($min, $max) = explode('-', trim($range), 2);
// Return false if IP is smaller than the range start
if ($ip < trim($min))
{
return false;
}
$max = $this->fillMaxRange($max, $min);
// Return false if IP is larger than the range end
if ($ip > trim($max))
{
return false;
}
return true;
}
/* Fill the max range by prefixing it with the missing parts from the min
range
* So 101.102.103.104-201.202 becomes:
* max: 101.102.201.202
*/
private function fillMaxRange($max, $min)
{
$max_parts = explode('.', $max);
if (count() == 4)
{
return $max;
}
$min_parts = explode('.', $min);
$prefix = array_slice($min_parts, 0, count($min_parts) -
count($max_parts));
return implode('.', $prefix) . '.' .
implode('.', $max_parts);
}
private function checkIPPart($range)
{
$ip = $_SERVER['REMOTE_ADDR'];
// Return if no IP address can be found (shouldn't happen, but who
knows)
if (empty($ip))
{
return false;
}
$ip_parts = explode('.', $ip);
$range_parts = explode('.', trim($range));
// Trim the IP to the part length of the range
$ip = implode('.', array_slice($ip_parts, 0,
count($range_parts)));
// Return false if ip does not match the range
if ($range != $ip)
{
return false;
}
return true;
}
}
assignments/k2.php000064400000010676151161676250010150 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
// If controller.php exists, assume this is K2 v3
defined('RL_K2_VERSION') or define('RL_K2_VERSION',
file_exists(JPATH_ADMINISTRATOR .
'/components/com_k2/controller.php') ? 3 : 2);
class RLAssignmentsK2 extends RLAssignment
{
public function passPageTypes()
{
return $this->passByPageTypes('com_k2', $this->selection,
$this->assignment, false, true);
}
public function passCategories()
{
if ($this->request->option != 'com_k2')
{
return $this->pass(false);
}
$pass = (
($this->params->inc_categories
&& (($this->request->view == 'itemlist'
&& $this->request->task == 'category')
|| $this->request->view == 'latest'
)
)
|| ($this->params->inc_items && $this->request->view
== 'item')
);
if ( ! $pass)
{
return $this->pass(false);
}
$cats = $this->makeArray($this->getCategories());
$pass = $this->passSimple($cats, 'include');
if ($pass && $this->params->inc_children == 2)
{
return $this->pass(false);
}
else if ( ! $pass && $this->params->inc_children)
{
foreach ($cats as $cat)
{
$cats = array_merge($cats, $this->getCatParentIds($cat));
}
}
return $this->passSimple($cats);
}
private function getCategories()
{
switch ($this->request->view)
{
case 'item' :
return $this->getCategoryIDFromItem();
break;
case 'itemlist' :
return $this->getCategoryID();
break;
default:
return '';
}
}
private function getCategoryID()
{
return $this->request->id ?:
JFactory::getApplication()->getUserStateFromRequest('com_k2itemsfilter_category',
'catid', 0, 'int');
}
private function getCategoryIDFromItem()
{
if ($this->article && isset($this->article->catid))
{
return $this->article->catid;
}
$query = $this->db->getQuery(true)
->select('i.catid')
->from('#__k2_items AS i')
->where('i.id = ' . (int) $this->request->id);
$this->db->setQuery($query);
return $this->db->loadResult();
}
public function passTags()
{
if ($this->request->option != 'com_k2')
{
return $this->pass(false);
}
$tag =
trim(JFactory::getApplication()->input->getString('tag',
''));
$pass = (
($this->params->inc_tags && $tag != '')
|| ($this->params->inc_items && $this->request->view
== 'item')
);
if ( ! $pass)
{
return $this->pass(false);
}
if ($this->params->inc_tags && $tag != '')
{
$tags =
[trim(JFactory::getApplication()->input->getString('tag',
''))];
return $this->passSimple($tags, true);
}
$query = $this->db->getQuery(true)
->select('t.name')
->from('#__k2_tags_xref AS x')
->join('LEFT', '#__k2_tags AS t ON t.id =
x.tagID')
->where('x.itemID = ' . (int) $this->request->id)
->where('t.published = 1');
$this->db->setQuery($query);
$tags = $this->db->loadColumn();
return $this->passSimple($tags, true);
}
public function passItems()
{
if ( ! $this->request->id || $this->request->option !=
'com_k2' || $this->request->view != 'item')
{
return $this->pass(false);
}
$pass = false;
// Pass Article Id
if ( ! $this->passItemByType($pass, 'ContentIds'))
{
return $this->pass(false);
}
// Pass Content Keywords
if ( ! $this->passItemByType($pass, 'ContentKeywords'))
{
return $this->pass(false);
}
// Pass Meta Keywords
if ( ! $this->passItemByType($pass, 'MetaKeywords'))
{
return $this->pass(false);
}
// Pass Authors
if ( ! $this->passItemByType($pass, 'Authors'))
{
return $this->pass(false);
}
return $this->pass($pass);
}
public function getItem($fields = [])
{
$query = $this->db->getQuery(true)
->select($fields)
->from('#__k2_items')
->where('id = ' . (int) $this->request->id);
$this->db->setQuery($query);
return $this->db->loadObject();
}
private function getCatParentIds($id = 0)
{
$parent_field = RL_K2_VERSION == 3 ? 'parent_id' :
'parent';
return $this->getParentIds($id, 'k2_categories',
$parent_field);
}
}
assignments/languages.php000064400000001371151161676250011572
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsLanguages extends RLAssignment
{
public function passLanguages()
{
return $this->passSimple(JFactory::getLanguage()->getTag(), true);
}
}
assignments/menu.php000064400000004547151161676250010600 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsMenu extends RLAssignment
{
public function passMenu()
{
// return if no Itemid or selection is set
if ( ! $this->request->Itemid || empty($this->selection))
{
return $this->pass($this->params->inc_noitemid);
}
$menutype = 'type.' . self::getMenuType();
// return true if menu type is in selection
if (in_array($menutype, $this->selection))
{
return $this->pass(true);
}
// return true if menu is in selection
if (in_array($this->request->Itemid, $this->selection))
{
return $this->pass(($this->params->inc_children != 2));
}
if ( ! $this->params->inc_children)
{
return $this->pass(false);
}
$parent_ids = $this->getMenuParentIds($this->request->Itemid);
$parent_ids = array_diff($parent_ids, [1]);
foreach ($parent_ids as $id)
{
if ( ! in_array($id, $this->selection))
{
continue;
}
return $this->pass(true);
}
return $this->pass(false);
}
private function getMenuParentIds($id = 0)
{
return $this->getParentIds($id, 'menu');
}
private function getMenuType()
{
if (isset($this->request->menutype))
{
return $this->request->menutype;
}
if (empty($this->request->Itemid))
{
$this->request->menutype = '';
return $this->request->menutype;
}
if (JFactory::getApplication()->isClient('site'))
{
$menu = JFactory::getApplication()->getMenu()->getItem((int)
$this->request->Itemid);
$this->request->menutype = isset($menu->menutype) ?
$menu->menutype : '';
return $this->request->menutype;
}
$query = $this->db->getQuery(true)
->select('m.menutype')
->from('#__menu AS m')
->where('m.id = ' . (int) $this->request->Itemid);
$this->db->setQuery($query);
$this->request->menutype = $this->db->loadResult();
return $this->request->menutype;
}
}
assignments/mijoshop.php000064400000005770151161676250011463
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsMijoShop extends RLAssignment
{
public function init()
{
$input = JFactory::getApplication()->input;
$category_id = $input->getCmd('path', 0);
if (strpos($category_id, '_'))
{
$category_id = end(explode('_', $category_id));
}
$this->request->item_id =
$input->getInt('product_id', 0);
$this->request->category_id = $category_id;
$this->request->id = ($this->request->item_id) ?
$this->request->item_id : $this->request->category_id;
$view = $input->getCmd('view', '');
if (empty($view))
{
$mijoshop = JPATH_ROOT .
'/components/com_mijoshop/mijoshop/mijoshop.php';
if ( ! file_exists($mijoshop))
{
return;
}
require_once($mijoshop);
$route = $input->getString('route', '');
$view = MijoShop::get('router')->getView($route);
}
$this->request->view = $view;
}
public function passPageTypes()
{
return $this->passByPageTypes('com_mijoshop',
$this->selection, $this->assignment, true);
}
public function passCategories()
{
if ($this->request->option != 'com_mijoshop')
{
return $this->pass(false);
}
$pass = (
($this->params->inc_categories
&& ($this->request->view == 'category')
)
|| ($this->params->inc_items && $this->request->view
== 'product')
);
if ( ! $pass)
{
return $this->pass(false);
}
$cats = [];
if ($this->request->category_id)
{
$cats = $this->request->category_id;
}
else if ($this->request->item_id)
{
$query = $this->db->getQuery(true)
->select('c.category_id')
->from('#__mijoshop_product_to_category AS c')
->where('c.product_id = ' . (int)
$this->request->id);
$this->db->setQuery($query);
$cats = $this->db->loadColumn();
}
$cats = $this->makeArray($cats);
$pass = $this->passSimple($cats, 'include');
if ($pass && $this->params->inc_children == 2)
{
return $this->pass(false);
}
else if ( ! $pass && $this->params->inc_children)
{
foreach ($cats as $cat)
{
$cats = array_merge($cats, $this->getCatParentIds($cat));
}
}
return $this->passSimple($cats);
}
public function passProducts()
{
if ( ! $this->request->id || $this->request->option !=
'com_mijoshop' || $this->request->view !=
'product')
{
return $this->pass(false);
}
return $this->passSimple($this->request->id);
}
private function getCatParentIds($id = 0)
{
return $this->getParentIds($id, 'mijoshop_category',
'parent_id', 'category_id');
}
}
assignments/php.php000064400000005445151161676250010421 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\MVC\Model\BaseDatabaseModel as JModel;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsPHP extends RLAssignment
{
public function passPHP()
{
$article = $this->article;
if ( ! is_array($this->selection))
{
$this->selection = [$this->selection];
}
$pass = false;
foreach ($this->selection as $php)
{
// replace \n with newline and other fix stuff
$php = str_replace('\|', '|', $php);
$php = preg_replace('#(?<!\\\)\\\n#', "\n",
$php);
$php = trim(str_replace('[:REGEX_ENTER:]', '\n',
$php));
if ($php == '')
{
$pass = true;
break;
}
if ( ! $article && strpos($php, '$article') !== false)
{
$article = null;
if ($this->request->option == 'com_content' &&
$this->request->view == 'article')
{
$article = $this->getArticleById($this->request->id);
}
}
if ( ! isset($Itemid))
{
$Itemid =
JFactory::getApplication()->input->getInt('Itemid', 0);
}
if ( ! isset($mainframe))
{
$mainframe = JFactory::getApplication();
}
if ( ! isset($app))
{
$app = JFactory::getApplication();
}
if ( ! isset($document))
{
$document = JFactory::getDocument();
}
if ( ! isset($doc))
{
$doc = JFactory::getDocument();
}
if ( ! isset($database))
{
$database = JFactory::getDbo();
}
if ( ! isset($db))
{
$db = JFactory::getDbo();
}
if ( ! isset($user))
{
$user = JFactory::getUser();
}
$php .= ';return true;';
$temp_PHP_func = create_function('&$article, &$Itemid,
&$mainframe, &$app, &$document, &$doc, &$database,
&$db, &$user', $php);
// evaluate the script
ob_start();
$pass = (bool) $temp_PHP_func($article, $Itemid, $mainframe, $app,
$document, $doc, $database, $db, $user);
unset($temp_PHP_func);
ob_end_clean();
if ($pass)
{
break;
}
}
return $this->pass($pass);
}
private function getArticleById($id = 0)
{
if ( ! $id)
{
return null;
}
if ( ! class_exists('ContentModelArticle'))
{
require_once JPATH_SITE .
'/components/com_content/models/article.php';
}
$model = JModel::getInstance('article',
'contentModel');
if ( ! method_exists($model, 'getItem'))
{
return null;
}
return $model->getItem($this->request->id);
}
}
assignments/redshop.php000064400000005046151161676250011273
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsRedShop extends RLAssignment
{
public function init()
{
$this->request->item_id =
JFactory::getApplication()->input->getInt('pid', 0);
$this->request->category_id =
JFactory::getApplication()->input->getInt('cid', 0);
$this->request->id = ($this->request->item_id) ?
$this->request->item_id : $this->request->category_id;
}
public function passPageTypes()
{
return $this->passByPageTypes('com_redshop',
$this->selection, $this->assignment, true);
}
public function passCategories()
{
if ($this->request->option != 'com_redshop')
{
return $this->pass(false);
}
$pass = (
($this->params->inc_categories
&& ($this->request->view == 'category')
)
|| ($this->params->inc_items && $this->request->view
== 'product')
);
if ( ! $pass)
{
return $this->pass(false);
}
$cats = [];
if ($this->request->category_id)
{
$cats = $this->request->category_id;
}
else if ($this->request->item_id)
{
$query = $this->db->getQuery(true)
->select('x.category_id')
->from('#__redshop_product_category_xref AS x')
->where('x.product_id = ' . (int)
$this->request->item_id);
$this->db->setQuery($query);
$cats = $this->db->loadColumn();
}
$cats = $this->makeArray($cats);
$pass = $this->passSimple($cats, 'include');
if ($pass && $this->params->inc_children == 2)
{
return $this->pass(false);
}
else if ( ! $pass && $this->params->inc_children)
{
foreach ($cats as $cat)
{
$cats = array_merge($cats, $this->getCatParentIds($cat));
}
}
return $this->passSimple($cats);
}
public function passProducts()
{
if ( ! $this->request->id || $this->request->option !=
'com_redshop' || $this->request->view !=
'product')
{
return $this->pass(false);
}
return $this->passSimple($this->request->id);
}
private function getCatParentIds($id = 0)
{
return $this->getParentIds($id, 'redshop_category_xref',
'category_parent_id', 'category_child_id');
}
}
assignments/tags.php000064400000005173151161676250010566 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsTags extends RLAssignment
{
public function passTags()
{
if (in_array($this->request->option, ['com_content',
'com_flexicontent']))
{
return $this->passTagsContent();
}
if ($this->request->option != 'com_tags'
|| $this->request->view != 'tag'
|| ! $this->request->id
)
{
return $this->pass(false);
}
return $this->passTag($this->request->id);
}
private function passTagsContent()
{
$is_item = in_array($this->request->view, ['',
'article', 'item']);
$is_category = in_array($this->request->view,
['category']);
switch (true)
{
case ($is_item):
$prefix = 'com_content.article';
break;
case ($is_category):
$prefix = 'com_content.category';
break;
default:
return $this->pass(false);
}
// Load the tags.
$query = $this->db->getQuery(true)
->select($this->db->quoteName('t.id'))
->select($this->db->quoteName('t.title'))
->from('#__tags AS t')
->join(
'INNER', '#__contentitem_tag_map AS m'
. ' ON m.tag_id = t.id'
. ' AND m.type_alias = ' . $this->db->quote($prefix)
. ' AND m.content_item_id IN ( ' . $this->request->id .
')'
);
$this->db->setQuery($query);
$tags = $this->db->loadObjectList();
if (empty($tags))
{
return $this->pass(false);
}
foreach ($tags as $tag)
{
if ( ! $this->passTag($tag->id) && !
$this->passTag($tag->title))
{
continue;
}
return $this->pass(true);
}
return $this->pass(false);
}
private function passTag($tag)
{
$pass = in_array($tag, $this->selection);
if ($pass)
{
// If passed, return false if assigned to only children
// Else return true
return ($this->params->inc_children != 2);
}
if ( ! $this->params->inc_children)
{
return false;
}
// Return true if a parent id is present in the selection
return array_intersect(
$this->getTagsParentIds($tag),
$this->selection
);
}
private function getTagsParentIds($id = 0)
{
$parentids = $this->getParentIds($id, 'tags');
// Remove the root tag
$parentids = array_diff($parentids, [1]);
return $parentids;
}
}
assignments/templates.php000064400000003773151161676250011632
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsTemplates extends RLAssignment
{
public function passTemplates()
{
$template = $this->getTemplate();
// Put template name and name + style id into array
// The '::' separator was used in pre Joomla 3.3
$template = [$template->template, $template->template .
'--' . $template->id, $template->template . '::'
. $template->id];
return $this->passSimple($template, true);
}
public function getTemplate()
{
$template = JFactory::getApplication()->getTemplate(true);
if (isset($template->id))
{
return $template;
}
$params = json_encode($template->params);
// Find template style id based on params, as the template style id is
not always stored in the getTemplate
$query = $this->db->getQuery(true)
->select('id')
->from('#__template_styles as s')
->where('s.client_id = 0')
->where('s.template = ' .
$this->db->quote($template->template))
->where('s.params = ' . $this->db->quote($params))
->setLimit(1);
$this->db->setQuery($query);
$template->id = $this->db->loadResult('id');
if ($template->id)
{
return $template;
}
// No template style id is found, so just grab the first result based on
the template name
$query->clear('where')
->where('s.client_id = 0')
->where('s.template = ' .
$this->db->quote($template->template))
->setLimit(1);
$this->db->setQuery($query);
$template->id = $this->db->loadResult('id');
return $template;
}
}
assignments/urls.php000064400000003401151161676250010605 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use Joomla\CMS\Uri\Uri as JUri;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
require_once dirname(__DIR__) . '/text.php';
class RLAssignmentsURLs extends RLAssignment
{
public function passURLs()
{
$regex = isset($this->params->regex) ? $this->params->regex :
0;
if ( ! is_array($this->selection))
{
$this->selection = explode("\n", $this->selection);
}
if (count($this->selection) == 1)
{
$this->selection = explode("\n", $this->selection[0]);
}
$url = JUri::getInstance();
$url = $url->toString();
$urls = [
RLText::html_entity_decoder(urldecode($url)),
urldecode($url),
RLText::html_entity_decoder($url),
$url,
];
$urls = array_unique($urls);
$pass = false;
foreach ($urls as $url)
{
foreach ($this->selection as $s)
{
$s = trim($s);
if ($s == '')
{
continue;
}
if ($regex)
{
$url_part = str_replace(['#', '&'],
['\#', '(&|&)'], $s);
$s = '#' . $url_part . '#si';
if (@preg_match($s . 'u', $url) || @preg_match($s, $url))
{
$pass = true;
break;
}
continue;
}
if (strpos($url, $s) !== false)
{
$pass = true;
break;
}
}
if ($pass)
{
break;
}
}
return $this->pass($pass);
}
}
assignments/users.php000064400000007123151161676250010766 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsUsers extends RLAssignment
{
public function passAccessLevels()
{
$user = JFactory::getUser();
$levels = $user->getAuthorisedViewLevels();
$this->selection =
$this->convertAccessLevelNamesToIds($this->selection);
return $this->passSimple($levels);
}
public function passUserGroupLevels()
{
$user = JFactory::getUser();
if ( ! empty($user->groups))
{
$groups = array_values($user->groups);
}
else
{
$groups = $user->getAuthorisedGroups();
}
if ($this->params->inc_children)
{
$this->setUserGroupChildrenIds();
}
$this->selection =
$this->convertUsergroupNamesToIds($this->selection);
return $this->passSimple($groups);
}
public function passUsers()
{
return $this->passSimple(JFactory::getUser()->get('id'));
}
private function convertAccessLevelNamesToIds($selection)
{
$names = [];
foreach ($selection as $i => $level)
{
if (is_numeric($level))
{
continue;
}
unset($selection[$i]);
$names[] = strtolower(str_replace(' ', '', $level));
}
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from('#__viewlevels')
->where('LOWER(REPLACE(' .
$db->quoteName('title') . ', " ",
"")) IN (\'' . implode('\',\'',
$names) . '\')');
$db->setQuery($query);
$level_ids = $db->loadColumn();
return array_unique(array_merge($selection, $level_ids));
}
private function convertUsergroupNamesToIds($selection)
{
$names = [];
foreach ($selection as $i => $group)
{
if (is_numeric($group))
{
continue;
}
unset($selection[$i]);
$names[] = strtolower(str_replace(' ', '', $group));
}
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from('#__usergroups')
->where('LOWER(REPLACE(' .
$db->quoteName('title') . ', " ",
"")) IN (\'' . implode('\',\'',
$names) . '\')');
$db->setQuery($query);
$group_ids = $db->loadColumn();
return array_unique(array_merge($selection, $group_ids));
}
private function setUserGroupChildrenIds()
{
$children = $this->getUserGroupChildrenIds($this->selection);
if ($this->params->inc_children == 2)
{
$this->selection = $children;
return;
}
$this->selection = array_merge($this->selection, $children);
}
private function getUserGroupChildrenIds($groups)
{
$children = [];
$db = JFactory::getDbo();
foreach ($groups as $group)
{
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__usergroups'))
->where($db->quoteName('parent_id') . ' = ' .
(int) $group);
$db->setQuery($query);
$group_children = $db->loadColumn();
if (empty($group_children))
{
continue;
}
$children = array_merge($children, $group_children);
$group_grand_children =
$this->getUserGroupChildrenIds($group_children);
if (empty($group_grand_children))
{
continue;
}
$children = array_merge($children, $group_grand_children);
}
$children = array_unique($children);
return $children;
}
}
assignments/virtuemart.php000064400000010021151161676250012016
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsVirtueMart extends RLAssignment
{
public function init()
{
$virtuemart_product_id =
JFactory::getApplication()->input->get('virtuemart_product_id',
[], 'array');
$virtuemart_category_id =
JFactory::getApplication()->input->get('virtuemart_category_id',
[], 'array');
$this->request->item_id = isset($virtuemart_product_id[0]) ?
$virtuemart_product_id[0] : null;
$this->request->category_id = isset($virtuemart_category_id[0]) ?
$virtuemart_category_id[0] : null;
$this->request->id = ($this->request->item_id) ?
$this->request->item_id : $this->request->category_id;
}
public function passPageTypes()
{
// Because VM sucks, we have to get the view again
$this->request->view =
JFactory::getApplication()->input->getString('view');
return $this->passByPageTypes('com_virtuemart',
$this->selection, $this->assignment, true);
}
public function passCategories()
{
if ($this->request->option != 'com_virtuemart')
{
return $this->pass(false);
}
// Because VM sucks, we have to get the view again
$this->request->view =
JFactory::getApplication()->input->getString('view');
$pass = (($this->params->inc_categories &&
in_array($this->request->view, ['categories',
'category']))
|| ($this->params->inc_items && $this->request->view
== 'productdetails')
);
if ( ! $pass)
{
return $this->pass(false);
}
$cats = [];
if ($this->request->view == 'productdetails' &&
$this->request->item_id)
{
$query = $this->db->getQuery(true)
->select('x.virtuemart_category_id')
->from('#__virtuemart_product_categories AS x')
->where('x.virtuemart_product_id = ' . (int)
$this->request->item_id);
$this->db->setQuery($query);
$cats = $this->db->loadColumn();
}
else if ($this->request->category_id)
{
$cats = $this->request->category_id;
if ( ! is_numeric($cats))
{
$query = $this->db->getQuery(true)
->select('config')
->from('#__virtuemart_configs')
->where('virtuemart_config_id = 1');
$this->db->setQuery($query);
$config = $this->db->loadResult();
$lang = substr($config, strpos($config, 'vmlang='));
$lang = substr($lang, 0, strpos($lang, '|'));
if (preg_match('#"([^"]*_[^"]*)"#',
$lang, $lang))
{
$lang = $lang[1];
}
else
{
$lang = 'en_gb';
}
$query = $this->db->getQuery(true)
->select('l.virtuemart_category_id')
->from('#__virtuemart_categories_' . $lang . ' AS
l')
->where('l.slug = ' . $this->db->quote($cats));
$this->db->setQuery($query);
$cats = $this->db->loadResult();
}
}
$cats = $this->makeArray($cats);
$pass = $this->passSimple($cats, 'include');
if ($pass && $this->params->inc_children == 2)
{
return $this->pass(false);
}
if ( ! $pass && $this->params->inc_children)
{
foreach ($cats as $cat)
{
$cats = array_merge($cats, $this->getCatParentIds($cat));
}
}
return $this->passSimple($cats);
}
public function passProducts()
{
// Because VM sucks, we have to get the view again
$this->request->view =
JFactory::getApplication()->input->getString('view');
if ( ! $this->request->id || $this->request->option !=
'com_virtuemart' || $this->request->view !=
'productdetails')
{
return $this->pass(false);
}
return $this->passSimple($this->request->id);
}
private function getCatParentIds($id = 0)
{
return $this->getParentIds($id,
'virtuemart_category_categories', 'category_parent_id',
'category_child_id');
}
}
assignments/zoo.php000064400000013015151161676250010431 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
require_once dirname(__DIR__) . '/assignment.php';
class RLAssignmentsZoo extends RLAssignment
{
public function init()
{
if ( ! $this->request->view)
{
$this->request->view = $this->request->task;
}
switch ($this->request->view)
{
case 'item':
$this->request->idname = 'item_id';
break;
case 'category':
$this->request->idname = 'category_id';
break;
}
$this->request->id =
JFactory::getApplication()->input->getInt($this->request->idname,
0);
}
public function initAssignment($assignment, $article = 0)
{
parent::initAssignment($assignment, $article);
if ($this->request->option != 'com_zoo' && !
isset($this->request->idname))
{
return;
}
switch ($this->request->idname)
{
case 'item_id':
$this->request->view = 'item';
break;
case 'category_id':
$this->request->view = 'category';
break;
}
}
public function passPageTypes()
{
return $this->passByPageTypes('com_zoo',
$this->selection, $this->assignment);
}
public function passCategories()
{
if ($this->request->option != 'com_zoo')
{
return $this->pass(false);
}
$pass = (
($this->params->inc_apps && $this->request->view ==
'frontpage')
|| ($this->params->inc_categories &&
$this->request->view == 'category')
|| ($this->params->inc_items && $this->request->view
== 'item')
);
if ( ! $pass)
{
return $this->pass(false);
}
$cats = $this->getCategories();
if ($cats === false)
{
return $this->pass(false);
}
$cats = $this->makeArray($cats);
$pass = $this->passSimple($cats, 'include');
if ($pass && $this->params->inc_children == 2)
{
return $this->pass(false);
}
if ( ! $pass && $this->params->inc_children)
{
foreach ($cats as $cat)
{
$cats = array_merge($cats, $this->getCatParentIds($cat));
}
}
return $this->passSimple($cats);
}
private function getCategories()
{
if ($this->article && isset($this->article->catid))
{
return [$this->article->catid];
}
$menuparams = $this->getMenuItemParams($this->request->Itemid);
switch ($this->request->view)
{
case 'frontpage':
if ($this->request->id)
{
return [$this->request->id];
}
if ( ! isset($menuparams->application))
{
return [];
}
return ['app' . $menuparams->application];
case 'category':
$cats = [];
if ($this->request->id)
{
$cats[] = $this->request->id;
}
else if (isset($menuparams->category))
{
$cats[] = $menuparams->category;
}
if (empty($cats[0]))
{
return [];
}
$query = $this->db->getQuery(true)
->select('c.application_id')
->from('#__zoo_category AS c')
->where('c.id = ' . (int) $cats[0]);
$this->db->setQuery($query);
$cats[] = 'app' . $this->db->loadResult();
return $cats;
case 'item':
$id = $this->request->id;
if ( ! $id && isset($menuparams->item_id))
{
$id = $menuparams->item_id;
}
if ( ! $id)
{
return [];
}
$query = $this->db->getQuery(true)
->select('c.category_id')
->from('#__zoo_category_item AS c')
->where('c.item_id = ' . (int) $id)
->where('c.category_id != 0');
$this->db->setQuery($query);
$cats = $this->db->loadColumn();
$query = $this->db->getQuery(true)
->select('i.application_id')
->from('#__zoo_item AS i')
->where('i.id = ' . (int) $id);
$this->db->setQuery($query);
$cats[] = 'app' . $this->db->loadResult();
return $cats;
default:
return false;
}
}
public function passItems()
{
if ( ! $this->request->id || $this->request->option !=
'com_zoo')
{
return $this->pass(false);
}
if ($this->request->view != 'item')
{
return $this->pass(false);
}
$pass = false;
// Pass Article Id
if ( ! $this->passItemByType($pass, 'ContentIds'))
{
return $this->pass(false);
}
// Pass Authors
if ( ! $this->passItemByType($pass, 'Authors'))
{
return $this->pass(false);
}
return $this->pass($pass);
}
public function getItem($fields = [])
{
$query = $this->db->getQuery(true)
->select($fields)
->from('#__zoo_item')
->where('id = ' . (int) $this->request->id);
$this->db->setQuery($query);
return $this->db->loadObject();
}
private function getCatParentIds($id = 0)
{
$parent_ids = [];
if ( ! $id)
{
return $parent_ids;
}
while ($id)
{
if (substr($id, 0, 3) == 'app')
{
$parent_ids[] = $id;
break;
}
$query = $this->db->getQuery(true)
->select('c.parent')
->from('#__zoo_category AS c')
->where('c.id = ' . (int) $id);
$this->db->setQuery($query);
$pid = $this->db->loadResult();
if ( ! $pid)
{
$query = $this->db->getQuery(true)
->select('c.application_id')
->from('#__zoo_category AS c')
->where('c.id = ' . (int) $id);
$this->db->setQuery($query);
$app = $this->db->loadResult();
if ($app)
{
$parent_ids[] = 'app' . $app;
}
break;
}
$parent_ids[] = $pid;
$id = $pid;
}
return $parent_ids;
}
}
assignments.php000064400000002132151161676250007620 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use RegularLabs\Library\Conditions as RL_Conditions;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
class RLAssignmentsHelper
{
function passAll($assignments, $matching_method = 'all', $item =
0)
{
return RL_Conditions::pass($assignments, $matching_method, $item);
}
public function getAssignmentsFromParams(&$params)
{
return RL_Conditions::getConditionsFromParams($params);
}
public function getAssignmentsFromTagAttributes(&$params, $types = [])
{
return RL_Conditions::getConditionsFromTagAttributes($params, $types);
}
public function hasAssignments(&$assignments)
{
return RL_Conditions::hasConditions($assignments);
}
}
cache.php000064400000002557151161676250006343 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_cache
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Cache component helper.
*
* @since 1.6
*/
class CacheHelper
{
/**
* Get a list of filter options for the application clients.
*
* @return array An array of JHtmlOption elements.
*
* @deprecated 4.0 No replacement.
*/
public static function getClientOptions()
{
// Build the filter options.
$options = array();
$options[] = JHtml::_('select.option', '0',
JText::_('JSITE'));
$options[] = JHtml::_('select.option', '1',
JText::_('JADMINISTRATOR'));
return $options;
}
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since 1.6
*/
public static function addSubmenu($vName)
{
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_SUBMENU_CHECKIN'),
'index.php?option=com_checkin',
$vName == 'com_checkin'
);
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_SUBMENU_CLEAR_CACHE'),
'index.php?option=com_cache',
$vName == 'cache'
);
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_SUBMENU_PURGE_EXPIRED_CACHE'),
'index.php?option=com_cache&view=purge',
$vName == 'purge'
);
}
}
field.php000064400000001070151161676250006350 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
class RLFormField
extends \RegularLabs\Library\Field
{
}
groupfield.php000064400000001102151161676250007421 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
class RLFormGroupField
extends \RegularLabs\Library\FieldGroup
{
}
helper.php000064400000270016151161676250006554 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
jimport('joomla.application.component.controller');
jimport('joomla.application.component.view');
jimport('joomla.filesystem.file');
$jversion = preg_replace('#[^0-9\.]#i','',JVERSION);
define('HIKASHOP_J16',version_compare($jversion,'1.6.0','>=')
? true : false);
define('HIKASHOP_J17',version_compare($jversion,'1.7.0','>=')
? true : false);
define('HIKASHOP_J25',version_compare($jversion,'2.5.0','>=')
? true : false);
define('HIKASHOP_J30',version_compare($jversion,'3.0.0','>=')
? true : false);
define('HIKASHOP_PHP5',version_compare(PHP_VERSION,'5.0.0',
'>=') ? true : false);
class hikashop{
function getDate($time = 0,$format = '%d %B %Y %H:%M'){ return
hikashop_getDate($time,$format); }
function isAllowed($allowedGroups,$id=null,$type='user'){ return
hikashop_isAllowed($allowedGroups,$id,$type); }
function addACLFilters(&$filters,$field,$table='',$level=2){
return hikashop_addACLFilters($filters,$field,$table,$level); }
function currentURL($checkInRequest=''){ return
hikashop_currentURL($checkInRequest); }
function getTime($date){ return hikashop_getTime($date); }
function getIP(){ return hikashop_getIP(); }
function encode(&$data,$type='order',$format='') {
return hikashop_encode($data,$type,$format); }
function base($id){ return hikashop_base($id); }
function decode($str,$type='order') { return
hikashop_decode($str,$type); }
function &array_path(&$array, $path) { return
hikashop_array_path($array, $path); }
function toFloat($val){ return hikashop_toFloat($val); }
function loadUser($full=false,$reset=false){ return
hikashop_loadUser($full,$reset); }
function getZone($type='shipping'){ return
hikashop_getZone($type); }
function getCurrency(){ return hikashop_getCurrency(); }
function cleanCart(){ return hikashop_cleanCart(); }
function import( $type, $name, $dispatcher = null ){ return
hikashop_import( $type, $name, $dispatcher); }
function createDir($dir,$report = true){ return
hikashop_createDir($dir,$report); }
function initModule(){ return hikashop_initModule(); }
function absoluteURL($text){ return hikashop_absoluteURL($text); }
function setTitle($name,$picture,$link){ return
hikashop_setTitle($name,$picture,$link); }
function getMenu($title="",$menu_style='content_top'){
return hikashop_getMenu($title,$menu_style); }
function getLayout($controller,$layout,$params,&$js){ return
hikashop_getLayout($controller,$layout,$params,$js); }
function setExplorer($task,$defaultId=0,$popup=false,$type=''){
return hikashop_setExplorer($task,$defaultId,$popup,$type); }
function frontendLink($link,$popup = false){ return
hikashop_frontendLink($link,$popup); }
function backendLink($link,$popup = false){ return
hikashop_backendLink($link,$popup); }
function bytes($val) { return hikashop_bytes($val); }
function display($messages,$type = 'success',$return = false){
return hikashop_display($messages,$type,$return); }
function completeLink($link,$popup = false,$redirect = false){ return
hikashop_completeLink($link,$popup,$redirect); }
function table($name,$component = true){ return
hikashop_table($name,$component); }
function secureField($fieldName){ return hikashop_secureField($fieldName);
}
function increasePerf(){ hikashop_increasePerf(); }
function &config($reload = false){ return hikashop_config($reload); }
function level($level){ return hikashop_level($level); }
function footer(){ return hikashop_footer(); }
function search($searchString,$object,$exclude=''){ return
hikashop_search($searchString,$object,$exclude); }
function get($path){ return hikashop_get($path); }
function getCID($field = '',$int=true){ return
hikashop_getCID($field,$int); }
function tooltip($desc,$title='',
$image='tooltip.png', $name = '',$href='',
$link=1){ return hikashop_tooltip($desc,$title, $image, $name,$href,
$link); }
function checkRobots(){ return hikashop_checkRobots(); }
}
function hikashop_getDate($time = 0,$format = '%d %B %Y %H:%M'){
if(empty($time))
return '';
if(is_numeric($format))
$format = JText::_('DATE_FORMAT_LC'.$format);
if(HIKASHOP_J16){
$format =
str_replace(array('%A','%d','%B','%m','%Y','%y','%H','%M','%S','%a'),array('l','d','F','m','Y','y','H','i','s','D'),$format);
return JHTML::_('date',$time,$format,false);
}
static $timeoffset = null;
if($timeoffset === null) {
$config = JFactory::getConfig();
$timeoffset = $config->getValue('config.offset');
}
return JHTML::_('date',$time-
date('Z'),$format,$timeoffset);
}
function
hikashop_isAllowed($allowedGroups,$id=null,$type='user'){
if($allowedGroups == 'all') return true;
if($allowedGroups == 'none') return false;
if(!is_array($allowedGroups)) $allowedGroups =
explode(',',$allowedGroups);
if(!HIKASHOP_J16){
if($type=='user'){
$my = JFactory::getUser($id);
if(empty($my->id)){
$group = 29;
}else{
$group = (int)@$my->gid;
}
}else{
$group = $id;
}
return in_array($group,$allowedGroups);
}
if($type=='user'){
jimport('joomla.access.access');
$my = JFactory::getUser($id);
$config =& hikashop_config();
$userGroups = JAccess::getGroupsByUser($my->id,
(bool)$config->get('inherit_parent_group_access'));
}else{
$userGroups = array($id);
}
$inter = array_intersect($userGroups,$allowedGroups);
if(empty($inter)) return false;
return true;
}
function hikashop_addACLFilters(&$filters, $field, $table='',
$level=2, $allowNull=false, $user_id=0){
if(hikashop_level($level)){
if(empty($user_id) || (int)$user_id == 0) {
$my = JFactory::getUser();
} else {
$userClass = hikashop_get('class.user');
$hkUser = $userClass->get($user_id);
$my = JFactory::getUser($hkUser->user_cms_id);
}
if(!HIKASHOP_J16){
if(empty($my->id)){
$userGroups = array(29);
}else{
$userGroups = array($my->gid);
}
}else{
jimport('joomla.access.access');
$config =& hikashop_config();
$userGroups = JAccess::getGroupsByUser($my->id,
(bool)$config->get('inherit_parent_group_access'));//$my->authorisedLevels();
}
if(!empty($userGroups)){
if(!empty($table)){
$table.='.';
}
$acl_filters = array($table.$field." = 'all'");
foreach($userGroups as $userGroup){
$acl_filters[]=$table.$field." LIKE
'%,".(int)$userGroup.",%'";
}
if($allowNull){
$acl_filters[]='ISNULL('.$table.$field.')';
}
$filters[]='('.implode(' OR
',$acl_filters).')';
}
}
}
function hikashop_currentURL($checkInRequest='',$safe=true){
if(!empty($checkInRequest)){
$url = JRequest::getVar($checkInRequest,'');
if(!empty($url)){
if(strpos($url,'http')!==0&&strpos($url,'/')!==0){
if($checkInRequest=='return_url'){
$url = base64_decode(urldecode($url));
}elseif($checkInRequest=='url'){
$url = urldecode($url);
}
}
if($safe){
$url =
str_replace(array('"',"'",'<','>',';'),array('%22','%27','%3C','%3E','%3B'),$url);
}
return $url;
}
}
if(!empty($_SERVER["REDIRECT_URL"]) &&
preg_match('#.*index\.php$#',$_SERVER["REDIRECT_URL"])
&&
empty($_SERVER['QUERY_STRING'])&&empty($_SERVER['REDIRECT_QUERY_STRING'])
&& !empty($_SERVER["REQUEST_URI"])){
$requestUri = $_SERVER["REQUEST_URI"];
}elseif(!empty($_SERVER["REDIRECT_URL"]) &&
(isset($_SERVER['QUERY_STRING'])||isset($_SERVER['REDIRECT_QUERY_STRING']))){
$requestUri = $_SERVER["REDIRECT_URL"];
if (!empty($_SERVER['REDIRECT_QUERY_STRING'])) $requestUri =
rtrim($requestUri,'/').'?'.$_SERVER['REDIRECT_QUERY_STRING'];
elseif (!empty($_SERVER['QUERY_STRING'])) $requestUri =
rtrim($requestUri,'/').'?'.$_SERVER['QUERY_STRING'];
}elseif(isset($_SERVER["REQUEST_URI"])){
$requestUri = $_SERVER["REQUEST_URI"];
}else{
$requestUri = $_SERVER['PHP_SELF'];
if (!empty($_SERVER['QUERY_STRING'])) $requestUri =
rtrim($requestUri,'/').'?'.$_SERVER['QUERY_STRING'];
}
$result = (hikashop_isSSL() ? 'https://' :
'http://').$_SERVER["HTTP_HOST"].$requestUri;
if($safe){
$result =
str_replace(array('"',"'",'<','>',';'),array('%22','%27','%3C','%3E','%3B'),$result);
}
return $result;
}
function hikashop_getTime($date){
static $timeoffset = null;
if($timeoffset === null){
$config = JFactory::getConfig();
if(!HIKASHOP_J30){
$timeoffset = $config->getValue('config.offset');
} else {
$timeoffset = $config->get('offset');
}
if(HIKASHOP_J16){
$dateC = JFactory::getDate($date,$timeoffset);
$timeoffset = $dateC->getOffsetFromGMT(true);
}
}
return strtotime($date) - $timeoffset *60*60 + date('Z');
}
function hikashop_getIP(){
$ip = '';
if( !empty($_SERVER['HTTP_X_FORWARDED_FOR']) &&
strlen($_SERVER['HTTP_X_FORWARDED_FOR']) > 6){
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}elseif( !empty($_SERVER['HTTP_CLIENT_IP']) &&
strlen($_SERVER['HTTP_CLIENT_IP']) > 6){
$ip = $_SERVER['HTTP_CLIENT_IP'];
}elseif(!empty($_SERVER['REMOTE_ADDR']) &&
strlen($_SERVER['REMOTE_ADDR']) > 6){
$ip = $_SERVER['REMOTE_ADDR'];
}
return strip_tags($ip);
}
function hikashop_isSSL(){
if((isset($_SERVER['HTTPS']) &&
!empty($_SERVER['HTTPS']) &&
(strtolower($_SERVER['HTTPS']) != 'off')) ||
$_SERVER['SERVER_PORT'] == 443 ||
(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) ==
'https') ) {
return true;
}else{
return false;
}
}
function hikashop_getUpgradeLink($tolevel){
$config =& hikashop_config();
$text = '';
if($tolevel=='essential'){
$text = 'ONLY_COMMERCIAL';
}elseif($tolevel=='business'){
$text = 'ONLY_FROM_BUSINESS';
}
return ' <a class="hikaupgradelink"
href="'.HIKASHOP_REDIRECT.'upgrade-hikashop-'.strtolower($config->get('level')).'-to-'.$tolevel.'"
target="_blank">'.JText::_($text).'</a>';
}
function hikashop_encode(&$data,$type='order', $format =
'') {
$id = null;
if(is_object($data)){
if($type=='order')
$id = $data->order_id;
if($type=='invoice')
$id = $data->order_invoice_id;
}else{
$id = $data;
}
if(is_object($data) && ($type=='order' ||
$type=='invoice') && hikashop_level(1)){
JPluginHelper::importPlugin( 'hikashop' );
$dispatcher = JDispatcher::getInstance();
$result='';
$trigger_name =
'onBefore'.ucfirst($type).'NumberGenerate';
$dispatcher->trigger($trigger_name, array( &$data, &$result)
);
if(!empty($result)){
return $result;
}
$config =& hikashop_config();
if(empty($format)) {
$format =
$config->get($type.'_number_format','{automatic_code}');
}
if(preg_match('#\{id
*(?:size=(?:"|\')(.*)(?:"|\'))?
*\}#Ui',$format,$matches)){
$copy = $id;
if(!empty($matches[1])){
$copy = sprintf('%0'.$matches[1].'d', $copy);
}
$format = str_replace($matches[0],$copy,$format);
}
$matches=null;
if(preg_match('#\{date
*format=(?:"|\')(.*)(?:"|\')
*\}#Ui',$format,$matches)){
$format =
str_replace($matches[0],date($matches[1],$data->order_modified),$format);
}
if(strpos($format,'{automatic_code}')!==false){
$format =
str_replace('{automatic_code}',hikashop_base($id),$format);
}
if(preg_match_all('#\{user
([a-z_0-9]+)\}#i',$format,$matches)){
if(empty($data->customer)){
$class = hikashop_get('class.user');
$data->customer = $class->get($data->order_customer_id);
}
foreach($matches[1] as $match){
if(isset($data->customer->$match)){
$format = str_replace('{user
'.$match.'}',$data->customer->$match,$format);
}else{
$format = str_replace('{user
'.$match.'}','',$format);
}
}
}
if(preg_match_all('#\{([a-z_0-9]+)\}#i',$format,$matches)){
foreach($matches[1] as $match){
if(isset($data->$match)){
$format =
str_replace('{'.$match.'}',$data->$match,$format);
}else{
$format =
str_replace('{'.$match.'}','',$format);
}
}
}
return $format;
}
return hikashop_base($id);
}
function hikashop_base($id){
$base=23;
$chars='ABCDEFGHJKLMNPQRSTUWXYZ';
$str = '';
$val2=(string)$id;
do {
$i = $id % $base;
$str = $chars[$i].$str;
$id = ($id - $i) / $base;
} while($id > 0);
$str2='';
$size = strlen($val2);
for($i=0;$i<$size;$i++){
if(isset($str[$i]))$str2.=$str[$i];
$str2.=$val2[$i];
}
if($i<strlen($str)){
$str2.=substr($str,$i);
}
return $str2;
}
function hikashop_decode($str,$type='order') {
$config =& hikashop_config();
if($type=='order' && hikashop_level(1)){
JPluginHelper::importPlugin( 'hikashop' );
$dispatcher = JDispatcher::getInstance();
$result='';
$dispatcher->trigger( 'onBeforeOrderNumberRevert', array(
& $str) );
if(!empty($result)){
return $result;
}
$format =
$config->get('order_number_format','{automatic_code}');
$format =
str_replace(array('^','$','.','[',']','|','(',')','?','*','+'),array('\^','\$','\.','\[','\]','\|','\(','\)','\?','\*','\+'),$format);
if(preg_match('#\{date
*format=(?:"|\')(.*)(?:"|\')
*\}#Ui',$format,$matches)){
$format =
str_replace($matches[0],'(?:'.preg_replace('#[a-z]+#i','[0-9a-z]+',$matches[1]).')',$format);
}
if(preg_match('#\{id
*(?:size=(?:"|\')(.*)(?:"|\'))?
*\}#Ui',$format,$matches)){
$format = str_replace($matches[0],'([0-9]+)',$format);
}
if(strpos($format,'{automatic_code}')!==false){
$format =
str_replace('{automatic_code}','([0-9a-z]+)',$format);
}
if(preg_match_all('#\{([a-z_0-9]+)\}#i',$format,$matches)){
foreach($matches[1] as $match){
if(isset($data->$match)){
$format =
str_replace('{'.$match.'}','.*',$format);
}else{
$format =
str_replace('{'.$match.'}','',$format);
}
}
}
$format =
str_replace(array('{','}'),array('\{','\}'),$format);
if(preg_match('#'.$format.'#i',$str,$matches)){
foreach($matches as $i => $match){
if($i){
return
ltrim(preg_replace('#[^0-9]#','',$match),'0');
}
}
}
}
return preg_replace('#[^0-9]#','',$str);
}
function &hikashop_array_path(&$array, $path) {
settype($path, 'array');
$offset =& $array;
foreach ($path as $index) {
if (!isset($offset[$index])) {
return false;
}
$offset =& $offset[$index];
}
return $offset;
}
function hikashop_toFloat($val){
if(preg_match_all('#-?[0-9]+#',$val,$parts) &&
count($parts[0])>1){
$dec=array_pop($parts[0]);
return (float) implode('',$parts[0]).'.'.$dec;
}
return (float) $val;
}
function hikashop_loadUser($full=false,$reset=false){
static $user = null;
if($reset){
$user = null;
return true;
}
if(!isset($user) || $user === null){
$app = JFactory::getApplication();
$user_id = (int)$app->getUserState(
HIKASHOP_COMPONENT.'.user_id' );
$class = hikashop_get('class.user');
if(empty($user_id)){
$userCMS = JFactory::getUser();
if(!$userCMS->guest){
$user_id = $class->getID($userCMS->get('id'));
}else{
return $user;
}
}
$user = $class->get($user_id);
}
if($full){
return $user;
}else{
return $user->user_id;
}
}
function hikashop_getZone($type = 'shipping'){
$app = JFactory::getApplication();
$shipping_address = $app->getUserState(
HIKASHOP_COMPONENT.'.'.$type.'_address',0);
$zone_id =0;
if(empty($shipping_address) && $type == 'shipping'){
$shipping_address = $app->getUserState(
HIKASHOP_COMPONENT.'.'.'billing_address',0);
}
if(!empty($shipping_address)){
$useMainZone=false;
$id = $app->getUserState(
HIKASHOP_COMPONENT.'.shipping_id','');
if($id){
if(is_array($id))
$id = reset($id);
$class = hikashop_get('class.shipping');
$shipping = $class->get($id);
if(!empty($shipping->shipping_params)) $params =
unserialize($shipping->shipping_params);
$override = 0;
if(isset($params->shipping_override_address)) {
$override = (int)$params->shipping_override_address;
}
if($override && $type == 'shipping'){
$config =& hikashop_config();
$zone_id =
explode(',',$config->get('main_tax_zone',$zone_id));
if(count($zone_id)){
$zone_id = array_shift($zone_id);
}else{
$zone_id=0;
}
return $zone_id;
}
}
$addressClass = hikashop_get('class.address');
$address = $addressClass->get($shipping_address);
if(!empty($address)){
$field = 'address_country';
if(!empty($address->address_state)){
$field = 'address_state';
}
static $zones = array();
if(empty($zones[$address->$field])){
$zoneClass = hikashop_get('class.zone');
$zones[$address->$field] = $zoneClass->get($address->$field);
}
if(!empty($zones[$address->$field])){
$zone_id = $zones[$address->$field]->zone_id;
}
}
}
if(empty($zone_id)){
$zone_id =$app->getUserState( HIKASHOP_COMPONENT.'.zone_id',
0 );
if(empty($zone_id)){
$config =& hikashop_config();
$zone_id =
explode(',',$config->get('main_tax_zone',$zone_id));
if(count($zone_id)){
$zone_id = array_shift($zone_id);
}else{
$zone_id=0;
}
$app->setUserState( HIKASHOP_COMPONENT.'.zone_id', $zone_id
);
}
}
return (int)$zone_id;
}
function hikashop_getCurrency(){
$config =& hikashop_config();
$main_currency = (int)$config->get('main_currency',1);
$app = JFactory::getApplication();
$currency_id = (int)$app->getUserState(
HIKASHOP_COMPONENT.'.currency_id', $main_currency );
if($currency_id!=$main_currency && !$app->isAdmin()){
static $checked = array();
if(!isset($checked[$currency_id])){
$checked[$currency_id]=true;
$db = JFactory::getDBO();
$db->setQuery('SELECT currency_id FROM
'.hikashop_table('currency').' WHERE currency_id =
'.$currency_id. ' AND ( currency_published=1 OR
currency_displayed=1 )');
$currency_id = $db->loadResult();
}
}
if(empty($currency_id)){
$app->setUserState( HIKASHOP_COMPONENT.'.currency_id',
$main_currency );
$currency_id=$main_currency;
}
return $currency_id;
}
function hikashop_cleanCart(){
$config =& hikashop_config();
$period = $config->get('cart_retaining_period');
$check =
$config->get('cart_retaining_period_check_frequency',86400);
$checked = $config->get('cart_retaining_period_checked',0);
$max = time()-$check;
if(!$checked || $checked<$max){
$query = 'SELECT cart_id FROM
'.hikashop_table('cart').' WHERE cart_modified <
'.(time()-$period);
$database = JFactory::getDBO();
$database->setQuery($query);
if(!HIKASHOP_J25){
$ids = $database->loadResultArray();
} else {
$ids = $database->loadColumn();
}
if(!empty($ids)){
$query = 'DELETE FROM
'.hikashop_table('cart_product').' WHERE cart_id IN
('.implode(',',$ids).')';
$database->setQuery($query);
$database->query();
$query = 'DELETE FROM
'.hikashop_table('cart').' WHERE cart_id IN
('.implode(',',$ids).')';
$database->setQuery($query);
$database->query();
}
$options = array('cart_retaining_period_checked'=>time());
$config->save($options);
}
}
function hikashop_import( $type, $name, $dispatcher = null ){
$type = preg_replace('#[^A-Z0-9_\.-]#i', '', $type);
$name = preg_replace('#[^A-Z0-9_\.-]#i', '', $name);
if(!HIKASHOP_J16){
$path = JPATH_PLUGINS.DS.$type.DS.$name.'.php';
}else{
$path = JPATH_PLUGINS.DS.$type.DS.$name.DS.$name.'.php';
}
$instance=false;
if (file_exists( $path )){
require_once( $path );
if($type=='editors-xtd') $typeName = 'Button';
else $typeName = $type;
$className = 'plg'.$typeName.$name;
if(class_exists($className)){
if($dispatcher==null){
$dispatcher = JDispatcher::getInstance();
}
$instance = new $className($dispatcher,
array('name'=>$name,'type'=>$type));
}
}
return $instance;
}
function hikashop_createDir($dir,$report = true){
if(is_dir($dir)) return true;
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$indexhtml = '<html><body
bgcolor="#FFFFFF"></body></html>';
if(!JFolder::create($dir)){
if($report) hikashop_display('Could not create the directly
'.$dir,'error');
return false;
}
if(!JFile::write($dir.DS.'index.html',$indexhtml)){
if($report) hikashop_display('Could not create the file
'.$dir.DS.'index.html','error');
}
return true;
}
function hikashop_initModule(){
static $done = false;
if(!$done){
$fe = JRequest::getVar('hikashop_front_end_main',0);
if(empty($fe)){
$done = true;
if(!HIKASHOP_PHP5) {
$lang =& JFactory::getLanguage();
} else {
$lang = JFactory::getLanguage();
}
$override_path =
JLanguage::getLanguagePath(JPATH_ROOT).DS.'overrides'.$lang->getTag().'.override.ini';
if(version_compare(JVERSION,'1.6','>=')&&
file_exists($override_path)){
$lang->override = $lang->parse($override_path);
}
$lang->load(HIKASHOP_COMPONENT,JPATH_SITE);
if(version_compare(JVERSION,'1.6','<') &&
file_exists($override_path)){
$lang->_load($override_path,'override');
}
}
}
return true;
}
// //-->";
function hikashop_absoluteURL($text){
static $mainurl = '';
if(empty($mainurl)){
$urls = parse_url(HIKASHOP_LIVE);
if(!empty($urls['path'])){
$mainurl =
substr(HIKASHOP_LIVE,0,strrpos(HIKASHOP_LIVE,$urls['path'])).'/';
}else{
$mainurl = HIKASHOP_LIVE;
}
}
$text =
str_replace(array('href="../undefined/','href="../../undefined/','href="../../../undefined//','href="undefined/'),array('href="'.$mainurl,'href="'.$mainurl,'href="'.$mainurl,'href="'.HIKASHOP_LIVE),$text);
$text =
preg_replace('#href="(/?administrator)?/({|%7B)#Uis','href="$2',$text);
$replace = array();
$replaceBy = array();
if($mainurl !== HIKASHOP_LIVE){
$replace[] = '#(href|src|action|background)[ ]*=[
]*\"(?!(\{|%7B|\#|[a-z]{3,7}:|/))(?:\.\./)#i';
$replaceBy[] =
'$1="'.substr(HIKASHOP_LIVE,0,strrpos(rtrim(HIKASHOP_LIVE,'/'),'/')+1);
}
$replace[] = '#(href|src|action|background)[ ]*=[
]*\"(?!(\{|%7B|\#|[a-z]{3,7}:|/))(?:\.\./|\./)?#i';
$replaceBy[] = '$1="'.HIKASHOP_LIVE;
$replace[] = '#(href|src|action|background)[ ]*=[
]*\"(?!(\{|%7B|\#|[a-z]{3,7}:))/#i';
$replaceBy[] = '$1="'.$mainurl;
$replace[] = '#((background-image|background)[ ]*:[
]*url\(\'?"?(?!([a-z]{3,7}:|/|\'|"))(?:\.\./|\./)?)#i';
$replaceBy[] = '$1'.HIKASHOP_LIVE;
return preg_replace($replace,$replaceBy,$text);
}
function hikashop_disallowUrlRedirect($url){
$url =
str_replace(array('http://www.','https://www.','https://'),
array('http://','http://','http://'),$url);
$live =
str_replace(array('http://www.','https://www.','https://'),
array('http://','http://','http://'),HIKASHOP_LIVE);
if(strpos($url,$live)!==0 &&
preg_match('#^http://.*#',$url)) return true;
return false;
}
function hikashop_setTitle($name,$picture,$link){
$config =& hikashop_config();
$menu_style =
$config->get('menu_style','title_bottom');
$html = '<a href="'.
hikashop_completeLink($link).'">'.$name.'</a>';
if($menu_style!='content_top'){
$html = hikashop_getMenu($html,$menu_style);
}
JToolBarHelper::title( $html , $picture.'.png' );
if(HIKASHOP_J25) {
$doc = JFactory::getDocument();
$app = JFactory::getApplication();
$doc->setTitle($app->getCfg('sitename'). ' - '
.JText::_('JADMINISTRATION').' - '.$name);
}
}
function
hikashop_getMenu($title="",$menu_style='content_top'){
$document = JFactory::getDocument();
$controller = new
hikashopBridgeController(array('name'=>'menu'));
$viewType = $document->getType();
if(!HIKASHOP_PHP5) {
$view = & $controller->getView( '', $viewType,
'');
} else {
$view = $controller->getView( '', $viewType, '');
}
$view->setLayout('default');
ob_start();
$view->display(null,$title,$menu_style);
return ob_get_clean();
}
function hikashop_getLayout($controller,$layout,$params,&$js){
$base_path=HIKASHOP_FRONT;
$app = JFactory::getApplication();
if($app->isAdmin()){
$base_path=HIKASHOP_BACK;
}
$base_path=rtrim($base_path,DS);
$document = JFactory::getDocument();
$controller = new
hikashopBridgeController(array('name'=>$controller,'base_path'=>$base_path));
$viewType = $document->getType();
if(!HIKASHOP_PHP5) {
$view = & $controller->getView( '', $viewType,
'',array('base_path'=>$base_path));
} else {
$view = $controller->getView( '', $viewType,
'',array('base_path'=>$base_path));
}
$folder =
JPATH_BASE.DS.'templates'.DS.$app->getTemplate().DS.'html'.DS.HIKASHOP_COMPONENT.DS.$view->getName();
$view->addTemplatePath($folder);
$view->setLayout($layout);
ob_start();
$view->display(null,$params);
$js = @$view->js;
return ob_get_clean();
}
function
hikashop_setExplorer($task,$defaultId=0,$popup=false,$type=''){
$document = JFactory::getDocument();
$controller = new
hikashopBridgeController(array('name'=>'explorer'));
$viewType = $document->getType();
if(!HIKASHOP_PHP5) {
$view =& $controller->getView('', $viewType,
'');
} else {
$view = $controller->getView('', $viewType, '');
}
$view->setLayout('default');
ob_start();
$view->display(null,$task,$defaultId,$popup,$type);
return ob_get_clean();
}
function hikashop_frontendLink($link,$popup = false){
if($popup) $link .= '&tmpl=component';
$config = hikashop_config();
$app = JFactory::getApplication();
if(!$app->isAdmin() &&
$config->get('use_sef',0)){
$link = ltrim(JRoute::_($link,false),'/');
}
static $mainurl = '';
static $otherarguments = false;
if(empty($mainurl)){
$urls = parse_url(HIKASHOP_LIVE);
if(isset($urls['path']) AND
strlen($urls['path'])>0){
$mainurl =
substr(HIKASHOP_LIVE,0,strrpos(HIKASHOP_LIVE,$urls['path'])).'/';
$otherarguments =
trim(str_replace($mainurl,'',HIKASHOP_LIVE),'/');
if(strlen($otherarguments) > 0) $otherarguments .= '/';
}else{
$mainurl = HIKASHOP_LIVE;
}
}
if($otherarguments && strpos($link,$otherarguments) === false){
$link = $otherarguments.$link;
}
return $mainurl.$link;
}
function hikashop_backendLink($link,$popup = false){
static $mainurl = '';
static $otherarguments = false;
if(empty($mainurl)){
$urls = parse_url(HIKASHOP_LIVE);
if(!empty($urls['path'])){
$mainurl =
substr(HIKASHOP_LIVE,0,strrpos(HIKASHOP_LIVE,$urls['path'])).'/';
$otherarguments =
trim(str_replace($mainurl,'',HIKASHOP_LIVE),'/');
if(!empty($otherarguments)) $otherarguments .= '/';
}else{
$mainurl = HIKASHOP_LIVE;
}
}
if($otherarguments && strpos($link,$otherarguments) === false){
$link = $otherarguments.$link;
}
return $mainurl.$link;
}
function hikashop_bytes($val) {
$val = trim($val);
if(empty($val)){
return 0;
}
$last = strtolower($val[strlen($val)-1]);
switch($last) {
case 'g':
$val *= 1024;
case 'm':
$val *= 1024;
case 'k':
$val *= 1024;
}
return (int)$val;
}
function hikashop_display($messages, $type = 'success', $return =
false, $close = true){
if(empty($messages))
return;
if(!is_array($messages))
$messages = array($messages);
$app = JFactory::getApplication();
if(($app->isAdmin() && !HIKASHOP_BACK_RESPONSIVE) ||
(!$app->isAdmin() && !HIKASHOP_RESPONSIVE)) {
$html = '<div
id="hikashop_messages_'.$type.'"
class="hikashop_messages
hikashop_'.$type.'"><ul><li>'.implode('</li><li>',$messages).'</li></ul></div>';
} else {
$html = '<div class="alert alert-'.$type.'
alert-block">'.($close?'<button
type="button" class="close"
data-dismiss="alert">Ă</button>':'').'<p>'.implode('</p><p>',$messages).'</p></div>';
}
if($return){
return $html;
}
echo $html;
}
function hikashop_completeLink($link,$popup = false,$redirect = false, $js
= false){
if($popup) $link .= '&tmpl=component';
$ret =
JRoute::_('index.php?option='.HIKASHOP_COMPONENT.'&ctrl='.$link,!$redirect);
if($js) return str_replace('&', '&',
$ret);
return $ret;
}
function hikashop_table($name,$component = true){
$prefix = $component ? HIKASHOP_DBPREFIX : '#__';
return $prefix.$name;
}
function hikashop_secureField($fieldName){
if (!is_string($fieldName) ||
preg_match('|[^a-z0-9#_.-]|i',$fieldName) !== 0 ){
die('field "'.$fieldName .'" not
secured');
}
return $fieldName;
}
function hikashop_increasePerf(){
@ini_set('max_execution_time',0);
if(hikashop_bytes(@ini_get('memory_limit')) < 60000000){
$config = hikashop_config();
if($config->get('hikaincreasemem','1')){
if(!empty($_SESSION['hikaincreasemem'])){
$newConfig = new stdClass();
$newConfig->hikaincreasemem = 0;
$config->save($newConfig);
unset($_SESSION['hikaincreasemem']);
return;
}
if(isset($_SESSION)) $_SESSION['hikaincreasemem'] = 1;
@ini_set('memory_limit','64M');
if(isset($_SESSION['hikaincreasemem']))
unset($_SESSION['hikaincreasemem']);
}
}
}
function &hikashop_config($reload = false){
static $configClass = null;
if($configClass === null || $reload || !is_object($configClass) ||
$configClass->get('configClassInit',0) == 0){
$configClass = hikashop_get('class.config');
$configClass->load();
$configClass->set('configClassInit',1);
}
return $configClass;
}
function hikashop_level($level){
$config =& hikashop_config();
if($config->get($config->get('level'),0) >= $level)
return true;
return false;
}
function hikashop_footer(){
$config =& hikashop_config();
if($config->get('show_footer',true)=='-1') return
'';
$description =
$config->get('description_'.strtolower($config->get('level')),'Joomla!<sup
style="font-size:6px">TM</sup> Ecommerce System');
$link = 'http://www.hikashop.com';
$aff = $config->get('partner_id');
if(!empty($aff)){
$link.='?partner_id='.$aff;
}
$text = '<!-- HikaShop Component powered by '.$link.'
-->
<!-- version '.$config->get('level').' :
'.$config->get('version').' [1312231536]
-->';
if(!$config->get('show_footer',true)) return $text;
$text .= '<div class="hikashop_footer"
style="text-align:center" align="center"><a
href="'.$link.'" target="_blank"
title="'.HIKASHOP_NAME.' :
'.strip_tags($description).'">'.HIKASHOP_NAME.'
';
$app= JFactory::getApplication();
if($app->isAdmin()){
$text .= $config->get('level').'
'.$config->get('version');
}
$text .= ', '.$description.'</a></div>';
return $text;
}
function hikashop_search($searchString,$object,$exclude=''){
if(empty($object) || is_numeric($object))
return $object;
if(is_string($object)){
return
preg_replace('#('.str_replace('#','\#',$searchString).')#i','<span
class="searchtext">$1</span>',$object);
}
if(is_array($object)){
foreach($object as $key => $element){
$object[$key] = hikashop_search($searchString,$element,$exclude);
}
}elseif(is_object($object)){
foreach($object as $key => $element){
if((is_string($exclude) && $key != $exclude) ||
(is_array($exclude) && !in_array($key, $exclude)))
$object->$key = hikashop_search($searchString,$element,$exclude);
}
}
return $object;
}
function hikashop_get($path){
list($group,$class) = explode('.',$path);
if($group=='controller'){
$className = $class.ucfirst($group);;
}else{
$className = 'hikashop'.ucfirst($class).ucfirst($group);
}
if(class_exists($className.'Override'))
$className .= 'Override';
if(!class_exists($className)) {
$app = JFactory::getApplication();
$path =
JPATH_THEMES.DS.$app->getTemplate().DS.'html'.DS.'com_hikashop'.DS.'administrator'.DS;
$override = str_replace(HIKASHOP_BACK, $path,
constant(strtoupper('HIKASHOP_'.$group))).$class.'.override.php';
if(JFile::exists($override)) {
$originalFile =
constant(strtoupper('HIKASHOP_'.$group)).$class.'.php';
include_once($override);
$className .= 'Override';
} else {
include_once(constant(strtoupper('HIKASHOP_'.$group)).$class.'.php');
}
}
if(!class_exists($className)) return null;
$args = func_get_args();
array_shift($args);
switch(count($args)){
case 3:
return new $className($args[0],$args[1],$args[2]);
case 2:
return new $className($args[0],$args[1]);
case 1:
return new $className($args[0]);
case 0:
default:
return new $className();
}
}
function hikashop_getCID($field = '',$int=true){
$oneResult = JRequest::getVar( 'cid', array(), '',
'array' );
if(is_array($oneResult)) $oneResult = reset($oneResult);
if(empty($oneResult) && !empty($field))
$oneResult=JRequest::getCmd( $field,0);
if($int) return intval($oneResult);
return $oneResult;
}
function hikashop_tooltip($desc, $title = '', $image =
'tooltip.png', $name = '',$href = '', $link =
1) {
return JHTML::_('tooltip', str_replace(array("'",
"::"), array("'", ":"), $desc),
str_replace(array("'", '::'),
array("'", ':'), $title), $image,
str_replace(array("'", '"', '::'),
array("'", """, ':'),
$name), $href, $link);
}
function hikashop_checkRobots(){
if(preg_match('#(libwww-perl|python)#i',@$_SERVER['HTTP_USER_AGENT']))
die('Not allowed for robots. Please contact us if you are not a
robot');
}
function hikashop_loadJslib($name){
static $loadLibs = array();
$doc = JFactory::getDocument();
$name = strtolower($name);
$ret = false;
if(isset($loadLibs[$name]))
return $loadLibs[$name];
switch($name) {
case 'mootools':
if(!HIKASHOP_J30)
JHTML::_('behavior.mootools');
else
JHTML::_('behavior.framework');
break;
case 'jquery':
$doc->addScript(HIKASHOP_JS.'jquery.min.js');
$doc->addScript(HIKASHOP_JS.'jquery-ui.min.js');
$ret = true;
break;
case 'otree':
$doc->addScript(HIKASHOP_JS.'otree.js');
$doc->addStyleSheet(HIKASHOP_CSS.'otree.css');
$ret = true;
break;
case 'opload':
$doc->addScript(HIKASHOP_JS.'opload.js');
$doc->addStyleSheet(HIKASHOP_CSS.'opload.css');
$ret = true;
break;
}
$loadLibs[$name] = $ret;
return $ret;
}
function hikashop_cleanURL($url, $forceInternURL=false){
$parsedURL = parse_url($url);
$parsedCurrent = parse_url(JURI::base());
if($forceInternURL==false){
if(isset($parsedURL['scheme'])){
return $url;
}
}
if(preg_match('#https?://#',$url)){
return $url;
}
if(preg_match('#www.#',$url)){
return $parsedCurrent['scheme'].'://'.$url;
}
if($parsedURL['path'][0]!='/'){
$parsedURL['path']='/'.$parsedURL['path'];
}
if(!isset($parsedURL['query']))
$endUrl = $parsedURL['path'];
else
$endUrl =
$parsedURL['path'].'?'.$parsedURL['query'];
$cleanUrl =
$parsedCurrent['scheme'].'://'.$parsedCurrent['host'].$endUrl;
return $cleanUrl;
}
function hikashop_orderStatus($order_status) {
$order_upper = JString::strtoupper($order_status);
$tmp = 'ORDER_STATUS_' . $order_upper;
$ret = JText::_($tmp);
if($ret != $tmp)
return $ret;
$ret = JText::_($order_upper);
if($ret != $order_upper)
return $ret;
return $order_status;
}
function hikashop_getEscaped($text, $extra = false) {
$db = JFactory::getDBO();
if(HIKASHOP_J30){
return $db->escape($text, $extra);
}else{
return $db->getEscaped($text, $extra);
}
}
if(!HIKASHOP_J30){
function hikashop_getFormToken() {
return JUtility::getToken();
}
} else {
function hikashop_getFormToken() {
return JSession::getFormToken();
}
}
if(!class_exists('hikashopBridgeController')){
if(!HIKASHOP_J30){
class hikashopBridgeController extends JController {}
} else {
class hikashopBridgeController extends JControllerLegacy {}
}
}
class hikashopController extends hikashopBridgeController {
var $pkey = array();
var $table = array();
var $groupMap = '';
var $groupVal = null;
var $orderingMap ='';
var $display =
array('listing','show','cancel','');
var $modify_views =
array('edit','selectlisting','childlisting','newchild');
var $add = array('add');
var $modify =
array('apply','save','save2new','store','orderdown','orderup','saveorder','savechild','addchild','toggle');
var $delete = array('delete','remove');
var $publish_return_view='listing';
function __construct($config = array(),$skip=false){
if(!$skip){
parent::__construct($config);
$this->registerDefaultTask('listing');
}
}
function listing(){
JRequest::setVar( 'layout', 'listing' );
return $this->display();
}
function show(){
JRequest::setVar( 'layout', 'show' );
return $this->display();
}
function edit(){
JRequest::setVar('hidemainmenu',1);
JRequest::setVar( 'layout', 'form' );
return $this->display();
}
function add(){
JRequest::setVar('hidemainmenu',1);
JRequest::setVar( 'layout', 'form' );
return $this->display();
}
function apply(){
$status = $this->store();
return $this->edit();
}
function save(){
$this->store();
return $this->listing();
}
function save2new(){
$this->store(true);
return $this->edit();
}
function orderdown(){
if(!empty($this->table)&&!empty($this->pkey)&&(empty($this->groupMap)||isset($this->groupVal))&&!empty($this->orderingMap)){
$orderClass = hikashop_get('helper.order');
$orderClass->pkey = $this->pkey;
$orderClass->table = $this->table;
$orderClass->groupMap = $this->groupMap;
$orderClass->groupVal = $this->groupVal;
$orderClass->orderingMap = $this->orderingMap;
if(!empty($this->main_pkey)){
$orderClass->main_pkey = $this->main_pkey;
}
$orderClass->order(true);
}
return $this->listing();
}
function orderup(){
if(!empty($this->table)&&!empty($this->pkey)&&(empty($this->groupMap)||isset($this->groupVal))&&!empty($this->orderingMap)){
$orderClass = hikashop_get('helper.order');
$orderClass->pkey = $this->pkey;
$orderClass->table = $this->table;
$orderClass->groupMap = $this->groupMap;
$orderClass->groupVal = $this->groupVal;
$orderClass->orderingMap = $this->orderingMap;
if(!empty($this->main_pkey)){
$orderClass->main_pkey = $this->main_pkey;
}
$orderClass->order(false);
}
return $this->listing();
}
function saveorder(){
if(!empty($this->table)&&!empty($this->pkey)&&(empty($this->groupMap)||isset($this->groupVal))&&!empty($this->orderingMap)){
$orderClass = hikashop_get('helper.order');
$orderClass->pkey = $this->pkey;
$orderClass->table = $this->table;
$orderClass->groupMap = $this->groupMap;
$orderClass->groupVal = $this->groupVal;
$orderClass->orderingMap = $this->orderingMap;
if(!empty($this->main_pkey)){
$orderClass->main_pkey = $this->main_pkey;
}
$orderClass->save();
}
return $this->listing();
}
function store($new=false){
if(!HIKASHOP_PHP5) {
$app =& JFactory::getApplication();
} else {
$app = JFactory::getApplication();
}
$class = hikashop_get('class.'.$this->type);
$status = $class->saveForm();
if($status) {
if(!HIKASHOP_J30)
$app->enqueueMessage(JText::_( 'HIKASHOP_SUCC_SAVED' ),
'success');
else
$app->enqueueMessage(JText::_( 'HIKASHOP_SUCC_SAVED' ));
if(!$new) JRequest::setVar( 'cid', $status );
else JRequest::setVar( 'cid', 0 );
JRequest::setVar( 'fail', null );
} else {
$app->enqueueMessage(JText::_( 'ERROR_SAVING' ),
'error');
if(!empty($class->errors)){
foreach($class->errors as $oneError){
$app->enqueueMessage($oneError, 'error');
}
}
}
return $status;
}
function remove(){
$cids = JRequest::getVar( 'cid', array(), '',
'array' );
$class = hikashop_get('class.'.$this->type);
$num = $class->delete($cids);
if($num){
$app = JFactory::getApplication();
$app->enqueueMessage(JText::sprintf('SUCC_DELETE_ELEMENTS',count($cids)),
'message');
}
return $this->listing();
}
function publish(){
$cid = JRequest::getVar( 'cid', array(), 'post',
'array' );
JArrayHelper::toInteger($cid);
return $this->_toggle($cid,1);
}
function unpublish(){
$cid = JRequest::getVar( 'cid', array(), 'post',
'array' );
JArrayHelper::toInteger($cid);
return $this->_toggle($cid,0);
}
function _toggle($cid, $publish){
if (empty( $cid )) {
JError::raiseWarning( 500, 'No items selected' );
}
if(in_array($this->type,array('product','category'))){
JPluginHelper::importPlugin( 'hikashop' );
$dispatcher = JDispatcher::getInstance();
$unset = array();
$objs = array();
foreach($cid as $k => $id){
$element = new stdClass();
$name = reset($this->toggle);
$element->$name = $id;
$publish_name = key($this->toggle);
$element->$publish_name = (int)$publish;
$do = true;
$dispatcher->trigger(
'onBefore'.ucfirst($this->type).'Update', array(
& $element, & $do) );
if(!$do){
$unset[]=$k;
}else{
$objs[$k]=& $element;
}
}
if(!empty($unset)){
foreach($unset as $u){
unset($cid[$u]);
}
}
}
$cids = implode( ',', $cid );
$db = JFactory::getDBO();
$query = 'UPDATE '.hikashop_table($this->type) . ' SET
'.key($this->toggle).' = ' . (int)$publish . ' WHERE
'.reset($this->toggle).' IN ( '.$cids.' )';
$db->setQuery( $query );
if (!$db->query()) {
JError::raiseWarning( 500, $db->getErrorMsg() );
}elseif(in_array($this->type,array('product','category'))){
if(!empty($objs)){
foreach($objs as $element){
$dispatcher->trigger(
'onAfter'.ucfirst($this->type).'Update', array(
& $element ) );
}
}
}
$task = $this->publish_return_view;
return $this->$task();
}
function getModel($name = '', $prefix = '', $config =
array(),$do=false) {
if($do) return parent::getModel($name, $prefix , $config);
return false;
}
function authorise($task){
return $this->authorize($task);
}
function authorize($task){
if(!$this->isIn($task,array('modify_views','add','modify','delete','display'))){
return false;
}
if($this->isIn($task,array('modify','delete'))
&& !JRequest::checkToken('request')){
return false;
}
$app = JFactory::getApplication();
$name = $this->getName();
if(!empty($name) && $app->isAdmin()){
if(hikashop_level(2)){
$config =& hikashop_config();
if($this->isIn($task,array('display'))){
$task = 'view';
}elseif($this->isIn($task,array('modify_views','add','modify'))){
$task = 'manage';
}elseif($this->isIn($task,array('delete'))){
$task = 'delete';
}else{
return true;
}
if(!hikashop_isAllowed($config->get('acl_'.$name.'_'.$task,'all'))){
hikashop_display(JText::_('RESSOURCE_NOT_ALLOWED'),'error');
return false;
}
}
}
return true;
}
function isIn($task,$lists){
foreach($lists as $list){
if(in_array($task,$this->$list)){
return true;
}
}
return false;
}
function execute($task){
if(substr($task,0,12)=='triggerplug-'){
JPluginHelper::importPlugin( 'hikashop' );
$dispatcher =& JDispatcher::getInstance();
$parts = explode('-',$task,2);
$event = 'onTriggerPlug'.array_pop($parts);
$dispatcher->trigger( $event, array( ) );
return true;
}
if(HIKASHOP_J30){
if(!$this->authorize($task)){
return JError::raiseError(403,
JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
}
}
return parent::execute($task);
}
function display($cachable = false, $urlparams = false){
$config =& hikashop_config();
$menu_style =
$config->get('menu_style','title_bottom');
if($menu_style=='content_top'){
$app = JFactory::getApplication();
if($app->isAdmin() && JRequest::getString('tmpl')
!== 'component'){
echo hikashop_getMenu('',$menu_style);
}
}
return parent::display();
}
function getUploadSetting($upload_key, $caller = '') {
return false;
}
function manageUpload($upload_key, &$ret, $uploadConfig, $caller =
'') { }
}
class hikashopClass extends JObject{
var $tables = array();
var $pkeys = array();
var $namekeys = array();
function __construct( $config = array() ){
$this->database = JFactory::getDBO();
return parent::__construct($config);
}
function save(&$element){
$pkey = end($this->pkeys);
if(empty($pkey)){
$pkey = end($this->namekeys);
}elseif(empty($element->$pkey)){
$tmp = end($this->namekeys);
if(!empty($tmp)){
if(!empty($element->$tmp)){
$pkey = $tmp;
}else{
$element->$tmp=$this->getNamekey($element);
if($element->$tmp===false){
return false;
}
}
}
}
if(!HIKASHOP_J16){
$obj = new JTable($this->getTable(),$pkey,$this->database);
$obj->setProperties($element);
}else{
$obj =& $element;
}
if(empty($element->$pkey)){
$query = $this->_getInsert($this->getTable(),$obj);
$this->database->setQuery($query);
$status = $this->database->query();
}else{
if(count((array) $element) > 1){
$status =
$this->database->updateObject($this->getTable(),$obj,$pkey);
}else{
$status = true;
}
}
if($status){
return empty($element->$pkey) ? $this->database->insertid() :
$element->$pkey;
}
return false;
}
function getTable(){
return hikashop_table(end($this->tables));
}
function _getInsert( $table, &$object, $keyName = NULL )
{
if(!HIKASHOP_J30){
$fmtsql = 'INSERT IGNORE INTO
'.$this->database->nameQuote($table).' ( %s ) VALUES ( %s )
';
} else {
$fmtsql = 'INSERT IGNORE INTO
'.$this->database->quoteName($table).' ( %s ) VALUES ( %s )
';
}
$fields = array();
foreach (get_object_vars( $object ) as $k => $v) {
if (is_array($v) or is_object($v) or $v === NULL or $k[0] ==
'_') {
continue;
}
if(!HIKASHOP_J30){
$fields[] = $this->database->nameQuote( $k );
$values[] = $this->database->isQuoted( $k ) ?
$this->database->Quote( $v ) : (int) $v;
} else {
$fields[] = $this->database->quoteName( $k );
$values[] = $this->database->Quote( $v );
}
}
return sprintf( $fmtsql, implode( ",", $fields ) , implode(
",", $values ) );
}
function delete(&$elementsToDelete){
if(!is_array($elementsToDelete)){
$elements = array($elementsToDelete);
}else{
$elements = $elementsToDelete;
}
$isNumeric = is_numeric(reset($elements));
$strings = array();
foreach($elements as $key => $val){
$strings[$key] = $this->database->Quote($val);
}
$columns = $isNumeric ? $this->pkeys : $this->namekeys;
if(empty($columns) || empty($elements)) return false;
$otherElements=array();
$otherColumn='';
foreach($columns as $i => $column){
if(empty($column)){
$query = 'SELECT
'.($isNumeric?end($this->pkeys):end($this->namekeys)).'
FROM '.$this->getTable().' WHERE
'.($isNumeric?end($this->pkeys):end($this->namekeys)).' IN
( '.implode(',',$strings).');';
$this->database->setQuery($query);
if(!HIKASHOP_J25){
$otherElements = $this->database->loadResultArray();
} else {
$otherElements = $this->database->loadColumn();
}
foreach($otherElements as $key => $val){
$otherElements[$key] = $this->database->Quote($val);
}
break;
}
}
$result = true;
$tables=array();
if(empty($this->tables)){
$tables[0]=$this->getTable();
}else{
foreach($this->tables as $i => $oneTable){
$tables[$i]=hikashop_table($oneTable);
}
}
foreach($tables as $i => $oneTable){
$column = $columns[$i];
if(empty($column)){
$whereIn = ' WHERE
'.($isNumeric?$this->namekeys[$i]:$this->pkeys[$i]).' IN
('.implode(',',$otherElements).')';
}else{
$whereIn = ' WHERE '.$column.' IN
('.implode(',',$strings).')';
}
$query = 'DELETE FROM '.$oneTable.$whereIn;
$this->database->setQuery($query);
$result = $this->database->query() && $result;
}
return $result;
}
function get($element,$default=null){
if(empty($element)) return null;
$pkey = end($this->pkeys);
$namekey = end($this->namekeys);
if(!is_numeric($element) && !empty($namekey)) {
$pkey = $namekey;
}
$query = 'SELECT * FROM '.$this->getTable().' WHERE
'.$pkey.' = '.$this->database->Quote($element).'
LIMIT 1';
$this->database->setQuery($query);
return $this->database->loadObject();
}
}
if(!class_exists('hikashopBridgeView')){
if(!HIKASHOP_J30){
class hikashopBridgeView extends JView {}
} else {
class hikashopBridgeView extends JViewLegacy {}
}
}
class hikashopView extends hikashopBridgeView {
var $triggerView = false;
var $toolbar = array();
var $direction = 'ltr';
function display($tpl = null) {
$lang = JFactory::getLanguage();
if($lang->isRTL()) $this->direction = 'rtl';
if($this->triggerView) {
JPluginHelper::importPlugin('hikashop');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onHikashopBeforeDisplayView',
array(&$this));
}
if(!empty($this->toolbar)) {
$toolbarHelper = hikashop_get('helper.toolbar');
$toolbarHelper->process($this->toolbar);
}
parent::display($tpl);
if($this->triggerView) {
$dispatcher->trigger('onHikashopAfterDisplayView', array(
&$this));
}
}
function &getPageInfo($default = '', $dir = 'asc')
{
$app = JFactory::getApplication();
$pageInfo = new stdClass();
$pageInfo->search =
$app->getUserStateFromRequest($this->paramBase.'.search',
'search', '', 'string');
$pageInfo->filter = new stdClass();
$pageInfo->filter->order = new stdClass();
$pageInfo->filter->order->value =
$app->getUserStateFromRequest($this->paramBase.'.filter_order',
'filter_order', $default, 'cmd');
$pageInfo->filter->order->dir =
$app->getUserStateFromRequest($this->paramBase.'.filter_order_Dir',
'filter_order_Dir', $dir, 'word');
$pageInfo->limit = new stdClass();
$pageInfo->limit->value =
$app->getUserStateFromRequest($this->paramBase.'.list_limit',
'limit', $app->getCfg('list_limit'),
'int');
if(empty($pageInfo->limit->value))
$pageInfo->limit->value = 500;
if(JRequest::getVar('search') !=
$app->getUserState($this->paramBase.'.search')) {
$app->setUserState($this->paramBase.'.limitstart',0);
$pageInfo->limit->start = 0;
} else {
$pageInfo->limit->start =
$app->getUserStateFromRequest($this->paramBase.'.limitstart',
'limitstart', 0, 'int' );
}
$pageInfo->search =
JString::strtolower($app->getUserStateFromRequest($this->paramBase.'.search',
'search', '', 'string'));
$pageInfo->elements = new stdClass();
$this->assignRef('pageInfo', $pageInfo);
return $pageInfo;
}
function getPageInfoTotal($query, $countValue = '*') {
if(empty($this->pageInfo))
return false;
$db = JFactory::getDBO();
$app = JFactory::getApplication();
$db->setQuery('SELECT COUNT('.$countValue.')
'.$query);
$this->pageInfo->elements->total = (int)$db->loadResult();
if((int)$this->pageInfo->limit->start >=
$this->pageInfo->elements->total) {
$this->pageInfo->limit->start = 0;
$app->setUserState($this->paramBase.'.limitstart', 0);
}
}
function processFilters(&$filters, &$order, $searchMap = array(),
$orderingAccept = array()) {
if(!empty($this->pageInfo->search)) {
$db = JFactory::getDBO();
if(!HIKASHOP_J30) {
$searchVal = '\'%' .
$db->getEscaped(JString::strtolower($this->pageInfo->search),
true) . '%\'';
} else {
$searchVal = '\'%' .
$db->escape(JString::strtolower($this->pageInfo->search), true) .
'%\'';
}
$filters[] = '('.implode(' LIKE '.$searchVal.'
OR ',$searchMap).' LIKE '.$searchVal.')';
}
if(!empty($filters)) {
$filters = ' WHERE '. implode(' AND ', $filters);
} else {
$filters = '';
}
if(!empty($this->pageInfo->filter->order->value)) {
$t = '';
if(strpos($this->pageInfo->filter->order->value,
'.') !== false)
list($t,$v) = explode('.',
$this->pageInfo->filter->order->value, 2);
if(empty($orderingAccept) || in_array($t.'.', $orderingAccept)
|| in_array($this->pageInfo->filter->order->value,
$orderingAccept))
$order = ' ORDER BY
'.$this->pageInfo->filter->order->value.'
'.$this->pageInfo->filter->order->dir;
}
}
function getPagination($max = 500, $limit = 100) {
if(empty($this->pageInfo))
return false;
jimport('joomla.html.pagination');
if($this->pageInfo->limit->value == $max)
$this->pageInfo->limit->value = $limit;
$pagination = new JPagination($this->pageInfo->elements->total,
$this->pageInfo->limit->start,
$this->pageInfo->limit->value);
$this->assignRef('pagination', $pagination);
return $pagination;
}
function getOrdering($value = '', $doOrdering = true) {
$this->assignRef('doOrdering', $doOrdering);
$ordering = new stdClass();
$ordering->ordering = false;
if($doOrdering) {
$ordering->ordering = false;
$ordering->orderUp = 'orderup';
$ordering->orderDown = 'orderdown';
$ordering->reverse = false;
if(!empty($this->pageInfo) &&
$this->pageInfo->filter->order->value == $value) {
$ordering->ordering = true;
if($this->pageInfo->filter->order->dir == 'desc')
{
$ordering->orderUp = 'orderdown';
$ordering->orderDown = 'orderup';
$ordering->reverse = true;
}
}
}
$this->assignRef('ordering', $ordering);
return $ordering;
}
}
class hikashopPlugin extends JPlugin {
var $db;
var $type = 'plugin';
var $multiple = false;
var $plugin_params = null;
var $toolbar = array();
function __construct(&$subject, $config) {
$this->db = JFactory::getDBO();
parent::__construct($subject, $config);
}
function pluginParams($id = 0) {
$this->plugin_params = null;
$this->plugin_data = null;
if(!empty($this->name) && in_array($this->type,
array('payment', 'shipping', 'plugin'))) {
$query = 'SELECT * FROM
'.hikashop_table($this->type).' WHERE
'.$this->type.'_type =
'.$this->db->Quote($this->name);
if($id > 0) {
$query .= ' AND '.$this->type.'_id = ' .
(int)$id;
}
$this->db->setQuery($query);
$this->db->query();
$data = $this->db->loadObject();
if(!empty($data)) {
$params = $this->type.'_params';
$this->plugin_params = unserialize($data->$params);
$this->plugin_data = $data;
unset($this->plugin_data->$params);
return true;
}
}
return false;
}
function isMultiple() {
return $this->multiple;
}
function configurationHead() {
return array();
}
function configurationLine($id = 0) {
return null;
}
function listPlugins($name, &$values, $full = true){
if(in_array($this->type, array('payment',
'shipping','plugin'))) {
if($this->multiple) {
$query = 'SELECT '.$this->type.'_id as id,
'.$this->type.'_name as name FROM
'.hikashop_table($this->type).' WHERE
'.$this->type.'_type = ' . $this->db->Quote($name)
. ' AND '.$this->type.'_published = 1 ORDER BY
'.$this->type.'_ordering';
$this->db->setQuery($query);
$plugins = $this->db->loadObjectList();
if($full) {
foreach($plugins as $plugin) {
$values['plg.'.$name.'-'.$plugin->id] =
$name.' - '.$plugin->name;
}
} else {
foreach($plugins as $plugin) {
$values[] = $plugin->id;
}
}
} else {
$values['plg.'.$name] = $name;
};
}
}
function pluginConfiguration(&$elements) {
$app = JFactory::getApplication();
$this->plugins =& $elements;
$this->pluginName = JRequest::getCmd('name',
$this->type);
$this->pluginView = '';
$plugin_id = JRequest::getInt('plugin_id',0);
if($plugin_id == 0) {
$plugin_id = JRequest::getInt($this->type.'_id', 0);
}
$this->toolbar = array(
'save',
'apply',
'cancel' => array('name' => 'link',
'icon' => 'cancel', 'alt' =>
JText::_('HIKA_CANCEL'), 'url' =>
hikashop_completeLink('plugins')),
);
if(!empty($this->doc_form)) {
$this->toolbar[] = '|';
$this->toolbar[] = array('name' => 'pophelp',
'target' =>
$this->type.'-'.$this->doc_form.'-form');
}
if(empty($this->title)) {
$this->title = JText::_('HIKASHOP_PLUGIN_METHOD');
}
if($plugin_id == 0) {
hikashop_setTitle($this->title, 'plugin',
'plugins&plugin_type='.$this->type.'&task=edit&name='.$this->pluginName.'&subtask=edit');
} else {
hikashop_setTitle($this->title, 'plugin',
'plugins&plugin_type='.$this->type.'&task=edit&name='.$this->pluginName.'&subtask='.$this->type.'_edit&'.$this->type.'_id='.$plugin_id);
}
}
function pluginMultipleConfiguration(&$elements) {
if(!$this->multiple)
return;
$app = JFactory::getApplication();
$this->plugins =& $elements;
$this->pluginName = JRequest::getCmd('name',
$this->type);
$this->pluginView = 'sublisting';
$this->subtask = JRequest::getCmd('subtask','');
$this->task = JRequest::getVar('task');
if(empty($this->title)) { $this->title =
JText::_('HIKASHOP_PLUGIN_METHOD'); }
if($this->subtask == 'copy') {
if(!in_array($this->task, array('orderup',
'orderdown', 'saveorder'))) {
$pluginIds = JRequest::getVar('cid', array(), '',
'array');
JArrayHelper::toInteger($pluginIds);
$result = true;
if(!empty($pluginIds) && in_array($this->type,
array('payment','shipping'))) {
$this->db->setQuery('SELECT * FROM
'.hikashop_table($this->type).' WHERE
'.$this->type.'_id IN
('.implode(',',$pluginIds).')');
$plugins = $this->db->loadObjectList();
$helper = hikashop_get('class.'.$this->type);
$plugin_id = $this->type . '_id';
foreach($plugins as $plugin) {
unset($plugin->$plugin_id);
if(!$helper->save($plugin)) {
$result = false;
}
}
}
if($result) {
$app->enqueueMessage(JText::_('HIKASHOP_SUCC_SAVED'),
'message');
$app->redirect(hikashop_completeLink('plugins&plugin_type='.$this->type.'&task=edit&name='.$this->pluginName,
false, true));
}
}
}
$this->toolbar = array(
array('name' => 'link',
'icon'=>'new','alt' =>
JText::_('HIKA_NEW'), 'url' =>
hikashop_completeLink('plugins&plugin_type='.$this->type.'&task=edit&name='.$this->pluginName.'&subtask=edit')),
'cancel',
'|',
array('name' => 'pophelp', 'target'
=> 'plugins-'.$this->doc_listing.'sublisting')
);
hikashop_setTitle($this->title, 'plugin',
'plugins&plugin_type='.$this->type.'&task=edit&name='.$this->pluginName);
$this->toggleClass = hikashop_get('helper.toggle');
jimport('joomla.html.pagination');
$this->pagination = new JPagination(count($this->plugins), 0,
false);
$this->order = new stdClass();
$this->order->ordering = true;
$this->order->orderUp = 'orderup';
$this->order->orderDown = 'orderdown';
$this->order->reverse = false;
$app->setUserState(HIKASHOP_COMPONENT.'.plugin_type.'.$this->type,
$this->pluginName);
}
}
class hikashopPaymentPlugin extends hikashopPlugin {
var $type = 'payment';
var $accepted_currencies = array();
var $doc_form = 'generic';
function onPaymentDisplay(&$order, &$methods,
&$usable_methods) {
if(empty($methods) || empty($this->name))
return true;
if(!empty($order->total)) {
$currencyClass = hikashop_get('class.currency');
$null = null;
$currency_id =
intval(@$order->total->prices[0]->price_currency_id);
$currency = $currencyClass->getCurrencies($currency_id, $null);
if(!empty($currency) && !empty($this->accepted_currencies)
&& !in_array(@$currency[$currency_id]->currency_code,
$this->accepted_currencies))
return true;
$this->currency = $currency;
$this->currency_id = $currency_id;
}
$currencyClass = hikashop_get('class.currency');
$this->currencyClass = $currencyClass;
$shippingClass = hikashop_get('class.shipping');
$volumeHelper = hikashop_get('helper.volume');
$weightHelper = hikashop_get('helper.weight');
foreach($methods as $method) {
if($method->payment_type != $this->name || !$method->enabled ||
!$method->payment_published)
continue;
if(method_exists($this, 'needCC')) {
$this->needCC($method);
} else if(!empty($this->ask_cc)) {
$method->ask_cc = true;
if(!empty($this->ask_owner))
$method->ask_owner = true;
if(!empty($method->payment_params->ask_ccv))
$method->ask_ccv = true;
}
if(@$method->payment_params->payment_price_use_tax) {
if(isset($order->total->prices[0]->price_value_with_tax))
$price = $order->total->prices[0]->price_value_with_tax;
if(isset($order->full_total->prices[0]->price_value_with_tax))
$price =
$order->full_total->prices[0]->price_value_with_tax;
} else {
if(isset($order->order_full_price))
$price = $order->order_full_price;
if(isset($order->total->prices[0]->price_value))
$price = $order->total->prices[0]->price_value;
if(isset($order->full_total->prices[0]->price_value))
$price =$order->full_total->prices[0]->price_value;
}
if(!empty($method->payment_params->payment_min_price) &&
hikashop_toFloat($method->payment_params->payment_min_price) >
$price) {
$method->errors['min_price'] =
(hikashop_toFloat($method->payment_params->payment_min_price) -
$price);
continue;
}
if(!empty($method->payment_params->payment_max_price) &&
hikashop_toFloat($method->payment_params->payment_max_price) <
$price){
$method->errors['max_price'] = ($price -
hikashop_toFloat($method->payment_params->payment_max_price));
continue;
}
if(!empty($method->payment_params->payment_max_volume) &&
bccomp((float)@$method->payment_params->payment_max_volume, 0, 3)) {
$method->payment_params->payment_max_volume_orig =
$method->payment_params->payment_max_volume;
$method->payment_params->payment_max_volume =
$volumeHelper->convert($method->payment_params->payment_max_volume,
@$method->payment_params->payment_size_unit);
if($method->payment_params->payment_max_volume <
$order->volume){
$method->errors['max_volume'] =
($method->payment_params->payment_max_volume - $order->volume);
continue;
}
}
if(!empty($method->payment_params->payment_min_volume) &&
bccomp((float)@$method->payment_params->payment_min_volume, 0, 3)) {
$method->payment_params->payment_min_volume_orig =
$method->payment_params->payment_min_volume;
$method->payment_params->payment_min_volume =
$volumeHelper->convert($method->payment_params->payment_min_volume,
@$method->payment_params->payment_size_unit);
if($method->payment_params->payment_min_volume >
$order->volume){
$method->errors['min_volume'] = ($order->volume -
$method->payment_params->payment_min_volume);
continue;
}
}
if(!empty($method->payment_params->payment_max_weight) &&
bccomp((float)@$method->payment_params->payment_max_weight, 0, 3)) {
$method->payment_params->payment_max_weight_orig =
$method->payment_params->payment_max_weight;
$method->payment_params->payment_max_weight =
$weightHelper->convert($method->payment_params->payment_max_weight,
@$method->payment_params->payment_weight_unit);
if($method->payment_params->payment_max_weight <
$order->weight){
$method->errors['max_weight'] =
($method->payment_params->payment_max_weight - $order->weight);
continue;
}
}
if(!empty($method->payment_params->payment_min_weight) &&
bccomp((float)@$method->payment_params->payment_min_weight,0,3)){
$method->payment_params->payment_min_weight_orig =
$method->payment_params->payment_min_weight;
$method->payment_params->payment_min_weight =
$weightHelper->convert($method->payment_params->payment_min_weight,
@$method->payment_params->payment_weight_unit);
if($method->payment_params->payment_min_weight >
$order->weight){
$method->errors['min_weight'] = ($order->weight -
$method->payment_params->payment_min_weight);
continue;
}
}
if(!empty($method->payment_params->payment_max_quantity)
&& (int)$method->payment_params->payment_max_quantity) {
if($method->payment_params->payment_max_quantity <
$order->total_quantity){
$method->errors['max_quantity'] =
($method->payment_params->payment_max_quantity -
$order->total_quantity);
continue;
}
}
if(!empty($method->payment_params->payment_min_quantity)
&& (int)$method->payment_params->payment_min_quantity){
if($method->payment_params->payment_min_quantity >
$order->total_quantity){
$method->errors['min_quantity'] =
($order->total_quantity -
$method->payment_params->payment_min_quantity);
continue;
}
}
if(!$this->checkPaymentDisplay($method, $order))
continue;
if((int)$method->payment_ordering > 0 &&
!isset($usable_methods[(int)$method->payment_ordering]))
$usable_methods[(int)$method->payment_ordering] = $method;
else
$usable_methods[] = $method;
}
return true;
}
function onPaymentSave(&$cart, &$rates, &$payment_id) {
$usable = array();
$this->onPaymentDisplay($cart, $rates, $usable);
$payment_id = (int)$payment_id;
foreach($usable as $usable_method) {
if($usable_method->payment_id == $payment_id)
return $usable_method;
}
return false;
}
function onPaymentConfiguration(&$element) {
$this->pluginConfiguration($element);
if(empty($element) || empty($element->payment_type)) {
$element = new stdClass();
$element->payment_type = $this->pluginName;
$element->payment_params= new stdClass();
$this->getPaymentDefaultValues($element);
}
$this->order_statuses = hikashop_get('type.categorysub');
$this->order_statuses->type = 'status';
$this->currency = hikashop_get('type.currency');
$this->weight = hikashop_get('type.weight');
$this->volume = hikashop_get('type.volume');
}
function onPaymentConfigurationSave(&$element) {
if(!empty($this->pluginConfig)) {
$formData = JRequest::getVar('data', array(), '',
'array', JREQUEST_ALLOWRAW);
if(isset($formData['payment']['payment_params'])) {
foreach($this->pluginConfig as $key => $config) {
if($config[1] == 'textarea' || $config[1] ==
'big-textarea') {
$element->payment_params->$key =
@$formData['payment']['payment_params'][$key];
}
}
}
}
return true;
}
function onBeforeOrderCreate(&$order, &$do) {
$app = JFactory::getApplication();
if($app->isAdmin())
return true;
if(empty($order->order_payment_method) ||
$order->order_payment_method != $this->name)
return true;
$this->loadOrderData($order);
$this->loadPaymentParams($order);
if(empty($this->payment_params)) {
$do = false;
return true;
}
}
function onAfterOrderConfirm(&$order, &$methods, $method_id) {
$method = $methods[$method_id];
$this->payment_params =& $method->payment_params;
$this->payment_name = $method->payment_name;
$this->loadOrderData($order);
}
function onPaymentNotification(&$statuses) {
}
function getOrder($order_id) {
$ret = null;
if(empty($order_id))
return $ret;
$orderClass = hikashop_get('class.order');
$ret = $orderClass->get($order_id);
return $ret;
}
function modifyOrder(&$order_id, $order_status, $history = null,
$email = null) {
if(is_object($order_id)) {
$order =& $order_id;
} else {
$order = new stdClass();
$order->order_id = $order_id;
}
if($order_status !== null)
$order->order_status = $order_status;
$history_notified = 0;
$history_amount = '';
$history_data = '';
$history_type = '';
if(!empty($history)) {
if($history === true) {
$history_notified = 1;
} else if(is_array($history)) {
$history_notified = (int)@$history['notified'];
$history_amount = @$history['amount'];
$history_data = @$history['data'];
$history_type = @$history['type'];
} else {
$history_notified = (int)@$history->notified;
$history_amount = @$history->amount;
$history_data = @$history->data;
$history_type = @$history->type;
}
}
$order->history = new stdClass();
$order->history->history_reason =
JText::sprintf('AUTOMATIC_PAYMENT_NOTIFICATION');
$order->history->history_notified = $history_notified;
$order->history->history_payment_method = $this->name;
$order->history->history_type = 'payment';
if(!empty($history_amount))
$order->history->history_amount = $history_amount;
if(!empty($history_data))
$order->history->history_data = $history_data;
if(!empty($history_type))
$order->history->history_type = $history_type;
if(!is_object($order_id) && $order_id !== false) {
$orderClass = hikashop_get('class.order');
$orderClass->save($order);
}
if(empty($email))
return;
$mailer = JFactory::getMailer();
$config =& hikashop_config();
$sender = array(
$config->get('from_email'),
$config->get('from_name')
);
$mailer->setSender($sender);
$mailer->addRecipient(explode(',',
$config->get('payment_notification_email')));
$payment_status = $order_status;
$mail_status = hikashop_orderStatus($order_status);
$order_number = '';
global $Itemid;
$this->url_itemid = empty($Itemid) ? '' :
'&Itemid=' . $Itemid;
if(is_object($order_id)) {
$subject = JText::sprintf('PAYMENT_NOTIFICATION',
$this->name, $payment_status);
$url =
HIKASHOP_LIVE.'administrator/index.php?option=com_hikashop&ctrl=order&task=listing'.
$this->url_itemid;
} elseif($order_id !== false) {
$dbOrder = $orderClass->get($order_id);
$order_number = $dbOrder->order_number;
$subject = JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER',
$this->name, $payment_status, $order_number);
$url =
HIKASHOP_LIVE.'administrator/index.php?option=com_hikashop&ctrl=order&task=edit&order_id='
. $order_id . $this->url_itemid;
}
$order_text = '';
if(is_string($email))
$order_text = "\r\n\r\n" . $email;
$body = str_replace('<br/>', "\r\n",
JText::sprintf('PAYMENT_NOTIFICATION_STATUS', $this->name,
$payment_status)) . ' ' .
JText::sprintf('ORDER_STATUS_CHANGED', $mail_status) .
"\r\n".JText::sprintf('NOTIFICATION_OF_ORDER_ON_WEBSITE',
$order_number, HIKASHOP_LIVE).
"\r\n".str_replace('<br/>', "\r\n",
JText::sprintf('ACCESS_ORDER_WITH_LINK', $url)) . $order_text;
if(is_object($email)) {
if(!empty($email->subject))
$subject = $email->subject;
if(!empty($email->body))
$body = $email->body;
}
$mailer->setSubject($subject);
$mailer->setBody($body);
$mailer->Send();
}
function loadOrderData(&$order) {
$this->app = JFactory::getApplication();
$lang = JFactory::getLanguage();
$currencyClass = hikashop_get('class.currency');
$cartClass = hikashop_get('class.cart');
$this->currency = 0;
if(!empty($order->order_currency_id)) {
$currencies = null;
$currencies =
$currencyClass->getCurrencies($order->order_currency_id,
$currencies);
$this->currency = $currencies[$order->order_currency_id];
}
hikashop_loadUser(true, true);
$this->user = hikashop_loadUser(true);
$this->locale = strtolower(substr($lang->get('tag'), 0,
2));
global $Itemid;
$this->url_itemid = empty($Itemid) ? '' :
'&Itemid=' . $Itemid;
$billing_address =
$this->app->getUserState(HIKASHOP_COMPONENT.'.billing_address');
if(!empty($billing_address))
$cartClass->loadAddress($order->cart, $billing_address,
'object', 'billing');
$shipping_address =
$this->app->getUserState(HIKASHOP_COMPONENT.'.shipping_address');
if(!empty($shipping_address))
$cartClass->loadAddress($order->cart, $shipping_address,
'object', 'shipping');
}
function loadPaymentParams(&$order) {
$payment_id = @$order->order_payment_id;
$this->payment_params = null;
if(!empty($order->order_payment_method) &&
$order->order_payment_method == $this->name &&
!empty($payment_id) && $this->pluginParams($payment_id))
$this->payment_params =& $this->plugin_params;
}
function ccLoad($ccv = true) {
if(!isset($this->app))
$this->app = JFactory::getApplication();
$this->cc_number =
$this->app->getUserState(HIKASHOP_COMPONENT.'.cc_number');
if(!empty($this->cc_number)) $this->cc_number =
base64_decode($this->cc_number);
$this->cc_month =
$this->app->getUserState(HIKASHOP_COMPONENT.'.cc_month');
if(!empty($this->cc_month)) $this->cc_month =
base64_decode($this->cc_month);
$this->cc_year =
$this->app->getUserState(HIKASHOP_COMPONENT.'.cc_year');
if(!empty($this->cc_year)) $this->cc_year =
base64_decode($this->cc_year);
$this->cc_type = $this->app->getUserState(
HIKASHOP_COMPONENT.'.cc_type');
if(!empty($this->cc_type)){
$this->cc_type = base64_decode($this->cc_type);
}
$this->cc_owner = $this->app->getUserState(
HIKASHOP_COMPONENT.'.cc_owner');
if(!empty($this->cc_owner)){
$this->cc_owner = base64_decode($this->cc_owner);
}
$this->cc_CCV = '';
if($ccv) {
$this->cc_CCV =
$this->app->getUserState(HIKASHOP_COMPONENT.'.cc_CCV');
if(!empty($this->cc_CCV)) $this->cc_CCV =
base64_decode($this->cc_CCV);
}
}
function ccClear() {
if(!isset($this->app))
$this->app = JFactory::getApplication();
$this->app->setUserState(HIKASHOP_COMPONENT.'.cc_number',
'');
$this->app->setUserState(HIKASHOP_COMPONENT.'.cc_month',
'');
$this->app->setUserState(HIKASHOP_COMPONENT.'.cc_year',
'');
$this->app->setUserState(HIKASHOP_COMPONENT.'.cc_type',
'');
$this->app->setUserState(HIKASHOP_COMPONENT.'.cc_owner',
'');
$this->app->setUserState(HIKASHOP_COMPONENT.'.cc_CCV',
'');
$this->app->setUserState(HIKASHOP_COMPONENT.'.cc_valid',
0);
}
function showPage($name = 'thanks') {
if(!HIKASHOP_J30)
JHTML::_('behavior.mootools');
else
JHTML::_('behavior.framework');
$app = JFactory::getApplication();
$path =
JPATH_THEMES.DS.$app->getTemplate().DS.'hikashoppayment'.DS.$this->name.'_'.$name.'.php';
if(!file_exists($path)) {
if(version_compare(JVERSION,'1.6','<'))
$path = JPATH_PLUGINS
.DS.'hikashoppayment'.DS.$this->name.'_'.$name.'.php';
else
$path = JPATH_PLUGINS
.DS.'hikashoppayment'.DS.$this->name.DS.$this->name.'_'.$name.'.php';
}
if(!file_exists($path)) {
}
if(!file_exists($path))
return false;
require($path);
return true;
}
function writeToLog($data) {
if($data === null) {
$dbg = ob_get_clean();
} else {
$dbg = $data;
}
if(!empty($dbg)) {
$dbg = '-- ' . date('m.d.y H:i:s') . ' --'
. "\r\n" . $dbg;
$config =& hikashop::config();
jimport('joomla.filesystem.file');
$file = $config->get('payment_log_file', '');
$file = rtrim(JPath::clean(html_entity_decode($file)), DS . '
');
if(!preg_match('#^([A-Z]:)?/.*#',$file)){
if(!$file[0] == '/' || !file_exists($file)) {
$file = JPath::clean(HIKASHOP_ROOT . DS . trim($file, DS . '
'));
}
}
if(!empty($file) && defined('FILE_APPEND')) {
if(!file_exists(dirname($file))) {
jimport('joomla.filesystem.folder');
JFolder::create(dirname($file));
}
file_put_contents($file, $dbg, FILE_APPEND);
}
}
if($data === null) {
ob_start();
}
}
function getPaymentDefaultValues(&$element){}
function checkPaymentDisplay(&$method, &$order) { return true; }
}
class hikashopShippingPlugin extends hikashopPlugin {
var $type = 'shipping';
function onShippingDisplay(&$order, &$dbrates, &$usable_rates,
&$messages) {
$config =& hikashop_config();
if(!$config->get('force_shipping') &&
bccomp(@$order->weight, 0, 5) <= 0)
return false;
if(empty($dbrates) || empty($this->name))
return false;
$rates = array();
foreach($dbrates as $k => $rate) {
if($rate->shipping_type == $this->name &&
!empty($rate->shipping_published)) {
$rates[] = $rate;
}
}
if(empty($rates))
return false;
$currencyClass = hikashop_get('class.currency');
$shippingClass = hikashop_get('class.shipping');
$volumeHelper = hikashop_get('helper.volume');
$weightHelper = hikashop_get('helper.weight');
foreach($rates as &$rate) {
$rate->shippingkey =
$shippingClass->getShippingProductsData($order, $order->products);
$shipping_prices = $order->shipping_prices[$rate->shippingkey];
if(!isset($rate->shipping_params->shipping_price_use_tax))
$rate->shipping_params->shipping_price_use_tax = 1;
if(!isset($rate->shipping_params->shipping_virtual_included) ||
$rate->shipping_params->shipping_virtual_included) {
if($rate->shipping_params->shipping_price_use_tax)
$price = $shipping_prices->all_with_tax;
else
$price = $shipping_prices->all_without_tax;
} else {
if($rate->shipping_params->shipping_price_use_tax)
$price = $shipping_prices->real_with_tax;
else
$price = $shipping_prices->real_without_tax;
}
if(bccomp($price, 0, 5) &&
isset($rate->shipping_params->shipping_percentage) &&
bccomp($rate->shipping_params->shipping_percentage, 0, 3))
$rate->shipping_price = round($rate->shipping_price + $price *
$rate->shipping_params->shipping_percentage / 100,
$currencyClass->getRounding($rate->shipping_currency_id));
if(!empty($rate->shipping_params->shipping_min_price) &&
hikashop_toFloat($rate->shipping_params->shipping_min_price) >
$price)
$rate->errors['min_price'] =
(hikashop_toFloat($rate->shipping_params->shipping_min_price) -
$price);
if(!empty($rate->shipping_params->shipping_max_price) &&
hikashop_toFloat($rate->shipping_params->shipping_max_price) <
$price)
$rate->errors['max_price'] = ($price -
hikashop_toFloat($rate->shipping_params->shipping_max_price));
if(!empty($rate->shipping_params->shipping_max_volume) &&
bccomp((float)@$rate->shipping_params->shipping_max_volume, 0, 3)) {
$rate->shipping_params->shipping_max_volume_orig =
$rate->shipping_params->shipping_max_volume;
$rate->shipping_params->shipping_max_volume =
$volumeHelper->convert($rate->shipping_params->shipping_max_volume,
@$rate->shipping_params->shipping_size_unit);
if($rate->shipping_params->shipping_max_volume <
$shipping_prices->volume)
$rate->errors['max_volume'] =
($rate->shipping_params->shipping_max_volume -
$shipping_prices->volume);
}
if(!empty($rate->shipping_params->shipping_min_volume) &&
bccomp((float)@$rate->shipping_params->shipping_min_volume, 0, 3)) {
$rate->shipping_params->shipping_min_volume_orig =
$rate->shipping_params->shipping_min_volume;
$rate->shipping_params->shipping_min_volume =
$volumeHelper->convert($rate->shipping_params->shipping_min_volume,
@$rate->shipping_params->shipping_size_unit);
if($rate->shipping_params->shipping_min_volume >
$shipping_prices->volume)
$rate->errors['min_volume'] =
($shipping_prices->volume -
$rate->shipping_params->shipping_min_volume);
}
if(!empty($rate->shipping_params->shipping_max_weight) &&
bccomp((float)@$rate->shipping_params->shipping_max_weight, 0, 3)) {
$rate->shipping_params->shipping_max_weight_orig =
$rate->shipping_params->shipping_max_weight;
$rate->shipping_params->shipping_max_weight =
$weightHelper->convert($rate->shipping_params->shipping_max_weight,
@$rate->shipping_params->shipping_weight_unit);
if($rate->shipping_params->shipping_max_weight <
$shipping_prices->weight)
$rate->errors['max_weight'] =
($rate->shipping_params->shipping_max_weight -
$shipping_prices->weight);
}
if(!empty($rate->shipping_params->shipping_min_weight) &&
bccomp((float)@$rate->shipping_params->shipping_min_weight,0,3)){
$rate->shipping_params->shipping_min_weight_orig =
$rate->shipping_params->shipping_min_weight;
$rate->shipping_params->shipping_min_weight =
$weightHelper->convert($rate->shipping_params->shipping_min_weight,
@$rate->shipping_params->shipping_weight_unit);
if($rate->shipping_params->shipping_min_weight >
$shipping_prices->weight)
$rate->errors['min_weight'] =
($shipping_prices->weight -
$rate->shipping_params->shipping_min_weight);
}
if(!empty($rate->shipping_params->shipping_max_quantity)
&& (int)$rate->shipping_params->shipping_max_quantity) {
if($rate->shipping_params->shipping_max_quantity <
$shipping_prices->total_quantity)
$rate->errors['max_quantity'] =
($rate->shipping_params->shipping_max_quantity -
$shipping_prices->total_quantity);
}
if(!empty($rate->shipping_params->shipping_min_quantity)
&& (int)$rate->shipping_params->shipping_min_quantity){
if($rate->shipping_params->shipping_min_quantity >
$shipping_prices->total_quantity)
$rate->errors['min_quantity'] =
($shipping_prices->total_quantity -
$rate->shipping_params->shipping_min_quantity);
}
if(isset($rate->shipping_params->shipping_per_product) &&
$rate->shipping_params->shipping_per_product) {
if(!isset($order->shipping_prices[$rate->shippingkey]->price_per_product)){
$order->shipping_prices[$rate->shippingkey]->price_per_product
= array();
}
$order->shipping_prices[$rate->shippingkey]->price_per_product[$rate->shipping_id]
= array(
'price' =>
(float)$rate->shipping_params->shipping_price_per_product,
'products' => array()
);
}
unset($rate);
}
foreach($order->shipping_prices as $key => $shipping_price) {
if(!empty($shipping_price->price_per_product) &&
!empty($shipping_price->products)) {
$query = 'SELECT a.shipping_id, a.shipping_price_ref_id as
`ref_id`, a.shipping_price_min_quantity as `min_quantity`,
a.shipping_price_value as `price`, a.shipping_fee_value as `fee` '.
' FROM ' . hikashop_table('shipping_price') .
' AS a '.
' WHERE a.shipping_id IN (' . implode(',',
array_keys($shipping_price->price_per_product)) . ') '.
' AND a.shipping_price_ref_id IN (' . implode(',',
array_keys($shipping_price->products)) . ') AND
a.shipping_price_ref_type = \'product\' '.
' ORDER BY a.shipping_id, a.shipping_price_ref_id,
a.shipping_price_min_quantity';
$db = JFactory::getDBO();
$db->setQuery($query);
$ret = $db->loadObjectList();
if(!empty($ret)) {
foreach($ret as $ship) {
if($ship->min_quantity <=
$shipping_price->products[$ship->ref_id]) {
$order->shipping_prices[$key]->price_per_product[$ship->shipping_id]['products'][$ship->ref_id]
= ($ship->price * $shipping_price->products[$ship->ref_id]) +
$ship->fee;
}
}
}
}
}
foreach($rates as &$rate) {
if(!isset($rate->shippingkey))
continue;
$shipping_prices =&
$order->shipping_prices[$rate->shippingkey];
if(isset($shipping_prices->price_per_product[$rate->shipping_id])
&& !empty($order->products)) {
$rate_prices =&
$order->shipping_prices[$rate->shippingkey]->price_per_product[$rate->shipping_id];
$price = 0;
foreach($order->products as $k => $row) {
if(!empty($rate->products) &&
!in_array($row->product_id, $rate->products))
continue;
if(isset($rate_prices['products'][$row->product_id])) {
$price += $rate_prices['products'][$row->product_id];
$rate_prices['products'][$row->product_id] = 0;
}
elseif(isset($rate_prices['products'][$row->product_parent_id]))
{
$price +=
$rate_prices['products'][$row->product_parent_id];
$rate_prices['products'][$row->product_parent_id] = 0;
}
elseif(!isset($rate->shipping_params->shipping_virtual_included) ||
$rate->shipping_params->shipping_virtual_included ||
$row->product_weight > 0) {
$price += $rate_prices['price'] *
$row->cart_product_quantity;
}
}
if($price > 0) {
if(!isset($rate->shipping_price_base))
$rate->shipping_price_base =
hikashop_toFloat($rate->shipping_price);
else
$rate->shipping_price = $rate->shipping_price_base;
$rate->shipping_price = round($rate->shipping_price + $price,
$currencyClass->getRounding($rate->shipping_currency_id));
}
if($price < 0) {
if(!isset($rate->errors['product_excluded']))
$rate->errors['product_excluded'] = 0;
$rate->errors['product_excluded']++;
}
unset($rate_prices);
}
unset($shipping_prices);
if(empty($rate->errors))
$usable_rates[$rate->shipping_id] = $rate;
else
$messages[] = $rate->errors;
}
return true;
}
function onShippingSave(&$cart, &$methods, &$shipping_id,
$warehouse_id = null) {
$usable_methods = array();
$errors = array();
$shipping = hikashop_get('class.shipping');
$usable_methods = $shipping->getShippings($cart);
foreach($usable_methods as $k => $usable_method) {
if(($usable_method->shipping_id == $shipping_id) &&
($warehouse_id == null || (isset($usable_method->shipping_warehouse_id)
&& $usable_method->shipping_warehouse_id == $warehouse_id)))
return $usable_method;
}
return false;
}
function onShippingConfiguration(&$element) {
$this->pluginConfiguration($element);
if(empty($element) || empty($element->shipping_type)) {
$element = new stdClass();
$element->shipping_type = $this->pluginName;
$element->shipping_params = new stdClass();
$this->getShippingDefaultValues($element);
}
$this->currency = hikashop_get('type.currency');
$this->weight = hikashop_get('type.weight');
$this->volume = hikashop_get('type.volume');
}
function onShippingConfigurationSave(&$element) {
if(!empty($this->pluginConfig)) {
$formData = JRequest::getVar('data', array(), '',
'array', JREQUEST_ALLOWRAW);
if(isset($formData['shipping']['shipping_params']))
{
foreach($this->pluginConfig as $key => $config) {
if($config[1] == 'textarea' || $config[1] ==
'big-textarea') {
$element->shipping_params->$key =
@$formData['shipping']['shipping_params'][$key];
}
}
}
}
return true;
}
function onAfterOrderConfirm(&$order,&$methods,$method_id) {
return true;
}
function getShippingAddress($id = 0) {
$app = JFactory::getApplication();
if($id == 0 && !$app->isAdmin()) {
$id = $app->getUserState(HIKASHOP_COMPONENT.'.shipping_id',
null);
if(!empty($id) && is_array($id))
$id = (int)reset($id);
else
$id = 0;
}
if(empty($id))
return false;
$shippingClass = hikashop_get('class.shipping');
$shipping = $shippingClass->get($id);
if($shipping->shipping_type != $this->name)
return false;
$params = unserialize($shipping->shipping_params);
$override = 0;
if(isset($params->shipping_override_address)) {
$override = (int)$params->shipping_override_address;
}
switch($override) {
case 4:
if(!empty($params->shipping_override_address_text))
return $params->shipping_override_address_text;
break;
case 3:
if(!empty($params->shipping_override_address_text))
return
str_replace(array("\r\n","\n","\r"),"<br/>",
htmlentities($params->shipping_override_address_text, ENT_COMPAT,
'UTF-8') );
break;
case 2:
return '';
case 1:
$config =& hikashop_config();
return
str_replace(array("\r\n","\n","\r"),"<br/>",
$config->get('store_address'));
case 0:
default:
return false;
}
return false;
}
function getShippingDefaultValues(&$element) {}
}
JHTML::_('select.booleanlist','hikashop');
if(HIKASHOP_J25){
class hikaParameter extends JRegistry {
function get($path, $default = null) {
$value = parent::get($path, 'noval');
if($value==='noval') $value =
parent::get('data.'.$path,$default);
return $value;
}
}
class hikaLanguage extends JLanguage {
function __construct($old = null) {
if(is_string($old)) {
parent::__construct($old);
$old = JFactory::getLanguage($old);
}else{
parent::__construct($old->lang);
}
if(is_object($old)) {
$this->strings = $old->strings; $this->override =
$old->override; $this->paths = $old->paths;
$this->metadata = $old->metadata; $this->locale =
$old->locale; $this->lang = $old->lang;
$this->default = $old->default; $this->debug = $old->debug;
$this->orphans = $old->orphans;
}
}
function publicLoadLanguage($filename, $extension = 'unknown')
{
if($extension == 'override')
return $this->reloadOverride($filename);
return $this->loadLanguage($filename, $extension);
}
function reloadOverride($filename = null) {
$ret = false;
if(empty($this->lang) && empty($file)) return $ret;
if(empty($filename))
$filename =
JPATH_BASE.'/language/overrides/'.$this->lang.'.override.ini';
if(file_exists($filename) && $contents =
$this->parse($filename)) {
if(is_array($contents)) {
$this->override = $contents;
$this->strings = array_merge($this->strings,
$this->override);
$ret = true;
}
unset($contents);
}
return $ret;
}
}
JFactory::$language = new hikaLanguage(JFactory::$language);
}else{
jimport('joomla.html.parameter');
class hikaParameter extends JParameter {}
}
define('HIKASHOP_COMPONENT','com_hikashop');
define('HIKASHOP_LIVE',rtrim(JURI::root(),'/').'/');
define('HIKASHOP_ROOT',rtrim(JPATH_ROOT,DS).DS);
define('HIKASHOP_FRONT',rtrim(JPATH_SITE,DS).DS.'components'.DS.HIKASHOP_COMPONENT.DS);
define('HIKASHOP_BACK',rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.HIKASHOP_COMPONENT.DS);
define('HIKASHOP_HELPER',HIKASHOP_BACK.'helpers'.DS);
define('HIKASHOP_BUTTON',HIKASHOP_BACK.'buttons');
define('HIKASHOP_CLASS',HIKASHOP_BACK.'classes'.DS);
define('HIKASHOP_INC',HIKASHOP_BACK.'inc'.DS);
define('HIKASHOP_VIEW',HIKASHOP_BACK.'views'.DS);
define('HIKASHOP_TYPE',HIKASHOP_BACK.'types'.DS);
define('HIKASHOP_MEDIA',HIKASHOP_ROOT.'media'.DS.HIKASHOP_COMPONENT.DS);
define('HIKASHOP_DBPREFIX','#__hikashop_');
$app = JFactory::getApplication();
$configClass =& hikashop_config();
if(!HIKASHOP_PHP5) {
$lang =& JFactory::getLanguage();
$doc =& JFactory::getDocument();
} else {
$lang = JFactory::getLanguage();
$doc = JFactory::getDocument();
}
if($configClass->get('bootstrap_design', HIKASHOP_J30)) {
define('HIKASHOP_RESPONSIVE', true);
} else {
define('HIKASHOP_RESPONSIVE', false);
}
if($configClass->get('bootstrap_back_design', HIKASHOP_J30))
{
define('HIKASHOP_BACK_RESPONSIVE', true);
} else {
define('HIKASHOP_BACK_RESPONSIVE', false);
}
if(HIKASHOP_J30 && (($app->isAdmin() &&
HIKASHOP_BACK_RESPONSIVE) || (!$app->isAdmin() &&
HIKASHOP_RESPONSIVE))){
include_once(dirname(__FILE__).DS.'joomla30.php');
}else{
class JHtmlHikaselect extends JHTMLSelect{}
}
define('HIKASHOP_RESSOURCE_VERSION', str_replace('.',
'', $configClass->get('version')));
if($app->isAdmin()){
define('HIKASHOP_CONTROLLER',HIKASHOP_BACK.'controllers'.DS);
define('HIKASHOP_IMAGES','../media/'.HIKASHOP_COMPONENT.'/images/');
define('HIKASHOP_CSS','../media/'.HIKASHOP_COMPONENT.'/css/');
define('HIKASHOP_JS','../media/'.HIKASHOP_COMPONENT.'/js/');
$css_type = 'backend';
$doc->addScript(HIKASHOP_JS.'hikashop.js?v='.HIKASHOP_RESSOURCE_VERSION);
$doc->addStyleSheet(HIKASHOP_CSS.'menu.css?v='.HIKASHOP_RESSOURCE_VERSION);
if(HIKASHOP_J30 &&
$_REQUEST['option']==HIKASHOP_COMPONENT){
JHTML::_('behavior.framework');
JHtml::_('formbehavior.chosen', 'select');
}
}else{
define('HIKASHOP_CONTROLLER',HIKASHOP_FRONT.'controllers'.DS);
define('HIKASHOP_IMAGES',JURI::base(true).'/media/'.HIKASHOP_COMPONENT.'/images/');
define('HIKASHOP_CSS',JURI::base(true).'/media/'.HIKASHOP_COMPONENT.'/css/');
define('HIKASHOP_JS',JURI::base(true).'/media/'.HIKASHOP_COMPONENT.'/js/');
$css_type = 'frontend';
$doc->addScript(HIKASHOP_JS.'hikashop.js?v='.HIKASHOP_RESSOURCE_VERSION);
if(HIKASHOP_J30 &&
$configClass->get('bootstrap_forcechosen', 0)){
JHTML::_('behavior.framework');
JHtml::_('formbehavior.chosen', 'select');
}
}
$css =
$configClass->get('css_'.$css_type,'default');
if(!empty($css)){
$doc->addStyleSheet(
HIKASHOP_CSS.$css_type.'_'.$css.'.css?v='.HIKASHOP_RESSOURCE_VERSION);
}
if(!$app->isAdmin()){
$style = $configClass->get('css_style','');
if(!empty($style)){
$doc->addStyleSheet(
HIKASHOP_CSS.'style_'.$style.'.css?v='.HIKASHOP_RESSOURCE_VERSION);
}
}
if($lang->isRTL()){
$doc->addStyleSheet(
HIKASHOP_CSS.'rtl.css?v='.HIKASHOP_RESSOURCE_VERSION);
}
$override_path =
JLanguage::getLanguagePath(JPATH_ROOT).DS.'overrides'.DS.$lang->getTag().'.override.ini';
$lang->load(HIKASHOP_COMPONENT,JPATH_SITE);
if(file_exists($override_path)){
if(!HIKASHOP_J16){
$lang->_load($override_path,'override');
}elseif(HIKASHOP_J25){
$lang->publicLoadLanguage($override_path,'override');
}
}
define('HIKASHOP_NAME','HikaShop');
define('HIKASHOP_TEMPLATE',HIKASHOP_FRONT.'templates'.DS);
define('HIKASHOP_URL','http://www.hikashop.com/');
define('HIKASHOP_UPDATEURL',HIKASHOP_URL.'index.php?option=com_updateme&ctrl=update&task=');
define('HIKASHOP_HELPURL',HIKASHOP_URL.'index.php?option=com_updateme&ctrl=doc&component='.HIKASHOP_NAME.'&page=');
define('HIKASHOP_REDIRECT',HIKASHOP_URL.'index.php?option=com_updateme&ctrl=redirect&page=');
if (is_callable("date_default_timezone_set"))
date_default_timezone_set(@date_default_timezone_get());
if(!function_exists('bccomp')){
function bccomp($Num1,$Num2,$Scale=0) {
if(!preg_match("/^\+?(\d+)(\.\d+)?$/",$Num1,$Tmp1)||
!preg_match("/^\+?(\d+)(\.\d+)?$/",$Num2,$Tmp2))
return('0');
$Num1=ltrim($Tmp1[1],'0');
$Num2=ltrim($Tmp2[1],'0');
if(strlen($Num1)>strlen($Num2)) return(1);
else {
if(strlen($Num1)<strlen($Num2)) return(-1);
else {
$Dec1=isset($Tmp1[2])?rtrim(substr($Tmp1[2],1),'0'):'';
$Dec2=isset($Tmp2[2])?rtrim(substr($Tmp2[2],1),'0'):'';
if($Scale!=null) {
$Dec1=substr($Dec1,0,$Scale);
$Dec2=substr($Dec2,0,$Scale);
}
$DLen=max(strlen($Dec1),strlen($Dec2));
$Num1.=str_pad($Dec1,$DLen,'0');
$Num2.=str_pad($Dec2,$DLen,'0');
for($i=0;$i<strlen($Num1);$i++) {
if((int)$Num1{$i}>(int)$Num2{$i}) return(1);
else
if((int)$Num1{$i}<(int)$Num2{$i}) return(-1);
}
return(0);
}
}
}
}
html.php000064400000001656151161676250006243 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use RegularLabs\Library\Form as RL_Form;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
class RLHtml
{
static function selectlist(&$options, $name, $value, $id, $size = 0,
$multiple = 0, $simple = 0)
{
return RL_Form::selectList($options, $name, $value, $id, $size,
$multiple, $simple);
}
static function selectlistsimple(&$options, $name, $value, $id, $size
= 0, $multiple = 0)
{
return RL_Form::selectListSimple($options, $name, $value, $id, $size,
$multiple);
}
}
htmlfix.php000064400000001205151161676250006740 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use RegularLabs\Library\Html as RL_Html;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
class RLHtmlFix
{
public static function _($string)
{
return RL_Html::fix($string);
}
}
licenses.php000064400000001354151161676250007077 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use RegularLabs\Library\License as RL_License;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
class RLLicenses
{
public static function render($name, $check_pro = false)
{
return ! class_exists('RegularLabs\Library\License') ?
'' : RL_License::getMessage($name, $check_pro);
}
}
mobile_detect.php000064400000001232151161676250010064 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
class RLMobile_Detect extends \RegularLabs\Library\MobileDetect
{
public function isMac()
{
return $this->match('(Mac OS|Mac_PowerPC|Macintosh)');
}
}
parameters.php000064400000001236151161676250007434 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use RegularLabs\Library\Parameters as RL_Parameters;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
class RLParameters
{
public static function getInstance()
{
return RL_Parameters::getInstance();
}
}
protect.php000064400000014604151161676250006754 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use RegularLabs\Library\Document as RL_Document;
use RegularLabs\Library\Protect as RL_Protect;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
class RLProtect
{
public static function isProtectedPage($extension_alias = '',
$hastags = false, $exclude_formats = ['pdf'])
{
if ( ! class_exists('RegularLabs\Library\Protect'))
{
return true;
}
if (RL_Protect::isDisabledByUrl($extension_alias))
{
return true;
}
return class_exists('RegularLabs\Library\Protect') &&
RL_Protect::isRestrictedPage($hastags, $exclude_formats);
}
public static function isAdmin($block_login = false)
{
return class_exists('RegularLabs\Library\Document') &&
RL_Document::isAdmin($block_login);
}
public static function isEditPage()
{
return class_exists('RegularLabs\Library\Document') &&
RL_Document::isEditPage();
}
public static function isRestrictedComponent($restricted_components, $area
= 'component')
{
return class_exists('RegularLabs\Library\Protect') &&
RL_Protect::isRestrictedComponent($restricted_components, $area);
}
public static function isComponentInstalled($extension_alias)
{
return class_exists('RegularLabs\Library\Protect') &&
RL_Protect::isComponentInstalled($extension_alias);
}
public static function isSystemPluginInstalled($extension_alias)
{
return class_exists('RegularLabs\Library\Protect') &&
RL_Protect::isSystemPluginInstalled($extension_alias);
}
public static function getFormRegex($regex_format = false)
{
return class_exists('RegularLabs\Library\Protect') &&
RL_Protect::getFormRegex($regex_format);
}
public static function protectFields(&$string, $search_strings = [])
{
class_exists('RegularLabs\Library\Protect') &&
RL_Protect::protectFields($string, $search_strings);
}
public static function protectScripts(&$string)
{
class_exists('RegularLabs\Library\Protect') &&
RL_Protect::protectScripts($string);
}
public static function protectHtmlTags(&$string)
{
class_exists('RegularLabs\Library\Protect') &&
RL_Protect::protectHtmlTags($string);
}
public static function protectByRegex(&$string, $regex)
{
class_exists('RegularLabs\Library\Protect') &&
RL_Protect::protectByRegex($string, $regex);
}
public static function protectTags(&$string, $tags = [],
$include_closing_tags = true)
{
class_exists('RegularLabs\Library\Protect') &&
RL_Protect::protectTags($string, $tags, $include_closing_tags);
}
public static function unprotectTags(&$string, $tags = [],
$include_closing_tags = true)
{
class_exists('RegularLabs\Library\Protect') &&
RL_Protect::unprotectTags($string, $tags, $include_closing_tags);
}
public static function protectInString(&$string, $unprotected = [],
$protected = [])
{
class_exists('RegularLabs\Library\Protect') &&
RL_Protect::protectInString($string, $unprotected, $protected);
}
public static function unprotectInString(&$string, $unprotected = [],
$protected = [])
{
class_exists('RegularLabs\Library\Protect') &&
RL_Protect::unprotectInString($string, $unprotected, $protected);
}
public static function protectSourcerer(&$string)
{
class_exists('RegularLabs\Library\Protect') &&
RL_Protect::protectSourcerer($string);
}
public static function protectForm(&$string, $tags = [],
$include_closing_tags = true)
{
class_exists('RegularLabs\Library\Protect') &&
RL_Protect::protectForm($string, $tags, $include_closing_tags);
}
public static function unprotect(&$string)
{
class_exists('RegularLabs\Library\Protect') &&
RL_Protect::unprotect($string);
}
public static function convertProtectionToHtmlSafe(&$string)
{
class_exists('RegularLabs\Library\Protect') &&
RL_Protect::convertProtectionToHtmlSafe($string);
}
public static function unprotectHtmlSafe(&$string)
{
class_exists('RegularLabs\Library\Protect') &&
RL_Protect::unprotectHtmlSafe($string);
}
public static function protectString($string, $is_tag = false)
{
return class_exists('RegularLabs\Library\Protect') &&
RL_Protect::protectString($string, $is_tag);
}
public static function unprotectString($string, $is_tag = false)
{
return class_exists('RegularLabs\Library\Protect') &&
RL_Protect::unprotectString($string, $is_tag);
}
public static function protectTag($string)
{
return class_exists('RegularLabs\Library\Protect') &&
RL_Protect::protectTag($string);
}
public static function protectArray($array, $is_tag = false)
{
return class_exists('RegularLabs\Library\Protect') &&
RL_Protect::protectArray($array, $is_tag);
}
public static function unprotectArray($array, $is_tag = false)
{
return class_exists('RegularLabs\Library\Protect') &&
RL_Protect::unprotectArray($array, $is_tag);
}
public static function unprotectForm(&$string, $tags = [])
{
class_exists('RegularLabs\Library\Protect') &&
RL_Protect::unprotectForm($string, $tags);
}
public static function removeInlineComments(&$string, $name)
{
class_exists('RegularLabs\Library\Protect') &&
RL_Protect::removeInlineComments($string, $name);
}
public static function removePluginTags(&$string, $tags,
$character_start = '{', $character_end = '{',
$keep_content = true)
{
class_exists('RegularLabs\Library\Protect') &&
RL_Protect::removePluginTags($string, $tags, $character_start,
$character_end, $keep_content);
}
public static function removeFromHtmlTagContent(&$string, $tags,
$include_closing_tags = true, $html_tags = ['title'])
{
class_exists('RegularLabs\Library\Protect') &&
RL_Protect::removeFromHtmlTagContent($string, $tags, $include_closing_tags,
$html_tags);
}
public static function removeFromHtmlTagAttributes(&$string, $tags,
$attributes = 'ALL', $include_closing_tags = true)
{
class_exists('RegularLabs\Library\Protect') &&
RL_Protect::removeFromHtmlTagAttributes($string, $tags, $attributes,
$include_closing_tags);
}
public static function articlePassesSecurity(&$article,
$securtiy_levels = [])
{
return class_exists('RegularLabs\Library\Protect') &&
RL_Protect::articlePassesSecurity($article, $securtiy_levels);
}
public static function isJoomla3()
{
return true;
}
}
string.php000064400000000716151161676250006601 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
jimport('joomla.string.string');
abstract class RLString extends JString
{
}
tags.php000064400000016457151161676250006242 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class HikaShopTagsHelper {
var $_isCompatible = false;
var $structure = array(
'product' => array(
'table' => 'product',
'id' => 'product_id',
'name' => 'PRODUCT',
'router' =>
'hikashopTagRouteHelper::getProductRoute',
'mapping' => array(
array(
'type' => 'common',
'core_content_item_id' => 'product_id',
'core_title' => 'product_name',
'core_state' => 'product_published',
'core_alias' => 'product_alias',
'core_created_time' => 'product_created',
'core_modified_time' => 'product_modified',
'core_body' => 'product_description',
'core_hits' => 'product_hit',
'core_metakey' => 'product_keywords',
'core_metadesc' => 'product_meta_description',
)
)
)
);
function __construct() {
$this->_isCompatible = (version_compare(JVERSION, '3.1.4',
'>'));
}
function isCompatible() {
return $this->_isCompatible;
}
function addStructure($name, $data) {
if(isset($this->structure[$name]))
return;
$this->structure[$name] = $data;
}
function renderInput($values = null, $options = array()) {
if(!$this->_isCompatible)
return '';
$tags = array();
if(!empty($values)) {
foreach($values as $v) {
if(is_object($v))
$tags[] = $v->tag_id;
else
$tags[] = (int)$v;
}
}
if(empty($options['name']))
$options['name'] = 'tags';
if(empty($options['mode']))
$options['mode'] = 'ajax';
if(!isset($options['class']))
$options['class'] = 'inputbox span12 small';
if(!isset($options['multiple']))
$options['multiple'] = true;
$xmlConf = new SimpleXMLElement('<field
name="'.$options['name'].'"
type="tag"
mode="'.$options['mode'].'"
label=""
class="'.$options['class'].'"
multiple="'.($options['multiple']?'true':'false').'"></field>');
JFormHelper::loadFieldClass('tag');
$jform = new JForm('hikashop');
$fieldTag = new JFormFieldTag();
$fieldTag->setForm($jform);
$fieldTag->setup($xmlConf, $tags);
return $fieldTag->input;
}
function loadTags($type, $element) {
if(!isset($this->structure[$type]) || !$this->_isCompatible)
return false;
$structure = $this->structure[$type];
$component = 'hikashop';
if(!empty($structure['component']))
$component = $structure['component'];
$alias =
'com_'.$component.'.'.$structure['table'];
$id = $structure['id'];
$ret = false;
if(!empty($element->$id)) {
$tagsHelper = new JHelperTags();
$ret = $tagsHelper->getItemTags($alias, $element->$id, false);
}
return $ret;
}
function saveUCM($type, $element, $tags = array()) {
if(!isset($this->structure[$type]) || !$this->_isCompatible)
return false;
$structure = $this->structure[$type];
$component = 'hikashop';
if(!empty($structure['component']))
$component = $structure['component'];
$alias =
'com_'.$component.'.'.$structure['table'];
$tagsHelper = new JHelperTags();
$tagsHelper->typeAlias = $alias;
$tagsTable = new JHikaShopTagTable($structure, $element);
$tagsHelper->preStoreProcess($tagsTable);
$ret = $tagsHelper->postStoreProcess($tagsTable, $tags);
if($ret) {
$query = 'UPDATE #__ucm_content SET core_catid = 1 WHERE core_catid
= 0 AND core_type_alias = \'com_hikashop.product\'';
$db = JFactory::getDBO();
$db->setQuery($query);
$db->execute();
}
}
function deleteUCM($type, $elements) {
if(!isset($this->structure[$type]) || !$this->_isCompatible)
return false;
$structure = $this->structure[$type];
$component = 'hikashop';
if(!empty($structure['component']))
$component = $structure['component'];
$alias =
'com_'.$component.'.'.$structure['table'];
$tagsHelper = new JHelperTags();
$tagsHelper->typeAlias = $alias;
$id = $structure['id'];
$tagsTable = new JHikaShopTagTable($structure, null);
$ret = true;
foreach($elements as $element) {
if(empty($element)) continue;
$tagsTable->$id = $element;
if (!$tagsHelper->deleteTagData($tagsTable, $element))
$ret = false;
}
return $ret;
}
function initTags() {
if(!$this->_isCompatible)
return;
$db = JFactory::getDBO();
$mapping_keys =
array('core_content_item_id','core_title','core_state','core_alias','core_created_time','core_modified_time','core_body','core_hits','core_publish_up','core_publish_down','core_access','core_params','core_featured','core_metadata','core_language','core_images','core_urls','core_version','core_ordering','core_metakey','core_metadesc','core_catid','core_xreference','asset_id');
foreach($this->structure as $structure) {
$component = 'hikashop';
if(!empty($structure['component']))
$component = $structure['component'];
$name = ucfirst($component).'
'.JText::_($structure['name']);
$alias =
'com_'.$component.'.'.$structure['table'];
$contentType = new JTableContenttype($db);
$contentType->load(array('type_alias' => $alias));
if(substr($structure['table'], 0, 1) == '#')
$table = $structure['table'];
else
$table = hikashop_table($structure['table']);
$contentType->type_title = $name;
$contentType->type_alias = $alias;
$contentType->table = json_encode(array(
'special' =>
array('dbtable'=>$table,'key'=>$structure['id'],'type'=>$name,'prefix'=>'JTable','config'=>'array()'),
'common' =>
array('dbtable'=>'#__ucm_content','key'=>'ucm_id','type'=>'CoreContent','prefix'=>'JTable','config'=>'array()')
));
$mapping_data = array('common' =>
array(),'special' => array());
foreach($structure['mapping'] as $mapping) {
$type = @$mapping['type'];
if(empty($type) || !isset($mapping_data[$type]))
$type = 'common';
unset($mapping['type']);
$i = count($mapping_data[$type]);
$mapping_data[$type][$i] = array();
foreach($mapping_keys as $k) {
$mapping_data[$type][$i][$k] = 'null';
}
foreach($mapping as $key => $value) {
if(isset($mapping_data[$type][$i][$key]))
$mapping_data[$type][$i][$key] = $value;
}
}
if(empty($mapping_data['special']))
$mapping_data['special'][0] = array();
if(empty($mapping_data['common']))
$mapping_data['common'][0] = array();
$contentType->field_mappings = json_encode($mapping_data);
$contentType->router = '';
if(!empty($structure['router']))
$contentType->router = $structure['router'];
$contentType->store();
}
$query = 'UPDATE #__ucm_content SET core_catid = 1 WHERE core_catid
= 0 AND core_type_alias = \'com_hikashop.product\'';
$db->setQuery($query);
$db->execute();
}
}
class JHikaShopTagTable extends JTable {
function __construct($structure, $element) {
$db = JFactory::getDBO();
if(substr($structure['table'], 0, 1) == '#')
$table = $structure['table'];
else
$table = hikashop_table($structure['table']);
$mapping = reset($structure['mapping']);
if(!empty($element)) {
foreach($element as $k => $v) {
if(!in_array($k, $mapping))
continue;
$this->$k = $v;
}
}
parent::__construct($table, $structure['id'], $db);
}
}
text.php000064400000011417151161676250006257 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use RegularLabs\Library\Alias as RL_Alias;
use RegularLabs\Library\ArrayHelper as RL_Array;
use RegularLabs\Library\Date as RL_Date;
use RegularLabs\Library\Form as RL_Form;
use RegularLabs\Library\Html as RL_Html;
use RegularLabs\Library\HtmlTag as RL_HtmlTag;
use RegularLabs\Library\PluginTag as RL_PluginTag;
use RegularLabs\Library\RegEx as RL_RegEx;
use RegularLabs\Library\StringHelper as RL_String;
use RegularLabs\Library\Title as RL_Title;
use RegularLabs\Library\Uri as RL_Uri;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
class RLText
{
/* Date functions */
public static function fixDate(&$date)
{
$date = RL_Date::fix($date);
}
public static function fixDateOffset(&$date)
{
RL_Date::applyTimezone($date);
}
public static function dateToDateFormat($dateFormat)
{
return RL_Date::strftimeToDateFormat($dateFormat);
}
public static function dateToStrftimeFormat($dateFormat)
{
return RL_Date::dateToStrftimeFormat($dateFormat);
}
/* String functions */
public static function html_entity_decoder($string, $quote_style =
ENT_QUOTES, $charset = 'UTF-8')
{
return RL_String::html_entity_decoder($string, $quote_style, $charset);
}
public static function stringContains($haystacks, $needles)
{
return RL_String::contains($haystacks, $needles);
}
public static function is_alphanumeric($string)
{
return RL_String::is_alphanumeric($string);
}
public static function splitString($string, $delimiters = [], $max_length
= 10000, $maximize_parts = true)
{
return RL_String::split($string, $delimiters, $max_length,
$maximize_parts);
}
public static function strReplaceOnce($search, $replace, $string)
{
return RL_String::replaceOnce($search, $replace, $string);
}
/* Array functions */
public static function toArray($data, $separator = '')
{
return RL_Array::toArray($data, $separator);
}
public static function createArray($data, $separator = ',')
{
return RL_Array::toArray($data, $separator, true);
}
/* RegEx functions */
public static function regexReplace($pattern, $replacement, $string)
{
return RL_RegEx::replace($pattern, $replacement, $string);
}
public static function pregQuote($string = '', $delimiter =
'#')
{
return RL_RegEx::quote($string, $delimiter);
}
public static function pregQuoteArray($array = [], $delimiter =
'#')
{
return RL_RegEx::quoteArray($array, $delimiter);
}
/* Title functions */
public static function cleanTitle($string, $strip_tags = false,
$strip_spaces = true)
{
return RL_Title::clean($string, $strip_tags, $strip_spaces);
}
public static function createUrlMatches($titles = [])
{
return RL_Title::getUrlMatches($titles);
}
/* Alias functions */
public static function createAlias($string)
{
return RL_Alias::get($string);
}
/* Uri functions */
public static function getURI($hash = '')
{
return RL_Uri::get($hash);
}
/* Plugin Tag functions */
public static function getTagRegex($tags, $include_no_attributes = true,
$include_ending = true, $required_attributes = [])
{
return RL_PluginTag::getRegexTags($tags, $include_no_attributes,
$include_ending, $required_attributes);
}
/* HTML functions */
public static function getBody($html)
{
return RL_Html::getBody($html);
}
public static function getContentContainingSearches($string,
$start_searches = [], $end_searches = [], $start_offset = 1000, $end_offset
= null)
{
return RL_Html::getContentContainingSearches($string, $start_searches,
$end_searches, $start_offset, $end_offset);
}
public static function convertWysiwygToPlainText($string)
{
return RL_Html::convertWysiwygToPlainText($string);
}
public static function combinePTags(&$string)
{
RL_Html::combinePTags($string);
}
/* HTML Tag functions */
public static function combineTags($tag1, $tag2)
{
return RL_HtmlTag::combine($tag1, $tag2);
}
public static function getAttribute($key, $string)
{
return RL_HtmlTag::getAttributeValue($key, $string);
}
public static function getAttributes($string)
{
return RL_HtmlTag::getAttributes($string);
}
public static function combineAttributes($string1, $string2)
{
return RL_HtmlTag::combineAttributes($string1, $string2);
}
/* Form functions */
public static function prepareSelectItem($string, $published = 1, $type =
'', $remove_first = 0)
{
return RL_Form::prepareSelectItem($string, $published, $type,
$remove_first);
}
}
versions.php000064400000002413151161676250007137 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
/* @DEPRECATED */
defined('_JEXEC') or die;
use RegularLabs\Library\Version as RL_Version;
if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
}
class RLVersions
{
public static function getXMLVersion($alias, $urlformat = false, $type =
'component', $folder = 'system')
{
return ! class_exists('RegularLabs\Library\Version') ?
'' : RL_Version::get($alias, $type, $folder);
}
public static function getPluginXMLVersion($alias, $folder =
'system')
{
return ! class_exists('RegularLabs\Library\Version') ?
'' : RL_Version::getPluginVersion($alias, $folder);
}
public static function render($alias)
{
return ! class_exists('RegularLabs\Library\Version') ?
'' : RL_Version::getMessage($alias);
}
public static function getFooter($name, $copyright = 1)
{
return ! class_exists('RegularLabs\Library\Version') ?
'' : RL_Version::getFooter($name, $copyright);
}
}
html/directory.php000064400000002372151161755560010245 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_admin
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Utility class working with directory
*
* @since 1.6
*/
abstract class JHtmlDirectory
{
/**
* Method to generate a (un)writable message for directory
*
* @param boolean $writable is the directory writable?
*
* @return string html code
*/
public static function writable($writable)
{
if ($writable)
{
return '<span class="badge badge-success">' .
JText::_('COM_ADMIN_WRITABLE') . '</span>';
}
return '<span class="badge badge-important">' .
JText::_('COM_ADMIN_UNWRITABLE') . '</span>';
}
/**
* Method to generate a message for a directory
*
* @param string $dir the directory
* @param boolean $message the message
* @param boolean $visible is the $dir visible?
*
* @return string html code
*/
public static function message($dir, $message, $visible = true)
{
$output = $visible ? $dir : '';
if (empty($message))
{
return $output;
}
return $output . ' <strong>' . JText::_($message) .
'</strong>';
}
}
html/phpsetting.php000064400000003017151161755560010423 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_admin
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Utility class working with phpsetting
*
* @since 1.6
*/
abstract class JHtmlPhpSetting
{
/**
* Method to generate a boolean message for a value
*
* @param boolean $val is the value set?
*
* @return string html code
*/
public static function boolean($val)
{
return JText::_($val ? 'JON' : 'JOFF');
}
/**
* Method to generate a boolean message for a value
*
* @param boolean $val is the value set?
*
* @return string html code
*/
public static function set($val)
{
return JText::_($val ? 'JYES' : 'JNO');
}
/**
* Method to generate a string message for a value
*
* @param string $val a php ini value
*
* @return string html code
*/
public static function string($val)
{
return !empty($val) ? $val : JText::_('JNONE');
}
/**
* Method to generate an integer from a value
*
* @param string $val a php ini value
*
* @return string html code
*
* @deprecated 4.0 Use intval() or casting instead.
*/
public static function integer($val)
{
try
{
JLog::add(sprintf('%s() is deprecated. Use intval() or casting
instead.', __METHOD__), JLog::WARNING, 'deprecated');
}
catch (RuntimeException $exception)
{
// Informational log only
}
return (int) $val;
}
}
html/system.php000064400000001145151161755560007562 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_admin
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Utility class working with system
*
* @since 1.6
*/
abstract class JHtmlSystem
{
/**
* Method to generate a string message for a value
*
* @param string $val a php ini value
*
* @return string html code
*/
public static function server($val)
{
return !empty($val) ? $val : JText::_('COM_ADMIN_NA');
}
}
html/modules.php000064400000014177151161757730007720 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_modules
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* JHtml module helper class.
*
* @since 1.6
*/
abstract class JHtmlModules
{
/**
* Builds an array of template options
*
* @param integer $clientId The client id.
* @param string $state The state of the template.
*
* @return array
*/
public static function templates($clientId = 0, $state = '')
{
$options = array();
$templates = ModulesHelper::getTemplates($clientId, $state);
foreach ($templates as $template)
{
$options[] = JHtml::_('select.option', $template->element,
$template->name);
}
return $options;
}
/**
* Builds an array of template type options
*
* @return array
*/
public static function types()
{
$options = array();
$options[] = JHtml::_('select.option', 'user',
'COM_MODULES_OPTION_POSITION_USER_DEFINED');
$options[] = JHtml::_('select.option', 'template',
'COM_MODULES_OPTION_POSITION_TEMPLATE_DEFINED');
return $options;
}
/**
* Builds an array of template state options
*
* @return array
*/
public static function templateStates()
{
$options = array();
$options[] = JHtml::_('select.option', '1',
'JENABLED');
$options[] = JHtml::_('select.option', '0',
'JDISABLED');
return $options;
}
/**
* Returns a published state on a grid
*
* @param integer $value The state value.
* @param integer $i The row index
* @param boolean $enabled An optional setting for access control on
the action.
* @param string $checkbox An optional prefix for checkboxes.
*
* @return string The Html code
*
* @see JHtmlJGrid::state
* @since 1.7.1
*/
public static function state($value, $i, $enabled = true, $checkbox =
'cb')
{
$states = array(
1 => array(
'unpublish',
'COM_MODULES_EXTENSION_PUBLISHED_ENABLED',
'COM_MODULES_HTML_UNPUBLISH_ENABLED',
'COM_MODULES_EXTENSION_PUBLISHED_ENABLED',
true,
'publish',
'publish',
),
0 => array(
'publish',
'COM_MODULES_EXTENSION_UNPUBLISHED_ENABLED',
'COM_MODULES_HTML_PUBLISH_ENABLED',
'COM_MODULES_EXTENSION_UNPUBLISHED_ENABLED',
true,
'unpublish',
'unpublish',
),
-1 => array(
'unpublish',
'COM_MODULES_EXTENSION_PUBLISHED_DISABLED',
'COM_MODULES_HTML_UNPUBLISH_DISABLED',
'COM_MODULES_EXTENSION_PUBLISHED_DISABLED',
true,
'warning',
'warning',
),
-2 => array(
'publish',
'COM_MODULES_EXTENSION_UNPUBLISHED_DISABLED',
'COM_MODULES_HTML_PUBLISH_DISABLED',
'COM_MODULES_EXTENSION_UNPUBLISHED_DISABLED',
true,
'unpublish',
'unpublish',
),
);
return JHtml::_('jgrid.state', $states, $value, $i,
'modules.', $enabled, true, $checkbox);
}
/**
* Display a batch widget for the module position selector.
*
* @param integer $clientId The client ID.
* @param integer $state The state of the module (enabled,
unenabled, trashed).
* @param string $selectedPosition The currently selected position
for the module.
*
* @return string The necessary positions for the widget.
*
* @since 2.5
*/
public static function positions($clientId, $state = 1, $selectedPosition
= '')
{
JLoader::register('TemplatesHelper', JPATH_ADMINISTRATOR .
'/components/com_templates/helpers/templates.php');
$templates = array_keys(ModulesHelper::getTemplates($clientId,
$state));
$templateGroups = array();
// Add an empty value to be able to deselect a module position
$option = ModulesHelper::createOption();
$templateGroups[''] =
ModulesHelper::createOptionGroup('', array($option));
// Add positions from templates
$isTemplatePosition = false;
foreach ($templates as $template)
{
$options = array();
$positions = TemplatesHelper::getPositions($clientId, $template);
if (is_array($positions))
{
foreach ($positions as $position)
{
$text = ModulesHelper::getTranslatedModulePosition($clientId,
$template, $position) . ' [' . $position . ']';
$options[] = ModulesHelper::createOption($position, $text);
if (!$isTemplatePosition && $selectedPosition === $position)
{
$isTemplatePosition = true;
}
}
$options = ArrayHelper::sortObjects($options, 'text');
}
$templateGroups[$template] =
ModulesHelper::createOptionGroup(ucfirst($template), $options);
}
// Add custom position to options
$customGroupText = JText::_('COM_MODULES_CUSTOM_POSITION');
$editPositions = true;
$customPositions = ModulesHelper::getPositions($clientId,
$editPositions);
$templateGroups[$customGroupText] =
ModulesHelper::createOptionGroup($customGroupText, $customPositions);
return $templateGroups;
}
/**
* Get a select with the batch action options
*
* @return void
*/
public static function batchOptions()
{
// Create the copy/move options.
$options = array(
JHtml::_('select.option', 'c',
JText::_('JLIB_HTML_BATCH_COPY')),
JHtml::_('select.option', 'm',
JText::_('JLIB_HTML_BATCH_MOVE'))
);
echo JHtml::_('select.radiolist', $options,
'batch[move_copy]', '', 'value',
'text', 'm');
}
/**
* Method to get the field options.
*
* @param integer $clientId The client ID
*
* @return array The field option objects.
*
* @since 2.5
*/
public static function positionList($clientId = 0)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('DISTINCT(position) as value')
->select('position as text')
->from($db->quoteName('#__modules'))
->where($db->quoteName('client_id') . ' = ' .
(int) $clientId)
->order('position');
// Get the options.
$db->setQuery($query);
try
{
$options = $db->loadObjectList();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
}
// Pop the first item off the array if it's blank
if (count($options))
{
if (strlen($options[0]->text) < 1)
{
array_shift($options);
}
}
return $options;
}
}
modules.php000064400000021463151161757730006750 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_modules
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Modules component helper.
*
* @since 1.6
*/
abstract class ModulesHelper
{
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*/
public static function addSubmenu($vName)
{
// Not used in this component.
}
/**
* Gets a list of the actions that can be performed.
*
* @param integer $moduleId The module ID.
*
* @return JObject
*
* @deprecated 3.2 Use JHelperContent::getActions() instead
*/
public static function getActions($moduleId = 0)
{
// Log usage of deprecated function
try
{
JLog::add(
sprintf('%s() is deprecated. Use JHelperContent::getActions() with
new arguments order instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
// Get list of actions
if (empty($moduleId))
{
$result = JHelperContent::getActions('com_modules');
}
else
{
$result = JHelperContent::getActions('com_modules',
'module', $moduleId);
}
return $result;
}
/**
* Get a list of filter options for the state of a module.
*
* @return array An array of JHtmlOption elements.
*/
public static function getStateOptions()
{
// Build the filter options.
$options = array();
$options[] = JHtml::_('select.option', '1',
JText::_('JPUBLISHED'));
$options[] = JHtml::_('select.option', '0',
JText::_('JUNPUBLISHED'));
$options[] = JHtml::_('select.option', '-2',
JText::_('JTRASHED'));
$options[] = JHtml::_('select.option', '*',
JText::_('JALL'));
return $options;
}
/**
* Get a list of filter options for the application clients.
*
* @return array An array of JHtmlOption elements.
*/
public static function getClientOptions()
{
// Build the filter options.
$options = array();
$options[] = JHtml::_('select.option', '0',
JText::_('JSITE'));
$options[] = JHtml::_('select.option', '1',
JText::_('JADMINISTRATOR'));
return $options;
}
/**
* Get a list of modules positions
*
* @param integer $clientId Client ID
* @param boolean $editPositions Allow to edit the positions
*
* @return array A list of positions
*/
public static function getPositions($clientId, $editPositions = false)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('DISTINCT(position)')
->from('#__modules')
->where($db->quoteName('client_id') . ' = ' .
(int) $clientId)
->order('position');
$db->setQuery($query);
try
{
$positions = $db->loadColumn();
$positions = is_array($positions) ? $positions : array();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
return;
}
// Build the list
$options = array();
foreach ($positions as $position)
{
if (!$position && !$editPositions)
{
$options[] = JHtml::_('select.option', 'none',
JText::_('COM_MODULES_NONE'));
}
else
{
$options[] = JHtml::_('select.option', $position, $position);
}
}
return $options;
}
/**
* Return a list of templates
*
* @param integer $clientId Client ID
* @param string $state State
* @param string $template Template name
*
* @return array List of templates
*/
public static function getTemplates($clientId = 0, $state = '',
$template = '')
{
$db = JFactory::getDbo();
// Get the database object and a new query object.
$query = $db->getQuery(true);
// Build the query.
$query->select('element, name, enabled')
->from('#__extensions')
->where('client_id = ' . (int) $clientId)
->where('type = ' . $db->quote('template'));
if ($state != '')
{
$query->where('enabled = ' . $db->quote($state));
}
if ($template != '')
{
$query->where('element = ' . $db->quote($template));
}
// Set the query and load the templates.
$db->setQuery($query);
$templates = $db->loadObjectList('element');
return $templates;
}
/**
* Get a list of the unique modules installed in the client application.
*
* @param int $clientId The client id.
*
* @return array Array of unique modules
*/
public static function getModules($clientId)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('element AS value, name AS text')
->from('#__extensions as e')
->where('e.client_id = ' . (int) $clientId)
->where('type = ' . $db->quote('module'))
->join('LEFT', '#__modules as m ON m.module=e.element
AND m.client_id=e.client_id')
->where('m.module IS NOT NULL')
->group('element,name');
$db->setQuery($query);
$modules = $db->loadObjectList();
$lang = JFactory::getLanguage();
foreach ($modules as $i => $module)
{
$extension = $module->value;
$path = $clientId ? JPATH_ADMINISTRATOR : JPATH_SITE;
$source = $path . "/modules/$extension";
$lang->load("$extension.sys", $path, null, false, true)
|| $lang->load("$extension.sys", $source, null, false,
true);
$modules[$i]->text = JText::_($module->text);
}
$modules = ArrayHelper::sortObjects($modules, 'text', 1, true,
true);
return $modules;
}
/**
* Get a list of the assignment options for modules to menus.
*
* @param int $clientId The client id.
*
* @return array
*/
public static function getAssignmentOptions($clientId)
{
$options = array();
$options[] = JHtml::_('select.option', '0',
'COM_MODULES_OPTION_MENU_ALL');
$options[] = JHtml::_('select.option', '-',
'COM_MODULES_OPTION_MENU_NONE');
if ($clientId == 0)
{
$options[] = JHtml::_('select.option', '1',
'COM_MODULES_OPTION_MENU_INCLUDE');
$options[] = JHtml::_('select.option', '-1',
'COM_MODULES_OPTION_MENU_EXCLUDE');
}
return $options;
}
/**
* Return a translated module position name
*
* @param integer $clientId Application client id 0: site | 1: admin
* @param string $template Template name
* @param string $position Position name
*
* @return string Return a translated position name
*
* @since 3.0
*/
public static function getTranslatedModulePosition($clientId, $template,
$position)
{
// Template translation
$lang = JFactory::getLanguage();
$path = $clientId ? JPATH_ADMINISTRATOR : JPATH_SITE;
$loaded = $lang->getPaths('tpl_' . $template .
'.sys');
// Only load the template's language file if it hasn't been
already
if (!$loaded)
{
$lang->load('tpl_' . $template . '.sys', $path,
null, false, false)
|| $lang->load('tpl_' . $template . '.sys', $path
. '/templates/' . $template, null, false, false)
|| $lang->load('tpl_' . $template . '.sys',
$path, $lang->getDefault(), false, false)
|| $lang->load('tpl_' . $template . '.sys', $path
. '/templates/' . $template, $lang->getDefault(), false,
false);
}
$langKey = strtoupper('TPL_' . $template .
'_POSITION_' . $position);
$text = JText::_($langKey);
// Avoid untranslated strings
if (!self::isTranslatedText($langKey, $text))
{
// Modules component translation
$langKey = strtoupper('COM_MODULES_POSITION_' . $position);
$text = JText::_($langKey);
// Avoid untranslated strings
if (!self::isTranslatedText($langKey, $text))
{
// Try to humanize the position name
$text = ucfirst(preg_replace('/^' . $template .
'\-/', '', $position));
$text = ucwords(str_replace(array('-', '_'), '
', $text));
}
}
return $text;
}
/**
* Check if the string was translated
*
* @param string $langKey Language file text key
* @param string $text The "translated" text to be
checked
*
* @return boolean Return true for translated text
*
* @since 3.0
*/
public static function isTranslatedText($langKey, $text)
{
return $text !== $langKey;
}
/**
* Create and return a new Option
*
* @param string $value The option value [optional]
* @param string $text The option text [optional]
*
* @return object The option as an object (stdClass instance)
*
* @since 3.0
*/
public static function createOption($value = '', $text =
'')
{
if (empty($text))
{
$text = $value;
}
$option = new stdClass;
$option->value = $value;
$option->text = $text;
return $option;
}
/**
* Create and return a new Option Group
*
* @param string $label Value and label for group [optional]
* @param array $options Array of options to insert into group
[optional]
*
* @return array Return the new group as an array
*
* @since 3.0
*/
public static function createOptionGroup($label = '', $options =
array())
{
$group = array();
$group['value'] = $label;
$group['text'] = $label;
$group['items'] = $options;
return $group;
}
}
xml.php000064400000002341151161757730006072 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_modules
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
try
{
JLog::add('ModulesHelperXML is deprecated. Do not use.',
JLog::WARNING, 'deprecated');
}
catch (RuntimeException $exception)
{
// Informational log only
}
/**
* Helper for parse XML module files
*
* @since 1.5
* @deprecated 3.2 Do not use.
*/
class ModulesHelperXML
{
/**
* Parse the module XML file
*
* @param array &$rows XML rows
*
* @return void
*
* @since 1.5
*
* @deprecated 3.2 Do not use.
*/
public function parseXMLModuleFile(&$rows)
{
foreach ($rows as $i => $row)
{
if ($row->module == '')
{
$rows[$i]->name = 'custom';
$rows[$i]->module = 'custom';
$rows[$i]->descrip = 'Custom created module, using Module
Manager New function';
}
else
{
$data = JInstaller::parseXMLInstallFile($row->path . '/' .
$row->file);
if ($data['type'] == 'module')
{
$rows[$i]->name = $data['name'];
$rows[$i]->descrip = $data['description'];
}
}
}
}
}
api_cert_chain.crt000064400000022461151162107730010216 0ustar00-----BEGIN
CERTIFICATE-----
MIIDgzCCAuygAwIBAgIQJUuKhThCzONY+MXdriJupDANBgkqhkiG9w0BAQUFADBf
MQswCQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xNzA1BgNVBAsT
LkNsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkw
HhcNOTcwNDE3MDAwMDAwWhcNMTExMDI0MjM1OTU5WjCBujEfMB0GA1UEChMWVmVy
aVNpZ24gVHJ1c3QgTmV0d29yazEXMBUGA1UECxMOVmVyaVNpZ24sIEluYy4xMzAx
BgNVBAsTKlZlcmlTaWduIEludGVybmF0aW9uYWwgU2VydmVyIENBIC0gQ2xhc3Mg
MzFJMEcGA1UECxNAd3d3LnZlcmlzaWduLmNvbS9DUFMgSW5jb3JwLmJ5IFJlZi4g
TElBQklMSVRZIExURC4oYyk5NyBWZXJpU2lnbjCBnzANBgkqhkiG9w0BAQEFAAOB
jQAwgYkCgYEA2IKA6NYZAn0fhRg5JaJlK+G/1AXTvOY2O6rwTGxbtueqPHNFVbLx
veqXQu2aNAoV1Klc9UAl3dkHwTKydWzEyruj/lYncUOqY/UwPpMo5frxCTvzt01O
OfdcSVq4wR3Tsor+cDCVQsv+K1GLWjw6+SJPkLICp1OcTzTnqwSye28CAwEAAaOB
4zCB4DAPBgNVHRMECDAGAQH/AgEAMEQGA1UdIAQ9MDswOQYLYIZIAYb4RQEHAQEw
KjAoBggrBgEFBQcCARYcaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL0NQUzA0BgNV
HSUELTArBggrBgEFBQcDAQYIKwYBBQUHAwIGCWCGSAGG+EIEAQYKYIZIAYb4RQEI
ATALBgNVHQ8EBAMCAQYwEQYJYIZIAYb4QgEBBAQDAgEGMDEGA1UdHwQqMCgwJqAk
oCKGIGh0dHA6Ly9jcmwudmVyaXNpZ24uY29tL3BjYTMuY3JsMA0GCSqGSIb3DQEB
BQUAA4GBAAgB7ORolANC8XPxI6I63unx2sZUxCM+hurPajozq+qcBBQHNgYL+Yhv
1RPuKSvD5HKNRO3RrCAJLeH24RkFOLA9D59/+J4C3IYChmFOJl9en5IeDCSk9dBw
E88mw0M9SR2egi5SX7w+xmYpAY5Okiy8RnUDgqxz6dl+C2fvVFIa
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG
A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz
cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2
MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV
BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt
YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN
ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE
BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is
I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G
CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do
lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc
AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIDAjCCAmsCEH3Z/gfPqB63EHln+6eJNMYwDQYJKoZIhvcNAQEFBQAwgcExCzAJ
BgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xh
c3MgMyBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcy
MTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3Jp
emVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMB4X
DTk4MDUxODAwMDAwMFoXDTI4MDgwMTIzNTk1OVowgcExCzAJBgNVBAYTAlVTMRcw
FQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMg
UHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEo
YykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5
MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMIGfMA0GCSqGSIb3DQEB
AQUAA4GNADCBiQKBgQDMXtERXVxp0KvTuWpMmR9ZmDCOFoUgRm1HP9SFIIThbbP4
pO0M8RcPO/mn+SXXwc+EY/J8Y8+iR/LGWzOOZEAEaMGAuWQcRXfH2G71lSk8UOg0
13gfqLptQ5GVj0VXXn7F+8qkBOvqlzdUMG+7AUcyM83cV5tkaWH4mx0ciU9cZwID
AQABMA0GCSqGSIb3DQEBBQUAA4GBAFFNzb5cy5gZnBWyATl4Lk0PZ3BwmcYQWpSk
U01UbSuvDV1Ai2TT1+7eVmGSX6bEHRBhNtMsJzzoKQm5EWR0zLVznxxIqbxhAe7i
F6YM40AIOw7n60RzKprxaZLvcRTDOaxxp5EJb+RxBrO6WVcmeQD2+A2iMzAo1KpY
oJ2daZH9
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIFjDCCBHSgAwIBAgIQVeuz+EgDzKxFsKnpA78ETzANBgkqhkiG9w0BAQsFADB3
MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRpb24xHzAd
BgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxKDAmBgNVBAMTH1N5bWFudGVj
IENsYXNzIDMgRVYgU1NMIENBIC0gRzMwHhcNMTUwOTE4MDAwMDAwWhcNMTcwOTI5
MjM1OTU5WjCCARcxEzARBgsrBgEEAYI3PAIBAxMCVVMxGTAXBgsrBgEEAYI3PAIB
AgwIRGVsYXdhcmUxHTAbBgNVBA8TFFByaXZhdGUgT3JnYW5pemF0aW9uMRAwDgYD
VQQFEwczMDE0MjY3MQswCQYDVQQGEwJVUzETMBEGA1UEEQwKOTUxMzEtMjAyMTET
MBEGA1UECAwKQ2FsaWZvcm5pYTERMA8GA1UEBwwIU2FuIEpvc2UxFjAUBgNVBAkM
DTIyMTEgTiAxc3QgU3QxFTATBgNVBAoMDFBheVBhbCwgSW5jLjEaMBgGA1UECwwR
UGF5UGFsIFByb2R1Y3Rpb24xHzAdBgNVBAMMFnd3dy5zYW5kYm94LnBheXBhbC5j
b20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDOQlgP1/OgAQ7TLB1A
1Kwr6a3EIfZRKl5HT9FmwR5sliGJBzQC4UdjUkCOQYBqzCwFrvc486aVTtAvE2JK
PVP1OertRT7rQH8Oq/d60X2Cv32PmvwO0NnPsiQWwEKtqAvfHOUZf+4nfp3LxfGa
gb4k4Nbeq/PegcArIXlGC06M85Urz3b10JqitnWgiHDRYWzh9PlHnPf6m/zVtLQw
GYZxu11Gtq8wB5Ot4q2vlQTf1WcR4Li5HmAFIVHYXgjNLpfdI3PMNkjTiZEgn1AT
kqkxyxzTt9V4YnwM7JEvygBpXRJKRHGYy52O35uKNdO+8J27HNX8kWnSHI1ogpC+
dezbAgMBAAGjggFwMIIBbDAhBgNVHREEGjAYghZ3d3cuc2FuZGJveC5wYXlwYWwu
Y29tMAkGA1UdEwQCMAAwDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUF
BwMBBggrBgEFBQcDAjBmBgNVHSAEXzBdMFsGC2CGSAGG+EUBBxcGMEwwIwYIKwYB
BQUHAgEWF2h0dHBzOi8vZC5zeW1jYi5jb20vY3BzMCUGCCsGAQUFBwICMBkaF2h0
dHBzOi8vZC5zeW1jYi5jb20vcnBhMB8GA1UdIwQYMBaAFAFZq+fdOgtZpmRj1s8g
B1fVkedqMCsGA1UdHwQkMCIwIKAeoByGGmh0dHA6Ly9zci5zeW1jYi5jb20vc3Iu
Y3JsMFcGCCsGAQUFBwEBBEswSTAfBggrBgEFBQcwAYYTaHR0cDovL3NyLnN5bWNk
LmNvbTAmBggrBgEFBQcwAoYaaHR0cDovL3NyLnN5bWNiLmNvbS9zci5jcnQwDQYJ
KoZIhvcNAQELBQADggEBACEZZKMKatEKSSuTaBF+qeRP2CqqJLZefggNLXDM8hNb
mh05RQ95FSqGQMSKprbDNWxYqPERee7R2wvW4egmM0kmtU+PWlm/W1DaSE0E/5QN
6gx9Is0wC7DF4W3USGT8M4Itp225wf9doh2d3+ACw19xHfmri0fQiogrPSo3U0/X
tD7QKpFNlrgpXH5Xz5qReiJeZnbI89dw1ILEdDjni/OCZmYGUpfZS2vY4eqR0w+s
0NWsfHzijXkJug2nrDjXJAmZAsagwR8acYOI8L86hJP8GC554z6TiuA6Of2GxVzx
ngM1+KlNBGhY5NRTEJG10KcQklDH6nMdoR1ZjajM7mw=
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIGgzCCBWugAwIBAgIQDwdzlHG9OSV38gstjQDDAjANBgkqhkiG9w0BAQsFADB+
MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRpb24xHzAd
BgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxLzAtBgNVBAMTJlN5bWFudGVj
IENsYXNzIDMgU2VjdXJlIFNlcnZlciBDQSAtIEc0MB4XDTE2MDExMzAwMDAwMFoX
DTE4MDExMzIzNTk1OVowgYkxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9y
bmlhMREwDwYDVQQHDAhTYW4gSm9zZTEVMBMGA1UECgwMUGF5UGFsLCBJbmMuMRow
GAYDVQQLDBFQYXlQYWwgUHJvZHVjdGlvbjEfMB0GA1UEAwwWYXBpLnNhbmRib3gu
cGF5cGFsLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOH6oHmU
rKtjVANXICp/J2CeBpl5SBafoZKUBgU7tcAzXPUASoQRlMOAoUKkO8bKX7xRynoC
a9Y4ZWLrKamFu/ovo9cPTYlpslj9kuNKqtCZM0TBwdCscYsd86RHgskjR4lCVQ+I
M9WbJ1DhLjiZh2c30VenVH4Hc86j+OakT/eLUvYMe/B1hrri/Ml8bHB34Gq+AszG
tt2dY7PL3BGJ4GOI4LebRYVqp4uFpq+PxRj+VSPyXytP7x/6r0gGR2R8gcnu/JnR
tdtOrAiq5lXgLxmBzmYvhBFbLvrMjV/Xo4ch6cL4pG5Wz3u9JL3ux+06FMoj4Ret
7k7hQFKj8sdO0EkCAwEAAaOCAu8wggLrMCEGA1UdEQQaMBiCFmFwaS5zYW5kYm94
LnBheXBhbC5jb20wCQYDVR0TBAIwADAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYw
FAYIKwYBBQUHAwEGCCsGAQUFBwMCMGEGA1UdIARaMFgwVgYGZ4EMAQICMEwwIwYI
KwYBBQUHAgEWF2h0dHBzOi8vZC5zeW1jYi5jb20vY3BzMCUGCCsGAQUFBwICMBka
F2h0dHBzOi8vZC5zeW1jYi5jb20vcnBhMB8GA1UdIwQYMBaAFF9gz2GQVd+EQxSK
YCqy9Xr0QxjvMCsGA1UdHwQkMCIwIKAeoByGGmh0dHA6Ly9zcy5zeW1jYi5jb20v
c3MuY3JsMFcGCCsGAQUFBwEBBEswSTAfBggrBgEFBQcwAYYTaHR0cDovL3NzLnN5
bWNkLmNvbTAmBggrBgEFBQcwAoYaaHR0cDovL3NzLnN5bWNiLmNvbS9zcy5jcnQw
ggGABgorBgEEAdZ5AgQCBIIBcASCAWwBagB2AN3rHSt6DU+mIIuBrYFocH4ujp0B
1VyIjT0RxM227L7MAAABUjz96joAAAQDAEcwRQIgVXzp/eXsIa/NHqvPNTSaekkp
f4LsU1ROrO3HOO5S7CECIQCff43664s3xgZkoeUbs6Nq2bcJZ2uusS2M8enkLNi6
agB3AKS5CZC0GFgUh7sTosxncAo8NZgE+RvfuON3zQ7IDdwQAAABUjz96mIAAAQD
AEgwRgIhAPwlv+Cntqwg0kMbGqJenRWycWh0hLyx2Rf5PPc1dPDJAiEAyd4aZNSa
GE3Jywug1EH8Hk6KKwun+tnqFsh/EvOWyXsAdwBo9pj4H2SCvjqM7rkoHUz8cVFd
Z5PURNEKZ6y7T0/7xAAAAVI8/ephAAAEAwBIMEYCIQCyFfphtFM9PPQ5qTQRkevU
6Rj0QOPBKNQPV7KM+4HvmQIhAKzk6vYTuwWAU6QNtWbk5G+iVi3B2zu2VGl0H+4k
d0NqMA0GCSqGSIb3DQEBCwUAA4IBAQAvKbOlMtw+W/c8sFDwIVFY30so0M7TgQIU
mWJBqk7HVFrEvP1SUR3vIkm11KnDzXPtdMIjem5qCdiiZKhGx+rwy7SCM+5KDquw
4McxgnpbTdwUCnh83nm8MsX/nJBBauqtNyn3sKuTR22Ut1lsa/XGD8+IG4c0DXi8
a1FSD9+WlgV2Kl29hllT33bb0+2+hujNHKPjfZnQvTsZfU5kzK2nkrl8zg8Rh2ad
ZjndRbNssIVB3Pk8VuoQ+o/bVFFAENKKKxdCHKqhSR0FHXYKjlMHs3JpMzTjE6NX
8sC6qaMrouLB/zwKJGmHYtcxRs5mx7kcNo1jyyChwtfNaudC8Sb4
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIFKzCCBBOgAwIBAgIQHTg+mj/CNqGgPmqLTmDqPDANBgkqhkiG9w0BAQUFADCB
tTELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL
ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTswOQYDVQQLEzJUZXJtcyBvZiB1c2Ug
YXQgaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JwYSAoYykxMDEvMC0GA1UEAxMm
VmVyaVNpZ24gQ2xhc3MgMyBTZWN1cmUgU2VydmVyIENBIC0gRzMwHhcNMTUwNDE1
MDAwMDAwWhcNMTYwNDAxMjM1OTU5WjCBgTELMAkGA1UEBhMCVVMxEzARBgNVBAgT
CkNhbGlmb3JuaWExETAPBgNVBAcUCFNhbiBKb3NlMRUwEwYDVQQKFAxQYXlQYWws
IEluYy4xGjAYBgNVBAsUEVBheVBhbCBQcm9kdWN0aW9uMRcwFQYDVQQDFA5hcGku
cGF5cGFsLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMTY3N4l
KXBAjsYjJc0WSissckwSVAofjIkhkoTwenXrsjs+gv9i4Mxx43Xt6sDURJBRNaUN
QviCJilZ+uqba7ngPjQDG6NqvSE2NT9rKgQMo1pfebIM2E8lVWDqNQ3C6UzHRhyV
X16ubMLftacGiWjwUzB22VdJLoWhRcOoWAXU5RhYJlg4ql9wRHrlHXaxnFdbdPbY
aSyprOcEZNecxXurEgy//1ojc8C7I1bhN/SeLwRenH+Dj6XSXFC2OoAIygXW/yjs
nCBxwL/IHwBhXe4XLWLqLlGe0aV5Frbo69g/bf4jVoccAwaocrTcSqDEH54KCsE7
JghouW3uNaqd8/UCAwEAAaOCAWcwggFjMBkGA1UdEQQSMBCCDmFwaS5wYXlwYWwu
Y29tMAkGA1UdEwQCMAAwDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUF
BwMBBggrBgEFBQcDAjBlBgNVHSAEXjBcMFoGCmCGSAGG+EUBBzYwTDAjBggrBgEF
BQcCARYXaHR0cHM6Ly9kLnN5bWNiLmNvbS9jcHMwJQYIKwYBBQUHAgIwGRoXaHR0
cHM6Ly9kLnN5bWNiLmNvbS9ycGEwHwYDVR0jBBgwFoAUDURcFlNEwYJ+HSCrJfQB
Y9i+eaUwKwYDVR0fBCQwIjAgoB6gHIYaaHR0cDovL3NkLnN5bWNiLmNvbS9zZC5j
cmwwVwYIKwYBBQUHAQEESzBJMB8GCCsGAQUFBzABhhNodHRwOi8vc2Quc3ltY2Qu
Y29tMCYGCCsGAQUFBzAChhpodHRwOi8vc2Quc3ltY2IuY29tL3NkLmNydDANBgkq
hkiG9w0BAQUFAAOCAQEAXFGDySlKXOx6nZNRnC764rYMm20C1neLh8XxCEEl9UP5
mGSgOY0ZFH4mbfLIEstZcj4tlBEJvc+s9bzWIli1d2ouSoZ8oEd73hL3elREc3BD
Tm8xvrJdAOmcu5YKd4BP6RGBlUzlirXcgmi2jxfr1vbIh2wUUkVG9GNVNvj7uhHu
d1V4cVpnZ30caTB9YYlPVo5qG5Cbzkuw76oZmxinr7ppFck3v3GkRchl77TL2w4I
X9nL7mbui2drNpsiCGjlc4wea2kXdXAj1w5LwHqkxFfjQyHvUCJFpx0hnRzEeVgT
x5DsDzb8RYgFgC3M+ZgV7SQh+Bjr+LTEAkFRogGFMA==
-----END CERTIFICATE-----
ipnlistener.php000064400000026564151162107730007631 0ustar00<?php
/**
* PayPal IPN Listener
*
* A class to listen for and handle Instant Payment Notifications (IPN)
from
* the PayPal server.
*
* https://github.com/Quixotix/PHP-PayPal-IPN
*
* @package PHP-PayPal-IPN
* @author Micah Carrick
* @copyright (c) 2012 - Micah Carrick
* @version 2.1.0
*/
defined('_JEXEC') or die;
//jimport('joomla.log.log');
//JLog::addLogger( array('text_file' =>
'com_phocacart_error_log.php'), JLog::ALL,
array('com_phocacart'));
if (! class_exists('PhocacartLoader')) {
require_once(
JPATH_ADMINISTRATOR.'/components/com_phocacart/libraries/loader.php');
}
phocacartimport('phocacart.utils.log');
class PhocacartPaypalStandardIpnListener {
/**
* If true, the recommended cURL PHP library is used to send the post
back
* to PayPal. If flase then fsockopen() is used. Default true.
*
* @var boolean
*/
public $use_curl = true;
/**
* If true, explicitly sets cURL to use SSL version 3. Use this if
cURL
* is compiled with GnuTLS SSL.
*
* @var boolean
*/
public $force_ssl_v3 = false;
/**
* If true, cURL will use the CURLOPT_FOLLOWLOCATION to follow any
* "Location: ..." headers in the response.
*
* @var boolean
*/
public $follow_location = false;
/**
* If true, an SSL secure connection (port 443) is used for the post
back
* as recommended by PayPal. If false, a standard HTTP (port 80)
connection
* is used. Default true.
*
* @var boolean
*/
public $use_ssl = true;
/**
* If true, the paypal sandbox URI www.sandbox.paypal.com is used for
the
* post back. If false, the live URI www.paypal.com is used. Default
false.
*
* @var boolean
*/
public $use_sandbox = false;
/**
* The amount of time, in seconds, to wait for the PayPal server to
respond
* before timing out. Default 30 seconds.
*
* @var int
*/
public $timeout = 30;
private $post_data = array();
private $post_uri = '';
private $response_status = '';
private $response = '';
const PAYPAL_HOST = 'www.paypal.com';
const SANDBOX_HOST = 'www.sandbox.paypal.com';
private $params = array();
public function setParams($p) {
$this->params = $p;
}
/**
* Post Back Using cURL
*
* Sends the post back to PayPal using the cURL library. Called by
* the processIpn() method if the use_curl property is true. Throws an
* exception if the post fails. Populates the response,
response_status,
* and post_uri properties on success.
*
* @param string The post data as a URL encoded string
*/
protected function curlPost($encoded_data) {
if ($this->use_ssl) {
$uri =
'https://'.$this->getPaypalHost().'/cgi-bin/webscr';
$this->post_uri = $uri;
} else {
$uri =
'http://'.$this->getPaypalHost().'/cgi-bin/webscr';
$this->post_uri = $uri;
}
$ch = curl_init();
if ($this->params['verify_ssl'] == 1) {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
} else {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
}
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO,
dirname(__FILE__)."/api_cert_chain.crt");
curl_setopt($ch, CURLOPT_URL, $uri);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded_data);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,
$this->follow_location);
curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
if ($this->force_ssl_v3) {
curl_setopt($ch, CURLOPT_SSLVERSION, 4); //Modified from 3 to 4
} else {
curl_setopt($ch, CURLOPT_SSLVERSION, 0);
}
$this->response = curl_exec($ch);
$this->response_status = strval(curl_getinfo($ch,
CURLINFO_HTTP_CODE));
if ($this->response === false || $this->response_status ==
'0') {
$errno = curl_errno($ch);
$errstr = curl_error($ch);
//JLog::add('Paypal Standard: '."cURL error: [$errno]
$errstr", JLog::WARNING, 'com_phocacart');
PhocacartLog::add(1, 'Payment - PayPal Standard - ERROR', 0,
"cURL error: [$errno] $errstr");
throw new Exception("cURL error: [$errno] $errstr");
}
}
/**
* Post Back Using fsockopen()
*
* Sends the post back to PayPal using the fsockopen() function.
Called by
* the processIpn() method if the use_curl property is false. Throws
an
* exception if the post fails. Populates the response,
response_status,
* and post_uri properties on success.
*
* @param string The post data as a URL encoded string
*/
protected function fsockPost($encoded_data) {
if ($this->use_ssl) {
$uri = 'ssl://'.$this->getPaypalHost();
$port = '443';
$this->post_uri = $uri.'/cgi-bin/webscr';
} else {
$uri = $this->getPaypalHost(); // no "http://" in
call to fsockopen()
$port = '80';
$this->post_uri =
'http://'.$uri.'/cgi-bin/webscr';
}
$fp = fsockopen($uri, $port, $errno, $errstr, $this->timeout);
if (!$fp) {
// fsockopen error
//JLog::add('Paypal Standard: '."fsockopen error:
[$errno] $errstr", JLog::WARNING, 'com_phocacart');
PhocacartLog::add(1, 'Payment - PayPal Standard - ERROR', 0,
"fsockopen error: [$errno] $errstr");
throw new Exception("fsockopen error: [$errno]
$errstr");
}
$header = "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Host:
".$this->getPaypalHost()."\r\n";
$header .= "Content-Type:
application/x-www-form-urlencoded\r\n";
$header .= "Content-Length:
".strlen($encoded_data)."\r\n";
$header .= "Connection: Close\r\n\r\n";
fputs($fp, $header.$encoded_data."\r\n\r\n");
while(!feof($fp)) {
if (empty($this->response)) {
// extract HTTP status from first line
$this->response .= $status = fgets($fp, 1024);
$this->response_status = trim(substr($status, 9, 4));
} else {
$this->response .= fgets($fp, 1024);
}
}
fclose($fp);
}
private function getPaypalHost() {
if ($this->use_sandbox) return self::SANDBOX_HOST;
else return self::PAYPAL_HOST;
}
/**
* Get POST URI
*
* Returns the URI that was used to send the post back to PayPal. This
can
* be useful for troubleshooting connection problems. The default URI
* would be
"ssl://www.sandbox.paypal.com:443/cgi-bin/webscr"
*
* @return string
*/
public function getPostUri() {
return $this->post_uri;
}
/**
* Get Response
*
* Returns the entire response from PayPal as a string including all
the
* HTTP headers.
*
* @return string
*/
public function getResponse() {
return $this->response;
}
/**
* Get Response Status
*
* Returns the HTTP response status code from PayPal. This should be
"200"
* if the post back was successful.
*
* @return string
*/
public function getResponseStatus() {
return $this->response_status;
}
/**
* Get Text Report
*
* Returns a report of the IPN transaction in plain text format. This
is
* useful in emails to order processors and system administrators.
Override
* this method in your own class to customize the report.
*
* @return string
*/
public function getTextReport() {
$r = '';
// date and POST url
for ($i=0; $i<80; $i++) { $r .= '-'; }
$r .= "\n[".date('m/d/Y g:i A').'] -
'.$this->getPostUri();
if ($this->use_curl) $r .= " (curl)\n";
else $r .= " (fsockopen)\n";
// HTTP Response
for ($i=0; $i<80; $i++) { $r .= '-'; }
$r .= "\n{$this->getResponse()}\n";
// POST vars
for ($i=0; $i<80; $i++) { $r .= '-'; }
$r .= "\n";
foreach ($this->post_data as $key => $value) {
$r .= str_pad($key, 25)."$value\n";
}
$r .= "\n\n";
return $r;
}
/**
* Process IPN
*
* Handles the IPN post back to PayPal and parsing the response. Call
this
* method from your IPN listener script. Returns true if the response
came
* back as "VERIFIED", false if the response came back
"INVALID", and
* throws an exception if there is an error.
*
* @param array
*
* @return boolean
*/
public function processIpn($post_data=null) {
$encoded_data = 'cmd=_notify-validate';
if ($post_data === null) {
// use raw POST data
if (!empty($_POST)) {// FOR JED CHECKERS: POST IS NEEDED HERE
$this->post_data = $_POST;// FOR JED CHECKERS: POST IS
NEEDED HERE
$encoded_data .=
'&'.file_get_contents('php://input');
} else {
//JLog::add('Paypal Standard: '."No POST data
found.", JLog::WARNING, 'com_phocacart');
PhocacartLog::add(1, 'Payment - PayPal Standard - ERROR', 0,
"No POST data found.");
throw new Exception("No POST data found.");
}
} else {
// use provided data array
$this->post_data = $post_data;
foreach ($this->post_data as $key => $value) {
$encoded_data .= "&$key=".urlencode($value);
}
}
if ($this->use_curl) $this->curlPost($encoded_data);
else $this->fsockPost($encoded_data);
if (strpos($this->response_status, '200') === false) {
//JLog::add('Paypal Standard: '."Invalid response status:
".$this->response_status, JLog::WARNING,
'com_phocacart');
PhocacartLog::add(1, 'Payment - PayPal Standard - ERROR', 0,
"Invalid response status: ".$this->response_status);
throw new Exception("Invalid response status:
".$this->response_status);
}
if (strpos($this->response, "VERIFIED") !== false) {
return true;
} elseif (strpos($this->response, "INVALID") !==
false) {
return false;
} else {
//JLog::add('Paypal Standard: '."Unexpected response from
PayPal.", 'com_phocacart');
PhocacartLog::add(1, 'Payment - PayPal Standard - ERROR', 0,
"Unexpected response from PayPal.");
throw new Exception("Unexpected response from
PayPal.");
}
}
/**
* Require Post Method
*
* Throws an exception and sets a HTTP 405 response header if the
request
* method was not POST.
*/
public function requirePostMethod() {
// require POST requests
if ($_SERVER['REQUEST_METHOD'] &&
$_SERVER['REQUEST_METHOD'] != 'POST') {
//JLog::add('Paypal Standard: '."Invalid HTTP request
method.", 'com_phocacart');
//PhocacartLog::add(1, 'Payment - PayPal Standard - ERROR', 0,
"Invalid HTTP request method.");
header('Allow: POST', true, 405);
throw new Exception("Invalid HTTP request method.");
}
}
}
?>
cart.php000064400000034621151162557560006231 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopCartHelper{
function hikashopCartHelper(){
static $done = false;
static $override = false;
if(!$done){
$done = true;
$app = JFactory::getApplication();
$chromePath =
JPATH_THEMES.DS.$app->getTemplate().DS.'html'.DS.'hikashop_button.php';
if (file_exists($chromePath)){
require_once ($chromePath);
$override = true;
}
}
$this->override = $override;
}
function
displayButton($name,$map,&$params,$url='',$ajax="",$options="",$max_quantity=0,$min_quantity=1,$classname='',$inc=true){
$config =& hikashop_config();
$button = $config->get('button_style','normal');
static $i=0;
if($inc)
$i++;
if(!empty($ajax)){
$ajax = 'onclick="var
field=document.getElementById(\'hikashop_product_quantity_field_'.$i.'\');'.$ajax.'"
';
}
if(!empty($classname) && substr($classname, 0, 1) != '
')
$classname = ' '.$classname;
if($this->override &&
function_exists('hikashop_button_render')){
$html =
hikashop_button_render($map,$name,$ajax,$options,$url,$classname);
}else{
switch($button){
case 'rounded': //deprecated
$params->set('main_div_name',
'hikashop_button_'.$i);
$moduleHelper = hikashop_get('helper.module');
$moduleHelper->setCSS($params);
$url = 'href="'.$url.'" ';
$html='
<div
id="'.$params->get('main_div_name').'">
<div class="hikashop_container">
<div class="hikashop_subcontainer">
<a
class="hikashop_cart_rounded_button'.$classname.'"
'.$url.$ajax.$options.'>'.$name.'</a>
</div>
</div>
</div>
';
break;
case 'css':
$url = 'href="'.$url.'" ';
$html= '<a
class="hikashop_cart_button'.$classname.'"
'.$options.'
'.$url.$ajax.'>'.$name.'</a>';
break;
case 'normal':
default:
$type = 'submit';
if(in_array($map,array('new','refresh','wishlist'))){
$type = 'button';
}
$html= '<input type="'.$type.'"
class="btn button
hikashop_cart_input_button'.$classname.'"
name="'.$map.'" value="'.$name.'"
'.$ajax.$options.'/>';
break;
}
}
if($map=='add'){
$show_quantity_field=$config->get('show_quantity_field',0);
if($params->get('show_quantity_field',0)=='-1')$params->set('show_quantity_field',$show_quantity_field);
if($params->get('show_quantity_field',0)==1){
$max_quantity=(int)$max_quantity;
$min_quantity=(int)$min_quantity;
static $first = false;
if(!$first && $map=='add'){
$first=true;
$js = '
function hikashopQuantityChange(field,plus,max,min){
var fieldEl=document.getElementById(field);
var current = fieldEl.value;
current = parseInt(current);
if(plus){
if(max==0 || current<max){
fieldEl.value=parseInt(fieldEl.value)+1;
}else if(max && current==max){
alert(\''.JText::_('NOT_ENOUGH_STOCK',true).'\');
}
}else{
if(current>1 && current>min){
fieldEl.value=current-1;
}
}
return false;
}
function hikashopCheckQuantityChange(field,max,min){
var fieldEl=document.getElementById(field);
var current = fieldEl.value;
current = parseInt(current);
if(max && current>max){
fieldEl.value=max;
alert(\''.JText::_('NOT_ENOUGH_STOCK',true).'\');
}else if(current<min){
fieldEl.value=min;
}
return false;
}
';
$setJS=$params->get('js');
if(!$setJS){
if (!HIKASHOP_PHP5) {
$doc =& JFactory::getDocument();
}else{
$doc = JFactory::getDocument();
}
$doc->addScriptDeclaration("<!--\n".$js."\n//-->\n");
}else{
echo '<script
type="text/javascript">'."<!--\n".$js."\n//-->\n".'</script>';
}
}
if($this->override &&
function_exists('hikashop_quantity_render')){
$html =
hikashop_quantity_render($html,$i,$max_quantity,$min_quantity);
}else{
$html ='
<table>
<tr>
<td rowspan="2">
<input
id="hikashop_product_quantity_field_'.$i.'"
type="text"
value="'.JRequest::getInt('quantity',$min_quantity).'"
class="hikashop_product_quantity_field" name="quantity"
onchange="hikashopCheckQuantityChange(\'hikashop_product_quantity_field_'.$i.'\','.$max_quantity.','.$min_quantity.');"
/>
</td>
<td>
<a
id="hikashop_product_quantity_field_change_plus_'.$i.'"
class="hikashop_product_quantity_field_change_plus
hikashop_product_quantity_field_change" href="#"
onclick="return
hikashopQuantityChange(\'hikashop_product_quantity_field_'.$i.'\',1,'.$max_quantity.','.$min_quantity.');">+</a>
</td>
<td rowspan="2">
'.$html.'
</td>
</tr>
<tr>
<td>
<a
id="hikashop_product_quantity_field_change_minus_'.$i.'"
class="hikashop_product_quantity_field_change_minus
hikashop_product_quantity_field_change" href="#"
onclick="return
hikashopQuantityChange(\'hikashop_product_quantity_field_'.$i.'\',0,'.$max_quantity.','.$min_quantity.');">–</a>
</td>
</tr>
</table>
';
}
}elseif($params->get('show_quantity_field',0)==0){
$html.='<input
id="hikashop_product_quantity_field_'.$i.'"
type="hidden" value="'.$min_quantity.'"
class="hikashop_product_quantity_field" name="quantity"
/>';
}elseif($params->get('show_quantity_field',0)==-1){
static $second = false;
if(!$second){
$second=true;
$js = '
function hikashopQuantityChange(field,plus,max,min){
var fieldEl=document.getElementById(field);
var current = fieldEl.value;
current = parseInt(current);
if(plus){
if(max==0 || current<max){
fieldEl.value=parseInt(fieldEl.value)+1;
}else if(max && current==max){
alert(\''.JText::_('NOT_ENOUGH_STOCK',true).'\');
}
}else{
if(current>1 && current>min){
fieldEl.value=current-1;
}
}
return false;
}
';
$setJS=$params->get('js');
if(!$setJS){
$doc =& JFactory::getDocument();
$doc->addScriptDeclaration("\n<!--\n".$js."\n//-->\n");
}else{
echo '<script
type="text/javascript">'."<!--\n".$js."\n//-->\n".'</script>';
}
}
$html = '<input
id="hikashop_product_quantity_field_'.$i.'"
type="text"
value="'.JRequest::getInt('quantity',$min_quantity).'"
class="hikashop_product_quantity_field" name="quantity"
onchange="hikashopCheckQuantityChange(\'hikashop_product_quantity_field_'.$i.'\','.$max_quantity.','.$min_quantity.');"
/>'.$html;
}elseif($params->get('show_quantity_field',0)==2){
}
}
return $html;
}
function cartCount($add=false){
static $carts = 0;
if($add){
$carts=$carts+1;
}
return $carts;
}
function getJS($url,$needNotice=true){
static $first = true;
if($first){
$config =& hikashop_config();
$redirect =
$config->get('redirect_url_after_add_cart','stay_if_cart');
global $Itemid;
$url_itemid='';
if(!empty($Itemid)){
$url_itemid='&Itemid='.$Itemid;
}
$baseUrl =
hikashop_completeLink('product&task=updatecart',true,true);
if(strpos($baseUrl,'?')!==false){
$baseUrl.='&';
}else{
$baseUrl.='?';
}
if($redirect=='ask_user' || hikashop_loadUser() == null){
JHTML::_('behavior.modal');
if($needNotice &&
JRequest::getVar('tmpl','')!='component'){
if($this->override &&
function_exists('hikashop_popup_render')){
echo hikashop_popup_render();
}else{
$config =& hikashop_config();
$popupWidth =
$config->get('add_to_cart_popup_width','480');
$popupHeight =
$config->get('add_to_cart_popup_height','140');
echo '<div style="display:none;">'.
'<a rel="{handler: \'iframe\',size: {x:
'.$popupWidth.', y: '.$popupHeight.'}}"
id="hikashop_notice_box_trigger_link"
href="'.hikashop_completeLink('checkout&task=notice&cart_type=cart'.$url_itemid,true).'"></a>'.
'<a rel="{handler: \'iframe\',size: {x:
'.$popupWidth.', y: '.$popupHeight.'}}"
id="hikashop_notice_wishlist_box_trigger_link"
href="'.hikashop_completeLink('checkout&task=notice&cart_type=wishlist'.$url_itemid,true).'"></a>'.
'</div>';
}
}
if($this->override &&
function_exists('hikashop_popup_js_render')){
$js = hikashop_popup_js_render($url);
}else{
$popupJs = '';
if($redirect == 'ask_user'){
$popupJs = '
if(cart_type == "wishlist"){
SqueezeBox.fromElement("hikashop_notice_wishlist_box_trigger_link",{parse:
"rel"});
} else {
SqueezeBox.fromElement("hikashop_notice_box_trigger_link",{parse:
"rel"});
}
';
}
$addTo = JRequest::getString('add_to','');
if(!empty($addTo))
$addTo = '&addTo='.$addTo;
$js = '
function hikashopModifyQuantity(id,obj,add,form,type,moduleid){
var d = document, cart_type="cart", addStr="", qty=1,
e = null;
if(type) cart_type = type;
if(add) addStr = "&add=1";
if(moduleid === undefined) moduleid = 0;
if(obj){
qty = parseInt(obj.value);
}else
if(document.getElementById("hikashop_product_quantity_field_"+id).value){
qty =
document.getElementById("hikashop_product_quantity_field_"+id).value;
}
if(form && document[form]){
var varform = document[form];
e =
d.getElementById("hikashop_cart_type_"+id+"_"+moduleid);
if(!e)
e = d.getElementById("hikashop_cart_type_"+id);
if(cart_type == "wishlist"){
if(e) e.value = "wishlist";
if(varform.cid) varform.cid.value = id;
f = d.getElementById("type");
if(f) f.value = "wishlist";
}else{
if(e) e.value = "cart";
if(varform.cid) varform.cid.value = id;
}
if(varform.task) {
varform.task.value = "updatecart";
}
var input = document.createElement("input");
input.type = "hidden";
input.name = "from_form";
input.value = "true";
varform.appendChild(input);
varform.submit();
}else{
if(qty){
'.$popupJs.'
}
var url =
"'.$baseUrl.'from=module&product_id="+id+"&cart_type="+cart_type+"&quantity="+qty+addStr+"'.$url_itemid.$addTo.'&return_url='.urlencode(base64_encode(urldecode($url))).'";
var completeFct = function(result) {
var hikaModule = false;
var checkmodule = false;
if(result == "notLogged"){ // if the customer is not logged
and use add to wishlist, display a popup for the notice
SqueezeBox.fromElement("hikashop_notice_wishlist_box_trigger_link",{parse:
"rel"});
}else if(result.indexOf("URL|") != "-1"){ // id the
option is set to redirect, do the redirection
result = result.replace("URL|","");
window.location = result;
return false;
}else if(result != ""){ // if the result is not empty check
for the module
checkmodule = true;
}
if(checkmodule){
if(cart_type != "wishlist") {
hikaModule =
window.document.getElementById("hikashop_cart_module");
}else{
hikaModule =
window.document.getElementById("hikashop_wishlist_module");
}
}
if(hikaModule) hikaModule.innerHTML = result;
};
try{
new Ajax(url, {method: "get", onComplete:
completeFct}).request();
}catch(err){
new Request({url: url, method: "get", onComplete:
completeFct}).send();
}
}
return false;
}
';
}
}else{
if($this->override &&
function_exists('hikashop_cart_js_render')){
$js = hikashop_cart_js_render($url);
}else{
$js='';
if($this->cartCount()!=1 && !empty($url)){
$js = 'window.location =
\''.urldecode($url).'\';';
}
$addTo = JRequest::getString('add_to','');
if(!empty($addTo))
$addTo = '&addTo='.$addTo;
$app = JFactory::getApplication();
$js = '
function hikashopModifyQuantity(id,obj,add,form,type,moduleid){
var d = document, cart_type="cart", addStr="", qty=1,
e = null;
if(type) cart_type = type;
if(add) addStr = "&add=1";
if(moduleid === undefined) moduleid = 0;
if(obj){
qty = parseInt(obj.value);
}else
if(document.getElementById("hikashop_product_quantity_field_"+id).value){
qty =
document.getElementById("hikashop_product_quantity_field_"+id).value;
}
if(form && document[form]){
var varform = document[form];
e =
d.getElementById("hikashop_cart_type_"+id+"_"+moduleid);
if(!e)
e = d.getElementById("hikashop_cart_type_"+id);
if(cart_type == "wishlist"){
if(e) e.value = "wishlist";
f = d.getElementById("type");
if(f) f.value = "wishlist";
}else{
if(e) e.value = "cart";
}
if(varform.task) {
varform.task.value = "updatecart";
}
var input = document.createElement("input");
input.type = "hidden";
input.name = "from_form";
input.value = "true";
varform.appendChild(input);
varform.submit();
}else{
var url =
"'.$baseUrl.'from=module&product_id="+id+"&cart_type="+cart_type+"&quantity="+qty+addStr+"'.$url_itemid.$addTo.'&return_url='.urlencode(base64_encode(urldecode($url))).'";
var completeFct = function(result) {
var hikaModule = false;
var checkmodule = false;
if(result == "notLogged"){
SqueezeBox.fromElement("hikashop_notice_wishlist_box_trigger_link",{parse:
"rel"});
}else if(result.indexOf("URL|") != "-1"){
result = result.replace("URL|","");
window.location = result;
return false;
}else if(result != ""){
checkmodule = true;
}
if(checkmodule){
if(cart_type != "wishlist") {
hikaModule =
window.document.getElementById("hikashop_cart_module");
}else{
hikaModule =
window.document.getElementById("hikashop_wishlist_module");
}
}
if(hikaModule) hikaModule.innerHTML = result;
if(!hikaModule) {
'.$js.'
}
};
try{
new Ajax(url, {method: "get", onComplete:
completeFct}).request();
}catch(err){
new Request({url: url, method: "get", onComplete:
completeFct}).send();
}
}
return false;
}
';
}
if(!HIKASHOP_J30)
JHTML::_('behavior.mootools');
else
JHTML::_('behavior.framework');
}
if (!HIKASHOP_PHP5) {
$doc =& JFactory::getDocument();
}else{
$doc = JFactory::getDocument();
}
$doc->addScriptDeclaration("\n<!--\n".$js."\n//-->\n");
$first = !$needNotice;
return $js;
}
}
}
checkout/address.php000064400000042260151162557560010530 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
include_once HIKASHOP_HELPER . 'checkout.php';
class hikashopCheckoutAddressHelper extends hikashopCheckoutHelperInterface
{
protected $params = array(
'read_only' => array(
'name' => 'READ_ONLY',
'type' => 'boolean',
'default' => 0
),
'address_selector' => array(
'name' => 'HIKASHOP_CHECKOUT_ADDRESS_SELECTOR',
'type' => 'radio',
'tooltip' => 'checkout_address_selector',
'default' => 1,
'showon' => array(
'key' => 'read_only',
'values' => array(0)
)
),
'type' => array(
'name' => 'HIKASHOP_ADDRESS_TYPE',
'type' => 'radio',
'default' => 'both',
),
'same_address' => array(
'name' => 'SHOW_SHIPPING_SAME_ADDRESS_CHECKBOX',
'type' => 'boolean',
'default' => 1,
'showon' => array(
'key' => 'read_only',
'values' => array(0)
)
),
'same_address_pre_checked' => array(
'name' => 'SAME_ADDRESS_CHECKBOX_PRE_CHECKED',
'type' => 'boolean',
'default' => 1,
'showon' => array(
'key' => 'same_address',
'values' => array(1)
)
),
'multi_address' => array(
'name' => 'ALLOW_MULTIPLE_ADDRESSES',
'type' => 'radio',
'default' => 2,
'showon' => array(
'key' => 'read_only',
'values' => array(0)
)
),
);
public function getParams() {
$config = hikashop_config();
$values = array(
JHTML::_('select.option', 1,
JText::_('HIKASHOP_CHECKOUT_ADDRESS_SELECTOR_LIST')),
JHTML::_('select.option', 2,
JText::_('HIKASHOP_CHECKOUT_ADDRESS_SELECTOR_DROPDOWN'))
);
$selector = $config->get('checkout_address_selector',0);
if($config->get('checkout_legacy', 0))
$values[] = JHTML::_('select.option', 0,
JText::_('HIKASHOP_CHECKOUT_ADDRESS_SELECTOR_POPUP'));
$this->params['address_selector']['values'] =
$values;
$this->params['type']['values'] = array(
JHTML::_('select.option', 'billing',
JText::_('HIKASHOP_BILLING_ADDRESS')),
JHTML::_('select.option', 'shipping',
JText::_('HIKASHOP_SHIPPING_ADDRESS')),
JHTML::_('select.option', 'both',
JText::_('WIZARD_BOTH'))
);
$this->params['multi_address']['values'] = array(
JHTML::_('select.option', 0,
JText::_('HIKASHOP_NO')),
JHTML::_('select.option', 2,
JText::_('FOR_LOGGED_IN_USERS_ONLY')),
JHTML::_('select.option', 1,
JText::_('HIKA_ALWAYS')),
);
return parent::getParams();
}
public function check(&$controller, &$params) {
if(!empty($params['read_only']))
return true;
$checkoutHelper = hikashopCheckoutHelper::get();
$cart = $checkoutHelper->getCart();
$type = !empty($params['type']) ? $params['type'] :
'both';
$billing_address_missing = false;
$shipping_address_missing = false;
if(empty($cart->cart_billing_address_id) && in_array($type,
array('billing', 'both'))) {
$billing_address_missing = true;
}
if(empty($cart->cart_shipping_address_ids) && in_array($type,
array('shipping', 'both')) &&
$checkoutHelper->isShipping()) {
$shippingAddress_override =
$checkoutHelper->getShippingAddressOverride();
if(empty($shippingAddress_override))
$shipping_address_missing = true;
}
if($billing_address_missing || $shipping_address_missing) {
$addresses = $checkoutHelper->getAddresses();
$billing_addresses = false;
$shipping_addresses = false;
foreach($addresses['data'] as $address) {
if(empty($address->address_type) || $address->address_type ==
'both') {
$billing_addresses = true;
$shipping_addresses = true;
break;
}
if($address->address_type == 'billing')
$billing_addresses = true;
elseif($address->address_type == 'shipping')
$shipping_addresses = true;
}
};
$app = JFactory::getApplication();
if($billing_address_missing) {
if($billing_addresses)
$app->enqueueMessage(JText::_('SELECT_BILLING_ADDRESS'),
'error');
else
$app->enqueueMessage(JText::_('ENTER_BILLING_ADDRESS'),
'notice');
}
if($shipping_address_missing) {
if($shipping_addresses)
$app->enqueueMessage(JText::_('SELECT_SHIPPING_ADDRESS'),
'error');
else
$app->enqueueMessage(JText::_('ENTER_SHIPPING_ADDRESS'),
'notice');
}
return !($billing_address_missing || $shipping_address_missing);
}
public function validate(&$controller, &$params, $data = array())
{
$data = hikaInput::get()->get('data', array(),
'array');
if(!empty($data) && !empty($data['address_' .
(int)$params['src']['step'] . '_' .
(int)$params['src']['pos']])) {
$address_data = $data['address_' .
(int)$params['src']['step'] . '_' .
(int)$params['src']['pos']];
$new_address_type = @$data['address_type_' .
(int)$params['src']['step'] . '_' .
(int)$params['src']['pos']];
$both_types = null;
if(!empty($new_address_type) &&
!empty($data['address_selecttype_' .
(int)$params['src']['step'] . '_' .
(int)$params['src']['pos']]))
$both_types = (int)@$data['address_bothtypes_' .
(int)$params['src']['step'] . '_' .
(int)$params['src']['pos']];
return $this->saveAddress($controller, $params, $address_data,
$new_address_type, $both_types);
}
$checkout = hikaInput::get()->get('checkout', array(),
'array');
if(!empty($checkout) && !empty($checkout['address']))
{
if(!empty($checkout['address']['billing']) ||
!empty($checkout['address']['shipping']))
return $this->setCartAddresses($checkout['address']);
if(!empty($checkout['address']['delete']))
return
$this->deleteAddresses($checkout['address']['delete']);
}
return true;
}
private function saveAddress(&$controller, &$params,
$address_data, $new_address_type = '', $both_types = null) {
$addressClass = hikashop_get('class.address');
$old_address = new stdClass();
if(!empty($address_data['address_id'])) {
$old_address =
$addressClass->get((int)$address_data['address_id']);
if(empty($old_address) || empty($old_address->address_published))
return false;
}
$fieldClass = hikashop_get('class.field');
$type = '';
if(!empty($old_address->address_type))
$type = $old_address->address_type;
elseif(empty($address_data['address_id']) &&
!empty($new_address_type))
$type = $new_address_type;
$field_type = $type;
if(!empty($field_type))
$field_type .= '_';
$field_type .= 'address';
$formdata = array($field_type => &$address_data);
$app = JFactory::getApplication();
$old_messages = $app->getMessageQueue();
$null = null;
$address = $fieldClass->getFilteredInput($field_type, $null,
'ret', $formdata, false, 'frontcomp');
$checkoutHelper = hikashopCheckoutHelper::get();
$ret = true;
if(empty($address)) {
$error_messages = $fieldClass->messages;
foreach($error_messages as $i => $err) {
$checkoutHelper->addMessage('address.error_'.$i,
array($err, 'error'));
}
$ret = false;
}
if($ret) {
if(isset($formdata[$field_type]) &&
!empty($formdata[$field_type]['address_id']))
$address->address_id =
(int)$formdata[$field_type]['address_id'];
$address->address_published = 1;
if(!empty($old_address) &&
!empty($old_address->address_default))
$address->address_default = 1;
$checkoutHelper = hikashopCheckoutHelper::get();
$cart = $checkoutHelper->getCart();
$address->address_user_id = $cart->user_id;
$billing_ret = $shipping_ret = 0;
if(!empty($new_address_type) && $both_types !== null) {
if($both_types) {
$shipping_address = hikashop_copy($address);
$billing_address = hikashop_copy($shipping_address);
$billing_address->address_type = 'billing';
$billing_ret = $addressClass->save($billing_address, 0,
'billing');
$shipping_address->address_type = 'shipping';
$shipping_ret = $addressClass->save($shipping_address, 0,
'shipping');
} else {
$address->address_type = $new_address_type;
}
}
if($both_types === null || !$both_types)
$ret = $addressClass->save($address);
}
if(!$ret) {
if(!empty($addressClass->message))
$checkoutHelper->addMessage('address.error',
array('msg' => $addressClass->message, 'type'
=> 'error'));
$new_messages = $app->getMessageQueue();
if(count($old_messages) < count($new_messages)) {
$new_messages = array_slice($new_messages, count($old_messages));
foreach($new_messages as $i => $msg) {
$checkoutHelper->addMessage('address.joomla_error_' . $i,
array(
'msg' => $msg['message'],
'type' => $msg['type']
));
}
}
$new_address_data =
$_SESSION['hikashop_'.$type.'_address_data'];
$_SESSION['hikashop_'.$type.'_address_data'] =
null;
unset($_SESSION['hikashop_'.$type.'_address_data']);
$step = $params['src']['workflow_step'];
$block_pos = $params['src']['pos'];
$content =&
$checkoutHelper->checkout_workflow['steps'][$step]['content'][$block_pos];
if(empty($content['params']))
$content['params'] = array();
$content['params']['edit_address'] =
empty($address_data['address_id']) ? true :
(int)$address_data['address_id'];
if(empty($content['params']['err']))
$content['params']['err'] = array();
$content['params']['err']['addr'] =
$new_address_data;
$content['params']['new_address_type'] =
$new_address_type;
return false;
}
$cartClass = hikashop_get('class.cart');
$cart = $checkoutHelper->getCart();
if(!empty($ret) && empty($old_address->address_id)) {
$addresses = $checkoutHelper->getAddresses();
if((!empty($new_address_type) && in_array($new_address_type,
array('billing', 'shipping'))) || (!empty($addresses)
&& count($addresses['data']) == 1)) {
if(!empty($addresses) && count($addresses['data']) ==
1)
$type = null;
else
$type = $new_address_type;
if(isset($billing_ret) && (int)$billing_ret > 0 &&
isset($shipping_ret) && (int)$shipping_ret > 0 &&
$both_types !== null && $both_types){
$cartClass->updateAddress($cart->cart_id, 'billing',
$billing_ret);
$cartClass->updateAddress($cart->cart_id, 'shipping',
$shipping_ret);
}else {
$cartClass->updateAddress($cart->cart_id, $type, $ret);
}
}
}
if(!empty($ret)) {
$cartClass->get('reset_cache',$cart->cart_id);
$checkoutHelper->getCart(true);
}
if(!empty($ret))
return true;
if(empty($content['params']['err']))
$content['params']['err'] = array();
$content['params']['err']['addr'] =
$formdata[$field_type];
$content['params']['new_address_type'] =
$new_address_type;
$error_message = 'error';
$checkoutHelper->addMessage('address.error', array(
$error_message,
'error'
));
return false;
}
private function setCartAddresses($data) {
$billing = (!empty($data['billing'])) ?
(int)$data['billing'] : 0;
$shipping = (!empty($data['shipping'])) ?
(int)$data['shipping'] : 0;
if(empty($billing) && empty($shipping))
return true;
$checkoutHelper = hikashopCheckoutHelper::get();
$cart = $checkoutHelper->getCart();
$cartClass = hikashop_get('class.cart');
$app = JFactory::getApplication();
$old_messages = $app->getMessageQueue();
$ret_billing = true;
if(!empty($billing)) {
$ret_billing = $cartClass->updateAddress($cart->cart_id,
'billing', $billing);
}
$ret_shipping = true;
if(!empty($shipping)) {
$ret_shipping = $cartClass->updateAddress($cart->cart_id,
'shipping', $shipping);
}
if($ret_shipping && $ret_billing) {
$cartClass->get('reset_cache',$cart->cart_id);
$checkoutHelper->getCart(true);
return true;
}
$new_messages = $app->getMessageQueue(true);
if(count($old_messages) < count($new_messages)) {
$new_messages = array_slice($new_messages, count($old_messages));
foreach($new_messages as $i => $msg) {
$checkoutHelper->addMessage('address.joomla_error_' . $i,
array(
'msg' => $msg['message'],
'type' => $msg['type']
));
}
}
return false;
}
private function deleteAddresses($address_id) {
if(empty($address_id))
return true;
$address_id = (int)$address_id;
$addressClass = hikashop_get('class.address');
$ret = $addressClass->delete($address_id);
if(!$ret)
return false;
$checkoutHelper = hikashopCheckoutHelper::get();
$cart = $checkoutHelper->getCart();
if((int)$cart->cart_billing_address_id != $address_id &&
(int)$cart->cart_shipping_address_ids != $address_id)
return true;
$addressClass->loadUserAddresses('reset_cache');
if((int)$cart->cart_billing_address_id == $address_id)
$cart->cart_billing_address_id = 0;
if((int)$cart->cart_shipping_address_ids == $address_id)
$cart->cart_shipping_address_ids = 0;
$cartClass = hikashop_get('class.cart');
$cartClass->save($cart);
return true;
}
public function display(&$view, &$params) {
$checkoutHelper = hikashopCheckoutHelper::get();
$params['js'] = '';
$params['show_billing'] = true;
$params['show_shipping'] = $checkoutHelper->isShipping();
if(!in_array(@$params['type'], array('billing',
'both', ''))) {
$params['show_billing'] = false;
}
if(!in_array(@$params['type'], array('shipping',
'both', ''))) {
$params['show_shipping'] = false;
}
if(!isset($params['same_address']))
$params['same_address'] = 1;
if(!isset($params['same_address_pre_checked']))
$params['same_address_pre_checked'] = 1;
if(!isset($params['multi_address']))
$params['multi_address'] = 2;
$user = JFactory::getUser();
if($params['multi_address'] == 2)
$params['multi_address'] = empty($user->guest);
$params['display'] = $checkoutHelper->isLoggedUser()
&& ($params['show_billing'] ||
$params['show_shipping']);
if(!isset($params['readonly']))
$params['readonly'] = false;
if(!isset($params['address_selector']))
$params['address_selector'] =
(int)$view->config->get('checkout_address_selector', 0);
if(empty($params['address_selector']))
$params['address_selector'] = 1;
$params['display_cancel'] = true;
if(empty($params['read_only']) &&
$params['display'] == true) {
$addresses = $checkoutHelper->getAddresses();
if(empty($addresses) || empty($addresses['data']))
$params['edit_address'] = true;
$checkout = hikaInput::get()->get('checkout', array(),
'array');
$address_id = 0;
if(!empty($checkout['address']['edit'])) {
$address_id = (int)$checkout['address']['edit'];
if(isset($addresses['data'][ $address_id ]))
$params['edit_address'] = $address_id;
} elseif(isset($checkout['address']['billing'])
&& $checkout['address']['billing'] == 0) {
$checkout['address']['new'] = 'billing';
} elseif(isset($checkout['address']['shipping'])
&& $checkout['address']['shipping'] == 0) {
$checkout['address']['new'] =
'shipping';
}else{
$billing_addresses = false;
$shipping_addresses = false;
foreach($addresses['data'] as $address) {
if(empty($address->address_type) || $address->address_type ==
'both') {
$billing_addresses = true;
$shipping_addresses = true;
break;
}
if($address->address_type == 'billing')
$billing_addresses = true;
elseif($address->address_type == 'shipping')
$shipping_addresses = true;
}
if($params['show_billing'] &&
$params['show_shipping'] && !$billing_addresses
&& !$shipping_addresses ) {
$checkout['address']['new'] =
'billing';
$params['display_cancel'] = false;
} elseif($params['show_billing'] &&
!$billing_addresses) {
$checkout['address']['new'] =
'billing';
$params['display_cancel'] = false;
} elseif($params['show_shipping'] &&
!$shipping_addresses) {
$checkout['address']['new'] =
'shipping';
$params['display_cancel'] = false;
}
}
if(!empty($checkout['address']['new'])) {
$params['edit_address'] = true;
$params['new_address_type'] =
$checkout['address']['new'];
}
if(isset($params['new_address_type']) &&
!in_array($params['new_address_type'], array('billing',
'shipping')))
unset($params['new_address_type']);
if(!empty($params['edit_address'])) {
if(empty($view->fieldClass))
$view->fieldClass = hikashop_get('class.field');
$view->edit_address = new stdClass();
if(!empty($params['err']['addr'])) {
$view->edit_address = $params['err']['addr'];
unset($params['err']['addr']);
} elseif((int)$params['edit_address'] > 0 &&
isset($addresses['data'][ (int)$params['edit_address']
])) {
$addressClass = hikashop_get('class.address');
$view->edit_address =
$addressClass->get($params['edit_address']);
}
$fields_type = 'fields';
if(!empty($view->edit_address->address_type) &&
in_array($view->edit_address->address_type,
array('billing', 'shipping')))
$fields_type = $view->edit_address->address_type .
'_fields';
$view->fieldClass->prepareFields($addresses[$fields_type],
$view->edit_address, 'address',
'checkout&task=state');
$params['js'] .=
$view->fieldClass->jsToggle($addresses[$fields_type],
$view->edit_address, 0, 'hikashop_checkout_',
array('return_data' => true, 'suffix_type' =>
'_'.$view->step.'_'.$view->block_position));
}
}
}
}
checkout/bar.php000064400000000717151162557560007650 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
include_once HIKASHOP_HELPER . 'checkout.php';
class hikashopCheckoutBarHelper extends hikashopCheckoutHelperInterface {
public function display(&$view, &$params) {
}
}
checkout/buttons.php000064400000000721151162557560010575 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
include_once HIKASHOP_HELPER . 'checkout.php';
class hikashopCheckoutButtonsHelper extends hikashopCheckoutHelperInterface
{
public function display(&$view, &$params) {
}
}
checkout/cart.php000064400000011645151162557560010037 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
include_once HIKASHOP_HELPER . 'checkout.php';
class hikashopCheckoutCartHelper extends hikashopCheckoutHelperInterface {
protected $params = array(
'readonly' => array(
'name' => 'READ_ONLY',
'type' => 'boolean',
'default' => 0
),
'show_cart_image' => array(
'name' => 'SHOW_IMAGE',
'type' => 'boolean',
'tooltip' => 'show_cart_image',
'default' => 1
),
'link_to_product_page' => array(
'name' => 'LINK_TO_PRODUCT_PAGE',
'type' => 'inherit',
'default' => -1
),
'show_product_code' => array(
'name' => 'DISPLAY_CODE',
'type' => 'inherit',
'default' => -1
),
'show_price' => array(
'name' => 'DISPLAY_PRICE',
'type' => 'boolean',
'default' => 1
),
'price_with_tax' => array(
'name' => 'PRICE_WITH_TAX',
'type' => 'inherit',
'default' => -1,
'showon' => array(
'key' => 'show_price',
'values' => array(1)
)
),
'show_delete' => array(
'name' => 'SHOW_CART_DELETE',
'type' => 'boolean',
'tooltip' => 'checkout_cart_delete',
'default' => 1,
'showon' => array(
'key' => 'readonly',
'values' => array(0)
)
),
'show_shipping' => array(
'name' => 'HIKASHOP_CHECKOUT_SHIPPING_PRICE',
'type' => 'boolean',
'default' => 1
),
'show_payment' => array(
'name' => 'HIKASHOP_CHECKOUT_PAYMENT_PRICE',
'type' => 'boolean',
'default' => 1
),
'show_coupon' => array(
'name' => 'HIKASHOP_CHECKOUT_COUPON_PRICE',
'type' => 'boolean',
'default' => 1
),
);
public function getParams() {
$config = hikashop_config();
$this->params['show_cart_image']['inherit'] =
$config->get('show_cart_image');
$this->params['show_product_code']['inherit'] =
$config->get('show_code');
$this->params['price_with_tax']['inherit'] =
$config->get('price_with_tax');
return parent::getParams();
}
public function check(&$controller, &$params) {
return true;
}
public function validate(&$controller, &$params, $data = array())
{
if(empty($data))
$data = hikaInput::get()->get('checkout', array(),
'array');
if(empty($data['cart']))
return true;
if(empty($data['cart']['item']))
return false;
$items = array();
foreach($data['cart']['item'] as $k => $v) {
if((int)$v == 0 && !is_numeric($v))
continue;
$items[] = array(
'id' => (int)$k,
'qty' => (int)$v
);
}
if(empty($items))
return true;
$checkoutHelper = hikashopCheckoutHelper::get();
$cart = $checkoutHelper->getCart();
$msg_cpt = !empty($cart->messages) ? count($cart->messages) : 0;
$cartClass = hikashop_get('class.cart');
$ret = $cartClass->updateProduct($cart->cart_id, $items);
$cart = $checkoutHelper->getCart(true);
if(empty($cart->products)) {
$checkoutHelper->redirectBeforeDisplay =
JText::_('CART_EMPTY');
}
if(!$ret && !empty($cart->messages) &&
count($cart->messages) > $msg_cpt) {
return false;
}
if(!$ret)
return true;
if(!empty($params['src']['context']) &&
$params['src']['context'] == 'submitstep') {
$checkoutHelper->addMessage('cart.updated', array(
JText::_('CART_UPDATED'),
'success'
));
}
$eventParams = null;
if(!empty($params['src']))
$eventParams = array('src' => $params['src']);
$checkoutHelper->addEvent('checkout.cart.updated',
$eventParams);
return true;
}
public function display(&$view, &$params) {
if(!isset($params['show_cart_image']) ||
(int)$params['show_cart_image'] === -1)
$params['show_cart_image'] =
(int)$view->config->get('show_cart_image');
if(!isset($params['show_product_code']) ||
(int)$params['show_product_code'] === -1)
$params['show_product_code'] =
(int)$view->config->get('show_code');
if(!isset($params['price_with_tax']) ||
(int)$params['price_with_tax'] === -1)
$params['price_with_tax'] =
(int)$view->config->get('price_with_tax');
if(!isset($params['show_price']))
$params['show_price'] = true;
if(!isset($params['show_delete']))
$params['show_delete'] = true;
if(!isset($params['show_shipping']))
$params['show_shipping'] = 1;
if(!isset($params['show_payment']))
$params['show_payment'] = 1;
if(!isset($params['show_coupon']))
$params['show_coupon'] = 1;
if(!isset($params['link_to_product_page']) ||
(int)$params['link_to_product_page'] === -1) {
$defaultParams = $view->config->get('default_params');
$params['link_to_product_page'] =
!empty($defaultParams['link_to_product_page']);
}
if(!empty($params['readonly']))
$params['status'] = true;
$view->loadFields();
hikashop_loadJslib('notify');
hikashop_loadJslib('translations');
}
}
checkout/coupon.php000064400000003644151162557560010411 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
include_once HIKASHOP_HELPER . 'checkout.php';
class hikashopCheckoutCouponHelper extends hikashopCheckoutHelperInterface
{
public function check(&$controller, &$params) {
return true;
}
public function validate(&$controller, &$params, $data = array())
{
$checkout = hikaInput::get()->get('checkout', array(),
'array');
$coupon = null;
if(isset($checkout['coupon']) &&
is_string($checkout['coupon']))
$coupon = $checkout['coupon'];
$qty = 1;
if(empty($coupon)) {
if(isset($checkout['removecoupon']) &&
is_string($checkout['removecoupon']))
$coupon = $checkout['removecoupon'];
$qty = 0;
}
$coupon = trim($coupon);
if(empty($coupon))
return true;
$checkoutHelper = hikashopCheckoutHelper::get();
$cart = $checkoutHelper->getCart();
$cartClass = hikashop_get('class.cart');
$ret = false;
if($qty == 1) {
$ret = $cartClass->addCoupon($cart->cart_id, $coupon);
$msg = 'COUPON_ADDED';
} else {
$ret = $cartClass->removeCoupon($cart->cart_id,
$cart->cart_coupon);
$msg = 'COUPON_REMOVED';
}
$cart = $checkoutHelper->getCart(true);
if(!empty($ret)){
if(@$params['src']['context'] ==
'submitstep') {
$checkoutHelper->addMessage('coupon.success', array(
JText::_($msg),
'success'
));
}
return true;
}
$error_message =
hikaInput::get()->getVar('coupon_error_message',
'');
if(empty($error_message))
$error_message = JText::_('COUPON_NOT_VALID');
$checkoutHelper->addMessage('coupon.invalid', array(
$error_message,
'error'
));
return false;
}
public function display(&$view, &$params) {
}
}
checkout/fields.php000064400000010577151162557560010357 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
include_once HIKASHOP_HELPER . 'checkout.php';
class hikashopCheckoutFieldsHelper extends hikashopCheckoutHelperInterface
{
public function getParams() {
if(!hikashop_level(2))
return '<span
style="color:red">'.JText::_('ONLY_FROM_HIKASHOP_BUSINESS').'</span>';
$type = hikashop_get('type.namebox');
$this->params = array(
'read_only' => array(
'name' => 'READ_ONLY',
'type' => 'boolean',
'default' => 0
),
'show_title' => array(
'name' => 'SHOW_TITLE',
'type' => 'boolean',
'default' => 1
),
'show_submit' => array(
'name' => 'SHOW_SUBMIT_BUTTON',
'type' => 'boolean',
'default' => 0,
'showon' => array(
'key' => 'read_only',
'values' => array(0)
)
),
'fields' => array(
'name' => 'FIELDS',
'type' => 'namebox',
'namebox' => 'field',
'default' => '',
'select' => hikashopNameboxType::NAMEBOX_MULTIPLE,
'namebox_params' => array(
'delete' => true,
'returnOnEmpty' => false,
'table' => 'order',
'default_text' =>
'<em>'.JText::_('HIKA_ALL').'</em>',
'url_params' => array(
'TABLE' => 'order',
),
),
),
);
return parent::getParams();
}
public function check(&$controller, &$params) {
if(!hikashop_level(2))
return true;
return true;
}
public function validate(&$controller, &$params, $data = array())
{
if(!hikashop_level(2))
return true;
if(!empty($params['read_only']))
return true;
if(empty($data))
$data = hikaInput::get()->get('data', array(),
'array');
$key = 'order_' . $params['src']['step'] .
'_' . $params['src']['pos'];
if(empty($data))
$data = hikaInput::get()->get('checkout', array(),
'array');
if(!isset($data[$key]))
$key = 'fields';
if(empty($data[$key]))
return true;
$checkoutHelper = hikashopCheckoutHelper::get();
$cart = $checkoutHelper->getCart();
if(!empty($cart->cart_fields) &&
is_string($cart->cart_fields))
$cart->cart_fields = json_decode($cart->cart_fields);
$old = new stdClass();
$old->products = $cart->products;
$old->cart_payment_id = @$cart->cart_payment_id;
$old->cart_shipping_ids = @$cart->cart_shipping_ids;
if(!empty($params['fields']) &&
is_string($params['fields']))
$params['fields'] =
explode(',',$params['fields']);
$fieldClass = hikashop_get('class.field');
$orderData = $fieldClass->getFilteredInput('order', $old,
'msg', $data[$key], false, '',
@$params['fields']);
if($orderData === false) {
$messages = $fieldClass->messages;
$fieldClass->messages = array();
$cpt = 0;
foreach($messages as $msg) {
$checkoutHelper->addMessage('fields.'.($cpt++), $msg);
}
return false;
}
if(empty($cart->cart_fields)) {
$cart->cart_fields = $orderData;
} else {
foreach($orderData as $k => $v) {
$cart->cart_fields->$k = $v;
}
}
$cartClass = hikashop_get('class.cart');
$ret = $cartClass->save($cart);
if(!$ret)
return false;
$checkoutHelper->getCart(true);
return true;
}
public function haveEmptyContent(&$controller, &$params) {
$checkoutHelper = hikashopCheckoutHelper::get();
$cart = $checkoutHelper->getCart();
if(empty($cart->order_fields))
return true;
return false;
}
public function display(&$view, &$params) {
if(!hikashop_level(2))
return;
if(!isset($params['show_title']))
$params['show_title'] = true;
if(!isset($params['show_submit']))
$params['show_submit'] = false;
if(!isset($params['read_only']))
$params['read_only'] = false;
$checkoutHelper = hikashopCheckoutHelper::get();
$cart = $checkoutHelper->getCart();
if(empty($cart->order_fields))
return;
$params['js'] = '';
if(empty($view->fieldClass))
$view->fieldClass = hikashop_get('class.field');
$null = array();
$view->fieldClass->addJS($null, $null, $null);
$params['js'] .=
$view->fieldClass->jsToggle($cart->order_fields,
$cart->cart_fields, 0, 'hikashop_',
array('return_data' => true, 'suffix_type' =>
'_'.$view->step.'_'.$view->block_position));
}
}
checkout/index.html000064400000000034151162557560010360
0ustar00<html><body></body></html>
checkout/login.php000064400000046740151162557560010222 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
include_once HIKASHOP_HELPER . 'checkout.php';
class hikashopCheckoutLoginHelper extends hikashopCheckoutHelperInterface
{
protected $params = array(
'show_submit' => array(
'name' => 'SHOW_SUBMIT_BUTTON',
'type' => 'boolean',
'default' => 1,
'tooltip' => 'login_submit',
),
'address_on_registration' => array(
'name' => 'ASK_ADDRESS_ON_REGISTRATION',
'type' => 'boolean',
'default' => 1,
'tooltip' => 'address_on_registration',
),
'same_address' => array(
'name' => 'SHOW_SHIPPING_SAME_ADDRESS_CHECKBOX',
'type' => 'boolean',
'default' => 1,
'showon' => array(
'key' => 'address_on_registration',
'values' => array(1)
)
),
'same_address_pre_checked' => array(
'name' => 'SAME_ADDRESS_CHECKBOX_PRE_CHECKED',
'type' => 'boolean',
'default' => 1,
'showon' => array(
'key' => 'same_address',
'values' => array(1)
)
),
);
public function check(&$controller, &$params) {
$checkoutHelper = hikashopCheckoutHelper::get();
return $checkoutHelper->isLoggedUser();
}
public function haveEmptyContent(&$controller, &$params) {
$user = JFactory::getUser();
return !$user->guest;
}
public function validate(&$controller, &$params, $data = array())
{
$user = JFactory::getUser();
if(!$user->guest)
return true;
$app = JFactory::getApplication();
$user_id =
$app->getUserState(HIKASHOP_COMPONENT.'.user_id');
if(!empty($user_id)){
$logout =
hikaInput::get()->getInt('hikashop_checkout_guest_logout',
0);
if($logout) {
$app->setUserState(HIKASHOP_COMPONENT.'.user_id', 0);
hikashop_loadUser(false, true);
if(!isset($params['address_on_registration'])) {
$config = hikashop_config();
$params['address_on_registration'] =
$config->get('address_on_registration', 1);
}
if(!$params['address_on_registration'])
$_SESSION['hikashop_previously_guest_as'] = $user_id;
$checkoutHelper = hikashopCheckoutHelper::get();
$cart = $checkoutHelper->getCart();
$cartClass = hikashop_get('class.cart');
$cartClass->sessionToUser($cart->cart_id, $cart->session_id,
0, false);
$cartToSave = $cartClass->get($cart->cart_id);
$cartToSave->cart_billing_address_id = 0;
$cartToSave->cart_shipping_address_ids = 0;
$cartClass->save($cartToSave);
$checkoutHelper->getCart(true);
}
return true;
}
JPluginHelper::importPlugin('user');
$data = hikaInput::get()->getVar('data');
if(isset($data['register']['registration_method']))
{
$checkoutHelper = hikashopCheckoutHelper::get();
$step = $params['src']['workflow_step'];
$block_pos = $params['src']['pos'];
$content =&
$checkoutHelper->checkout_workflow['steps'][$step]['content'][$block_pos];
if(empty($content['params']))
$content['params'] = array();
$content['params']['default_registration_view'] =
$data['register']['registration_method'];
unset($content);
if($data['register']['registration_method'] ==
'login')
return $this->validateLogin($controller, $params);
else
return $this->validateRegistration($controller, $params);
}
$register =
hikaInput::get()->getString('register','');
$action =
hikaInput::get()->getString('login_view_action','');
if($action == 'register' || ($action != 'login'
&& !empty($register)))
return $this->validateRegistration($controller, $params);
$login = hikaInput::get()->get('login', array(),
'array');
if($action == 'login' || (!empty($login['username'])
&& !empty($login['passwd'])))
return $this->validateLogin($controller, $params);
$formData = hikaInput::get()->get('data', array(),
'array');
if(!empty($formData['register']['email']))
return $this->validateRegistration($controller, $params);
$config =& hikashop_config();
if($config->get('display_login', 1)) {
$username =
hikaInput::get()->request->getUsername('username',
'');
if(!empty($username))
return $this->validateLogin($controller, $params);
$checkoutHelper = hikashopCheckoutHelper::get();
$checkoutHelper->addMessage('login',
array(JText::_('PLEASE_FILL_FORM_BEFORE_PROCEEDING'),'error'));
return;
}
return $this->validateRegistration($controller, $params);
}
protected function validateLogin(&$controller, &$params) {
$login = hikaInput::get()->get('login', array(),
'array');
if(empty($login))
return false;
$app = JFactory::getApplication();
$checkoutHelper = hikashopCheckoutHelper::get();
$cart = $checkoutHelper->getCart();
$jsession = JFactory::getSession();
$old_session = $jsession->getId();
$options = array(
'return' => true,
'remember' => !empty($login['remember'])
);
$credentials = array(
'username' => (string)$login['username'],
'password' => (string)$login['passwd']
);
$old_messages = $app->getMessageQueue();
$result = $app->login($credentials, $options);
$user = JFactory::getUser();
if($result !== true || $user->guest) {
$new_messages = $app->getMessageQueue();
if(count($old_messages) < count($new_messages)) {
$new_messages = array_slice($new_messages, count($old_messages));
foreach($new_messages as $msg) {
$checkoutHelper->addMessage('login', array(
'msg' => $msg['message'],
'type' => $msg['type']
));
}
} else {
$checkoutHelper->addMessage('login',
array(JText::_('LOGIN_NOT_VALID'),'error'));
}
return false;
}
$jsession = JFactory::getSession();
$new_session = $jsession->getId();
$userClass = hikashop_get('class.user');
$user_id = $userClass->getID($user->get('id'));
if(!empty($user_id)) {
$app->setUserState(HIKASHOP_COMPONENT.'.user_id',
$user_id);
$cartClass = hikashop_get('class.cart');
if($cartClass->sessionToUser($cart->cart_id, $old_session,
$user_id)) {
$cartClass->get('reset_cache');
$checkoutHelper->getCart(true);
}
}
$params['login_done'] = true;
$checkoutHelper->addEvent('checkout.user.updated', null);
return true;
}
protected function validateRegistration(&$controller, &$params) {
$checkoutHelper = hikashopCheckoutHelper::get();
$cart = $checkoutHelper->getCart();
$config =& hikashop_config();
$jsession = JFactory::getSession();
$old_session = $jsession->getId();
$formData = hikaInput::get()->get('data', array(),
'array');
$data = array(
'register' => null,
'user' => null,
'address' => null
);
if(isset($formData['register']))
$data['register'] = $formData['register'];
if(isset($formData['user']))
$data['user'] = $formData['user'];
if(!isset($params['address_on_registration']))
$params['address_on_registration'] =
$config->get('address_on_registration', 1);
if($params['address_on_registration'] &&
isset($formData['address']))
$data['address'] = $formData['address'];
if(!isset($params['same_address']))
$params['same_address'] = 1;
$shippingAddress_override =
$checkoutHelper->getShippingAddressOverride();
if(!$checkoutHelper->isShipping() ||
!empty($shippingAddress_override)) {
$params['same_address'] = 0;
}
if($params['address_on_registration'] &&
$params['same_address'] &&
empty($formData['same_address']) &&
isset($formData['shipping_address'])) {
$data['shipping_address'] =
$formData['shipping_address'];
}
$mode = $config->get('simplified_registration', 0);
$display = $config->get('display_method', 0);
if(!hikashop_level(1))
$display = 0;
if($display == 1) {
$mode = explode(',', $mode);
$formData = hikaInput::get()->get('data', array(),
'array');
if(isset($formData['register']['registration_method'])
&&
in_array($formData['register']['registration_method'],
$mode)) {
$mode =
$formData['register']['registration_method'];
} else {
$mode = array_shift($mode);
}
}
$options = array('address_type' => 'both');
if($params['same_address'] &&
empty($formData['same_address']))
$options['address_type'] = 'billing';
if($params['same_address'])
$_SESSION['same_address_pre_checked'] =
(bool)@$formData['same_address'];
$userClass = hikashop_get('class.user');
$ret = $userClass->register($data, $mode, $options);
if($ret === false || !isset($ret['status']))
return false;
$step = $params['src']['workflow_step'];
$block_pos = $params['src']['pos'];
$content =&
$checkoutHelper->checkout_workflow['steps'][$step]['content'][$block_pos];
if(empty($content['params']))
$content['params'] = array();
if(empty($ret['status']) || $ret['status'] == false)
{
if(!empty($ret['raise_error_msg']))
$checkoutHelper->addMessage('login',
array($ret['raise_error_msg'], 'error'));
if(!empty($ret['raise_warning_msg']))
$checkoutHelper->addMessage('login',
array($ret['raise_warning_msg'], 'warning'));
if(!empty($ret['messages'])) {
foreach($ret['messages'] as $k => $msg) {
$checkoutHelper->addMessage('login.'.$k, $msg);
}
$content['params']['registration_invalid_fields'] =
array_keys($ret['messages']);
}
return false;
}
if(!empty($ret['status']) && $ret['status']
== true && !empty($ret['userActivation']) &&
$ret['userActivation'] > 0){
if(!empty($ret['messages'])) {
foreach($ret['messages'] as $k => $msg) {
$checkoutHelper->addMessage('login.'.$k, $msg);
}
}
$content['params']['registration'] = false;
$content['params']['show_login'] = false;
$content['params']['waiting_validation'] = true;
return false;
}
$app = JFactory::getApplication();
if(isset($ret['user_id']))
$app->setUserState(HIKASHOP_COMPONENT.'.user_id',
$ret['user_id']);
$config =& hikashop_config();
$simplified = $config->get('simplified_registration',0);
$display = $config->get('display_method',0);
if(!hikashop_level(1))
$display = 0;
if($display == 1) {
$simplified = explode(',', $simplified);
if($config->get('display_login', 1))
$simplified[] = 'login';
if(count($simplified) == 1) {
$simplified = array_shift($simplified);
} else {
$formData = hikaInput::get()->get('data', array(),
'array');
$simplified =
@$formData['register']['registration_method'];
}
}
if($simplified != 2 && @$ret['userActivation'] == 0) {
$options = array(
'return' => true,
'remember' => false
);
$credentials = array(
'username' =>
(string)$ret['registerData']->username,
'password' =>
(string)$ret['registerData']->password
);
$result = $app->login($credentials, $options);
$juser = JFactory::getUser();
if($result === true && !$juser->guest) {
$userClass = hikashop_get('class.user');
$user_id = $userClass->getID($juser->get('id'));
if(!empty($user_id)) {
$app->setUserState(HIKASHOP_COMPONENT.'.user_id',
$user_id);
$cartClass = hikashop_get('class.cart');
if($cartClass->sessionToUser($cart->cart_id, $old_session,
$user_id)) {
$cartClass->get('reset_cache');
$checkoutHelper->getCart(true);
}
}
$checkoutHelper->addEvent('checkout.user.updated', null);
} else {
$params['register_done'] = true;
}
}
if($simplified == 2) {
$params['register_done'] = true;
}
return $ret['status'];
}
public function display(&$view, &$params) {
if(!isset($params['show_login']))
$params['show_login'] =
$view->config->get('display_login', 1);
$params['current_login'] = hikashop_loadUser(true);
$view->mainUser = JFactory::getUser();
$checkoutHelper = hikashopCheckoutHelper::get();
if($checkoutHelper->isLoggedUser())
return;
if(!isset($params['registration']))
$params['registration'] = true;
$params['display_method'] = 0;
$joomla_params = JComponentHelper::getParams('com_users');
if(((int)$joomla_params->get('allowUserRegistration') == 0))
{
$params['registration'] =
strpos($view->config->get('simplified_registration',
0),'2')!==false;
$params['registration_not_allowed'] = true;
}
if(!empty($params['registration'])) {
$this->loadRegistrationparams($view, $params);
$this->initRegistration($view, $params);
}
}
protected function loadRegistrationparams(&$view, &$params) {
$params['registration_email_confirmation'] =
$view->config->get('show_email_confirmation_field', 0);
$params['affiliate_registration'] =
$view->config->get('affiliate_registration', 0);
$params['user_group_registration'] =
$view->config->get('user_group_registration',
'');
if(!isset($params['default_registration_view']))
$params['default_registration_view'] =
$view->config->get('default_registration_view',
'');
if(!isset($params['show_submit']))
$params['show_submit'] = 1;
if(!isset($params['address_on_registration']))
$params['address_on_registration'] =
$view->config->get('address_on_registration', 1);
if(!isset($params['same_address']))
$params['same_address'] = 1;
if(!isset($params['same_address_pre_checked']))
$params['same_address_pre_checked'] = 1;
$checkoutHelper = hikashopCheckoutHelper::get();
if(!$checkoutHelper->isShipping()) {
$params['same_address'] = 0;
}
$params['display_method'] = 0;
$params['registration_registration'] = true;
$params['registration_count'] = 1;
$params['display_method'] = (hikashop_level(1) ?
(int)$view->config->get('display_method', 0) : 0);
$simplified_registration =
$view->config->get('simplified_registration', 0);
if(strlen($simplified_registration)) {
$registration_list = array(
0 => 'registration_registration',
1 => 'registration_simplified',
2 => 'registration_guest',
3 => 'registration_password',
);
foreach($registration_list as $k) {
$params[$k] = false;
}
$params['registration_count'] = 0;
$simplified_registration = explode(',',
$simplified_registration);
hikashop_toInteger($simplified_registration);
foreach($simplified_registration as $registration_value) {
$params[$registration_list[$registration_value]] = true;
$params['registration_count']++;
}
}
if(!in_array($params['default_registration_view'],
array('login','0','1','2','3')))
$params['default_registration_view'] = 'login';
if($params['registration_registration'] ||
$params['registration_simplified'] ||
$params['registration_password']) {
$userClass = hikashop_get('class.user');
$privacy = $userClass->getPrivacyConsentSettings();
if($privacy) {
$params['privacy'] = true;
$params['privacy_id'] = $privacy['id'];
$params['privacy_text'] = $privacy['text'];
}
}
if(!empty($params['registration_guest'])) {
$userClass = hikashop_get('class.user');
$privacy =
$userClass->getPrivacyConsentSettings('contact');
if($privacy) {
$params['privacy_guest'] = true;
$params['privacy_guest_id'] = $privacy['id'];
$params['privacy_guest_text'] = $privacy['text'];
}
}
}
protected function initRegistration(&$view, &$params) {
$simplified_registration =
$view->config->get('simplified_registration', 0);
$params['js'] = '';
$jversion = preg_replace('#[^0-9\.]#i','',
JVERSION);
if(version_compare($jversion, '3.4.0', '>='))
JHTML::_('behavior.formvalidator');
else
JHTML::_('behavior.formvalidation');
$data = @$_SESSION['hikashop_main_user_data'];
if(!empty($data)) {
if(empty($view->mainUser))
$view->mainUser = new stdClass();
foreach($data as $key => $val) {
$view->mainUser->$key = $val;
}
}
$view->user = @$_SESSION['hikashop_user_data'];
if(empty($view->fieldsClass))
$view->fieldsClass = hikashop_get('class.field');
$view->extraFields['user'] =
$view->fieldsClass->getFields('frontcomp', $view->user,
'user');
$params['js'] .=
$view->fieldsClass->jsToggle($view->extraFields['user'],
$view->user, 0, 'hikashop_', array('return_data'
=> true, 'suffix_type' =>
'_'.$view->step.'_'.$view->block_position));
$check_values = array('user' => $view->user);
if(!empty($params['address_on_registration'])) {
$view->address =
@$_SESSION['hikashop_billing_address_data'];
if(empty($view->address)) {
$app = JFactory::getApplication();
$session_addresses =
$app->getUserState(HIKASHOP_COMPONENT.'.addresses', array());
$session_address = reset($session_addresses);
if(!empty($session_address))
$view->address = hikashop_copy($session_address);
unset($session_addresses);
unset($session_address);
}
$view->extraFields['address'] =
$view->fieldsClass->getFields('frontcomp',
$view->address, 'billing_address');
$params['js'] .=
$view->fieldsClass->jsToggle($view->extraFields['address'],
$view->address, 0, 'hikashop_', array('return_data'
=> true, 'suffix_type' =>
'_'.$view->step.'_'.$view->block_position,
'type' => ''));
$check_values['address'] = $view->address;
if($params['same_address']) {
$checkoutHelper = hikashopCheckoutHelper::get();
$shippingAddress_override =
$checkoutHelper->getShippingAddressOverride();
if(!$checkoutHelper->isShipping() ||
!empty($shippingAddress_override)) {
$params['same_address'] = false;
}
}
if($params['same_address']) {
if(isset($_SESSION['same_address_pre_checked']))
$params['same_address_pre_checked'] =
(int)$_SESSION['same_address_pre_checked'];
$view->shipping_address =
@$_SESSION['hikashop_shipping_address_data'];
if(empty($view->shipping_address)) {
$app = JFactory::getApplication();
$session_addresses =
$app->getUserState(HIKASHOP_COMPONENT.'.addresses', array());
$session_address = reset($session_addresses);
if(!empty($session_address))
$view->shipping_address = hikashop_copy($session_address);
unset($session_addresses);
unset($session_address);
}
$view->extraFields['shipping_address'] =
$view->fieldsClass->getFields('frontcomp',
$view->shipping_address, 'shipping_address');
$params['js'] .=
$view->fieldsClass->jsToggle($view->extraFields['shipping_address'],
$view->shipping_address, 0, 'hikashop_',
array('return_data' => true, 'suffix_type' =>
'_shipping_'.$view->step.'_'.$view->block_position,
'type' => 'shipping_'));
$check_values['shipping_address'] =
$view->shipping_address;
}
}
$affiliate = $view->config->get(
'affiliate_registration_default', 0);
if($affiliate) {
$affiliate = 'checked="checked"';
} else {
$affiliate = '';
}
$view->affiliate_checked = $affiliate;
}
public function checkMarker($markerName, $oldMarkers, $newMarkers,
&$controller, $params) {
if(!in_array($markerName, array('billing_address',
'billing_addresses', 'shipping_address',
'shipping_addresses', 'user')))
return true;
if(!empty($params['register_done'])){
if(!isset($params['address_on_registration'])){
$config = hikashop_config();
$params['address_on_registration'] =
(int)$config->get('address_on_registration', 1);
}
if($params['address_on_registration'])
return false;
$checkoutHelper = hikashopCheckoutHelper::get();
$workflow = $checkoutHelper->checkout_workflow;
foreach($workflow['steps'] as $step) {
foreach($step['content'] as $step_content) {
if($step_content['task'] == 'address')
return true;
}
}
return false;
}
return true;
}
}
checkout/payment.php000064400000031542151162557560010561 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
include_once HIKASHOP_HELPER . 'checkout.php';
class hikashopCheckoutPaymentHelper extends hikashopCheckoutHelperInterface
{
protected $params = array(
'read_only' => array(
'name' => 'READ_ONLY',
'type' => 'boolean',
'default' => 0
),
'show_title' => array(
'name' => 'SHOW_TITLE',
'type' => 'boolean',
'default' => 1
),
'payment_selector' => array(
'name' => 'HIKASHOP_CHECKOUT_DISPLAY_SELECTOR',
'type' => 'radio',
'tooltip' => 'checkout_payment_selector',
'default' => 1,
'showon' => array(
'key' => 'read_only',
'values' => array(0)
)
),
'price_with_tax' => array(
'name' => 'PRICE_WITH_TAX',
'type' => 'inherit',
'default' => -1,
),
);
public function getParams() {
$config = hikashop_config();
$values = array(
JHTML::_('select.option', 1,
JText::_('HIKASHOP_CHECKOUT_ADDRESS_SELECTOR_LIST')),
JHTML::_('select.option', 2,
JText::_('HIKASHOP_CHECKOUT_ADDRESS_SELECTOR_DROPDOWN'))
);
$this->params['payment_selector']['values'] =
$values;
$this->params['price_with_tax']['values'] =
array(
JHTML::_('select.option', '2',
JText::_('WIZARD_BOTH'))
);
return parent::getParams();
}
public function check(&$controller, &$params) {
if(!empty($params['read_only']))
return true;
$checkoutHelper = hikashopCheckoutHelper::get();
$cart = $checkoutHelper->getCart();
if((empty($cart->full_total->prices[0]) ||
$cart->full_total->prices[0]->price_value_with_tax == 0.0) ||
!empty($cart->payment)) {
return true;
}
$checkoutHelper->addMessage('payment.checkfailed', array(
JText::_('SELECT_PAYMENT'),
'error'
));
return false;
}
public function validate(&$controller, &$params, $data = array())
{
if(!empty($params['read_only']))
return true;
if(empty($data))
$data = hikaInput::get()->get('checkout', array(),
'array');
if(empty($data['payment']))
return true;
$payment_id = (int)$data['payment']['id'];
if(empty($payment_id))
return false;
$checkoutHelper = hikashopCheckoutHelper::get();
$cart = $checkoutHelper->getCart();
$payment_price = $this->getPaymentPrice($cart);
$selectionOnly = hikaInput::get()->getInt('selectionOnly',
0);
if($selectionOnly) {
$cart_markers = $checkoutHelper->getCartMarkers();
}
$payment_change = ((int)$cart->cart_payment_id != $payment_id);
$cartClass = hikashop_get('class.cart');
$ret = $cartClass->updatePayment($cart->cart_id, $payment_id);
$new_payment_price = $payment_price;
if($payment_change) {
$cart = $checkoutHelper->getCart(true);
$new_payment_price = $this->getPaymentPrice($cart);
}
if($ret &&
!empty($data['payment']['card'][$payment_id])) {
$app = JFactory::getApplication();
$checkout_cc =
$app->getUserState(HIKASHOP_COMPONENT.'.checkout_cc', null);
if(is_string($checkout_cc))
$checkout_cc = json_decode(base64_decode($checkout_cc));
if(is_object($checkout_cc))
$checkout_cc = get_object_vars($checkout_cc);
if(empty($checkout_cc))
$checkout_cc = array();
if(is_array($data['payment']['card'][$payment_id]))
{
$checkout_cc[$payment_id] = array();
$fields = array('num', 'mm', 'yy',
'ccv', 'type', 'owner');
foreach($fields as $field) {
if(isset($data['payment']['card'][$payment_id][$field])
&&
is_string($data['payment']['card'][$payment_id][$field]))
$checkout_cc[$payment_id][$field] =
trim($data['payment']['card'][$payment_id][$field]);
}
$cards =
$this->checkCreditCard($checkout_cc[$payment_id]['num']);
if($cards === false) {
$ret = false;
$checkoutHelper->addMessage('payment',
array(JText::_('CREDIT_CARD_INVALID'), 'error'));
}
if(isset($checkout_cc[$payment_id]['mm']) &&
isset($checkout_cc[$payment_id]['yy'])) {
}
$plugin = hikashop_import('hikashoppayment',
$cart->payment->payment_type);
if(method_exists($plugin, 'needCC')) {
$plugin->needCC($cart->payment);
} else if(!empty($plugin->ask_cc)) {
if(!empty($cart->payment->payment_params->ask_ccv))
$cart->payment->ask_ccv = true;
}
if(!empty($cart->payment->ask_ccv) &&
empty($checkout_cc[$payment_id]['ccv'])){
$ret = false;
$checkoutHelper->addMessage('payment',
array(JText::_('CCV_MISSING'), 'error'));
}
} else
if(is_string($data['payment']['card'][$payment_id])
&& $data['payment']['card'][$payment_id] ===
'reset')
unset($checkout_cc[$payment_id]);
if($ret)
$app->setUserState(HIKASHOP_COMPONENT.'.checkout_cc',
base64_encode(json_encode($checkout_cc)));
}
if($ret &&
!empty($data['payment']['custom'][$payment_id])) {
$app = JFactory::getApplication();
$checkout_custom =
$app->getUserState(HIKASHOP_COMPONENT.'.checkout_custom',
null);
if(is_string($checkout_custom))
$checkout_custom = json_decode(base64_decode($checkout_custom), true);
if(empty($checkout_custom))
$checkout_custom = array();
if(!isset($checkout_custom[ $payment_id ]))
$checkout_custom[$payment_id] = array();
$plugin = hikashop_import('hikashoppayment',
$cart->payment->payment_type);
$checkout_custom[$payment_id] = $plugin->onPaymentCustomSave($cart,
$cart->payment,
$data['payment']['custom'][$payment_id]);
$app->setUserState(HIKASHOP_COMPONENT.'.checkout_custom',
base64_encode(json_encode($checkout_custom)));
}
if($ret && !empty($cart->payment->custom_html)) {
$plugin = hikashop_import('hikashoppayment',
$cart->payment->payment_type);
$submitstep = !empty($params['src']['context'])
&& $params['src']['context'] ==
'submitstep';
if(!$submitstep) {
$app = JFactory::getApplication();
$old_messages = $app->getMessageQueue();
}
$paymentData = $plugin->onPaymentSave($cart,
$cart->usable_methods->payment, $cart->payment->payment_id);
if($paymentData !== false) {
$cartClass->updatePaymentCustom($cart->cart_id,
$cart->payment->payment_id, $paymentData->custom_html);
} else {
$ret = false;
if(!$submitstep) {
$new_messages = $app->getMessageQueue();
if(count($old_messages) < count($new_messages)) {
$new_messages = array_slice($new_messages, count($old_messages));
foreach($new_messages as $i => $msg) {
$checkoutHelper->addMessage('payment.error_'.$i,
array($msg['message'], $msg['type']));
}
}
}
}
}
$tmpl = hikaInput::get()->getCmd('tmpl', '');
if(hikaInput::get()->getInt('selectionOnly', 0) &&
in_array($tmpl, array('ajax', 'raw'))) {
$data = array(
'ret' => $ret,
'events' => array(),
);
if($ret && $payment_change) {
$data['events'][] = 'checkout.payment.updated';
$checkoutHelper->generateBlockEvents($cart_markers);
$events = $checkoutHelper->getEvents();
foreach($events as $evtName => $params) {
$data['events'][] = $evtName;
}
}
if($new_payment_price != $payment_price)
$data['events'][] = 'checkout.cart.updated';
ob_end_clean();
echo json_encode($data);
exit;
}
if($ret && $payment_change) {
$eventParams = null;
if(!empty($params['src']))
$eventParams = array('src' => $params['src']);
$checkoutHelper->addEvent('checkout.payment.updated',
$eventParams);
}
return $ret;
}
public function display(&$view, &$params) {
if(!isset($params['read_only']))
$params['read_only'] = false;
if(!isset($params['show_title']))
$params['show_title'] = true;
if(!isset($params['payment_selector']))
$params['payment_selector'] = 0;
if($params['read_only'])
$params['payment_selector'] = 0;
if(!isset($params['price_with_tax']))
$params['price_with_tax'] = -1;
if($params['price_with_tax'] == -1) {
$config = hikashop_config();
$params['price_with_tax'] =
$config->get('price_with_tax', 0);
}
$checkoutHelper = hikashopCheckoutHelper::get();
$cart = $checkoutHelper->getCart();
if(empty($cart->full_total->prices[0]) ||
$cart->full_total->prices[0]->price_value_with_tax == 0.0)
return;
if(empty($cart->usable_methods->payment)) {
$checkoutHelper->addMessage('payment.error_no_method',
array(
JText::_('NO_PAYMENT_METHODS_FOUND'),
'error'
));
}
}
protected function checkCreditCard($cardnum) {
$cardnum = trim($cardnum);
if(!preg_match('/^[0-9]{8,19}$/', $cardnum))
return false;
$cards = array(
0 => array('name' => 'Visa',
'length' => array(13,16,19), 'prefixes' =>
'4', 'checkdigit' => true),
1 => array('name' => 'MasterCard',
'length' => array(16), 'prefixes' =>
'51,52,53,54,55,2221,2222,2223,2224,2225,2226,2227,2228,2229,223,224,225,226,227,228,229,23,24,25,26,271,2720',
'checkdigit' => true),
2 => array('name' => 'DinersClub',
'length' => array(14,16), 'prefixes' =>
'305,36,38,54,55', 'checkdigit' => true),
3 => array('name' =>
'CarteBlanche','length' =>
array(14),'prefixes' => '300,301,302,303,304,305',
'checkdigit' => true),
4 => array('name' => 'AmEx',
'length' => array(15), 'prefixes' =>
'34,37','checkdigit' => true),
5 => array('name' => 'Discover',
'length' => array(16), 'prefixes' =>
'6011,622,64,65', 'checkdigit' => true),
6 => array('name' => 'JCB', 'length'
=> array(16,19), 'prefixes' => '35',
'checkdigit' => true),
7 => array('name' => 'enRoute',
'length' => array(15), 'prefixes' =>
'2014,2149', 'checkdigit' => false),
8 => array('name' => 'Solo',
'length' => array(16,18,19), 'prefixes' =>
'6334,6767', 'checkdigit' => true),
9 => array('name' => 'Switch',
'length' => array(16,18,19), 'prefixes' =>
'4903,4905,4911,4936,564182,633110,6333,6759',
'checkdigit' => true),
10 => array('name' => 'Maestro',
'length' => array(12,13,14,15,16,18,19), 'prefixes'
=> '50,56,57,58,59,60,61,62,63,64,65,66,67,68,69',
'checkdigit' => true),
11 => array('name' => 'UATP',
'length' => array(15), 'prefixes' =>
'1', 'checkdigit' => true),
12 => array('name' => 'LaserCard',
'length' => array(16,17,18,19), 'prefixes' =>
'6304,6706,6771,6709', 'checkdigit' => true),
13 => array('name' => 'UnionPay',
'length' => array(16,17,18,19), 'prefixes' =>
'62', 'checkdigit' => true),
14 => array('name' => 'Isracard',
'length' => array(8), 'prefixes' =>
'0,1,2,3,4,5,6,7,8,9', 'checkdigit' => false),
15 => array('name' => 'Direct',
'length' => array(9), 'prefixes' =>
'0,1,2,3,4,5,6,7,8,9', 'checkdigit' => false),
16 => array('name' => 'Bankcard',
'length' => array(16), 'prefixes' =>
'62', 'checkdigit' => true),
17 => array('name' => 'China UnionPay',
'length' => array(16,17,18,19), 'prefixes' =>
'62', 'checkdigit' => true),
18 => array('name' => 'InterPayment',
'length' => array(16,17,18,19), 'prefixes' =>
'636', 'checkdigit' => true),
19 => array('name' => 'InstaPayment',
'length' => array(16), 'prefixes' =>
'637,638,639', 'checkdigit' => true),
20 => array('name' => 'Laser',
'length' => array(16,17,18,19), 'prefixes' =>
'6304,6706,6771,6709', 'checkdigit' => true),
21 => array('name' => 'Dankort',
'length' => array(16), 'prefixes' =>
'5019', 'checkdigit' => true),
22 => array('name' => 'NSPK MIR',
'length' => array(16), 'prefixes' =>
'2200,2201,2202,2203', 'checkdigit' => true),
23 => array('name' => 'Verve',
'length' => array(16,19), 'prefixes' =>
'506,6500', 'checkdigit' => true),
24 => array('name' => 'CARDGUARD EAD BG ILS',
'length' => array(16), 'prefixes' =>
'5392', 'checkdigit' => true),
);
$valid = array();
$checksum = false;
$cardlen = strlen($cardnum);
foreach($cards as $card) {
if(!in_array($cardlen, $card['length']))
continue;
if($card['prefixes'] == null) {
$valid[] = $card;
$checksum = ($checksum || $card['checkdigit']);
continue;
}
$prefixes = explode(',', $card['prefixes']);
foreach($prefixes as $prefix) {
if(substr($cardnum, 0, strlen($prefix)) == $prefix) {
$valid[] = $card;
$checksum = ($checksum || $card['checkdigit']);
break;
}
}
}
$card_checksum = false;
if($checksum) {
$card_checksum = 0;
$j = 1;
for($i = strlen($cardnum) - 1; $i >= 0; $i--) {
$calc = (int)substr($cardnum, $i, 1) * $j;
if($calc > 9) {
$card_checksum++;
$calc -= 10;
}
$card_checksum += $calc;
$j = ($j == 1) ? 2 : 1;
}
$card_checksum = ($card_checksum % 10 == 0);
}
if(!$card_checksum) {
foreach($valid as $k => $v) {
if($v['checkdigit'])
unset($valid[$k]);
}
}
if(empty($valid))
return false;
return $valid;
}
protected function getPaymentPrice(&$cart) {
if(empty($cart->payment))
return 0.0;
return (float)hikashop_toFloat($cart->payment->payment_price);
}
}
checkout/separator.php000064400000001642151162557560011102
0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
include_once HIKASHOP_HELPER . 'checkout.php';
class hikashopCheckoutSeparatorHelper extends
hikashopCheckoutHelperInterface {
protected $params = array(
'type' => array(
'name' => 'TYPE_OF_SEPARATION',
'type' => 'radio',
'default' => 'vertical',
),
);
public function getParams() {
$values = array(
JHTML::_('select.option', 'vertical',
JText::_('VERTICAL')),
JHTML::_('select.option', 'horizontal',
JText::_('HORIZONTAL'))
);
$this->params['type']['values'] = $values;
return parent::getParams();
}
public function haveEmptyContent(&$controller, &$params) {
return true;
}
}
checkout/shipping.php000064400000017736151162557560010736 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
include_once HIKASHOP_HELPER . 'checkout.php';
class hikashopCheckoutShippingHelper extends
hikashopCheckoutHelperInterface {
protected $params = array(
'read_only' => array(
'name' => 'READ_ONLY',
'type' => 'boolean',
'default' => 0
),
'show_title' => array(
'name' => 'SHOW_TITLE',
'type' => 'boolean',
'default' => 1
),
'show_shipping_products' => array(
'name' => 'MULTI_GROUP_PRODUCT_DISPLAY',
'type' => 'boolean',
'default' => 1,
),
'shipping_selector' => array(
'name' => 'HIKASHOP_CHECKOUT_DISPLAY_SELECTOR',
'type' => 'radio',
'tooltip' => 'checkout_shipping_selector',
'default' => 1,
'showon' => array(
'key' => 'read_only',
'values' => array(0)
)
),
'price_with_tax' => array(
'name' => 'PRICE_WITH_TAX',
'type' => 'inherit',
'default' => -1,
),
);
public function getParams() {
$config = hikashop_config();
$values = array(
JHTML::_('select.option', 1,
JText::_('HIKASHOP_CHECKOUT_ADDRESS_SELECTOR_LIST')),
JHTML::_('select.option', 2,
JText::_('HIKASHOP_CHECKOUT_ADDRESS_SELECTOR_DROPDOWN'))
);
$this->params['shipping_selector']['values'] =
$values;
$this->params['price_with_tax']['values'] =
array(
JHTML::_('select.option', '2',
JText::_('WIZARD_BOTH'))
);
return parent::getParams();
}
public function check(&$controller, &$params) {
if(!empty($params['read_only']))
return true;
$checkoutHelper = hikashopCheckoutHelper::get();
$cart = $checkoutHelper->getCart();
if(!isset($cart->usable_methods) ||
$cart->usable_methods->shipping_valid == true)
return true;
$checkoutHelper->addMessage('shipping.checkfailed', array(
JText::_('SELECT_SHIPPING'),
'error'
));
return false;
}
public function validate(&$controller, &$params, $data = array())
{
if(!empty($params['read_only']))
return true;
if(empty($data))
$data = hikaInput::get()->get('checkout', array(),
'array');
if(empty($data['shipping']))
return true;
$shipping_ids = array();
foreach($data['shipping'] as $group => $shipping) {
if(!isset($shipping['id']))
continue;
if(is_numeric($group))
$group = (int)$group;
if(is_numeric($shipping['id']))
$shipping['id'] = (int)$shipping['id'];
$shipping_ids[$group] = $shipping['id'];
}
if(count($shipping_ids) == 0)
return false;
$checkoutHelper = hikashopCheckoutHelper::get();
$cart = $checkoutHelper->getCart();
$shipping_price = $this->getShippingPrice($cart);
if(empty($_POST['selectionOnly'])){
foreach($cart->shipping_groups as $group_id => $group_info) {
$group_check = false;
foreach($shipping_ids as $ship_group_id => $ship_id){
if($ship_group_id == $group_id)
$group_check = true;
}
if(!$group_check)
return false;
}
}
$selectionOnly = hikaInput::get()->getInt('selectionOnly',
0);
if($selectionOnly) {
$cart_markers = $checkoutHelper->getCartMarkers();
}
$cartClass = hikashop_get('class.cart');
$ret = $cartClass->updateShipping($cart->cart_id, $shipping_ids);
$cart = $checkoutHelper->getCart(true);
if($ret &&
!empty($data['shipping']['custom'])) {
$checkout_custom = array();
foreach($shipping_ids as $group => $id) {
if(!isset($data['shipping']['custom'][$group][$id]))
continue;
$warehouse_struct = $group;
if(preg_match_all('#([a-zA-Z])*([0-9]+)#iu', $group, $tmp))
$warehouse_struct = array_combine($tmp[1], $tmp[2]);
$shipping = null;
foreach($cart->shipping as $s) {
if($s->shipping_id != $id || ($s->shipping_warehouse_id !==
$warehouse_struct && $s->shipping_warehouse_id !== $group))
continue;
if(empty($s->custom_html))
continue;
$plugin = hikashop_import('hikashopshipping',
$s->shipping_type);
$ret = $plugin->onShippingCustomSave($cart, $s, $group,
$data['shipping']['custom'][$group][$id]);
if($ret === false)
break;
if(!isset($checkout_custom[ $group ]))
$checkout_custom[$group] = array();
if(!isset($checkout_custom[ $group ]))
$checkout_custom[$group][$id] = array();
$checkout_custom[$group][$id] = $ret;
}
}
$cartClass->updateShippingCustomData($cart->cart_id,
$checkout_custom);
}
$tmpl = hikaInput::get()->getCmd('tmpl', '');
if($selectionOnly && in_array($tmpl, array('ajax',
'raw'))) {
$data = array(
'ret' => $ret,
'events' => array(),
);
if($ret) {
$data['events'][] = 'checkout.shipping.updated';
$checkoutHelper->generateBlockEvents($cart_markers);
$events = $checkoutHelper->getEvents();
foreach($events as $evtName => $params) {
$data['events'][] = $evtName;
}
}
$new_shipping_price = $this->getShippingPrice($cart);
if($new_shipping_price != $shipping_price)
$data['events'][] = 'checkout.cart.updated';
ob_end_clean();
echo json_encode($data);
exit;
}
if($ret) {
$eventParams = null;
if(!empty($params['src']))
$eventParams = array('src' => $params['src']);
$checkoutHelper->addEvent('checkout.shipping.updated',
$eventParams);
}
return $ret;
}
protected function getShippingPrice(&$cart) {
$shipping_price = 0.0;
if(empty($cart->shipping))
return $shipping_price;
if(isset($cart->shipping->shipping_price))
return (float)hikashop_toFloat($cart->shipping->shipping_price);
foreach($cart->shipping as $s) {
$shipping_price += hikashop_toFloat($s->shipping_price);
}
return $shipping_price;
}
public function display(&$view, &$params) {
if(!isset($params['show_shipping_products']))
$params['show_shipping_products'] = true;
if(!isset($params['read_only']))
$params['read_only'] = false;
if(!isset($params['show_title']))
$params['show_title'] = true;
if(!isset($params['shipping_selector']))
$params['shipping_selector'] = 0;
if($params['read_only'])
$params['shipping_selector'] = 0;
if(!isset($params['price_with_tax']))
$params['price_with_tax'] = -1;
if($params['price_with_tax'] == -1) {
$config = hikashop_config();
$params['price_with_tax'] =
$config->get('price_with_tax', 0);
}
$checkoutHelper = hikashopCheckoutHelper::get();
if(!$checkoutHelper->isMessages('shipping')) {
$cart = $checkoutHelper->getCart();
$this->addShippingErrors($cart);
}
}
protected function addShippingErrors(&$cart) {
if(!empty($cart->usable_methods->shipping_valid))
return;
$several_groups = isset($cart->shipping_groups) ?
(count($cart->shipping_groups) > 1) : false;
if(!$several_groups &&
!empty($cart->usable_methods->shipping))
return;
$checkoutHelper = hikashopCheckoutHelper::get();
if(!$several_groups) {
$msg =
$this->getShippingErrorMessage(@$cart->usable_methods->shipping_errors);
$checkoutHelper->addMessage('shipping.error', array($msg,
'error'));
return;
}
$warehouse_order = 0;
foreach($cart->shipping_groups as $group) {
$warehouse_order++;
if(!empty($group->shippings) || empty($group->errors))
continue;
$msg = $this->getShippingErrorMessage($group->errors);
$checkoutHelper->addMessage('shipping.warehouse_'.$warehouse_order,
array($msg, 'error'));
}
}
private function getShippingErrorMessage($errors) {
if(empty($errors)) {
return JText::_('NO_SHIPPING_METHOD_FOUND');
}
$shippingClass = hikashop_get('class.shipping');
foreach($errors as $k => $err) {
if(is_array($err)) {
$n = array_keys($err);
$n = array_shift($n);
return $shippingClass->_displayErrors($n, array_shift($err),
false);
}
return $shippingClass->_displayErrors($k, $err, false);
}
}
}
checkout/status.php000064400000000636151162557560010427 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
include_once HIKASHOP_HELPER . 'checkout.php';
class hikashopCheckoutStatusHelper extends hikashopCheckoutHelperInterface
{
}
checkout/terms.php000064400000010544151162557560010235 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
include_once HIKASHOP_HELPER . 'checkout.php';
class hikashopCheckoutTermsHelper extends hikashopCheckoutHelperInterface
{
protected $params = array(
'article_id' => array(
'name' => 'HIKASHOP_CHECKOUT_TERMS',
'type' => 'namebox',
'tooltip' => 'checkout_terms',
'namebox' => 'article',
'default' => ''
),
'size' => array(
'name' => 'TERMS_AND_CONDITIONS_POPUP_SIZE',
'type' => 'group',
'tooltip' => 'terms_and_conditions_xy',
'data' => array(
'popup_width' => array(
'type' => 'text',
'attributes' =>
'style="width:50px"',
'default' => 450
),
'size_separator' => array(
'type' => 'html',
'html' => ' x ',
),
'popup_height' => array(
'type' => 'text',
'attributes' =>
'style="width:50px"',
'default' => 480
),
'size_unit' => array(
'type' => 'html',
'html' => ' px',
),
),
),
'label' => array(
'name' => 'FIELD_LABEL',
'type' => 'textarea',
'default' => '',
),
'pre_checked' => array(
'name' => 'CHECKBOX_PRE_CHECKED',
'type' => 'boolean',
'default' => 0
),
);
public function getParams() {
$this->params['label']['attributes'] =
'rows="3" cols="30"
placeholder="'.JText::_('PLEASE_ACCEPT_TERMS').'"';
return parent::getParams();
}
public function check(&$controller, &$params) {
$checkoutHelper = hikashopCheckoutHelper::get();
$cart = $checkoutHelper->getCart();
$key = 'terms_checked_' .
$params['src']['step'] . '_' .
$params['src']['pos'];
if(!empty($cart->cart_params->$key))
return true;
$checkoutHelper->addMessage('terms_' .
$params['src']['step'] . '_' .
$params['src']['pos'] . '.checkfailed',
array(
JText::_('PLEASE_ACCEPT_TERMS_BEFORE_FINISHING_ORDER'),
'error'
));
return false;
}
public function validate(&$controller, &$params, $data = array())
{
$checkout = hikaInput::get()->get('checkout', array(),
'array');
$checkoutHelper = hikashopCheckoutHelper::get();
$cart = $checkoutHelper->getCart();
$cart_id = (int)$cart->cart_id;
$name = 'terms_'. $params['src']['step'] .
'_' . $params['src']['pos'];
if(!isset($checkout[$name]))
$checkout[$name] = 0;
$key = 'terms_checked_' .
$params['src']['step'] . '_' .
$params['src']['pos'];
if(isset($cart->cart_params->$key) &&
(int)$cart->cart_params->$key == (int)$checkout[$name]) {
if((int)$cart->cart_params->$key)
return true;
$checkoutHelper->addMessage('terms_' .
$params['src']['step'] . '_' .
$params['src']['pos'] . '.checkfailed',
array(
JText::_('PLEASE_ACCEPT_TERMS_BEFORE_FINISHING_ORDER'),
'error'
));
return false;
}
$cartClass = hikashop_get('class.cart');
if(!$cartClass->updateTerms($cart_id, (int)$checkout[$name], $key)) {
$checkoutHelper->addMessage('terms_' .
$params['src']['step'] . '_' .
$params['src']['pos'] . '.updatefailed',
array(
JText::_('TERMS_AND_CONDITIONS_CHECKED_STATUS_FAILED'),
'error'
));
return false;
}
$checkoutHelper->getCart(true);
if((int)$checkout[$name])
return true;
$checkoutHelper->addMessage('terms_' .
$params['src']['step'] . '_' .
$params['src']['pos'] . '.checkfailed',
array(
JText::_('PLEASE_ACCEPT_TERMS_BEFORE_FINISHING_ORDER'),
'error'
));
return false;
}
public function display(&$view, &$params) {
if(!isset($params['article_id']))
$params['article_id'] =
(int)$view->config->get('checkout_terms', 0);
if(!isset($params['popup_width']))
$params['popup_width'] =
(int)$view->config->get('terms_and_conditions_width',
450);
if($params['popup_width'] <= 0)
$params['popup_width'] = 450;
if(!isset($params['popup_height']))
$params['popup_height'] =
(int)$view->config->get('terms_and_conditions_height',
480);
if($params['popup_height'] <= 0)
$params['popup_height'] = 480;
if(empty($params['label']))
$params['label'] = JText::_('PLEASE_ACCEPT_TERMS');
else{
$key = strtoupper($params['label']);
$trans = JText::_($key);
if($trans != $key)
$params['label'] = $trans;
}
}
}
checkout/text.php000064400000002306151162557560010064 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
include_once HIKASHOP_HELPER . 'checkout.php';
class hikashopCheckoutTextHelper extends hikashopCheckoutHelperInterface {
protected $params = array(
'text' => array(
'name' => 'CONTENT',
'type' => 'textarea',
'default' => ''
),
);
public function getParams() {
$this->params['text']['attributes'] =
'rows="3" cols="30"
placeholder="'.htmlentities(JText::_('WRITE_TEXT_HTML_HERE'),
ENT_COMPAT, 'UTF-8').'"';
return parent::getParams();
}
public function display(&$view, &$params) {
if(empty($params['text'])) {
$params['text'] = '';
return;
}
$params['text'] = JHTML::_('content.prepare',
hikashop_translate($params['text']));
}
public function haveEmptyContent(&$controller, &$params) {
if(empty($params['text']))
return true;
$text = JHTML::_('content.prepare',
hikashop_translate($params['text']));
if(empty($text))
return true;
return false;
}
}
checkout.php000064400000047473151162557560007116 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopCheckoutHelper {
protected static $instance = null;
public $cart = false;
public $checkout_workflow = null;
public $redirectBeforeDisplay = null;
protected $cart_id = 0;
protected $shop_closed = false;
protected $config = null;
protected $cartClass = null;
protected $shippingClass = null;
protected $paymentClass = null;
protected $addressClass = null;
protected $currencyClass = null;
protected $redirect_url = null;
protected $events = array();
protected $messages = array();
protected $images = array();
public static function &get($cart_id = null) {
if(self::$instance === null) {
$classname = class_exists('hikashopCheckoutHelperOverride')
? 'hikashopCheckoutHelperOverride' :
'hikashopCheckoutHelper';
self::$instance = new $classname($cart_id);
self::$instance->config = hikashop_config();
self::$instance->loadWorkflow();
}
return self::$instance;
}
public function __construct($cart_id = null) {
$this->cart_id = 0;
if($cart_id !== null) {
$this->cartClass = hikashop_get('class.cart');
$this->cart_id = (int)$cart_id;
$cart = $this->cartClass->get($this->cart_id);
if(empty($cart) || $cart->cart_type == 'wishlist')
$this->cart_id = 0;
}
}
protected function loadWorkflow() {
$this->checkout_workflow =
$this->config->get('checkout_workflow', '');
if(!empty($this->checkout_workflow))
$this->checkout_workflow = json_decode($this->checkout_workflow,
true);
if(empty($this->checkout_workflow) ||
(int)$this->config->get('checkout_workflow_legacy', 0) ==
1)
$this->loadWorkflowLegacy();
$this->shop_closed = false;
JPluginHelper::importPlugin('hikashop');
$app = JFactory::getApplication();
$app->triggerEvent('onCheckoutWorkflowLoad',
array(&$this->checkout_workflow, &$this->shop_closed,
$this->cart_id));
}
protected function loadWorkflowLegacy() {
$checkout_config =
trim($this->config->get('checkout','login_address_shipping_payment_coupon_cart_status_confirm,end'));
$legacy_steps = explode(',', $checkout_config);
$this->checkout_workflow = array(
'steps' => array()
);
foreach($legacy_steps as $steps) {
$steps = explode('_', $steps);
$content = array();
foreach($steps as $step) {
$c = array('task' => $step);
if($step == 'cartstatus') {
$c['task'] = 'cart';
$c['params'] = array('readonly' => true);
}
$content[] = $c;
}
$this->checkout_workflow['steps'][] = array(
'content' => $content
);
}
}
public function isLoggedUser() {
$app = JFactory::getApplication();
$user = JFactory::getUser();
$user_id =
$app->getUserState(HIKASHOP_COMPONENT.'.user_id');
return (empty($user->guest) || !empty($user_id));
}
public function isStoreClosed() {
return $this->shop_closed;
}
public function &getCart($reset = false) {
if(!$reset && $this->cart !== false)
return $this->cart;
if(empty($this->cartClass) || $reset)
$this->cartClass = hikashop_get('class.cart');
$this->cart = $this->cartClass->getFullCart($this->cart_id);
return $this->cart;
}
public function getCartId() {
return $this->cart_id;
}
public function isShipping() {
$cart = $this->getCart();
$config =& hikashop_config();
return !empty($cart->usable_methods->shipping) ||
!empty($cart->package['weight']['value']) ||
$config->get('force_shipping', 0);
}
public function getAddresses($type = '') {
$ret = array(
'data' => array(),
'fields' => array()
);
if(!in_array($type, array('', 'billing',
'shipping')))
$type = '';
if(empty($this->addressClass))
$this->addressClass = hikashop_get('class.address');
$cart = $this->getCart();
if(!empty($cart->user_id))
$ret['data'] =
$this->addressClass->loadUserAddresses($cart->user_id, $type);
if(!empty($ret['data'])) {
$this->addressClass->loadZone($ret['data']);
$ret['fields'] =& $this->addressClass->fields;
} else {
$fieldClass = hikashop_get('class.field');
$fields = $fieldClass->getData('frontcomp',
'address');
$ret['fields'] =& $fields;
}
if(!empty($ret['fields']) &&
count($ret['fields'])) {
$ret['billing_fields'] = array();
$ret['shipping_fields'] = array();
foreach($ret['fields'] as $k => $field) {
if($field->field_address_type == 'billing') {
$ret['billing_fields'][$k] = $field;
continue;
}
if($field->field_address_type == 'shipping') {
$ret['shipping_fields'][$k] = $field;
continue;
}
if(empty($field->field_address_type)) {
$ret['billing_fields'][$k] = $field;
$ret['shipping_fields'][$k] = $field;
}
}
}
return $ret;
}
public function getShippingAddressOverride() {
if(!$this->isShipping())
return false;
$cart = $this->getCart();
if(empty($cart->shipping))
return false;
$currentShipping = array();
foreach($cart->shipping as $method) {
$currentShipping[$method->shipping_id] =
hikashop_import('hikashopshipping', $method->shipping_type);
}
$override = false;
foreach($currentShipping as $shipping_id => $selectedMethod) {
if(!empty($selectedMethod) && method_exists($selectedMethod,
'getShippingAddress')) {
$override = $selectedMethod->getShippingAddress($shipping_id,
$cart);
}
}
return $override;
}
public function getDisplayPrice($data, $type, $options = null) {
if(!isset($data->{$type.'_price'}))
return '';
if($data->{$type.'_price'} == 0.0)
return JText::_('FREE_'.strtoupper($type));
$config = hikashop_config();
$defaultParams = $config->get('default_params');
if(isset($options['price_with_tax']))
$pt = $options['price_with_tax'];
else
$pt = (int)$config->get('price_with_tax', 0);
if(empty($this->currencyClass))
$this->currencyClass = hikashop_get('class.currency');
if(isset($data->{$type.'_currency_id'}))
$currency = (int)$data->{$type.'_currency_id'};
else
$currency =
$data->{$type.'_params'}->{$type.'_currency'};
$price_text = JText::_('PRICE_BEGINNING') . '<span
class="hikashop_checkout_'.$type.'_price">';
if($pt > 0)
$price_text .=
$this->currencyClass->format($data->{$type.'_price_with_tax'},
$currency);
if($pt == 2)
$price_text .= JText::_('PRICE_BEFORE_TAX');
if($pt == 2 || $pt == 0)
$price_text .=
$this->currencyClass->format($data->{$type.'_price'},
$currency);
if($pt == 2)
$price_text .= JText::_('PRICE_AFTER_TAX');
if(!empty($options['show_original_price']) &&
isset($data->{$type.'_price_orig'}) &&
$data->{$type.'_currency_orig'} > 0.0) {
$price_text .= JText::_('PRICE_BEFORE_ORIG');
if($pt > 0)
$price_text .=
$this->currencyClass->format($data->{$type.'_price_orig_with_tax'},
$data->{$type.'_currency_orig'});
if($pt == 2)
$price_text .= JText::_('PRICE_BEFORE_TAX');
if($pt == 2 || $pt == 0)
$price_text .=
$this->currencyClass->format($data->{$type.'_price_orig'},
$data->{$type.'_currency_orig'});
if($pt == 2)
$price_text .= JText::_('PRICE_AFTER_TAX');
$price_text .= JText::_('PRICE_AFTER_ORIG');
}
$price_text .=
'</span>'.JText::_('PRICE_END');
return $price_text;
}
public function getPluginImage($name, $type = null) {
if(!in_array($type, array('payment', 'shipping')))
return false;
$ret = new stdClass;
if(!empty($this->images[$type])) {
if(!isset($this->images[$type][$name]))
return false;
$ret->url = HIKASHOP_IMAGES . $type . '/' .
$this->images[$type][$name];
return $ret;
}
jimport('joomla.filesystem.folder');
$files = JFolder::files(HIKASHOP_MEDIA .'images'.DS.$type.DS);
$this->images[$type] = array();
if(!empty($files)) {
foreach($files as $file) {
$parts = explode('.', $file);
array_pop($parts);
$file_name = implode('.', $parts);
$this->images[$type][$file_name] = $file;
}
}
if(!isset($this->images[$type][$name]))
return false;
$ret->url = HIKASHOP_IMAGES . $type . '/' .
$this->images[$type][$name];
return $ret;
}
public function getCreditCard($payment, $hide = true) {
$cart = $this->getCart();
$method = null;
foreach($cart->usable_methods->payment as $p) {
if($p->payment_type == $payment->payment_type &&
$p->payment_id == $payment->payment_id)
$method = $p;
}
if(empty($method) || !$method->ask_cc)
return false;
$app = JFactory::getApplication();
$checkout_cc =
$app->getUserState(HIKASHOP_COMPONENT.'.checkout_cc', null);
if(empty($checkout_cc))
return false;
if(is_string($checkout_cc))
$checkout_cc = json_decode(base64_decode($checkout_cc));
$var = $method->payment_id;
if(!isset($checkout_cc->$var))
return false;
if(!is_object($checkout_cc->$var))
return false;
$ret = $checkout_cc->$var;
if($hide){
$l = strlen($ret->num);
$ret->num = str_repeat('X', $l - 4).substr($ret->num, $l
- 4);
if(!empty($ret->ccv))
$ret->ccv = str_repeat('X', strlen($ret->ccv));
}
return $ret;
}
public function getCustomHtml($data, $input_name) {
if(is_string($data))
return $data;
$ret = '';
return $ret;
}
public function completeLink($url, $ajax = false, $redirect = false, $js =
false, $Itemid = 0) {
$config = hikashop_config();
$menusClass = hikashop_get('class.menus');
$config_itemid = (int)$config->get('checkout_itemid', 0);
$setCtrl = true;
$checkout_itemid = !empty($checkout_itemid) ? $checkout_itemid :
$Itemid;
$valid_menu = $menusClass->loadAMenuItemId('checkout',
'show', $checkout_itemid);
if(!empty($valid_menu)) {
$setCtrl = false;
} else {
$valid_menu = $menusClass->loadAMenuItemId('',
'', $checkout_itemid);
if(!$valid_menu) {
$checkout_itemid = $menusClass->loadAMenuItemId('',
'');
}
}
if(!$setCtrl) {
$jconfig = JFactory::getConfig();
if(!$jconfig->get('sef'))
$setCtrl = true;
if(class_exists('Sh404sefHelperGeneral')) {
$params = Sh404sefHelperGeneral::getComponentParams();
if($params->get('Enabled'))
$setCtrl = true;
}
}
$cart_id = $this->getCartId();
$url .= ($cart_id > 0) ? '&cart_id=' . $cart_id :
'';
$link = 'index.php?option=' . HIKASHOP_COMPONENT . ($setCtrl ?
'&ctrl=checkout' : '') . (!empty($url) ?
'&'.$url : '') . '&Itemid=' .
$checkout_itemid . ($ajax ? '&tmpl=raw' : '');
$ret = JRoute::_($link, !$redirect);
if($js) return str_replace('&', '&',
$ret);
return $ret;
}
public function getRedirectUrl($override = false) {
if(!$override && !empty($this->redirect_url))
return $this->redirect_url;
$this->redirect_url =
$this->config->get('redirect_url_when_cart_is_empty',
'');
if(!$override && !empty($this->redirect_url)) {
$this->redirect_url = hikashop_translate($this->redirect_url);
if(!preg_match('#^https?://#', $this->redirect_url))
$this->redirect_url = JURI::base() . ltrim($this->redirect_url,
'/');
$this->redirect_url = JRoute::_($this->redirect_url, false);
return $this->redirect_url;
}
global $Itemid;
$url = '';
$itemid_to_use = $Itemid;
$menusClass = hikashop_get('class.menus');
if(!empty($itemid_to_use))
$ok = $menusClass->loadAMenuItemId('product',
'listing', $itemid_to_use);
if(empty($ok))
$ok = $menusClass->loadAMenuItemId('product',
'listing');
if($ok)
$itemid_to_use = $ok;
if(!empty($itemid_to_use))
$url = '&Itemid=' . $itemid_to_use;
$this->redirect_url =
hikashop_completeLink('product&task=listing' . $url, false,
true);
return $this->redirect_url;
}
public function getCartMarkers() {
$cart = $this->getCart(true);
$user = (int)$cart->user_id;
if(empty($user))
$user = $cart->session_id;
foreach($cart->cart_products as &$p) {
unset($p->cart_product_modified);
}
unset($p);
$total = hikashop_copy($cart->full_total);
if(!empty($total->prices)) {
foreach($total->prices as &$price ) {
if(!empty($price->taxes)) {
foreach($price->taxes as $i => $tax) {
foreach(get_object_vars($tax) as $k => $v) {
if($k != 'tax_namekey')
unset($price->taxes[$i]->$k);
}
}
}
if(!empty($price->taxes_without_discount)) {
foreach($price->taxes_without_discount as $i => $tax) {
foreach(get_object_vars($tax) as $k => $v) {
if($k != 'tax_namekey')
unset($price->taxes_without_discount[$i]->$k);
}
}
}
}
}
$fullprice = md5(serialize($total));
$products = md5(serialize($cart->cart_products) .
serialize(@$cart->additional));
$paymentMethods = hikashop_copy(@$cart->usable_methods->payment);
if(!empty($paymentMethods)) {
foreach($paymentMethods as &$paymentMethod ) {
unset($paymentMethod->total);
unset($paymentMethod->custom_html);
}
}
$payments = md5(serialize(@$paymentMethods));
$shippingMethods =
hikashop_copy(@$cart->usable_methods->shipping);
if(!empty($shippingMethods)) {
foreach($shippingMethods as &$shippingMethod ) {
unset($shippingMethod->taxes);
unset($shippingMethod->custom_html);
}
}
$shippings = md5(serialize(@$shippingMethods));
$address_override =
md5(serialize($this->getShippingAddressOverride()));
$fields = null;
if(!empty($cart->order_fields))
$fields = array_keys($cart->order_fields);
$order_fields = md5(serialize($fields));
$billing_addreses =
md5(serialize(@$cart->usable_addresses->billing));
$shipping_addreses =
md5(serialize(@$cart->usable_addresses->shipping));
$shipping = $cart->cart_shipping_ids;
if(is_array($shippings))
$shipping = implode(',', $shipping);
$payment_price = 0.0;
if(isset($cart->payment->payment_price))
$payment_price = $cart->payment->payment_price;
$shipping_price = 0.0;
$shipping_products = '';
if(!empty($cart->shipping)) {
if(isset($cart->shipping->shipping_price)) {
$shipping_price =
hikashop_toFloat($cart->shipping->shipping_price);
} else {
foreach($cart->shipping as $s) {
$shipping_price += hikashop_toFloat($s->shipping_price);
}
}
if(isset($cart->shipping_groups) &&
count($cart->shipping_groups) > 1) {
$s = array();
foreach($cart->shipping_groups as $k => $v) {
$s[$k] = array();
foreach($v->products as $p) {
$s[$k][] = (int)$p->product_id;
}
}
$shipping_products = md5(serialize($s));
}
}
$ret = array(
'full_price' => $fullprice, // hash of the full amount of
the cart
'cart_products' => $products, // hash of the products
(& additional)
'cart_empty' => (count($cart->cart_products) == 0),
'coupon' => $cart->cart_coupon, // for the coupon
'payment_selected' => (int)$cart->cart_payment_id, //
status && payment
'payment_price' => $payment_price, // cart
'payment_list' => $payments, // payment
'shipping_selected' => $shipping, // status &&
shipping
'shipping_price' => $shipping_price, // cart
'shipping_list' => $shippings, // shipping
'shipping_group_products' => $shipping_products, //
shipping
'billing_address' =>
(int)$cart->cart_billing_address_id,
'billing_addresses' => $billing_addreses,
'shipping_address' =>
(int)$cart->cart_shipping_address_ids,
'shipping_address_overirde' => $address_override,
'shipping_addresses' => $shipping_addreses,
'user' => $user,
'order_fields' => $order_fields,
);
$markers = array();
JPluginHelper::importPlugin('hikashop');
$app = JFactory::getApplication();
$app->triggerEvent('onCheckoutGetCartMarkers',
array(&$markers, &$cart));
if(!empty($markers)) {
$ret['plugins'] = $markers;
}
return $ret;
}
public function generateBlockEvents($markers, $params = null) {
$newMarkers = $this->getCartMarkers();
$events = array(
'full_price' => 'checkout.cart.updated',
'cart_products' => 'checkout.cart.updated',
'coupon' => array('checkout.coupon.updated',
'checkout.cart.updated'),
'payment_selected' =>
'checkout.payment.changed',
'payment_price' => 'checkout.cart.updated',
'payment_list' => 'checkout.payment.updated',
'shipping_selected' =>
'checkout.shipping.changed',
'shipping_price' => 'checkout.cart.updated',
'shipping_list' => 'checkout.shipping.updated',
'shipping_group_products' =>
'checkout.shipping.updated',
'shipping_address_overirde' =>
'checkout.address.updated',
'billing_addresses' =>
'checkout.address.updated',
'shipping_addresses' =>
'checkout.address.updated',
'user' => 'checkout.user.updated',
'order_fields' => 'checkout.fields.updated',
);
if(!empty($newMarkers['cart_empty'])) {
if(empty($params))
$params = array();
$params['cart_empty'] = true;
}
foreach($markers as $k => $v) {
if($v === $newMarkers[$k])
continue;
if(!isset($events[$k]))
continue;
$evt = $events[$k];
if(is_array($evt)) {
foreach($evt as $e) {
$this->addEvent($e, $params);
}
} else {
$this->addEvent($evt, $params);
}
}
if(!empty($markers['plugins'])) {
$app = JFactory::getApplication();
foreach($markers['plugins'] as $k => $v) {
if($v === $newMarkers['plugins'][$k])
continue;
$evts = array();
$app->triggerEvent('onCheckoutProcessCartMarker',
array($k, &$evts, $v, $newMarkers['plugins'][$k]));
foreach($evts as $e) {
$this->addEvent($e, $params);
}
}
}
return true;
}
public function addEvent($name, $params = null) {
if(isset($this->events[$name]))
return false;
$this->events[$name] = $params;
return true;
}
public function getEvents() {
return $this->events;
}
public function addMessage($name, $message = null) {
if(isset($this->messages[$name]))
return false;
$this->messages[$name] = $message;
return true;
}
public function displayMessages($name = null, $display = true) {
if(empty($this->messages) && $name !== 'cart')
return;
$key = ($name !== null) ? $name.'.' : null;
$messagesToReturn = array();
foreach($this->messages as $n => $msg) {
if($key !== null && $n !== $name && strpos($n, $key) !==
0)
continue;
unset($this->messages[$n]);
$messagesToReturn[] = $msg;
if(!$display)
continue;
if(!is_array($msg)) {
hikashop_display($msg);
continue;
}
if(!isset($msg['msg'])) {
if(!isset($msg[1]))
hikashop_display($msg[0]);
else
hikashop_display($msg[0], $msg[1]);
continue;
}
if(!isset($msg['type']))
$msg['type'] = 'error';
hikashop_display($msg['msg'], $msg['type']);
}
if($name !== 'cart')
return $messagesToReturn;
$cart = $this->getCart();
if(empty($cart->messages))
return $messagesToReturn;
foreach($cart->messages as $msg) {
hikashop_display($msg['msg'], $msg['type']);
}
return $messagesToReturn;
}
public function isMessages($name = null) {
if(empty($this->messages))
return false;
if($name === null)
return true;
foreach($this->messages as $n => $msg) {
if($n !== $name && strpos($n, $name.'.') !== 0)
continue;
return true;
}
return false;
}
}
class hikashopCheckoutHelperInterface {
protected $params = array();
public function getParams() {
return $this->params;
}
public function check(&$controller, &$params) {
return true;
}
public function validate(&$controller, &$params, $data = array())
{
return true;
}
public function display(&$view, &$params) {
}
public function haveEmptyContent(&$controller, &$params) {
return false;
}
public function checkMarker($markerName, $oldMarkers, $newMarkers,
&$controller, $params) {
return true;
}
}
cron.php000064400000010567151162557560006244 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopCronHelper{
var $report = false;
var $messages = array();
var $detailMessages = array();
function cron(){
$time = time();
$config =& hikashop_config();
$firstMessage =
JText::sprintf('CRON_TRIGGERED',hikashop_getDate(time()));
$this->messages[] = $firstMessage;
if($this->report){
hikashop_display($firstMessage,'info');
}
if($config->get('cron_next') > $time){
if($config->get('cron_next') > ($time +
$config->get('cron_frequency'))){
$newConfig = new stdClass();
$newConfig->cron_next = $time +
$config->get('cron_frequency');
$config->save($newConfig);
}
$nottime =
JText::sprintf('CRON_NEXT',hikashop_getDate($config->get('cron_next')));
$this->messages[] = $nottime;
if($this->report){
hikashop_display($nottime,'info');
}
$sendreport = $config->get('cron_sendreport');
if($sendreport == 1){
$mailer = hikashop_get('class.mail');
$data = new stdClass();
$data->report =
implode('<br/>',$this->messages);
$data->detailreport = '';
$mail = $mailer->get('cron_report',$data);
$mail->subject = JText::_($mail->subject);
$receiverString = $config->get('cron_sendto');
$receivers = explode(',',$receiverString);
if(!empty($receivers)){
foreach($receivers as $oneReceiver){
$mail->dst_email = $oneReceiver;
$mailer->sendMail($mail);
}
}
}
return false;
}
$newConfig = new stdClass();
$newConfig->cron_next = $config->get('cron_next') +
$config->get('cron_frequency');
if($newConfig->cron_next <= $time || $newConfig->cron_next>
$time + $config->get('cron_frequency'))
$newConfig->cron_next = $time +
$config->get('cron_frequency');
$newConfig->cron_last = $time;
$newConfig->cron_fromip = hikashop_getIP();
$config->save($newConfig);
JPluginHelper::importPlugin('hikashoppayment');
JPluginHelper::importPlugin('hikashopshipping');
JPluginHelper::importPlugin('hikashop');
$dispatcher = JDispatcher::getInstance();
$resultsTrigger = array();
$dispatcher->trigger('onHikashopCronTrigger',array(&$resultsTrigger));
if($this->report){
foreach($resultsTrigger as $message){
hikashop_display($message,'info');
}
}
$this->detailMessages = $resultsTrigger;
return true;
}
function report(){
$config =& hikashop_config();
$newConfig = new stdClass();
$newConfig->cron_report =
@implode('<br/>',$this->messages);
if(strlen($newConfig->cron_report) > 800)
$newConfig->cron_report =
substr($newConfig->cron_report,0,795).'...';
$config->save($newConfig);
$saveReport = $config->get('cron_savereport');
if(!empty($saveReport)){
$reportPath =
JPath::clean(HIKASHOP_ROOT.trim(html_entity_decode($config->get('cron_savepath'))));
jimport('joomla.filesystem.folder');
$parentFolder=dirname($reportPath);
if(JFolder::exists($parentFolder) || JFolder::create($parentFolder)){
file_put_contents($reportPath,
"\r\n"."\r\n".str_repeat('*',150)."\r\n".str_repeat('*',20).str_repeat('
',5).hikashop_getDate(time()).str_repeat('
',5).str_repeat('*',20)."\r\n", FILE_APPEND);
@file_put_contents($reportPath,
@implode("\r\n",$this->messages), FILE_APPEND);
if($saveReport == 2 AND !empty($this->detailMessages)){
@file_put_contents($reportPath, "\r\n"."---- Details
----"."\r\n", FILE_APPEND);
@file_put_contents($reportPath,
@implode("\r\n",$this->detailMessages), FILE_APPEND);
}
}
}
$sendreport = $config->get('cron_sendreport');
if(!empty($sendreport)){
$mailer = hikashop_get('class.mail');
$data = new stdClass();
$data->report =
@implode('<br/>',$this->messages);
$data->detailreport =
@implode('<br/>',$this->detailMessages);
$mail = $mailer->get('cron_report',$data);
$mail->subject = JText::_($mail->subject);
$receiverString = $config->get('cron_sendto');
$receivers = explode(',',$receiverString);
if($sendreport == 1 || !empty($this->detailMessages)){
if(!empty($receivers)){
foreach($receivers as $oneReceiver){
$mail->dst_email = $oneReceiver;
$mailer->sendMail($mail);
}
}
}
}
}
}
database.php000064400000055127151162557560007050 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopDatabaseHelper {
protected $db = null;
public static $check_results = null;
public function __construct() {
$this->db = JFactory::getDBO();
}
function addColumns($table, $columns) {
if(!is_array($columns))
$columns = array($columns);
$query = 'ALTER TABLE `'.hikashop_table($table).'` ADD
'.implode(', ADD', $columns).';';
$this->db->setQuery($query);
$err = false;
try {
$this->db->execute();
}catch(Exception $e) {
$err = true;
}
if(!$err)
return true;
if($err && count($columns) > 1) {
foreach($columns as $col) {
$query = 'ALTER TABLE `'.hikashop_table($table).'` ADD
'.$col.';';
$this->db->setQuery($query);
$err = 0;
try {
$this->db->execute();
}catch(Exception $e) {
$err++;
}
}
if($err < count($columns))
return true;
}
return false;
}
public function parseTableFile($filename, &$createTable,
&$structure) {
$queries = file_get_contents($filename);
$tables = explode('CREATE TABLE IF NOT EXISTS', $queries);
foreach($tables as $oneTable) {
$fields = explode("\n\t", trim($oneTable));
$tableNameTmp = substr($oneTable, strpos($oneTable, '`') + 1,
strlen($oneTable) - 1);
$tableName = substr($tableNameTmp, 0, strpos($tableNameTmp,
'`'));
if(empty($tableName))
continue;
foreach($fields as $oneField) {
$oneField = trim($oneField);
$pattern='/`(.*)`.*AUTO_INCREMENT/msU';
preg_match($pattern, $oneField , $ai_matches);
if(isset($ai_matches[1])){
$structure[$tableName]['AUTO_INCREMENT'][] =
$ai_matches[1];
}
$pattern='/PRIMARY KEY \(`(.*)`\)/msU';
preg_match($pattern, $oneField , $pm_matches);
if(isset($pm_matches[1])){
$structure[$tableName]['PRIMARY_KEY'] = $pm_matches[1];
}
if(substr($oneField,0,1) != '`' || substr($oneField,
strlen($oneField) - 1, strlen($oneField)) != ',')
continue;
if(empty($structure[$tableName]))
$structure[$tableName] = array();
$fieldNameTmp = substr($oneField,strpos($oneField,'`') + 1,
strlen($oneField) - 1);
$fieldName = substr($fieldNameTmp, 0, strpos($fieldNameTmp,
'`'));
$structure[$tableName][$fieldName] = trim($oneField, ',');
}
$createTable[$tableName] = 'CREATE TABLE IF NOT EXISTS ' .
trim($oneTable);
}
}
public function checkdb() {
$createTable = array();
$structure = array();
$this->parseTableFile(HIKASHOP_BACK . 'tables.sql',
$createTable, $structure);
try{
$this->db->setQuery("SELECT * FROM #__hikashop_field");
$custom_fields = $this->db->loadObjectList();
} catch(Exception $e) {
$custom_fields = array();
$msg = $e->getMessage();
}
$ret = array();
ob_start();
JPluginHelper::importPlugin('hikashop');
$app = JFactory::getApplication();
$obj =& $this;
$app->triggerEvent('onHikashopBeforeCheckDB',
array(&$createTable, &$custom_fields, &$structure,
&$obj));
$html = ob_get_clean();
if(!empty($html))
$ret[] = $html;
if(!empty($custom_fields)){
foreach($custom_fields as $custom_field) {
if(@$custom_field->field_type == 'customtext')
continue;
if(substr($custom_field->field_table, 0, 4) == 'plg.')
continue;
switch($custom_field->field_table) {
case 'contact':
break;
case 'item':
$table = '#__hikashop_cart_product';
if(!isset($structure[$table][$custom_field->field_namekey]))
$structure[$table][$custom_field->field_namekey] =
'`'.$custom_field->field_namekey.'` TEXT NULL';
$table = '#__hikashop_order_product';
if(!isset($structure[$table][$custom_field->field_namekey]))
$structure[$table][$custom_field->field_namekey] =
'`'.$custom_field->field_namekey.'` TEXT NULL';
break;
default:
$table = '#__hikashop_'.$custom_field->field_table;
if(!isset($structure[$table][$custom_field->field_namekey]))
$structure[$table][$custom_field->field_namekey] =
'`'.$custom_field->field_namekey.'` TEXT NULL';
break;
}
}
}
$tableName = array_keys($structure);
$structureDB = array();
foreach($tableName as $oneTableName) {
$msg = '';
$fields2 = null;
try{
$this->db->setQuery('SHOW COLUMNS FROM ' .
$oneTableName);
$fields2 = $this->db->loadObjectList();
} catch(Exception $e) {
$fields2 = null;
$msg = $e->getMessage();
}
$table_name = str_replace('#__', '',
$oneTableName);
if($fields2 == null) {
if(empty($msg))
$msg = substr(strip_tags($this->db->getErrorMsg()), 0, 200);
$ret[] = array(
'info',
sprintf('Could not load columns from the table "%s" :
%s', $table_name, $msg)
);
$msg = '';
try {
$this->db->setQuery($createTable[$oneTableName]);
$isError = $this->db->execute();
} catch(Exception $e) {
$isError = null;
$msg = $e->getMessage();
}
if($isError == null) {
if(empty($msg))
$msg = substr(strip_tags($this->db->getErrorMsg()), 0, 200);
$ret[] = array(
'error',
sprintf('Could not create the table "%s"',
$table_name)
);
$ret[] = array('error_msg', $msg);
} else {
$ret[] = array(
'success',
sprintf('Problem solved - table "%s" created',
$table_name)
);
$fields2 = null;
try{
$this->db->setQuery('SHOW COLUMNS FROM ' .
$oneTableName);
$fields2 = $this->db->loadObjectList();
} catch(Exception $e) {
$fields2 = null;
$msg = $e->getMessage();
}
}
}
if(!empty($fields2)) {
foreach($fields2 as $oneField) {
if(empty($structureDB[$oneTableName]))
$structureDB[$oneTableName] = array();
$structureDB[$oneTableName][$oneField->Field] =
$oneField->Field;
}
}
}
foreach($tableName as $oneTableName) {
$t = array();
if(!empty($structureDB[$oneTableName]))
$t = $structureDB[$oneTableName];
$resultCompare[$oneTableName] =
array_diff(array_keys($structure[$oneTableName]), $t,
array('AUTO_INCREMENT','PRIMARY_KEY'));
$table_name = str_replace('#__', '',
$oneTableName);
if(empty($resultCompare[$oneTableName])) {
$ret[] = array(
'success',
sprintf('Table "%s" checked', $table_name)
);
continue;
}
foreach($resultCompare[$oneTableName] as $oneField) {
if($oneField == 'AUTO_INCREMENT' || $oneField ==
'PRIMARY_KEY')
continue;
$ret[] = array(
'info',
sprintf('Field "%s" missing in %s', $oneField,
$table_name)
);
$msg = '';
try{
$this->db->setQuery('ALTER TABLE ' . $oneTableName .
' ADD ' . $structure[$oneTableName][$oneField]);
$isError = $this->db->execute();
} catch(Exception $e) {
$isError = null;
$msg = $e->getMessage();
}
if($isError == null) {
if(empty($msg))
$msg = substr(strip_tags($this->db->getErrorMsg()), 0, 200);
$ret[] = array(
'error',
sprintf('Could not add the field "%s" in the table
"%s"', $oneField, $table_name)
);
$ret[] = array('error_msg', $msg);
} else {
$ret[] = array(
'success',
sprintf('Field "%s" added in the table
"%s"', $oneField, $table_name)
);
}
}
}
foreach($tableName as $oneTableName) {
$msg = '';
$fields2 = null;
try{
$this->db->setQuery('SHOW COLUMNS FROM ' .
$oneTableName);
$fields2 = $this->db->loadObjectList();
} catch(Exception $e) {
$fields2 = null;
$msg = $e->getMessage();
}
$table_name = str_replace('#__', '',
$oneTableName);
if(empty($fields2))
continue;
$primary_keys = array();
if(isset($structure[$oneTableName]['PRIMARY_KEY'])){
if(strpos($structure[$oneTableName]['PRIMARY_KEY'],
"`,`") !== false)
$primary_keys = explode( "`,`",
$structure[$oneTableName]['PRIMARY_KEY']);
else
$primary_keys[] = $structure[$oneTableName]['PRIMARY_KEY'];
}
$auto_increments = array();
if(isset($structure[$oneTableName]['AUTO_INCREMENT'])){
$auto_increments =
$structure[$oneTableName]['AUTO_INCREMENT'];
}
$deletePrimary = false;
foreach($fields2 as $oneField) {
if(in_array($oneField->Field, $primary_keys) &&
(empty($oneField->Key) || $oneField->Key != 'PRI')) {
$deletePrimary = true;
break;
}
}
if(!empty($deletePrimary)) {
$query = 'SELECT '.
implode(',',$primary_keys).', count(*) AS counter FROM
'. $oneTableName .
' GROUP BY '. implode(',',$primary_keys) .
' HAVING counter > 1';
try{
$this->db->setQuery($query);
$duplication_primarykeys = $this->db->loadObjectList();
} catch(Exception $e) {
$ret[] = array(
'error',
$e->getMessage()
);
$duplication_primarykeys = false;
}
if(is_array($duplication_primarykeys) &&
!empty($duplication_primarykeys) &&
count($duplication_primarykeys)) {
$where = ' WHERE ';
$where_conditions = array();
foreach($duplication_primarykeys as $duplication_primarykey){
$first_duplication = true;
$where_condition = '';
foreach($duplication_primarykey as $duplication_key =>
$duplication_value){
if($duplication_key == 'counter')
continue;
if(!$first_duplication)
$where_condition .= ' AND ';
else
$first_duplication = false;
$where_condition .= $duplication_key . ' = ' .
$duplication_value;
}
$where_conditions[] = $where_condition;
}
if(!empty($where_conditions)){
$where .= implode(' OR ',$where_conditions);
$query = 'DELETE FROM '.$oneTableName .
$where.';';
try{
$this->db->setQuery($query);
$result = $this->db->execute();
} catch(Exception $e) {
$ret[] = array(
'error',
$e->getMessage()
);
$result = false;
}
if($result) {
$ret[] = array(
'info',
'Element(s) of the table "'.$table_name.'"
with the same ID deleted'
);
}
}
}
try{
$query = 'ALTER TABLE '.$oneTableName.' ADD PRIMARY
KEY('.implode(',',$primary_keys).')';
$this->db->setQuery($query);
$result = $this->db->execute();
} catch(Exception $e) {
$ret[] = array(
'error',
$table_name.': '.$e->getMessage()
);
$ret[] = array(
'error',
'<pre>'.$query.'</pre>'
);
$result = false;
}
if($result){
$ret[] = array(
'info',
'Primary key(s) for the table
"'.$table_name.'" fixed'
);
}
}
foreach($fields2 as $oneField) {
if(!in_array($oneField->Field, $auto_increments) ||
$oneField->Extra == 'auto_increment')
continue;
try{
$query = 'ALTER TABLE '.$oneTableName.' MODIFY COLUMN
'.$oneField->Field . ' ';
if(!empty($oneField->Type))
$query.= $oneField->Type . ' ';
$query.= 'auto_increment';
$this->db->setQuery($query);
$result = $this->db->execute();
} catch(Exception $e) {
$ret[] = array(
'error',
$table_name.': '.$e->getMessage()
);
$ret[] = array(
'error',
'<pre>'.$query.'</pre>'
);
$result = false;
}
if($result){
$ret[] = array(
'info',
'Auto increments for the table
"'.$table_name.'" fixed'
);
}
}
}
$query = 'SELECT category_id FROM `#__hikashop_category` WHERE
category_type = ' . $this->db->Quote('root') . '
AND category_parent_id = 0';
try {
$this->db->setQuery($query);
$root = $this->db->loadResult();
} catch(Exception $e) {
$root = 0;
}
if(empty($root)) {
$query = 'INSERT IGNORE INTO `#__hikashop_category` '.
'(`category_id`, `category_parent_id`, `category_type`,
`category_name`, `category_description`, `category_published`,
`category_ordering`, `category_left`, `category_right`, `category_depth`,
`category_namekey`) VALUES '.
"(1, 0, 'root', 'ROOT', '', 0, 0, 1,
22, 0, 'root'),".
"(2, 1, 'product', 'product category',
'', 1, 1, 2, 3, 1, 'product'),".
"(3, 1, 'tax', 'taxation category',
'', 1, 2, 4, 7, 1, 'tax')";
try {
$this->db->setQuery($query);
$result = $this->db->execute();
} catch(Exception $e) {
$result = -1;
}
if($result) {
$ret[] = array(
'info',
'Missing core categories fixed'
);
$root = null;
$categoryClass = hikashop_get('class.category');
$categoryClass->rebuildTree($root,0,1);
}
}
$query = 'SELECT count(p.product_id) as result FROM
`#__hikashop_product` AS p ' .
' LEFT JOIN `#__hikashop_product_category` AS pc ON p.product_id =
pc.product_id ' .
' WHERE p.product_type = ' .
$this->db->Quote('main') . ' AND pc.category_id IS
NULL;';
try {
$this->db->setQuery($query);
$result = $this->db->loadResult();
} catch(Exception $e) {
$result = -1;
}
if($result > 0) {
$ret[] = array(
'info',
sprintf('Found %d product(s) without category', $result)
);
$product_category_id = 'product';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($product_category_id);
$query = 'INSERT INTO `#__hikashop_product_category` (category_id,
product_id, ordering) ' .
' SELECT '.$product_category_id.', p.product_id, 1 FROM
`#__hikashop_product` AS p ' .
' LEFT JOIN `#__hikashop_product_category` AS pc ON p.product_id
= pc.product_id ' .
' WHERE p.product_type = ' .
$this->db->Quote('main') . ' AND pc.category_id IS
NULL;';
$msg = '';
try {
$this->db->setQuery($query);
$isError = $this->db->execute();
} catch(Exception $e) {
$isError = null;
$msg = $e->getMessage();
}
if($isError == null) {
if(empty($msg))
$msg = substr(strip_tags($this->db->getErrorMsg()), 0, 200);
$ret[] = array(
'error',
'Could not retrieve the missing products'
);
$ret[] = array('error_msg', $msg);
} else {
$ret[] = array(
'success',
sprintf('Add %d product(s) in the main product category',
$result)
);
}
} else if($result < 0) {
$ret[] = array(
'error',
'Could not check for missing products'
);
} else {
$ret[] = array(
'success',
'Product categories checked'
);
}
$query = 'UPDATE `#__hikashop_product` set product_parent_id=0 WHERE
product_type=\'main\';';
try {
$this->db->setQuery($query);
$result = $this->db->execute();
} catch(Exception $e) {
$ret[] = array(
'error',
$e->getMessage()
);
}
$query = 'SELECT characteristic_id FROM
`#__hikashop_characteristic`;';
try {
$this->db->setQuery($query);
$characteristic_ids = $this->db->loadColumn();
$where = '';
if(is_array($characteristic_ids) &&
count($characteristic_ids)){
$where = ' WHERE variant_characteristic_id NOT
IN('.implode(',',$characteristic_ids).')';
}
$query = 'DELETE FROM
`#__hikashop_variant`'.$where.';';
$this->db->setQuery($query);
$result = $this->db->execute();
if($result){
$ret[] = array(
'success',
'Variants orphan links cleaned'
);
}
} catch(Exception $e) {
$ret[] = array(
'error',
$e->getMessage()
);
}
$query = 'SELECT COUNT(*) FROM `#__hikashop_orderstatus`';
try{
$this->db->setQuery($query);
$result = $this->db->loadResult();
if(empty($result)) {
$query = 'INSERT IGNORE INTO `#__hikashop_orderstatus`
(orderstatus_name, orderstatus_description, orderstatus_published,
orderstatus_ordering, orderstatus_namekey) '.
' SELECT category_name, category_description,
category_published, category_ordering, category_namekey FROM
`#__hikashop_category` AS c '.
' WHERE c.category_type = \'status\' AND
c.category_depth > 1';
$this->db->setQuery($query);
$result = $this->db->execute();
if($result){
$ret[] = array(
'success',
'Order statuses imported'
);
}
}
} catch(Exception $e) {
$ret[] = array(
'error',
$e->getMessage()
);
}
$query = 'SELECT DISTINCT order_status COLLATE utf8_bin FROM
`#__hikashop_order` WHERE order_type = \'sale\'';
try{
$this->db->setQuery($query);
$statuses_in_orders = $this->db->loadColumn();
$query = 'SELECT * FROM `#__hikashop_orderstatus`';
$this->db->setQuery($query);
$order_statuses = $this->db->loadObjectList();
} catch(Exception $e) {
$ret[] = array(
'error',
$e->getMessage()
);
}
if(!empty($statuses_in_orders) && !empty($order_statuses)) {
$moves = array();
$invalids = array();
foreach($statuses_in_orders as $status_in_orders) {
$f = false;
foreach($order_statuses as $order_status) {
if($order_status->orderstatus_namekey == $status_in_orders) {
$f = true;
break;
}
if($order_status->orderstatus_name == $status_in_orders) {
$f = $order_status->orderstatus_namekey;
}
}
if($f === false) {
$invalids[] = $status_in_orders;
} elseif($f !== true) {
$moves[$status_in_orders] = $f;
}
}
foreach($moves as $old => $new) {
try{
$query = 'UPDATE `#__hikashop_order` SET order_status = ' .
$this->db->Quote($new).' WHERE order_status =
'.$this->db->Quote($old);
$this->db->setQuery($query);
$this->db->execute();
$ret[] = array(
'warning',
'Orders with order statuses `'.$old.'` changed to
`'.$new.'`'
);
} catch(Exception $e) {
$ret[] = array(
'error',
$e->getMessage()
);
}
}
foreach($invalids as $invalid) {
if(empty($invalid))
continue;
$ret[] = array(
'error',
'The order status `'.$invalid.'` is not found but
orders with that status exist'
);
}
}
$query = 'INSERT IGNORE INTO `#__hikashop_user`
(`user_email`,`user_cms_id`,`user_created`) SELECT `email`,
`id`,'.time().' FROM `#__users`';
$this->db->setQuery($query);
try{
$result = $this->db->execute();
if($result){
$ret[] = array(
'success',
'Joomla users synchronized'
);
}
} catch(Exception $e) {
$ret[] = array(
'error',
$e->getMessage()
);
}
$query = 'UPDATE `#__hikashop_user` AS hku LEFT JOIN `#__users` AS
ju ON hku.`user_email`=ju.`email` SET hku.`user_cms_id`=ju.`id` WHERE
hku.`user_cms_id`!=ju.`id`';
$this->db->setQuery($query);
try{
$result = $this->db->execute();
if($result){
$ret[] = array(
'success',
'User email addresses synchronized'
);
}
} catch(Exception $e) {
$ret[] = array(
'error',
$e->getMessage()
);
}
$app->triggerEvent('onHikashopAfterCheckDB',
array(&$ret));
$config = hikashop_config();
$cfgVersion = $config->get( 'version');
$manifestVersion = $this->getVersion_NumberOnly();
if ( version_compare( $manifestVersion, $cfgVersion) > 0) {
$query = "UPDATE `#__hikashop_config` SET `config_value` =
".$this->db->Quote($manifestVersion)." WHERE config_namekey
= 'version'";
$this->db->setQuery($query);
$this->db->execute();
}
self::$check_results = $ret;
return $ret;
}
public function getVersion()
{
static $instance;
if ( isset( $instance)) { return $instance; }
jimport('joomla.application.helper');
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$version = "unknown";
$folder = dirname(dirname(__FILE__));
$pattern = '^' . substr( basename(
dirname(dirname(__FILE__)),'.php'), 4) . '.*' .
'\.xml$';
$xmlFilesInDir = JFolder::files( $folder, $pattern);
if ( !empty( $xmlFilesInDir)) {
foreach ($xmlFilesInDir as $xmlfile) {
if ($data = JInstaller::parseXMLInstallFile($folder.DS.$xmlfile)) {
if ( isset( $found_version)) {
if ( version_compare( $data['version'], $found_version)
>= 0) {
$found_version = $data['version'];
}
}
else {
$found_version = $data['version'];
}
}
}
if ( !empty( $found_version)) {
$version = $found_version;
}
}
else {
$filename = dirname(dirname(__FILE__)) .DS. substr( basename(
dirname(dirname(__FILE__)),'.php'), 4).'.xml';
if (file_exists($filename) && $data =
JInstaller::parseXMLInstallFile($filename)) {
if (isset($data['version']) &&
!empty($data['version'])) {
$version = $data['version'];
}
}
}
$instance = $version;
return $instance;
}
public function getVersion_NumberOnly($verString = null) {
if(empty($verString)) {
$verString = $this->getVersion();
}
if ( preg_match( '#[A-Za-z0-9\.\s]+#i', $verString, $match))
{
$result = $match[0];
}
else {
$parts = explode( '-', $verString);
$result = $parts[0];
}
$result = str_replace( ' ', '.', trim( $result));
return $result;
}
public function getCheckResults() {
return self::$check_results;
}
public function &getNameboxData($typeConfig, &$fullLoad, $mode,
$value, $search, $options) {
$ret = array(
0 => array(),
1 => array()
);
$fullLoad = false;
$displayFormat = !empty($options['displayFormat']) ?
$options['displayFormat'] :
@$typeConfig['displayFormat'];
$start = (int)@$options['start']; // TODO
$limit = (int)@$options['limit'];
$page = (int)@$options['page'];
if($limit <= 0)
$limit = 50;
$table = @$options['table'];
$db = JFactory::getDBO();
if(!HIKASHOP_J30){
$columnsTable = $db->getTableFields(hikashop_table($table));
$columnsArray = reset($columnsTable);
} else {
$columnsArray = $db->getTableColumns(hikashop_table($table));
}
ksort($columnsArray);
if(!empty($search)) {
$results = array();
foreach($columnsArray as $k => $t) {
if(strpos($k, $search)!==false)
$results[$k] = $t;
}
$columnsArray = $results;
}
foreach($columnsArray as $k => $t) {
$obj = new stdClass();
$obj->column_name = $k;
$obj->column_type = $t;
$ret[0][$k] = $obj;
}
if(count($ret[0]) < $limit)
$fullLoad = true;
if(!empty($value)) {
if($mode == hikashopNameboxType::NAMEBOX_SINGLE &&
isset($ret[0][$value])) {
$ret[1][$value] = $ret[0][$value];
} elseif($mode == hikashopNameboxType::NAMEBOX_MULTIPLE &&
is_array($value)) {
foreach($value as $v) {
if(isset($ret[0][$v])) {
$ret[1][$v] = $ret[0][$v];
}
}
}
}
return $ret;
}
}
dropdown.php000064400000007067151162557560007140 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopDropdownHelper {
public function __construct() {
}
public function init() {
hikashop_loadJsLib('dropdown');
}
public function display($label, $data, $options = array()) {
$this->init();
$class = '';
if(!empty($options['main_class']))
$class .= ' '.$options['main_class'];
if(!empty($options['up']))
$class .= ' hkdropup';
$ret = '<div
class="hkdropdown'.$class.'">';
$extra = '';
if(!empty($options['label-id']))
$extra .= '
id="'.$options['label-id'].'"';
$caret = ' <span class="caret"></span>';
$drop_label = '<span
class="hkdropdown-text"'.$extra.'>'.htmlentities($label).'</span>'
. $caret;
if(!empty($options['hkicon']))
$drop_label = '<span class="hkdropdown-icon
'.htmlentities($options['hkicon']).'"
title="'.htmlentities($label).'"></span>
<span class="hkdropdown-label">'.htmlentities($label)
. $caret . '</span>';
if (!empty($options['fa'])) {
$fa_stack = is_array($options['fa']['html']) ?
'fa-stack ': '';
$fa_size = !empty($options['fa']['size']) ?
(int)$options['fa']['size'] : 2;
$fa_content = is_array($options['fa']['html']) ?
implode('', $options['fa']['html']) :
$options['fa']['html'];
$drop_label = '<span class="btnIcon hk-icon
'.$fa_stack.'fa-'.$fa_size.'x"
title="'.htmlentities($label).'">'.$fa_content.'</span>'.
' <span
class="hkdropdown-label">'.htmlentities($label) . $caret
. '</span>';
}
$extra = '';
if(!empty($options['id']))
$extra .= '
id="'.$options['id'].'"';
$class = 'hikabtn';
if(!empty($options['mini']))
$class .= ' '.$class.'-mini';
if(!empty($options['class']))
$class .= ' ' . $options['class'];
$type = @$options['type'];
switch($type) {
case 'caret':
$ret .= '<a href="#"
data-toggle="hkdropdown" class="caret"
aria-haspopup="true"
aria-expanded="false"></a>';
break;
case 'link':
$ret .= '<a href="#"
data-toggle="hkdropdown" aria-haspopup="true"
aria-expanded="false">'.$drop_label.'</a>';
break;
case 'button':
default:
$ret .= '<button type="button"
data-toggle="hkdropdown"
class="'.$class.'"'.$extra.'
aria-haspopup="true" aria-expanded="false">'.
$drop_label.
'</button>';
break;
}
$extra = '';
if(!empty($options['id']))
$extra .= '
aria-labelledby="'.$options['id'].'"';
$class = '';
if(!empty($options['right']))
$class .= ' hkdropdown-menu-right';
$ret .= '<ul
class="hkdropdown-menu'.$class.'"'.$extra.'>';
foreach($data as $d) {
if(empty($d) || $d === '-') {
$ret .= '<li role="separator"
class="divider"></li>';
continue;
}
if(empty($d['name']))
continue;
$name = $d['name'];
$link = '#';
$extra = '';
if(!empty($d['link']))
$link = $d['link'];
if(!empty($d['extra']))
$extra .= ' '.trim($d['extra']);
if(!empty($d['click']))
$extra .= '
onclick="'.trim($d['click']).'"';
if(!empty($d['header'])) {
$ret .= '<li><h6
class="hkdropdown-header"'.$extra.'>'.$name.'</h6></li>';
continue;
}
if(empty($d['disable']))
$ret .= '<li><a
href="'.$link.'"'.$extra.'>'.$name.'</a></li>';
else
$ret .= '<li class="disabled"><a
href="#" onclick="return
false;">'.$name.'</span></li>';
}
$ret .= '</ul></div>';
return $ret;
}
}
editor.php000064400000010333151162557560006560 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopEditorHelper{
var $width = '100%';
var $height = '500';
var $cols = 100;
var $rows = 20;
var $editor = null;
var $name = '';
var $content = '';
var $id = 'jform_articletext';
static $cpt = 0;
function __construct() {
$this->setEditor();
$this->options = array('pagebreak');
$config =& hikashop_config();
$readmore = $config->get('readmore',0);
if(!$readmore){
$this->options[]='readmore';
}
}
function setDescription() {
$this->width = 700;
$this->height = 200;
$this->cols = 80;
$this->rows = 10;
}
function setContent($var) {
$name = $this->myEditor->get('_name');
$function =
'try{'.$this->myEditor->setContent($this->name,$var).'
}catch(err){alert(\'Error using the setContent function of the wysiwyg
editor\')}';
if(!empty($name)){
if($name == 'jce'){
return '
try{JContentEditor.setContent(\''.$this->name.'\',
'.$var.');
}catch(err){try{WFEditor.setContent(\''.$this->name.'\',
'.$var.')}catch(err){'.$function.'} }';
}
if($name == 'fckeditor'){
return '
try{FCKeditorAPI.GetInstance(\''.$this->name.'\').SetHTML('.$var.');
}catch(err){'.$function.'} ';
}
if($name == 'jckeditor'){
return '
try{oEditor.setData('.$var.');}catch(err){(!oEditor) ?
CKEDITOR.instances.'.$this->name.'.setData('.$var.')
: oEditor.insertHtml = '.$var.'}';
}
if($name == 'ckeditor'){
return '
try{CKEDITOR.instances.'.$this->name.'.setData('.$var.');
}catch(err){'.$function.'} ';
}
if($name == 'artofeditor'){
return '
try{CKEDITOR.instances.'.$this->name.'.setData('.$var.');
}catch(err){'.$function.'} ';
}
}
return $function;
}
function getContent(){
return $this->myEditor->getContent($this->name);
}
function display() {
if(version_compare(JVERSION,'1.6','<')){
return $this->myEditor->display( $this->name,
$this->content ,$this->width, $this->height, $this->cols,
$this->rows,$this->options ) ;
}else{
$id = $this->id;
if(self::$cpt >= 1 && $this->id ==
'jform_articletext') {
$id = $this->id . '_' . self::$cpt;
}
self::$cpt++;
return $this->myEditor->display( $this->name,
$this->content ,$this->width, $this->height, $this->cols,
$this->rows,$this->options, $id ) ;
}
}
function jsCode() {
return $this->myEditor->save( $this->name );
}
function displayCode($name,$content){
if($this->hasCodeMirror()){
$this->setEditor('codemirror');
}else{
$this->setEditor('none');
}
$this->myEditor->setContent($name,$content);
if(version_compare(JVERSION,'1.6','<')){
return $this->myEditor->display( $name, $content
,$this->width, $this->height, $this->cols, $this->rows,false);
}else{
$id = $this->id;
if(self::$cpt >= 1 && $this->id ==
'jform_articletext') {
$id = $this->id . '_' . self::$cpt;
}
self::$cpt++;
return $this->myEditor->display( $name, $content
,$this->width, $this->height, $this->cols,
$this->rows,false,$id) ;
}
}
function setEditor($editor=''){
if(empty($editor)){
$config =& hikashop_config();
$this->editor = $config->get('editor',null);
if(empty($this->editor)) $this->editor = null;
}else{
$this->editor = $editor;
}
if (!HIKASHOP_PHP5) {
$this->myEditor =& JFactory::getEditor($this->editor);
}else{
$this->myEditor = JFactory::getEditor($this->editor);
}
$this->myEditor->initialise();
}
function hasCodeMirror(){
static $has = null;
if(!isset($has)){
if(version_compare(JVERSION,'1.6','<')){
$query = 'SELECT element FROM
'.hikashop_table('plugins',false).' WHERE
element=\'codemirror\' AND folder=\'editors\' AND
published=1';
}else{
$query = 'SELECT element FROM
'.hikashop_table('extensions',false).' WHERE
element=\'codemirror\' AND folder=\'editors\' AND
enabled=1 AND type=\'plugin\'';
}
$db = JFactory::getDBO();
$db->setQuery($query);
$editor = $db->loadResult();
$has = !empty($editor);
}
return $has;
}
}
encoding.php000064400000003607151162557560007066 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopEncodingHelper{
function change($data,$input,$output){
$input = strtoupper(trim($input));
$output = strtoupper(trim($output));
if($input == $output) return $data;
if($input == 'UTF-8' && $output ==
'ISO-8859-1'){
$data =
str_replace(array('ïżœ','ïżœ','ïżœ'),array('EUR','"','"'),$data);
}
if (function_exists('iconv')){
set_error_handler('hikashop_error_handler_encoding');
$encodedData = iconv($input, $output."//IGNORE", $data);
restore_error_handler();
if(!empty($encodedData) &&
!hikashop_error_handler_encoding('result')){
return $encodedData;
}
}
if (function_exists('mb_convert_encoding')){
return @mb_convert_encoding($data, $output, $input);
}
if ($input == 'ISO-8859-1' && $output ==
'UTF-8'){
return utf8_encode($data);
}
if ($input == 'UTF-8' && $output ==
'ISO-8859-1'){
return utf8_decode($data);
}
return $data;
}
function detectEncoding(&$content){
if(!function_exists('mb_check_encoding')) return '';
$toTest = array('UTF-8');
$lang = JFactory::getLanguage();
$tag = $lang->getTag();
if($tag == 'el-GR'){
$toTest[] = 'ISO-8859-7';
}
$toTest[] = 'ISO-8859-1';
$toTest[] = 'ISO-8859-2';
$toTest[] = 'Windows-1252';
foreach($toTest as $oneEncoding){
if(mb_check_encoding($content,$oneEncoding)) return $oneEncoding;
}
return '';
}
}
function hikashop_error_handler_encoding($errno,$errstr=''){
static $error = false;
if(is_string($errno) && $errno=='result'){
$currentError = $error;
$error = false;
return $currentError;
}
$error = true;
return true;
}
gallery.php000064400000014012151162557560006727 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopGalleryHelper {
var $extensions = array('jpg', 'jpeg',
'png', 'gif');
var $root = '';
var $urlRoot = '';
var $dirs = array();
var $dirlistdepth = 3;
var $hideFolders = array('safe', 'thumbnail',
'thumbnails', 'thumbnail_*');
function __construct() {
$config = hikashop_config();
$uploadFolderConfig =
rtrim(JPath::clean(html_entity_decode($config->get('uploadfolder'))),
DS) . DS;
$this->setRoot($uploadFolderConfig);
}
function setRoot($dir) {
if(strpos($dir,JPATH_ROOT)!==false){
$dir = str_replace(JPATH_ROOT,'',$dir);
}
$dir = ltrim($dir,'/');
$this->root = JPATH_ROOT.DS.$dir;
$app = JFactory::getApplication();
$dir = str_replace(DS, '/', $dir);
if($app->isAdmin())
$this->urlRoot = '../' . $dir;
else
$this->urlRoot = rtrim(JURI::base(true), '/') .
'/' . $dir;
}
function validatePath($path) {
if(empty($path))
return true;
jimport('joomla.filesystem.folder');
if(!JFolder::exists($this->root . $path))
return false;
return true;
}
function getTreeList($folder = '', $openTo = '') {
$id = 'hikashopGallery';
jimport('joomla.filesystem.folder');
if(!JFolder::exists($this->root . $folder))
return false;
$oToScript = '';
if(!empty($openTo)) {
$oToScript = '
var otoNode = '.$id.'.find("/'. trim($openTo,
'/').'");
if(otoNode) { '.$id.'.oTo(otoNode);
'.$id.'.sel(otoNode); }';
}
$ret = '<div id="'.$id.'_otree"
class="oTree"></div>
<script type="text/javascript">
var data_'.$id.' = ['.$this->_getTreeChildList(null,
'/').'];
'.$id.' = new
oTree("'.$id.'",{rootImg:"'.HIKASHOP_IMAGES.'otree/",showLoading:true,useSelection:true},null,data_'.$id.',true);
'.$id.'.render(true);'.$oToScript.'
</script>';
return $ret;
}
function _getTreeChildList($parent, $folder, $depth = 0) {
$ret = '';
if(empty($parent))
$parent = '';
if(!JFolder::exists($this->root . $parent . DS . $folder))
return false;
if($depth > $this->dirlistdepth)
return $ret;
$status = 1;
$jsName = str_replace('"','\"', $folder);
$jsValue = str_replace('"','\"', $parent .
'/' . $folder);
if(empty($parent))
$jsValue = str_replace('"','\"',
$folder);
if($parent == '/')
$jsValue = str_replace('"','\"',
'/' . $folder);
if(empty($parent) && $folder == '/') {
$jsName = str_replace('"', '\"',
JText::_('HIKASHOP_IMAGE_ROOTDIR'));
$jsValue = '/';
$status = 2;
}
if($depth == $this->dirlistdepth) {
$status = 3;
$ret =
'{status:'.$status.',name:"'.$jsName.'",value:"'.$jsValue.'"}';
return $ret;
}
$data = array();
$folders = JFolder::folders($this->root . $parent . DS . $folder);
if(!empty($folders)) {
$newParent = $parent . '/' . $folder;
if(empty($parent))
$newParent = $folder;
if($parent == '/')
$newParent = '/' . $folder;
foreach($folders as $f) {
$hide = false;
foreach($this->hideFolders as $h) {
if($f == $h) $hide = true;
if(substr($h, -1) == '*' && substr($f, 0, strlen($h)
- 1) == substr($h, 0, -1)) $hide = true;
if($hide) break;
}
if($hide)
continue;
$r = $this->_getTreeChildList($newParent, $f);
if(!empty($r))
$data[] = $r;
}
}
if(empty($data)) {
$status = 4;
$data = '';
} else {
$data = ',data:['.implode(',',$data).']';
}
$ret =
'{status:'.$status.',name:"'.$jsName.'",value:"'.$jsValue.'"'.$data.'}';
return $ret;
}
function getDirContent($folder = '', $options = array()) {
$ret = array();
$this->filecount = 0;
jimport('joomla.filesystem.folder');
if(!JFolder::exists($this->root . $folder))
return false;
$workingFolder = $this->root . $folder;
$externFolder = $this->urlRoot . $folder;
$workingFolder = rtrim(JPath::clean($workingFolder), DS) . DS;
if(!empty($options['filter']))
$files = JFolder::files($workingFolder, $options['filter']);
else
$files = JFolder::files($workingFolder);
if(empty($files))
return $ret;
$u =
array('B','KB','MB','GB','TB','PB');
$sizeOptions = array(100, 100);
$thumbnailsOptions = array(
'forcesize' => true,
'grayscale' => false,
'scale' => 'outside',
);
$imageHelper = hikashop_get('helper.image');
$imageHelper->thumbnail = 1;
natcasesort($files);
$images = array();
foreach($files as $file) {
if(strrpos($file, '.') === false)
continue;
$ext = strtolower(substr($file, strrpos($file, '.') + 1));
if(!in_array($ext, $this->extensions))
continue;
$images[] = $file;
}
unset($files);
$this->filecount = count($images);
$offset = 0;
$length = 30;
if(isset($options['length']) &&
(int)$options['length'] > 0)
$length = (int)$options['length'];
if(isset($options['offset']))
$offset = (int)$options['offset'];
if($offset == 0 && isset($options['page']))
$offset = (int)$options['page'] * $length;
if($offset >= $this->filecount)
$offset = 0;
$images = array_slice($images, $offset, $length);
foreach($images as $file) {
$image = new stdClass();
$image->filename = $file;
$image->path = $folder . $file;
$image->fullpath = $workingFolder . $file;
$image->baseurl = $externFolder;
$image->folder = $folder;
$image->rawsize = @filesize($workingFolder . $file);
$image->size = sprintf('%01.2f',
@round($image->rawsize/pow(1024,($i=floor(log($image->rawsize,1024)))),2)).'
'.$u[$i];
list($image->width, $image->height) =
getimagesize($image->fullpath);
$image->thumbnail =
$imageHelper->getThumbnail(ltrim($image->path, '/\\'),
$sizeOptions, $thumbnailsOptions, $this->root);
$image->thumbnail->url = $this->urlRoot .
str_replace('\\', '/', $image->thumbnail->path);
$ret[] = $image;
}
return $ret;
}
}
image.php000064400000067732151162557560006373 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopImageHelper{
function __construct() {
$config =& hikashop_config();
$uploadFolder =
ltrim(JPath::clean(html_entity_decode($config->get('uploadfolder'))),DS);
$uploadFolder = rtrim($uploadFolder,DS).DS;
$this->uploadFolder_url =
str_replace(DS,'/',$uploadFolder);
$this->uploadFolder = JPATH_ROOT.DS.$uploadFolder;
$app = JFactory::getApplication();
if($app->isAdmin()){
$this->uploadFolder_url =
'../'.$this->uploadFolder_url;
}else{
$this->uploadFolder_url =
rtrim(JURI::base(true),'/').'/'.$this->uploadFolder_url;
}
$this->thumbnail = $config->get('thumbnail',1);
$this->thumbnail_x = $config->get('thumbnail_x',100);
$this->thumbnail_y = $config->get('thumbnail_y',100);
$this->main_thumbnail_x = $this->thumbnail_x;
$this->main_thumbnail_y = $this->thumbnail_y;
$this->main_uploadFolder_url = $this->uploadFolder_url;
$this->main_uploadFolder = $this->uploadFolder;
static $done = false;
static $override = false;
if(!$done){
$done = true;
$chromePath =
JPATH_THEMES.DS.$app->getTemplate().DS.'html'.DS.'hikashop_image.php';
if (file_exists($chromePath)){
require_once ($chromePath);
$override = true;
}
}
$this->override = $override;
}
function display($path, $addpopup = true, $title = '', $options
= '', $optionslink = '', $width = 0, $height = 0,
$alt='') {
$html = '';
if(!$this->_checkImage($this->uploadFolder.$path)) {
$config =& hikashop_config();
$path = $config->get('default_image');
if($path == 'barcode.png') {
$this->uploadFolder_url = HIKASHOP_IMAGES;
$this->uploadFolder = HIKASHOP_MEDIA.'images'.DS;
}
if(!$this->_checkImage($this->uploadFolder.$path)) {
$this->uploadFolder_url = $this->main_uploadFolder_url;
$this->uploadFolder = $this->main_uploadFolder;
return $html;
}
}
if(empty($alt)){
$alt = $title;
}else{
$title = $alt;
}
list($this->width, $this->height) =
getimagesize($this->uploadFolder.$path);
if($width != 0 && $height != 0) {
$module = array(
0 => $height,
1 => $width
);
$this->main_thumbnail_x = $width;
$this->main_thumbnail_y = $height;
$html = $this->displayThumbnail($path, $title, is_string($addpopup),
$options, $module, $alt);
} else {
$html = $this->displayThumbnail($path, $title, is_string($addpopup),
$options, false, $alt);
}
if($addpopup) {
$config =& hikashop_config();
$popup_x = $config->get('max_x_popup',760);
$popup_y = $config->get('max_y_popup',480);
$this->width += 20;
$this->height += 30;
if($this->width > $popup_x)
$this->width = $popup_x;
if($this->height > $popup_y)
$this->height = $popup_y;
if(is_string($addpopup)) {
static $first=true;
if($first) {
if($this->override &&
function_exists('hikashop_image_toggle_js')) {
$js = hikashop_image_toggle_js($this);
} else {
$js = '
function hikashopChangeImage(id,url,x,y,obj,nTitle,nAlt){
if(nAlt === undefined) nAlt = \'\';
image=document.getElementById(id);
if(image){
image.src=url;
if(x) image.width=x;
if(y) image.height=y;
if(nAlt) image.alt=nAlt;
if(nTitle) image.title=nTitle;
}
image_link = document.getElementById(id+\'_link\');
if(image_link){
image_link.href=obj.href;
image_link.rel=obj.rel;
if(nAlt) image_link.title=nAlt;
if(nTitle) image_link.title=nTitle;
}
var myEls = getElementsByClass(\'hikashop_child_image\');
for ( i=0;i<myEls.length;i++ ) {
myEls[i].style.border=\'0px\';
}
obj.childNodes[0].style.border=\'1px solid\';
return false;
}
function getElementsByClass(searchClass,node,tag) {
var classElements = new Array();
if ( node == null )
node = document;
if ( tag == null )
tag = \'*\';
var els = node.getElementsByTagName(tag);
var elsLen = els.length;
var pattern = new
RegExp("(^|\\s)"+searchClass+"(\\s|$)");
for (i = 0, j = 0; i < elsLen; i++) {
if ( pattern.test(els[i].className) ) {
classElements[j] = els[i];
j++;
}
}
return classElements;
}
window.addEvent(\'domready\', function() {
image_link =
document.getElementById(\'hikashop_image_small_link_first\');
if(image_link){
image_link.childNodes[0].style.border=\'1px solid\';
}
});
';
}
$doc = JFactory::getDocument();
$doc->addScriptDeclaration("\n<!--\n".$js."\n//-->\n");
$first = false;
$optionslink.=' id="hikashop_image_small_link_first"
';
JHTML::_('behavior.modal');
}
if(!empty($this->no_size_override)) {
$this->thumbnail_x = '';
$this->thumbnail_y = '';
$this->uploadFolder_url_thumb = $this->uploadFolder_url.$path;
}
if($this->override &&
function_exists('hikashop_small_image_link_render')) {
$html =
hikashop_small_image_link_render($this,$path,$addpopup,$optionslink,$html,$title,$alt);
} else {
$html = '<a title="'.$title.'"
alt="'.$alt.'"
class="hikashop_image_small_link" rel="{handler:
\'image\'}"
href="'.$this->uploadFolder_url.$path.'"
onclick="SqueezeBox.fromElement(this,{parse:
\'rel\'});return false;" target="_blank"
onmouseover="return
hikashopChangeImage(\''.$addpopup.'\',\''.$this->uploadFolder_url_thumb.'\',\''.$this->thumbnail_x.'\',\''.$this->thumbnail_y.'\',this,\''.$title.'\',\''.$alt.'\');"
'.$optionslink.'>'.$html.'</a>';
}
} else {
JHTML::_('behavior.modal');
if($this->override &&
function_exists('hikashop_image_link_render')) {
$html =
hikashop_image_link_render($this,$path,$addpopup,$optionslink,$html,$title,$alt);
} else {
$html = '<a title="'.$title.'"
alt="'.$alt.'" rel="{handler:
\'image\'}" target="_blank"
href="'.$this->uploadFolder_url.$path.'"
onclick="SqueezeBox.fromElement(this,{parse:
\'rel\'});return false;"
'.$optionslink.'>'.$html.'</a>';
}
}
}
$this->uploadFolder_url = $this->main_uploadFolder_url;
$this->uploadFolder = $this->main_uploadFolder;
return $html;
}
function _checkImage($path){
if(!empty($path)){
jimport('joomla.filesystem.file');
if(JFile::exists($path)){
return true;
}
}
return false;
}
function checkSize(&$width,&$height,&$row){
$exists=false;
if(!empty($row->file_path)){
jimport('joomla.filesystem.file');
if(JFile::exists(HIKASHOP_MEDIA.'upload'.DS.$row->file_path)){
$exists=true;
}else{
$exists=false;
}
}
if(!$exists){
$config =& hikashop_config();
$path = $config->get('default_image');
if($path == 'barcode.png'){
$file_path=HIKASHOP_MEDIA.'images'.DS.'barcode.png';
}
if(!empty($path)){
jimport('joomla.filesystem.file');
if(JFile::exists($this->main_uploadFolder.$path)){
$exists=true;
}
}else{
$exists=false;
}
if($exists){
$file_path=$this->main_uploadFolder.$path;
}
}else{
$file_path=$this->main_uploadFolder.$row->file_path;
}
if(!empty($file_path)){
$theImage= new stdClass();
list($theImage->width, $theImage->height) =
getimagesize($file_path);
if(empty($width)){
if($theImage->height >= $height){
list($width, $height) = $this->scaleImage($theImage->width,
$theImage->height, 0, $height);
}else{
$width=$this->main_thumbnail_x;
}
}
if(empty($height)){
if($theImage->width >= $width){
list($width, $height) = $this->scaleImage($theImage->width,
$theImage->height, $width, 0);
}else{
$height=$this->main_thumbnail_y;
}
}
}
}
function getPath($file_path,$url=true){
if($url){
return $this->uploadFolder_url.$file_path;
}
return $this->uploadFolder.$file_path;
}
function
displayThumbnail($path,$title='',$reduceSize=false,$options='',$module=false,$alt=''){
if((empty($this->main_thumbnail_x) &&
!empty($this->main_thumbnail_y)) || (empty($this->main_thumbnail_y)
&& !empty($this->main_thumbnail_x))){
$module[0]=$this->main_thumbnail_y;
$module[1]=$this->main_thumbnail_x;
}
$new = $this->scaleImage($this->width,
$this->height,$this->main_thumbnail_x,$this->main_thumbnail_y);
if($new !== false) {
$this->thumbnail_x = $new[0];
$this->thumbnail_y = $new[1];
}else{
$this->thumbnail_x = $this->width;
$this->thumbnail_y = $this->height;
}
if($module){
if(empty($this->main_thumbnail_y)){$this->main_thumbnail_y=0;}
if(empty($this->main_thumbnail_x)){$this->main_thumbnail_x=0;}
$folder='thumbnail_'.$this->main_thumbnail_y.'x'.$this->main_thumbnail_x;
}else{
$folder='thumbnail_'.$this->thumbnail_y.'x'.$this->thumbnail_x;
}
if(!$reduceSize && !$module ){
$options.=' height="'.$this->thumbnail_y.'"
width="'.$this->thumbnail_x.'" ';
}
if($this->thumbnail){
jimport('joomla.filesystem.file');
$ok = true;
if(!JFile::exists($this->uploadFolder.$folder.DS.$path)){
if($module){
$ok = $this->generateThumbnail($path, $module);
}
else{
$ok = $this->generateThumbnail($path);
}
}
if($ok){
if(is_array($ok)){
$folder='thumbnail_'.$ok[0].'x'.$ok[1];
}
$this->uploadFolder_url_thumb=$this->uploadFolder_url.$folder.'/'.$path;
return '<img
src="'.$this->uploadFolder_url_thumb.'"
alt="'.$alt.'" title="'.$title.'"
'.$options.' />';
}
}
$this->uploadFolder_url_thumb=$this->uploadFolder_url.$path;
return '<img
src="'.$this->uploadFolder_url_thumb.'"
alt="'.$alt.'" title="'.$title.'"
'.$options.' />';
}
function getThumbnail($filename, $size = null, $options = array(),
$relativePath = true, $cachePath = null) {
$config =& hikashop_config();
$scalemode = 'inside';
$ret = new stdClass();
$ret->success = false;
$ret->path = $filename;
$ret->height = 0;
$ret->width = 0;
$ret->req_height = 0;
$ret->req_width = 0;
$fullFilename = $filename;
if($relativePath === true)
$fullFilename = $this->uploadFolder . $filename;
if(is_string($relativePath))
$fullFilename = $relativePath . $filename;
if($cachePath !== false && empty($cachePath))
$cachePath = $this->uploadFolder;
else if($cachePath !== false)
$cachePath = rtrim(JFolder::cleanPath($cachePath), DS) . DS;
if(!JFile::exists($fullFilename)) {
if(!isset($options['default']))
return $ret;
$config =& hikashop_config();
$ret->path = $filename = $config->get('default_image');
if($ret->path == 'barcode.png') {
$fullFilename = HIKASHOP_MEDIA.'images'.DS . $ret->path;
$ret->url = HIKASHOP_IMAGES . '/' . $ret->path;
$ret->origin_url = HIKASHOP_IMAGES . '/' . $ret->path;
$ret->filename = $ret->path;
} else {
$fullFilename = $this->uploadFolder . $ret->path;
}
if(!JFile::exists($fullFilename)) {
return $ret;
}
unset($ret->url);
unset($ret->filename);
}
if(empty($size))
$size = array('x' =>
(int)$config->get('thumbnail_x', 100), 'y' =>
(int)$config->get('thumbnail_y', 100));
if(isset($size['width']))
$size = array('x' => (int)$size['width'],
'y' => (int)$size['height']);
if(!isset($size['x']))
$size = array('x' => (int)$size[0], 'y' =>
(int)$size[1]);
$optString = '';
if(!empty($options['forcesize'])) $optString .= 'f';
if(!empty($options['grayscale'])) $optString .= 'g';
if(!empty($options['blur'])) $optString .= 'b';
if(!empty($options['scale'])) {
switch($options['scale']) {
case 'outside':
$scalemode = 'outside';
$optString .= 'sO';
case 'inside':
break;
}
}
if(!empty($options['radius']) &&
(int)$options['radius'] > 2) $optString .=
'r'.(int)$options['radius'];
$destFolder = 'thumbnails' . DS . $size['y'] .
'x' . $size['x'] . $optString;
$ret->req_height = $size['y'];
$ret->req_width = $size['x'];
$origin = new stdClass();
list($origin->width, $origin->height) =
getimagesize($fullFilename);
$ret->orig_height = $origin->height;
$ret->orig_width = $origin->width;
if($cachePath !== false && JFile::exists($cachePath . $destFolder
. DS . $filename)) {
$ret->success = true;
$ret->path = $destFolder . DS . $filename;
$ret->filename = $filename;
$ret->url = $this->uploadFolder_url . str_replace('\\',
'/', $ret->path);
if(empty($ret->origin_url))
$ret->origin_url = $this->uploadFolder_url .
str_replace('\\', '/', $filename);
list($ret->width, $ret->height) = getimagesize($cachePath .
$destFolder . DS . $filename);
return $ret;
}
$scaling = $this->scaleImage($origin->width, $origin->height,
$size['x'], $size['y'], $scalemode);
if($scaling === false && empty($options['forcesize']))
{
$ret->success = true;
$ret->width = $origin->width;
$ret->height = $origin->height;
$ret->filename = $filename;
$ret->url = $this->uploadFolder_url . str_replace('\\',
'/', $ret->path);
if(empty($ret->origin_url))
$ret->origin_url = $this->uploadFolder_url .
str_replace('\\', '/', $filename);
return $ret;
}
unset($ret->url);
if($scaling === false) {
$scaling = array($origin->width, $origin->height);
}
$extension = strtolower(substr($filename, strrpos($filename,
'.') + 1));
$quality = array(
'jpg' => 95,
'png' => 9
);
if(!empty($options['quality'])) {
if(is_array($options['quality'])) {
if(!empty($options['quality']['jpg']))
$quality['jpg'] =
(int)$options['quality']['jpg'];
if(!empty($options['quality']['png']))
$quality['png'] =
(int)$options['quality']['png'];
} elseif((int)$options['quality'] > 0) {
$quality['jpg'] = (int)$options['quality'];
}
}
$img = $this->_getImage($fullFilename, $extension);
if(!$img)
return false;
$transparentIndex = imagecolortransparent($img);
if(in_array($extension, array('gif', 'png'))) {
imagealphablending($img, false);
imagesavealpha($img, true);
}
if(empty($options['forcesize']))
$thumb = imagecreatetruecolor($scaling[0], $scaling[1]);
else
$thumb = imagecreatetruecolor($size['x'],
$size['y']);
$bgcolor = $this->_getBackgroundColor($thumb,
@$option['background']);
if(in_array($extension,array('gif', 'png'))) {
if($transparentIndex >= 0) {
$trnprt_color = imagecolorsforindex($img, $transparentIndex);
$color = imagecolorallocate($thumb, $trnprt_color['red'],
$trnprt_color['green'], $trnprt_color['blue']);
imagecolortransparent($thumb, $color);
imagefill($thumb, 0, 0, $color);
} elseif($extension == 'png') {
imagealphablending($thumb, false);
$color = imagecolorallocatealpha($thumb, 0, 0, 0, 127);
imagefill($thumb, 0, 0, $color);
imagesavealpha($thumb, true);
}
} else {
imagefill($thumb, 0, 0, $bgcolor);
}
if(function_exists('imageantialias')) {
imageantialias($thumb, true);
}
$x = 0;
$y = 0;
$sx = $scaling[0];
$sy = $scaling[1];
if(!empty($options['forcesize'])) {
$x = ($size['x'] - $scaling[0]) / 2;
$y = ($size['y'] - $scaling[1]) / 2;
} else {
if($origin->width < $sx) $sx = $origin->width;
if($origin->height < $sy) $sy = $origin->height;
}
if(function_exists('imagecopyresampled')) {
imagecopyresampled($thumb, $img, $x, $y, 0, 0, $sx, $sy,
$origin->width, $origin->height);
} else {
imagecopyresized($thumb, $img, $x, $y, 0, 0, $sx, $sy,
$origin->width, $origin->height);
}
if(!empty($options['radius']) &&
(int)$options['radius'] > 2) {
$radius = (int)$options['radius'];
$corner_image = imagecreatetruecolor($radius, $radius);
imagealphablending($corner_image, false);
imagesavealpha($corner_image, true);
$bgcolor = $this->_getBackgroundColor($corner_image,
@$option['background']);
$color = imagecolorallocatealpha($corner_image, 0, 0, 0, 127);
imagecolortransparent($corner_image, $color);
imagefill($corner_image, 0, 0, $bgcolor);
imagefilledellipse($corner_image, $radius, $radius, $radius * 2, $radius
* 2, $color);
imagecopymerge($thumb, $corner_image, 0, 0, 0, 0, $radius, $radius,
100);
$corner_image = imagerotate($corner_image, 90, 0);
imagecopymerge($thumb, $corner_image, 0, $scaling[1] - $radius, 0, 0,
$radius, $radius, 100);
$corner_image = imagerotate($corner_image, 90, 0);
imagecopymerge($thumb, $corner_image, $scaling[0] - $radius, $scaling[1]
- $radius, 0, 0, $radius, $radius, 100);
$corner_image = imagerotate($corner_image, 90, 0);
imagecopymerge($thumb, $corner_image, $scaling[0] - $radius, 0, 0, 0,
$radius, $radius, 100);
}
if(function_exists('imagefilter')) {
if(!empty($options['grayscale']))
imagefilter($thumb, IMG_FILTER_GRAYSCALE);
if(!empty($options['blur']))
imagefilter($thumb, IMG_FILTER_GAUSSIAN_BLUR);
}
ob_start();
switch($extension) {
case 'gif':
$status = imagegif($thumb);
break;
case 'jpg':
case 'jpeg':
$status = imagejpeg($thumb, null, $quality['jpg']);
break;
case 'png':
$status = imagepng($thumb, null, $quality['png']);
break;
}
imagedestroy($img);
@imagedestroy($thumb);
$imageContent = ob_get_clean();
if($cachePath === false) {
$ret->success = $status;
$ret->data = $imageContent;
return $ret;
}
$ret->success = $status && JFile::write($cachePath .
$destFolder . DS . $filename, $imageContent);
if($ret->success) {
list($ret->width, $ret->height) = getimagesize($cachePath .
$destFolder . DS . $filename);
$ret->path = $destFolder . DS . $filename;
$ret->filename = $filename;
$ret->url = $this->uploadFolder_url . str_replace('\\',
'/', $ret->path);
if(empty($ret->origin_url))
$ret->origin_url = $this->uploadFolder_url .
str_replace('\\', '/', $filename);
}
return $ret;
}
function _getBackgroundColor($resource, $color) {
if(!empty($color)) {
if(is_array($color)) {
$bgcolor = imagecolorallocatealpha($resource, $color[0], $color[1],
$color[2], 0);
} elseif( is_string($color) ) {
$rgb = str_split(ltrim($color, '#'), 2);
$bgcolor = imagecolorallocatealpha($resource, hexdec($rgb[0]),
hexdec($rgb[1]), hexdec($rgb[2]), 0);
}
}
if(empty($bgcolor)) {
$bgcolor = imagecolorallocatealpha($resource, 255, 255, 255, 0);
}
return $bgcolor;
}
function generateThumbnail($file_path, $module=false){
$ok = true;
if($this->thumbnail){
$ok = false;
$gd_ok = false;
if (function_exists('gd_info')) {
$gd = gd_info();
if (isset ($gd["GD Version"])) {
$gd_ok = true;
list($this->width, $this->height) =
getimagesize($this->uploadFolder.$file_path);
$config =& hikashop_config();
if($module){
$thumbnail_x=$module[1];
$thumbnail_y=$module[0];
}
else{
$thumbnail_x=$config->get('thumbnail_x',100);
$thumbnail_y=$config->get('thumbnail_y',100);
}
if(!$thumbnail_x && !$thumbnail_y){
return true;
};
$new = $this->scaleImage($this->width,
$this->height,$thumbnail_x,$thumbnail_y);
if($new!==false){
if(empty($thumbnail_y)){$thumbnail_y=0;}
if(empty($thumbnail_x)){$thumbnail_x=0;}
$ok = $this->_resizeImage($file_path, $new[0], $new[1],
$this->uploadFolder.'thumbnail_'.$thumbnail_y.'x'.$thumbnail_x.DS);
if($ok & !$module){
$ok = array($new[1],$new[0]);
}
}
}
}
if(!$gd_ok){
$app =& JFactory::getApplication();
if($app->isAdmin()){
$app->enqueueMessage('The PHP GD extension could not be found.
Thus, it is impossible to generate thumbnails in PHP from your images. If
you want HikaShop to generate thumbnails you need to install GD or ask your
hosting company to do so. Otherwise, you can deactivate thumbnails creation
in the configuration of HikaShop and this message won\'t be
displayed');
}
}
}
return $ok;
}
function resizeImage($file_path, $type = 'image', $size = null,
$options = null) {
$config =& hikashop_config();
$image_x = $config->get('image_x',0);
$image_y = $config->get('image_y',0);
if(!empty($size) && is_array($size)) {
if(isset($size['x']) || isset($size['y'])) {
$image_x = (int)@$size['x'];
$image_y = (int)@$size['y'];
} else if(isset($size['width']) ||
isset($size['height'])) {
$image_x = (int)@$size['width'];
$image_y = (int)@$size['height'];
} else {
$image_x = $size[0];
$image_y = $size[1];
}
}
$watermark_name = '';
if(empty($options) || (isset($options['watermark']) &&
$options['watermark'] === true)) {
$watermark_name = $config->get('watermark','');
}
if(!empty($options['watermark']) &&
is_string($options['wartermark'])) {
$watermark_name = $options['watermark'];
}
$ok = true;
if(($image_x || $image_y) || !empty($watermark_name)){
$ok = false;
$gd_ok = false;
if(function_exists('gd_info')) {
$gd = gd_info();
if(isset($gd["GD Version"])) {
$gd_ok = true;
$new = getimagesize($this->uploadFolder . $file_path);
$this->width=$new[0];
$this->height=$new[1];
if(!$image_x && !$image_y && empty($watermark_name)){
return true;
}
if($image_x || $image_y){
$new = $this->scaleImage($this->width,
$this->height,$image_x,$image_y);
if($new === false) {
$new = array($this->width, $this->height);
}
}
$ok = $this->_resizeImage($file_path, $new[0], $new[1],
$this->uploadFolder, $type);
}
}
if(!$gd_ok){
$app =& JFactory::getApplication();
if($app->isAdmin()){
$app->enqueueMessage('The PHP GD extension could not be found.
Thus, it is impossible to process your images in PHP. If you want HikaShop
to process your images, you need to install GD or ask your hosting company
to do so. Otherwise, you can deactivate thumbnails creation, remove your
watermark image if any, and clear the image max width and height in the
configuration of HikaShop and this message won\'t be
displayed');
}
}
}
return $ok;
}
function _resizeImage($file_path, $newWidth, $newHeight, $dstFolder =
'', $type = 'thumbnail') {
$image = $this->uploadFolder.$file_path;
if(empty($dstFolder)){
$dstFolder =
$this->uploadFolder.'thumbnail_'.$this->thumbnail_y.'x'.$this->thumbnail_x.DS;
}
$watermark_path = '';
if($type=='image'){
if(hikashop_level(2)){
$config =& hikashop_config();
$watermark_name = $config->get('watermark','');
if(!empty($watermark_name)){
$watermark_path = $this->main_uploadFolder.$watermark_name;
if(!$this->_checkImage($watermark_path)){
$watermark_path = '';
}else{
$wm_extension =
strtolower(substr($watermark_path,strrpos($watermark_path,'.')+1));
$watermark = $this->_getImage($watermark_path,$wm_extension);
if($watermark){
if(in_array($wm_extension,array('gif','png'))){
imagealphablending($watermark, false);
imagesavealpha($watermark,true);
}
}else{
$watermark_path = '';
}
}
}
}
}
$extension =
strtolower(substr($file_path,strrpos($file_path,'.')+1));
$img = $this->_getImage($image,$extension);
if(!$img) return false;
if(in_array($extension,array('gif','png'))){
imagealphablending($img, false);
imagesavealpha($img,true);
}
if($newWidth!=$this->width || $newHeight!=$this->height){
$thumb = ImageCreateTrueColor($newWidth, $newHeight);
if(in_array($extension,array('gif','png'))){
$trnprt_indx = imagecolortransparent($img);
if ($trnprt_indx >= 0) {
$trnprt_color = imagecolorsforindex($img, $trnprt_indx);
$trnprt_indx = imagecolorallocate($thumb,
$trnprt_color['red'], $trnprt_color['green'],
$trnprt_color['blue']);
imagefill($thumb, 0, 0, $trnprt_indx);
imagecolortransparent($thumb, $trnprt_indx);
}elseif($extension=='png'){
imagealphablending($thumb, false);
$color = imagecolorallocatealpha($thumb, 0, 0, 0, 127);
imagefill($thumb, 0, 0, $color);
imagesavealpha($thumb,true);
}
}
if(function_exists("imageAntiAlias")) {
imageAntiAlias($thumb,true);
}
if(function_exists("imagecopyresampled")){
ImageCopyResampled($thumb, $img, 0, 0, 0, 0, $newWidth,
$newHeight,$this->width, $this->height);
}else{
ImageCopyResized($thumb, $img, 0, 0, 0, 0, $newWidth,
$newHeight,$this->width, $this->height);
}
}else{
$thumb =& $img;
}
if(!empty($watermark_path)){
list($wm_width,$wm_height) = getimagesize($watermark_path);
$padding = 3;
$dest_x = $newWidth - $wm_width - $padding;
if($dest_x < 0) $dest_x = 0;
$dest_y = $newHeight - $wm_height - $padding;
if($dest_y < 0) $dest_y = 0;
$trnprt_color=null;
if(in_array($extension,array('gif','png'))){
$trnprt_indx = imagecolortransparent($img);
if ($trnprt_indx >= 0) {
$trnprt_color = imagecolorsforindex($img, $trnprt_indx);
}
}
imagealphablending($thumb, false);
imagealphablending($watermark, false);
$this->imagecopymerge_alpha($thumb, $watermark, $dest_x, $dest_y, 0,
0, $wm_width, $wm_height,
(int)$config->get('opacity',0),$trnprt_color);
imagedestroy($watermark);
}
$dest = $dstFolder.$file_path;
ob_start();
switch($extension){
case 'gif':
$status = imagegif($thumb);
break;
case 'jpg':
case 'jpeg':
$status = imagejpeg($thumb,null,100);
break;
case 'png':
$status = imagepng($thumb,null,0);
break;
}
$imageContent = ob_get_clean();
$status = $status && JFile::write($dest,$imageContent);
imagedestroy($img);
@imagedestroy($thumb);
return $status;
}
function _getImage($image,$extension){
switch($extension){
case 'gif':
return ImageCreateFromGIF($image);
break;
case 'jpg':
case 'jpeg':
return ImageCreateFromJPEG($image);
break;
case 'png':
return ImageCreateFromPNG($image);
break;
}
}
function scaleImage($x, $y, $cx, $cy, $scaleMode = 'inside') {
if(empty($cx)) $cx = 9999;
if(empty($cy)) $cy = 9999;
if ($x >= $cx || $y >= $cy) {
if ($x>0) $rx = $cx / $x;
if ($y>0) $ry = $cy / $y;
switch($scaleMode) {
case 'outside': {
if ($rx > $ry)
$r = $rx;
else
$r = $ry;
}
break;
case 'inside':
default: {
if ($rx > $ry)
$r = $ry;
else
$r = $rx;
}
break;
}
$x = intval($x * $r);
$y = intval($y * $r);
return array($x,$y);
}
return false;
}
function imagecopymerge_alpha($dst_im, $src_im, $dst_x, $dst_y, $src_x,
$src_y, $src_w, $src_h, $pct, $trans = NULL)
{
$dst_w = imagesx($dst_im);
$dst_h = imagesy($dst_im);
$src_x = max($src_x, 0);
$src_y = max($src_y, 0);
$dst_x = max($dst_x, 0);
$dst_y = max($dst_y, 0);
if ($dst_x + $src_w > $dst_w)
$src_w = $dst_w - $dst_x;
if ($dst_y + $src_h > $dst_h)
$src_h = $dst_h - $dst_y;
for($x_offset = 0; $x_offset < $src_w; $x_offset++) {
for($y_offset = 0; $y_offset < $src_h; $y_offset++) {
$srccolor = imagecolorsforindex($src_im, imagecolorat($src_im, $src_x +
$x_offset, $src_y + $y_offset));
$dstcolor = imagecolorsforindex($dst_im, imagecolorat($dst_im, $dst_x +
$x_offset, $dst_y + $y_offset));
if (is_null($trans) || ($srccolor !== $trans)) {
$src_a = $srccolor['alpha'] * $pct / 100;
$src_a = 127 - $src_a;
$dst_a = 127 - $dstcolor['alpha'];
$dst_r = ($srccolor['red'] * $src_a +
$dstcolor['red'] * $dst_a * (127 - $src_a) / 127) / 127;
$dst_g = ($srccolor['green'] * $src_a +
$dstcolor['green'] * $dst_a * (127 - $src_a) / 127) / 127;
$dst_b = ($srccolor['blue'] * $src_a +
$dstcolor['blue'] * $dst_a * (127 - $src_a) / 127) / 127;
$dst_a = 127 - ($src_a + $dst_a * (127 - $src_a) / 127);
$color = imagecolorallocatealpha($dst_im, $dst_r, $dst_g, $dst_b,
$dst_a);
if (!imagesetpixel($dst_im, $dst_x + $x_offset, $dst_y + $y_offset,
$color))
return false;
imagecolordeallocate($dst_im, $color);
}
}
}
return true;
}
}
import/index.html000064400000000034151162557560010065
0ustar00<html><body></body></html>
import/mijo.php000064400000200124151162557560007541 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
include_once HIKASHOP_HELPER . 'import.php';
@include(HIKASHOP_ROOT .
'components/com_mijoshop/opencart/admin/config.php');
class hikashopImportmijoHelper extends hikashopImportHelper
{
var $importcurrencies;
function __construct()
{
parent::__construct();
$this->importName = 'mijo';
jimport('joomla.filesystem.file');
}
function importFromMijo()
{
@ob_clean();
echo $this->getHtmlPage();
$this->token = hikashop_getFormToken();
flush();
if( isset($_GET['import']) && $_GET['import']
== '1' )
{
$this->importcurrencies =
hikaInput::get()->getInt('importcurrencies');
$time = microtime(true);
$processed = $this->doImport();
if( $processed )
{
$elasped = microtime(true) - $time;
if( !$this->refreshPage )
echo
'<p><br/><a'.$this->linkstyle.'href="'.hikashop_completeLink('import&task=import&importfrom=mijo&'.$this->token.'=1&import=1&importcurrencies='.$this->importcurrencies.'&time='.time()).'">'.JText::_('HIKA_NEXT').'</a></p>';
echo '<p style="font-size:0.85em;
color:#605F5D;">Elasped time: ' . round($elasped * 1000, 2) .
'ms</p>';
}
else
{
echo
'<a'.$this->linkstyle.'href="'.hikashop_completeLink('import&task=show').'">'.JText::_('HIKA_BACK').'</a>';
}
}
else
{
echo $this-> getStartPage();
}
if( $this->refreshPage )
{
echo "<script type=\"text/javascript\">\r\nr =
true;\r\n</script>";
}
echo '</body></html>';
exit;
}
function getStartPage()
{
$this->importcurrencies =
hikaInput::get()->getInt('import_currencies');
return '<span style="color:#297F93;
font-size:1.2em;text-decoration:underline;">Step
0</span><br/><br/>'.
'Make a backup of your database.<br/>'.
'When ready, click on <a '.$this->linkstyle.'
href="'.hikashop_completeLink('import&task=import&importfrom=mijo&'.$this->token.'=1&import=1&importcurrencies='.$this->importcurrencies).'">'.JText::_('HIKA_NEXT').'</a>,
otherwise '.
'<a'.$this->linkstyle.'
href="'.hikashop_completeLink('import&task=show').'">'.JText::_('HIKA_BACK').'</a>.';
}
function doImport()
{
if( $this->db == null )
return false;
$this->loadConfiguration();
$current = $this->options->current;
$ret = true;
$next = false;
switch($this->options->state)
{
case 0:
$next = $this->createTables();
break;
case 1:
$next = $this->importTaxes();
break;
case 2:
$next = $this->importManufacturers();
break;
case 3:
$next = $this->importCategories();
break;
case 4:
$next = $this->importProducts();
break;
case 5:
$next = $this->importProductPrices();
break;
case 6:
$next = $this->importProductCategory();
break;
case 7:
$next = $this->importUsers();
break;
case 8:
$next = $this->importDiscount();
break;
case 9:
$next = $this->importOrders();
break;
case 10:
$next = $this->importOrderItems();
break;
case 11:
$next = $this->importDownloads();
break;
case 12:
case 13:
$next = $this->finishImport();
$ret = false;
break;
case 14:
$next = false;
$ret = $this->proposeReImport();
break;
default:
$ret = false;
break;
}
if( $ret && $next )
{
$sql = "UPDATE `#__hikashop_config` SET
config_value=(config_value+1) WHERE config_namekey =
'mijo_import_state'; ";
$this->db->setQuery($sql);
$this->db->execute();
$sql = "UPDATE `#__hikashop_config` SET config_value=0 WHERE
config_namekey = 'mijo_import_current';";
$this->db->setQuery($sql);
$this->db->execute();
}
else if( $current != $this->options->current )
{
$sql = "UPDATE `#__hikashop_config` SET
config_value=".$this->options->current." WHERE
config_namekey = 'mijo_import_current';";
$this->db->setQuery($sql);
$this->db->execute();
}
return $ret;
}
function loadConfiguration()
{
$this->options = new stdClass();
if (defined('DIR_IMAGE')) {
if(strpos(DIR_IMAGE, HIKASHOP_ROOT) === false)
$this->copyImgDir = HIKASHOP_ROOT.DIR_IMAGE;
else
$this->copyImgDir = DIR_IMAGE;
} else
$this->copyImgDir =
HIKASHOP_ROOT.'components/com_mijoshop/opencart/image/';
if (defined('DIR_IMAGE')) {
if(strpos(DIR_IMAGE, HIKASHOP_ROOT) === false)
$this->copyCatImgDir = HIKASHOP_ROOT.DIR_IMAGE;
else
$this->copyCatImgDir = DIR_IMAGE;
} else
$this->copyCatImgDir =
HIKASHOP_ROOT.'components/com_mijoshop/opencart/image/';
if (defined('DIR_DOWNLOAD')) {
if(strpos(DIR_DOWNLOAD, HIKASHOP_ROOT) === false)
$this->copyDownloadDir = HIKASHOP_ROOT.DIR_DOWNLOAD;
else
$this->copyDownloadDir = DIR_DOWNLOAD;
} else
$this->copyDownloadDir =
HIKASHOP_ROOT.'components/com_mijoshop/opencart/download/';
$data = array(
'uploadfolder',
'uploadsecurefolder',
'main_currency',
'mijo_import_state',
'mijo_import_current',
'mijo_import_tax_id',
'mijo_import_main_cat_id',
'mijo_import_max_hk_cat',
'mijo_import_max_hk_prod',
'mijo_import_last_mijo_cat',
'mijo_import_last_mijo_prod',
'mijo_import_last_mijo_user',
'mijo_import_last_mijo_order',
'mijo_import_last_mijo_pfile',
'mijo_import_last_mijo_coupon',
'mijo_import_last_mijo_voucher',
'mijo_import_last_mijo_taxrate',
'mijo_import_last_mijo_taxclass',
'mijo_import_last_mijo_manufacturer'
);
$this->db->setQuery('SELECT config_namekey, config_value FROM
`#__hikashop_config` WHERE config_namekey IN
('."'".implode("','",$data)."'".');');
$result = $this->db->loadObjectList();
if (!empty($result))
{
foreach($result as $o)
{
if( substr($o->config_namekey, 0, 12) == 'mijo_import_' )
$nk = substr($o->config_namekey, 12);
else
$nk = $o->config_namekey;
$this->options->$nk = $o->config_value;
}
}
$this->options->uploadfolder =
rtrim(JPath::clean(html_entity_decode($this->options->uploadfolder)),DS.'
').DS;
if(!preg_match('#^([A-Z]:)?/.*#',$this->options->uploadfolder)){
if(!$this->options->uploadfolder[0]=='/' ||
!is_dir($this->options->uploadfolder)){
$this->options->uploadfolder =
JPath::clean(HIKASHOP_ROOT.DS.trim($this->options->uploadfolder,DS.'
').DS);
}
}
$this->options->uploadsecurefolder =
rtrim(JPath::clean(html_entity_decode($this->options->uploadsecurefolder)),DS.'
').DS;
if(!preg_match('#^([A-Z]:)?/.*#',$this->options->uploadsecurefolder)){
if(!$this->options->uploadsecurefolder[0]=='/' ||
!is_dir($this->options->uploadsecurefolder)){
$this->options->uploadsecurefolder =
JPath::clean(HIKASHOP_ROOT.DS.trim($this->options->uploadsecurefolder,DS.'
').DS);
}
}
if( !isset($this->options->state) )
{
$this->options->state = 0;
$this->options->current = 0;
$this->options->tax_id = 0;
$this->options->last_mijo_coupon = 0;
$this->options->last_mijo_voucher = 0;
$this->options->last_mijo_pfile = 0;
$this->options->last_mijo_taxrate = 0;
$this->options->last_mijo_taxclass = 0;
$this->options->last_mijo_manufacturer = 0;
$element = 'product';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$this->options->main_cat_id = $element;
$this->db->setQuery("SELECT max(category_id) as
'max' FROM `#__hikashop_category`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(product_id) as
'max' FROM `#__hikashop_product`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_prod = (int)($data[0]->max);
$query='SHOW TABLES LIKE
'.$this->db->Quote($this->db->getPrefix().substr(hikashop_table('mijo_cat'),3));
$this->db->setQuery($query);
$table = $this->db->loadResult();
if(!empty($table))
{
$this->db->setQuery("SELECT max(mijo_id) as 'max'
FROM `#__hikashop_mijo_cat`;");
$data = $this->db->loadObjectList();
if( $data )
$this->options->last_mijo_cat = (int)($data[0]->max);
else
$this->options->last_mijo_cat = 0;
$this->db->setQuery("SELECT max(mijo_id) as 'max'
FROM `#__hikashop_mijo_prod`;");
$data = $this->db->loadObjectList();
if( $data )
$this->options->last_mijo_prod = (int)($data[0]->max);
else
$this->options->last_mijo_prod = 0;
$this->db->setQuery("SELECT max(order_mijo_id) as
'max' FROM `#__hikashop_order`;");
$data = $this->db->loadObjectList();
if( $data )
$this->options->last_mijo_order = (int)($data[0]->max);
else
$this->options->last_mijo_order = 0;
}
else
{
$this->options->last_mijo_cat = 0;
$this->options->last_mijo_prod = 0;
$this->options->last_mijo_order = 0;
}
$this->options->last_mijo_user = 0;
$sql = 'INSERT IGNORE INTO `#__hikashop_config`
(`config_namekey`,`config_value`,`config_default`) VALUES '.
"('mijo_import_state',".$this->options->state.",".$this->options->state.")".
",('mijo_import_current',".$this->options->current.",".$this->options->current.")".
",('mijo_import_tax_id',".$this->options->tax_id.",".$this->options->tax_id.")".
",('mijo_import_main_cat_id',".$this->options->main_cat_id.",".$this->options->main_cat_id.")".
",('mijo_import_max_hk_cat',".$this->options->max_hk_cat.",".$this->options->max_hk_cat.")".
",('mijo_import_max_hk_prod',".$this->options->max_hk_prod.",".$this->options->max_hk_prod.")".
",('mijo_import_last_mijo_cat',".$this->options->last_mijo_cat.",".$this->options->last_mijo_cat.")".
",('mijo_import_last_mijo_prod',".$this->options->last_mijo_prod.",".$this->options->last_mijo_prod.")".
",('mijo_import_last_mijo_user',".$this->options->last_mijo_user.",".$this->options->last_mijo_user.")".
",('mijo_import_last_mijo_order',".$this->options->last_mijo_order.",".$this->options->last_mijo_order.")".
",('mijo_import_last_mijo_pfile',".$this->options->last_mijo_pfile.",".$this->options->last_mijo_pfile.")".
",('mijo_import_last_mijo_coupon',".$this->options->last_mijo_coupon.",".$this->options->last_mijo_coupon.")".
",('mijo_import_last_mijo_voucher',".$this->options->last_mijo_voucher.",".$this->options->last_mijo_voucher.")".
",('mijo_import_last_mijo_taxrate',".$this->options->last_mijo_taxrate.",".$this->options->last_mijo_taxrate.")".
",('mijo_import_last_mijo_taxclass',".$this->options->last_mijo_taxclass.",".$this->options->last_mijo_taxclass.")".
",('mijo_import_last_mijo_manufacturer',".$this->options->last_mijo_manufacturer.",".$this->options->last_mijo_manufacturer.")".
';';
$this->db->setQuery($sql);
$this->db->execute();
}
}
function createTables()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
1 :</span>Â Initialization Tables</p>';
$create = true;
$query='SHOW TABLES LIKE
'.$this->db->Quote($this->db->getPrefix().substr(hikashop_table('mijo_cat'),3));
$this->db->setQuery($query);
$table = $this->db->loadResult();
if (!empty($table))
$create = false;
if ($create)
{
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_mijo_prod` (`mijo_id` int(11) unsigned NOT NULL DEFAULT
'0', `hk_id` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`mijo_id`)) ENGINE=MyISAM");
$this->db->execute();
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_mijo_cat` (`mijo_cat_id` INT(11) unsigned NOT NULL
AUTO_INCREMENT, `mijo_id` int(11) unsigned NOT NULL DEFAULT '0',
`hk_id` int(11) unsigned NOT NULL DEFAULT '0', `category_type`
varchar(255) NULL, PRIMARY KEY (`mijo_cat_id`)) ENGINE=MyISAM");
$this->db->execute();
$databaseHelper = hikashop_get('helper.database');
$databaseHelper->addColumns('address','`address_mijo_order_info_id`
INT(11) NULL');
$databaseHelper->addColumns('order','`order_mijo_id`
INT(11) NULL');
$databaseHelper->addColumns('order','INDEX (
`order_mijo_id` )');
$databaseHelper->addColumns('taxation','`tax_mijo_id`
INT(11) NULL');
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
All table created</p>';
}
else
{
echo '<p>Tables have been already created.</p>';
$this->refreshPage = true; //toComment ?
}
return true;
}
function importTaxes()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
2 :</span>Â Import Taxes<p>';
$ret = false;
$data = array(
'tax_namekey' => "CONCAT('MIJO_TAX_',
mjt.tax_rate_id)",
'tax_rate' => 'mjt.rate'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_tax`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__mijoshop_tax_rate` AS mjt '.
'WHERE mjt.tax_rate_id > ' .
(int)$this->options->last_mijo_taxrate;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported taxes: ' . $total . '</p>';
$element = 'tax';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$data = array(
'category_type' => "'tax'",
'category_name' => "CONCAT('Tax imported
(', mtc.title,')')",
'category_published' => '1',
'category_parent_id' => $element,
'category_namekey' => "
CONCAT('MIJO_TAX_CATEGORY_', mtc.tax_class_id)" //"case
when hkz.zone_id IS NULL then CONCAT('MIJO_TAX_',
mjtr.tax_rate_id,'_0') else CONCAT('MIJO_TAX_',
mjtr.tax_rate_id,'_',hkz.zone_id) end",
);
$sql = 'INSERT IGNORE INTO `#__hikashop_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__mijoshop_tax_class` AS mtc ';
'WHERE mtc.tax_class_id > ' .
(int)$this->options->last_mijo_taxclass;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Taxes Categories: ' . $total . '</p>';
if( $total > 0 ) {
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'mijo_import_max_hk_cat'; ");
$this->db->execute();
$this->importRebuildTree();
}
$data = array(
'zone_namekey' => "case when hkz.zone_namekey IS NULL
then '' else hkz.zone_namekey end",
'category_namekey' =>
"CONCAT('MIJO_TAX_CATEGORY_', mjtc.tax_class_id)",
//"case when hkz.zone_id IS NULL then CONCAT('MIJO_TAX_',
mjtr.tax_rate_id,'_0') else CONCAT('MIJO_TAX_',
mjtr.tax_rate_id,'_',hkz.zone_id) end",
'tax_namekey' => "CONCAT('MIJO_TAX_',
mjtra.tax_rate_id)",
'taxation_published' => '1',
'taxation_type' => "''",
'tax_mijo_id' => 'mjtc.tax_class_id'
//'mjtra.tax_rate_id' See import product
);
$sql = 'INSERT IGNORE INTO `#__hikashop_taxation`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__mijoshop_tax_class` AS mjtc '.
'INNER JOIN `#__mijoshop_tax_rule` AS mjtr ON mjtc.tax_class_id =
mjtr.tax_class_id '.
'INNER JOIN `#__mijoshop_tax_rate` AS mjtra ON mjtr.tax_rate_id =
mjtra.tax_rate_id '.
'LEFT JOIN `#__mijoshop_zone_to_geo_zone` AS mjz ON
mjtra.geo_zone_id = mjz.geo_zone_id '.
'LEFT JOIN `#__mijoshop_country` AS mjc ON mjz.country_id =
mjc.country_id ' .
"LEFT JOIN `#__hikashop_zone` hkz ON mjc.iso_code_3 =
hkz.zone_code_3 AND hkz.zone_type = 'country' ".
'WHERE mjtra.tax_rate_id > ' .
(int)$this->options->last_mijo_taxrate;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Taxations: ' . $total . '</p>';
$ret = true;
return $ret;
}
function importManufacturers()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
3 :</span>Â Import Manufacturers</p>';
$ret = false;
$count = 100;
$rebuild = false;
$sql1 = 'SELECT * FROM `#__mijoshop_manufacturer` mjm '.
'LEFT JOIN `#__hikashop_mijo_cat` hkmj ON mjm.manufacturer_id =
hkmj.mijo_id AND category_type=\'manufacturer\' '.
'WHERE mjm.manufacturer_id > ' .
(int)$this->options->last_mijo_manufacturer;
'ORDER BY mjm.manufacturer_id ASC;';
$this->db->setQuery($sql1);
$this->db->execute();
$datas = $this->db->loadObjectList();
$sql2 = 'INSERT INTO `#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_published`,'.
'`category_namekey`,`category_description`,`category_menu`) VALUES
';
$sql3 = 'INSERT INTO `#__hikashop_mijo_cat`
(`mijo_id`,`hk_id`,`category_type`) VALUES ';
$sql4 = 'INSERT INTO `#__hikashop_file`
(`file_name`,`file_description`,`file_path`,`file_type`,`file_ref_id`)
VALUES ';
$doSql3 = false;
$doSql4 = false;
$i = $this->options->max_hk_cat + 1;
$ids = array( 0 => $this->options->main_cat_id);
$sep = '';
$sep2 = '';
$cpt=0;
$echo=false;
if( empty($datas) )
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported manufacturers : 0</p>';
return true;
}
else
{
foreach($datas as $data)
{
if( !empty($data->mijo_id) )
{
$ids[$data->manufacturer_id] = $data->hk_id;
}
else
{
$doSql3 = true;
$ids[$data->manufacturer_id] = $i;
$sql3 .=
$sep.'('.$data->manufacturer_id.','.$i.',\'manufacturer\')';
$i++;
$sep = ',';
}
$cpt++;
if( $cpt >= $count )
break;
}
$sql3 .= ';';
$cpt = 0;
$sep = '';
foreach($datas as $data)
{
if( !empty($data->mijo_id) )
continue;
$id = $ids[$data->manufacturer_id];
$element = 'manufacturer';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$d = array(
$id,
$element,
"'manufacturer'",
$this->db->quote($data->name),
'1',
"CONCAT('MIJO_MANUFAC_',
".$data->manufacturer_id .")",
"'manufacturer imported from Mijoshop'",
'0'
);
$sql2 .= $sep.'('.implode(',',$d).')';
if( !empty($data->image))
{
$this->copyCatImgDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode($this->copyCatImgDir)),DS.'
').DS);
if (!$echo)
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying manufacturers images... </p>';
$echo=true;
}
$doSql4 = true;
$sql4 .=
$sep2."(".$this->db->quote($data->name).",'',".$this->db->quote($data->image).",'category',".$id.')';
//type = category / manufacturer ?
$sep2 = ',';
$file_name =
str_replace('\\','/',$data->image);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyCatImgDir,$data->image,
str_replace('//','/',str_replace('\\','/',$this->options->uploadfolder.$file_name)));
}
$sep = ',';
$cpt++;
if( $cpt >= $count )
break;
}
}
if($cpt > 0)
{
$sql2 .= ';';
$sql4 .= ';';
$this->db->setQuery($sql2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Manufacturers : ' . $total . '</p>';
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Manufacturers : 0</p>';
}
if( isset($total) && $total > 0)
{
$rebuild = true;
$this->options->max_hk_cat += $total + 1;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'mijo_import_max_hk_cat'; ");
$this->db->execute();
}
if ($doSql3)
{
$this->db->setQuery($sql3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links : ' . $total . '</p>';
}
if($doSql4)
{
$this->db->setQuery($sql4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Manufacturers files : ' . $total . '</p>';
}
if( $rebuild )
$this->importRebuildTree();
if( $cpt < $count )
$ret = true;
return $ret;
}
function importCategories()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
4 :</span>Â Import General Categories</p>';
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$rebuild = false;
$ret = false;
$offset = 0;
$count = 100;
$cpt = 0;
$sep = '';
$sep2 = '';
$echo=false;
$statuses = array(
'P' => 'created',
'C' => 'confirmed',
'X' => 'cancelled',
'R'=> 'refunded' ,
'S' => 'shipped'
);
$this->db->setQuery("SELECT category_keywords,
category_parent_id FROM `#__hikashop_category` WHERE category_type =
'status' AND category_name = 'confirmed'");
$data = $this->db->loadObject();
$status_category = $data->category_parent_id;
if( $data->category_keywords != 'C' ) {
foreach($statuses as $k => $v) {
$this->db->setQuery("UPDATE `#__hikashop_category` SET
category_keywords = '".$k."' WHERE category_type =
'status' AND category_name = '".$v."';
");
$this->db->execute();
}
}
$this->db->setQuery("SELECT order_status_id, name FROM
`#__mijoshop_order_status` WHERE name NOT IN
('".implode("','",$statuses)."','canceled');");
$data = $this->db->loadObjectList();
if( count($data) > 0 )
{
$sql0 = 'INSERT IGNORE INTO `#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_description`,`category_published`,'.
'`category_namekey`,`category_access`,`category_menu`,`category_keywords`)
VALUES ';
$id = $this->options->max_hk_cat + 1;
$sep = '';
foreach($data as $c) {
$d = array(
$id++,
$status_category,
"'status'",
$this->db->quote( strtolower($c->name) ),
"'Order status imported from Mijoshop'",
'1',
$this->db->quote('status_mijo_import_'.strtolower(str_replace('
','_',$c->name))),
"'all'",
'0',
$this->db->quote( $c->order_status_id )
);
$sql0 .= $sep.'('.implode(',',$d).')';
$sep = ',';
}
$this->db->setQuery($sql0);
$this->db->execute();
$total = $this->db->getAffectedRows();
if( $total > 0 ) {
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported order status categories : ' . $total .
'</p>';
$rebuild = true;
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'mijo_import_max_hk_cat'; ");
$this->db->execute();
$sql0 = '';
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported order status categories : 0</p>';
}
}
$sql1 = 'SELECT * FROM `#__mijoshop_category` mjc '.
'INNER JOIN `#__mijoshop_category_description` mjcd ON
mjc.category_id = mjcd.category_id '.
'LEFT JOIN `#__hikashop_mijo_cat` hkmj ON mjc.category_id =
hkmj.mijo_id AND category_type=\'category\' '.
'WHERE mjc.category_id >
'.$this->options->last_mijo_cat.' '.
'ORDER BY mjc.parent_id ASC, mjc.category_id ASC;';
$this->db->setQuery($sql1);
$this->db->execute();
$datas = $this->db->loadObjectList();
$sql2 = 'INSERT IGNORE INTO `#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_description`,`category_published`,'.
'`category_ordering`,`category_namekey`,`category_created`,`category_modified`,`category_access`,`category_menu`)
VALUES ';
$sql3 = 'INSERT INTO `#__hikashop_mijo_cat`
(`mijo_id`,`hk_id`,`category_type`) VALUES ';
$sql4 = 'INSERT INTO `#__hikashop_file`
(`file_name`,`file_description`,`file_path`,`file_type`,`file_ref_id`)
VALUES ';
$doSql3 = false;
$doSql4 = false;
$i = $this->options->max_hk_cat + 1;
$ids = array( 0 => $this->options->main_cat_id);
$sep = '';
if( empty($datas) )
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported category : 0</p>';
if( $rebuild )
$this->importRebuildTree();
return true;
}
else
{
foreach($datas as $data)
{
if( !empty($data->mijo_id) )
{
$ids[(int)$data->category_id] = $data->hk_id;
}
else
{
$doSql3 = true;
$ids[(int)$data->category_id] = $i;
$sql3 .=
$sep.'('.$data->category_id.','.$i.',\'category\')';
$i++;
$sep = ',';
}
$cpt++;
if( $cpt >= $count )
break;
}
$sql3 .= ';';
$cpt = 0;
$sep = '';
foreach($datas as $data)
{
if( !empty($data->mijo_id) )
continue;
$id = (int)$ids[(int)$data->category_id];
if(!empty($ids[$data->parent_id]))
$pid = (int)$ids[$data->parent_id];
else
$pid = $ids[0];
$element = new stdClass();
$element->category_id = $id;
$element->category_parent_id = $pid;
$element->category_name = $data->name;
$nameKey = $categoryClass->getNameKey($element);
if(!is_numeric($data->date_added)) $data->date_added =
strtotime($data->date_added);
if(!is_numeric($data->date_modified)) $data->date_modified =
strtotime($data->date_modified);
$d = array(
$id,
$pid,
"'product'",
$this->db->quote($data->name),
$this->db->quote($data->description),
'1',
$data->sort_order,
$this->db->quote($nameKey),
"'".$data->date_added."'",
"'".$data->date_modified."'",
"'all'",
'0'
);
$sql2 .= $sep.'('.implode(',',$d).')';
if( !empty($data->image))
{
$this->copyCatImgDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode($this->copyCatImgDir)),DS.'
').DS);
if (!$echo)
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying categories images... </p>';
$echo=true;
}
$doSql4 = true;
$sql4 .=
$sep2."('','','".$data->image."','category',".$id.')';
$sep2 = ',';
$file_name =
str_replace('\\','/',$data->image);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyCatImgDir,$data->image,
str_replace('//','/',str_replace('\\','/',$this->options->uploadfolder.$file_name)));
}
$sep = ',';
$cpt++;
if( $cpt >= $count )
break;
}
}
if($cpt > 0)
{
$sql2 .= ';';
$sql4 .= ';';
$this->db->setQuery($sql2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Categories : ' . $total . '</p>';
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported category : 0</p>';
}
if( isset($total) && $total > 0)
{
$rebuild = true;
$this->options->max_hk_cat += $total + 1;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'mijo_import_max_hk_cat'; ");
$this->db->execute();
}
if ($doSql3)
{
$this->db->setQuery($sql3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links : ' . $total . '</p>';
}
if($doSql4)
{
$this->db->setQuery($sql4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Categories files : ' . $total . '</p>';
}
if( $rebuild )
$this->importRebuildTree();
if( $cpt < $count )
$ret = true;
return $ret;
}
function importProducts()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
5 :</span>Â Import Products</p>';
$ret = false;
$count = 100;
$offset = $this->options->current;
$max = 0;
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$query = 'SELECT * FROM `#__mijoshop_product`;';
$this->db->setQuery($query);
$el = $this->db->loadObject();
$main_image = false;
if(isset($el->image)){
$main_image = true;
$query = 'SELECT mjp.product_id, mjp.image FROM
`#__mijoshop_product` mjp '.
'LEFT JOIN `#__hikashop_mijo_prod` hkprod ON mjp.product_id =
hkprod.mijo_id '.
'WHERE mjp.product_id > '.$offset.' AND hkprod.hk_id
IS NULL AND (mjp.image IS NOT NULL) AND mjp.image <> \'\'
'.
'ORDER BY product_id ASC LIMIT '.$count.';';
$this->db->setQuery($query);
$datas = $this->db->loadObjectList();
$this->copyImgDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode($this->copyImgDir)),DS.'
').DS);
if (!empty($datas))
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying products images... </p>';
foreach($datas as $data) {
if( !empty($data->image) ) {
$file_name =
str_replace('\\','/',$data->image);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyImgDir,$data->image,
$this->options->uploadfolder.$file_name);
$max = $data->product_id;
}
}
}
}
$query = 'SELECT mjp.product_id, mjpi.image FROM
`#__mijoshop_product` mjp '.
'LEFT JOIN `#__mijoshop_product_image` mjpi ON mjp.product_id =
mjpi.product_id '.
'LEFT JOIN `#__hikashop_mijo_prod` hkprod ON mjp.product_id =
hkprod.mijo_id '.
'WHERE mjp.product_id > '.$offset.' AND hkprod.hk_id
IS NULL AND (mjpi.image IS NOT NULL) AND mjpi.image <> \'\'
'.
'ORDER BY product_id ASC LIMIT '.$count.';';
$this->db->setQuery($query);
$datas = $this->db->loadObjectList();
$this->copyImgDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode($this->copyImgDir)),DS.'
').DS);
if (!empty($datas))
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying products images... </p>';
foreach($datas as $data) {
if( !empty($data->image) ) {
$file_name =
str_replace('\\','/',$data->image);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyImgDir,$data->image,
$this->options->uploadfolder.$file_name);
}
}
}
if( $max > 0 )
{
echo '<p>Copying files...(last proccessed product id: '
. $max . ')</p>';
$this->options->current = $max;
$this->refreshPage = true;
return $ret;
}
$data = array(
'product_name' => 'mjpd.name',
'product_description' => 'mjpd.description',
'product_quantity' => 'case when mjp.quantity IS NULL
or mjp.quantity < 0 then 0 else mjp.quantity end',
'product_code' => 'mjp.hika_sku',
'product_published' => 'mjp.status',
'product_hit' => 'mjp.viewed',
'product_created' => 'mjp.date_added',
'product_modified' => 'mjp.date_modified',
'product_sale_start' => 'mjp.date_available',
'product_tax_id' => 'hkc.category_id',
'product_type' => "'main'",
'product_url' => "''",
'product_weight' => 'mjp.weight',
'product_weight_unit' => "LOWER(mjwcd.unit)",
'product_dimension_unit' => "LOWER(mjlcd.unit)",
'product_min_per_order' => 'mjp.minimum',
'product_sales' => '0',
'product_width' => 'mjp.width',
'product_length' => 'mjp.length',
'product_height' => 'mjp.height',
'product_parent_id' => '0'
);
$sql1 = 'INSERT IGNORE INTO `#__hikashop_product`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__mijoshop_product` AS mjp '.
'INNER JOIN `#__mijoshop_weight_class_description` mjwcd ON
mjp.weight_class_id = mjwcd.weight_class_id '.
'INNER JOIN `#__mijoshop_length_class_description` mjlcd ON
mjp.length_class_id = mjlcd.length_class_id '.
'INNER JOIN `#__mijoshop_product_description` mjpd ON
mjp.product_id = mjpd.product_id '.
'LEFT JOIN `#__hikashop_taxation` hkt ON hkt.tax_mijo_id =
mjp.tax_class_id '.
'LEFT JOIN `#__hikashop_category` hkc ON hkc.category_namekey =
hkt.category_namekey '.
'LEFT JOIN `#__hikashop_mijo_prod` AS hkp ON mjp.product_id =
hkp.mijo_id '.
'WHERE hkp.hk_id IS NULL ORDER BY mjp.product_id ASC;';
$this->db->setQuery("SHOW COLUMNS FROM `#__mijoshop_product`
LIKE 'hika_sku';");
$data = $this->db->loadObjectList();
if (empty($data))
{
$this->db->setQuery('ALTER TABLE `#__mijoshop_product` ADD
COLUMN `hika_sku` VARCHAR(255) NOT NULL;');
$this->db->execute();
}
$this->db->setQuery('UPDATE `#__mijoshop_product` AS mjp SET
mjp.hika_sku = mjp.sku;');
$this->db->execute();
$this->db->setQuery("UPDATE `#__mijoshop_product` AS mjp SET
mjp.hika_sku = CONCAT(mjp.model,'_',mjp.product_id) WHERE
mjp.hika_sku='';");
$this->db->execute();
$this->db->setQuery('SELECT hika_sku FROM
`#__mijoshop_product` GROUP BY hika_sku HAVING
COUNT(hika_sku)>1');
$data = $this->db->loadObjectList();
if (!empty($data))
{
foreach ($data as $d)
{
$this->db->setQuery("UPDATE `#__mijoshop_product` AS mjp SET
mjp.hika_sku = CONCAT(mjp.hika_sku,'_',mjp.product_id) WHERE
mjp.hika_sku = '".$d->hika_sku."';");
$this->db->execute();
}
}
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
SKU generated: '.count($data).'</p>';
$data = array(
'mijo_id' => 'mjp.product_id',
'hk_id' => 'hkp.product_id'
);
$sql2 = 'INSERT IGNORE INTO `#__hikashop_mijo_prod`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__mijoshop_product` AS mjp '.
'INNER JOIN `#__hikashop_product` AS hkp ON CONVERT(mjp.hika_sku
USING utf8) = CONVERT(hkp.product_code USING utf8) '.
'LEFT JOIN `#__hikashop_mijo_prod` hkmjp ON hkmjp.mijo_id =
mjp.product_id '.
'WHERE hkmjp.hk_id IS NULL;';
$data = array(
'file_name' => "''",
'file_description' => "''",
'file_path' =>
"SUBSTRING_INDEX(mjp.image,'/',-1)",
'file_type' => "'product'",
'file_ref_id' => 'hkmjp.hk_id'
);
$sql40 = 'INSERT IGNORE INTO `#__hikashop_file`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__mijoshop_product` AS mjp '.
'INNER JOIN `#__hikashop_mijo_prod` AS hkmjp ON mjp.product_id =
hkmjp.mijo_id '.
'WHERE mjp.product_id >
'.$this->options->last_mijo_prod. ' AND (mjp.image IS NOT
NULL) AND (mjp.image <>'." '');";
$data = array(
'file_name' => "''",
'file_description' => "''",
'file_path' =>
"SUBSTRING_INDEX(mjpi.image,'/',-1)",
'file_type' => "'product'",
'file_ref_id' => 'hkmjp.hk_id'
);
$sql4 = 'INSERT IGNORE INTO `#__hikashop_file`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__mijoshop_product` AS mjp '.
'INNER JOIN `#__mijoshop_product_image` mjpi ON mjp.product_id =
mjpi.product_id '.
'INNER JOIN `#__hikashop_mijo_prod` AS hkmjp ON mjp.product_id =
hkmjp.mijo_id '.
'WHERE mjp.product_id >
'.$this->options->last_mijo_prod. ' AND (mjpi.image IS NOT
NULL) AND (mjpi.image <>'." '');";
$sql5 = 'UPDATE `#__hikashop_product` AS hkp '.
'INNER JOIN `#__hikashop_mijo_prod` AS hkmjp ON hkp.product_id =
hkmjp.hk_id '.
'INNER JOIN `#__mijoshop_product` AS mjp ON hkmjp.mijo_id =
mjp.product_id '.
"INNER JOIN `#__hikashop_category` AS hkc ON hkc.category_type =
'manufacturer' AND mjp.manufacturer_id = hkc.category_menu
".
'SET hkp.product_manufacturer_id = hkc.category_id '.
'WHERE mjp.manufacturer_id >
'.$this->options->last_mijo_manufacturer.' OR
mjp.product_id >
'.$this->options->last_mijo_prod.';';
$this->db->setQuery($sql1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products: ' . $total . '</p>';
$this->db->setQuery($sql2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links: ' . $total . '</p>';
if($main_image){
$this->db->setQuery($sql40);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products files: ' . $total . '</p>';
}
$this->db->setQuery($sql4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products images: ' . $total . '</p>';
$this->db->setQuery($sql5);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating products manufacturers: ' . $total . '</p>';
$ret = true;
return $ret;
}
function importVariant()
{
}
function importProductPrices()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
6 :</span>Â Import Product Prices</p>';
$ret = false;
$cpt = 0;
$query = 'SELECT hkcur.currency_id FROM `#__mijoshop_currency` mjc
'.
'INNER JOIN `#__hikashop_currency` hkcur ON CONVERT(mjc.code USING
utf8) = CONVERT(hkcur.currency_code USING utf8) '.
'WHERE mjc.value = ' . $this->db->Quote('1.0')
. ';';
$this->db->setQuery($query);
$data = $this->db->loadObjectList();
if (!empty($data))
{
$query = 'INSERT IGNORE INTO `#__hikashop_price`
(`price_product_id`,`price_value`,`price_currency_id`,`price_min_quantity`,`price_access`)
'.
'SELECT hkprod.hk_Id, mjp.price, ' .
$this->db->Quote($data[0]->currency_id) . ', ' .
$this->db->Quote('0') . ', ' .
$this->db->Quote('all') . ' '.
'FROM `#__mijoshop_product` mjp INNER JOIN `#__hikashop_mijo_prod`
hkprod ON mjp.product_id = hkprod.mijo_id '.
'WHERE mjp.product_id > ' .
(int)$this->options->last_mijo_prod;
$this->db->setQuery($query);
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Prices imported : 0</p>';
}
$ret = $this->db->execute();
$cpt = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Prices imported : ' . $cpt .'</p>';
if ($this->importcurrencies)
$this->importCurrencies();
return $ret;
}
function importProductCategory()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
7 :</span>Â Import Product Category</p>';
$ret = false;
$data = array(
'category_id' => 'hmjc.hk_id',
'product_id' => 'hmjp.hk_id',
'ordering' => '0',
);
$sql = 'INSERT IGNORE INTO `#__hikashop_product_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__mijoshop_product_to_category` mjpc '.
'INNER JOIN #__hikashop_mijo_cat hmjc ON mjpc.category_id =
hmjc.mijo_id AND category_type=\'category\' '.
'INNER JOIN #__hikashop_mijo_prod hmjp ON mjpc.product_id =
hmjp.mijo_id '.
'WHERE hmjp.mijo_id > ' .
(int)$this->options->last_mijo_prod . ' OR hmjc.mijo_id >
' . (int)$this->options->last_mijo_cat;
$this->db->setQuery($sql);
$ret = $this->db->execute();
$total = $this->db->getAffectedRows();
$this->importRebuildTree();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products categories: ' . $total . '</p>';
return $ret;
}
function importUsers()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
8 :</span>Â Import Users</p>';
$ret = false;
$sql0 = 'INSERT IGNORE INTO `#__hikashop_user`
(`user_cms_id`,`user_email`) '.
'SELECT u.id, u.email FROM `#__mijoshop_customer` mjc '.
'INNER JOIN `#__mijoshop_juser_ocustomer_map` mjju ON
mjju.ocustomer_id = mjc.customer_id '.
'INNER JOIN `#__users` u ON mjju.juser_id = u.id '.
'LEFT JOIN `#__hikashop_user` AS hkusr ON mjju.juser_id =
hkusr.user_cms_id '.
'WHERE hkusr.user_cms_id IS NULL;';
$data = array(
'address_user_id' => 'hku.user_id',
'address_title' => "'Mr'",
'address_firstname' => 'mja.firstname',
'address_lastname' => 'mja.lastname',
'address_company' => 'mja.company',
'address_street' => 'CONCAT(mja.address_1,\'
\',mja.address_2)',
'address_post_code' => 'mja.postcode',
'address_city' => 'mja.city',
'address_telephone' => 'mjcu.telephone',
'address_fax' => 'mjcu.fax',
'address_state' => 'hkzsta.zone_namekey',
'address_country' => 'hkzcou.zone_namekey',
'address_published' => 4
);
$sql1 = 'INSERT IGNORE INTO `#__hikashop_address`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__mijoshop_customer` AS mjcu '.
'INNER JOIN `#__mijoshop_address` AS mja ON mjcu.customer_id =
mja.customer_id '.
'INNER JOIN `#__mijoshop_juser_ocustomer_map` mjju ON
mja.customer_id = mjju.ocustomer_id '.
'INNER JOIN `#__users` u ON mjju.juser_id = u.id '.
'INNER JOIN `#__hikashop_user` AS hku ON mjju.juser_id =
hku.user_cms_id '.
'INNER JOIN `#__mijoshop_country` AS mjc ON mja.country_id =
mjc.country_id '.
'INNER JOIN `#__mijoshop_zone` AS mjz ON mja.zone_id = mjz.zone_id
'.
'LEFT JOIN `#__hikashop_zone` AS hkzcou ON mjc.iso_code_3 =
hkzcou.zone_code_3 AND hkzcou.zone_type=\'country\' '.
'INNER JOIN `#__hikashop_zone_link` AS hkzl ON hkzcou.zone_namekey
= hkzl.zone_parent_namekey '.
'INNER JOIN `#__hikashop_zone` AS hkzsta ON mjz.code =
hkzsta.zone_code_3 AND hkzsta.zone_type=\'state\' AND
hkzsta.zone_namekey = hkzl.zone_child_namekey '.
'WHERE mjcu.customer_id >
'.$this->options->last_mijo_user.' ORDER BY mja.customer_id
ASC';
$sql2 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone` AS hkz ON (a.address_country =
hkz.zone_code_3 AND hkz.zone_type = "country") '.
'SET address_country = hkz.zone_namekey, address_published = 3
WHERE address_published = 4;';
$sql3 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone_link` AS zl ON (a.address_country =
zl.zone_parent_namekey) '.
'JOIN `#__hikashop_zone` AS hks ON (hks.zone_namekey =
zl.zone_child_namekey AND hks.zone_type = "state" AND
hks.zone_code_3 = a.address_state) '.
'SET address_state = hks.zone_namekey, address_published = 2 WHERE
address_published = 3;';
$sql4 = 'UPDATE `#__hikashop_address` AS a SET a.address_country =
\'\' WHERE address_published > 3;';
$sql5 = 'UPDATE `#__hikashop_address` AS a SET a.address_state =
\'\' WHERE address_published > 2;';
$sql6 = 'UPDATE `#__hikashop_address` AS a SET a.address_published =
1 WHERE address_published > 1;';
$this->db->setQuery($sql0);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Users: ' . $total . '</p>';
$this->db->setQuery($sql1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses: ' . $total . '</p>';
$this->db->setQuery($sql2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses countries: ' . $total . '</p>';
$this->db->setQuery($sql3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses states: ' . $total . '</p>';
$this->db->setQuery($sql4);
$this->db->execute();
$this->db->setQuery($sql5);
$this->db->execute();
$this->db->setQuery($sql6);
$this->db->execute();
$ret = true;
return $ret;
}
function importOrders()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
10 :</span>Â Import Orders</p>';
$ret = false;
$offset = $this->options->current;
$count = 100;
$total = 0;
$vat_cols = "''";
$data = array(
'order_number' => 'mjo.order_id',
'order_mijo_id' => 'mjo.order_id',
'order_user_id' => 'hkusr.user_id',
'order_status' => 'hkc.category_name',
'order_created' => 'mjo.date_added', //
UNIX_TIMESTAMP(...)
'order_ip' => 'mjo.ip',
'order_currency_id' => 'hkcur.currency_id',
'order_shipping_price' => "''", //?
'order_shipping_method' =>
'mjo.shipping_method',
'order_shipping_id' => '1',
'order_payment_id' => 0,
'order_payment_method' => 'mjo.payment_method',
'order_full_price' => 'mjot.value',
'order_modified' => 'mjo.date_modified', //
UNIX_TIMESTAMP(...)
'order_partner_id' => 0,
'order_partner_price' => 0,
'order_partner_paid' => 0,
'order_type' => "'sale'",
'order_partner_currency_id' => 0,
'order_shipping_tax' => "''", //?
'order_discount_tax' => 0
);
$sql1 = 'INSERT IGNORE INTO `#__hikashop_order`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__mijoshop_order` AS mjo '.
'INNER JOIN `#__mijoshop_order_product` mjop ON mjop.order_id =
mjo.order_id '.
'INNER JOIN `#__mijoshop_order_status` AS mjos ON
mjo.order_status_id = mjos.order_status_id '.
'INNER JOIN `#__hikashop_category` AS hkc ON mjos.name =
hkc.category_name AND hkc.category_type = \'status\' '.
'INNER JOIN `#__hikashop_currency` AS hkcur ON
CONVERT(mjo.currency_code USING utf8) = CONVERT(hkcur.currency_code USING
utf8) '.
'INNER JOIN `#__mijoshop_order_total` mjot ON mjo.order_id =
mjot.order_id AND code=\'total\' '.
'INNER JOIN `#__mijoshop_juser_ocustomer_map` mjju ON
mjo.customer_id = mjju.ocustomer_id '.
'INNER JOIN `#__users` u ON mjju.juser_id = u.id '.
'INNER JOIN `#__hikashop_user` AS hkusr ON mjju.juser_id =
hkusr.user_cms_id '.
'WHERE mjo.order_id > ' .
(int)$this->options->last_mijo_order . ' '.
'GROUP BY mjo.order_id '.
'ORDER BY mjo.order_id ASC;';
$sql1_1 = 'UPDATE `#__hikashop_order` AS hko '.
'INNER JOIN `#__mijoshop_voucher` AS mjv ON hko.order_mijo_id =
mjv.order_id '.
'INNER JOIN `#__hikashop_discount` AS hkd ON hkd.discount_code =
mjv.code '.
'SET hko.order_discount_code = hkd.discount_code AND
hko.order_discount_price = hkd.discount_flat_amount';
$data = array(
'address_user_id' => 'mjo.customer_id',
'address_firstname' => 'mjo.payment_firstname',
'address_lastname' => 'mjo.payment_lastname',
'address_company' => 'mjo.payment_company',
'address_street' =>
'CONCAT(mjo.payment_address_1,\'
\',mjo.payment_address_2)',
'address_post_code' => 'mjo.payment_postcode',
'address_city' => 'mjo.payment_city ',
'address_telephone' => 'mjo.telephone',
'address_fax' => 'mjo.fax',
'address_state' => 'hkzsta.zone_namekey',
'address_country' => 'hkzcou.zone_namekey',
'address_published' => '7',
'address_vat' => $vat_cols,
'address_mijo_order_info_id' => 'mjo.order_id'
//8
);
$sql2_1 = 'INSERT IGNORE INTO `#__hikashop_address`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__mijoshop_order` AS mjo '.
'INNER JOIN `#__mijoshop_country` AS mjc ON mjo.payment_country_id
= mjc.country_id '.
'INNER JOIN `#__mijoshop_zone` AS mjz ON mjo.payment_zone_id =
mjz.zone_id '.
'INNER JOIN `#__hikashop_zone` AS hkzcou ON mjc.iso_code_3 =
hkzcou.zone_code_3 AND hkzcou.zone_type=\'country\' '.
'INNER JOIN `#__hikashop_zone_link` AS hkzl ON hkzcou.zone_namekey
= hkzl.zone_parent_namekey '.
'INNER JOIN `#__hikashop_zone` AS hkzsta ON mjz.code =
hkzsta.zone_code_3 AND hkzsta.zone_type=\'state\' AND
hkzsta.zone_namekey = hkzl.zone_child_namekey '.
'WHERE mjo.order_id > ' .
(int)$this->options->last_mijo_order;
$sql2_2 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone` AS hkz ON (a.address_country =
hkz.zone_code_3 AND hkz.zone_type = "country") '.
'SET address_country = hkz.zone_namekey, address_published = 6
WHERE address_published >= 7;';
$sql2_3 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone_link` AS zl ON (a.address_country =
zl.zone_parent_namekey) '.
'JOIN `#__hikashop_zone` AS hks ON (hks.zone_namekey =
zl.zone_child_namekey AND hks.zone_type = "state" AND
hks.zone_code_3 = a.address_state) '.
'SET address_state = hks.zone_namekey, address_published = 5 WHERE
address_published = 6;';
$sql2_4 = 'UPDATE `#__hikashop_address` AS a '.
'SET address_published = 0 WHERE address_published > 4;';
$sql3 = 'UPDATE `#__hikashop_order` AS o '.
'INNER JOIN `#__hikashop_address` AS a ON
a.address_mijo_order_info_id = o.order_mijo_id '.
'SET o.order_billing_address_id = a.address_id,
o.order_shipping_address_id = a.address_id '.
'WHERE o.order_billing_address_id = 0 AND address_published >= 7
;';
$sql4 = 'UPDATE `#__hikashop_order` AS o '.
'INNER JOIN `#__hikashop_address` AS a ON
a.address_mijo_order_info_id = o.order_mijo_id '.
'SET o.order_shipping_address_id = a.address_id '.
'WHERE (o.order_shipping_address_id = 0 OR
o.order_shipping_address_id = o.order_billing_address_id) AND
address_published >= 8 ;';
$sql5 = 'UPDATE `#__hikashop_order` AS hko '.
'JOIN `#__mijoshop_order` AS mjo ON hko.order_mijo_id =
mjo.order_id '.
'SET hko.order_payment_method = CONCAT(' .
$this->db->Quote('mijo import: ') . ',
mjo.payment_method) '.
'WHERE hko.order_mijo_id > ' .
(int)$this->options->last_mijo_order;
$this->db->setQuery($sql1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported orders: ' . $total . '</p>';
$this->db->setQuery($sql1_1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating discount orders: ' . $total . '</p>';
$this->db->setQuery($sql2_1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported orders addresses: ' . $total . '</p>';
$this->db->setQuery($sql3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating billing addresses: ' . $total . '</p>';
$this->db->setQuery($sql4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating shipping addresses: ' . $total . '</p>';
$this->db->setQuery($sql5);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating order payments: ' . $total . '</p>';
$this->db->setQuery($sql2_2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating orders: ' . $total;
$this->db->setQuery($sql2_3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '/' . $total;
$this->db->setQuery($sql2_4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '/' . $total . '</p>';
$ret = true;
return $ret;
}
function importOrderItems()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
11 :</span>Â Import Order Items</p>';
$ret = false;
$offset = $this->options->current;
$count = 100;
$data = array(
'order_id' => 'hko.order_id',
'product_id' => 'hkp.hk_id',
'order_product_quantity' => 'mjop.quantity',
'order_product_name' => 'mjop.name',
'order_product_code' => 'mjp.hika_sku',
'order_product_price' => 'mjop.price',
'order_product_tax' => 'mjop.tax',
'order_product_options' => "''"
);
$sql = 'INSERT IGNORE INTO `#__hikashop_order_product`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__mijoshop_order_product` AS mjop '.
'INNER JOIN `#__mijoshop_product` mjp ON
mjop.product_id=mjp.product_id '.
'INNER JOIN `#__hikashop_order` AS hko ON mjop.order_id =
hko.order_mijo_id '.
'INNER JOIN `#__hikashop_mijo_prod` AS hkp ON hkp.mijo_id =
mjop.product_id '.
'WHERE mjop.order_id > ' .
(int)$this->options->last_mijo_order . ';';
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Orders Items : '. $total .'</p>';
$ret = true;
return $ret;
}
function importDownloads()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
12 :</span>Â Import Downloads</p>';
$ret = false;
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$count = 100;
$offset = $this->options->current;
if( $offset == 0 )
$offset = $this->options->last_mijo_pfile;
$sql = 'SELECT mjd.download_id, mjd.filename FROM
`#__mijoshop_download` AS mjd WHERE mjd.download_id >
'.$offset.' ORDER BY mjd.download_id ASC LIMIT
'.$count.';'; //Why no Mask FFS
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$max = 0;
if (!empty($data))
{
$this->copyDownloadDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode($this->copyDownloadDir)),DS.'
').DS);
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying downloads files... </p>';
foreach($data as $c)
{
$file_name =
end(explode('/',str_replace('\\','/',$c->filename)));
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$dstFolder = $this->options->uploadfolder; //secure ?
$this->copyFile($this->copyDownloadDir, $c->filename,
$dstFolder.$file_name);
$max = $c->download_id;
}
if( $max > 0 )
{
echo '<p>Copying files...<br/>(Last processed file id:
' . $max . '</p>';
$this->options->current = $max;
$this->refreshPage = true;
return $ret;
}
}
$data = array(
'file_name' => 'mjdd.name',
'file_description' => "''",
'file_path' => "SUBSTRING_INDEX(mjd.filename
,'/',-1)", //Why no filename ?
'file_type' => "'file'",
'file_ref_id' => 'hkmjp.hk_id'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_file`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__mijoshop_download` AS mjd '.
'INNER JOIN `#__mijoshop_download_description` mjdd ON
mjd.download_id = mjdd.download_id '.
'LEFT JOIN `#__mijoshop_product_to_download` mjpd ON
mjd.download_id = mjpd.download_id '.
'LEFT JOIN `#__hikashop_mijo_prod` AS hkmjp ON mjpd.product_id =
hkmjp.mijo_id '.
'WHERE mjd.download_id >
'.$this->options->last_mijo_pfile;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Downloable files imported : ' . $total . '</p>';
$data = array(
'file_id' => 'hkf.file_id',
'order_id' => 'hko.order_id'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_download`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__mijoshop_download` AS mjd '.
'INNER JOIN `#__mijoshop_download_description` mjdd ON
mjd.download_id = mjdd.download_id '.
'INNER JOIN `#__hikashop_file` AS hkf ON ( CONVERT(hkf.file_name
USING utf8) = CONVERT(mjdd.name USING utf8) )'.
'INNER JOIN `#__mijoshop_product_to_download` AS mjpd ON
mjd.download_id = mjpd.download_id '.
'INNER JOIN `#__mijoshop_order_product` AS mjop ON mjpd.product_id
= mjop.product_id '.
'INNER JOIN `#__hikashop_order` AS hko ON hko.order_mijo_id =
mjop.order_id '.
'WHERE mjd.download_id >
'.$this->options->last_mijo_pfile;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Downloable order files imported : ' . $total .
'</p>';
$ret = true;
return $ret;
}
function copyFile($dir, $fsrc, $dst, $debug = false){
if ($debug){
echo 'Source folder : '.$dir.'<br/>';
echo 'File source name : '.$fsrc.'<br/>';
echo 'From "'.$dir.$fsrc.'" to folder/file :
"'.$dst.'"<br/>';
echo '#####<br/>';
}
$src = $fsrc;
if( file_exists($dir.$fsrc) )
$src = $dir.$fsrc;
else if( file_exists(HIKASHOP_ROOT.$fsrc) )
$src = HIKASHOP_ROOT.$fsrc;
if( !file_exists($src) ) {
$files = JFolder::files($dir, $fsrc, true, true);
if($files) {
$dst = reset($files);
}
if( !file_exists($src) ) {
echo '<span '.$this->copywarning.'>File is not
found "' . $dir.$fsrc .
'"</span><br/>';
return false;
}
}
if( !file_exists($dst) ){
$ret = JFile::copy($src, $dst);
if( !$ret ){
echo '<span '.$this->copywarning.'>The file
"' . $src . '" could not be copied to "' .
$dst . '"</span><br/>';
}else{
return true;
}
}
else{
echo '<span '.$this->copywarning.'>File already
exists "' .$dst . '" ("' . $src .
'")</span><br/>';
return true;
}
return false;
}
function importDiscount()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
9 :</span>Â Import Discount</p>';
$ret = false;
$sql = "SELECT `config_value` FROM `#__hikashop_config` WHERE
config_namekey = 'main_currency';";
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$main_currency = $data[0]->config_value;
$data = array(
'discount_type' => "'coupon'",
'discount_start' => 'date_start',
'discount_end' => 'date_end',
'discount_quota' => 'uses_total',
'discount_quota_per_user' => 'uses_customer',
'discount_published' => 'status',
'discount_code' => 'code',
'discount_currency_id' =>
$this->db->Quote($main_currency),
'discount_flat_amount' => "case when type =
'F' then discount else 0 end",
'discount_percent_amount' => "case when type =
'P' then discount else 0 end",
'discount_quota' => '0'
);
$sql = 'INSERT IGNORE INTO #__hikashop_discount
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
#__mijoshop_coupon WHERE coupon_id > ' .
(int)$this->options->last_mijo_coupon;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Discount codes/coupons imported : ' . $total .
'</p>';
$data = array(
'discount_type' => "'coupon'",
'discount_code' => 'code',
'discount_currency_id' =>
$this->db->Quote($main_currency),
'discount_flat_amount' => 'amount',
'discount_percent_amount' => '0',
'discount_published' => 'status',
);
$sql = 'INSERT IGNORE INTO #__hikashop_discount
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
#__mijoshop_voucher WHERE voucher_id > ' .
(int)$this->options->last_mijo_voucher;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Vouchers imported : ' . $total . '</p>';
$ret = true;
return $ret;
}
function importCurrencies()
{
if( $this->db == null )
return false;
$query = 'UPDATE `#__hikashop_currency` AS hkcur '.
'INNER JOIN `#__mijoshop_currency` mjc ON CONVERT(mjc.code USING
utf8) = CONVERT( hkcur.currency_code USING utf8) '.
'SET hkcur.currency_rate = mjc.value';
$this->db->setQuery($query);
$ret = $this->db->execute();
$cpt = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Currencies values imported : ' . $cpt .'</p>';
return true;
}
function finishImport()
{
$this->db->setQuery("SELECT max(category_id) as
'max' FROM `#__hikashop_category`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(product_id) as 'max'
FROM `#__hikashop_product`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_prod = (int)($data[0]->max);
$this->db->setQuery("SELECT max(mijo_id) as 'max'
FROM `#__hikashop_mijo_cat`;");
$data = $this->db->loadObjectList();
$this->options->last_mijo_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(mijo_id) as 'max'
FROM `#__hikashop_mijo_prod`;");
$data = $this->db->loadObjectList();
$this->options->last_mijo_prod = (int)($data[0]->max);
$this->db->setQuery("SELECT max(customer_id) as
'max' FROM `#__mijoshop_customer`;");
$data = $this->db->loadObjectList();
$this->options->last_mijo_user = (int)($data[0]->max);
$this->db->setQuery("SELECT max(order_mijo_id) as
'max' FROM `#__hikashop_order`;");
$data = $this->db->loadObjectList();
$this->options->last_mijo_order = (int)($data[0]->max);
$this->db->setQuery("SELECT max(mjpi.product_image_id) as
'max' FROM `#__mijoshop_product_image` mjpi INNER JOIN
`#__mijoshop_product` mjp ON mjpi.product_id = mjp.product_id");
$data = $this->db->loadObject();
$this->options->last_mijo_pfile = (int)($data->max);
$this->db->setQuery("SELECT max(coupon_id) as 'max'
FROM `#__mijoshop_coupon`;");
$data = $this->db->loadObject();
$this->options->last_mijo_coupon = (int)($data->max);
$this->db->setQuery("SELECT max(voucher_id) as 'max'
FROM `#__mijoshop_voucher`;");
$data = $this->db->loadObject();
$this->options->last_mijo_voucher = (int)($data->max);
$this->db->setQuery("SELECT max(tax_rate_id) as
'max' FROM `#__mijoshop_tax_rate`;");
$data = $this->db->loadObject();
$this->options->last_mijo_taxrate = (int)($data->max);
$this->db->setQuery("SELECT max(tax_class_id) as
'max' FROM `#__mijoshop_tax_class`;");
$data = $this->db->loadObject();
$this->options->last_mijo_taxclass = (int)($data->max);
$this->db->setQuery("SELECT max(manufacturer_id) as
'max' FROM `#__mijoshop_manufacturer`;");
$data = $this->db->loadObjectList();
$this->options->last_mijo_manufacturer = (int)($data[0]->max);
$this->options->state = 14;
$query = 'REPLACE INTO `#__hikashop_config`
(`config_namekey`,`config_value`,`config_default`) VALUES '.
"('mijo_import_state',".$this->options->state.",".$this->options->state.")".
",('mijo_import_max_hk_cat',".$this->options->max_hk_cat.",".$this->options->max_hk_cat.")".
",('mijo_import_max_hk_prod',".$this->options->max_hk_prod.",".$this->options->max_hk_prod.")".
",('mijo_import_last_mijo_cat',".$this->options->last_mijo_cat.",".$this->options->last_mijo_cat.")".
",('mijo_import_last_mijo_prod',".$this->options->last_mijo_prod.",".$this->options->last_mijo_prod.")".
",('mijo_import_last_mijo_user',".$this->options->last_mijo_user.",".$this->options->last_mijo_user.")".
",('mijo_import_last_mijo_order',".$this->options->last_mijo_order.",".$this->options->last_mijo_order.")".
",('mijo_import_last_mijo_pfile',".$this->options->last_mijo_pfile.",".$this->options->last_mijo_pfile.")".
",('mijo_import_last_mijo_coupon',".$this->options->last_mijo_coupon.",".$this->options->last_mijo_coupon.")".
",('mijo_import_last_mijo_voucher',".$this->options->last_mijo_voucher.",".$this->options->last_mijo_voucher.")".
",('mijo_import_last_mijo_taxrate',".$this->options->last_mijo_taxrate.",".$this->options->last_mijo_taxrate.")".
",('mijo_import_last_mijo_taxclass',".$this->options->last_mijo_taxclass.",".$this->options->last_mijo_taxclass.")".
",('mijo_import_last_mijo_manufacturer',".$this->options->last_mijo_manufacturer.",".$this->options->last_mijo_manufacturer.")".
';';
$this->db->setQuery($query);
$this->db->execute();
echo '<p'.$this->titlefont.'>Import finished
!</p>';
$pluginsClass = hikashop_get('class.plugins');
$infos =
$pluginsClass->getByName('system','mijo_redirect');
if($infos)
{
$pkey = reset($pluginsClass->pkeys);
if(!empty($infos->$pkey))
{
$url =
JRoute::_('index.php?option=com_plugins&view=plugin&layout=edit&extension_id='.$infos->$pkey);
echo '<p>You can publish the
<a'.$this->linkstyle.'
href="'.$url.'">Mijoshop Fallback Redirect
Plugin</a> so that your old Mijoshop links are automatically
redirected to HikaShop pages and thus not loose the ranking of your content
on search engines.</p>';
}
}
}
}
import/openc.php000064400000214021151162557560007710 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
include_once HIKASHOP_HELPER . 'import.php';
class hikashopImportopencHelper extends hikashopImportHelper
{
var $hikaDatabaseName;
var $opencDatabase;
var $opencPrefix;
var $opencRootPath;
var $sessionParams;
var $importcurrencies;
function __construct()
{
parent::__construct();
$this->importName = 'openc';
$this->copyImgDir = '';
$this->copyCatImgDir = '';
$this->copyDownloadDir = '';
$this->copyManufDir = '';
$this->sessionParams = HIKASHOP_COMPONENT.'openc';
jimport('joomla.filesystem.file');
}
function importFromOpenc()
{
@ob_clean();
echo $this->getHtmlPage();
$this->token = hikashop_getFormToken();
flush();
if( isset($_GET['import']) && $_GET['import']
== '1' )
{
$app = JFactory::getApplication();
$config = JFactory::getConfig();
$this->opencDatabase =
$app->getUserState($this->sessionParams.'dbName');
$this->opencRootPath =
$app->getUserState($this->sessionParams.'rootPath');
$this->opencPrefix =
$app->getUserState($this->sessionParams.'prefix');
if(HIKASHOP_J30)
$this->hikaDatabaseName = $config->get('db');
else
$this->hikaDatabaseName = $config->getValue('db');
$this->importcurrencies =
$app->getUserState($this->sessionParams.'importcurrencies');
if (substr($this->opencRootPath, -1)!='/')
$this->opencRootPath = $this->opencRootPath.'/';
@include_once($this->opencRootPath . 'admin/config.php');
$time = microtime(true);
$processed = $this->doImport();
if( $processed )
{
$elasped = microtime(true) - $time;
if( !$this->refreshPage )
echo
'<p><br/><a'.$this->linkstyle.'href="'.hikashop_completeLink('import&task=import&importfrom=openc&'.$this->token.'=1&import=1&time='.time()).'">'.JText::_('HIKA_NEXT').'</a></p>';
echo '<p style="font-size:0.85em;
color:#605F5D;">Elasped time: ' . round($elasped * 1000, 2) .
'ms</p>';
}
else
{
echo
'<a'.$this->linkstyle.'href="'.hikashop_completeLink('import&task=show').'">'.JText::_('HIKA_BACK').'</a>';
}
}
else
{
echo $this-> getStartPage();
}
if( $this->refreshPage )
{
echo "<script type=\"text/javascript\">\r\nr =
true;\r\n</script>";
}
echo '</body></html>';
exit;
}
function getStartPage()
{
$app = JFactory::getApplication();
$database = JFactory::getDBO();
$returnString = '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
0</span></p>';
$continue = true;
$this->opencDatabase =
$app->getUserStateFromRequest($this->sessionParams.'dbName',
'opencDbName', '', 'string' );
//getUserStateFromRequest( 'keyFromSession',
'keyFromRequest', '', 'typeKey' ) -
hikaInput::get()->getString()
$this->opencRootPath =
$app->getUserStateFromRequest($this->sessionParams.'rootPath',
'opencRootPath', '', 'string' );
$this->opencPrefix =
$app->getUserStateFromRequest($this->sessionParams.'prefix',
'opencPrefix', '', 'string' );
$config = JFactory::getConfig();
if(HIKASHOP_J30)
$this->hikaDatabaseName = $config->get('db');
else
$this->hikaDatabaseName = $config->getValue('db');
$this->importcurrencies =
$app->getUserStateFromRequest($this->sessionParams.'importcurrencies',
'import_currencies', '', 'string' );
if (empty($this->opencDatabase))
{
$returnString .= '<p style="color:red">Please
specify a name for your Opencart Database.</p>';
}
elseif (empty($this->opencRootPath))
{
$returnString .= '<p style="color:red">Please
specify a root path for your Opencart website.</p>';
}
else
{
$query = 'SHOW TABLES FROM '.$this->opencDatabase.'
LIKE
'.$database->Quote(substr(hikashop_table($this->opencPrefix.'product',false),3)).';';
try
{
$database->setQuery($query);
$table = $database->loadResult();
}
catch(Exception $e)
{
$returnString .= '<p style="color:red">Error with
the openning of the `'.$this->opencDatabase.'`
database.<br/><span style="font-size:0.75em">Mysql
Error :'.$e.'</span></p>';
$continue = false;
}
if ($continue)
{
if (empty($table))
$returnString .= '<p style="color:red">Opencart
has not been found in the database you specified :
'.$this->opencDatabase.'</p>';
else
$returnString .= 'The import will now start from the database
`'.$this->opencDatabase.'`.<br/>First, make a backup of
your databases.<br/>'.
'When ready, click on <a '.$this->linkstyle.'
href="'.hikashop_completeLink('import&task=import&importfrom=openc&'.$this->token.'=1&import=1').'">'.JText::_('HIKA_NEXT').'</a>,
otherwise ';
}
}
$returnString .= '<a'.$this->linkstyle.'
href="'.hikashop_completeLink('import&task=show').'">'.JText::_('HIKA_BACK').'</a>';
return $returnString;
}
function doImport()
{
if( $this->db == null )
return false;
$this->loadConfiguration();
$current = $this->options->current;
$ret = true;
$next = false;
switch($this->options->state)
{
case 0:
$next = $this->createTables();
break;
case 1:
$next = $this->importTaxes();
break;
case 2:
$next = $this->importManufacturers();
break;
case 3:
$next = $this->importCategories();
break;
case 4:
$next = $this->importProducts();
break;
case 5:
$next = $this->importProductPrices();
break;
case 6:
$next = $this->importProductCategory();
break;
case 7:
$next = $this->importUsers();
break;
case 8:
$next = $this->importDiscount();
break;
case 9:
$next = $this->importOrders();
break;
case 10:
$next = $this->importOrderItems();
break;
case 11:
$next = $this->importDownloads();
break;
case 12:
case 13:
$next = $this->finishImport();
$ret = false;
break;
case 14:
$next = false;
$ret = $this->proposeReImport();
break;
default:
$ret = false;
break;
}
if( $ret && $next )
{
$sql = "UPDATE `#__hikashop_config` SET
config_value=(config_value+1) WHERE config_namekey =
'openc_import_state'; ";
$this->db->setQuery($sql);
$this->db->execute();
$sql = "UPDATE `#__hikashop_config` SET config_value=0 WHERE
config_namekey = 'openc_import_current';";
$this->db->setQuery($sql);
$this->db->execute();
}
else if( $current != $this->options->current )
{
$sql = "UPDATE `#__hikashop_config` SET
config_value=".$this->options->current." WHERE
config_namekey = 'openc_import_current';";
$this->db->setQuery($sql);
$this->db->execute();
}
return $ret;
}
function loadConfiguration()
{
$this->options = null;
$data = array(
'uploadfolder',
'uploadsecurefolder',
'main_currency',
'openc_import_state',
'openc_import_current',
'openc_import_tax_id',
'openc_import_main_cat_id',
'openc_import_max_hk_cat',
'openc_import_max_hk_prod',
'openc_import_last_openc_cat',
'openc_import_last_openc_prod',
'openc_import_last_openc_user',
'openc_import_last_openc_order',
'openc_import_last_openc_pfile',
'openc_import_last_openc_coupon',
'openc_import_last_openc_voucher',
'openc_import_last_openc_taxrate',
'openc_import_last_openc_taxclass',
'openc_import_last_openc_manufacturer',
'openc_import_max_joomla_user'
);
$this->db->setQuery('SELECT config_namekey, config_value FROM
`#__hikashop_config` WHERE config_namekey IN
('."'".implode("','",$data)."'".');');
$result = $this->db->loadObjectList();
if (!empty($result))
{
foreach($result as $o)
{
if( substr($o->config_namekey, 0, 13) == 'openc_import_'
)
$nk = substr($o->config_namekey, 13);
else
$nk = $o->config_namekey;
$this->options->$nk = $o->config_value;
}
}
$this->options->uploadfolder =
rtrim(JPath::clean(html_entity_decode($this->options->uploadfolder)),DS.'
').DS;
if(!preg_match('#^([A-Z]:)?/.*#',$this->options->uploadfolder)){
if(!$this->options->uploadfolder[0]=='/' ||
!is_dir($this->options->uploadfolder)){
$this->options->uploadfolder =
JPath::clean(HIKASHOP_ROOT.DS.trim($this->options->uploadfolder,DS.'
').DS);
}
}
$this->options->uploadsecurefolder =
rtrim(JPath::clean(html_entity_decode($this->options->uploadsecurefolder)),DS.'
').DS;
if(!preg_match('#^([A-Z]:)?/.*#',$this->options->uploadsecurefolder)){
if(!$this->options->uploadsecurefolder[0]=='/' ||
!is_dir($this->options->uploadsecurefolder)){
$this->options->uploadsecurefolder =
JPath::clean(HIKASHOP_ROOT.DS.trim($this->options->uploadsecurefolder,DS.'
').DS);
}
}
if( !isset($this->options->state) )
{
$this->options->state = 0;
$this->options->current = 0;
$this->options->tax_id = 0;
$this->options->last_openc_coupon = 0;
$this->options->last_openc_voucher = 0;
$this->options->last_openc_pfile = 0;
$this->options->last_openc_taxrate = 0;
$this->options->last_openc_taxclass = 0;
$this->options->last_openc_manufacturer = 0;
$element = 'product';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$this->options->main_cat_id = $element;
$this->db->setQuery("SELECT max(category_id) as
'max' FROM `#__hikashop_category`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(product_id) as
'max' FROM `#__hikashop_product`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_prod = (int)($data[0]->max);
$this->db->setQuery("SELECT max(id) as 'max' FROM
`#__users`;");
$data = $this->db->loadObjectList();
$this->options->max_joomla_user = (int)($data[0]->max);
$query='SHOW TABLES LIKE
'.$this->db->Quote($this->db->getPrefix().substr(hikashop_table('openc_cat'),3));
$this->db->setQuery($query);
$table = $this->db->loadResult();
if(!empty($table))
{
$this->db->setQuery("SELECT max(openc_id) as 'max'
FROM `#__hikashop_openc_cat`;");
$data = $this->db->loadObjectList();
if( $data )
$this->options->last_openc_cat = (int)($data[0]->max);
else
$this->options->last_openc_cat = 0;
$this->db->setQuery("SELECT max(openc_id) as 'max'
FROM `#__hikashop_openc_prod`;");
$data = $this->db->loadObjectList();
if( $data )
$this->options->last_openc_prod = (int)($data[0]->max);
else
$this->options->last_openc_prod = 0;
$this->db->setQuery("SELECT max(order_openc_id) as
'max' FROM `#__hikashop_order`;");
$data = $this->db->loadObjectList();
if( $data )
$this->options->last_openc_order = (int)($data[0]->max);
else
$this->options->last_openc_order = 0;
}
else
{
$this->options->last_openc_cat = 0;
$this->options->last_openc_prod = 0;
$this->options->last_openc_order = 0;
}
$this->options->last_openc_user = 0;
$sql = 'INSERT IGNORE INTO `#__hikashop_config`
(`config_namekey`,`config_value`,`config_default`) VALUES '.
"('openc_import_state',".$this->options->state.",".$this->options->state.")".
",('openc_import_current',".$this->options->current.",".$this->options->current.")".
",('openc_import_tax_id',".$this->options->tax_id.",".$this->options->tax_id.")".
",('openc_import_main_cat_id',".$this->options->main_cat_id.",".$this->options->main_cat_id.")".
",('openc_import_max_hk_cat',".$this->options->max_hk_cat.",".$this->options->max_hk_cat.")".
",('openc_import_max_joomla_user',".$this->options->max_joomla_user.",".$this->options->max_joomla_user.")".
",('openc_import_max_hk_prod',".$this->options->max_hk_prod.",".$this->options->max_hk_prod.")".
",('openc_import_last_openc_cat',".$this->options->last_openc_cat.",".$this->options->last_openc_cat.")".
",('openc_import_last_openc_prod',".$this->options->last_openc_prod.",".$this->options->last_openc_prod.")".
",('openc_import_last_openc_user',".$this->options->last_openc_user.",".$this->options->last_openc_user.")".
",('openc_import_last_openc_order',".$this->options->last_openc_order.",".$this->options->last_openc_order.")".
",('openc_import_last_openc_pfile',".$this->options->last_openc_pfile.",".$this->options->last_openc_pfile.")".
",('openc_import_last_openc_coupon',".$this->options->last_openc_coupon.",".$this->options->last_openc_coupon.")".
",('openc_import_last_openc_voucher',".$this->options->last_openc_voucher.",".$this->options->last_openc_voucher.")".
",('openc_import_last_openc_taxrate',".$this->options->last_openc_taxrate.",".$this->options->last_openc_taxrate.")".
",('openc_import_last_openc_taxclass',".$this->options->last_openc_taxclass.",".$this->options->last_openc_taxclass.")".
",('openc_import_last_openc_manufacturer',".$this->options->last_openc_manufacturer.",".$this->options->last_openc_manufacturer.")".
';';
$this->db->setQuery($sql);
$this->db->execute();
}
}
function createTables()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
1 :</span>Â Initialization Tables</p>';
$create = true;
$query='SHOW TABLES LIKE
'.$this->db->Quote($this->db->getPrefix().substr(hikashop_table('openc_cat'),3));
$this->db->setQuery($query);
$table = $this->db->loadResult();
if (!empty($table))
$create = false;
if ($create)
{
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_openc_prod` (`openc_id` int(11) unsigned NOT NULL DEFAULT
'0', `hk_id` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`openc_id`)) ENGINE=MyISAM");
$this->db->execute();
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_openc_cat` (`openc_cat_id` INT(11) unsigned NOT NULL
AUTO_INCREMENT, `openc_id` int(11) unsigned NOT NULL DEFAULT '0',
`hk_id` int(11) unsigned NOT NULL DEFAULT '0', `category_type`
varchar(255) NULL, PRIMARY KEY (`openc_cat_id`)) ENGINE=MyISAM");
$this->db->execute();
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_openc_user` (`openc_user_id` int(11) unsigned NOT NULL DEFAULT
'0', `hk_user_cms_id` int(11) unsigned NOT NULL DEFAULT
'0', PRIMARY KEY (`openc_user_id`)) ENGINE=MyISAM");
$this->db->execute();
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_openc_customer` (`openc_customer_id` int(11) unsigned NOT NULL
DEFAULT '0', `hk_customer_cms_id` int(11) unsigned NOT NULL
DEFAULT '0', PRIMARY KEY (`openc_customer_id`))
ENGINE=MyISAM");
$this->db->execute();
$databaseHelper = hikashop_get('helper.database');
$databaseHelper->addColumns('address','`address_openc_order_info_id`
INT(11) NULL');
$databaseHelper->addColumns('order','`order_openc_id`
INT(11) NULL');
$databaseHelper->addColumns('order','INDEX (
`order_openc_id` )');
$databaseHelper->addColumns('taxation','`tax_openc_id`
INT(11) NULL');
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
All table created</p>';
}
else
{
echo '<p>Tables have been already created.</p>';
}
return true;
}
function importTaxes()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
2 :</span>Â Import Taxes<p>';
$ret = false;
$data = array(
'tax_namekey' => "CONCAT('OPENC_TAX_',
octr.tax_rate_id)",
'tax_rate' => 'octr.rate/100'
);
$sql = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_tax`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'tax_rate`
AS octr '.
'WHERE octr.tax_rate_id > ' .
(int)$this->options->last_openc_taxrate;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported taxes: ' . $total . '</p>';
$element = 'tax';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$data = array(
'category_type' => "'tax'",
'category_name' => "CONCAT('Tax imported
(', octc.title,')')",
'category_published' => '1',
'category_parent_id' => $element,
'category_namekey' => "
CONCAT('OPENC_TAX_CATEGORY_', octc.tax_class_id)"
);
$sql = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'tax_class`
AS octc ';
'WHERE octc.tax_class_id > ' .
(int)$this->options->last_openc_taxclass;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Taxes Categories: ' . $total . '</p>';
if( $total > 0 ) {
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'openc_import_max_hk_cat'; ");
$this->db->execute();
$this->importRebuildTree();
}
$data = array(
'zone_namekey' => "case when hkz.zone_namekey IS NULL
then '' else hkz.zone_namekey end",
'category_namekey' =>
"CONCAT('OPENC_TAX_CATEGORY_', octc.tax_class_id)",
//"case when hkz.zone_id IS NULL then CONCAT('openc_TAX_',
octr.tax_rate_id,'_0') else CONCAT('openc_TAX_',
octr.tax_rate_id,'_',hkz.zone_id) end",
'tax_namekey' => "CONCAT('OPENC_TAX_',
octra.tax_rate_id)",
'taxation_published' => '1',
'taxation_type' => "''",
'tax_openc_id' => 'octc.tax_class_id'
//'octra.tax_rate_id' See import product
);
$sql = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_taxation`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'tax_class`
AS octc '.
'INNER JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'tax_rule`
AS octr ON octc.tax_class_id = octr.tax_class_id '.
'INNER JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'tax_rate`
AS octra ON octr.tax_rate_id = octra.tax_rate_id '.
'LEFT JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'zone_to_geo_zone`
AS ocz ON octra.geo_zone_id = ocz.geo_zone_id '.
'LEFT JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'country`
AS occ ON ocz.country_id = occ.country_id ' .
"LEFT JOIN
`".$this->hikaDatabaseName."`.`#__hikashop_zone` hkz ON
occ.iso_code_3 = hkz.zone_code_3 AND hkz.zone_type = 'country'
".
'WHERE octra.tax_rate_id > ' .
(int)$this->options->last_openc_taxrate;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Taxations: ' . $total . '</p>';
$ret = true;
return $ret;
}
function importManufacturers()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
3 :</span>Â Import Manufacturers</p>';
$ret = false;
$count = 100;
$rebuild = false;
$sql1 = 'SELECT * FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'manufacturer`
ocm '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_cat` hkoc ON
ocm.manufacturer_id = hkoc.openc_id AND
category_type=\'manufacturer\' '.
'WHERE ocm.manufacturer_id > ' .
(int)$this->options->last_openc_manufacturer;
'ORDER BY ocm.manufacturer_id ASC;';
$this->db->setQuery($sql1);
$this->db->execute();
$datas = $this->db->loadObjectList();
$sql2 = 'INSERT INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_published`,'.
'`category_namekey`,`category_description`,`category_menu`) VALUES
';
$sql3 = 'INSERT INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_cat`
(`openc_id`,`hk_id`,`category_type`) VALUES ';
$sql4 = 'INSERT INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_file`
(`file_name`,`file_description`,`file_path`,`file_type`,`file_ref_id`)
VALUES ';
$doSql3 = false;
$doSql4 = false;
$i = $this->options->max_hk_cat + 1;
$ids = array( 0 => $this->options->main_cat_id);
$sep = '';
$sep2 = '';
$cpt=0;
$echo=false;
if( empty($datas) )
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported manufacturers : 0</p>';
return true;
}
else
{
foreach($datas as $data)
{
if( !empty($data->openc_id) )
{
$ids[$data->manufacturer_id] = $data->hk_id;
}
else
{
$doSql3 = true;
$ids[$data->manufacturer_id] = $i;
$sql3 .=
$sep.'('.$data->manufacturer_id.','.$i.',\'manufacturer\')';
$i++;
$sep = ',';
}
$cpt++;
if( $cpt >= $count )
break;
}
$sql3 .= ';';
$cpt = 0;
$sep = '';
foreach($datas as $data)
{
if( !empty($data->openc_id) )
continue;
$id = $ids[$data->manufacturer_id];
$element = 'manufacturer';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$d = array(
$id,
$element,
"'manufacturer'",
$this->db->quote($data->name),
'1',
"CONCAT('OPENC_MANUFAC_',
".$data->manufacturer_id .")",
"'manufacturer imported from Opencart'",
'0'
);
$sql2 .= $sep.'('.implode(',',$d).')';
if( !empty($data->image) &&
!empty($this->opencRootPath))
{
if (defined('DIR_IMAGE'))
$this->copyManufDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode(DIR_IMAGE)),DS.'
').DS);
else
$this->copyManufDir = $this->opencRootPath.'image/';
if (!$echo)
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying manufacturers images... </p>';
$echo=true;
}
$doSql4 = true;
$sql4 .=
$sep2."(".$this->db->quote($data->name).",'',".$this->db->quote($data->image).",'category',".$id.')';
$sep2 = ',';
$file_name =
str_replace('\\','/',$data->image);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyManufDir,$data->image,
str_replace('//','/',str_replace('\\','/',$this->options->uploadfolder.$file_name)));
}
$sep = ',';
$cpt++;
if( $cpt >= $count )
break;
}
}
if($cpt > 0)
{
$sql2 .= ';';
$sql4 .= ';';
$this->db->setQuery($sql2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Manufacturers : ' . $total . '</p>';
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Manufacturers : 0</p>';
}
if( isset($total) && $total > 0)
{
$rebuild = true;
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'openc_import_max_hk_cat'; ");
$this->db->execute();
}
if ($doSql3)
{
$this->db->setQuery($sql3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links : ' . $total . '</p>';
}
if($doSql4)
{
$this->db->setQuery($sql4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Manufacturers files : ' . $total . '</p>';
}
if( $rebuild )
$this->importRebuildTree();
if( $cpt < $count )
$ret = true;
return $ret;
}
function importCategories()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
4 :</span>Â Import General Categories</p>';
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$rebuild = false;
$ret = false;
$offset = 0;
$count = 100;
$cpt = 0;
$sep = '';
$sep2 = '';
$echo = false;
$statuses = array(
'P' => 'created',
'C' => 'confirmed',
'X' => 'cancelled',
'R'=> 'refunded' ,
'S' => 'shipped'
);
$this->db->setQuery("SELECT category_keywords,
category_parent_id FROM `#__hikashop_category` WHERE category_type =
'status' AND category_name = 'confirmed'");
$data = $this->db->loadObject();
$status_category = $data->category_parent_id;
if( $data->category_keywords != 'C' ) {
foreach($statuses as $k => $v) {
$this->db->setQuery("UPDATE `#__hikashop_category` SET
category_keywords = '".$k."' WHERE category_type =
'status' AND category_name = '".$v."';
");
$this->db->execute();
}
}
$this->db->setQuery("SELECT order_status_id, name FROM
`".$this->opencDatabase."`.`".$this->opencPrefix."order_status`
WHERE name NOT IN
('".implode("','",$statuses)."','canceled');");
$data = $this->db->loadObjectList();
if( count($data) > 0 )
{
$sql0 = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_description`,`category_published`,'.
'`category_namekey`,`category_access`,`category_menu`,`category_keywords`)
VALUES ';
$id = $this->options->max_hk_cat + 1;
$sep = '';
foreach($data as $c) {
$d = array(
$id++,
$status_category,
"'status'",
$this->db->quote( strtolower($c->name) ),
"'Order status imported from Opencart'",
'1',
$this->db->quote('status_openc_import_'.strtolower(str_replace('
','_',$c->name))),
"'all'",
'0',
$this->db->quote( $c->order_status_id )
);
$sql0 .= $sep.'('.implode(',',$d).')';
$sep = ',';
}
$this->db->setQuery($sql0);
$this->db->execute();
$total = $this->db->getAffectedRows();
if( $total > 0 ) {
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported order status categories : ' . $total .
'</p>';
$rebuild = true;
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'openc_import_max_hk_cat'; ");
$this->db->execute();
$sql0 = '';
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported order status categories : 0</p>';
}
}
$sql1 = 'SELECT * FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'category`
occ '.
'INNER JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'category_description`
occd ON occ.category_id = occd.category_id '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_cat` hkoc ON
occ.category_id = hkoc.openc_id AND category_type=\'category\'
'.
'WHERE occ.category_id >
'.$this->options->last_openc_cat.' '.
'ORDER BY occ.parent_id ASC, occ.category_id ASC;';
$this->db->setQuery($sql1);
$this->db->execute();
$datas = $this->db->loadObjectList();
$sql2 = 'INSERT INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_description`,`category_published`,'.
'`category_ordering`,`category_namekey`,`category_created`,`category_modified`,`category_access`,`category_menu`)
VALUES ';
$sql3 = 'INSERT INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_cat`
(`openc_id`,`hk_id`,`category_type`) VALUES ';
$sql4 = 'INSERT INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_file`
(`file_name`,`file_description`,`file_path`,`file_type`,`file_ref_id`)
VALUES ';
$doSql3 = false;
$doSql4 = false;
$i = $this->options->max_hk_cat + 1;
$ids = array( 0 => $this->options->main_cat_id);
$sep = '';
if( empty($datas) )
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported category : 0</p>';
if( $rebuild )
$this->importRebuildTree();
return true;
}
else
{
foreach($datas as $data)
{
if( !empty($data->openc_id) )
{
$ids[$data->category_id] = $data->hk_id;
}
else
{
$doSql3 = true;
$ids[$data->category_id] = $i;
$sql3 .=
$sep.'('.$data->category_id.','.$i.',\'category\')';
$i++;
$sep = ',';
}
$cpt++;
if( $cpt >= $count )
break;
}
$sql3 .= ';';
$cpt = 0;
$sep = '';
foreach($datas as $data)
{
if( !empty($data->openc_id) )
continue;
$id = $ids[$data->category_id];
if(!empty($ids[$data->parent_id]))
$pid = (int)$ids[$data->parent_id];
else
$pid = $ids[0];
$element = new stdClass();
$element->category_id = $id;
$element->category_parent_id = $pid;
$element->category_name = $data->name;
$nameKey = $categoryClass->getNameKey($element);
$d = array(
$id,
$pid,
"'product'",
$this->db->quote($data->name),
$this->db->quote($data->description),
'1',
$data->sort_order,
$this->db->quote($nameKey),
"'".$data->date_added."'",
"'".$data->date_modified."'",
"'all'",
'0'
);
$sql2 .= $sep.'('.implode(',',$d).')';
if( !empty($data->image) &&
!empty($this->opencRootPath))
{
if (defined('DIR_IMAGE'))
$this->copyCatImgDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode(DIR_IMAGE)),DS.'
').DS);
else
$this->copyCatImgDir =
$this->opencRootPath.'image/';
if (!$echo)
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying categories images... </p>';
$echo=true;
}
$doSql4 = true;
$sql4 .=
$sep2."('','','".$data->image."','category',".$id.')';
$sep2 = ',';
$file_name =
str_replace('\\','/',$data->image);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyCatImgDir,$data->image,
str_replace('//','/',str_replace('\\','/',$this->options->uploadfolder.$file_name)));
}
$sep = ',';
$cpt++;
if( $cpt >= $count )
break;
}
}
if($cpt > 0)
{
$sql2 .= ';';
$sql4 .= ';';
$this->db->setQuery($sql2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Categories : ' . $total . '</p>';
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported category : 0</p>';
}
if( isset($total) && $total > 0)
{
$rebuild = true;
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'openc_import_max_hk_cat'; ");
$this->db->execute();
}
if ($doSql3)
{
$this->db->setQuery($sql3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links : ' . $total . '</p>';
}
if($doSql4)
{
$this->db->setQuery($sql4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Categories files : ' . $total . '</p>';
}
if( $rebuild )
$this->importRebuildTree();
if( $cpt < $count )
$ret = true;
return $ret;
}
function importProducts()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
5 :</span>Â Import Products</p>';
$ret = false;
$count = 100;
$offset = $this->options->current;
$max = 0;
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$this->db->setQuery('SELECT ocp.product_id, ocpi.image FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'product`
ocp '.
'LEFT JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'product_image`
ocpi ON ocp.product_id = ocpi.product_id '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_prod` hkprod
ON ocp.product_id = hkprod.openc_id '.
"WHERE ocp.product_id > ".(int)$offset." AND
hkprod.hk_id IS NULL AND (ocp.image IS NOT NULL) AND ocp.image <>
'' ".
'ORDER BY product_id ASC LIMIT '.$count.';'
);
$datas = $this->db->loadObjectList();
if (!empty($datas) && !empty($this->opencRootPath))
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying products images... </p>';
if (defined('DIR_IMAGE'))
$this->copyImgDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode(DIR_IMAGE)),DS.'
').DS);
else
$this->copyImgDir = $this->opencRootPath.'image/';
foreach($datas as $data) {
if( !empty($data->image) ) {
$file_name =
str_replace('\\','/',$data->image);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyImgDir,$data->image,
$this->options->uploadfolder.$file_name);
$max = $data->product_id;
}
}
}
if( $max > 0 )
{
echo '<p>Copying files...(last proccessed product id: '
. $max . ')</p>';
$this->options->current = $max;
$this->refreshPage = true;
return $ret;
}
$data = array(
'product_name' => 'ocpd.name',
'product_description' => 'ocpd.description',
'product_quantity' => 'case when ocp.quantity IS NULL
or ocp.quantity < 0 then 0 else ocp.quantity end',
'product_code' => 'ocp.hika_sku',
'product_published' => 'ocp.status',
'product_hit' => 'ocp.viewed',
'product_created' => 'ocp.date_added',
'product_modified' => 'ocp.date_modified',
'product_sale_start' => 'ocp.date_available',
'product_tax_id' => 'hkc.category_id',
'product_type' => "'main'",
'product_url' => "''",
'product_weight' => 'ocp.weight',
'product_weight_unit' => "LOWER(ocwcd.unit)",
'product_dimension_unit' => "LOWER(oclcd.unit)",
'product_min_per_order' => 'ocp.minimum',
'product_sales' => '0',
'product_width' => 'ocp.width',
'product_length' => 'ocp.length',
'product_height' => 'ocp.height',
'product_parent_id' => '0'
);
$sql1 = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_product`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'product`
AS ocp '.
'INNER JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'weight_class_description`
ocwcd ON ocp.weight_class_id = ocwcd.weight_class_id '.
'INNER JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'length_class_description`
oclcd ON ocp.length_class_id = oclcd.length_class_id '.
'INNER JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'product_description`
ocpd ON ocp.product_id = ocpd.product_id '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_taxation` hkt ON
hkt.tax_openc_id = ocp.tax_class_id '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_category` hkc ON
hkc.category_namekey = hkt.category_namekey '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_prod` AS hkp
ON ocp.product_id = hkp.openc_id '.
'WHERE hkp.hk_id IS NULL ORDER BY ocp.product_id ASC;';
$this->db->setQuery('SHOW COLUMNS FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'product`
LIKE \'hika_sku\';');
$data = $this->db->loadObjectList();
if (empty($data))
{
$this->db->setQuery('ALTER TABLE
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'product`
ADD COLUMN `hika_sku` VARCHAR(255) NOT NULL;');
$this->db->execute();
}
$this->db->setQuery('UPDATE
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'product`
AS ocp SET ocp.hika_sku = ocp.sku;');
$this->db->execute();
$this->db->setQuery("UPDATE
`".$this->opencDatabase."`.`".$this->opencPrefix."product`
AS ocp SET ocp.hika_sku = CONCAT(ocp.model,'_',ocp.product_id)
WHERE ocp.hika_sku='';");
$this->db->execute();
$this->db->setQuery('SELECT hika_sku FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'product`
GROUP BY hika_sku HAVING COUNT(hika_sku)>1');
$data = $this->db->loadObjectList();
if (!empty($data))
{
foreach ($data as $d)
{
$this->db->setQuery("UPDATE `oc_product` AS ocp SET
ocp.hika_sku = CONCAT(ocp.hika_sku,'_',ocp.product_id) WHERE
ocp.hika_sku = '".$d->hika_sku."';");
$this->db->execute();
}
}
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
SKU generated: '.count($data).'</p>';
$data = array(
'openc_id' => 'ocp.product_id',
'hk_id' => 'hkp.product_id'
);
$sql2 = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_prod`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'product`
AS ocp '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_product` AS hkp ON
CONVERT(ocp.hika_sku USING utf8) = CONVERT(hkp.product_code USING utf8)
'.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_prod` hkocp
ON hkocp.openc_id = ocp.product_id '.
'WHERE hkocp.hk_id IS NULL;';
$data = array(
'file_name' => "''",
'file_description' => "''",
'file_path' =>
"SUBSTRING_INDEX(ocpi.image,'/',-1)",
'file_type' => "'product'",
'file_ref_id' => 'hkocp.hk_id'
);
$sql4 = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_file`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'product`
AS ocp '.
'INNER JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'product_image`
ocpi ON ocp.product_id = ocpi.product_id '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_prod` AS
hkocp ON ocp.product_id = hkocp.openc_id '.
'WHERE ocp.product_id >
'.(int)$this->options->last_openc_prod. ' AND (ocpi.image
IS NOT NULL) AND (ocpi.image <>'." '');";
$sql5 = 'UPDATE
`'.$this->hikaDatabaseName.'`.`#__hikashop_product` AS hkp
'.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_prod` AS
hkocp ON hkp.product_id = hkocp.hk_id '.
'INNER JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'product`
AS ocp ON hkocp.openc_id = ocp.product_id '.
"INNER JOIN
`".$this->hikaDatabaseName."`.`#__hikashop_category` AS hkc ON
hkc.category_type = 'manufacturer' AND ocp.manufacturer_id =
hkc.category_menu ".
'SET hkp.product_manufacturer_id = hkc.category_id '.
'WHERE ocp.manufacturer_id >
'.(int)$this->options->last_openc_manufacturer.' OR
ocp.product_id >
'.$this->options->last_openc_prod.';';
$this->db->setQuery($sql1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products: ' . $total . '</p>';
$this->db->setQuery($sql2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links: ' . $total . '</p>';
$this->db->setQuery($sql4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products files: ' . $total . '</p>';
$this->db->setQuery($sql5);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating products manufacturers: ' . $total . '</p>';
$ret = true;
return $ret;
}
function importVariant()
{
}
function importProductPrices()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
6 :</span>Â Import Product Prices</p>';
$ret = false;
$cpt = 0;
$this->db->setQuery('SELECT hkcur.currency_id FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'currency`
occ '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_currency` hkcur ON
CONVERT(occ.code USING utf8) = CONVERT( hkcur.currency_code USING utf8)
'.
"WHERE occ.value = '1.0';");
$data = $this->db->loadObjectList();
if (!empty($data))
{
$this->db->setQuery('INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_price`
(`price_product_id`,`price_value`,`price_currency_id`,`price_min_quantity`,`price_access`)
'
."SELECT hkprod.hk_Id, ocp.price,
'".$data[0]->currency_id."', '0',
'all' "
.'FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'product`
ocp INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_prod` hkprod
ON ocp.product_id = hkprod.openc_id '
.'WHERE ocp.product_id > ' .
(int)$this->options->last_openc_prod
);
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Prices imported : 0</p>';
}
$ret = $this->db->execute();
$cpt = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Prices imported : ' . $cpt .'</p>';
if ($this->importcurrencies)
$this->importCurrencies();
return $ret;
}
function importProductCategory()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
7 :</span>Â Import Product Category</p>';
$ret = false;
$data = array(
'category_id' => 'hocc.hk_id',
'product_id' => 'hocp.hk_id',
'ordering' => '0',
);
$sql = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_product_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'product_to_category`
ocpc '.
'INNER JOIN #__hikashop_openc_cat hocc ON ocpc.category_id =
hocc.openc_id AND category_type=\'category\' '.
'INNER JOIN #__hikashop_openc_prod hocp ON ocpc.product_id =
hocp.openc_id '.
'WHERE hocp.openc_id > ' .
(int)$this->options->last_openc_prod . ' OR hocc.openc_id >
' . $this->options->last_openc_cat;
$this->db->setQuery($sql);
$ret = $this->db->execute();
$total = $this->db->getAffectedRows();
$this->importRebuildTree();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products categories: ' . $total . '</p>';
return $ret;
}
function importUsers()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
8 :</span>Â Import Users</p>';
$ret = false;
$sqla = 'SELECT ocu.* FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'user`
ocu '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_user` hkocu
ON ocu.user_id = hkocu.openc_user_id '.
'WHERE hkocu.openc_user_id IS NULL '.
'ORDER BY ocu.user_id ASC;';
$this->db->setQuery($sqla);
$this->db->execute();
$datas = $this->db->loadObjectList();
$i = $this->options->max_joomla_user + 1;
if( empty($datas) )
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported user to Joomla : 0</p>';
}
else
{
$total = $this->importUsersToJoomla($datas,$i,false);
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported users to Joomla : ' . $total . '</p>';
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links (users) : ' . $total . '</p>';
}
$sqla = 'SELECT occu.* FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'customer`
occu '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_customer`
hkoccu ON occu.customer_id = hkoccu.openc_customer_id '.
'WHERE hkoccu.openc_customer_id IS NULL '.
'ORDER BY occu.customer_id ASC;';
$this->db->setQuery($sqla);
$this->db->execute();
$datas = $this->db->loadObjectList();
if( empty($datas) )
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported customer to Joomla : 0</p>';
}
else
{
$total = $this->importUsersToJoomla($datas,$i,true);
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported customers to Joomla : ' . $total . '</p>';
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links (customers) : ' . $total . '</p>';
}
$sql0 = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_user`
(`user_cms_id`,`user_email`) '.
'SELECT hkoccu.hk_customer_cms_id, occ.email FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'customer`
occ '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_customer`
hkoccu ON hkoccu.openc_customer_id = occ.customer_id '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_user` AS hkusr ON
hkoccu.hk_customer_cms_id = hkusr.user_cms_id '.
'WHERE hkusr.user_cms_id IS NULL;';
$data = array(
'address_user_id' => 'hku.user_id',
'address_title' => "'Mr'",
'address_firstname' => 'oca.firstname',
'address_lastname' => 'oca.lastname',
'address_company' => 'oca.company',
'address_street' => 'CONCAT(oca.address_1,\'
\',oca.address_2)',
'address_post_code' => 'oca.postcode',
'address_city' => 'oca.city',
'address_telephone' => 'occu.telephone',
'address_fax' => 'occu.fax',
'address_state' => 'hkzsta.zone_namekey',
'address_country' => 'hkzcou.zone_namekey',
'address_published' => 1
);
$sql1 = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_address`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'customer`
AS occu '.
'INNER JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'address`
AS oca ON occu.customer_id = oca.customer_id '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_customer`
hkoccu ON oca.customer_id = hkoccu.openc_customer_id '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_user` AS hku ON
hkoccu.hk_customer_cms_id = hku.user_cms_id '.
'LEFT JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'country`
AS occ ON oca.country_id = occ.country_id '.
'LEFT JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'zone`
AS ocz ON oca.zone_id = ocz.zone_id '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_zone` AS hkzcou ON
occ.iso_code_3 = hkzcou.zone_code_3 AND
hkzcou.zone_type=\'country\' '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_zone_link` AS hkzl
ON hkzcou.zone_namekey = hkzl.zone_parent_namekey '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_zone` AS hkzsta ON
ocz.code = hkzsta.zone_code_3 AND hkzsta.zone_type=\'state\' AND
hkzsta.zone_namekey = hkzl.zone_child_namekey '.
'WHERE occu.customer_id >
'.(int)$this->options->last_openc_user.' ORDER BY
oca.customer_id ASC';
$this->db->setQuery($sql0);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported users to Hikashop : ' . $total . '</p>';
$this->db->setQuery($sql1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses : ' . $total . '</p>';
$ret = true;
return $ret;
}
function importUsersToJoomla($datas,&$i,$customer)
{
$cpt = 0;
foreach($datas as $data)
{
if ($customer)
$data->username = $data->email;
$this->db->setQuery("SELECT * FROM `#__users` WHERE username
= ".$this->db->quote($data->username).";");
$this->db->execute();
$result = $this->db->loadObjectList();
if (!empty($result))
{
echo
'<p><span'.$this->bullstyle.'>►</span>
The user <strong>'.$data->username.'</strong>
won\'t be imported because an user with the same name already exists
on Joomla.</p>';
}
else
{
$sqlb = 'INSERT IGNORE INTO `#__users` (id, name, username, email,
password, block, sendEmail, registerDate, params) VALUES ';
$sqlc = 'INSERT IGNORE INTO `#__user_usergroup_map` (user_id,
group_id) VALUES ';
if ($customer)
{
$sqld = 'INSERT IGNORE INTO `#__hikashop_openc_customer`
(openc_customer_id, hk_customer_cms_id) VALUES ';
$block = !$data->approved;
}
else
{
$sqld = 'INSERT IGNORE INTO `#__hikashop_openc_user`
(openc_user_id, hk_user_cms_id) VALUES ';
$block = 0;
}
$d = array(
$i,
$this->db->quote($data->firstname.'
'.$data->lastname),
$this->db->quote($data->username),
$this->db->quote($data->email),
"CONCAT(".$this->db->quote(@$data->password).",':',".$this->db->quote(@$data->salt).")",
$this->db->quote($block),
'0',
$this->db->quote($data->date_added),
"'{}'",
);
$sqlb .= '('.implode(',',$d).');';
if (isset($data->password)) //Don't insert guest
{
$this->db->setQuery($sqlb);
$this->db->execute();
}
if (!$customer)
$data->user_group_id == 1 ? $group = 8 : $group = 2;
else
$group = 2;
$sqlc .= '('.$i.','.$group.')';
if (isset($data->password)) //Don't insert guest
{
$this->db->setQuery($sqlc);
$this->db->execute();
}
if ($customer)
$sqld .=
'('.$data->customer_id.','.$i.')';
else
$sqld .=
'('.$data->user_id.','.$i.')';
$this->db->setQuery($sqld);
$this->db->execute();
$i++;
$cpt++;
}
}
return $cpt;
}
function importOrders()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
10 :</span>Â Import Orders</p>';
$ret = false;
$offset = $this->options->current;
$count = 100;
$total = 0;
$vat_cols = "''";
$data = array(
'order_number' => 'oco.order_id',
'order_openc_id' => 'oco.order_id',
'order_user_id' => 'hkusr.user_id',
'order_status' => 'hkc.category_name',
'order_created' =>
'UNIX_TIMESTAMP(oco.date_added)',
'order_ip' => 'oco.ip',
'order_currency_id' => 'hkcur.currency_id',
'order_shipping_price' => "''", //?
'order_shipping_method' =>
'oco.shipping_method',
'order_shipping_id' => '1',
'order_payment_id' => 0,
'order_payment_method' => 'oco.payment_method',
'order_full_price' => 'ocot.value',
'order_modified' =>
'UNIX_TIMESTAMP(oco.date_modified)',
'order_partner_id' => 0,
'order_partner_price' => 0,
'order_partner_paid' => 0,
'order_type' => "'sale'",
'order_partner_currency_id' => 0,
'order_shipping_tax' => "''", //?
'order_discount_tax' => 0
);
$sql1 = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_order`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'order`
AS oco '.
'INNER JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'order_product`
ocop ON ocop.order_id = oco.order_id '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_category` AS hkc ON
oco.order_status_id = hkc.category_keywords AND hkc.category_type =
\'status\' '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_currency` AS hkcur
ON CONVERT(oco.currency_code USING utf8) = CONVERT(hkcur.currency_code
USING utf8) '.
'INNER JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'order_total`
ocot ON oco.order_id = ocot.order_id AND code=\'total\' '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_customer`
hkoccu ON oco.customer_id = hkoccu.openc_customer_id '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_user` AS hkusr ON
hkoccu.hk_customer_cms_id = hkusr.user_cms_id '.
'WHERE oco.order_id > ' .
(int)$this->options->last_openc_order . ' '.
'GROUP BY oco.order_id '.
'ORDER BY oco.order_id ASC;';
$sql1_1 = 'UPDATE
`'.$this->hikaDatabaseName.'`.`#__hikashop_order` AS hko
'.
'INNER JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'voucher`
AS ocv ON hko.order_openc_id = ocv.order_id '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_discount` AS hkd ON
hkd.discount_code = ocv.code '.
'SET hko.order_discount_code = hkd.discount_code AND
hko.order_discount_price = hkd.discount_flat_amount';
$data = array(
'address_user_id' => 'oco.customer_id',
'address_firstname' => 'oco.payment_firstname',
'address_lastname' => 'oco.payment_lastname',
'address_company' => 'oco.payment_company',
'address_street' =>
'CONCAT(oco.payment_address_1,\'
\',oco.payment_address_2)',
'address_post_code' => 'oco.payment_postcode',
'address_city' => 'oco.payment_city ',
'address_telephone' => 'oco.telephone',
'address_fax' => 'oco.fax',
'address_state' => 'hkzsta.zone_namekey',
'address_country' => 'hkzcou.zone_namekey',
'address_published' => '7',
'address_vat' => $vat_cols,
'address_openc_order_info_id' => 'oco.order_id'
//8
);
$sql2_1 = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_address`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'order`
AS oco '.
'INNER JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'country`
AS occ ON oco.payment_country_id = occ.country_id '.
'INNER JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'zone`
AS ocz ON oco.payment_zone_id = ocz.zone_id '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_zone` AS hkzcou ON
occ.iso_code_3 = hkzcou.zone_code_3 AND
hkzcou.zone_type=\'country\' '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_zone_link` AS hkzl
ON hkzcou.zone_namekey = hkzl.zone_parent_namekey '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_zone` AS hkzsta ON
ocz.code = hkzsta.zone_code_3 AND hkzsta.zone_type=\'state\' AND
hkzsta.zone_namekey = hkzl.zone_child_namekey '.
'WHERE oco.order_id > ' .
(int)$this->options->last_openc_order;
$sql2_2 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone` AS hkz ON (a.address_country =
hkz.zone_code_3 AND hkz.zone_type = "country") '.
'SET address_country = hkz.zone_namekey, address_published = 6
WHERE address_published >= 7;';
$sql2_3 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone_link` AS zl ON (a.address_country =
zl.zone_parent_namekey) '.
'JOIN `#__hikashop_zone` AS hks ON (hks.zone_namekey =
zl.zone_child_namekey AND hks.zone_type = "state" AND
hks.zone_code_3 = a.address_state) '.
'SET address_state = hks.zone_namekey, address_published = 5 WHERE
address_published = 6;';
$sql2_4 = 'UPDATE `#__hikashop_address` AS a '.
'SET address_published = 0 WHERE address_published > 4;';
$sql3 = 'UPDATE `#__hikashop_order` AS o '.
'INNER JOIN `#__hikashop_address` AS a ON
a.address_openc_order_info_id = o.order_openc_id '.
'SET o.order_billing_address_id = a.address_id,
o.order_shipping_address_id = a.address_id '.
"WHERE o.order_billing_address_id = 0 AND address_published >= 7
;";
$sql4 = 'UPDATE `#__hikashop_order` AS o '.
'INNER JOIN `#__hikashop_address` AS a ON
a.address_openc_order_info_id = o.order_openc_id '.
'SET o.order_shipping_address_id = a.address_id '.
"WHERE (o.order_shipping_address_id = 0 OR
o.order_shipping_address_id = o.order_billing_address_id) AND
address_published >= 8 ;";
$sql5 = 'UPDATE
`'.$this->hikaDatabaseName.'`.`#__hikashop_order` AS hko
'.
'JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'order`
AS oco ON hko.order_openc_id = oco.order_id '.
"SET hko.order_payment_method = CONCAT('openc import: ',
oco.payment_method) ".
'WHERE hko.order_openc_id > ' .
(int)$this->options->last_openc_order;
$this->db->setQuery($sql1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported orders: ' . $total . '</p>';
$this->db->setQuery($sql1_1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating discount orders: ' . $total . '</p>';
$this->db->setQuery($sql2_1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported orders addresses: ' . $total . '</p>';
$this->db->setQuery($sql3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating billing addresses: ' . $total . '</p>';
$this->db->setQuery($sql4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating shipping addresses: ' . $total . '</p>';
$this->db->setQuery($sql5);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating order payments: ' . $total . '</p>';
$this->db->setQuery($sql2_2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating orders: ' . $total;
$this->db->setQuery($sql2_3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '/' . $total;
$this->db->setQuery($sql2_4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '/' . $total . '</p>';
$ret = true;
return $ret;
}
function importOrderItems()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
11 :</span>Â Import Order Items</p>';
$ret = false;
$offset = $this->options->current;
$count = 100;
$data = array(
'order_id' => 'hko.order_id',
'product_id' => 'hkp.hk_id',
'order_product_quantity' => 'ocop.quantity',
'order_product_name' => 'ocop.name',
'order_product_code' => 'ocp.hika_sku',
'order_product_price' => 'ocop.price',
'order_product_tax' => 'ocop.tax',
'order_product_options' => "''"
);
$sql = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_order_product`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'order_product`
AS ocop '.
'INNER JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'product`
ocp ON ocop.product_id=ocp.product_id '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_order` AS hko ON
ocop.order_id = hko.order_openc_id '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_prod` AS hkp
ON hkp.openc_id = ocop.product_id '.
'WHERE ocop.order_id > ' .
(int)$this->options->last_openc_order . ';';
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Orders Items : '. $total .'</p>';
$ret = true;
return $ret;
}
function importDownloads()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
12 :</span>Â Import Downloads</p>';
$ret = false;
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$count = 100;
$offset = $this->options->current;
if( $offset == 0 )
$offset = $this->options->last_openc_pfile;
$sql = "SELECT `config_value` FROM `#__hikashop_config` WHERE
config_namekey = 'download_number_limit';";
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$dl_limit = $data[0]->config_value;
$sql = 'SELECT ocd.download_id, ocd.filename FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'download`
AS ocd WHERE ocd.download_id > '.$offset.' ORDER BY
ocd.download_id ASC LIMIT '.$count.';';
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$max = 0;
if (!empty($data) && !empty($this->opencRootPath))
{
if ( defined('DIR_DOWNLOAD') )
$this->copyDownloadDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode(DIR_DOWNLOAD)),DS.'
').DS);
else
$this->copyDownloadDir =
'C:/wamp/www/Opencart_156/download/';
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying downloads files... </p>';
foreach($data as $c)
{
$file_name =
end(explode('/',str_replace('\\','/',$c->filename)));
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$dstFolder = $this->options->uploadfolder; //secure ?
$this->copyFile($this->copyDownloadDir, $c->filename,
$dstFolder.$file_name);
$max = $c->download_id;
}
if( $max > 0 )
{
echo '<p>Copying files...<br/>(Last processed file id:
' . $max . '</p>';
$this->options->current = $max;
$this->refreshPage = true;
return $ret;
}
}
$data = array(
'file_name' => 'ocdd.name',
'file_description' => "''",
'file_path' => "SUBSTRING_INDEX(ocd.filename
,'/',-1)", //Why no filename ?
'file_type' => "'file'",
'file_ref_id' => 'hkocp.hk_id'
);
$sql = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_file`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'download`
AS ocd '.
'INNER JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'download_description`
ocdd ON ocd.download_id = ocdd.download_id '.
'LEFT JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'product_to_download`
ocpd ON ocd.download_id = ocpd.download_id '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_prod` AS
hkocp ON ocpd.product_id = hkocp.openc_id '.
'WHERE ocd.download_id >
'.(int)$this->options->last_openc_pfile;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Downloable files imported : ' . $total . '</p>';
$data = array(
'file_id' => 'hkf.file_id',
'order_id' => 'hko.order_id',
'download_number' => '(' . $dl_limit . '-
ocd.remaining)' //$dl_limit ?
);
$sql = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_download`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'download`
AS ocd '.
'INNER JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'download_description`
ocdd ON ocd.download_id = ocdd.download_id '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_file` AS hkf ON (
CONVERT(hkf.file_name USING utf8) = CONVERT(ocdd.name USING utf8) )'.
'INNER JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'product_to_download`
AS ocpd ON ocd.download_id = ocpd.download_id '.
'INNER JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'order_product`
AS ocop ON ocpd.product_id = ocop.product_id '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_order` AS hko ON
hko.order_openc_id = ocop.order_id '.
'WHERE ocd.download_id >
'.(int)$this->options->last_openc_pfile;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Downloable order files imported : ' . $total .
'</p>';
$ret = true;
return $ret;
}
function importDiscount()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
9 :</span>Â Import Discount</p>';
$ret = false;
$sql = "SELECT `config_value` FROM `#__hikashop_config` WHERE
config_namekey = 'main_currency';";
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$main_currency = $data[0]->config_value;
$data = array(
'discount_type' => "'coupon'",
'discount_start' => 'date_start',
'discount_end' => 'date_end',
'discount_quota' => 'uses_total',
'discount_quota_per_user' => 'uses_customer',
'discount_published' => 'status',
'discount_code' => 'code',
'discount_currency_id' =>
$this->db->Quote($main_currency),
'discount_flat_amount' => "case when type =
'F' then discount else 0 end",
'discount_percent_amount' => "case when type =
'P' then discount else 0 end",
'discount_quota' => '0'
);
$sql = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_discount`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'coupon`
WHERE coupon_id > ' . $this->options->last_openc_coupon;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Discount codes/coupons imported : ' . $total .
'</p>';
$data = array(
'discount_type' => "'coupon'",
'discount_code' => 'code',
'discount_currency_id' => $main_currency,
'discount_flat_amount' => 'amount',
'discount_percent_amount' => '0',
'discount_published' => 'status',
);
$sql = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_discount`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'voucher`
WHERE voucher_id > ' . $this->options->last_openc_voucher;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Vouchers imported : ' . $total . '</p>';
$ret = true;
return $ret;
}
function importCurrencies()
{
if( $this->db == null )
return false;
$this->db->setQuery('UPDATE
`'.$this->hikaDatabaseName.'`.`#__hikashop_currency` AS hkcur
'.
'INNER JOIN
`'.$this->opencDatabase.'`.`'.$this->opencPrefix.'currency`
occ ON CONVERT(occ.code USING utf8) = CONVERT( hkcur.currency_code USING
utf8) '.
'SET hkcur.currency_rate = occ.value'
);
$ret = $this->db->execute();
$cpt = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Currencies values imported : ' . $cpt .'</p>';
return true;
}
function finishImport()
{
$this->db->setQuery("SELECT max(category_id) as
'max' FROM `#__hikashop_category`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(id) as 'max' FROM
`#__users`;");
$data = $this->db->loadObjectList();
$this->options->max_joomla_user = (int)($data[0]->max);
$this->db->setQuery("SELECT max(product_id) as 'max'
FROM `#__hikashop_product`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_prod = (int)($data[0]->max);
$this->db->setQuery("SELECT max(openc_id) as 'max'
FROM `#__hikashop_openc_cat`;");
$data = $this->db->loadObjectList();
$this->options->last_openc_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(openc_id) as 'max'
FROM `#__hikashop_openc_prod`;");
$data = $this->db->loadObjectList();
$this->options->last_openc_prod = (int)($data[0]->max);
$this->db->setQuery("SELECT max(customer_id) as
'max' FROM
`".$this->opencDatabase."`.`".$this->opencPrefix."customer`;");
$data = $this->db->loadObjectList();
$this->options->last_openc_user = (int)($data[0]->max);
$this->db->setQuery("SELECT max(order_openc_id) as
'max' FROM `#__hikashop_order`;");
$data = $this->db->loadObjectList();
$this->options->last_openc_order = (int)($data[0]->max);
$this->db->setQuery("SELECT max(ocpi.product_image_id) as
'max' FROM
`".$this->opencDatabase."`.`".$this->opencPrefix."product_image`
ocpi INNER JOIN
`".$this->opencDatabase."`.`".$this->opencPrefix."product`
ocp ON ocpi.product_id = ocp.product_id");
$data = $this->db->loadObject();
$this->options->last_openc_pfile = (int)($data->max);
$this->db->setQuery("SELECT max(coupon_id) as 'max'
FROM
`".$this->opencDatabase."`.`".$this->opencPrefix."coupon`;");
$data = $this->db->loadObject();
$this->options->last_openc_coupon = (int)($data->max);
$this->db->setQuery("SELECT max(voucher_id) as 'max'
FROM
`".$this->opencDatabase."`.`".$this->opencPrefix."voucher`;");
$data = $this->db->loadObject();
$this->options->last_openc_voucher = (int)($data->max);
$this->db->setQuery("SELECT max(tax_rate_id) as
'max' FROM
`".$this->opencDatabase."`.`".$this->opencPrefix."tax_rate`;");
$data = $this->db->loadObject();
$this->options->last_openc_taxrate = (int)($data->max);
$this->db->setQuery("SELECT max(tax_class_id) as
'max' FROM
`".$this->opencDatabase."`.`".$this->opencPrefix."tax_class`;");
$data = $this->db->loadObject();
$this->options->last_openc_taxclass = (int)($data->max);
$this->db->setQuery("SELECT max(manufacturer_id) as
'max' FROM
`".$this->opencDatabase."`.`".$this->opencPrefix."manufacturer`;");
$data = $this->db->loadObjectList();
$this->options->last_openc_manufacturer = (int)($data[0]->max);
$this->options->state = 14;
$query = 'REPLACE INTO `#__hikashop_config`
(`config_namekey`,`config_value`,`config_default`) VALUES '.
"('openc_import_state',".$this->options->state.",".$this->options->state.")".
",('openc_import_max_hk_cat',".$this->options->max_hk_cat.",".$this->options->max_hk_cat.")".
",('openc_import_max_joomla_user',".$this->options->max_joomla_user.",".$this->options->max_joomla_user.")".
",('openc_import_max_hk_prod',".$this->options->max_hk_prod.",".$this->options->max_hk_prod.")".
",('openc_import_last_openc_cat',".$this->options->last_openc_cat.",".$this->options->last_openc_cat.")".
",('openc_import_last_openc_prod',".$this->options->last_openc_prod.",".$this->options->last_openc_prod.")".
",('openc_import_last_openc_user',".$this->options->last_openc_user.",".$this->options->last_openc_user.")".
",('openc_import_last_openc_order',".$this->options->last_openc_order.",".$this->options->last_openc_order.")".
",('openc_import_last_openc_pfile',".$this->options->last_openc_pfile.",".$this->options->last_openc_pfile.")".
",('openc_import_last_openc_coupon',".$this->options->last_openc_coupon.",".$this->options->last_openc_coupon.")".
",('openc_import_last_openc_voucher',".$this->options->last_openc_voucher.",".$this->options->last_openc_voucher.")".
",('openc_import_last_openc_taxrate',".$this->options->last_openc_taxrate.",".$this->options->last_openc_taxrate.")".
",('openc_import_last_openc_taxclass',".$this->options->last_openc_taxclass.",".$this->options->last_openc_taxclass.")".
",('openc_import_last_openc_manufacturer',".$this->options->last_openc_manufacturer.",".$this->options->last_openc_manufacturer.")".
';';
$this->db->setQuery($query);
$this->db->execute();
echo '<p'.$this->titlefont.'>Import finished
!</p>';
$class = hikashop_get('class.plugins');
}
}
import/reds.php000064400000174640151162557560007555 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
include_once HIKASHOP_HELPER . 'import.php';
@include(HIKASHOP_ROOT .
'administrator/components/com_redshop/helpers/redshop.cfg.php');
class hikashopImportredsHelper extends hikashopImportHelper
{
function __construct()
{
parent::__construct();
$this->importName = 'reds';
$this->copyImgDir = HIKASHOP_ROOT .
'components/com_redshop/assets/images/product';
$this->copyCatImgDir = HIKASHOP_ROOT .
'components/com_redshop/assets/images/category';
if (defined('PRODUCT_DOWNLOAD_ROOT'))
$this->copyDownloadDir = PRODUCT_DOWNLOAD_ROOT;
else
$this->copyDownloadDir = HIKASHOP_ROOT .
'components/com_redshop/assets/download/product';
$this->copyManufDir = HIKASHOP_ROOT .
'components/com_redshop/assets/images/manufacturer';
jimport('joomla.filesystem.file');
}
function importFromRedshop()
{
@ob_clean();
echo $this->getHtmlPage();
$this->token = hikashop_getFormToken();
flush();
if( isset($_GET['import']) && $_GET['import']
== '1' )
{
$time = microtime(true);
$processed = $this->doImport();
if( $processed )
{
$elasped = microtime(true) - $time;
if( !$this->refreshPage )
echo
'<p><br/><a'.$this->linkstyle.'href="'.hikashop_completeLink('import&task=import&importfrom=redshop&'.$this->token.'=1&import=1&time='.time()).'">'.JText::_('HIKA_NEXT').'</a></p>';
echo '<p style="font-size:0.85em;
color:#605F5D;">Elasped time: ' . round($elasped * 1000, 2) .
'ms</p>';
}
else
{
echo
'<a'.$this->linkstyle.'href="'.hikashop_completeLink('import&task=show').'">'.JText::_('HIKA_BACK').'</a>';
}
}
else
{
echo $this-> getStartPage();
}
if( $this->refreshPage )
{
echo "<script type=\"text/javascript\">\r\nr =
true;\r\n</script>";
}
echo '</body></html>';
exit;
}
function doImport()
{
if( $this->db == null )
return false;
$this->loadConfiguration();
$current = $this->options->current;
$ret = true;
$next = false;
switch($this->options->state)
{
case 0:
$next = $this->createTables();
break;
case 1:
$next = $this->importTaxes();
break;
case 2:
$next = $this->importManufacturers();
break;
case 3:
$next = $this->importCategories();
break;
case 4:
$next = $this->importProducts();
break;
case 5:
$next = $this->importProductPrices();
break;
case 6:
$next = $this->importProductCategory();
break;
case 7:
$next = $this->importUsers();
break;
case 8:
$next = $this->importDiscount();
break;
case 9:
$next = $this->importOrders();
break;
case 10:
$next = $this->importOrderItems();
break;
case 11:
$next = $this->importDownloads();
break;
case 12:
case 13:
$next = $this->finishImport();
$ret = false;
break;
case 14:
$next = false;
$ret = $this->proposeReImport();
break;
default:
$ret = false;
break;
}
if( $ret && $next )
{
$sql = "UPDATE `#__hikashop_config` SET
config_value=(config_value+1) WHERE config_namekey =
'reds_import_state'; ";
$this->db->setQuery($sql);
$this->db->execute();
$sql = "UPDATE `#__hikashop_config` SET config_value=0 WHERE
config_namekey = 'reds_import_current';";
$this->db->setQuery($sql);
$this->db->execute();
}
else if( $current != $this->options->current )
{
$sql = "UPDATE `#__hikashop_config` SET
config_value=".$this->options->current." WHERE
config_namekey = 'reds_import_current';";
$this->db->setQuery($sql);
$this->db->execute();
}
return $ret;
}
function loadConfiguration()
{
$this->options = new stdClass();
$data = array(
'uploadfolder',
'uploadsecurefolder',
'main_currency',
'reds_import_state',
'reds_import_current',
'reds_import_tax_id',
'reds_import_main_cat_id',
'reds_import_max_hk_cat',
'reds_import_max_hk_prod',
'reds_import_last_reds_cat',
'reds_import_last_reds_prod',
'reds_import_last_reds_user',
'reds_import_last_reds_order',
'reds_import_last_reds_pfile',
'reds_import_last_reds_coupon',
'reds_import_last_reds_discount',
'reds_import_last_reds_discount_prod',
'reds_import_last_reds_voucher',
'reds_import_last_reds_taxrate',
'reds_import_last_reds_taxclass',
'reds_import_last_reds_manufacturer'
);
$this->db->setQuery('SELECT config_namekey, config_value FROM
`#__hikashop_config` WHERE config_namekey IN
('."'".implode("','",$data)."'".');');
$result = $this->db->loadObjectList();
if (!empty($result))
{
foreach($result as $o)
{
if( substr($o->config_namekey, 0, 12) == 'reds_import_' )
$nk = substr($o->config_namekey, 12);
else
$nk = $o->config_namekey;
$this->options->$nk = $o->config_value;
}
}
$this->options->uploadfolder =
rtrim(JPath::clean(html_entity_decode($this->options->uploadfolder)),DS.'
').DS;
if(!preg_match('#^([A-Z]:)?/.*#',$this->options->uploadfolder)){
if(!$this->options->uploadfolder[0]=='/' ||
!is_dir($this->options->uploadfolder)){
$this->options->uploadfolder =
JPath::clean(HIKASHOP_ROOT.DS.trim($this->options->uploadfolder,DS.'
').DS);
}
}
$this->options->uploadsecurefolder =
rtrim(JPath::clean(html_entity_decode($this->options->uploadsecurefolder)),DS.'
').DS;
if(!preg_match('#^([A-Z]:)?/.*#',$this->options->uploadsecurefolder)){
if(!$this->options->uploadsecurefolder[0]=='/' ||
!is_dir($this->options->uploadsecurefolder)){
$this->options->uploadsecurefolder =
JPath::clean(HIKASHOP_ROOT.DS.trim($this->options->uploadsecurefolder,DS.'
').DS);
}
}
if( !isset($this->options->state) )
{
$this->options->state = 0;
$this->options->current = 0;
$this->options->tax_id = 0;
$this->options->last_reds_coupon = 0;
$this->options->last_reds_discount = 0;
$this->options->last_reds_discount_prod = 0;
$this->options->last_reds_voucher = 0;
$this->options->last_reds_pfile = 0;
$this->options->last_reds_taxrate = 0;
$this->options->last_reds_taxclass = 0;
$this->options->last_reds_manufacturer = 0;
$element = 'product';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$this->options->main_cat_id = $element;
$this->db->setQuery("SELECT max(category_id) as
'max' FROM `#__hikashop_category`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(product_id) as
'max' FROM `#__hikashop_product`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_prod = (int)($data[0]->max);
$query='SHOW TABLES LIKE
'.$this->db->Quote($this->db->getPrefix().substr(hikashop_table('reds_cat'),3));
$this->db->setQuery($query);
$table = $this->db->loadResult();
if(!empty($table))
{
$this->db->setQuery("SELECT max(reds_id) as 'max'
FROM `#__hikashop_reds_cat`;");
$data = $this->db->loadObjectList();
if( $data )
$this->options->last_reds_cat = (int)($data[0]->max);
else
$this->options->last_reds_cat = 0;
$this->db->setQuery("SELECT max(reds_id) as 'max'
FROM `#__hikashop_reds_prod`;");
$data = $this->db->loadObjectList();
if( $data )
$this->options->last_reds_prod = (int)($data[0]->max);
else
$this->options->last_reds_prod = 0;
$this->db->setQuery("SELECT max(order_reds_id) as
'max' FROM `#__hikashop_order`;");
$data = $this->db->loadObjectList();
if( $data )
$this->options->last_reds_order = (int)($data[0]->max);
else
$this->options->last_reds_order = 0;
}
else
{
$this->options->last_reds_cat = 0;
$this->options->last_reds_prod = 0;
$this->options->last_reds_order = 0;
}
$this->options->last_reds_user = 0;
$sql = 'INSERT IGNORE INTO `#__hikashop_config`
(`config_namekey`,`config_value`,`config_default`) VALUES '.
"('reds_import_state',".$this->options->state.",".$this->options->state.")".
",('reds_import_current',".$this->options->current.",".$this->options->current.")".
",('reds_import_tax_id',".$this->options->tax_id.",".$this->options->tax_id.")".
",('reds_import_main_cat_id',".$this->options->main_cat_id.",".$this->options->main_cat_id.")".
",('reds_import_max_hk_cat',".$this->options->max_hk_cat.",".$this->options->max_hk_cat.")".
",('reds_import_max_hk_prod',".$this->options->max_hk_prod.",".$this->options->max_hk_prod.")".
",('reds_import_last_reds_cat',".$this->options->last_reds_cat.",".$this->options->last_reds_cat.")".
",('reds_import_last_reds_prod',".$this->options->last_reds_prod.",".$this->options->last_reds_prod.")".
",('reds_import_last_reds_user',".$this->options->last_reds_user.",".$this->options->last_reds_user.")".
",('reds_import_last_reds_order',".$this->options->last_reds_order.",".$this->options->last_reds_order.")".
",('reds_import_last_reds_pfile',".$this->options->last_reds_pfile.",".$this->options->last_reds_pfile.")".
",('reds_import_last_reds_coupon',".$this->options->last_reds_coupon.",".$this->options->last_reds_coupon.")".
",('reds_import_last_reds_discount',".$this->options->last_reds_discount.",".$this->options->last_reds_discount.")".
",('reds_import_last_reds_discount_prod',".$this->options->last_reds_discount_prod.",".$this->options->last_reds_discount_prod.")".
",('reds_import_last_reds_voucher',".$this->options->last_reds_voucher.",".$this->options->last_reds_voucher.")".
",('reds_import_last_reds_taxrate',".$this->options->last_reds_taxrate.",".$this->options->last_reds_taxrate.")".
",('reds_import_last_reds_taxclass',".$this->options->last_reds_taxclass.",".$this->options->last_reds_taxclass.")".
",('reds_import_last_reds_manufacturer',".$this->options->last_reds_manufacturer.",".$this->options->last_reds_manufacturer.")".
';';
$this->db->setQuery($sql);
$this->db->execute();
}
}
function createTables()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
1 :</span>Â Initialization Tables</p>';
$create = true;
$query='SHOW TABLES LIKE
'.$this->db->Quote($this->db->getPrefix().substr(hikashop_table('reds_cat'),3));
$this->db->setQuery($query);
$table = $this->db->loadResult();
if (!empty($table))
$create = false;
if ($create)
{
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_reds_prod` (`reds_id` int(11) unsigned NOT NULL DEFAULT
'0', `hk_id` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`reds_id`)) ENGINE=MyISAM");
$this->db->execute();
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_reds_cat` (`reds_cat_id` INT(11) unsigned NOT NULL
AUTO_INCREMENT, `reds_id` int(11) unsigned NOT NULL DEFAULT '0',
`hk_id` int(11) unsigned NOT NULL DEFAULT '0', `category_type`
varchar(255) NULL, PRIMARY KEY (`reds_cat_id`)) ENGINE=MyISAM");
$this->db->execute();
$databaseHelper = hikashop_get('helper.database');
$databaseHelper->addColumns('address','`address_reds_order_info_id`
INT(11) NULL');
$databaseHelper->addColumns('order','`order_reds_id`
INT(11) NULL');
$databaseHelper->addColumns('order','INDEX (
`order_reds_id` )');
$databaseHelper->addColumns('taxation','`tax_reds_id`
INT(11) NULL');
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
All table created</p>';
}
else
{
echo '<p>Tables have been already created.</p>';
$this->refreshPage = true; //toComment ?
}
return true;
}
function importTaxes()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
2 :</span>Â Import Taxes<p>';
$ret = false;
$id = 'tax_rate_id';
$columns =
$this->db->getTableColumns('#__redshop_tax_rate');
if(!isset($columns['tax_rate_id']))
$id = 'id';
$data = array(
'tax_namekey' => "CONCAT('REDS_TAX_',
rstr.".$id.")",
'tax_rate' => 'rstr.tax_rate'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_tax`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__redshop_tax_rate` AS rstr '.
'WHERE rstr.'.$id.' > ' .
(int)$this->options->last_reds_taxrate;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported taxes: ' . $total . '</p>';
$element = 'tax';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$query = "SHOW COLUMNS FROM #__redshop_tax_group";
$this->db->setQuery($query);
$cols = $this->db->loadObjectList('Field');
$prefix = 'tax_group_';
if (is_array($cols) && isset($cols['name'])) {
$prefix = '';
}
$data = array(
'category_type' => "'tax'",
'category_name' => "CONCAT('Tax imported
(', rstg.".$prefix."name,')')",
'category_published' => 'rstg.published',
'category_parent_id' => $element,
'category_namekey' => "
CONCAT('REDS_TAX_CATEGORY_', rstg.".$prefix."id)"
);
$sql = 'INSERT IGNORE INTO `#__hikashop_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__redshop_tax_group` AS rstg ';
'WHERE rstg.'.$prefix.'id > ' .
(int)$this->options->last_reds_taxclass;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Taxes Categories: ' . $total . '</p>';
if( $total > 0 ) {
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'reds_import_max_hk_cat'; ");
$this->db->execute();
$this->importRebuildTree();
}
$data = array(
'zone_namekey' => "case when hkz.zone_namekey IS NULL
then '' else hkz.zone_namekey end",
'category_namekey' =>
"CONCAT('REDS_TAX_CATEGORY_',
rstg.".$prefix."id)",
'tax_namekey' => "CONCAT('REDS_TAX_',
rstr.".$id.")",
'taxation_published' => '1',
'taxation_type' => "''",
'tax_reds_id' => 'rstg.'.$prefix.'id'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_taxation`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__redshop_tax_rate` AS rstr '.
'INNER JOIN `#__redshop_tax_group` AS rstg ON rstr.tax_group_id =
rstg.'.$prefix.'id '.
'LEFT JOIN `#__redshop_country` AS rsc ON rstr.tax_country =
rsc.country_3_code ' . //Tocheck
"LEFT JOIN `#__hikashop_zone` hkz ON rsc.country_3_code =
hkz.zone_code_3 AND hkz.zone_type = 'country' ".
'WHERE rstr.'.$id.' > ' .
(int)$this->options->last_reds_taxrate;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Taxations: ' . $total . '</p>';
$ret = true;
return $ret;
}
function importManufacturers()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
3 :</span>Â Import Manufacturers</p>';
$ret = false;
$count = 100;
$rebuild = false;
$sql1 = 'SELECT * FROM `#__redshop_manufacturer` rsm '.
'LEFT JOIN `#__redshop_media` rsme ON rsme.section_id =
rsm.manufacturer_id AND rsme.media_section = \'manufacturer\'
'.
'LEFT JOIN `#__hikashop_reds_cat` hkmj ON rsm.manufacturer_id =
hkmj.reds_id AND category_type=\'manufacturer\' '.
'WHERE rsm.manufacturer_id > ' .
(int)$this->options->last_reds_manufacturer;
'ORDER BY rsm.manufacturer_id ASC;';
$this->db->setQuery($sql1);
$this->db->execute();
$datas = $this->db->loadObjectList();
$sql2 = 'INSERT INTO `#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_published`,'.
'`category_namekey`,`category_description`,`category_menu`,`category_keywords`)
VALUES ';
$sql3 = 'INSERT INTO `#__hikashop_reds_cat`
(`reds_id`,`hk_id`,`category_type`) VALUES ';
$sql4 = 'INSERT INTO `#__hikashop_file`
(`file_name`,`file_description`,`file_path`,`file_type`,`file_ref_id`)
VALUES ';
$doSql3 = false;
$doSql4 = false;
$i = $this->options->max_hk_cat + 1;
$ids = array( 0 => $this->options->main_cat_id);
$sep = '';
$sep2 = '';
$cpt=0;
if( empty($datas) )
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported manufacturers : 0</p>';
return true;
}
else
{
foreach($datas as $data)
{
if( !empty($data->reds_id) )
{
$ids[$data->manufacturer_id] = $data->hk_id;
}
else
{
$doSql3 = true;
$ids[$data->manufacturer_id] = $i;
$sql3 .=
$sep.'('.$data->manufacturer_id.','.$i.',\'manufacturer\')';
$i++;
$sep = ',';
}
$cpt++;
if( $cpt >= $count )
break;
}
$sql3 .= ';';
$cpt = 0;
$sep = '';
foreach($datas as $data)
{
if( !empty($data->reds_id) )
continue;
$id = $ids[$data->manufacturer_id];
$element = 'manufacturer';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$d = array(
$id,
$element,
"'manufacturer'",
$this->db->quote($data->manufacturer_name),
'1',
"CONCAT('REDS_MANUFAC_',
".$data->manufacturer_id .")",
"'manufacturer imported from Redshop'",
'0',
$this->db->quote($data->metakey)
);
$sql2 .= $sep.'('.implode(',',$d).')';
if( !empty($data->media_name))
{
$this->copyManufDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode($this->copyManufDir)),DS.'
').DS);
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying categories images... </p>';
$doSql4 = true;
$sql4 .=
$sep2."('".$data->media_name."','','".$data->media_name."','category',".$id.')';
$sep2 = ',';
$file_name =
str_replace('\\','/',$data->media_name);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyManufDir,$data->media_name,
str_replace('//','/',str_replace('\\','/',$this->options->uploadfolder.$file_name)));
}
$sep = ',';
$cpt++;
if( $cpt >= $count )
break;
}
}
if($cpt > 0)
{
$sql2 .= ';';
$sql4 .= ';';
$this->db->setQuery($sql2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Manufacturers : ' . $total . '</p>';
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Manufacturers : 0</p>';
}
if( isset($total) && $total > 0)
{
$rebuild = true;
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'reds_import_max_hk_cat'; ");
$this->db->execute();
}
if ($doSql3)
{
$this->db->setQuery($sql3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links : ' . $total . '</p>';
}
if($doSql4)
{
$this->db->setQuery($sql4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Manufacturers files : ' . $total . '</p>';
}
if( $rebuild )
$this->importRebuildTree();
if( $cpt < $count )
$ret = true;
return $ret;
}
function importCategories()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
4 :</span>Â Import General Categories</p>';
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$rebuild = false;
$ret = false;
$offset = 0;
$count = 100;
$cpt = 0;
$sep = '';
$sep2 = '';
$statuses = array(
'P' => 'created',
'C' => 'confirmed',
'X' => 'cancelled',
'R'=> 'refunded' ,
'S' => 'shipped'
);
$this->db->setQuery("SELECT category_keywords,
category_parent_id FROM `#__hikashop_category` WHERE category_type =
'status' AND category_name = 'confirmed'");
$data = $this->db->loadObject();
$status_category = $data->category_parent_id;
if( $data->category_keywords != 'C' ) {
foreach($statuses as $k => $v) {
$this->db->setQuery("UPDATE `#__hikashop_category` SET
category_keywords = '".$k."' WHERE category_type =
'status' AND category_name = '".$v."';
");
$this->db->execute();
}
}
$this->db->setQuery("SELECT order_status_code,
order_status_name FROM `#__redshop_order_status` WHERE order_status_name
NOT IN
('".implode("','",$statuses)."');");
$data = $this->db->loadObjectList();
if( count($data) > 0 )
{
$sql0 = 'INSERT IGNORE INTO `#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_description`,`category_published`,'.
'`category_namekey`,`category_access`,`category_menu`,`category_keywords`)
VALUES ';
$id = $this->options->max_hk_cat + 1;
$sep = '';
foreach($data as $c) {
$d = array(
$id++,
$status_category,
"'status'",
$this->db->quote( strtolower($c->order_status_name) ),
"'Order status imported from Redshop'",
'1',
$this->db->quote('status_reds_import_'.strtolower(str_replace('
','_',$c->order_status_name))),
"'all'",
'0',
$this->db->quote( $c->order_status_code )
);
$sql0 .= $sep.'('.implode(',',$d).')';
$sep = ',';
}
$this->db->setQuery($sql0);
$this->db->execute();
$total = $this->db->getAffectedRows();
if( $total > 0 ) {
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported order status categories : ' . $total .
'</p>';
$rebuild = true;
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'reds_import_max_hk_cat'; ");
$this->db->execute();
$sql0 = '';
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported order status categories : 0</p>';
}
}
$sql1 = 'SELECT * FROM `#__redshop_category` rsc '.
'LEFT JOIN `#__redshop_category_xref` rscx ON rsc.category_id =
rscx.category_child_id '.
'LEFT JOIN `#__hikashop_reds_cat` hkrs ON rsc.category_id =
hkrs.reds_id AND category_type=\'category\' '.
'WHERE rsc.category_id >
'.$this->options->last_reds_cat.' '.
'ORDER BY category_parent_id ASC, ordering ASC, category_id
ASC;';
$this->db->setQuery($sql1);
$this->db->execute();
$datas = $this->db->loadObjectList();
$sql2 = 'INSERT INTO `#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_description`,`category_published`,'.
'`category_ordering`,`category_namekey`,`category_created`,`category_access`,`category_menu`,`category_keywords`)
VALUES ';
$sql3 = 'INSERT INTO `#__hikashop_reds_cat`
(`reds_id`,`hk_id`,`category_type`) VALUES ';
$sql4 = 'INSERT INTO `#__hikashop_file`
(`file_name`,`file_description`,`file_path`,`file_type`,`file_ref_id`)
VALUES ';
$doSql3 = false;
$doSql4 = false;
$i = $this->options->max_hk_cat + 1;
$ids = array( 0 => $this->options->main_cat_id);
$sep = '';
if( empty($datas) )
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported category : 0</p>';
if( $rebuild )
$this->importRebuildTree();
return true;
}
else
{
foreach($datas as $data)
{
if( !empty($data->reds_id) )
{
$ids[$data->category_id] = $data->hk_id;
}
else
{
$doSql3 = true;
$ids[$data->category_id] = $i;
$sql3 .=
$sep.'('.$data->category_id.','.$i.',\'category\')';
$i++;
$sep = ',';
}
$cpt++;
if( $cpt >= $count )
break;
}
$sql3 .= ';';
$cpt = 0;
$sep = '';
foreach($datas as $data)
{
if( !empty($data->reds_id) )
continue;
$id = (int)$ids[$data->category_id];
if(!empty($ids[$data->category_parent_id]))
$pid = (int)$ids[$data->category_parent_id];
else
$pid = $ids[0];
$element = new stdClass();
$element->category_id = $id;
$element->category_parent_id = $pid;
$element->category_name = $data->category_name;
$nameKey = $categoryClass->getNameKey($element);
$d = array(
$id,
$pid,
"'product'",
$this->db->quote($data->category_name),
$this->db->quote($data->category_description),
$data->published,
$data->ordering,
$this->db->quote($nameKey),
"'".$data->category_pdate."'",
"'all'",
'0',
$this->db->quote($data->metakey)
);
$sql2 .= $sep.'('.implode(',',$d).')';
if( !empty($data->category_full_image))
{
$this->copyCatImgDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode($this->copyCatImgDir)),DS.'
').DS);
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying categories images... </p>';
$doSql4 = true;
$sql4 .=
$sep2."('','','".$data->category_full_image."','category',".$id.')';
$sep2 = ',';
$file_name =
str_replace('\\','/',$data->category_full_image);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyCatImgDir,$data->category_full_image,
str_replace('//','/',str_replace('\\','/',$this->options->uploadfolder.$file_name)));
}
$sep = ',';
$cpt++;
if( $cpt >= $count )
break;
}
}
if($cpt > 0)
{
$sql2 .= ';';
$sql4 .= ';';
$this->db->setQuery($sql2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Categories : ' . $total . '</p>';
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported category : 0</p>';
}
if( isset($total) && $total > 0)
{
$rebuild = true;
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'reds_import_max_hk_cat'; ");
$this->db->execute();
}
if ($doSql3)
{
$this->db->setQuery($sql3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links : ' . $total . '</p>';
}
if($doSql4)
{
$this->db->setQuery($sql4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Categories files : ' . $total . '</p>';
}
if( $rebuild )
$this->importRebuildTree();
if( $cpt < $count )
$ret = true;
return $ret;
}
function importProducts()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
5 :</span>Â Import Products</p>';
$ret = false;
$count = 100;
$offset = $this->options->current;
$max = 0;
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$this->db->setQuery('SELECT rsp.product_id, rsm.media_name
FROM `#__redshop_product` rsp '.
'LEFT JOIN `#__redshop_media` rsm ON rsp.product_id =
rsm.section_id '.
'LEFT JOIN `#__hikashop_reds_prod` hkprod ON rsp.product_id =
hkprod.reds_id '.
"WHERE rsp.product_id > ".$offset." AND
hkprod.hk_id IS NULL AND (rsm.media_name IS NOT NULL) AND rsm.media_name
<> '' AND rsm.media_section = 'product' ".
'ORDER BY product_id ASC LIMIT '.$count.';'
);
$datas = $this->db->loadObjectList();
$this->copyImgDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode($this->copyImgDir)),DS.'
').DS);
if (!empty($datas))
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying products images... </p>';
foreach($datas as $data) {
if( !empty($data->media_name) ) {
$file_name =
str_replace('\\','/',$data->media_name);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyImgDir,$data->media_name,
$this->options->uploadfolder.$file_name);
$max = $data->product_id;
}
}
}
if( $max > 0 )
{
echo '<p>Copying files...(last proccessed product id: '
. $max . ')</p>';
$this->options->current = $max;
$this->refreshPage = true;
return $ret;
}
$data = array(
'product_name' => 'rsp.product_name',
'product_description' => 'rsp.product_desc',
'product_meta_description' => 'rsp.metadesc',
'product_quantity' => 'case when
quantity_selectbox_value IS NULL or quantity_selectbox_value < 0 then 0
else quantity_selectbox_value end',
'product_code' => 'rsp.hika_sku',
'product_published' => 'rsp.published',
'product_hit' => 'rsp.visited',
'product_created' => time(),
'product_modified' => 'rsp.update_date',
'product_sale_start' =>
'rsp.product_availability_date',
'product_tax_id' => 'hkc.category_id',
'product_type' => "'main'",
'product_url' => 'rsp.sef_url',
'product_weight' => 'rsp.weight',
'product_weight_unit' =>
"LOWER('".DEFAULT_WEIGHT_UNIT."')",
'product_dimension_unit' =>
"LOWER('".DEFAULT_VOLUME_UNIT."')",
'product_min_per_order' =>
'rsp.min_order_product_quantity',
'product_max_per_order' =>
'rsp.max_order_product_quantity',
'product_sales' => '0',
'product_width' => 'rsp.product_width',
'product_length' => 'rsp.product_length',
'product_height' => 'rsp.product_height',
'product_parent_id' => '0'
//rsp.product_parent_id ?
);
$sql1 = 'INSERT IGNORE INTO `#__hikashop_product`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__redshop_product` AS rsp '.
'LEFT JOIN `#__hikashop_taxation` hkt ON hkt.tax_reds_id =
rsp.product_tax_id '.
'LEFT JOIN `#__hikashop_category` hkc ON hkc.category_namekey =
hkt.category_namekey '.
'LEFT JOIN `#__hikashop_reds_prod` AS hkp ON rsp.product_id =
hkp.reds_id '.
'WHERE hkp.hk_id IS NULL ORDER BY rsp.product_id ASC;';
$this->db->setQuery("SHOW COLUMNS FROM `#__redshop_product`
LIKE 'hika_sku';");
$data = $this->db->loadObjectList();
if (empty($data))
{
$this->db->setQuery('ALTER TABLE `#__redshop_product` ADD
COLUMN `hika_sku` VARCHAR(255) NOT NULL;');
$this->db->execute();
}
$this->db->setQuery("UPDATE `#__redshop_product` AS rsp SET
rsp.hika_sku = CONCAT(rsp.product_name,'_',rsp.product_id) WHERE
rsp.hika_sku='';");
$this->db->execute();
$this->db->setQuery('SELECT hika_sku FROM `#__redshop_product`
GROUP BY hika_sku HAVING COUNT(hika_sku)>1');
$data = $this->db->loadObjectList();
if (!empty($data))
{
foreach ($data as $d)
{
$this->db->setQuery("UPDATE `#__redshop_product` AS rsp SET
rsp.hika_sku = CONCAT(rsp.hika_sku,'_',rsp.product_id) WHERE
rsp.hika_sku = '".$d->hika_sku."';");
$this->db->execute();
}
}
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
SKU generated: '.count($data).'</p>';
$data = array(
'reds_id' => 'rsp.product_id',
'hk_id' => 'hkp.product_id'
);
$sql2 = 'INSERT IGNORE INTO `#__hikashop_reds_prod`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__redshop_product` AS rsp '.
'INNER JOIN `#__hikashop_product` AS hkp ON CONVERT(rsp.hika_sku
USING utf8) = CONVERT(hkp.product_code USING utf8) '.
'LEFT JOIN `#__hikashop_reds_prod` hkrsp ON hkrsp.reds_id =
rsp.product_id '.
'WHERE hkrsp.hk_id IS NULL;';
$sql3 = 'UPDATE `#__hikashop_product` AS hkp '.
'INNER JOIN `#__redshop_product` AS rsp ON CONVERT(rsp.hika_sku
USING utf8) = CONVERT(hkp.product_code USING utf8) '.
'INNER JOIN `#__hikashop_reds_prod` hkrsp ON hkrsp.reds_id =
rsp.product_parent_id '.
'SET hkp.product_parent_id = hkrsp.hk_id;';
$data = array(
'file_name' => "''",
'file_description' => "''",
'file_path' =>
"SUBSTRING_INDEX(rsm.media_name,'/',-1)",
'file_type' => "'product'",
'file_ref_id' => 'hkprod.hk_id'
);
$sql4 = 'INSERT IGNORE INTO `#__hikashop_file`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__redshop_product` rsp '.
'INNER JOIN `#__redshop_media` rsm ON rsp.product_id =
rsm.section_id '.
'INNER JOIN `#__hikashop_reds_prod` hkprod ON rsp.product_id =
hkprod.reds_id '.
'WHERE rsp.product_id >
'.$this->options->last_reds_prod. ' AND (rsm.media_name IS
NOT NULL) AND (rsm.media_name <>'." '') AND
rsm.media_section = 'product' ;";
$sql5 = 'UPDATE `#__hikashop_product` AS hkp '.
'INNER JOIN `#__hikashop_reds_prod` AS hkrsp ON hkp.product_id =
hkrsp.hk_id '.
'INNER JOIN `#__redshop_product` AS rsp ON hkrsp.reds_id =
rsp.product_id '.
"INNER JOIN `#__hikashop_category` AS hkc ON hkc.category_type =
'manufacturer' AND rsp.manufacturer_id = hkc.category_menu
".
'SET hkp.product_manufacturer_id = hkc.category_id '.
'WHERE rsp.manufacturer_id >
'.$this->options->last_reds_manufacturer.' OR
rsp.product_id >
'.$this->options->last_reds_prod.';';
$this->db->setQuery($sql1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products: ' . $total . '</p>';
$this->db->setQuery($sql2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links: ' . $total . '</p>';
$this->db->setQuery($sql3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating products for parent links: ' . $total .
'</p>';
$this->db->setQuery($sql4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products files: ' . $total . '</p>';
$this->db->setQuery($sql5);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating products manufacturers: ' . $total . '</p>';
$ret = true;
return $ret;
}
function importProductPrices()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
6 :</span>Â Import Product Prices</p>';
$ret = false;
$cpt = 0;
$data = array(
'price_product_id' => 'hkprod.hk_Id',
'price_value' => 'rsp.product_price',
'price_currency_id' => "case when hkcur.currency_id IS
NULL then '0' else hkcur.currency_id end",
'price_min_quantity' => "case when
rspp.price_quantity_start IS NULL then '0' else
rspp.price_quantity_start end",
'price_access' => "'all'"
);
$this->db->setQuery('INSERT IGNORE INTO #__hikashop_price
(`'.implode('`,`',array_keys($data)).'`) '
.'SELECT '.implode(',',$data).'FROM
#__redshop_product rsp '
.'INNER JOIN #__hikashop_reds_prod hkprod ON rsp.product_id =
hkprod.reds_id '
.'LEFT JOIN #__redshop_product_price rspp ON rsp.product_id =
rspp.product_id '
.'LEFT JOIN #__redshop_currency rsc ON rspp.product_currency =
rsc.currency_id '
.'LEFT JOIN #__hikashop_currency hkcur ON
CONVERT(rsc.currency_code USING utf8) = CONVERT( hkcur.currency_code USING
utf8) '
.'WHERE rsp.product_id > ' .
(int)$this->options->last_reds_prod
);
$ret = $this->db->execute();
$cpt = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Prices imported : ' . $cpt .'</p>';
return $ret;
}
function importProductCategory()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
7 :</span>Â Import Product Category</p>';
$ret = false;
$data = array(
'category_id' => 'hkrc.hk_id',
'product_id' => 'hkrp.hk_id',
'ordering' => 'rspcx.ordering',
);
$sql = 'INSERT IGNORE INTO `#__hikashop_product_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__redshop_product_category_xref` rspcx '.
'INNER JOIN `#__hikashop_reds_cat` hkrc ON rspcx.category_id =
hkrc.reds_id AND category_type=\'category\''.
'INNER JOIN `#__hikashop_reds_prod` hkrp ON rspcx.product_id =
hkrp.reds_id '.
'WHERE hkrp.reds_id > ' .
(int)$this->options->last_reds_prod . ' OR hkrc.reds_id >
' . (int)$this->options->last_reds_cat;
$this->db->setQuery($sql);
$ret = $this->db->execute();
$total = $this->db->getAffectedRows();
$this->importRebuildTree();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products categories: ' . $total . '</p>';
return $ret;
}
function importUsers()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
8 :</span>Â Import Users</p>';
$ret = false;
$sql0 = 'INSERT IGNORE INTO `#__hikashop_user`
(`user_cms_id`,`user_email`) '.
'SELECT rsui.user_id, rsui.user_email FROM `#__redshop_users_info`
AS rsui '.
'LEFT JOIN `#__hikashop_user` AS hkusr ON rsui.user_id =
hkusr.user_cms_id '.
'WHERE hkusr.user_cms_id IS NULL;';
$data = array(
'address_user_id' => 'hku.user_id',
'address_firstname' => 'rsui.firstname',
'address_lastname' => 'rsui.lastname',
'address_company' => 'rsui.company_name',
'address_street' => 'rsui.address',
'address_post_code' => 'rsui.zipcode',
'address_city' => 'rsui.city',
'address_telephone' => 'rsui.phone',
'address_state' => 'hkzsta.zone_namekey',
'address_country' => 'hkzcou.zone_namekey',
'address_vat' => "case when
rsui.tax_exempt='0' then rsui.vat_number else ''
end",
'address_published' => '4'
);
$id = 'country_id';
$columns =
$this->db->getTableColumns('#__redshop_country');
if(!isset($columns['country_id']))
$id = 'id';
$sql1 = 'INSERT IGNORE INTO `#__hikashop_address`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__redshop_users_info` AS rsui '.
'INNER JOIN `#__redshop_country` rsc ON rsui.country_code =
rsc.country_3_code '.
'INNER JOIN `#__redshop_state` rss ON rsc.'.$id.' =
rss.country_id AND rsui.state_code = rss.state_2_code '.
'INNER JOIN `#__hikashop_user` AS hku ON rsui.user_id =
hku.user_cms_id '.
'INNER JOIN `#__hikashop_zone` AS hkzcou ON rsc.country_3_code =
hkzcou.zone_code_3 AND hkzcou.zone_type=\'country\' '.
'INNER JOIN `#__hikashop_zone_link` AS hkzl ON hkzcou.zone_namekey
= hkzl.zone_parent_namekey '.
'INNER JOIN `#__hikashop_zone` AS hkzsta ON rss.state_2_code =
hkzsta.zone_code_3 AND hkzsta.zone_type=\'state\' AND
hkzsta.zone_namekey = hkzl.zone_child_namekey '.
'WHERE rsui.user_id >
'.$this->options->last_reds_user.' ORDER BY rsui.user_id
ASC;';
$sql2 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone` AS hkz ON (a.address_country =
hkz.zone_code_3 AND hkz.zone_type = "country") '.
'SET address_country = hkz.zone_namekey, address_published = 3
WHERE address_published = 4;';
$sql3 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone_link` AS zl ON (a.address_country =
zl.zone_parent_namekey) '.
'JOIN `#__hikashop_zone` AS hks ON (hks.zone_namekey =
zl.zone_child_namekey AND hks.zone_type = "state" AND
hks.zone_code_3 = a.address_state) '.
'SET address_state = hks.zone_namekey, address_published = 2 WHERE
address_published = 3;';
$sql4 = "UPDATE `#__hikashop_address` AS a SET a.address_country =
'' WHERE address_published > 3;";
$sql5 = "UPDATE `#__hikashop_address` AS a SET a.address_state =
'' WHERE address_published > 2;";
$sql6 = 'UPDATE `#__hikashop_address` AS a SET a.address_published =
1 WHERE address_published > 1;';
$this->db->setQuery($sql0);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Users: ' . $total . '</p>';
$this->db->setQuery($sql1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses: ' . $total . '</p>';
$this->db->setQuery($sql2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses countries: ' . $total . '</p>';
$this->db->setQuery($sql3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses states: ' . $total . '</p>';
$this->db->setQuery($sql4);
$this->db->execute();
$this->db->setQuery($sql5);
$this->db->execute();
$this->db->setQuery($sql6);
$this->db->execute();
$ret = true;
return $ret;
}
function importDiscount()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
9 :</span>Â Import Discount</p>';
$ret = false;
$sql = "SELECT `config_value` FROM `#__hikashop_config` WHERE
config_namekey = 'main_currency';";
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$main_currency = $data[0]->config_value;
$data = array(
'discount_type' => "'discount'",
'discount_published' => 'published',
'discount_code' => "CONCAT('REDS_DISCOUNT_',
discount_id)", //Hum
'discount_currency_id' => $main_currency,
'discount_flat_amount' => "case when discount_type =
'0' then discount_amount else 0 end",
'discount_percent_amount' => "case when discount_type
= '1' then discount_amount else 0 end",
'discount_start' => 'start_date',
'discount_end' => 'end_date',
'discount_quota' => '0'
);
$sql1 = 'INSERT IGNORE INTO #__hikashop_discount
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
#__redshop_discount WHERE discount_id > ' .
(int)$this->options->last_reds_discount;
$data['discount_code'] =
"CONCAT('REDS_DISCOUNTPROD_', discount_product_id)";
$sql2 = 'INSERT IGNORE INTO #__hikashop_discount
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
#__redshop_discount_product WHERE discount_product_id > ' .
(int)$this->options->last_reds_discount_prod;
$data = array(
'discount_type' => "'coupon'",
'discount_published' => 'published',
'discount_code' => 'coupon_code',
'discount_currency_id' => $main_currency,
'discount_flat_amount' => "case when percent_or_total
= '0' then coupon_value else 0 end",
'discount_percent_amount' => "case when
percent_or_total = '1' then coupon_value else 0 end",
'discount_start' => 'start_date',
'discount_end' => 'end_date',
'discount_quota' => 'coupon_left'
);
$sql3 = 'INSERT IGNORE INTO #__hikashop_discount
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
#__redshop_coupons WHERE coupon_id > ' .
(int)$this->options->last_reds_coupon;
$data = array(
'discount_type' => "'coupon'",
'discount_published' => 'rsv.published',
'discount_code' => 'rsv.voucher_code',
'discount_currency_id' => $main_currency,
'discount_flat_amount' => "case when voucher_type =
'Percentage' then 0 else rsv.amount end",
'discount_percent_amount' => "case when voucher_type =
'Percentage' then rsv.amount else 0 end",
'discount_start' => 'rsv.start_date',
'discount_end' => 'rsv.end_date',
'discount_quota' => 'rsv.voucher_left',
'discount_product_id' => 'rspv.product_id'
);
$sql4 = 'INSERT IGNORE INTO #__hikashop_discount
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
#__redshop_product_voucher rsv '.
'LEFT JOIN #__redshop_product_voucher_xref AS rspv ON
rsv.voucher_id = rspv.voucher_id '.
'WHERE rsv.voucher_id > ' .
(int)$this->options->last_reds_voucher;
$this->db->setQuery($sql1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Discount codes imported : ' . $total . '</p>';
$this->db->setQuery($sql2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Discount codes product imported : ' . $total .
'</p>';
$this->db->setQuery($sql3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Coupons imported : ' . $total . '</p>';
$this->db->setQuery($sql4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Vouchers imported : ' . $total . '</p>';
$ret = true;
return $ret;
}
function importOrders()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
10 :</span>Â Import Orders</p>';
$ret = false;
$offset = $this->options->current;
$count = 100;
$total = 0;
$vat_cols = "''";
$data = array(
'order_number' => 'rso.order_number',
'order_reds_id' => 'rso.order_id',
'order_user_id' => 'hkusr.user_id',
'order_status' => 'hkc.category_name',
'order_discount_price' =>
'rso.coupon_discount',
'order_created' => 'rso.cdate',
'order_modified' => 'rso.mdate',
'order_ip' => 'rso.ip_address',
'order_currency_id' => 'hkcur.currency_id',
'order_shipping_price' => 'rso.order_shipping',
'order_shipping_method' => "'Redshop
import'",
'order_shipping_id' => '1',
'order_payment_id' => 0,
'order_payment_method' => "'Redshop
import'",
'order_full_price' => 'rso.order_total',
'order_partner_id' => 0,
'order_partner_price' => 0,
'order_partner_paid' => 0,
'order_type' => "'sale'",
'order_partner_currency_id' => 0,
'order_shipping_tax' =>
'rso.order_shipping_tax',
'order_discount_tax' => 0
);
$sql1 = 'INSERT IGNORE INTO `#__hikashop_order`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__redshop_orders` AS rso '.
'INNER JOIN `#__redshop_order_item` AS rsoi ON rso.order_id =
rsoi.order_id '.
'INNER JOIN `#__redshop_order_status` AS rsos ON rso.order_status =
rsos.order_status_code '.
'JOIN `#__hikashop_category` AS hkc ON rsos.order_status_name =
hkc.category_name AND hkc.category_type = \'status\' '.
'JOIN `#__hikashop_currency` AS hkcur ON
CONVERT(rsoi.order_item_currency USING utf8) = CONVERT(hkcur.currency_code
USING utf8) OR CONVERT(rsoi.order_item_currency USING utf8) =
CONVERT(hkcur.currency_symbol USING utf8)'.
'JOIN `#__hikashop_user` AS hkusr ON rso.user_id =
hkusr.user_cms_id '.
'WHERE rso.order_id > ' .
(int)$this->options->last_reds_order . ' '.
'GROUP BY rso.order_id '.
'ORDER BY rso.order_id ASC;';
$sql1_1 = 'UPDATE `#__hikashop_order` AS hko '.
'INNER JOIN `#__redshop_coupons` AS rsc ON hko.order_reds_id =
rsc.order_id '.
'INNER JOIN `#__hikashop_discount` AS hkd ON hkd.discount_code =
rsc.coupon_code '.
'SET hko.order_discount_code = hkd.discount_code AND
hko.order_discount_price = hkd.discount_flat_amount';
$data = array(
'address_user_id' => 'rsui.user_id',
'address_firstname' => 'rsui.firstname',
'address_lastname' => 'rsui.lastname',
'address_company' => 'rsui.company_name',
'address_street' => 'rsui.address',
'address_post_code' => 'rsui.zipcode',
'address_city' => 'rsui.city',
'address_telephone' => 'rsui.phone',
'address_state' => 'hkzsta.zone_namekey',
'address_country' => 'hkzcou.zone_namekey',
'address_published' => "case when rsui.address_type =
'BT' then 7 else 8 end",
'address_vat' => "case when
rsui.tax_exempt='0' then rsui.vat_number else ''
end",
'address_reds_order_info_id' => 'rsui.order_id'
);
$id = 'country_id';
$columns =
$this->db->getTableColumns('#__redshop_country');
if(!isset($columns['country_id']))
$id = 'id';
$sql2_1 = 'INSERT IGNORE INTO `#__hikashop_address`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__redshop_order_users_info` AS rsui '.
'INNER JOIN `#__redshop_country` rsc ON rsui.country_code =
rsc.country_3_code '.
'INNER JOIN `#__redshop_state` rss ON rsc.'.$id.' =
rss.country_id AND rsui.state_code = rss.state_2_code '.
'INNER JOIN `#__hikashop_user` AS hku ON rsui.user_id =
hku.user_cms_id '.
'INNER JOIN `#__hikashop_zone` AS hkzcou ON rsc.country_3_code =
hkzcou.zone_code_3 AND hkzcou.zone_type=\'country\' '.
'INNER JOIN `#__hikashop_zone_link` AS hkzl ON hkzcou.zone_namekey
= hkzl.zone_parent_namekey '.
'INNER JOIN `#__hikashop_zone` AS hkzsta ON rss.state_2_code =
hkzsta.zone_code_3 AND hkzsta.zone_type=\'state\' AND
hkzsta.zone_namekey = hkzl.zone_child_namekey '.
'WHERE rsui.order_id >
'.$this->options->last_reds_order.' ORDER BY
rsui.order_info_id ASC';
$sql2_2 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone` AS hkz ON (a.address_country =
hkz.zone_code_3 AND hkz.zone_type = "country") '.
'SET address_country = hkz.zone_namekey, address_published = 6
WHERE address_published >= 7;';
$sql2_3 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone_link` AS zl ON (a.address_country =
zl.zone_parent_namekey) '.
'JOIN `#__hikashop_zone` AS hks ON (hks.zone_namekey =
zl.zone_child_namekey AND hks.zone_type = "state" AND
hks.zone_code_3 = a.address_state) '.
'SET address_state = hks.zone_namekey, address_published = 5 WHERE
address_published = 6;';
$sql2_4 = 'UPDATE `#__hikashop_address` AS a '.
'SET address_published = 0 WHERE address_published > 4;';
$sql3 = 'UPDATE `#__hikashop_order` AS o '.
'INNER JOIN `#__hikashop_address` AS a ON
a.address_reds_order_info_id = o.order_reds_id '.
'SET o.order_billing_address_id = a.address_id,
o.order_shipping_address_id = a.address_id '.
"WHERE o.order_billing_address_id = 0 AND address_published >= 7
;";
$sql4 = 'UPDATE `#__hikashop_order` AS o '.
'INNER JOIN `#__hikashop_address` AS a ON
a.address_reds_order_info_id = o.order_reds_id '.
'SET o.order_shipping_address_id = a.address_id '.
"WHERE (o.order_shipping_address_id = 0 OR
o.order_shipping_address_id = o.order_billing_address_id) AND
address_published >= 8 ;";
$sql5 = 'UPDATE `#__hikashop_order` AS hko '.
'JOIN `#__redshop_orders` AS rso ON hko.order_reds_id =
rso.order_id '.
"SET hko.order_payment_method = CONCAT('Redshop import:
', rso.payment_oprand) ".
'WHERE hko.order_reds_id > ' .
(int)$this->options->last_reds_order;
$this->db->setQuery($sql1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported orders: ' . $total . '</p>';
$this->db->setQuery("SHOW COLUMNS FROM
#__redshop_coupons");
$cols = $this->db->loadObjectList('Field');
if (is_array($cols) && array_key_exists('order_id',
$cols)){
$this->db->setQuery($sql1_1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating discount orders: ' . $total . '</p>';
}
$this->db->setQuery($sql2_1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported orders addresses: ' . $total . '</p>';
$this->db->setQuery($sql3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating billing addresses: ' . $total . '</p>';
$this->db->setQuery($sql4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating shipping addresses: ' . $total . '</p>';
$this->db->setQuery($sql5);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating order payments: ' . $total . '</p>';
$this->db->setQuery($sql2_2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating orders: ' . $total;
$this->db->setQuery($sql2_3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '/' . $total;
$this->db->setQuery($sql2_4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '/' . $total . '</p>';
$ret = true;
return $ret;
}
function importOrderItems()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
11 :</span>Â Import Order Items</p>';
$ret = false;
$offset = $this->options->current;
$count = 100;
$data = array(
'order_id' => 'hko.order_id',
'product_id' => 'hkp.hk_id',
'order_product_quantity' =>
'rsoi.product_quantity',
'order_product_name' => 'rsoi.order_item_name',
'order_product_code' => 'rsp.hika_sku',
'order_product_price' =>
'rsoi.product_item_price',
'order_product_tax' => "''",
'order_product_options' => "''"
);
$sql = 'INSERT IGNORE INTO `#__hikashop_order_product`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__redshop_order_item` AS rsoi '.
'INNER JOIN `#__redshop_product` rsp ON
rsoi.product_id=rsp.product_id '.
'INNER JOIN `#__hikashop_order` AS hko ON rsoi.order_id =
hko.order_reds_id '.
'INNER JOIN `#__hikashop_reds_prod` AS hkp ON rsoi.product_id =
hkp.reds_id '.
'WHERE rsoi.order_id > ' .
(int)$this->options->last_reds_order . ';';
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Orders Items : '. $total .'</p>';
$ret = true;
return $ret;
}
function importDownloads()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
12 :</span>Â Import Downloads</p>';
$ret = false;
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$count = 100;
$offset = $this->options->current;
if( $offset == 0 )
$offset = $this->options->last_reds_pfile;
$sql = 'SELECT download_id, file_name FROM
`#__redshop_product_download` WHERE download_id > '.$offset.'
ORDER BY download_id ASC LIMIT '.$count.';';
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$max = 0;
if (!empty($data))
{
$this->copyDownloadDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode($this->copyDownloadDir)),DS.'
').DS);
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying downloads files... </p>';
foreach($data as $c)
{
$file_name =
end(explode('/',str_replace('\\','/',$c->filename)));
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$dstFolder = $this->options->uploadfolder; //secure ?
$this->copyFile($this->copyDownloadDir, $c->filename,
$dstFolder.$file_name);
$max = $c->download_id;
}
if( $max > 0 )
{
echo '<p>Copying files...<br/>(Last processed file id:
' . $max . '</p>';
$this->options->current = $max;
$this->refreshPage = true;
return $ret;
}
}
$data = array(
'file_name' => 'rspd.file_name',
'file_description' => "'File imported from
Redshop'",
'file_path' =>
"SUBSTRING_INDEX(SUBSTRING_INDEX(rspd.file_name, '/', -1),
'\\\\', -1)",
'file_type' => "'file'",
'file_ref_id' => 'hkrsp.hk_id'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_file`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__redshop_product_download` AS rspd '.
'LEFT JOIN `#__hikashop_reds_prod` AS hkrsp ON rspd.product_id =
hkrsp.reds_id '.
'WHERE rspd.download_id >
'.$this->options->last_reds_pfile;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Downloable files imported : ' . $total . '</p>';
$data = array(
'file_id' => 'hkf.file_id',
'order_id' => 'hko.order_id',
'download_number' => 'rspd.download_max'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_download`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__redshop_product_download` AS rspd '.
'INNER JOIN `#__hikashop_order` AS hko ON hko.order_reds_id =
rspd.order_id '.
'INNER JOIN `#__hikashop_reds_prod` AS hkp ON hkp.reds_id =
rspd.product_id '.
'INNER JOIN `#__hikashop_file` AS hkf ON ( CONVERT(hkf.file_name
USING utf8) = CONVERT(rspd.file_name USING utf8) )'.
"WHERE hkf.file_type = 'file' AND (hkp.hk_id =
hkf.file_ref_id) AND (rspd.product_id >
".$this->options->last_reds_prod.' OR rspd.order_id >
' . (int)$this->options->last_reds_order . ');';
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Downloable order files imported : ' . $total .
'</p>';
$ret = true;
return $ret;
}
function finishImport()
{
$this->db->setQuery("SELECT max(category_id) as
'max' FROM `#__hikashop_category`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(product_id) as 'max'
FROM `#__hikashop_product`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_prod = (int)($data[0]->max);
$this->db->setQuery("SELECT max(reds_id) as 'max'
FROM `#__hikashop_reds_cat`;");
$data = $this->db->loadObjectList();
$this->options->last_reds_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(reds_id) as 'max'
FROM `#__hikashop_reds_prod`;");
$data = $this->db->loadObjectList();
$this->options->last_reds_prod = (int)($data[0]->max);
$this->db->setQuery("SELECT max(user_id) as 'max'
FROM `#__redshop_users_info`;");
$data = $this->db->loadObjectList();
$this->options->last_reds_user = (int)($data[0]->max);
$this->db->setQuery("SELECT max(order_reds_id) as
'max' FROM `#__hikashop_order`;");
$data = $this->db->loadObjectList();
$this->options->last_reds_order = (int)($data[0]->max);
$this->db->setQuery("SELECT max(rsm.media_id) as
'max' FROM `#__redshop_media` rsm INNER JOIN `#__redshop_product`
rsp ON rsp.product_id = rsm.section_id AND media_section =
'product';");
$data = $this->db->loadObject();
$this->options->last_reds_pfile = (int)($data->max);
$this->db->setQuery("SELECT max(coupon_id) as 'max'
FROM `#__redshop_coupons`;");
$data = $this->db->loadObject();
$this->options->last_reds_coupon = (int)($data->max);
$this->db->setQuery("SELECT max(discount_id) as
'max' FROM `#__redshop_discount`;");
$data = $this->db->loadObject();
$this->options->last_reds_discount = (int)($data->max);
$this->db->setQuery("SELECT max(discount_product_id) as
'max' FROM `#__redshop_discount_product`;");
$data = $this->db->loadObject();
$this->options->last_reds_discount_prod = (int)($data->max);
$this->db->setQuery("SELECT max(voucher_id) as 'max'
FROM `#__redshop_product_voucher`;");
$data = $this->db->loadObject();
$this->options->last_reds_voucher = (int)($data->max);
$this->db->setQuery("SELECT max(tax_rate_id) as
'max' FROM `#__redshop_tax_rate`;");
$data = $this->db->loadObject();
$this->options->last_reds_taxrate = (int)($data->max);
$this->db->setQuery("SELECT max(tax_group_id) as
'max' FROM `#__redshop_tax_group`;");
$data = $this->db->loadObject();
$this->options->last_reds_taxclass = (int)($data->max);
$this->db->setQuery("SELECT max(manufacturer_id) as
'max' FROM `#__redshop_manufacturer`;");
$data = $this->db->loadObjectList();
$this->options->last_reds_manufacturer = (int)($data[0]->max);
$this->options->state = 14;
$query = 'REPLACE INTO `#__hikashop_config`
(`config_namekey`,`config_value`,`config_default`) VALUES '.
"('reds_import_state',".$this->options->state.",".$this->options->state.")".
",('reds_import_max_hk_cat',".$this->options->max_hk_cat.",".$this->options->max_hk_cat.")".
",('reds_import_max_hk_prod',".$this->options->max_hk_prod.",".$this->options->max_hk_prod.")".
",('reds_import_last_reds_cat',".$this->options->last_reds_cat.",".$this->options->last_reds_cat.")".
",('reds_import_last_reds_prod',".$this->options->last_reds_prod.",".$this->options->last_reds_prod.")".
",('reds_import_last_reds_user',".$this->options->last_reds_user.",".$this->options->last_reds_user.")".
",('reds_import_last_reds_order',".$this->options->last_reds_order.",".$this->options->last_reds_order.")".
",('reds_import_last_reds_pfile',".$this->options->last_reds_pfile.",".$this->options->last_reds_pfile.")".
",('reds_import_last_reds_coupon',".$this->options->last_reds_coupon.",".$this->options->last_reds_coupon.")".
",('reds_import_last_reds_discount',".$this->options->last_reds_discount.",".$this->options->last_reds_discount.")".
",('reds_import_last_reds_discount_prod',".$this->options->last_reds_discount_prod.",".$this->options->last_reds_discount_prod.")".
",('reds_import_last_reds_voucher',".$this->options->last_reds_voucher.",".$this->options->last_reds_voucher.")".
",('reds_import_last_reds_taxrate',".$this->options->last_reds_taxrate.",".$this->options->last_reds_taxrate.")".
",('reds_import_last_reds_taxclass',".$this->options->last_reds_taxclass.",".$this->options->last_reds_taxclass.")".
",('reds_import_last_reds_manufacturer',".$this->options->last_reds_manufacturer.",".$this->options->last_reds_manufacturer.")".
';';
$this->db->setQuery($query);
$this->db->execute();
echo '<p'.$this->titlefont.'>Import finished
!</p>';
$class = hikashop_get('class.plugins');
$infos =
$class->getByName('system','reds_redirect');
if($infos)
{
$pkey = reset($class->pkeys);
if(!empty($infos->$pkey))
{
$url =
JRoute::_('index.php?option=com_plugins&view=plugin&layout=edit&extension_id='.$infos->$pkey);
echo '<p>You can publish the
<a'.$this->linkstyle.'
href="'.$url.'">Redshop Fallback Redirect
Plugin</a> so that your old Redshop links are automatically
redirected to HikaShop pages and thus not loose the ranking of your content
on search engines.</p>';
}
}
}
}
import/vm1.php000064400000170671151162557560007323 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
include_once HIKASHOP_HELPER . 'import.php';
@include_once(HIKASHOP_ROOT .
'administrator/components/com_virtuemart/virtuemart.cfg.php');
ini_set('max_execution_time', 300);
class hikashopImportvm1Helper extends hikashopImportHelper
{
var $vm_version = 1;
var $vm_current_lng = '';
var $sessionParams = '';
var $vmprefix;
function __construct(&$parent)
{
parent::__construct();
$this->importName = 'vm';
$this->sessionParams = HIKASHOP_COMPONENT.'vm';
jimport('joomla.filesystem.file');
}
function importFromVM()
{
@ob_clean();
echo $this->getHtmlPage();
$this->token = hikashop_getFormToken();
$app = JFactory::getApplication();
flush();
if( isset($_GET['import']) && $_GET['import']
== '1' )
{
$time = microtime(true);
$this->vmprefix =
$app->getUserState($this->sessionParams.'vmPrefix');
$processed = $this->doImport();
if($processed)
{
$elasped = microtime(true) - $time;
if( !$this->refreshPage )
echo '<p><a'.$this->linkstyle.'
href="'.hikashop_completeLink('import&task=import&importfrom=vm&'.$this->token.'=1&import=1&time='.time()).'">'.JText::_('HIKA_NEXT').'</a></p>';
echo '<p style="font-size:0.85em;
color:#605F5D;">Elasped time: ' . round($elasped * 1000, 2) .
'ms</p>';
}
else
{
echo '<a'.$this->linkstyle.'
href="'.hikashop_completeLink('import&task=show').'">'.JText::_('HIKA_BACK').'</a>';
}
}
else
{
echo $this->getStartPage();
}
if( $this->refreshPage == true )
{
echo "<script type=\"text/javascript\">\r\nr =
true; \r\n</script>";
}
echo '</body></html>';
exit;
}
function getStartPage()
{
$app = JFactory::getApplication();
$returnString = '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
0</span></p>';
$this->vmprefix =
$app->getUserStateFromRequest($this->sessionParams.'vmPrefix',
'vmPrefix', '', 'string' );
if (empty($this->vmprefix))
$this->vmprefix = $this->db->getPrefix();
elseif(substr($this->vmprefix, -1, 1) != '_')
$this->vmprefix .= '_';
if(strpos($this->vmprefix, '__') !== false &&
$this->vmprefix != '#__')
$this->vmprefix = str_replace('__', '_',
$this->vmprefix);
$app->setUserState($this->sessionParams.'vmPrefix',$this->vmprefix);
$this->db->setQuery("SHOW TABLES LIKE
'".$this->vmprefix."vm_product'");
$table = $this->db->loadObjectList();
if (!$table)
{
$returnString .= '<p style="color:red;
font-size:0.9em;">There is no table with the prefix
\''.$this->vmprefix.'\' in your Joomla
database.</p>';
}
else
{
$returnString = 'First, make a backup of your
database.<br/>'.
'When ready, click on <a '.$this->linkstyle.'
href="'.hikashop_completeLink('import&task=import&importfrom=vm&'.$this->token.'=1&import=1').'">'.JText::_('HIKA_NEXT').'</a>,
otherwise ';
}
$returnString .= '<a'.$this->linkstyle.'
href="'.hikashop_completeLink('import&task=show').'">'.JText::_('HIKA_BACK').'</a>';
return $returnString;
}
function doImport() {
if( $this->db == null )
return false;
$this->loadConfiguration();
$current = $this->options->current;
$ret = true;
$next = false;
switch( $this->options->state ) {
case 0:
$next = $this->createTables();
break;
case 1:
$next = $this->importTaxes();
break;
case 2:
$next = $this->importManufacturers();
break;
case 3:
$next = $this->importCategories();
break;
case 4:
$next = $this->importProducts();
break;
case 5:
$next = $this->importProductPrices();
break;
case 6:
$next = $this->importProductCategory();
break;
case 7:
$next = $this->importUsers();
break;
case 8:
$next = $this->importDiscount();
break;
case 9:
$next = $this->importOrders();
break;
case 10:
$next = $this->importOrderItems();
break;
case 11:
$next = $this->importDownloads();
break;
case 12:
$next = $this->importReviews();
break;
case 13:
$next = $this->finishImport();
$ret = false;
break;
case 14:
$next = false;
$ret = $this->proposeReImport();
break;
default:
$ret = false;
break;
}
if( $ret && $next ) {
$sql = "UPDATE `#__hikashop_config` SET
config_value=(config_value+1) WHERE config_namekey =
'vm_import_state'; ";
$this->db->setQuery($sql);
$this->db->execute();
$sql = "UPDATE `#__hikashop_config` SET config_value=0 WHERE
config_namekey = 'vm_import_current';";
$this->db->setQuery($sql);
$this->db->execute();
} else if( $current != $this->options->current ) {
$sql = "UPDATE `#__hikashop_config` SET
config_value=".$this->options->current." WHERE
config_namekey = 'vm_import_current';";
$this->db->setQuery($sql);
$this->db->execute();
}
return $ret;
}
function loadConfiguration() {
if( $this->db == null )
return false;
$this->loadVmConfigs();
$data = array(
'uploadfolder',
'uploadsecurefolder',
'main_currency',
'vm_import_state',
'vm_import_current',
'vm_import_tax_id',
'vm_import_main_cat_id',
'vm_import_max_hk_cat',
'vm_import_max_hk_prod',
'vm_import_last_vm_cat',
'vm_import_last_vm_prod',
'vm_import_last_vm_user',
'vm_import_last_vm_order',
'vm_import_last_vm_pfile',
'vm_import_last_vm_coupon',
'vm_import_last_vm_taxrate',
'vm_import_last_vm_manufacturer',
'vm_import_last_vm_review'
);
$this->db->setQuery('SELECT config_namekey, config_value FROM
`#__hikashop_config` WHERE config_namekey IN
('."'".implode("','",$data)."'".');');
$options = $this->db->loadObjectList();
$this->options = new stdClass();
if (!empty($options))
{
foreach($options as $o) {
if( substr($o->config_namekey, 0, 10) == 'vm_import_' ) {
$nk = substr($o->config_namekey, 10);
} else {
$nk = $o->config_namekey;
}
$this->options->$nk = $o->config_value;
}
}
$this->options->uploadfolder =
rtrim(JPath::clean(html_entity_decode($this->options->uploadfolder)),DS.'
').DS;
if(!preg_match('#^([A-Z]:)?/.*#',$this->options->uploadfolder)){
if(!$this->options->uploadfolder[0]=='/' ||
!is_dir($this->options->uploadfolder)){
$this->options->uploadfolder =
JPath::clean(HIKASHOP_ROOT.DS.trim($this->options->uploadfolder,DS.'
').DS);
}
}
$this->options->uploadsecurefolder =
rtrim(JPath::clean(html_entity_decode($this->options->uploadsecurefolder)),DS.'
').DS;
if(!preg_match('#^([A-Z]:)?/.*#',$this->options->uploadsecurefolder)){
if(!$this->options->uploadsecurefolder[0]=='/' ||
!is_dir($this->options->uploadsecurefolder)){
$this->options->uploadsecurefolder =
JPath::clean(HIKASHOP_ROOT.DS.trim($this->options->uploadsecurefolder,DS.'
').DS);
}
}
if( !isset($this->options->state) ) {
$this->options->state = 0;
$this->options->current = 0;
$this->options->tax_id = 0;
$this->options->last_vm_coupon = 0;
$this->options->last_vm_pfile = 0;
$this->options->last_vm_taxrate = 0;
$this->options->last_vm_manufacturer = 0;
$this->options->last_vm_review = 0;
$element = 'product';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$this->options->main_cat_id = $element;
$this->db->setQuery("SELECT max(category_id) as
'max' FROM `#__hikashop_category`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(product_id) as
'max' FROM `#__hikashop_product`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_prod = (int)($data[0]->max);
$query='SHOW TABLES LIKE
'.$this->db->Quote($this->db->getPrefix().substr(hikashop_table('vm_cat'),3));
$this->db->setQuery($query);
$table = $this->db->loadResult();
if(!empty($table)){
$this->db->setQuery("SELECT max(vm_id) as 'max'
FROM `#__hikashop_vm_cat`;");
$data = $this->db->loadObjectList();
if( $data ) {
$this->options->last_vm_cat = (int)($data[0]->max);
} else {
$this->options->last_vm_cat = 0;
}
$this->db->setQuery("SELECT max(vm_id) as 'max'
FROM `#__hikashop_vm_prod`;");
$data = $this->db->loadObjectList();
if( $data ) {
$this->options->last_vm_prod = (int)($data[0]->max);
} else {
$this->options->last_vm_prod = 0;
}
$this->db->setQuery("SELECT max(order_vm_id) as
'max' FROM `#__hikashop_order`;");
$data = $this->db->loadObjectList();
$this->options->last_vm_order = (int)($data[0]->max);
}else{
$this->options->last_vm_cat = 0;
$this->options->last_vm_prod = 0;
$this->options->last_vm_order = 0;
}
$this->options->last_vm_user = 0;
$sql = 'INSERT IGNORE INTO `#__hikashop_config`
(`config_namekey`,`config_value`,`config_default`) VALUES '.
"('vm_import_state',".$this->options->state.",".$this->options->state.")".
",('vm_import_current',".$this->options->current.",".$this->options->current.")".
",('vm_import_tax_id',".$this->options->tax_id.",".$this->options->tax_id.")".
",('vm_import_main_cat_id',".$this->options->main_cat_id.",".$this->options->main_cat_id.")".
",('vm_import_max_hk_cat',".$this->options->max_hk_cat.",".$this->options->max_hk_cat.")".
",('vm_import_max_hk_prod',".$this->options->max_hk_prod.",".$this->options->max_hk_prod.")".
",('vm_import_last_vm_cat',".$this->options->last_vm_cat.",".$this->options->last_vm_cat.")".
",('vm_import_last_vm_prod',".$this->options->last_vm_prod.",".$this->options->last_vm_prod.")".
",('vm_import_last_vm_user',".$this->options->last_vm_user.",".$this->options->last_vm_user.")".
",('vm_import_last_vm_order',".$this->options->last_vm_order.",".$this->options->last_vm_order.")".
",('vm_import_last_vm_pfile',".$this->options->last_vm_pfile.",".$this->options->last_vm_pfile.")".
",('vm_import_last_vm_coupon',".$this->options->last_vm_coupon.",".$this->options->last_vm_coupon.")".
",('vm_import_last_vm_taxrate',".$this->options->last_vm_taxrate.",".$this->options->last_vm_taxrate.")".
",('vm_import_last_vm_manufacturer',".$this->options->last_vm_manufacturer.",".$this->options->last_vm_manufacturer.")".
",('vm_import_last_vm_review',".$this->options->last_vm_review.",".$this->options->last_vm_review.")".
';';
$this->db->setQuery($sql);
$this->db->execute();
}
}
function loadVmConfigs()
{
$configstring = '';
if ( defined('IMAGEPATH') )
{
$this->copyImgDir = IMAGEPATH. 'product/';
if ( substr($this->copyImgDir, 0, 1)=='/')
$this->copyImgDir = HIKASHOP_ROOT.substr($this->copyImgDir, 1,
strlen($this->copyImgDir)-1);
elseif ( substr($this->copyImgDir, 0, 1)=='\\')
$this->copyImgDir = HIKASHOP_ROOT.substr($this->copyImgDir, 1,
strlen($this->copyImgDir)-1);
$this->copyCatImgDir = IMAGEPATH. 'category/';
if ( substr($this->copyCatImgDir, 0, 1)=='/')
$this->copyCatImgDir = HIKASHOP_ROOT.substr($this->copyCatImgDir, 1,
strlen($this->copyCatImgDir)-1);
elseif ( substr($this->copyCatImgDir, 0, 1)=='\\')
$this->copyCatImgDir = HIKASHOP_ROOT.substr($this->copyCatImgDir, 1,
strlen($this->copyCatImgDir)-1);
$this->copyManufDir = IMAGEPATH. 'vendor/';
if ( substr($this->copyManufDir, 0, 1)=='/')
$this->copyManufDir = HIKASHOP_ROOT.substr($this->copyManufDir, 1,
strlen($this->copyManufDir)-1);
elseif ( substr($this->copyManufDir, 0, 1)=='\\')
$this->copyManufDir = HIKASHOP_ROOT.substr($this->copyManufDir, 1,
strlen($this->copyManufDir)-1);
}
else
{
$this->copyImgDir =
HIKASHOP_ROOT.'components/com_virtuemart/shop_image/product/';
$this->copyCatImgDir =
HIKASHOP_ROOT.'components/com_virtuemart/shop_image/category/';
$this->copyManufDir =
HIKASHOP_ROOT.'components/com_virtuemart/shop_image/vendor/';
}
}
function parseConfig($string)
{
$arraypath = array(
'media_category_path',
'media_product_path',
'media_manufacturer_path'
);
$paths = array();
$firstparse = explode('|', $string);
foreach ($firstparse as $fp)
{
$secondparse = explode('=', $fp);
if (in_array($secondparse[0],$arraypath))
{
$thirdparse = explode('"', $secondparse[1]);
$paths[$secondparse[0]] = $thirdparse[1];
}
}
return $paths;
}
function finishImport()
{
if( $this->db == null )
return false;
$this->db->setQuery("SELECT max(category_id) as
'max' FROM `#__hikashop_category`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(product_id) as 'max'
FROM `#__hikashop_product`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_prod = (int)($data[0]->max);
$this->db->setQuery("SELECT max(vm_id) as 'max' FROM
`#__hikashop_vm_cat`;");
$data = $this->db->loadObjectList();
$this->options->last_vm_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(vm_id) as 'max' FROM
`#__hikashop_vm_prod`;");
$data = $this->db->loadObjectList();
$this->options->last_vm_prod = (int)($data[0]->max);
$this->db->setQuery("SELECT max(user_id) as 'max'
FROM `".$this->vmprefix."vm_user_info`;");
$data = $this->db->loadObjectList();
$this->options->last_vm_user = (int)($data[0]->max);
$this->db->setQuery("SELECT max(order_vm_id) as
'max' FROM `#__hikashop_order`;");
$data = $this->db->loadObjectList();
$this->options->last_vm_order = (int)($data[0]->max);
$this->db->setQuery("SELECT max(file_id) as 'max'
FROM `".$this->vmprefix."vm_product_files`;");
$data = $this->db->loadObject();
$this->options->last_vm_pfile = (int)($data->max);
$this->db->setQuery("SELECT max(coupon_id) as 'max'
FROM `".$this->vmprefix."vm_coupons`;");
$data = $this->db->loadObject();
$this->options->last_vm_coupon = (int)($data->max);
$this->db->setQuery("SELECT max(tax_rate_id) as
'max' FROM
`".$this->vmprefix."vm_tax_rate`;");
$data = $this->db->loadObject();
$this->options->last_vm_taxrate = (int)($data->max);
$this->db->setQuery("SELECT max(manufacturer_id) as
'max' FROM
`".$this->vmprefix."vm_manufacturer`;");
$data = $this->db->loadObjectList();
$this->options->last_vm_manufacturer = (int)($data[0]->max);
$this->db->setQuery("SELECT max(review_id) as 'max'
FROM `".$this->vmprefix."vm_product_reviews`;");
$data = $this->db->loadObject();
$this->options->last_vm_review = (int)($data->max);
$this->options->state = 14;
$query = 'REPLACE INTO `#__hikashop_config`
(`config_namekey`,`config_value`,`config_default`) VALUES '.
"('vm_import_state',".$this->options->state.",".$this->options->state.")".
",('vm_import_max_hk_cat',".$this->options->max_hk_cat.",".$this->options->max_hk_cat.")".
",('vm_import_max_hk_prod',".$this->options->max_hk_prod.",".$this->options->max_hk_prod.")".
",('vm_import_last_vm_cat',".$this->options->last_vm_cat.",".$this->options->last_vm_cat.")".
",('vm_import_last_vm_prod',".$this->options->last_vm_prod.",".$this->options->last_vm_prod.")".
",('vm_import_last_vm_user',".$this->options->last_vm_user.",".$this->options->last_vm_user.")".
",('vm_import_last_vm_order',".$this->options->last_vm_order.",".$this->options->last_vm_order.")".
",('vm_import_last_vm_pfile',".$this->options->last_vm_pfile.",".$this->options->last_vm_pfile.")".
",('vm_import_last_vm_coupon',".$this->options->last_vm_coupon.",".$this->options->last_vm_coupon.")".
",('vm_import_last_vm_taxrate',".$this->options->last_vm_taxrate.",".$this->options->last_vm_taxrate.")".
",('vm_import_last_vm_manufacturer',".$this->options->last_vm_manufacturer.",".$this->options->last_vm_manufacturer.")".
",('vm_import_last_vm_review',".$this->options->last_vm_review.",".$this->options->last_vm_review.")".
';';
$this->db->setQuery($query);
$this->db->execute();
echo '<p'.$this->titlefont.'>Import finished
!</p>';
$class = hikashop_get('class.plugins');
$infos =
$class->getByName('system','vm_redirect');
if($infos){
$pkey = reset($class->pkeys);
if(!empty($infos->$pkey)){
$url =
JRoute::_('index.php?option=com_plugins&view=plugin&layout=edit&extension_id='.$infos->$pkey);
echo '<p>You can publish the
<a'.$this->linkstyle.'
href="'.$url.'">VirtueMart Fallback Redirect
Plugin</a> so that your old VirtueMart links are automatically
redirected to HikaShop pages and thus not loose the ranking of your content
on search engines.</p>';
}
}
}
function createTables() {
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
1 :</span>Â Initialization Tables</p>';
$query = 'SHOW TABLES LIKE
'.$this->db->Quote($this->db->getPrefix().substr(hikashop_table('vm_cat'),3));
$this->db->setQuery($query);
$table = $this->db->loadResult();
if(empty($table) )
{
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_vm_prod` (`vm_id` int(10) unsigned NOT NULL DEFAULT
'0', `hk_id` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`vm_id`)) ENGINE=MyISAM");
$this->db->execute();
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_vm_cat` (`vm_id` int(10) unsigned NOT NULL DEFAULT
'0', `hk_id` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`vm_id`)) ENGINE=MyISAM");
$this->db->execute();
$databaseHelper = hikashop_get('helper.database');
$databaseHelper->addColumns('address','`address_vm_order_info_id`
INT(11) NULL');
$databaseHelper->addColumns('order','`order_vm_id`
INT(11) NULL');
$databaseHelper->addColumns('order','INDEX (
`order_vm_id` )');
$databaseHelper->addColumns('taxation','`tax_vm_id`
INT(11) NULL');
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
All table created</p>';
}
else
{
echo '<p>Tables have been already created.</p>';
}
return true;
}
function importTaxes() {
if( $this->db == null )
return false;
$ret = false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
2 :</span>Â Import Taxes<p>';
$buffTable=$this->vmprefix."vm_tax_rate";
$data = array(
'tax_namekey' => "CONCAT('VM_TAX_',
vmtr.tax_rate_id)",
'tax_rate' => 'vmtr.tax_rate'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_tax`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$buffTable.'` AS vmtr '.
'WHERE vmtr.tax_rate_id > ' .
(int)$this->options->last_vm_taxrate;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported taxes: ' . $total . '</p>';
$element = 'tax';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$data = array(
'category_type' => "'tax'",
'category_name' => "CONCAT('Tax imported (',
vmtr.tax_country,')')",
'category_published' => '1',
'category_parent_id' => $element,
'category_namekey' => "CONCAT('VM_TAX_',
vmtr.tax_rate_id,'_',hkz.zone_id)",
);
$sql = 'INSERT IGNORE INTO `#__hikashop_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$this->vmprefix.'vm_tax_rate` vmtr '.
"INNER JOIN `#__hikashop_zone` hkz ON vmtr.tax_country =
hkz.zone_code_3 AND hkz.zone_type = 'country' ".
'WHERE vmtr.tax_rate_id > ' .
(int)$this->options->last_vm_taxrate;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Taxes Categories: ' . $total . '</p>';
if( $total > 0 ) {
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'vm_import_max_hk_cat'; ");
$this->db->execute();
$this->importRebuildTree();
}
$data = array(
'zone_namekey' => 'hkz.zone_namekey',
'category_namekey' => "CONCAT('VM_TAX_',
vmtr.tax_rate_id,'_',hkz.zone_id)",
'tax_namekey' => "CONCAT('VM_TAX_',
vmtr.tax_rate_id)",
'taxation_published' => '1',
'taxation_type' => "''",
'tax_vm_id' => 'vmtr.tax_rate_id'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_taxation`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$this->vmprefix.'vm_tax_rate` vmtr '.
"INNER JOIN #__hikashop_zone hkz ON vmtr.tax_country =
hkz.zone_code_3 AND hkz.zone_type = 'country' ".
'WHERE vmtr.tax_rate_id > ' .
(int)$this->options->last_vm_taxrate;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Taxations: ' . $total . '</p>';
$ret = true;
return $ret;
}
function importManufacturers() {
if( $this->db == null )
return false;
$ret = false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
3 :</span>Â Import Manufacturers</p>';
$element = 'manufacturer';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$buffTable=$this->vmprefix."vm_manufacturer";
$data = array(
'category_type' => "'manufacturer'",
'category_name' => "vmm.mf_name ",
'category_published' => '1',
'category_parent_id' => $element,
'category_namekey' => "CONCAT('VM_MANUFAC_',
vmm.manufacturer_id )",
'category_description' => 'vmm.mf_desc',
'category_menu' => 'vmm.manufacturer_id'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$buffTable.'` vmm '.
'WHERE vmm.manufacturer_id > ' .
(int)$this->options->last_vm_manufacturer;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Manufacturers : ' . $total . '</p>';
if( $total > 0 )
{
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'vm_import_max_hk_cat'; ");
$this->db->execute();
$this->importRebuildTree();
}
$ret = true;
return $ret;
}
function importCategories()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
4 :</span>Â Import General Categories</p>';
if( $this->db == null )
return false;
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$rebuild = false;
$ret = false;
$offset = $this->options->current;
$count = 100;
$max = 0;
$statuses = array(
'P' => 'created',
'C' => 'confirmed',
'X' => 'cancelled',
'R'=> 'refunded' ,
'S' => 'shipped'
);
$this->db->setQuery("SELECT category_keywords,
category_parent_id FROM `#__hikashop_category` WHERE category_type =
'status' AND category_name = 'confirmed'");
$data = $this->db->loadObject();
$status_category = $data->category_parent_id;
if( $data->category_keywords != 'C' ) {
foreach($statuses as $k => $v) {
$this->db->setQuery("UPDATE `#__hikashop_category` SET
category_keywords = '".$k."' WHERE category_type =
'status' AND category_name = '".$v."';
");
$this->db->execute();
}
}
$this->db->setQuery("SELECT order_status_code,
order_status_name, order_status_description FROM
`".$this->vmprefix."vm_order_status` WHERE order_status_name
NOT IN
('".implode("','",$statuses)."');");
$data = $this->db->loadObjectList();
if( count($data) > 0 )
{
$sql0 = 'INSERT IGNORE INTO `#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_description`,`category_published`,'.
'`category_namekey`,`category_access`,`category_menu`,`category_keywords`)
VALUES ';
$id = $this->options->max_hk_cat + 1;
$sep = '';
foreach($data as $c) {
$d = array(
$id++,
$status_category,
"'status'",
$this->db->quote( strtolower($c->order_status_name) ),
$this->db->quote( $c->order_status_description ),
'1',
$this->db->quote('status_vm_import_'.strtolower(str_replace('
','_',$c->order_status_name))),
"'all'",
'0',
$this->db->quote( $c->order_status_code )
);
$sql0 .= $sep.'('.implode(',',$d).')';
$sep = ',';
}
$this->db->setQuery($sql0);
$this->db->execute();
$total = $this->db->getAffectedRows();
if( $total > 0 )
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported order status categories : ' . $total .
'</p>';
$rebuild = true;
$this->options->max_hk_cat = $id;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'vm_import_max_hk_cat'; ");
$this->db->execute();
$sql0 = '';
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported order status categories : 0</p>';
}
}
$this->db->setQuery('SELECT *, hkvm.vm_id AS vm_cat_id,
hkvmp.vm_id AS vm_parent_id FROM
`'.$this->vmprefix.'vm_category` vmc '.
'LEFT JOIN `'.$this->vmprefix.'vm_category_xref` vmcx
ON vmc.category_id = vmcx.category_child_id '.
'LEFT JOIN `#__hikashop_vm_cat` hkvm ON vmc.category_id =
hkvm.vm_id '.
'LEFT JOIN `#__hikashop_vm_cat` hkvmp ON vmcx.category_parent_id =
hkvmp.vm_id '.
'ORDER BY category_parent_id ASC, list_order ASC, category_id ASC
LIMIT '.(int)$offset.', '.(int)$count.';');
$data = $this->db->loadObjectList();
$max = $offset + count($data);
$total = count($data);
if( $total == 0 ) {
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported category : 0</p>';
if( $rebuild )
$this->importRebuildTree();
return true;
}
$sql0 = 'INSERT IGNORE INTO `#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_description`,`category_published`,'.
'`category_ordering`,`category_namekey`,`category_created`,`category_modified`,`category_access`,`category_menu`)
VALUES ';
$sql1 = 'INSERT IGNORE INTO `#__hikashop_vm_cat` (`vm_id`,`hk_id`)
VALUES ';
$sql2 = 'INSERT INTO `#__hikashop_file`
(`file_name`,`file_description`,`file_path`,`file_type`,`file_ref_id`)
VALUES ';
$doSql2 = false;
$doSql1 = false;
$i = $this->options->max_hk_cat + 1;
$ids = array( 0 => $this->options->main_cat_id);
$sep = '';
foreach($data as $c)
{
if( !empty($c->vm_cat_id) )
{
$ids[(int)$c->category_id] = $c->hk_id;
}
else
{
$doSql1 = true;
$ids[(int)$c->category_id] = $i;
$sql1 .=
$sep.'('.(int)$c->category_id.','.$i.')';
$i++;
$sep = ',';
}
}
$sql1 .= ';';
$sep = '';
$sep2 = '';
$doQuery = false;
foreach($data as $c)
{
if( !empty($c->vm_cat_id) )
continue;
$doQuery = true;
$id = $ids[(int)$c->category_id];
if(!empty($ids[(int)$c->category_parent_id]))
$pid = (int)$ids[(int)$c->category_parent_id];
else if(!empty($c->vm_parent_id))
$pid = (int)$c->vm_parent_id;
else
$pid = $ids[0];
$element = new stdClass();
$element->category_id = $id;
$element->category_parent_id = $pid; //See also category_parent_id
$element->category_name = $c->category_name;
$nameKey = $categoryClass->getNameKey($element);
$d = array(
$id,
$pid,
"'product'",
$this->db->quote($c->category_name),
$this->db->quote($c->category_description),
'1',
(int)@$c->list_order,
$this->db->quote($nameKey),
(int)@$c->cdate,
(int)@$c->mdate,
"'all'",
'0'
);
$sql0 .= $sep.'('.implode(',',$d).')';
if( !empty($c->category_full_image)) {
$doSql2 = true;
$sql2 .=
$sep2."('','','".$c->category_full_image."','category',".$id.')';
$sep2 = ',';
$file_name =
str_replace('\\','/',$c->category_full_image);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyCatImgDir,$c->category_full_image,
$this->options->uploadfolder.$file_name);
$max = $c->category_id;
}
$sep = ',';
}
$sql0 .= ';';
if ($doQuery)
{
$this->db->setQuery($sql0);
$this->db->execute();
$total = $this->db->getAffectedRows();
}
else
$total = 0;
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Categories : ' . $total . '</p>';
if( isset($total) && $total > 0)
{
$rebuild = true;
$this->options->max_hk_cat += $total + 1;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'vm_import_max_hk_cat'; ");
$this->db->execute();
}
if ($doSql1)
{
$this->db->setQuery($sql1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links : ' . $total . '</p>';
}
else
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links : 0</p>';
if( $doSql2 )
{
$sql2 .= ';';
$this->db->setQuery($sql2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Categories files : ' . $total . '</p>';
}
else
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Categories files : 0</p>';
if( $rebuild )
$this->importRebuildTree();
$this->options->current = $max;
if( $max > 0 ) {
echo '<p>Copying files...(last proccessed product id: '
. $max . ')</p>';
$this->options->current = $max;
$this->refreshPage = true;
return $ret;
}
$ret = true;
return $ret;
}
function importProducts() {
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
5 :</span>Â Import Products</p>';
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$ret = false;
$count = 100;
$offset = $this->options->current;
$max = 0;
$this->db->setQuery(
'SELECT vmp.product_id, vmp.product_full_image '.
'FROM `'.$this->vmprefix.'vm_product` vmp '.
'LEFT JOIN `#__hikashop_vm_prod` hkprod ON vmp.product_id =
hkprod.vm_id '.
"WHERE vmp.product_id > ".$offset." AND hkprod.hk_id
IS NULL AND (vmp.product_full_image IS NOT NULL) AND vmp.product_full_image
<> '' ".
'ORDER BY vmp.product_id ASC LIMIT '.$count.';'
);
$data = $this->db->loadObjectList();
if (!empty($data))
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying products images... </p>';
foreach($data as $c) {
if( !empty($c->product_full_image) ) {
$file_name =
str_replace('\\','/',$c->product_full_image);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyImgDir,$c->product_full_image,
$this->options->uploadfolder.$file_name);
$max = $c->product_id;
}
}
}
$this->db->setQuery('SELECT config_value FROM
`#__hikashop_config` WHERE config_namekey =
\'weight_symbols\'');
$data = $this->db->loadObjectList();
$wghtunit = explode(',',$data[0]->config_value);
$this->db->setQuery('SELECT config_value FROM
`#__hikashop_config` WHERE config_namekey =
\'volume_symbols\'');
$data = $this->db->loadObjectList();
$dimunit = explode(',',$data[0]->config_value);
$data = array(
'product_name' => 'vmp.product_name',
'product_description' =>
"CONCAT(vmp.product_s_desc,'<hr
id=\"system-readmore\"/>',vmp.product_desc)",
'product_quantity' => 'case when vmp.product_in_stock
IS NULL or vmp.product_in_stock < 0 then 0 else vmp.product_in_stock
end',
'product_code' => 'vmp.product_sku',
'product_published' => "case when vmp.product_publish
= 'Y' then 1 else 0 end",
'product_hit' => '0',
'product_created' => 'vmp.cdate',
'product_modified' => 'vmp.mdate',
'product_sale_start' =>
'vmp.product_available_date',
'product_tax_id' => 'hkc.category_id',
'product_type' => "'main'",
'product_url' => 'vmp.product_url',
'product_weight' => 'vmp.product_weight',
'product_weight_unit' => "case when
LOWER(vmp.product_weight_uom) = 'pounds' then 'lb' else
'".$wghtunit[0]."' end",
'product_dimension_unit' => "case when
LOWER(vmp.product_lwh_uom) = 'inches' then 'in' else
'".$dimunit[0]."' end",
'product_sales' => 'vmp.product_sales',
'product_width' => 'vmp.product_width',
'product_length' => 'vmp.product_length',
'product_height' => 'vmp.product_height',
);
$sql1 = 'INSERT IGNORE INTO `#__hikashop_product`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->vmprefix.'vm_product` AS vmp '.
'LEFT JOIN `#__hikashop_taxation` hkt ON hkt.tax_vm_id =
product_tax_id '.
'LEFT JOIN `#__hikashop_category` hkc ON hkc.category_namekey =
hkt.category_namekey '.
'LEFT JOIN `#__hikashop_vm_prod` AS hkp ON vmp.product_id =
hkp.vm_id '.
'WHERE hkp.hk_id IS NULL AND vmp.product_id >
'.$offset.' '.
'ORDER BY vmp.product_id ASC LIMIT '.$count.';';
$data = array(
'vm_id' => 'vmp.product_id',
'hk_id' => 'hkp.product_id'
);
$sql2 = 'INSERT IGNORE INTO `#__hikashop_vm_prod`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->vmprefix.'vm_product` AS vmp INNER JOIN
`#__hikashop_product` AS hkp ON CONVERT(vmp.product_sku USING utf8) =
CONVERT(hkp.product_code USING utf8) '.
'LEFT JOIN `#__hikashop_vm_prod` hkvm ON hkvm.vm_id =
vmp.product_id '.
'WHERE hkvm.hk_id IS NULL AND vmp.product_id >
'.$offset.' '.
'ORDER BY vmp.product_id ASC LIMIT '.$count.';';
$sql3 = 'UPDATE `#__hikashop_product` AS hkp '.
'INNER JOIN `'.$this->vmprefix.'vm_product` AS vmp ON
CONVERT(vmp.product_sku USING utf8) = CONVERT(hkp.product_code USING utf8)
'.
'INNER JOIN `#__hikashop_vm_prod` AS hkvm ON vmp.product_parent_id
= hkvm.vm_id '.
'SET hkp.product_parent_id = hkvm.hk_id;';
$data = array(
'file_name' => "''",
'file_description' => "''",
'file_path' =>
"SUBSTRING_INDEX(vmp.product_full_image,'/',-1)",
'file_type' => "'product'",
'file_ref_id' => 'hkvm.hk_id'
);
$sql4 = 'INSERT IGNORE INTO `#__hikashop_file`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->vmprefix.'vm_product` AS vmp '.
'INNER JOIN `#__hikashop_vm_prod` AS hkvm ON vmp.product_id =
hkvm.vm_id '.
'WHERE vmp.product_id >
'.$this->options->last_vm_prod.' AND
(vmp.product_full_image IS NOT NULL) AND (vmp.product_full_image
<>'." '')";
$sql5 = 'UPDATE `#__hikashop_product` AS hkp '.
'INNER JOIN `#__hikashop_vm_prod` AS hkvm ON hkp.product_id =
hkvm.hk_id '.
'INNER JOIN `'.$this->vmprefix.'vm_product_mf_xref` AS
vmm ON vmm.product_id = hkvm.vm_id '.
"INNER JOIN `#__hikashop_category` AS hkc ON hkc.category_type =
'manufacturer' AND vmm.manufacturer_id = hkc.category_menu
".
'SET hkp.product_manufacturer_id = hkc.category_id '.
'WHERE vmm.manufacturer_id >
'.$this->options->last_vm_manufacturer.' OR vmm.product_id
> '.$this->options->last_vm_prod.';';
$this->db->setQuery($sql1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products: ' . $total . '</p>';
$this->db->setQuery($sql2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links: ' . $total . '</p>';
$this->db->setQuery('SELECT MAX(vm_id) FROM
`#__hikashop_vm_prod`');
$this->db->execute();
$max = (int)$this->db->loadResult();
$this->db->setQuery($sql3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating products for parent links: ' . $total .
'</p>';
$this->db->setQuery($sql4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products files: ' . $total . '</p>';
$this->db->setQuery($sql5);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating products manufacturers: ' . $total . '</p>';
if( $max > 0 && $max > $offset) {
echo '<p>Copying files...(last proccessed product id: '
. $max . ')</p>';
$this->options->current = $max;
$this->refreshPage = true;
return $ret;
}
$ret = true;
return $ret;
}
function importProductPrices()
{
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
6 :</span>Â Import Product Prices</p>';
$ret = false;
$cpt = 0;
$this->db->setQuery('INSERT IGNORE INTO #__hikashop_price
(`price_product_id`,`price_value`,`price_currency_id`,`price_min_quantity`,`price_access`)
'
.'SELECT hkprod.hk_Id, product_price, hkcur.currency_id,
price_quantity_start, \'all\' '
.'FROM `'.$this->vmprefix.'vm_product_price` vm INNER
JOIN #__hikashop_vm_prod hkprod ON vm.product_id = hkprod.vm_id '
.'INNER JOIN #__hikashop_currency hkcur ON
CONVERT(vm.product_currency USING utf8) = CONVERT( hkcur.currency_code
USING utf8) '
.'WHERE product_price_vdate < NOW() AND (product_price_edate =
0 OR product_price_edate > NOW() ) '
.'AND vm.product_id > ' .
(int)$this->options->last_vm_prod
);
$ret = $this->db->execute();
$cpt = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Prices imported : ' . $cpt .'</p>';
return $ret;
}
function importProductCategory()
{
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
7 :</span>Â Import Product Category</p>';
$data = array(
'category_id' => 'vmc.hk_id',
'product_id' => 'vmp.hk_id',
'ordering' => '`product_list`',
);
$sql = 'INSERT IGNORE INTO `#__hikashop_product_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$this->vmprefix.'vm_product_category_xref` vm '.
'INNER JOIN `#__hikashop_vm_cat` vmc ON vm.category_id = vmc.vm_id
'.
'INNER JOIN `#__hikashop_vm_prod` vmp ON vm.product_id = vmp.vm_id
'.
'WHERE vmp.vm_id > ' .
(int)$this->options->last_vm_prod . ' OR vmc.vm_id > ' .
(int)$this->options->last_vm_cat;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products categories: ' . $total . '</p>';
return true;
}
function importUsers() {
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
8 :</span>Â Import Users</p>';
$ret = false;
$sql0 = 'INSERT IGNORE INTO `#__hikashop_user`
(`user_cms_id`,`user_email`) '.
'SELECT vmui.user_id, vmui.user_email FROM
`'.$this->vmprefix.'vm_user_info` AS vmui '.
'LEFT JOIN `#__hikashop_user` AS hkusr ON vmui.user_id =
hkusr.user_cms_id '.
'WHERE hkusr.user_cms_id IS NULL;';
$data = array(
'address_user_id' => 'hku.user_id',
'address_firstname' => 'vmui.first_name',
'address_middle_name' => 'vmui.middle_name',
'address_lastname' => 'vmui.last_name',
'address_company' => 'vmui.company',
'address_street' => 'CONCAT(vmui.address_1,\'
\',vmui.address_2)',
'address_post_code' => 'vmui.zip',
'address_city' => 'vmui.city',
'address_telephone' => 'vmui.phone_1',
'address_telephone2' => 'vmui.phone_2',
'address_fax' => 'vmui.fax',
'address_state' => 'vmui.state',
'address_country' => 'vmui.country',
'address_published' => 4
);
$sql1 = 'INSERT IGNORE INTO `#__hikashop_address`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->vmprefix.'vm_user_info` AS vmui INNER JOIN
`#__hikashop_user` AS hku ON vmui.user_id = hku.user_cms_id WHERE
vmui.user_id > '.$this->options->last_vm_user.' ORDER BY
vmui.user_id ASC';
$sql2 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone` AS hkz ON (a.address_country =
hkz.zone_code_3 AND hkz.zone_type = "country") '.
'SET address_country = hkz.zone_namekey, address_published = 3
WHERE address_published = 4;';
$sql3 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone_link` AS zl ON (a.address_country =
zl.zone_parent_namekey) '.
'JOIN `#__hikashop_zone` AS hks ON (hks.zone_namekey =
zl.zone_child_namekey AND hks.zone_type = "state" AND
hks.zone_code_3 = a.address_state) '.
'SET address_state = hks.zone_namekey, address_published = 2 WHERE
address_published = 3;';
$sql4 = "UPDATE `#__hikashop_address` AS a SET a.address_country =
'' WHERE address_published > 3;";
$sql5 = "UPDATE `#__hikashop_address` AS a SET a.address_state =
'' WHERE address_published > 2;";
$sql6 = 'UPDATE `#__hikashop_address` AS a SET a.address_published =
1 WHERE address_published > 1;';
$this->db->setQuery($sql0);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Users: ' . $total . '</p>';
$this->db->setQuery($sql1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses: ' . $total . '</p>';
$this->db->setQuery($sql2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses countries: ' . $total . '</p>';
$this->db->setQuery($sql3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses states: ' . $total . '</p>';
$this->db->setQuery($sql4);
$this->db->execute();
$this->db->setQuery($sql5);
$this->db->execute();
$this->db->setQuery($sql6);
$this->db->execute();
$ret = true;
return $ret;
}
function importOrders()
{
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
10 :</span>Â Import Orders</p>';
$ret = false;
$offset = $this->options->current;
$count = 100;
$total = 0;
$guest = 0;
$this->db->setQuery("SELECT name FROM
`".$this->vmprefix."vm_userfield` WHERE type =
'euvatid' AND published = 1");
$vat_cols = $this->db->loadObjectList();
if( isset($vat_cols) && $vat_cols !== null &&
is_array($vat_cols) && count($vat_cols)>0)
$vat_cols = 'vmui.' . $vat_cols[0]->name;
else
$vat_cols = "''";
$data = array(
'order_number' => 'vmo.order_number',
'order_vm_id' => 'vmo.order_id',
'order_user_id' => 'case when vmo.user_id < 0 OR
hkusr.user_cms_id IS NULL then 0 else hkusr.user_id end ',
'order_status' => 'hkc.category_name',
'order_discount_code' => 'vmo.coupon_code',
'order_discount_price' => 'vmo.coupon_discount',
'order_created' => 'vmo.cdate',
'order_ip' => 'vmo.ip_address',
'order_currency_id' => 'hkcur.currency_id',
'order_shipping_price' => 'vmo.order_shipping',
'order_shipping_method' => "'vm
import'",
'order_shipping_id' => '1',
'order_payment_id' => 0,
'order_payment_method' => '\'vm
import\'',
'order_full_price' => 'vmo.order_total',
'order_modified' => 'vmo.mdate',
'order_partner_id' => 0,
'order_partner_price' => 0,
'order_partner_paid' => 0,
'order_type' => "'sale'",
'order_partner_currency_id' => 0,
'order_shipping_tax' =>
'vmo.order_shipping_tax',
'order_discount_tax' => 0
);
$sql1 = 'INSERT IGNORE INTO `#__hikashop_order`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->vmprefix.'vm_orders` AS vmo '.
'JOIN `'.$this->vmprefix.'vm_order_status` AS vmos ON
vmo.order_status = vmos.order_status_code '.
'JOIN `#__hikashop_category` AS hkc ON vmos.order_status_name =
hkc.category_name AND hkc.category_type = \'status\' '.
'JOIN `#__hikashop_currency` AS hkcur ON CONVERT(vmo.order_currency
USING utf8) = CONVERT(hkcur.currency_code USING utf8) '.
'LEFT JOIN `#__hikashop_user` AS hkusr ON vmo.user_id =
hkusr.user_cms_id '.
'WHERE vmo.order_id > ' .
(int)$this->options->last_vm_order . ' '.
'GROUP BY vmo.order_id '.
'ORDER BY vmo.order_id ASC;';
$this->db->setQuery('SELECT * FROM `#__hikashop_order` WHERE
order_user_id = 0');
$data = $this->db->loadObjectList();
if (!empty($data))
{
$buffstring = '(';
$sep = '';
foreach ($data as $d)
{
$buffstring .= $sep.$d->order_vm_id;
$sep = ',';
}
$buffstring .= ')';
$sql0 = 'SELECT vmou.user_email FROM
`'.$this->vmprefix.'vm_orders` AS vmo '.
'INNER JOIN `'.$this->vmprefix.'vm_order_user_info`
AS vmou ON vmo.order_id = vmou.order_id '.
'WHERE vmo.order_id IN '.$buffstring;
$this->db->setQuery($sql0);
$buffdata = $this->db->loadObjectList();
$string = '';
$sep = '';
foreach ($buffdata as $bf)
{
$string .=
$sep."('0','".$bf->user_email."')";
$sep = ',';
}
$sql0 = 'INSERT IGNORE INTO `#__hikashop_user`
(`user_cms_id`,`user_email`) VALUES '.$string;
$this->db->setQuery($sql0);
$this->db->execute();
$sql0 = 'UPDATE `#__hikashop_order` AS hko '.
'INNER JOIN `'.$this->vmprefix.'vm_orders` AS vmo ON
hko.order_vm_id = vmo.order_id '.
'INNER JOIN `'.$this->vmprefix.'vm_order_user_info`
AS vmou ON vmo.user_id = vmou.user_id '.
'INNER JOIN `#__hikashop_user` as hku ON vmou.user_email =
hku.user_email '.
'SET hko.order_user_id = hku.user_id '.
'WHERE hko.order_user_id = 0';
$this->db->setQuery($sql0);
$this->db->execute();
$guest = $this->db->getAffectedRows();
}
$data = array(
'address_user_id' => '0',
'address_firstname' => 'vmui.first_name',
'address_middle_name' => 'vmui.middle_name',
'address_lastname' => 'vmui.last_name',
'address_company' => 'vmui.company',
'address_street' => "CONCAT(vmui.address_1,'
',vmui.address_2)",
'address_post_code' => 'vmui.zip',
'address_city' => 'vmui.city',
'address_telephone' => 'vmui.phone_1',
'address_telephone2' => 'vmui.phone_2',
'address_fax' => 'vmui.fax',
'address_state' => 'vmui.state',
'address_country' => 'vmui.country',
'address_published' => "case when vmui.address_type =
'BT' then 7 else 8 end",
'address_vat' => $vat_cols,
'address_vm_order_info_id' => 'vmui.order_id'
);
$sql2_1 = 'INSERT IGNORE INTO `#__hikashop_address`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->vmprefix.'vm_order_user_info` AS vmui WHERE
vmui.order_id > '.$this->options->last_vm_order.' ORDER
BY vmui.order_info_id ASC';
$sql2_2 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone` AS hkz ON (a.address_country =
hkz.zone_code_3 AND hkz.zone_type = "country") '.
'SET address_country = hkz.zone_namekey, address_published = 6
WHERE address_published >= 7;';
$sql2_3 = 'UPDATE `#__hikashop_address` AS a '. // todo
'JOIN `#__hikashop_zone_link` AS zl ON (a.address_country =
zl.zone_parent_namekey) '.
'JOIN `#__hikashop_zone` AS hks ON (hks.zone_namekey =
zl.zone_child_namekey AND hks.zone_type = "state" AND
hks.zone_code_3 = a.address_state) '.
'SET address_state = hks.zone_namekey, address_published = 5 WHERE
address_published = 6;';
$sql2_4 = 'UPDATE `#__hikashop_address` AS a '.
'SET address_published = 0 WHERE address_published > 4;';
$sql3 = 'UPDATE `#__hikashop_order` AS o '.
'INNER JOIN `#__hikashop_address` AS a ON
a.address_vm_order_info_id = o.order_vm_id '.
'SET o.order_billing_address_id = a.address_id,
o.order_shipping_address_id = a.address_id '.
"WHERE o.order_billing_address_id = 0 AND address_published >= 7
;";
$sql4 = 'UPDATE `#__hikashop_order` AS o '.
'INNER JOIN `#__hikashop_address` AS a ON
a.address_vm_order_info_id = o.order_vm_id '.
'SET o.order_shipping_address_id = a.address_id '.
"WHERE (o.order_shipping_address_id = 0 OR
o.order_shipping_address_id = o.order_billing_address_id) AND
address_published >= 8 ;";
$sql5 = 'UPDATE `#__hikashop_order` AS a '.
'JOIN `'.$this->vmprefix.'vm_order_payment` AS o ON
a.order_vm_id = o.order_id '.
'JOIN `'.$this->vmprefix.'vm_payment_method` AS p ON
o.payment_method_id = p.payment_method_id '.
"SET a.order_payment_method = CONCAT('vm import: ',
p.payment_method_name) ".
'WHERE a.order_vm_id > ' .
(int)$this->options->last_vm_order;
$this->db->setQuery('SET SQL_BIG_SELECTS=1');
$this->db->execute();
$this->db->setQuery($sql1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported orders: ' . $total . ' (including '.$guest.'
guests)</p>';
$this->db->setQuery($sql2_1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported orders addresses: ' . $total . '</p>';
$this->db->setQuery($sql3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating billing addresses: ' . $total . '</p>';
$this->db->setQuery($sql4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating shipping addresses: ' . $total . '</p>';
$this->db->setQuery($sql5);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating order payments: ' . $total . '</p>';
$this->db->setQuery($sql2_2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating orders: ' . $total;
$this->db->setQuery($sql2_3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '/' . $total;
$this->db->setQuery($sql2_4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '/' . $total . '</p>';
$ret = true;
return $ret;
}
function importOrderItems()
{
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
11 :</span>Â Import Order Items</p>';
$ret = false;
$offset = $this->options->current;
$count = 100;
$data = array(
'order_id' => 'hko.order_id',
'product_id' => 'hkp.hk_id',
'order_product_quantity' =>
'vmoi.product_quantity',
'order_product_name' => 'vmoi.order_item_name',
'order_product_code' => 'vmoi.order_item_sku',
'order_product_price' =>
'vmoi.product_item_price',
'order_product_tax' => '(vmoi.product_final_price -
vmoi.product_item_price)',
'order_product_options' => "''"
);
$sql = 'INSERT IGNORE INTO `#__hikashop_order_product`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->vmprefix.'vm_order_item` AS vmoi '.
'INNER JOIN `#__hikashop_order` AS hko ON vmoi.order_id =
hko.order_vm_id '.
'INNER JOIN `#__hikashop_vm_prod` AS hkp ON hkp.vm_id =
vmoi.product_id '.
'WHERE vmoi.order_id > ' .
(int)$this->options->last_vm_order . ';';
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Orders Items imported : '. $total .'</p>';
$ret = true;
return $ret;
}
function importDownloads()
{
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
12 :</span>Â Import Downloads</p>';
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$app = JFactory::getApplication();
$ret = false;
$count = 100;
$offset = $this->options->current;
if( $offset == 0 )
{
$offset =
$app->getUserState($this->sessionParams.'last_vm_pfile');
if (!$offset)
$offset = $this->options->last_vm_pfile;
}
$sql = "SELECT `config_value` FROM `#__hikashop_config` WHERE
config_namekey = 'download_number_limit';";
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$dl_limit = $data[0]->config_value;
$sql = 'SELECT vmf.file_id,vmf.file_name,vmf.file_is_image FROM
`'.$this->vmprefix.'vm_product_files` AS vmf WHERE vmf.file_id
> '.$offset.' ORDER BY vmf.file_id ASC LIMIT
'.$count.';';
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$max = 0;
foreach($data as $c) {
$file_name =
str_replace('\\','/',$c->file_name);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$dstFolder = $this->options->uploadsecurefolder;
if($c->file_is_image){
$dstFolder = $this->options->uploadfolder;
}
$this->copyFile($this->copyImgDir,$c->file_name,
$dstFolder.$file_name);
$max = $c->file_id;
}
if( $max > 0 ) {
echo '<p>Copying files...<br/>(Last processed file id:
' . $max . ')</p>';
$this->options->current = $max;
$this->refreshPage = true;
return $ret;
}
$data = array(
'file_name' => 'vmf.file_title',
'file_description' => 'vmf.file_description',
'file_path' =>
"SUBSTRING_INDEX(SUBSTRING_INDEX(vmf.file_name, '/', -1),
'\\\\', -1)",
'file_type' => "case when vmf.file_is_image = 1 then
'product' else 'file' end",
'file_ref_id' => 'hkp.hk_id'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_file`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->vmprefix.'vm_product_files` AS vmf '.
'INNER JOIN `#__hikashop_vm_prod` AS hkp ON hkp.vm_id =
vmf.file_product_id '.
'WHERE vmf.file_id >
'.$this->options->last_vm_pfile.';';
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Downloable files imported : ' . $total . '</p>';
$data = array(
'file_id' => 'hkf.file_id',
'order_id' => 'hko.order_id',
'download_number' => '(' . $dl_limit . '-
vmd.download_max)'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_download`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->vmprefix.'vm_product_download` AS vmd '.
'INNER JOIN `#__hikashop_order` AS hko ON hko.order_vm_id =
vmd.order_id '.
'INNER JOIN `#__hikashop_vm_prod` AS hkp ON hkp.vm_id =
vmd.product_id '.
'INNER JOIN `#__hikashop_file` AS hkf ON ( CONVERT(hkf.file_name
USING utf8) = CONVERT(vmd.file_name USING utf8) )'.
"WHERE hkf.file_type = 'file' AND (hkp.hk_id =
hkf.file_ref_id) AND (vmd.product_id >
".$this->options->last_vm_prod.' OR vmd.order_id >
' . (int)$this->options->last_vm_order . ');';
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Downloable order files imported : ' . $total .
'</p>';
$ret = true;
return $ret;
}
function importDiscount() {
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
9 :</span>Â Import Discount</p>';
$sql = "SELECT `config_value` FROM `#__hikashop_config` WHERE
config_namekey = 'main_currency';";
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$main_currency = $data[0]->config_value;
$data = array(
'discount_type' => "'coupon'", //coupon
or discount
'discount_published' => '1',
'discount_code' => '`coupon_code`',
'discount_currency_id' => $main_currency,
'discount_flat_amount' => "case when percent_or_total
= 'total' then coupon_value else 0 end",
'discount_percent_amount' => "case when
percent_or_total = 'percent' then coupon_value else 0 end",
'discount_quota' => "case when coupon_type =
'gift' then 1 else 0 end"
);
$sql = 'INSERT IGNORE INTO #__hikashop_discount
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
'.$this->vmprefix.'vm_coupons WHERE coupon_id > ' .
(int)$this->options->last_vm_coupon;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Discount codes / coupons imported : ' . $total .
'</p>';
$data = array(
'discount_type' => "'discount'",
//coupon or discount
'discount_published' => '1',
'discount_code' => "CONCAT('discount_',
vmp.product_sku)",
'discount_currency_id' => $main_currency,
'discount_flat_amount' => "case when vmd.is_percent =
0 then vmd.amount else 0 end",
'discount_percent_amount' => "case when vmd.is_percent
= 1 then vmd.amount else 0 end",
'discount_quota' => "''",
'discount_product_id' => 'hkp.hk_id',
'discount_category_id' => '0',
'discount_start' => "vmd.start_date",
'discount_end' => "vmd.end_date"
);
$sql = 'INSERT IGNORE INTO #__hikashop_discount
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
'.$this->vmprefix.'vm_product vmp '.
'INNER JOIN `'.$this->vmprefix.'vm_product_discount`
vmd ON vmp.product_discount_id = vmd.discount_id '.
'INNER JOIN `#__hikashop_vm_prod` AS hkp ON hkp.vm_id =
vmp.product_id '.
'WHERE vmp.product_id > ' .
(int)$this->options->last_vm_prod;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Discount product imported : ' . $total . '</p>';
$ret = true;
return $ret;
}
function importReviews()
{
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
13 :</span>Â Import Product reviews</p>';
$ret = false;
$offset = $this->options->current;
$count = 100;
$data = array(
'vote_ref_id' => 'hkvp.hk_id',
'vote_type' => "'product'",
'vote_user_id' => 'hkusr.user_id',
'vote_rating' => 'vpr.review_votes',
'vote_comment' => 'vpr.comment',
'vote_useful' => '0', //review_ok ?
'vote_pseudo' => 'u.username',
'vote_ip' => "''",
'vote_email' => 'u.email',
'vote_date' => 'CURDATE()'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_vote`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__vm_product_reviews` AS vpr '.
'INNER JOIN `#__hikashop_vm_prod` AS hkvp ON vpr.product_id =
hkvp.vm_id '.
'INNER JOIN `#__hikashop_user` AS hkusr ON vpr.userid =
hkusr.user_cms_id '.
'INNER JOIN `#__users` AS u ON hkusr.user_cms_id = u.id '.
'WHERE vpr.review_id > ' .
(int)$this->options->last_vm_review . ';';
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
$sql = 'SELECT hkvp.hk_id as hkid, vpr.review_id as vmvote FROM
`#__vm_product_reviews` AS vpr '.
'INNER JOIN `#__hikashop_vm_prod` AS hkvp ON vpr.product_id =
hkvp.vm_id '.
'WHERE vpr.review_id > ' .
(int)$this->options->last_vm_review . ' '.
'ORDER BY hkvp.hk_id; ';
$this->db->setQuery($sql);
$this->db->execute();
$data = $this->db->loadObjectList();
$continue = false;
$idmain = $sum = $divide = $nbentries = 0;
foreach($data as $d)
{
if (!$continue)
$idmain = $d->hkid;
$sum += $d->vmvote;
$divide++;
if ($idmain==$d->hkid)
{
$continue = true;
continue;
}
$average = $sum / $divide;
$sql = 'UPDATE `#__hikashop_product` SET `product_average_score` =
'.$average.', `product_total_vote` = '.$divide.' WHERE
product_id = '.$d->hkid;
$this->db->execute();
$nbentries += $this->db->getAffectedRows();
$sum = $divide = 0;
$continue = false;
}
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Products reviews imported : '. $total .'</p>';
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Products average scores updated : '. $nbentries
.'</p>';
$ret = true;
return $ret;
}
}
import/vm2.php000064400000216357151162557560007326 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
include_once HIKASHOP_HELPER . 'import.php';
@include_once(HIKASHOP_ROOT .
'administrator/components/com_virtuemart/virtuemart.cfg.php');
ini_set('max_execution_time', 300);
class hikashopImportvm2Helper extends hikashopImportHelper
{
var $vm_version = 2;
var $vm_current_lng = '';
var $sessionParams = '';
var $vmprefix;
function __construct(&$parent)
{
parent::__construct();
$this->importName = 'vm';
$this->sessionParams = HIKASHOP_COMPONENT.'vm';
jimport('joomla.filesystem.file');
}
function checkCategories(){
$sql = "UPDATE `#__hikashop_category` AS cat ".
"SET cat.category_parent_id = 2 ".
"WHERE cat.category_type = 'product' AND
(cat.category_parent_id = 0 OR cat.category_parent_id = cat.category_id)
AND cat.category_id > 2;";
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Total number of corrected Hikashop Parent Categories : ' . $total .
'</p>';
}
function importFromVM()
{
@ob_clean();
echo $this->getHtmlPage();
$this->token = hikashop_getFormToken();
$app = JFactory::getApplication();
flush();
if( isset($_GET['import']) && $_GET['import']
== '1' )
{
$time = microtime(true);
$this->vmprefix =
$app->getUserState($this->sessionParams.'vmPrefix');
$this->vm_current_lng =
$app->getUserState($this->sessionParams.'language');
$processed = $this->doImport();
if($processed)
{
$elasped = microtime(true) - $time;
if( !$this->refreshPage )
echo '<p><a'.$this->linkstyle.'
href="'.hikashop_completeLink('import&task=import&importfrom=vm&'.$this->token.'=1&import=1&time='.time()).'">'.JText::_('HIKA_NEXT').'</a></p>';
echo '<p style="font-size:0.85em;
color:#605F5D;">Elasped time: ' . round($elasped * 1000, 2) .
'ms</p>';
}
else
{
echo '<a'.$this->linkstyle.'
href="'.hikashop_completeLink('import&task=show').'">'.JText::_('HIKA_BACK').'</a>';
}
}
else
{
echo $this->getStartPage();
}
if( $this->refreshPage == true )
{
echo "<script type=\"text/javascript\">\r\nr =
true; \r\n</script>";
}
echo '</body></html>';
exit;
}
function getStartPage()
{
$app = JFactory::getApplication();
$returnString = '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
0</span></p>';
$continue=true;
$this->vmprefix =
$app->getUserStateFromRequest($this->sessionParams.'vmPrefix',
'vmPrefix', '', 'string' );
if (empty($this->vmprefix))
$this->vmprefix = $this->db->getPrefix();
elseif(substr($this->vmprefix, -1, 1) != '_')
$this->vmprefix .= '_';
if(strpos($this->vmprefix, '__') !== false &&
$this->vmprefix != '#__')
$this->vmprefix = str_replace('__', '_',
$this->vmprefix);
$app->setUserState($this->sessionParams.'vmPrefix',$this->vmprefix);
$this->db->setQuery("SHOW TABLES LIKE
'".$this->vmprefix."virtuemart_products'");
$table = $this->db->loadObjectList();
if (!$table)
{
$returnString .= '<p style="color:red;
font-size:0.9em;">There is no table with the prefix
\''.$this->vmprefix.'\' in your Joomla
database.</p>';
$continue = false;
}
$this->vm_current_lng =
$app->getUserStateFromRequest($this->sessionParams.'language',
'language', '', 'string'
);//hikaInput::get()->getString('language');
$this->vm_current_lng =
strtolower(str_replace('-','_',$this->vm_current_lng));
$app->setUserState($this->sessionParams.'language',$this->vm_current_lng);
$this->db->setQuery("SHOW TABLES LIKE
'".$this->db->getPrefix()."virtuemart_products_".$this->vm_current_lng."'");
$table = $this->db->loadObjectList();
if (!$table)
{
$returnString .= '<p style="color:red;
font-size:0.9em;"> There is no table corresponding to the language
you selected ('.$this->vm_current_lng.') in your database.
Please go back and select another language.</p>';
$continue = false;
}
if ($continue)
{
$returnString = 'First, make a backup of your
database.<br/>'.
'When ready, click on <a '.$this->linkstyle.'
href="'.hikashop_completeLink('import&task=import&importfrom=vm&'.$this->token.'=1&import=1').'">'.JText::_('HIKA_NEXT').'</a>,
otherwise ';
}
$returnString .= '<a'.$this->linkstyle.'
href="'.hikashop_completeLink('import&task=show').'">'.JText::_('HIKA_BACK').'</a>';
return $returnString;
}
function doImport() {
if( $this->db == null )
return false;
$this->loadConfiguration();
$current = $this->options->current;
$ret = true;
$next = false;
switch( $this->options->state ) {
case 0:
$next = $this->createTables();
break;
case 1:
$next = $this->importTaxes();
break;
case 2:
$next = $this->importManufacturers();
break;
case 3:
$next = $this->importCategories();
break;
case 4:
$next = $this->importProducts();
break;
case 5:
$next = $this->importProductPrices();
break;
case 6:
$next = $this->importProductCategory();
break;
case 7:
$next = $this->importUsers();
break;
case 8:
$next = $this->importDiscount();
break;
case 9:
$next = $this->importOrders();
break;
case 10:
$next = $this->importOrderItems();
break;
case 11:
$next = $this->importDownloads();
break;
case 12:
$next = $this->importReviews();
break;
case 13:
$next = $this->finishImport();
$ret = false;
break;
case 14:
$next = false;
$ret = $this->proposeReImport();
break;
default:
$ret = false;
break;
}
if( $ret && $next ) {
$sql = "UPDATE `#__hikashop_config` SET
config_value=(config_value+1) WHERE config_namekey =
'vm_import_state'; ";
$this->db->setQuery($sql);
$this->db->execute();
$sql = "UPDATE `#__hikashop_config` SET config_value=0 WHERE
config_namekey = 'vm_import_current';";
$this->db->setQuery($sql);
$this->db->execute();
} else if( $current != $this->options->current ) {
$sql = "UPDATE `#__hikashop_config` SET
config_value=".$this->options->current." WHERE
config_namekey = 'vm_import_current';";
$this->db->setQuery($sql);
$this->db->execute();
}
return $ret;
}
function loadConfiguration()
{
if( $this->db == null )
return false;
$this->loadVmConfigs();
$data = array(
'uploadfolder',
'uploadsecurefolder',
'main_currency',
'vm_import_state',
'vm_import_current',
'vm_import_tax_id',
'vm_import_main_cat_id',
'vm_import_max_hk_cat',
'vm_import_max_hk_prod',
'vm_import_last_vm_cat',
'vm_import_last_vm_prod',
'vm_import_last_vm_user',
'vm_import_last_vm_order',
'vm_import_last_vm_pfile',
'vm_import_last_vm_coupon',
'vm_import_last_vm_taxrate',
'vm_import_last_vm_manufacturer',
'vm_import_last_vm_review'
);
$this->db->setQuery('SELECT config_namekey, config_value FROM
`#__hikashop_config` WHERE config_namekey IN
('."'".implode("','",$data)."'".');');
$options = $this->db->loadObjectList();
$this->options = new stdClass();
if (!empty($options))
{
foreach($options as $o) {
if( substr($o->config_namekey, 0, 10) == 'vm_import_' ) {
$nk = substr($o->config_namekey, 10);
} else {
$nk = $o->config_namekey;
}
$this->options->$nk = $o->config_value;
}
}
$this->options->uploadfolder =
rtrim(JPath::clean(html_entity_decode($this->options->uploadfolder)),DS.'
').DS;
if(!preg_match('#^([A-Z]:)?/.*#',$this->options->uploadfolder)){
if(!$this->options->uploadfolder[0]=='/' ||
!is_dir($this->options->uploadfolder)){
$this->options->uploadfolder =
JPath::clean(HIKASHOP_ROOT.DS.trim($this->options->uploadfolder,DS.'
').DS);
}
}
$this->options->uploadsecurefolder =
rtrim(JPath::clean(html_entity_decode($this->options->uploadsecurefolder)),DS.'
').DS;
if(!preg_match('#^([A-Z]:)?/.*#',$this->options->uploadsecurefolder)){
if(!$this->options->uploadsecurefolder[0]=='/' ||
!is_dir($this->options->uploadsecurefolder)){
$this->options->uploadsecurefolder =
JPath::clean(HIKASHOP_ROOT.DS.trim($this->options->uploadsecurefolder,DS.'
').DS);
}
}
if( !isset($this->options->state) ) {
$this->options->state = 0;
$this->options->current = 0;
$this->options->tax_id = 0;
$this->options->last_vm_coupon = 0;
$this->options->last_vm_pfile = 0;
$this->options->last_vm_taxrate = 0;
$this->options->last_vm_manufacturer = 0;
$this->options->last_vm_review = 0;
$element = 'product';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$this->options->main_cat_id = $element;
$this->db->setQuery("SELECT max(category_id) as
'max' FROM `#__hikashop_category`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(product_id) as
'max' FROM `#__hikashop_product`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_prod = (int)($data[0]->max);
$query='SHOW TABLES LIKE
'.$this->db->Quote($this->db->getPrefix().substr(hikashop_table('vm_cat'),3));
$this->db->setQuery($query);
$table = $this->db->loadResult();
if(!empty($table)){
$this->db->setQuery("SELECT max(vm_id) as 'max'
FROM `#__hikashop_vm_cat`;");
$data = $this->db->loadObjectList();
if( $data ) {
$this->options->last_vm_cat = (int)($data[0]->max);
} else {
$this->options->last_vm_cat = 0;
}
$this->db->setQuery("SELECT max(vm_id) as 'max'
FROM `#__hikashop_vm_prod`;");
$data = $this->db->loadObjectList();
if( $data ) {
$this->options->last_vm_prod = (int)($data[0]->max);
} else {
$this->options->last_vm_prod = 0;
}
$this->db->setQuery("SELECT max(order_vm_id) as
'max' FROM `#__hikashop_order`;");
$data = $this->db->loadObjectList();
$this->options->last_vm_order = (int)($data[0]->max);
}else{
$this->options->last_vm_cat = 0;
$this->options->last_vm_prod = 0;
$this->options->last_vm_order = 0;
}
$this->options->last_vm_user = 0;
$sql = 'INSERT IGNORE INTO `#__hikashop_config`
(`config_namekey`,`config_value`,`config_default`) VALUES '.
"('vm_import_state',".$this->options->state.",".$this->options->state.")".
",('vm_import_current',".$this->options->current.",".$this->options->current.")".
",('vm_import_tax_id',".$this->options->tax_id.",".$this->options->tax_id.")".
",('vm_import_main_cat_id',".$this->options->main_cat_id.",".$this->options->main_cat_id.")".
",('vm_import_max_hk_cat',".$this->options->max_hk_cat.",".$this->options->max_hk_cat.")".
",('vm_import_max_hk_prod',".$this->options->max_hk_prod.",".$this->options->max_hk_prod.")".
",('vm_import_last_vm_cat',".$this->options->last_vm_cat.",".$this->options->last_vm_cat.")".
",('vm_import_last_vm_prod',".$this->options->last_vm_prod.",".$this->options->last_vm_prod.")".
",('vm_import_last_vm_user',".$this->options->last_vm_user.",".$this->options->last_vm_user.")".
",('vm_import_last_vm_order',".$this->options->last_vm_order.",".$this->options->last_vm_order.")".
",('vm_import_last_vm_pfile',".$this->options->last_vm_pfile.",".$this->options->last_vm_pfile.")".
",('vm_import_last_vm_coupon',".$this->options->last_vm_coupon.",".$this->options->last_vm_coupon.")".
",('vm_import_last_vm_taxrate',".$this->options->last_vm_taxrate.",".$this->options->last_vm_taxrate.")".
",('vm_import_last_vm_manufacturer',".$this->options->last_vm_manufacturer.",".$this->options->last_vm_manufacturer.")".
",('vm_import_last_vm_review',".$this->options->last_vm_review.",".$this->options->last_vm_review.")".
';';
$this->db->setQuery($sql);
$this->db->execute();
}
}
function loadVmConfigs()
{
$configstring = '';
$this->db->setQuery('SELECT config FROM
`'.$this->vmprefix.'virtuemart_configs`;');
$data = $this->db->loadObjectList();
$configstring = $data[0]->config;
$paths = $this->parseConfig($configstring);
foreach ($paths as $key => $value)
{
switch ($key)
{
case 'media_category_path' :
$this->copyCatImgDir = HIKASHOP_ROOT.$value;
break;
case 'media_product_path' :
$this->copyImgDir = HIKASHOP_ROOT.$value;
$this->copyImgValue = $value;
break;
case 'media_manufacturer_path' :
$this->copyManufDir = HIKASHOP_ROOT.$value;
break;
default :
break;
}
}
}
function parseConfig($string)
{
$arraypath = array(
'media_category_path',
'media_product_path',
'media_manufacturer_path'
);
$paths =array();
$firstparse = explode('|', $string);
foreach ($firstparse as $fp)
{
$secondparse = explode('=', $fp);
if (in_array($secondparse[0],$arraypath))
{
$thirdparse = explode('"', $secondparse[1]);
$paths[$secondparse[0]] = $thirdparse[1];
}
}
return $paths;
}
function finishImport()
{
if( $this->db == null )
return false;
$this->db->setQuery("SELECT max(category_id) as
'max' FROM `#__hikashop_category`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(product_id) as 'max'
FROM `#__hikashop_product`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_prod = (int)($data[0]->max);
$this->db->setQuery("SELECT max(vm_id) as 'max' FROM
`#__hikashop_vm_cat`;");
$data = $this->db->loadObjectList();
$this->options->last_vm_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(vm_id) as 'max' FROM
`#__hikashop_vm_prod`;");
$data = $this->db->loadObjectList();
$this->options->last_vm_prod = (int)($data[0]->max);
$this->db->setQuery("SELECT max(virtuemart_user_id) as
'max' FROM
`".$this->vmprefix."virtuemart_userinfos`;");
$data = $this->db->loadObjectList();
$this->options->last_vm_user = (int)($data[0]->max);
$this->db->setQuery("SELECT max(order_vm_id) as
'max' FROM `#__hikashop_order`;");
$data = $this->db->loadObjectList();
$this->options->last_vm_order = (int)($data[0]->max);
$this->db->setQuery("SELECT max(vmpm.virtuemart_media_id) as
'max' FROM `".$this->vmprefix."virtuemart_products`
vmp INNER JOIN `".$this->vmprefix."virtuemart_product_medias`
vmpm ON vmp.virtuemart_product_id = vmpm.virtuemart_product_id INNER JOIN
`".$this->vmprefix."virtuemart_medias` vmm ON
vmpm.virtuemart_media_id = vmm.virtuemart_media_id;");
$data = $this->db->loadObject();
$this->options->last_vm_pfile = (int)($data->max);
$this->db->setQuery("SELECT max(virtuemart_coupon_id) as
'max' FROM
`".$this->vmprefix."virtuemart_coupons`;");
$data = $this->db->loadObject();
$this->options->last_vm_coupon = (int)($data->max);
$this->db->setQuery("SELECT max(virtuemart_calc_id) as
'max' FROM
`".$this->vmprefix."virtuemart_calcs`;");
$data = $this->db->loadObject();
$this->options->last_vm_taxrate = (int)($data->max);
$this->db->setQuery("SELECT max(virtuemart_manufacturer_id) as
'max' FROM
`".$this->vmprefix."virtuemart_manufacturers`;");
$data = $this->db->loadObjectList();
$this->options->last_vm_manufacturer = (int)($data[0]->max);
$this->db->setQuery("SELECT max(virtuemart_rating_review_id)
as 'max' FROM
`".$this->vmprefix."virtuemart_rating_reviews`;");
$data = $this->db->loadObject();
$this->options->last_vm_review = (int)($data->max);
$this->options->state = 14;
$query = 'REPLACE INTO `#__hikashop_config`
(`config_namekey`,`config_value`,`config_default`) VALUES '.
"('vm_import_state',".$this->options->state.",".$this->options->state.")".
",('vm_import_max_hk_cat',".$this->options->max_hk_cat.",".$this->options->max_hk_cat.")".
",('vm_import_max_hk_prod',".$this->options->max_hk_prod.",".$this->options->max_hk_prod.")".
",('vm_import_last_vm_cat',".$this->options->last_vm_cat.",".$this->options->last_vm_cat.")".
",('vm_import_last_vm_prod',".$this->options->last_vm_prod.",".$this->options->last_vm_prod.")".
",('vm_import_last_vm_user',".$this->options->last_vm_user.",".$this->options->last_vm_user.")".
",('vm_import_last_vm_order',".$this->options->last_vm_order.",".$this->options->last_vm_order.")".
",('vm_import_last_vm_pfile',".$this->options->last_vm_pfile.",".$this->options->last_vm_pfile.")".
",('vm_import_last_vm_coupon',".$this->options->last_vm_coupon.",".$this->options->last_vm_coupon.")".
",('vm_import_last_vm_taxrate',".$this->options->last_vm_taxrate.",".$this->options->last_vm_taxrate.")".
",('vm_import_last_vm_manufacturer',".$this->options->last_vm_manufacturer.",".$this->options->last_vm_manufacturer.")".
",('vm_import_last_vm_review',".$this->options->last_vm_review.",".$this->options->last_vm_review.")".
';';
$this->db->setQuery($query);
$this->db->execute();
$this->checkCategories();
echo '<p'.$this->titlefont.'>Import finished
!</p>';
$class = hikashop_get('class.plugins');
$infos =
$class->getByName('system','vm_redirect');
if($infos){
$pkey = reset($class->pkeys);
if(!empty($infos->$pkey)){
$url =
JRoute::_('index.php?option=com_plugins&view=plugin&layout=edit&extension_id='.$infos->$pkey);
echo '<p>You can publish the
<a'.$this->linkstyle.'
href="'.$url.'">VirtueMart Fallback Redirect
Plugin</a> so that your old VirtueMart links are automatically
redirected to HikaShop pages and thus not loose the ranking of your content
on search engines.</p>';
}
}
$databaseHelper = hikashop_get('helper.database');
$databaseHelper->checkdb();
}
function createTables()
{
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
1 :</span>Â Initialization Tables</p>';
$query='SHOW TABLES LIKE
'.$this->db->Quote($this->db->getPrefix().substr(hikashop_table('vm_cat'),3));
$this->db->setQuery($query);
$table = $this->db->loadResult();
if( empty($table) )
{
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_vm_prod` (`vm_id` int(10) unsigned NOT NULL DEFAULT
'0', `hk_id` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`vm_id`)) ENGINE=MyISAM");
$this->db->execute();
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_vm_cat` (`vm_id` int(10) unsigned NOT NULL DEFAULT
'0', `hk_id` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`vm_id`)) ENGINE=MyISAM");
$this->db->execute();
$databaseHelper = hikashop_get('helper.database');
$databaseHelper->addColumns('address','`address_vm_order_info_id`
INT(11) NULL');
$databaseHelper->addColumns('order','`order_vm_id`
INT(11) NULL');
$databaseHelper->addColumns('order','INDEX (
`order_vm_id` )');
$databaseHelper->addColumns('taxation','`tax_vm_id`
INT(11) NULL');
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
All table created</p>';
}
else
{
echo '<p>Tables have been already created.</p>';
}
$this->addVirtuemartCategoryLevel();
$vm_childs = array();
$this->addVirtuemartCategoryLevelcolumn(1,$vm_childs);
return true;
}
function importTaxes()
{
if( $this->db == null )
return false;
$ret = false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
2 :</span>Â Import Taxes<p>';
$buffTable=$this->vmprefix."virtuemart_calcs";
$data = array(
'tax_namekey' => "CONCAT('VM_TAX_',
vmtr.virtuemart_calc_id)",
'tax_rate' => 'vmtr.calc_value / 100'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_tax`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$buffTable.'` AS vmtr '.
'WHERE vmtr.virtuemart_calc_id > ' .
(int)$this->options->last_vm_taxrate;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported taxes: ' . $total . '</p>';
$element = 'tax';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$data = array(
'category_type' => "'tax'",
'category_name' => "case when vmcs.country_name IS
NULL then 'Tax imported (no country)' else CONCAT('Tax
imported (', vmcs.country_name,')') end",
'category_published' => '1',
'category_parent_id' => $element,
'category_namekey' => "case when hkz.zone_id IS NULL
then CONCAT('VM_TAX_', vmtr.virtuemart_calc_id,'_0')
else CONCAT('VM_TAX_',
vmtr.virtuemart_calc_id,'_',hkz.zone_id) end",
);
$sql = 'INSERT IGNORE INTO `#__hikashop_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$this->vmprefix.'virtuemart_calcs` vmtr '.
"LEFT JOIN
`".$this->vmprefix."virtuemart_calc_countries` vmcc ON
vmtr.virtuemart_calc_id = vmcc.virtuemart_calc_id " .
"LEFT JOIN `".$this->vmprefix."virtuemart_countries`
vmcs ON vmcc.virtuemart_country_id = vmcs.virtuemart_country_id ".
"LEFT JOIN `#__hikashop_zone` hkz ON vmcs.country_3_code =
hkz.zone_code_3 AND hkz.zone_type = 'country' ".
"WHERE vmtr.virtuemart_calc_id >" .
$this->options->last_vm_taxrate;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Taxes Categories: ' . $total . '</p>';
if( $total > 0 ) {
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'vm_import_max_hk_cat'; ");
$this->db->execute();
$this->importRebuildTree();
}
$data = array(
'zone_namekey' => "case when hkz.zone_namekey IS NULL
then '' else hkz.zone_namekey end",
'category_namekey' => "case when hkz.zone_id IS NULL
then CONCAT('VM_TAX_', vmtr.virtuemart_calc_id,'_0')
else CONCAT('VM_TAX_',
vmtr.virtuemart_calc_id,'_',hkz.zone_id) end",
'tax_namekey' => "CONCAT('VM_TAX_',
vmtr.virtuemart_calc_id)",
'taxation_published' => '1',
'taxation_type' => "''",
'tax_vm_id' => 'vmtr.virtuemart_calc_id'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_taxation`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$this->vmprefix.'virtuemart_calcs` vmtr '.
"LEFT JOIN
`".$this->vmprefix."virtuemart_calc_countries` vmcc ON
vmtr.virtuemart_calc_id = vmcc.virtuemart_calc_id " .
"LEFT JOIN `".$this->vmprefix."virtuemart_countries`
vmcs ON vmcc.virtuemart_country_id = vmcs.virtuemart_country_id ".
"LEFT JOIN `".$this->vmprefix."hikashop_zone` hkz ON
vmcs.country_3_code = hkz.zone_code_3 AND hkz.zone_type =
'country' ".
"WHERE vmtr.virtuemart_calc_id >" .
$this->options->last_vm_taxrate;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Taxations: ' . $total . '</p>';
$ret = true;
return $ret;
}
function importManufacturers() {
if( $this->db == null )
return false;
$ret = false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
3 :</span>Â Import Manufacturers</p>';
$element = 'manufacturer';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$buffTable=$this->vmprefix."virtuemart_manufacturers_".$this->vm_current_lng;
$data = array(
'category_type' => "'manufacturer'",
'category_name' => "vmm.mf_name ",
'category_published' => '1',
'category_parent_id' => $element,
'category_namekey' => "CONCAT('VM_MANUFAC_',
vmm.virtuemart_manufacturer_id )",
'category_description' => 'vmm.mf_desc',
'category_menu' =>
'vmm.virtuemart_manufacturer_id'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$buffTable.'` vmm '.
'WHERE vmm.virtuemart_manufacturer_id > ' .
(int)$this->options->last_vm_manufacturer;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Manufacturers : ' . $total . '</p>';
if( $total > 0 )
{
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'vm_import_max_hk_cat'; ");
$this->db->execute();
$this->importRebuildTree();
}
$ret = true;
return $ret;
}
function importCategories()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
4 :</span>Â Import General Categories</p>';
if( $this->db == null )
return false;
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$rebuild = false;
$ret = false;
$offset = $this->options->current;
$count = 100;
$max = 0;
$statuses = array(
'P' => 'created',
'C' => 'confirmed',
'X' => 'cancelled',
'R'=> 'refunded' ,
'S' => 'shipped'
);
$this->db->setQuery("SELECT category_keywords,
category_parent_id FROM `#__hikashop_category` WHERE category_type =
'status' AND category_name = 'confirmed'");
$data = $this->db->loadObject();
$status_category = $data->category_parent_id;
if( $data->category_keywords != 'C' ) {
foreach($statuses as $k => $v) {
$this->db->setQuery("UPDATE `#__hikashop_category` SET
category_keywords = '".$k."' WHERE category_type =
'status' AND category_name = '".$v."';
");
$this->db->execute();
}
}
$this->db->setQuery("SELECT order_status_code,
order_status_name, order_status_description FROM
`".$this->vmprefix."virtuemart_orderstates` WHERE
order_status_name NOT IN
('".implode("','",$statuses)."');");
$data = $this->db->loadObjectList();
if( count($data) > 0 )
{
$sql0 = 'INSERT IGNORE INTO `#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_description`,`category_published`,'.
'`category_namekey`,`category_access`,`category_menu`,`category_keywords`)
VALUES ';
$sql1 = 'INSERT IGNORE INTO `#__hikashop_orderstatus`
(`orderstatus_name`,`orderstatus_description`,`orderstatus_published`,`orderstatus_namekey`)
VALUES ';
$id = $this->options->max_hk_cat + 1;
$sep = '';
foreach($data as $c) {
$d = array(
$id++,
$status_category,
"'status'",
$this->db->Quote(strtolower(JText::_($c->order_status_name))),
$this->db->Quote( $c->order_status_description ),
'1',
$this->db->Quote('status_vm_import_'.strtolower(str_replace('
','_',JText::_($c->order_status_name)))),
"'all'",
'0',
$this->db->Quote( $c->order_status_code )
);
$d1 = array(
$this->db->Quote(strtolower(JText::_($c->order_status_name))),
$this->db->Quote( $c->order_status_description ),
'1',
$this->db->Quote('status_vm_import_'.strtolower(str_replace('
','_',JText::_($c->order_status_name)))),
);
$sql0 .= $sep.'('.implode(',',$d).')';
unset($d);
$sql1 .= $sep.'('.implode(',',$d1).')';
unset($d1);
$sep = ',';
}
$this->db->setQuery($sql0);
$this->db->execute();
$total = $this->db->getAffectedRows();
$this->db->setQuery($sql1);
$this->db->execute();
if( $total > 0 )
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported order status categories : ' . $total .
'</p>';
$rebuild = true;
$this->options->max_hk_cat = $id;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'vm_import_max_hk_cat'; ");
$this->db->execute();
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported order status categories : 0</p>';
}
$sql0 = '';
$sql1 = '';
}
$buffTable=$this->vmprefix."virtuemart_categories_".$this->vm_current_lng;
$this->db->setQuery('SELECT *, vmc.virtuemart_category_id as
vmid, hkvm.vm_id as vm_cat_id, vmcc.category_parent_id as vm_parent_id FROM
`'.$this->vmprefix.'virtuemart_categories` vmc '.
"LEFT JOIN `".$buffTable."` vmceg ON
vmc.virtuemart_category_id = vmceg.virtuemart_category_id ".
"LEFT JOIN
`".$this->vmprefix."virtuemart_category_medias` vmcm ON
vmceg.virtuemart_category_id = vmcm.virtuemart_category_id ".
"LEFT JOIN `".$this->vmprefix."virtuemart_medias` vmm
ON vmcm.virtuemart_media_id = vmm.virtuemart_media_id ".
'LEFT JOIN
`'.$this->vmprefix.'virtuemart_category_categories` vmcc ON
vmceg.virtuemart_category_id = vmcc.category_child_id '.
'LEFT JOIN `#__hikashop_vm_cat` hkvm ON vmc.virtuemart_category_id
= hkvm.vm_id '.
'ORDER BY vmcc.level ASC, vmc.ordering ASC,
vmc.virtuemart_category_id ASC LIMIT '.(int)$offset.',
'.(int)$count.';');
$data = $this->db->loadObjectList();
$new_offset = $offset + count($data);
$total = count($data);
if( $total == 0 ) {
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported category : 0</p>';
if( $rebuild )
$this->importRebuildTree();
return true;
}
$sql0 = 'INSERT IGNORE INTO `#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_description`,`category_published`,'.
'`category_ordering`,`category_namekey`,`category_created`,`category_modified`,`category_access`,`category_menu`)
VALUES ';
$sql1 = 'INSERT IGNORE INTO `#__hikashop_vm_cat` (`vm_id`,`hk_id`)
VALUES ';
$sql2 = 'INSERT INTO `#__hikashop_file`
(`file_name`,`file_description`,`file_path`,`file_type`,`file_ref_id`)
VALUES ';
$doSql2 = false;
$doSql1 = false;
$i = $this->options->max_hk_cat + 1;
$ids = array( 0 => $this->options->main_cat_id);
$sep = '';
foreach($data as $c)
{
if( !empty($c->vm_cat_id) )
{
$ids[(int)$c->vmid] = $c->hk_id;
}
else
{
$doSql1 = true;
$ids[(int)$c->vmid] = $i;
$sql1 .=
$sep.'('.(int)$c->vmid.','.$i.')';
$i++;
$sep = ',';
}
}
$sql1 .= ';';
$sep = '';
$sep2 = '';
$doQuery = false;
$cat_ids = array();
foreach($data as $c)
{
if( !empty($c->vm_cat_id) )
continue;
$doQuery = true;
$id = $ids[(int)$c->vmid];
$pid = (int)$c->vm_parent_id;
$element = new stdClass();
$element->category_id = $id;
$element->category_parent_id = $pid; //See also category_parent_id
$element->category_name = $c->category_name;
$nameKey = $categoryClass->getNameKey($element);
$cat_ids[] = $id;
$d = array(
$id,
$pid,
"'product'",
$this->db->Quote($c->category_name),
$this->db->Quote($c->category_description),
'1',
(int)@$c->ordering,
$this->db->Quote($nameKey),
$this->db->Quote(strtotime($c->created_on)),
$this->db->Quote(strtotime($c->modified_on)),
"'all'",
'0'
);
$sql0 .= $sep.'('.implode(',',$d).')';
$result = false;
if(!empty($c->file_meta) ) {
$file_name =
str_replace('\\','/',$c->file_meta);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$result = $this->copyFile($this->copyCatImgDir,$c->file_meta,
$this->options->uploadfolder.$file_name);
if($result){
$sql2 .=
$sep2."('','',".$this->db->Quote($file_name).",'category',".$id.')';
$sep2 = ',';
$max = $c->virtuemart_category_id;
}
}
if(!$result && !empty($c->file_url)){
$file_name =
str_replace('\\','/',$c->file_url);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$result = $this->copyFile($this->copyCatImgDir,$c->file_url,
$this->options->uploadfolder.$file_name);
if($result) {
$sql2 .=
$sep2."('','',".$this->db->Quote($file_name).",'category',".$id.')';
$sep2 = ',';
$max = $c->virtuemart_category_id;
} else if(!empty($c->file_meta)) {
$file_name =
str_replace('\\','/',$c->file_meta);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$sql2 .=
$sep2."('','',".$this->db->Quote($file_name).",'category',".$id.')';
$sep2 = ',';
$max = $c->virtuemart_category_id;
}
}
if($result)
$doSql2 = true;
$sep = ',';
}
$sql0 .= ';';
if ($doQuery)
{
$this->db->setQuery($sql0);
$this->db->execute();
$total = $this->db->getAffectedRows();
}
else
$total = 0;
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Categories : ' . $total . '</p>';
if( isset($total) && $total > 0)
{
$rebuild = true;
$this->options->max_hk_cat += $total + 1;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'vm_import_max_hk_cat'; ");
$this->db->execute();
}
if ($doSql1)
{
$this->db->setQuery($sql1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links : ' . $total . '</p>';
$this->db->setQuery("UPDATE `#__hikashop_category` hkc,
`#__hikashop_vm_cat` hkvmc SET hkc.category_parent_id = hkvmc.hk_id WHERE
hkc.category_parent_id = hkvmc.vm_id AND hkc.category_id IN
(".implode(',',$cat_ids).") ");
$this->db->execute();
}
else
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links : 0</p>';
if( $doSql2 )
{
$sql2 .= ';';
$this->db->setQuery($sql2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Categories files : ' . $total . '</p>';
}
else
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Categories files : 0</p>';
if( $rebuild )
$this->importRebuildTree();
$this->options->current = $new_offset;
if( $max > 0 ) {
echo '<p>Copying files...(last proccessed product id: '
. $max . ')</p>';
$this->refreshPage = true;
return $ret;
}
$ret = true;
return $ret;
}
function addVirtuemartCategoryLevel(){
$this->db->setQuery('ALTER TABLE `'. $this->vmprefix
.'virtuemart_category_categories` ADD `level` INT(11)');
try{ $this->db->execute(); }catch(Exception $e){}
}
function addVirtuemartCategoryLevelcolumn($level, $childs = array()){
$level = (int)$level;
if((int)$level <= 0)
return;
if($level == 1)
$childs[] = 0;
if(empty($childs))
return;
$sql = 'UPDATE `'. $this->vmprefix
.'virtuemart_category_categories` '.
'SET level = '. (int)$level .
' WHERE category_parent_id IN
('."'".implode("','",$childs)."'".');';
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Total number of added levels through the
"virtuemart_category_categories" table : ' . $total .
'</p>';
$query = 'SELECT category_child_id FROM `'. $this->vmprefix
.'virtuemart_category_categories` ' .
'WHERE category_parent_id IN
('."'".implode("','",$childs)."'".');';
$this->db->setQuery($query);
$childArray = $this->db->loadRowList();
if(empty($childArray))
return;
$childs = array();
foreach($childArray as $child){
if(isset($child[0]))
$childs[] = $child[0];
}
$level++;
$this->addVirtuemartCategoryLevelcolumn($level, $childs);
}
function importProducts() {
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
5 :</span>Â Import Products</p>';
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$ret = false;
$count = 100;
$offset = (int)$this->options->current;
$max = 0;
$this->db->setQuery(
'SELECT MAX(pid) FROM ('.
' SELECT vmp.virtuemart_product_id as pid '.
' FROM `'.$this->vmprefix.'virtuemart_products` AS
vmp '.
' LEFT JOIN `#__hikashop_vm_prod` hkvm ON
vmp.virtuemart_product_id = hkvm.vm_id '.
' WHERE vmp.virtuemart_product_id > '.$offset.' AND
hkvm.hk_id IS NULL '.
' ORDER BY vmp.virtuemart_product_id ASC LIMIT '.$count.
') AS t;'
);
$maxOffset = (int)$this->db->loadResult();
$this->db->setQuery(
'SELECT vmp.virtuemart_product_id, vmm.file_meta, vmm.file_url,
vmm.file_title '.
'FROM `'.$this->vmprefix.'virtuemart_products` AS vmp
'.
"INNER JOIN
`".$this->vmprefix."virtuemart_product_medias` AS vmpm ON
vmp.virtuemart_product_id = vmpm.virtuemart_product_id ".
"INNER JOIN `".$this->vmprefix."virtuemart_medias` AS
vmm ON vmpm.virtuemart_media_id = vmm.virtuemart_media_id ".
'LEFT JOIN `#__hikashop_vm_prod` AS hkprod ON
vmp.virtuemart_product_id = hkprod.vm_id '.
'WHERE vmp.virtuemart_product_id > '.$offset.' AND
vmp.virtuemart_product_id <= '.$maxOffset.' AND hkprod.hk_id
IS NULL AND ('.
'(vmm.file_meta IS NOT NULL AND vmm.file_meta <>
\'\') OR vmm.file_url <> \'\''.
') '.
'ORDER BY vmp.virtuemart_product_id ASC;'
);
$data = $this->db->loadObjectList();
$meta_files = array();
if (!empty($data))
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying products images... </p>';
foreach($data as $c) {
$result = false;
if( !empty($c->file_meta) ) {
$file_name =
str_replace('\\','/',$c->file_meta);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$result = $this->copyFile($this->copyImgDir, $c->file_meta,
$this->options->uploadfolder.$file_name);
if($result){
$meta_files[] = $this->db->Quote($c->file_meta);
}
}
if(!$result && !empty($c->file_title) ) {
$file_name =
str_replace('\\','/',$c->file_title);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$file_title_ext = strtolower(substr($c->file_title, -4));
if(in_array($file_title_ext,
array('.jpg','.png','.gif')) ||
strtolower(substr($c->file_title, -5)) == '.jpeg')
$result = $this->copyFile($this->copyImgDir, $c->file_title,
$this->options->uploadfolder.$file_name);
if($result) {
$meta_files[] = $this->db->Quote($c->file_title);
}
}
if(!$result && !empty($c->file_url)) {
$file_name =
str_replace(array('\\/','\\'),array('/','/'),$c->file_url);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
if(strpos($this->copyImgValue, trim($c->file_url,
'/')) === 0)
$c->file_url = trim(substr(trim($c->file_url, '/'),
strlen($this->copyImgValue)), '/');
$result = $this->copyFile($this->copyImgDir, $c->file_url,
$this->options->uploadfolder.$file_name);
if(!$result && !empty($c->file_meta)) { //if we
couldn't copy the image from the file_url, we still add the image name
from file_meta and then the user can copy the files manually
$meta_files[] = $this->db->Quote($c->file_meta);
}
}
}
}
if(empty($meta_files) || !count($meta_files)){
$meta_files = "'##'";
} else {
$meta_files = implode(',',$meta_files);
}
$buffTable =
$this->vmprefix."virtuemart_products_".$this->vm_current_lng;
$data = array(
'product_name' => 'vmpeg.product_name',
'product_description' =>
"CONCAT(vmpeg.product_s_desc,'<hr
id=\"system-readmore\"/>',vmpeg.product_desc)",
'product_quantity' => 'case when vmp.product_in_stock
IS NULL or vmp.product_in_stock < 0 then 0 else vmp.product_in_stock
end',
'product_code' => 'case when vmp.product_sku IS NULL
or vmp.product_sku="" then MD5(vmp.virtuemart_product_id) else
vmp.product_sku end',
'product_published' => "vmp.published",
'product_hit' => '0',
'product_created' =>
"UNIX_TIMESTAMP(vmp.created_on)",
'product_modified' =>
'UNIX_TIMESTAMP(vmp.modified_on)',
'product_sale_start' =>
'UNIX_TIMESTAMP(vmp.product_available_date)',
'product_tax_id' => 'hkc.category_id',
'product_type' => "'main'",
'product_url' => 'vmp.product_url',
'product_weight' => 'vmp.product_weight',
'product_weight_unit' =>
"LOWER(vmp.product_weight_uom)",
'product_dimension_unit' =>
"LOWER(vmp.product_lwh_uom)",
'product_sales' => 'vmp.product_sales',
'product_width' => 'vmp.product_width',
'product_length' => 'vmp.product_length',
'product_height' => 'vmp.product_height',
);
$sql1 = 'INSERT IGNORE INTO `#__hikashop_product`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->vmprefix.'virtuemart_products` AS vmp '.
'INNER JOIN `'.$buffTable.'` vmpeg ON
vmp.virtuemart_product_id = vmpeg.virtuemart_product_id '.
'LEFT JOIN
`'.$this->vmprefix.'virtuemart_product_prices` vmpp ON
vmpeg.virtuemart_product_id = vmpp.virtuemart_product_id '.
'LEFT JOIN `#__hikashop_taxation` hkt ON (hkt.tax_vm_id =
vmpp.product_tax_id OR (hkt.tax_vm_id = 0 AND vmpp.product_tax_id =
'.(int)@$this->options->tax_id.')) '.
'LEFT JOIN `#__hikashop_category` hkc ON hkc.category_namekey =
hkt.category_namekey '.
'LEFT JOIN `#__hikashop_vm_prod` AS hkp ON
vmp.virtuemart_product_id = hkp.vm_id '.
'WHERE hkp.hk_id IS NULL AND vmp.virtuemart_product_id >
'.$offset.' '.
'GROUP BY vmp.virtuemart_product_id '.
'ORDER BY vmp.virtuemart_product_id ASC LIMIT
'.$count.';';
$data = array(
'vm_id' => 'vmp.virtuemart_product_id',
'hk_id' => 'hkp.product_id'
);
$sql2 = 'INSERT IGNORE INTO `#__hikashop_vm_prod`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->vmprefix.'virtuemart_products` AS vmp '.
'INNER JOIN `#__hikashop_product` AS hkp ON CONVERT(vmp.product_sku
USING utf8) = CONVERT(hkp.product_code USING utf8) '.
'LEFT JOIN `#__hikashop_vm_prod` hkvm ON vmp.virtuemart_product_id
= hkvm.vm_id '.
'WHERE hkvm.hk_id IS NULL AND vmp.virtuemart_product_id >
'.$offset.' '.
'ORDER BY vmp.virtuemart_product_id ASC LIMIT
'.$count.';';
$sql3 = 'UPDATE `#__hikashop_product` AS hkp '.
'INNER JOIN `'.$this->vmprefix.'virtuemart_products`
AS vmp ON CONVERT(vmp.product_sku USING utf8) = CONVERT(hkp.product_code
USING utf8) '.
'INNER JOIN `#__hikashop_vm_prod` AS hkvm ON vmp.product_parent_id
= hkvm.vm_id '.
'SET hkp.product_parent_id = hkvm.hk_id;';
$data = array(
'file_name' => "''",
'file_description' => "''",
'file_path' =>
"SUBSTRING_INDEX(vmm.file_url,'/',-1)",
'file_type' => "'product'",
'file_ref_id' => 'hkvm.hk_id'
);
$sql4 = 'INSERT IGNORE INTO `#__hikashop_file`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->vmprefix.'virtuemart_products` AS vmp '.
"INNER JOIN `#__hikashop_vm_prod` AS hkvm ON
vmp.virtuemart_product_id = hkvm.vm_id ".
"INNER JOIN
`".$this->vmprefix."virtuemart_product_medias` vmpm ON
hkvm.vm_id = vmpm.virtuemart_product_id ".
"INNER JOIN `".$this->vmprefix."virtuemart_medias` vmm
ON vmpm.virtuemart_media_id = vmm.virtuemart_media_id ".
'WHERE vmp.virtuemart_product_id > '.$offset." AND
(vmm.file_meta <> '' OR vmm.file_url <>
'')".
'ORDER BY vmp.virtuemart_product_id ASC;';
$sql5 = 'UPDATE `#__hikashop_product` AS hkp '.
'INNER JOIN `#__hikashop_vm_prod` AS hkvm ON hkp.product_id =
hkvm.hk_id '.
'INNER JOIN
`'.$this->vmprefix.'virtuemart_product_manufacturers` AS vmpm
ON vmpm.virtuemart_product_id = hkvm.vm_id '.
"INNER JOIN `#__hikashop_category` AS hkc ON hkc.category_type =
'manufacturer' AND vmpm.virtuemart_manufacturer_id =
hkc.category_menu ".
'SET hkp.product_manufacturer_id = hkc.category_id '.
'WHERE vmpm.virtuemart_manufacturer_id >
'.$this->options->last_vm_manufacturer.' OR
vmpm.virtuemart_product_id > '.$offset.';';
$this->db->setQuery($sql1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products: ' . $total . '</p>';
$this->db->setQuery($sql2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links: ' . $total . '</p>';
$this->db->setQuery('SELECT MAX(vm_id) FROM
`#__hikashop_vm_prod`');
$this->db->execute();
$max = (int)$this->db->loadResult();
$this->db->setQuery($sql3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating products for parent links: ' . $total .
'</p>';
$this->db->setQuery($sql4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products files: ' . $total . '</p>';
$this->db->setQuery($sql5);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating products manufacturers: ' . $total . '</p>';
if( $max > 0 && $max > $offset) {
echo '<p>Copying files...(last proccessed product id: '
. $max . ')</p>';
$this->options->current = $max;
$this->refreshPage = true;
return $ret;
}
$ret = true;
return $ret;
}
function importProductPrices()
{
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
6 :</span>Â Import Product Prices</p>';
$ret = false;
$cpt = 0;
$this->db->setQuery('INSERT IGNORE INTO #__hikashop_price
(`price_product_id`,`price_value`,`price_currency_id`,`price_min_quantity`,`price_access`)
'
.'SELECT hkprod.hk_Id, product_price, hkcur.currency_id,
price_quantity_start, \'all\' '
.'FROM '.$this->vmprefix.'virtuemart_product_prices
vmpp '
.'INNER JOIN #__hikashop_vm_prod hkprod ON
vmpp.virtuemart_product_id = hkprod.vm_id '
.'INNER JOIN '.$this->vmprefix.'virtuemart_currencies
vmc ON vmpp.product_currency = vmc.virtuemart_currency_id '
.'INNER JOIN #__hikashop_currency hkcur ON
CONVERT(vmc.currency_code_3 USING utf8) = CONVERT( hkcur.currency_code
USING utf8) '
.'WHERE vmpp.virtuemart_product_id > ' .
(int)$this->options->last_vm_prod
);
$ret = $this->db->execute();
$cpt = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Prices imported : ' . $cpt .'</p>';
return $ret;
}
function importProductCategory()
{
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
7 :</span>Â Import Product Category</p>';
$data = array(
'category_id' => 'vmc.hk_id',
'product_id' => 'vmp.hk_id',
'ordering' => '`product_list`',
);
$data['ordering'] = '`ordering`';
$sql = 'INSERT IGNORE INTO `#__hikashop_product_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$this->vmprefix.'virtuemart_product_categories` vmpc
'.
'INNER JOIN #__hikashop_vm_cat vmc ON vmpc.virtuemart_category_id =
vmc.vm_id '.
'INNER JOIN #__hikashop_vm_prod vmp ON vmpc.virtuemart_product_id =
vmp.vm_id '.
'WHERE vmp.vm_id > ' .
(int)$this->options->last_vm_prod . ' OR vmc.vm_id > ' .
(int)$this->options->last_vm_cat;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products categories: ' . $total . '</p>';
return true;
}
function importUsers()
{
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
8 :</span>Â Import Users</p>';
$ret = false;
$sql0 = 'INSERT IGNORE INTO `#__hikashop_user`
(`user_cms_id`,`user_email`) '.
'SELECT u.id, u.email FROM
`'.$this->vmprefix.'virtuemart_userinfos` vmui INNER JOIN
`#__users` u ON vmui.virtuemart_user_id = u.id '. //?
'LEFT JOIN `#__hikashop_user` AS hkusr ON vmui.virtuemart_user_id
= hkusr.user_cms_id '.
'WHERE hkusr.user_cms_id IS NULL;';
$data = array(
'address_user_id' => 'hku.user_id',
'address_firstname' => 'vmui.first_name',
'address_middle_name' => 'vmui.middle_name',
'address_lastname' => 'vmui.last_name',
'address_company' => 'vmui.company',
'address_street' => 'CONCAT(vmui.address_1,\'
\',vmui.address_2)',
'address_post_code' => 'vmui.zip',
'address_city' => 'vmui.city',
'address_telephone' => 'vmui.phone_1',
'address_telephone2' => 'vmui.phone_2',
'address_fax' => 'vmui.fax',
'address_state' => 'vmui.state',
'address_country' => 'vmui.country',
'address_published' => 4
);
$data['address_state'] = 'vms.state_3_code';
$data['address_country'] = 'vmc.country_3_code';
$sql1 = 'INSERT IGNORE INTO `#__hikashop_address`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->vmprefix.'virtuemart_userinfos` AS vmui '.
"LEFT JOIN `".$this->vmprefix."virtuemart_states` vms
ON vmui.virtuemart_state_id = vms.virtuemart_state_id ".
"LEFT JOIN `".$this->vmprefix."virtuemart_countries`
vmc ON vmui.virtuemart_country_id = vmc.virtuemart_country_id ".
'INNER JOIN `#__hikashop_user` AS hku ON vmui.virtuemart_user_id =
hku.user_cms_id '.
'WHERE vmui.virtuemart_user_id >
'.$this->options->last_vm_user.' ORDER BY
vmui.virtuemart_user_id ASC;';
$sql2 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone` AS hkz ON (a.address_country =
hkz.zone_code_3 AND hkz.zone_type = "country") '.
'SET address_country = hkz.zone_namekey, address_published = 3
WHERE address_published = 4;';
$sql3 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone_link` AS zl ON (a.address_country =
zl.zone_parent_namekey) '.
'JOIN `#__hikashop_zone` AS hks ON (hks.zone_namekey =
zl.zone_child_namekey AND hks.zone_type = "state" AND
hks.zone_code_3 = a.address_state) '.
'SET address_state = hks.zone_namekey, address_published = 2 WHERE
address_published = 3;';
$sql4 = "UPDATE `#__hikashop_address` AS a SET a.address_country =
'' WHERE address_published > 3;";
$sql5 = "UPDATE `#__hikashop_address` AS a SET a.address_state =
'' WHERE address_published > 2;";
$sql6 = 'UPDATE `#__hikashop_address` AS a SET a.address_published =
1 WHERE address_published > 1;';
$this->db->setQuery($sql0);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Users: ' . $total . '</p>';
$this->db->setQuery($sql1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses: ' . $total . '</p>';
$this->db->setQuery($sql2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses countries: ' . $total . '</p>';
$this->db->setQuery($sql3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses states: ' . $total . '</p>';
$this->db->setQuery($sql4);
$this->db->execute();
$this->db->setQuery($sql5);
$this->db->execute();
$this->db->setQuery($sql6);
$this->db->execute();
$ret = true;
return $ret;
}
function importOrders()
{
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
10 :</span>Â Import Orders</p>';
$ret = false;
$offset = $this->options->current;
$count = 100;
$total = 0;
$guest = 0;
$this->db->setQuery("SELECT name FROM
`".$this->vmprefix."virtuemart_userfields` WHERE name =
'tax_exemption_number' AND published = 1");
$vat_cols = $this->db->loadObjectList();
if( isset($vat_cols) && $vat_cols !== null &&
is_array($vat_cols) && count($vat_cols)>0)
$vat_cols = 'vmui.' . $vat_cols[0]->name;
else
$vat_cols = "''";
$data = array(
'order_number' => 'vmo.order_number',
'order_vm_id' => 'vmo.virtuemart_order_id',
'order_user_id' => 'hkusr.user_id',
'order_status' => 'hkc.category_name',
'order_discount_code' => 'vmo.coupon_code',
'order_discount_price' => 'vmo.coupon_discount',
'order_created' =>
'UNIX_TIMESTAMP(vmo.created_on)',
'order_ip' => 'vmo.ip_address',
'order_currency_id' => 'hkcur.currency_id',
'order_shipping_price' => 'vmo.order_shipment',
'order_shipping_method' => "'vm
import'",
'order_shipping_id' => '1',
'order_payment_id' => 0,
'order_payment_method' => "'vm
import'",
'order_full_price' => 'vmo.order_total',
'order_modified' =>
'UNIX_TIMESTAMP(vmo.modified_on)',
'order_partner_id' => 0,
'order_partner_price' => 0,
'order_partner_paid' => 0,
'order_type' => "'sale'",
'order_partner_currency_id' => 0,
'order_shipping_tax' =>
'vmo.order_shipment_tax',
'order_discount_tax' => 0
);
$sql1 = 'INSERT IGNORE INTO `#__hikashop_order`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->vmprefix.'virtuemart_orders` AS vmo '.
'INNER JOIN `'.$this->vmprefix.'virtuemart_currencies`
vmc ON vmo.order_currency = vmc.virtuemart_currency_id '.
'INNER JOIN `#__hikashop_currency` hkcur ON
CONVERT(vmc.currency_code_3 USING utf8) = CONVERT( hkcur.currency_code
USING utf8) '. //needed ?
'LEFT JOIN `'.$this->vmprefix.'virtuemart_orderstates`
AS vmos ON vmo.order_status = vmos.order_status_code '.
'LEFT JOIN `#__hikashop_category` AS hkc ON vmos.order_status_name
= hkc.category_name AND hkc.category_type = \'status\' '.
//No U founded
'LEFT JOIN `#__hikashop_user` AS hkusr ON vmo.virtuemart_user_id =
hkusr.user_cms_id '.
'WHERE vmo.virtuemart_order_id > ' .
(int)$this->options->last_vm_order . ' '.
'GROUP BY vmo.virtuemart_order_id '.
'ORDER BY vmo.virtuemart_order_id ASC;';
$data = array(
'address_user_id' => 'hkusr.user_id',
'address_firstname' => 'vmui.first_name',
'address_middle_name' => 'vmui.middle_name',
'address_lastname' => 'vmui.last_name',
'address_company' => 'vmui.company',
'address_street' => "CONCAT(vmui.address_1,'
',vmui.address_2)",
'address_post_code' => 'vmui.zip',
'address_city' => 'vmui.city',
'address_telephone' => 'vmui.phone_1',
'address_telephone2' => 'vmui.phone_2',
'address_fax' => 'vmui.fax',
'address_state' => 'vms.state_3_code',
'address_country' => 'vmc.country_3_code',
'address_published' => "case when vmui.address_type =
'BT' then 7 else 8 end",
'address_vat' => $vat_cols,
'address_vm_order_info_id' =>
'vmui.virtuemart_order_id'
);
$sql2_1 = 'INSERT IGNORE INTO `#__hikashop_address`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->vmprefix.'virtuemart_order_userinfos` AS vmui
'.
"INNER JOIN `".$this->vmprefix."virtuemart_states` vms
ON vmui.virtuemart_state_id = vms.virtuemart_state_id ".
"INNER JOIN `".$this->vmprefix."virtuemart_countries`
vmc ON vmui.virtuemart_country_id = vmc.virtuemart_country_id ".
'LEFT JOIN `#__hikashop_user` AS hkusr ON vmui.virtuemart_user_id =
hkusr.user_cms_id '.
'WHERE vmui.virtuemart_order_id >
'.$this->options->last_vm_order.' ORDER BY
vmui.virtuemart_order_userinfo_id ASC';
$sql2_2 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone` AS hkz ON (a.address_country =
hkz.zone_code_3 AND hkz.zone_type = "country") '.
'SET address_country = hkz.zone_namekey, address_published = 6
WHERE address_published >= 7;';
$sql2_3 = 'UPDATE `#__hikashop_address` AS a '. // todo
'JOIN `#__hikashop_zone_link` AS zl ON (a.address_country =
zl.zone_parent_namekey) '.
'JOIN `#__hikashop_zone` AS hks ON (hks.zone_namekey =
zl.zone_child_namekey AND hks.zone_type = "state" AND
hks.zone_code_3 = a.address_state) '.
'SET address_state = hks.zone_namekey, address_published = 5 WHERE
address_published = 6;';
$sql2_4 = 'UPDATE `#__hikashop_address` AS a '.
'SET address_published = 0 WHERE address_published > 4;';
$sql3 = 'UPDATE `#__hikashop_order` AS o '.
'INNER JOIN `#__hikashop_address` AS a ON
a.address_vm_order_info_id = o.order_vm_id '.
'SET o.order_billing_address_id = a.address_id,
o.order_shipping_address_id = a.address_id '.
"WHERE o.order_billing_address_id = 0 AND address_published >= 7
;";
$sql4 = 'UPDATE `#__hikashop_order` AS o '.
'INNER JOIN `#__hikashop_address` AS a ON
a.address_vm_order_info_id = o.order_vm_id '.
'SET o.order_shipping_address_id = a.address_id '.
"WHERE (o.order_shipping_address_id = 0 OR
o.order_shipping_address_id = o.order_billing_address_id) AND
address_published >= 8 ;";
$buffTable=$this->vmprefix."virtuemart_paymentmethods_".$this->vm_current_lng;
$sql5 = 'UPDATE `#__hikashop_order` AS a '.
'JOIN `'.$this->vmprefix.'virtuemart_orders` AS vmo
ON a.order_vm_id = vmo.virtuemart_order_id '.
'JOIN `'.$buffTable.'` AS vmp ON
vmo.virtuemart_paymentmethod_id = vmp.virtuemart_paymentmethod_id '.
"SET a.order_payment_method = CONCAT('vm import: ',
vmp.payment_name) ".
'WHERE a.order_vm_id > ' .
(int)$this->options->last_vm_order;
$this->db->setQuery('SET SQL_BIG_SELECTS=1');
$this->db->execute();
$this->db->setQuery($sql1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported orders: ' . $total . ' (including '.$guest.'
guests)</p>';
$this->db->setQuery($sql2_1);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported orders addresses: ' . $total . '</p>';
$this->db->setQuery($sql3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating billing addresses: ' . $total . '</p>';
$this->db->setQuery($sql4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating shipping addresses: ' . $total . '</p>';
$this->db->setQuery($sql5);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating order payments: ' . $total . '</p>';
$this->db->setQuery($sql2_2);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating orders: ' . $total;
$this->db->setQuery($sql2_3);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '/' . $total;
$this->db->setQuery($sql2_4);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '/' . $total . '</p>';
$ret = true;
return $ret;
}
function importOrderItems()
{
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
11 :</span>Â Import Order Items</p>';
$ret = false;
$offset = $this->options->current;
$count = 100;
$data = array(
'order_id' => 'hko.order_id',
'product_id' => 'hkp.hk_id',
'order_product_quantity' =>
'vmoi.product_quantity',
'order_product_name' => 'vmoi.order_item_name',
'order_product_code' => 'vmoi.order_item_sku',
'order_product_price' =>
'vmoi.product_item_price',
'order_product_tax' => '(vmoi.product_final_price -
vmoi.product_item_price)',
'order_product_options' => "''"
);
$sql = 'INSERT IGNORE INTO `#__hikashop_order_product`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->vmprefix.'virtuemart_order_items` AS vmoi '.
'INNER JOIN `#__hikashop_order` AS hko ON vmoi.virtuemart_order_id
= hko.order_vm_id '.
'INNER JOIN `#__hikashop_vm_prod` AS hkp ON
vmoi.virtuemart_product_id = hkp.vm_id '.
'WHERE vmoi.virtuemart_order_id > ' .
(int)$this->options->last_vm_order . ';';
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Orders Items imported : '. $total .'</p>';
$ret = true;
return $ret;
}
function importDownloads()
{
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
12 :</span>Â Import Downloads</p>';
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$app = JFactory::getApplication();
$ret = false;
$count = 100;
$offset = $this->options->current;
if( $offset == 0 )
{
$offset =
$app->getUserState($this->sessionParams.'last_vm_pfile');
if (!$offset)
$offset = $this->options->last_vm_pfile;
}
$sql = "SELECT `config_value` FROM `#__hikashop_config` WHERE
config_namekey = 'download_number_limit';";
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$dl_limit = $data[0]->config_value;
$sql = 'SELECT vmm.virtuemart_media_id, vmm.file_meta,
vmm.file_is_product_image, vmm.file_is_downloadable '.
'FROM `'.$this->vmprefix.'virtuemart_products` vmp
' .
'INNER JOIN
`'.$this->vmprefix.'virtuemart_product_medias` AS vmpm ON
vmp.virtuemart_product_id = vmpm.virtuemart_product_id ' .
'INNER JOIN `'.$this->vmprefix.'virtuemart_medias` vmm
ON vmpm.virtuemart_media_id = vmm.virtuemart_media_id ' .
'WHERE vmm.virtuemart_media_id > '.$offset.' AND
vmm.file_is_downloadable = 1'.
' ORDER BY vmm.virtuemart_media_id ASC LIMIT
'.$count.';';
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$max = 0;
$meta_files = array();
foreach($data as $c) {
$result = false;
if( !empty($c->file_meta) ) {
$file_name =
str_replace('\\','/',$c->file_meta);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$dstFolder = $this->options->uploadsecurefolder;
if($c->file_is_product_image){
$dstFolder = $this->options->uploadfolder;
}
$result = $this->copyFile($this->copyImgDir,$c->file_meta,
$dstFolder.$file_name);
if($result){
$meta_files[] = $this->db->Quote($c->file_meta);
}
$max = $c->virtuemart_media_id;
}
if(!$result && !empty($c->file_url)){
$file_name =
str_replace('\\','/',$c->file_url);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$dstFolder = $this->options->uploadsecurefolder;
if($c->file_is_product_image){
$dstFolder = $this->options->uploadfolder;
}
$result = $this->copyFile($this->copyImgDir,$c->file_url,
$dstFolder.$file_name);
if(!$result && !empty($c->file_meta)){
$meta_files[] = $this->db->Quote($c->file_meta);
}
$max = $c->virtuemart_media_id;
}
}
if(empty($meta_files) || !count($meta_files)){
$meta_files = "''";
}else{
$meta_files = implode(',',$meta_files);
}
$app->setUserState($this->sessionParams.'last_vm_pfile',$max);
if( $max > 0 ) {
echo '<p>Copying files...<br/>(Last processed file id:
' . $max . ')</p>';
$this->options->current = $max;
$this->refreshPage = true;
return $ret;
}
$data = array(
'file_name' => 'vmm.file_title',
'file_description' => 'vmm.file_description',
'file_path' => "case when vmm.file_meta IN
(".$meta_files.") then
SUBSTRING_INDEX(SUBSTRING_INDEX(vmm.file_meta, '/', -1),
'\\\\', -1) else SUBSTRING_INDEX(SUBSTRING_INDEX(vmm.file_url,
'/', -1), '\\\\', -1) end",
'file_type' => "case when vmm.file_is_product_image =
1 then 'product' else 'file' end",
'file_ref_id' => 'hkp.hk_id'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_file`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->vmprefix.'virtuemart_products` vmp '.
"INNER JOIN
`".$this->vmprefix."virtuemart_product_medias` AS vmpm ON
vmp.virtuemart_product_id = vmpm.virtuemart_product_id ".
"INNER JOIN `".$this->vmprefix."virtuemart_medias` vmm
ON vmpm.virtuemart_media_id = vmm.virtuemart_media_id " .
'INNER JOIN `#__hikashop_vm_prod` AS hkp ON vmm.virtuemart_media_id
= hkp.vm_id '.
'WHERE vmm.virtuemart_media_id >
'.$this->options->last_vm_pfile.';';
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Downloable files imported : ' . $total . '</p>';
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Downloable order files imported : 0</p>';
return true;
}
function importDiscount()
{
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
9 :</span>Â Import Discount</p>';
$sql = "SELECT `config_value` FROM `#__hikashop_config` WHERE
config_namekey = 'main_currency';";
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$main_currency = $data[0]->config_value;
$data = array(
'discount_type' => "'coupon'", //coupon
or discount
'discount_published' => '1',
'discount_code' => '`coupon_code`',
'discount_currency_id' => $main_currency,
'discount_flat_amount' => "case when percent_or_total
= 'total' then coupon_value else 0 end",
'discount_percent_amount' => "case when
percent_or_total = 'percent' then coupon_value else 0 end",
'discount_quota' => "case when coupon_type =
'gift' then 1 else 0 end"
);
$sql = 'INSERT IGNORE INTO #__hikashop_discount
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
'.$this->vmprefix.'virtuemart_coupons WHERE
virtuemart_coupon_id > ' .
(int)$this->options->last_vm_coupon;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Discount codes / coupons imported : ' . $total .
'</p>';
$data = array(
'discount_type' => "'discount'",
'discount_published' => '1',
'discount_code' => "CONCAT('discount_',
vmp.product_sku)",
'discount_currency_id' => $main_currency,
'discount_flat_amount' => "case when
vmc.percent_or_total = 'total' then vmc.coupon_value else 0
end",
'discount_percent_amount' => "case when
vmc.percent_or_total = 'percent' then vmc.coupon_value else 0
end",
'discount_quota' => "''",
'discount_product_id' => 'hkp.hk_id',
'discount_category_id' => '0',
'discount_start' =>
"UNIX_TIMESTAMP(vmc.coupon_start_date)",
'discount_end' =>
"UNIX_TIMESTAMP(vmc.coupon_expiry_date)"
);
$sql = 'INSERT IGNORE INTO #__hikashop_discount
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
'.$this->vmprefix.'virtuemart_products vmp '.
'INNER JOIN
`'.$this->vmprefix.'virtuemart_product_prices` vmpp ON
vmp.virtuemart_product_id = vmpp.virtuemart_product_id '.
'INNER JOIN `'.$this->vmprefix.'virtuemart_coupons`
vmc ON vmpp.product_discount_id = vmc.virtuemart_coupon_id '.
'INNER JOIN `#__hikashop_vm_prod` AS hkp ON hkp.vm_id =
vmp.virtuemart_product_id '.
'WHERE vmp.virtuemart_product_id > ' .
(int)$this->options->last_vm_prod;
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Discount product imported : ' . $total . '</p>';
$ret = true;
return $ret;
}
function importReviews()
{
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
13 :</span>Â Import Product reviews</p>';
$ret = false;
$offset = $this->options->current;
$count = 100;
$data = array(
'vote_ref_id' => 'hkvp.hk_id',
'vote_type' => "'product'",
'vote_user_id' => 'hkusr.user_id',
'vote_rating' => 'vrv.vote',
'vote_comment' => 'vrr.comment',
'vote_useful' => '0', //review_ok ?
'vote_pseudo' => 'u.username',
'vote_ip' => 'vrr.lastip',
'vote_email' => 'u.email',
'vote_date' => 'UNIX_TIMESTAMP(vrv.created_on)'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_vote`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__virtuemart_rating_reviews` AS vrr '.
'INNER JOIN `#__virtuemart_rating_votes` AS vrv ON
vrr.virtuemart_rating_review_id = vrv.virtuemart_rating_vote_id '.
//join with double primary keys Zzzz
'INNER JOIN `#__hikashop_vm_prod` AS hkvp ON
vrr.virtuemart_product_id = hkvp.vm_id '.
'INNER JOIN `#__hikashop_user` AS hkusr ON vrr.created_by =
hkusr.user_cms_id '.
'INNER JOIN `#__users` AS u ON hkusr.user_cms_id = u.id '.
'WHERE vrr.virtuemart_rating_review_id > ' .
(int)$this->options->last_vm_review . ';';
$this->db->setQuery($sql);
$this->db->execute();
$total = $this->db->getAffectedRows();
$sql = 'SELECT hkvp.hk_id as hkid, vrv.vote as vmvote FROM
`#__virtuemart_rating_votes` AS vrv '.
'INNER JOIN `#__hikashop_vm_prod` AS hkvp ON
vrv.virtuemart_product_id = hkvp.vm_id '.
'WHERE vrv.virtuemart_rating_vote_id > ' .
(int)$this->options->last_vm_review . ' '.
'ORDER BY hkvp.hk_id; ';
$this->db->setQuery($sql);
$this->db->execute();
$data = $this->db->loadObjectList();
$continue = false;
$idmain = $sum = $divide = $nbentries = 0;
foreach($data as $d)
{
if (!$continue)
$idmain = $d->hkid;
$sum += $d->vmvote;
$divide++;
if ($idmain==$d->hkid)
{
$continue = true;
continue;
}
else
{
$average = $sum / $divide;
$sql = 'UPDATE `#__hikashop_product` SET `product_average_score` =
'.$average.', `product_total_vote` = '.$divide.' WHERE
product_id = '.$d->hkid;
$this->db->execute();
$nbentries += $this->db->getAffectedRows();
$sum = $divide = 0;
$continue = false;
}
}
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Products reviews imported : '. $total .'</p>';
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Products average scores updated : '. $nbentries
.'</p>';
$ret = true;
return $ret;
}
function copyFile($dir, $fsrc, $dst, $debug = false){
if ($debug){
echo 'Source folder : '.$dir.'<br/>';
echo 'File source name : '.$fsrc.'<br/>';
echo 'From "'.$dir.$fsrc.'" to folder/file :
"'.$dst.'"<br/>';
echo '#####<br/>';
}
$dir = str_replace(array('\\/', '/', '\\'),
DS, $dir);
$fsrc = str_replace(array('\\/', '/',
'\\'), DS, $fsrc);
$dst = str_replace(array('\\/', '/', '\\'),
DS, $dst);
$src = $fsrc;
if( file_exists($dir.$fsrc) )
$src = $dir.$fsrc;
else if( file_exists(HIKASHOP_ROOT.$fsrc) )
$src = HIKASHOP_ROOT.$fsrc;
if( file_exists($src) ){
if( !file_exists($dst) ){
$ret = JFile::copy($src, $dst);
if( !$ret ){
echo '<span '.$this->copywarning.'>The file
"' . $src . '" could not be copied to "' .
$dst . '"</span><br/>';
}else{
return true;
}
}
else{
echo '<span '.$this->copywarning.'>File already
exists "' .$dst . '" ("' . $src .
'")</span><br/>';
return true;
}
}
else{
echo '<span '.$this->copywarning.'>File is not
found "' . $dir.$fsrc .
'"</span><br/>';
}
return false;
}
}
import.php000064400000205604151162557560006613 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
define('MAX_IMPORT_ID', 12);
class hikashopImportHelper
{
var $template = null;
var $totalInserted = 0;
var $totalTry = 0;
var $totalValid = 0;
var $listSeparators =
array(';',',','|',"\t");
var $perBatch = 50;
var $codes = array();
var $characteristics = array();
var $characteristicsConversionTable = array();
var $characteristicColumns = array();
var $countVariant = true;
var $overwrite = false;
var $products_already_in_db = array();
var $new_variants_in_db = array();
var $columnNamesConversionTable = array();
var $createCategories = false;
var $header_errors = true;
var $force_published = true;
var $tax_category=0;
var $default_file = '';
var $importName;
var $db;
var $options;
var $refreshPage;
var $token = '';
var $linkstyle;
var $titlestyle;
var $bullstyle;
var $pmarginstyle;
var $titlefont;
var $copywarning;
var $copyImgDir;
var $copyCatImgDir;
var $copycDownloadDir;
var $copyManufDir;
function __construct()
{
$this->db = JFactory::getDBO();
$this->options = null;
$this->refreshPage = false;
$this->linkstyle = '
style="color:#297F93;text-decoration:none;"
onmouseover="this.style.color=\'#3AABC6\';this.style.textDecoration=\'underline\';"
onmouseout="this.style.color=\'#297F93\';this.style.textDecoration=\'none\';"
';
$this->titlestyle = ' style="color:#297F93;
text-decoration:underline;" ';
$this->bullstyle = ' style="color:#E69700;" ';
$this->pmarginstyle =
'style="margin-left:15px;"';
$this->titlefont = ' style="font-size:1.2em;" ';
$this->copywarning = '
style="color:grey;font-size:0.8em" ';
$this->fields =
array('product_weight','product_description','product_meta_description','product_tax_id','product_vendor_id','product_manufacturer_id','product_url','product_keywords','product_weight_unit','product_dimension_unit','product_width','product_length','product_height','product_max_per_order','product_min_per_order');
$fieldClass = hikashop_get('class.field');
$userFields = $fieldClass->getData('','product');
if(!empty($userFields)){
foreach($userFields as $k => $v){
if($v->field_type!='customtext'){
$this->fields[]=$k;
}
}
}
$this->all_fields =
array_merge($this->fields,array('product_name','product_published','product_code','product_created','product_modified','product_sale_start','product_sale_end','product_type','product_quantity'));
$this->db = JFactory::getDBO();
if(version_compare(JVERSION,'3.0','<')) {
$columnsProductTable =
$this->db->getTableFields(hikashop_table('product'));
$this->columnsProductTable =
array_keys($columnsProductTable[hikashop_table('product')]);
} else {
$this->columnsProductTable =
array_keys($this->db->getTableColumns(hikashop_table('product')));
}
$characteristic = hikashop_get('class.characteristic');
$characteristic->loadConversionTables($this);
$this->volumeHelper = hikashop_get('helper.volume');
$this->weightHelper = hikashop_get('helper.weight');
$class = hikashop_get('class.category');
$this->mainProductCategory = 'product';
$class->getMainElement($this->mainProductCategory);
$this->mainManufacturerCategory = 'manufacturer';
$class->getMainElement($this->mainManufacturerCategory);
$this->mainTaxCategory = 'tax';
$class->getMainElement($this->mainTaxCategory);
$this->db->setQuery('SELECT category_id FROM '.
hikashop_table('category'). ' WHERE
category_type=\'tax\' &&
category_parent_id='.(int)$this->mainTaxCategory.' ORDER BY
category_ordering DESC');
$this->tax_category = $this->db->loadResult();
$config =& hikashop_config();
$uploadFolder =
ltrim(JPath::clean(html_entity_decode($config->get('uploadfolder'))),DS);
$uploadFolder = rtrim($uploadFolder,DS).DS;
$this->uploadFolder = JPATH_ROOT.DS.$uploadFolder;
$this->uploadFolder_url =
str_replace(DS,'/',$uploadFolder);
$this->uploadFolder_url = HIKASHOP_LIVE.$this->uploadFolder_url;
jimport('joomla.filesystem.file');
}
function addTemplate($template_product_id){
if($template_product_id){
$productClass = hikashop_get('class.product');
if($productClass->getProducts($template_product_id,'import')
&& !empty($productClass->products)){
$key = key($productClass->products);
$this->template = $productClass->products[$key];
}
}
}
function importFromFolder($type,$delete,$uploadFolder){
$config =& hikashop_config();
if($type=='both'){
$allowed =
explode(',',strtolower($config->get('allowedimages')));
}else{
$allowed =
explode(',',strtolower($config->get('allowed'.$type)));
}
$uploadFolder =
rtrim(JPath::clean(html_entity_decode($uploadFolder)),DS.'
').DS;
if(!preg_match('#^([A-Z]:)?/.*#',$uploadFolder)){
if(!$uploadFolder[0]=='/' || !is_dir($uploadFolder)){
$uploadFolder =
JPath::clean(HIKASHOP_ROOT.DS.trim($uploadFolder,DS.' ').DS);
}
}
$fileClass = hikashop_get('class.file');
if($delete && !$fileClass->checkFolder($uploadFolder)){
return false;
}
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$app =& JFactory::getApplication();
$files = JFolder::files($uploadFolder);
if(!empty($files)){
$imageHelper = hikashop_get('helper.image');
if(!empty($this->template->variants)){
$this->countVariant = false;
}
$oldType = $type;
foreach($files as $file){
if(in_array($file,array('index.html','.htaccess')))
continue;
$extension = strtolower(substr($file,strrpos($file,'.')+1));
if(!in_array($extension,$allowed)){
$app->enqueueMessage(JText::sprintf('FILE_SKIPPED',$file));
continue;
}
$type = $oldType;
$newProduct = new stdClass();
if($type=='both'){
$newProduct->files = $file;
$newProduct->images = $file;
}else{
$newProduct->$type = $file;
}
$this->_checkData($newProduct);
$this->totalTry++;
if(!empty($newProduct->product_code)){
$this->totalValid++;
$products = array($newProduct);
if(!empty($this->template->variants)){
foreach($this->template->variants as $variant){
$copy = (!HIKASHOP_PHP5) ? $variant : clone($variant);
unset($copy->product_id);
$copy->product_parent_id = $newProduct->product_code;
$copy->product_code =
$newProduct->product_code.'_'.$copy->product_code;
$products[]=$copy;
}
}
$this->_insertProducts($products);
$folder = 'image';
if($type!='images'){
$folder = 'file';
}
$uploadPath = $fileClass->getPath($folder);
if($delete){
JFile::move($uploadFolder.$file,$uploadPath.$file);
}else{
JFile::copy($uploadFolder.$file,$uploadPath.$file);
}
if($type=='both'){
$type='images';
$uploadPath2 = $fileClass->getPath('image');
JFile::copy($uploadPath.$file,$uploadPath2.$file);
}
if($type!='files'){
$imageHelper->resizeImage($file);
}
}
}
$this->_deleteUnecessaryVariants();
}
$app->enqueueMessage(JText::sprintf('IMPORT_REPORT',$this->totalTry,$this->totalInserted,$this->totalTry
- $this->totalValid,$this->totalValid - $this->totalInserted));
}
function copyProduct($product_id){
$this->addTemplate($product_id);
$newProduct = new stdClass();
$newProduct->product_code =
$this->template->product_code.'_copy'.rand();
$this->_checkData($newProduct);
if(!empty($newProduct->product_code)){
$products = array($newProduct);
if(!empty($this->template->variants)){
foreach($this->template->variants as $variant){
$copy = (!HIKASHOP_PHP5) ? $variant : clone($variant);
$copy->product_parent_id = $newProduct->product_code;
$copy->product_code =
$copy->product_code.'_copy'.rand();
unset($copy->product_id);
$products[]=$copy;
}
}
JPluginHelper::importPlugin( 'hikashop' );
$dispatcher = JDispatcher::getInstance();
$do = true;
$dispatcher->trigger( 'onBeforeProductCopy', array( &
$this->template, & $products[0], & $do) );
if(!$do){
return false;
}
$this->_insertProducts($products);
$dispatcher->trigger( 'onAfterProductCopy', array( &
$this->template, & $products[0]) );
}
return true;
}
function importFromFile(&$importFile, $process = true){
$app = JFactory::getApplication();
if(empty($importFile['name'])){
$app->enqueueMessage(JText::_('BROWSE_FILE'),'notice');
return false;
}
$this->charsetConvert =
JRequest::getString('charsetconvert','');
jimport('joomla.filesystem.file');
$config =& hikashop_config();
$allowedFiles =
explode(',',strtolower($config->get('allowedfiles')));
$uploadFolder =
JPath::clean(html_entity_decode($config->get('uploadfolder')));
$uploadFolder = trim($uploadFolder,DS.' ').DS;
$uploadPath = JPath::clean(HIKASHOP_ROOT.$uploadFolder);
if(!is_dir($uploadPath)){
jimport('joomla.filesystem.folder');
JFolder::create($uploadPath);
JFile::write($uploadPath.'index.html','<html><body
bgcolor="#FFFFFF"></body></html>');
}
if(!is_writable($uploadPath)){
@chmod($uploadPath,'0755');
if(!is_writable($uploadPath)){
$app->enqueueMessage(JText::sprintf(
'WRITABLE_FOLDER',$uploadPath), 'notice');
}
}
$attachment = new stdClass();
$attachment->filename =
strtolower(JFile::makeSafe($importFile['name']));
$attachment->size = $importFile['size'];
if(!preg_match('#\.('.str_replace(array(',','.'),array('|','\.'),$config->get('allowedfiles')).')$#Ui',$attachment->filename,$extension)
||
preg_match('#\.(php.?|.?htm.?|pl|py|jsp|asp|sh|cgi)$#Ui',$attachment->filename)){
$app->enqueueMessage(JText::sprintf(
'ACCEPTED_TYPE',substr($attachment->filename,strrpos($attachment->filename,'.')+1),$config->get('allowedfiles')),
'notice');
return false;
}
$attachment->filename = str_replace(array('.','
'),'_',substr($attachment->filename,0,strpos($attachment->filename,$extension[0]))).$extension[0];
if ( !move_uploaded_file($importFile['tmp_name'], $uploadPath .
$attachment->filename)) {
if(!JFile::upload($importFile['tmp_name'], $uploadPath .
$attachment->filename)){
$app->enqueueMessage(JText::sprintf(
'FAIL_UPLOAD',$importFile['tmp_name'],$uploadPath .
$attachment->filename), 'error');
}
}
hikashop_increasePerf();
$contentFile = file_get_contents($uploadPath .
$attachment->filename);
if(!$contentFile){
$app->enqueueMessage(JText::sprintf(
'FAIL_OPEN',$uploadPath . $attachment->filename),
'error');
return false;
};
if($process){
unlink($uploadPath . $attachment->filename);
$toTest = array();
if(empty($this->charsetConvert)){
$encodingHelper = hikashop_get('helper.encoding');
$this->charsetConvert =
$encodingHelper->detectEncoding($contentFile);
}
return $this->handleContent($contentFile);
}else{
$filePath = $uploadPath . $attachment->filename;
return $filePath;
}
}
function handleContent(&$contentFile){
$app = JFactory::getApplication();
$contentFile =
str_replace(array("\r\n","\r"),"\n",$contentFile);
$this->importLines = explode("\n", $contentFile);
$this->i = 0;
while(empty($this->header)){
$this->header = trim($this->importLines[$this->i]);
$this->i++;
}
if(!$this->_autoDetectHeader()){
return false;
}
$this->numberColumns = count($this->columns);
$importProducts = array();
$encodingHelper = hikashop_get('helper.encoding');
$errorcount = 0;
while ($data = $this->_getProduct()) {
$this->totalTry++;
$newProduct = new stdClass();
foreach($data as $num => $value){
if(!empty($this->columns[$num])){
$field = $this->columns[$num];
if( strpos('|',$field) !== false ) { $field =
str_replace('|','__tr__',$field); }
$newProduct->$field = preg_replace('#^[\'"
]{1}(.*)[\'" ]{1}$#','$1',$value);
if(!empty($this->charsetConvert)){
$newProduct->$field =
$encodingHelper->change($newProduct->$field,$this->charsetConvert,'UTF-8');
}
}
}
$this->_checkData($newProduct,true);
if(!empty($newProduct->product_code)){
$importProducts[] = $newProduct;
if(count($this->currentProductVariants)){
foreach($this->currentProductVariants as $variant){
$importProducts[] = $variant;
}
}
$this->totalValid++;
}else{
$errorcount++;
if($errorcount<20){
if(isset($this->importLines[$this->i-1]))$app->enqueueMessage(JText::sprintf('IMPORT_ERRORLINE',$this->importLines[$this->i-1]).'
'.JText::_('PRODUCT_NOT_FOUND'),'notice');
}elseif($errorcount == 20){
$app->enqueueMessage('...','notice');
}
}
if( $this->totalValid%$this->perBatch == 0){
$this->_insertProducts($importProducts);
$importProducts = array();
}
}
if(!empty($importProducts)){
$this->_insertProducts($importProducts);
}
$this->_deleteUnecessaryVariants();
$app->enqueueMessage(JText::sprintf('IMPORT_REPORT',$this->totalTry,$this->totalInserted,$this->totalTry
- $this->totalValid,$this->totalValid - $this->totalInserted));
return true;
}
function _deleteUnecessaryVariants(){
if(!empty($this->products_already_in_db)){
$this->db->setQuery('SELECT product_id FROM
'.hikashop_table('product').' WHERE product_parent_id
IN ('.implode(',',$this->products_already_in_db).')
AND product_id NOT IN
('.implode(',',$this->new_variants_in_db).') AND
product_type=\'variant\'');
if(!HIKASHOP_J25){
$variants_to_be_deleted = $this->db->loadResultArray();
} else {
$variants_to_be_deleted = $this->db->loadColumn();
}
if(!empty($variants_to_be_deleted)){
$productClass = hikashop_get('class.product');
$productClass->delete($variants_to_be_deleted);
}
}
}
function &_getProduct(){
$false = false;
if(!isset($this->importLines[$this->i])){
return $false;
}
if(empty($this->importLines[$this->i])){
$this->i++;
return $this->_getProduct();
}
$quoted = false;
$dataPointer=0;
$data = array('');
while($data!==false && isset($this->importLines[$this->i])
&& (count($data) < $this->numberColumns||$quoted)){
$k = 0;
$total = strlen($this->importLines[$this->i]);
while($k < $total){
switch($this->importLines[$this->i][$k]){
case '"':
if($quoted && isset($this->importLines[$this->i][$k+1])
&& $this->importLines[$this->i][$k+1]=='"'){
$data[$dataPointer].='"';
$k++;
}elseif($quoted){
$quoted = false;
}elseif(empty($data[$dataPointer])){
$quoted = true;
}else{
$data[$dataPointer].='"';
}
break;
case $this->separator:
if(!$quoted){
$data[]='';
$dataPointer++;
break;
}
default:
$data[$dataPointer].=$this->importLines[$this->i][$k];
break;
}
$k++;
}
$this->_checkLineData($data);
if(count($data) < $this->numberColumns||$quoted){
$data[$dataPointer].="\r\n";
}
$this->i++;
}
if($data!=false) $this->_checkLineData($data,false);
return $data;
}
function _checkLineData(&$data,$type=true){
if($type){
$not_ok = count($data) > $this->numberColumns;
}else{
$not_ok = count($data) != $this->numberColumns;
}
if($not_ok){
static $errorcount = 0;
if(empty($errorcount)){
$app = JFactory::getApplication();
$app->enqueueMessage(JText::sprintf('IMPORT_ARGUMENTS',$this->numberColumns),'error');
}
$errorcount++;
if($errorcount<20){
$app = JFactory::getApplication();
$app->enqueueMessage(JText::sprintf('IMPORT_ERRORLINE',$this->importLines[$this->i]),'notice');
$data = $this->_getProduct();
}elseif($errorcount == 20){
$app = JFactory::getApplication();
$app->enqueueMessage('...','notice');
}
}
}
function _checkData(&$product,$main=false){
$this->currentProductVariants = array();
if(empty($product->product_created)){
$product->product_created = time();
}elseif(!is_numeric($product->product_created)){
$product->product_created = strtotime($product->product_created);
}
if(empty($product->product_modified)){
$product->product_modified = time();
}elseif(!is_numeric($product->product_modified)){
$product->product_modified =
strtotime($product->product_modified);
}
if(empty($product->product_sale_start)){
if(!empty($this->template->product_sale_start)){
$product->product_sale_start =
$this->template->product_sale_start;
}
}elseif(!is_numeric($product->product_sale_start)){
$product->product_sale_start =
strtotime($product->product_sale_start);
}
if(empty($product->product_sale_end)){
if(!empty($this->template->product_sale_end)){
$product->product_sale_end =
$this->template->product_sale_end;
}
}elseif(!is_numeric($product->product_sale_end)){
$product->product_sale_end =
strtotime($product->product_sale_end);
}
if(!empty($product->product_weight)){
$product->product_weight =
hikashop_toFloat($product->product_weight);
}
if(!empty($product->product_width)){
$product->product_width =
hikashop_toFloat($product->product_width);
}
if(!empty($product->product_height)){
$product->product_height =
hikashop_toFloat($product->product_height);
}
if(!empty($product->product_length)){
$product->product_length =
hikashop_toFloat($product->product_length);
}
if(empty($product->product_type)){
if(empty($product->product_parent_id)){
$product->product_type='main';
}else{
if(!empty($product->product_parent_id) &&
!empty($product->product_code) && $product->product_parent_id
== $product->product_code){
$app = JFactory::getApplication();
$app->enqueueMessage('The product
'.$product->product_code.' has the same value in the
product_parent_id and product_code fields which is not possible ( a main
product cannot be a variant at the same time ). This product has been
considered as a main product by HikaShop and has been imported as
such.');
$product->product_type='main';
$product->product_parent_id=0;
}else{
$product->product_type='variant';
}
}
}else{
if(!in_array($product->product_type,array('main','variant'))){
$product->product_type = 'main';
}
}
if($product->product_type=='main'){
if(!empty($product->product_parent_id)){
$app = JFactory::getApplication();
$app->enqueueMessage('The product
'.@$product->product_code.' should have an empty value instead
of the value '.$product->product_parent_id.' in the field
product_parent_id as it is a main product (not a variant) and thus
doesn\'t have any parent.','error');
}
}
if(!isset($product->product_tax_id) ||
strlen($product->product_tax_id)<1){
$product->product_tax_id = $this->tax_category;
}else{
if(!is_numeric($product->product_tax_id)){
$id =
$this->_getCategory($product->product_tax_id,0,!$this->createCategories,'tax');
if(empty($id) && $this->createCategories){
$id =
$this->_createCategory($product->product_tax_id,0,'tax');
}
$product->product_tax_id = $id;
}
}
if(!empty($product->product_manufacturer_id) &&
!is_numeric($product->product_manufacturer_id)){
$id =
$this->_getCategory($product->product_manufacturer_id,0,!$this->createCategories,'manufacturer');
if(empty($id) && $this->createCategories){
$id =
$this->_createCategory($product->product_manufacturer_id,0,'manufacturer');
}
$product->product_manufacturer_id = $id;
}
if(!isset($product->product_quantity) ||
strlen($product->product_quantity)<1){
if(!empty($this->template->product_quantity)){
$product->product_quantity=$this->template->product_quantity;
}
}
if(isset($product->product_quantity) &&
!is_numeric($product->product_quantity)){
$product->product_quantity=-1;
}
foreach($this->fields as $field){
if(empty($product->$field)&&!empty($this->template->$field)){
$product->$field=$this->template->$field;
}
}
if(empty($product->product_dimension_unit)){
$product->product_dimension_unit=$this->volumeHelper->getSymbol();
}else{
$product->product_dimension_unit=
strtolower($product->product_dimension_unit);
}
if(empty($product->product_weight_unit)){
$product->product_weight_unit=$this->weightHelper->getSymbol();
}else{
$product->product_weight_unit=
strtolower($product->product_weight_unit);
}
if(!empty($product->product_published)){
$product->product_published=1;
}
if(!isset($product->product_published)){
if(!empty($this->template)){
$product->product_published =
$this->template->product_published;
}
}
if(!empty($product->price_value_with_tax)){
$currencyHelper = hikashop_get('class.currency');
if(empty($product->product_tax_id)){
$product->product_tax_id = $currencyHelper->getTaxCategory();
}
if($product->product_tax_id){
if(strpos($product->price_value_with_tax,'|')===false){
$product->price_value =
$currencyHelper->getUntaxedPrice(hikashop_toFloat($product->price_value_with_tax),hikashop_getZone(),$product->product_tax_id);
}else{
$price_value =
explode('|',$product->price_value_with_tax);
foreach($price_value as $k => $price_value_one){
$price_value[$k] =
$currencyHelper->getUntaxedPrice($price_value_one,hikashop_getZone(),$product->product_tax_id);
}
$product->price_value = implode('|',$price_value);
}
}
}
if(!empty($product->price_value)){
$product->prices = array();
if(strpos($product->price_value,'|')===false){
$price = new stdClass();
$price->price_value = hikashop_toFloat($product->price_value);
if(!empty($this->price_fee)){
$price->price_value +=
$price->price_value*hikashop_toFloat($this->price_fee)/100;
}
$price->price_min_quantity = (int)@$product->price_min_quantity;
if($price->price_min_quantity==1){
$price->price_min_quantity=0;
}
if(empty($product->price_access)){
$price->price_access = 'all';
}else{
$price->price_access = $product->price_access;
}
if(!empty($product->price_currency_id)){
if(!is_numeric($product->price_currency_id)){
$product->price_currency_id =
$this->_getCurrency($product->price_currency_id);
}
$price->price_currency_id = $product->price_currency_id;
}else{
$config =& hikashop_config();
$price->price_currency_id =
$config->get('main_currency',1);
}
$product->prices[]=$price;
}else{
$price_value = explode('|',$product->price_value);
if(!empty($product->price_min_quantity)){
$price_min_quantity =
explode('|',$product->price_min_quantity);
}
if(!empty($product->price_access)){
$price_access = explode('|',$product->price_access);
}
if(!empty($product->price_currency_id)){
$price_currency_id =
explode('|',$product->price_currency_id);
}
foreach($price_value as $k => $price_value_one){
$price = new stdClass();
$price->price_value = hikashop_toFloat($price_value_one);
if(!empty($this->price_fee)){
$price->price_value +=
$price->price_value*hikashop_toFloat($this->price_fee)/100;
}
$price->price_min_quantity = (int)@$price_min_quantity[$k];
if($price->price_min_quantity==1){
$price->price_min_quantity=0;
}
if(empty($price_access[$k])){
$price->price_access = 'all';
}else{
$price->price_access = $price_access[$k];
}
if(!empty($price_currency_id[$k])){
if(!is_numeric($price_currency_id[$k])){
$price_currency_id[$k] =
$this->_getCurrency($price_currency_id[$k]);
}
$price->price_currency_id = $price_currency_id[$k];
}else{
$config =& hikashop_config();
$price->price_currency_id =
$config->get('main_currency',1);
}
$product->prices[]=$price;
}
}
}
if(!empty($product->files) && !is_array($product->files)){
$this->_separate($product->files);
$unset = array();
foreach($product->files as $k => $file){
if(substr($file,0,7)=='http://'||substr($file,0,8)=='https://'){
$parts = explode('/',$file);
$name = array_pop($parts);
if(!file_exists($this->uploadFolder.$name)){
$data = @file_get_contents($file);
if(empty($data) && !empty($this->default_file)){
$name = $this->default_file;
}else{
JFile::write($this->uploadFolder.$name,$data);
}
}else{
$size = $this->getSizeFile($file);
if($size!=filesize($this->uploadFolder.$name)){
$name=$size.'_'.$name;
if(!file_exists($this->uploadFolder.$name)){
JFile::write($this->uploadFolder.$name,file_get_contents($file));
}
}
}
if(file_exists($this->uploadFolder.$name) &&
(filesize($this->uploadFolder.$name) > 0 ||
filesize($this->uploadFolder.$name) === false)){
$product->files[$k] = $name;
}else{
$unset[]=$k;
}
}
}
if(!empty($unset)){
foreach($unset as $k){
unset($product->files[$k]);
}
}
}
if(!empty($product->images) &&
!is_array($product->images)){
$this->_separate($product->images);
$unset = array();
foreach($product->images as $k => $image){
if(substr($image,0,7)=='http://'||substr($image,0,8)=='https://'){
$parts = explode('/',$image);
$name = array_pop($parts);
if(!file_exists($this->uploadFolder.$name)){
JFile::write($this->uploadFolder.$name,file_get_contents($image));
}else{
$size = $this->getSizeFile($image);
if($size!=filesize($this->uploadFolder.$name)){
$name=$size.'_'.$name;
if(!file_exists($this->uploadFolder.$name)){
JFile::write($this->uploadFolder.$name,file_get_contents($image));
}
}
}
if(file_exists($this->uploadFolder.$name) &&
(filesize($this->uploadFolder.$name) > 0 ||
filesize($this->uploadFolder.$name) === false)){
$product->images[$k] = $name;
}else{
$unset[]=$k;
}
}
}
if(!empty($unset)){
foreach($unset as $k){
unset($product->images[$k]);
}
}
}
if(empty($product->product_name)){
if(!empty($product->files)){
if(!is_array($product->files)){
$this->_separate($product->files);
}
$product->product_name=substr($product->files[0],0,strrpos($product->files[0],'.'));
}elseif(!empty($product->images)){
if(!is_array($product->images)){
$this->_separate($product->images);
}
$product->product_name=substr($product->images[0],0,strrpos($product->images[0],'.'));
}
}
if(!empty($product->related) &&
!is_array($product->related)){
$this->_separate($product->related);
}
if(!empty($product->options) &&
!is_array($product->options)){
$this->_separate($product->options);
}
if($product->product_type=='variant'){
$product->categories = null;
}else{
if(!empty($product->categories)){
if(!is_array($product->categories)){
$this->_separate($product->categories);
}
$parent_id=0;
if($this->createCategories &&
!empty($product->parent_category)){
$this->_separate($product->parent_category);
$parent_id = array();
foreach($product->parent_category as $k => $parent_category){
$parent_id[$k] =
$this->_getCategory($parent_category,0,false,'product');
if(empty($parent_id[$k])){
$parent_id[$k] = $this->_createCategory($parent_category);
}
}
}
if($this->createCategories &&
!empty($product->categories_image)){
$unset = array();
$this->_separate($product->categories_image);
foreach($product->categories_image as $k => $image){
if(substr($image,0,7)=='http://'||substr($image,0,8)=='https://'){
$parts = explode('/',$image);
$name = array_pop($parts);
if(!file_exists($this->uploadFolder.$name)){
JFile::write($this->uploadFolder.$name,file_get_contents($image));
}else{
$size = $this->getSizeFile($image);
if($size!=filesize($this->uploadFolder.$name)){
$name=$size.'_'.$name;
if(!file_exists($this->uploadFolder.$name)){
JFile::write($this->uploadFolder.$name,file_get_contents($image));
}
}
}
if(filesize($this->uploadFolder.$name)){
$product->categories_image[$k] = $name;
}else{
$unset[]=$k;
}
}
}
if(!empty($unset)){
foreach($unset as $k){
unset($product->categories_image[$k]);
}
}
}
if($this->createCategories &&
!empty($product->categories_namekey)){
$this->_separate($product->categories_namekey);
}
foreach($product->categories as $k => $v){
if(!is_numeric($v) || !empty($product->categories_namekey)){
$pid = 0;
if(is_array($parent_id)){
if(!empty($parent_id[$k])){
$pid = $parent_id[$k];
}elseif(!empty($parent_id[0])){
$pid = $parent_id[0];
}
}
$id =
$this->_getCategory($v,0,!$this->createCategories,'product',$pid,@$product->categories_image[$k]);
if(empty($id) && $this->createCategories){
$id =
$this->_createCategory($v,$pid,'product',@$product->categories_image[$k],@$product->categories_namekey[$k]);
}
$product->categories[$k] = $id;
}
}
}
}
if(!empty($product->categories_ordering)){
$this->_separate($product->categories_ordering);
}
if(empty($product->product_access)){
if(!empty($this->template)){
$product->product_access = @$this->template->product_access;
}else{
$product->product_access = 'all';
}
}
if(!isset($product->product_contact) &&
!empty($this->template)){
$product->product_contact = @$this->template->product_contact;
}
if(!isset($product->product_group_after_purchase) &&
!empty($this->template)){
$product->product_group_after_purchase =
@$this->template->product_group_after_purchase;
}
if(hikashop_level(2) && !empty($product->product_access)){
if(!is_array($product->product_access)){
if(!in_array($product->product_access,array('none','all'))){
if(!is_array($product->product_access)){
$this->_separate($product->product_access);
}
}
}
if(is_array($product->product_access)){
$accesses = array();
foreach($product->product_access as $access){
if(empty($access))continue;
if(!is_numeric($access)){
$access = $this->_getAccess($access);
if(empty($access))continue;
}
$accesses[] = $access;
}
$product->product_access =
','.implode(',',$accesses).',';
}
}
if(!empty($this->characteristicColumns)){
foreach($this->characteristicColumns as $column){
if(isset($product->$column) &&
strlen($product->$column)>0){
if($product->product_type=='main' &&
!empty($this->characteristicsConversionTable[$column])){
if(!isset($product->variant_links)){
$product->variant_links=array();
}
$product->variant_links[]=$this->characteristicsConversionTable[$column];
}
if(function_exists('mb_strtolower')){
$key = mb_strtolower(trim($product->$column,'"
'));
}else{
$key = strtolower(trim($product->$column,'" '));
}
if(!empty($this->characteristicsConversionTable[$column.'_'.$key])){
$key = $column.'_'.$key;
}
if(!empty($this->characteristicsConversionTable[$key])){
if(!isset($product->variant_links)){
$product->variant_links=array();
}
$product->variant_links[]=$this->characteristicsConversionTable[$key];
}
}
}
}
if (!empty($product->product_id) &&
empty($product->product_code)){
$query = 'SELECT `product_code` FROM
'.hikashop_table('product') .
' WHERE product_id='.(int)$product->product_id;
$this->db->setQuery($query);
$product->product_code = $this->db->loadResult();
}
else
if(empty($product->product_code)&&!empty($product->product_name)){
$test=preg_replace('#[^a-z0-9_-]#i','',$product->product_name);
if(empty($test)){
static $last_pid = null;
if($last_pid===null){
$query = 'SELECT MAX(`product_id`) FROM
'.hikashop_table('product');
$this->db->setQuery($query);
$last_pid = (int)$this->db->loadResult();
}
$last_pid++;
$product->product_code = 'product_'.$last_pid;
}else{
$product->product_code =
preg_replace('#[^a-z0-9_-]#i','_',$product->product_name);
}
}
if(empty($product->product_name)&&!empty($this->template->product_name)){
$product->product_name = $this->template->product_name;
}
if( !empty($this->translateColumns) ) {
foreach($this->translateColumns as $k => $v) {
if( !empty($product->$v) ) {
list($name,$lng) = explode('__tr__',$v);
if( $lng == $this->locale ) {
$product->$name =& $product->$v;
} else {
if( isset($this->translateLanguages[$lng]) ) {
if( !isset($product->translations) ) {
$product->translations = array();
}
$obj = new stdClass();
$obj->language_id = $this->translateLanguages[$lng];
$obj->reference_table = 'hikashop_product';
$obj->reference_field = $name;
$obj->value =& $product->$v;
$obj->modified_by = 0; //TODO
$obj->published = 1;
$product->translations[] = $obj;
}
}
}
}
}
$unset = array();
foreach(get_object_vars($product) as $column=>$value){
if(!empty($this->columnNamesConversionTable[$column]) &&
is_array($this->columnNamesConversionTable[$column])){
if(!empty($this->columnNamesConversionTable[$column]['append'])){
$new_column =
$this->columnNamesConversionTable[$column]['append'];
if(in_array($column,array('files','images'))){
if(is_array($value)){
$tmp=array();
foreach($value as $v){
$tmp[]='<a
href="'.$this->uploadFolder_url.$v.'">'.$v.'</a>';
}
$value = implode(',',$tmp);
}else{
$value='<a
href="'.$this->uploadFolder_url.$value.'">'.$value.'</a>';
}
}
$trans_string = 'HIKASHOP_FEED_'.strtoupper($column);
$trans = JText::_($trans_string);
if($trans_string==$trans){
$trans=$column;
}
$product->$new_column.='<div
id="hikashop_product_'.$column.'">'.$trans.':'.$value.'</div>';
$unset[]=$column;
}
if(!empty($this->columnNamesConversionTable[$column]['copy'])){
$new_column =
$this->columnNamesConversionTable[$column]['copy'];
$product->$new_column=$value;
}
}
}
if($product->product_type=='main' && $main
&& !isset($product->product_parent_id)){
if(!empty($this->template->variants)){
foreach($this->template->variants as $variant){
$copy = (!HIKASHOP_PHP5) ? $variant : clone($variant);
unset($copy->product_id);
$copy->product_parent_id = $product->product_code;
$copy->product_code =
$product->product_code.'_'.$copy->product_code;
$this->currentProductVariants[]=$copy;
}
}
}
if(!empty($unset)){
foreach($unset as $u){
unset($product->$u);
}
}
}
function getSizeFile($url) {
if (substr($url,0,4)=='http') {
$x = array_change_key_case(get_headers($url, 1),CASE_LOWER);
if ( strcasecmp($x[0], 'HTTP/1.1 200 OK') != 0 ) { $x =
$x['content-length'][1]; }
else { $x = $x['content-length']; }
}
else { $x = @filesize($url); }
return $x;
}
function
_createCategory($category,$parent_id=0,$type='product',$img='',$namekey=''){
$obj=new stdClass();
$obj->category_name = $category;
$obj->category_namekey = $namekey;
$obj->category_type = $type;
if(empty($parent_id)){
$name = 'main'.ucfirst($type).'Category';
$parent_id = @$this->$name;
}
$obj->category_parent_id = $parent_id;
$class = hikashop_get('class.category');
$new_id = $class->save($obj,false);
$this->_getCategory($obj->category_namekey,$new_id,true,$type,$parent_id);
$this->_getCategory($obj->category_name,$new_id,true,$type,$parent_id);
if($new_id && !empty($img)){
$db = JFactory::getDBO();
$base = substr($img,0,strrpos($img,'.'));
$db->setQuery('INSERT IGNORE INTO
'.hikashop_table('file').'
(`file_name`,`file_description`,`file_path`,`file_type`,`file_ref_id`)
VALUES
('.$db->Quote($base).',\'\','.$db->Quote($img).',\'category\','.(int)$new_id.');');
$db->query();
}
return $new_id;
}
function
_getCategory($code,$newId=0,$error=true,$type='product',$parent_id=0,$image=''){
static $data=array();
$namekey = $code;
$parent_condition = '';
if(!empty($parent_id)){
$namekey.='__'.$parent_id;
$parent_condition = ' AND category_parent_id='.$parent_id;
}
if(!empty($newId)){
$data[$code] = $newId;
$data[$namekey] = $newId;
}
if(!isset($data[$namekey])){
$query = 'SELECT category_id FROM
'.hikashop_table('category').' WHERE
category_namekey='.$this->db->Quote($code).' AND
category_type='.$this->db->Quote($type).$parent_condition;
$this->db->setQuery($query);
$data[$namekey] = $this->db->loadResult();
if(empty($data[$namekey])){
$query = 'SELECT category_id FROM
'.hikashop_table('category').' WHERE
category_name='.$this->db->Quote($code).' AND
category_type='.$this->db->Quote($type).$parent_condition;
$this->db->setQuery($query);
$data[$namekey] = $this->db->loadResult();
if(empty($data[$namekey])){
if($error){
$app =& JFactory::getApplication();
$app->enqueueMessage('The '.$type.' category
"'.$code.'" could not be found in the database.
Products imported and using this '.$type.' category will be
linked to the main '.$type.' category.');
$name = 'main'.ucfirst($type).'Category';
$data[$namekey] = @$this->$name;
}else{
$data[$namekey] = 0;
}
}
}
}
if($data[$namekey] && !empty($image)){
$base = substr($image,0,strrpos($image,'.'));
$this->db->setQuery('DELETE FROM
'.hikashop_table('file').' WHERE file_type =
\'category\' AND
file_ref_id='.(int)$data[$namekey].';');
$this->db->query();
$this->db->setQuery('INSERT IGNORE INTO
'.hikashop_table('file').'
(`file_name`,`file_description`,`file_path`,`file_type`,`file_ref_id`)
VALUES
('.$this->db->Quote($base).',\'\','.$this->db->Quote($image).',\'category\','.(int)$data[$namekey].');');
$this->db->query();
}
return $data[$namekey];
}
function _getRelated($code){
static $data=array();
if(!isset($data[$code])){
$query = 'SELECT product_id FROM
'.hikashop_table('product').' WHERE
product_code='.$this->db->Quote($code);
$this->db->setQuery($query);
$id = $this->db->loadResult();
if(empty($id)){
$query = 'SELECT product_id FROM
'.hikashop_table('product').' WHERE
product_id='.$this->db->Quote($code);
$this->db->setQuery($query);
$id = $this->db->loadResult();
if(empty($id)){
return $code;
}else{
$data[$code] = $id;
}
}else{
$data[$code] = $id;
}
}
return $data[$code];
}
function _getAccess($access){
static $data=array();
if(!isset($data[$access])){
if(version_compare(JVERSION,'1.6','<')){
$query = 'SELECT id FROM
'.hikashop_table('core_acl_aro_groups',false).' WHERE
name='.$this->db->Quote($access);
}else{
$query = 'SELECT id FROM
'.hikashop_table('usergroups',false).' WHERE
title='.$this->db->Quote($access);
}
$this->db->setQuery($query);
$data[$access] = (int)$this->db->loadResult();
}
return $data[$access];
}
function _getCurrency($code){
static $data=array();
if(!isset($data[$code])){
$query = 'SELECT currency_id FROM
'.hikashop_table('currency').' WHERE
currency_code='.$this->db->Quote(strtoupper($code));
$this->db->setQuery($query);
$data[$code] = $this->db->loadResult();
}
return $data[$code];
}
function _insertPrices(&$products){
$values = array();
$totalValid=0;
$insert = 'INSERT IGNORE INTO
'.hikashop_table('price').'
(`price_value`,`price_currency_id`,`price_min_quantity`,`price_product_id`,`price_access`)
VALUES (';
$ids = array();
foreach($products as $product){
if(empty($product->prices) &&
empty($product->hikashop_update)){
if(@$product->product_type!='variant' &&
!empty($this->template->prices)){
foreach($this->template->prices as $price){
$value =
array($this->db->Quote($price->price_value),(int)$price->price_currency_id,(int)$price->price_min_quantity,(int)$product->product_id,$this->db->Quote(@$price->price_access));
$values[] = implode(',',$value);
$totalValid++;
if( $totalValid%$this->perBatch == 0){
$this->db->setQuery($insert.implode('),(',$values).')');
$this->db->query();
$totalValid=0;
$values=array();
}
}
}
}elseif(!empty($product->prices)){
$ids[]=(int)$product->product_id;
foreach($product->prices as $price){
$value =
array($this->db->Quote($price->price_value),(int)$price->price_currency_id,(int)$price->price_min_quantity,(int)$product->product_id,$this->db->Quote(@$price->price_access));
$values[] = implode(',',$value);
$totalValid++;
if( $totalValid%$this->perBatch == 0){
if(!empty($ids)){
$this->db->setQuery('DELETE FROM
'.hikashop_table('price').' WHERE price_product_id IN
('.implode(',',$ids).')');
$this->db->query();
$ids=array();
}
$this->db->setQuery($insert.implode('),(',$values).')');
$this->db->query();
$totalValid=0;
$values=array();
}
}
}
}
if(!empty($values)){
if(!empty($ids)){
$this->db->setQuery('DELETE FROM
'.hikashop_table('price').' WHERE price_product_id IN
('.implode(',',$ids).')');
$this->db->query();
}
$this->db->setQuery($insert.implode('),(',$values).')');
$this->db->query();
}
}
function _insertCategories(&$products){
$values = array();
$totalValid=0;
$insert = 'INSERT IGNORE INTO
'.hikashop_table('product_category').'
(`category_id`,`product_id`,`ordering`) VALUES (';
$ids = array();
foreach($products as $product){
if(empty($product->categories) &&
empty($product->hikashop_update)){
if(@$product->product_type!='variant'){
if(empty($this->template->categories)){
$product->categories = array($this->mainProductCategory);
}else{
foreach($this->template->categories as $k => $id){
static $orderings = array();
if(!isset($orderings[(int)$id])){
$this->db->setQuery('SELECT max(ordering) FROM
'.hikashop_table('product_category').' WHERE
category_id='.(int)$id);
$orderings[(int)$id] = (int)$this->db->loadResult();
}
$orderings[(int)$id]++;
$value =
array((int)$id,$product->product_id,$orderings[(int)$id]);
$values[] = implode(',',$value);
$totalValid++;
if( $totalValid%$this->perBatch == 0){
$this->db->setQuery($insert.implode('),(',$values).')');
$this->db->query();
$totalValid=0;
$values=array();
}
}
}
}
}
if(!empty($product->categories)){
$ids[] = (int)$product->product_id;
foreach($product->categories as $k => $id){
$value =
array((int)$id,(int)$product->product_id,(int)@$product->categories_ordering[$k]);
$values[] = implode(',',$value);
$totalValid++;
if( $totalValid%$this->perBatch == 0){
if(!empty($ids)){
$this->db->setQuery('DELETE FROM
'.hikashop_table('product_category').' WHERE product_id
IN ('.implode(',',$ids).')');
$this->db->query();
$ids=array();
}
$this->db->setQuery($insert.implode('),(',$values).')');
$this->db->query();
$totalValid=0;
$values=array();
}
}
}
}
if(!empty($values)){
if(!empty($ids)){
$this->db->setQuery('DELETE FROM
'.hikashop_table('product_category').' WHERE product_id
IN ('.implode(',',$ids).')');
$this->db->query();
}
$this->db->setQuery($insert.implode('),(',$values).')');
$this->db->query();
}
}
function _insertRelated(&$products,$type='related'){
$values = array();
$totalValid=0;
$insert = 'INSERT IGNORE INTO
'.hikashop_table('product_related').'
(`product_related_id`,`product_related_type`,`product_id`) VALUES (';
$ids=array();
foreach($products as $product){
if(!isset($product->$type) &&
empty($product->hikashop_update)){
if(@$product->product_type!='variant' &&
!empty($this->template->$type)){
foreach($this->template->$type as $id){
$value =
array((int)$id,$this->db->Quote($type),$product->product_id);
$values[] = implode(',',$value);
$totalValid++;
if( $totalValid%$this->perBatch == 0){
$this->db->setQuery($insert.implode('),(',$values).')');
$this->db->query();
$totalValid=0;
$values=array();
}
}
}
}elseif(isset($product->$type)&&is_array($product->$type)){
$ids[] = (int)$product->product_id;
foreach($product->$type as $k => $id){
if(!empty($id)){
$id = $this->_getRelated($id);
$product->{$type}[$k] = $id;
$value =
array((int)$id,$this->db->Quote($type),$product->product_id);
$values[] = implode(',',$value);
$totalValid++;
}
if( $totalValid%$this->perBatch == 0){
if(!empty($ids)){
$this->db->setQuery('DELETE FROM
'.hikashop_table('product_related').' WHERE product_id
IN ('.implode(',',$ids).') AND
product_related_type='.$this->db->Quote($type));
$this->db->query();
$ids=array();
}
$this->db->setQuery($insert.implode('),(',$values).')');
$this->db->query();
$totalValid=0;
$values=array();
}
}
}
}
if(!empty($ids)){
$this->db->setQuery('DELETE FROM
'.hikashop_table('product_related').' WHERE product_id
IN ('.implode(',',$ids).') AND
product_related_type='.$this->db->Quote($type));
$this->db->query();
}
if(!empty($values)){
$this->db->setQuery($insert.implode('),(',$values).')');
$this->db->query();
}
}
function _insertVariants(&$products){
$values = array();
$totalValid=0;
$insert = 'INSERT IGNORE INTO
'.hikashop_table('variant').'
(`variant_characteristic_id`,`variant_product_id`) VALUES (';
$ids = array();
foreach($products as $product){
if(empty($product->variant_links)&&!empty($this->template->variant_links)
&& empty($product->hikashop_update)){
$product->variant_links = $this->template->variant_links;
}
if(!empty($product->variant_links)){
$ids[] = (int)$product->product_id;
foreach($product->variant_links as $link){
$value = array((int)$link,(int)$product->product_id);
$values[] = implode(',',$value);
$totalValid++;
if( $totalValid%$this->perBatch == 0){
if(!empty($ids)){
$this->db->setQuery('DELETE FROM
'.hikashop_table('variant').' WHERE variant_product_id
IN ('.implode(',',$ids).')');
$this->db->query();
$ids=array();
}
$this->db->setQuery($insert.implode('),(',$values).')');
$this->db->query();
$totalValid=0;
$values=array();
}
}
}
}
if(!empty($values)){
if(!empty($ids)){
$this->db->setQuery('DELETE FROM
'.hikashop_table('variant').' WHERE variant_product_id
IN ('.implode(',',$ids).')');
$this->db->query();
}
$this->db->setQuery($insert.implode('),(',$values).')');
$this->db->query();
}
}
function _insertTranslations(&$products){
$value = array();
$product_translation = false;
$translations = array();
foreach($products as $p) {
if( !empty($p->translations) ) {
$product_translation = true;
$translation = reset($p->translations);
foreach( get_object_vars($translation) as $key => $field){
$value[] = $key;
}
$value[] = 'reference_id';
break;
}
}
if(!$product_translation) {
if(empty($this->template->translations) ||
!empty($product->hikashop_update)) {
return true;
}
$translations =& $this->template->translations;
$translation = reset($translations);
if(isset($translation->id)) unset($translation->id);
foreach(get_object_vars($translation) as $key => $field){
$value[] = $key;
}
}
$ids = array();
$values = array();
$totalValid=0;
$translationHelper = hikashop_get('helper.translation');
if($translationHelper->isMulti(true,false)){
$trans_table = 'jf_content';
if($translationHelper->falang){
$trans_table = 'falang_content';
}
$insert = 'INSERT IGNORE INTO
'.hikashop_table($trans_table,false).'
('.implode(',',$value).') VALUES (';
foreach($products as $product){
if($product_translation) {
unset($translations);
$translations =& $product->translations;
}
if(empty($translations) || !is_array($translations)) continue;
foreach($translations as $translation){
$translation->reference_id = $product->product_id;
if(isset($translation->id)) unset($translation->id);
$value = array();
foreach(get_object_vars($translation) as $field){
$value[] = $this->db->Quote($field);
}
$values[] = implode(',',$value);
$ids[] =
'language_id='.(int)$translation->language_id.' AND
reference_id='.(int)$translation->reference_id.' AND
reference_table='.$this->db->Quote($translation->reference_table).'
AND
reference_field='.$this->db->Quote($translation->reference_field);
$totalValid++;
if( $totalValid%$this->perBatch == 0){
if(!empty($ids)){
$this->db->setQuery('DELETE FROM
'.hikashop_table($trans_table,false).' WHERE (' .
implode(') OR (', $ids) . ')');
$this->db->query();
$ids=array();
}
$this->db->setQuery($insert.implode('),(',$values).')');
$this->db->query();
$totalValid=0;
$values=array();
}
}
}
if(!empty($values)){
if(!empty($ids)){
$this->db->setQuery('DELETE FROM
'.hikashop_table($trans_table,false).' WHERE (' .
implode(') OR (', $ids) . ')');
$this->db->query();
}
$this->db->setQuery($insert.implode('),(',$values).')');
$this->db->query();
}
}
}
function _insertFiles(&$products,$type='files'){
$db_type = 'product';
if($type=='files'){
$db_type='file';
}
$values = array();
$totalValid=0;
$ids=array();
$insert = 'INSERT IGNORE INTO
'.hikashop_table('file').'
(`file_name`,`file_description`,`file_path`,`file_type`,`file_ref_id`,`file_ordering`)
VALUES (';
foreach($products as $product){
if(!isset($product->$type) &&
empty($product->hikashop_update)){
if(@$product->product_type!='variant' &&
!empty($this->template->$type)){
foreach($this->template->$type as $file){
$value =
array($this->db->Quote($file->file_name),$this->db->Quote($file->file_description),$this->db->Quote($file->file_path),$this->db->Quote($db_type),$product->product_id,$this->db->Quote($file->file_ordering));
$values[] = implode(',',$value);
$totalValid++;
if( $totalValid%$this->perBatch == 0){
$this->db->setQuery($insert.implode('),(',$values).')');
$this->db->query();
$totalValid=0;
$values=array();
}
}
}
}elseif(!empty($product->$type)){
$ids[]=(int)$product->product_id;
$ordering = 0;
foreach($product->$type as $file){
if(is_string($file)){
$value =
array($this->db->Quote(str_replace('_','
',substr($file,0,strrpos($file,'.')))),$this->db->Quote(''),$this->db->Quote($file),$this->db->Quote($db_type),$product->product_id,$ordering);
}else{
$value =
array($this->db->Quote($file->file_name),$this->db->Quote($file->file_description),$this->db->Quote($file->file_path),$this->db->Quote($db_type),$product->product_id,$ordering);
}
$ordering++;
$values[] = implode(',',$value);
$totalValid++;
if( $totalValid%$this->perBatch == 0){
if(!empty($ids)){
$this->db->setQuery('DELETE FROM
'.hikashop_table('file').' WHERE file_ref_id IN
('.implode(',',$ids).') AND
file_type=\''.$db_type.'\'');
$this->db->query();
$ids = array();
}
$this->db->setQuery($insert.implode('),(',$values).')');
$this->db->query();
$totalValid=0;
$values=array();
}
}
}
}
if(!empty($values)){
if(!empty($ids)){
$this->db->setQuery('DELETE FROM
'.hikashop_table('file').' WHERE file_ref_id IN
('.implode(',',$ids).') AND
file_type=\''.$db_type.'\'');
$this->db->query();
}
$this->db->setQuery($insert.implode('),(',$values).')');
$this->db->query();
}
}
function _separate(&$files){
$separator='';
foreach($this->listSeparators as $sep){
$pos = strpos($files,$sep);
if(preg_match('#(?!\\\\)'.$sep.'#',$files)){
$separator = $sep;
$files=str_replace('\\'.$separator,'#.#.#.#',$files);
break;
}
}
if(!empty($separator)){
$files = explode($separator,$files);
}else{
$files = array($files);
}
foreach($files as $k => $v){
$files[$k]=str_replace('#.#.#.#',$separator,$v);
}
}
function _autoDetectHeader(){
$app = JFactory::getApplication();
$this->separator = ',';
$this->header =
str_replace("\xEF\xBB\xBF","",$this->header);
foreach($this->listSeparators as $sep){
if(strpos($this->header,$sep) !== false){
$this->separator = $sep;
break;
}
}
$this->columns = explode($this->separator,$this->header);
$this->translateColumns = array();
if(!HIKASHOP_J30){
$columnsTable =
$this->db->getTableFields(hikashop_table('product'));
$columns = reset($columnsTable);
} else {
$columns =
$this->db->getTableColumns(hikashop_table('product'));
}
$columns['price_value']='price_value';
$columns['price_value_with_tax']='price_value_with_tax';
$columns['price_currency_id']='price_currency_id';
$columns['price_min_quantity']='price_min_quantity';
$columns['price_access']='price_access';
$columns['files']='files';
$columns['images']='images';
$columns['parent_category']='parent_category';
$columns['categories_namekey']='categories_namekey';
$columns['categories_image']='categories_image';
$columns['categories_ordering']='categories_ordering';
$columns['categories']='categories';
$columns['related']='related';
$columns['options']='options';
if(hikashop_level(2)){
$columns['product_access']='product_access';
$columns['product_group_after_purchase']='product_group_after_purchase';
}
foreach($this->columns as $i => $oneColumn){
if(function_exists('mb_strtolower')){
$this->columns[$i] = mb_strtolower(trim($oneColumn,'"
'));
}else{
$this->columns[$i] = strtolower(trim($oneColumn,'"
'));
}
$this->columns[$i] = strtolower(trim($oneColumn,'"
'));
foreach($this->columns as $k => $otherColumn){
if($i != $k && $this->columns[$i] ==
strtolower($otherColumn)) {
$app->enqueueMessage('The column
"'.$this->columns[$i].'" is twice in your CSV. Only
the second column data will be taken into
account.','error');
}
}
if( strpos($this->columns[$i],'|') !== false ) {
$this->columns[$i] =
str_replace('|','__tr__',$this->columns[$i]);
$this->translateColumns[] = $this->columns[$i];
$columns[$this->columns[$i]] = '';
}
if(!isset($columns[$this->columns[$i]])){
if( isset($this->columnNamesConversionTable[$this->columns[$i]])
){
if(is_array($this->columnNamesConversionTable[$this->columns[$i]])){
$this->columnNamesConversionTable[$this->columnNamesConversionTable[$this->columns[$i]]['name']]=$this->columnNamesConversionTable[$this->columns[$i]];
$this->columns[$i]=$this->columnNamesConversionTable[$this->columns[$i]]['name'];
}else{
$this->columns[$i]=$this->columnNamesConversionTable[$this->columns[$i]];
}
}else{
if(isset($this->characteristicsConversionTable[$this->columns[$i]])){
$this->characteristicColumns[] = $this->columns[$i];
}else{
$possibilities =
array_diff(array_keys($columns),array('product_id'));
if(!empty($this->characteristics)){
foreach($this->characteristics as $char){
if(empty($char->characteristic_parent_id)){
if(function_exists('mb_strtolower')){
$possibilities[]=mb_strtolower(trim($char->characteristic_value,'
"'));
}else{
$possibilities[]=strtolower(trim($char->characteristic_value,'
"'));
}
}
}
}
if($this->header_errors){
$app->enqueueMessage(JText::sprintf('IMPORT_ERROR_FIELD',$this->columns[$i],implode('
| ',$possibilities)),'error');
}
}
}
}
}
$config = JFactory::getConfig();
if(HIKASHOP_J30){
$this->locale = strtolower($config->get('language'));
}else{
$this->locale =
strtolower($config->getValue('config.language'));
}
$this->translateLanguages = array();
$transHelper = hikashop_get('helper.translation');
if($transHelper->isMulti(true,false)){
$languages = $transHelper->loadLanguages();
if(!empty($languages)){
foreach($languages as $language) {
$this->translateLanguages[ strtolower($language->code) ] =
$language->id;
}
}
}
return true;
}
function _insertProducts(&$products){
$this->_insertOneTypeOfProducts($products,'main');
foreach($products as $k => $variant){
if($variant->product_type!='main'){
$parent_code = $variant->product_parent_id;
if(is_numeric($parent_code)){
foreach($products as $k2 => $main){
if($variant->product_parent_id == $main->product_id){
$parent_code=$main->product_code;
}
}
}
if(!empty($this->codes[$parent_code])){
$products[$k]->product_parent_id =
@$this->codes[$parent_code]->product_id;
}
if(empty($products[$k]->product_parent_id)){
unset($products[$k]->product_parent_id);
}
}
}
$this->_insertOneTypeOfProducts($products,'variant');
$this->_insertVariants($products);
$this->_insertPrices($products);
$this->_insertFiles($products,'images');
$this->_insertFiles($products,'files');
$this->_insertCategories($products);
$this->_insertRelated($products);
$this->_insertRelated($products,'options');
$this->_insertTranslations($products);
$this->products =& $products;
}
function _insertOneTypeOfProducts(&$products,$type='main'){
if(empty($products)) return true;
$lines = array();
$totalValid=0;
$fields = array();
$all_fields = $this->all_fields;
if($type!='main'){
$all_fields[]='product_parent_id';
}
$all_fields[]='product_id';
foreach($this->columnsProductTable as $field){
if(!in_array($field,$all_fields)){
$all_fields[]=$field;
}
}
foreach($all_fields as $field){
$fields[]= '`'.$field.'`';
}
$fields = implode(', ',$fields);
$insert = 'REPLACE INTO
'.hikashop_table('product').' ('.$fields.')
VALUES (';
$codes = array();
foreach($products as $product){
if($product->product_type!=$type) continue;
$codes[$product->product_code] =
$this->db->Quote($product->product_code);
}
if(!empty($codes)){
$query = 'SELECT * FROM '.hikashop_table('product').
' WHERE product_code IN
('.implode(',',$codes).')';
$this->db->setQuery($query);
$already = $this->db->loadObjectList('product_id');
if(!empty($already)){
foreach($already as $code){
$found = false;
foreach($products as $k => $product){
if($product->product_code==$code->product_code){
$found = $k;
break;
}
}
if($found!==false){
if($this->overwrite){
if(!empty($products[$found]->product_type) &&
!empty($code->product_type) &&
$products[$found]->product_type==$code->product_type){
$products[$found]->product_id = $code->product_id;
$products[$found]->hikashop_update = true;
}else{
unset($products[$found]);
$app = JFactory::getApplication();
$app->enqueueMessage('The product
'.$products[$found]->product_code.' is of the type '.
$products[$found]->product_type.' but it already exists in the
database and is of the type '.$code->product_type.'. In order
to avoid any problem the product insertion process has been skipped. Please
correct its type before trying to reimport it.','error');
}
}else{
unset($products[$found]);
}
}
}
}
$exist=0;
if(!empty($codes)){
foreach($products as $product){
if($product->product_type!=$type ||
empty($codes[$product->product_code])) continue;
$line = array();
foreach($all_fields as $field){
if(!isset($product->$field) &&
!empty($product->product_id) &&
isset($already[$product->product_id])){
$product->$field = $already[$product->product_id]->$field;
}
if($field=='product_id'){
if(empty($product->$field)|| !is_numeric($product->$field)){
$line[] = 'NULL';
}else{
$exist++;
$line[] = $this->db->Quote(@$product->$field);
}
}else{
if($field=='product_published' &&
!isset($product->$field) && $this->force_published){
$product->product_published=1;
}
if($field=='product_quantity' &&
!isset($product->$field) && $this->force_published){
$product->product_quantity=-1;
}
if(JRequest::getInt('update_product_quantity','0')
&& $field=='product_quantity' &&
$product->product_quantity != -1){
$product->product_quantity +=
$already[$product->product_id]->$field;
}
$line[] = $this->db->Quote(@$product->$field);
}
}
$lines[]=implode(',',$line);
$totalValid++;
if( $totalValid%$this->perBatch == 0){
$this->db->setQuery($insert.implode('),(',$lines).')');
$this->db->query();
if($type=='main' || $this->countVariant){
$this->totalInserted += count($lines);
}
$totalValid=0;
$lines=array();
}
}
if(!empty($lines)){
$this->db->setQuery($insert.implode('),(',$lines).')');
$this->db->query();
if($type=='main' || $this->countVariant){
$this->totalInserted += count($lines);
}
}
}
$this->totalInserted=$this->totalInserted-$exist;
if(!empty($codes)){
$query = 'SELECT product_code, product_id FROM
'.hikashop_table('product'). ' WHERE product_code IN
('.implode(',',$codes).')';
$this->db->setQuery($query);
$newCodes =
(array)$this->db->loadObjectList('product_code');
foreach($newCodes as $k => $code){
$this->codes[$k]=$code;
}
foreach($products as $k => $product){
if($product->product_type==$type &&
!empty($this->codes[$product->product_code])){
$products[$k]->product_id =
@$this->codes[$product->product_code]->product_id;
if($type=='variant'){
$this->products_already_in_db[(int)@$products[$k]->product_parent_id]=(int)@$products[$k]->product_parent_id;
$this->new_variants_in_db[(int)@$products[$k]->product_id]=(int)@$products[$k]->product_id;
}
}
}
}
}
}
function getHtmlPage()
{
switch ($this->importName)
{
case 'openc':
$buff = 'Opencart';
break;
case 'mijo':
$buff = 'Mijoshop';
break;
case 'reds':
$buff = 'Redshop';
break;
case 'vm':
$buff = 'Virtuemart';
break;
default:
$buff = '';
break;
}
$imgFolder = HIKASHOP_IMAGES.'icons/icon-48-import.png';
return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
.
'<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en-gb" lang="en-gb" dir="ltr"
id="minwidth" >' .
'<head><meta http-equiv="content-type"
content="text/html; charset=utf-8" /><title>HikaShop -
'.$buff.' Import</title>' .
'<script type="text/javascript">' .
"\r\n" . 'var r = false; function
import'.ucfirst($this->importName).'() { setTimeout(
function() { if(r) window.location.reload(); }, 1000 ); }' .
"\r\n" . '</script>' .
'</head><body
onload="import'.ucfirst($this->importName).'()">'.
'<div style="width:auto; height:48px;
margin:15px;"><div
style="background-image:url('.$imgFolder.');width:48px;height:48px;float:left;"></div><h1
style="color:#3AABC6; font-size:1.4em; float:left;"><span
style="color:#297F93">Â HikaShop :</span>
'.JText::sprintf('PRODUCTS_FROM_X',$buff).'</h1></div><br/>'.
'<div style="margin-left:20px;">';
}
function getStartPage()
{
$buff = $this->importName;
if ($buff == 'reds')
$buff='redshop';
return '<span style="color:#297F93;
font-size:1.2em;text-decoration:underline;">Step
0</span><br/><br/>'.
'Make a backup of your database.<br/>'.
'When ready, click on <a '.$this->linkstyle.'
href="'.hikashop_completeLink('import&task=import&importfrom='.$buff.'&'.$this->token.'=1&import=1').'">'.JText::_('HIKA_NEXT').'</a>,
otherwise '.
'<a'.$this->linkstyle.'
href="'.hikashop_completeLink('import&task=show').'">'.JText::_('HIKA_BACK').'</a>.';
}
function proposeReImport()
{
$buff = $this->importName;
if ($buff == 'reds')
$buff='redshop';
if( !isset($_GET['reimport']) )
{
echo '<p>You have already make an import. If you restart it,
the import system will just import new elements</p>';
echo
'<p><span'.$this->bullstyle.'>►</span>
<a'.$this->linkstyle.'href="'.hikashop_completeLink('import&task=import&importfrom='.$buff.'&'.$this->token.'=1&import=1&reimport=1').'">Import
new elements</a></p>';
return false;
}
$sql = "UPDATE `#__hikashop_config` SET config_value=1 WHERE
config_namekey =
'".$this->importName."_import_state';";
$this->db->setQuery($sql);
$this->db->query();
$this->refreshPage = true;
echo '<p>The import will restart and import new
elements...</p>';
return true;
}
function importRebuildTree()
{
if( $this->db == null )
return false;
$categoryClass = hikashop_get('class.category');
$query = 'SELECT
category_namekey,category_left,category_right,category_depth,category_id,category_parent_id
FROM `#__hikashop_category` ORDER BY category_left ASC';
$this->db->setQuery($query);
$categories = $this->db->loadObjectList();
$root = null;
$categoryClass->categories = array();
foreach($categories as $cat){
$categoryClass->categories[$cat->category_parent_id][]=$cat;
if(empty($cat->category_parent_id)){
$root = $cat;
}
}
$categoryClass->rebuildTree($root,0,1);
}
function copyFile($dir, $fsrc, $dst, $debug = false)
{
if ($debug)
{
var_dump($dir);
var_dump($fsrc);
var_dump($dst);
}
$src = $fsrc;
if( file_exists($dir.$fsrc) )
$src = $dir.$fsrc;
else if( file_exists(HIKASHOP_ROOT.$fsrc) )
$src = HIKASHOP_ROOT.$fsrc;
if( file_exists($src) )
{
if( !file_exists($dst) )
{
$ret = JFile::copy($src, $dst);
if( !$ret )
echo '<span '.$this->copywarning.'>The file
"' . $src . '" could not be copied to "' .
$dst . '"</span><br/>';
}
else
echo '<span '.$this->copywarning.'>File already
exists "' .$dst . '" ("' . $src .
'")</span><br/>';
}
else
{
echo '<span '.$this->copywarning.'>File is not
found "' . $src . '"</span><br/>';
}
}
}
joomla25.php000064400000002527151162557560006730 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class JHtmlHikaselect extends JHTMLSelect {
static $event = false;
public static function inheritRadiolist($name, $selected = null, $extra =
array(), $attribs = null, $id = false){
$arr = array(
JHtml::_('select.option', '-1',
JText::_('HIKA_INHERIT')),
JHtml::_('select.option', '1',
JText::_('JYES')),
JHtml::_('select.option', '0',
JText::_('JNO'))
);
if(!is_array($extra))
$extra = array($extra);
foreach($extra as $option){
$arr[] = $option;
}
$shortName =
str_replace(']','',preg_replace('#(.*)\[#','',$name));
$config = hikashop_config();
if($shortName == 'display_filters')
$shortName = 'show_filters';
$default = $config->get($shortName,'');
$default_params = $config->get('default_params');
if(isset($default_params[$shortName])){
$default = $default_params[$shortName];
}
foreach($arr as $k => $v){
$arr[$k]->booleanlist = true;
if($v->value == $default)
$v->default = true;
}
return self::radiolist($arr, $name, $attribs, 'value',
'text', (int) $selected, $id);
}
}
joomla30.php000064400000011466151162557560006726 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class JHtmlHikaselect extends JHTMLSelect {
static $event = false;
public static function booleanlist($name, $attribs = null, $selected =
null, $yes = 'JYES', $no = 'JNO', $id = false){
$arr = array(
JHtml::_('select.option', '1', JText::_($yes)),
JHtml::_('select.option', '0', JText::_($no))
);
$arr[0]->booleanlist = true;
$arr[1]->booleanlist = true;
return JHtml::_('hikaselect.radiolist', $arr, $name, $attribs,
'value', 'text', (int) $selected, $id);
}
public static function radiolist($data, $name, $attribs = null, $optKey =
'value', $optText = 'text', $selected = null, $idtag =
false, $translate = false, $vertical = false){
reset($data);
$app = JFactory::getApplication();
if(!self::$event) {
self::$event = true;
$doc = JFactory::getDocument();
if($app->isAdmin()) {
$doc->addScriptDeclaration('
(function($){
$.propHooks.checked = {
set: function(elem, value, name) {
var ret = (elem[ name ] = value);
$(elem).trigger("change");
return ret;
}
};
})(jQuery);');
} else {
JHtml::_('jquery.framework');
$doc->addScriptDeclaration('
(function($){
if(!window.hikashopLocal)
window.hikashopLocal = {};
window.hikashopLocal.radioEvent = function(el) {
var id = $(el).attr("id"), c = $(el).attr("class"),
lbl = $("label[for=\"" + id + "\"]");
if(c !== undefined && c.length > 0)
lbl.addClass(c);
lbl.addClass("active");
$("input[name=\"" + $(el).attr("name") +
"\"]").each(function() {
if($(this).attr("id") != id) {
c = $(this).attr("class");
lbl = $("label[for=\"" +
jQuery(this).attr("id") + "\"]");
if(c !== undefined && c.length > 0)
lbl.removeClass(c);
lbl.removeClass("active");
}
});
}
$(document).ready(function() {
setTimeout(function(){ $(".hikaradios .btn-group
label").off("click"); }, 200);
});
})(jQuery);');
}
}
if (is_array($attribs)) {
$attribs = JArrayHelper::toString($attribs);
}
$id_text =
str_replace(array('[',']'),array('_',''),$idtag
? $idtag : $name);
$backend = $app->isAdmin();
$htmlLabels = '';
if($backend) {
$html = '<div class="controls"><fieldset
id="'.$id_text.'" class="radio btn-group'.
($vertical?'
btn-group-vertical':'').'">';
} else {
$html = '<div class="hikaradios"
id="'.$id_text.'">';
}
foreach ($data as $obj) {
$k = $obj->$optKey;
$t = $translate ? JText::_($obj->$optText) : $obj->$optText;
$class = isset($obj->class) ? $obj->class : '';
$sel = false;
$extra = $attribs;
$currId = $id_text . $k;
if(isset($obj->id))
$currId = $obj->id;
if (is_array($selected)) {
foreach ($selected as $val) {
$k2 = is_object($val) ? $val->$optKey : $val;
if ($k == $k2) {
$extra .= ' selected="selected"';
$sel = true;
break;
}
}
} elseif((string) $k == (string) $selected) {
$extra .= ' checked="checked"';
$sel = true;
}
if($backend) {
$html .= "\n\t" . "\n\t" . '<input
type="radio" name="' . $name . '"' .
' id="' . $currId . '" value="' . $k .
'"' . ' ' . $extra . '/>';
$html .= "\n\t" . '<label for="' . $currId
. '"' . '>' . $t . '</label>';
} else {
$extra = ' '.$extra;
if(strpos($extra, ' style="') !== false) {
$extra = str_replace(' style="', '
style="display:none;', $extra);
} elseif(strpos($extra, 'style=\'') !== false) {
$extra = str_replace(' style=\'', '
style=\'display:none;', $extra);
} else {
$extra .= ' style="display:none;"';
}
if(strpos($extra, ' onchange="') !== false) {
$extra = str_replace(' onchange="', '
onchange="hikashopLocal.radioEvent(this);', $extra);
} elseif(strpos($extra, 'onchange=\'') !== false) {
$extra = str_replace(' onchange=\'', '
onchange=\'hikashopLocal.radioEvent(this);', $extra);
} else {
$extra .= '
onchange="hikashopLocal.radioEvent(this);"';
}
if(!empty($obj->class)) {
$extra .= '
class="'.$obj->class.'"';
}
$html .= "\n\t" . '<input type="radio"
name="' . $name . '"' . ' id="' .
$currId . '" value="' . $k . '"' .
' ' . $extra . ' ' . $attribs . '/>';
$htmlLabels .= "\n\t"."\n\t" . '<label
for="' . $currId . '"' . '
class="btn'. ($sel ? ' active '.$class : '')
.'">' . $t . '</label>';
}
}
if($backend) {
$html .= '</fieldset></div>';
} else {
$html .= "\n" . '<div class="btn-group'.
($vertical?' btn-group-vertical':'').'"
data-toggle="buttons-radio">' . $htmlLabels .
"\n" . '</div>';
$html .= "\n" . '</div>';
}
$html .= "\n";
return $html;
}
}
module.php000064400000014234151162557560006563 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopModuleHelper{
function initialize(&$obj){
$this->_getParams($obj);
$this->setCSS($obj->params,@$obj->module);
$obj->modules =
$this->setModuleData($obj->params->get('modules'));
}
function setCSS(&$params,$name=''){
$css ='';
$main_div_name = $params->get('main_div_name');
if(empty($main_div_name)){
$main_div_name
='hikashop_category_information_'.($name?'module_':'menu_').$params->get('id');
$params->set('main_div_name',$main_div_name);
}
$config =& hikashop_config();
if($config->get('no_css_header',0)){
return true;
}
if($params->get('background_color','')==''){
$defaultParams = $config->get('default_params');
$params->set('background_color',$defaultParams['background_color']);
}
if($params->get('margin','')==''){
$defaultParams = $config->get('default_params');
$params->set('margin',$defaultParams['margin']);
}
$background_color = $params->get('background_color');
if(!empty($background_color)){
$css='
#'.$main_div_name.' div.hikashop_subcontainer {
background:'.$background_color.';
}
#'.$main_div_name.' .hikashop_rtop
*,#'.$main_div_name.' .hikashop_rbottom *{
background:'.$background_color.';
}
';
}
if($params->get('text_center','-1')=='-1'){
$config =& hikashop_config();
$defaultParams = $config->get('default_params');
$params->set('text_center',$defaultParams['text_center']);
}
$center = $params->get('text_center');
if(!empty($center)){
$css.='
#'.$main_div_name.'
div.hikashop_subcontainer,#'.$main_div_name.'
div.hikashop_subcontainer span {
text-align:center;
}
#'.$main_div_name.' div.hikashop_container {
text-align:center;
}
';
}else{
$css.='
#'.$main_div_name.'
div.hikashop_subcontainer,#'.$main_div_name.'
div.hikashop_subcontainer span {
text-align:left;
}
#'.$main_div_name.' div.hikashop_container {
text-align:left;
}
';
}
$margin = $params->get('margin',0);
$css.='
#'.$main_div_name.' div.hikashop_container {
margin:'.$margin.'px '.$margin.'px;
}
#'.$main_div_name.'
div.hikashop_category,#'.$main_div_name.' div.hikashop_product{
float:left;
}';
if($params->get('rounded_corners','-1')=='-1'){
$config =& hikashop_config();
$defaultParams = $config->get('default_params');
$params->set('rounded_corners',$defaultParams['rounded_corners']);
}
$rounded_corners = $params->get('rounded_corners',0);
if($rounded_corners){
$css.= '
#'.$main_div_name.' .hikashop_subcontainer {
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-khtml-border-radius: 5px;
border-radius: 5px;
}
';
}else{
$css.= '
';
}
if (!HIKASHOP_PHP5) {
$doc =& JFactory::getDocument();
}else{
$doc = JFactory::getDocument();
}
$doc->addStyleDeclaration($css);
}
function setModuleData($modules){
if(!empty($modules)){
if(!is_array($modules)){
$modules = explode(',',$modules);
}
JArrayHelper::toInteger($modules);
$modules = implode(',',$modules);
$database = JFactory::getDBO();
$query = 'SELECT * FROM
'.hikashop_table('modules',false).' WHERE id IN
('.$modules.');';
$database->setQuery($query);
$modulesData = $database->loadObjectList('id');
$unset = array();
$modules = explode(',',$modules);
foreach($modules as $k => $v){
if(isset($modulesData[$v])){
$file = $modulesData[$v]->module;
$custom = substr( $file, 0, 4 ) == 'mod_' ? 0 : 1;
$modulesData[$v]->user = $custom;
$modulesData[$v]->name = $custom ? $modulesData[$v]->title :
substr( $file, 4 );
$modulesData[$v]->style = null;
$modulesData[$v]->position =
strtolower($modulesData[$v]->position);
$modules[$k] = $modulesData[$v];
}else{
$unset[]=$k;
}
}
if(!empty($unset)){
foreach($unset as $u){
unset($modules[$u]);
}
}
}else{
$modules=array();
}
return $modules;
}
function _getParams(&$obj){
if(empty($obj->params)){
global $Itemid;
$app = JFactory::getApplication();
$menus = $app->getMenu();
$menu = $menus->getActive();
if(!empty($Itemid) && !empty($menu) &&
!empty($menuData->link) &&
strpos($menu->link,'option='.HIKASHOP_COMPONENT)!==false
&& (strpos($menu->link,'view=category')!==false ||
strpos($menu->link,'view=')===false)){
$app->setUserState(HIKASHOP_COMPONENT.'.category_item_id',$Itemid);
}
if(empty($menu)){
if(!empty($Itemid)){
$menus->setActive($Itemid);
$menu = $menus->getItem($Itemid);
}else{
$item_id =
$app->getUserState(HIKASHOP_COMPONENT.'.category_item_id');
if(!empty($item_id)){
$menus->setActive($item_id);
$menu = $menus->getItem($item_id);
}
}
}
jimport('joomla.html.parameter');
if (is_object( $menu )) {
$obj->params = new HikaParameter( $menu->params );
$obj->params->set('id',$menu->id);
if(version_compare(JVERSION,'1.6','<')){
$obj->params->set('title',$menu->name);
}else{
$obj->params->set('title',$menu->title);
}
}else{
$params ='';
$obj->params = new HikaParameter($params);
}
$config =& hikashop_config();
$menuClass = hikashop_get('class.menus');
$menuData = $menuClass->get(@$menu->id);
if($config->get('auto_init_options',1) &&
!empty($menuData->link) &&
strpos($menuData->link,'view=product')===false){
$options = $config->get('menu_'.@$menu->id,null);
if(empty($options) || empty($options['modules'])){
$menuClass->createMenuOption($menuData,$options);
}
}
if(!empty($menuData->hikashop_params)){
foreach($menuData->hikashop_params as $key => $item){
$obj->params->set($key,$item);
}
}
if(!empty($menuData->params)){
foreach($menuData->params as $key => $item){
if(!is_object($item)){
$obj->params->set($key,$item);
}
}
}
}else{
$obj->module = true;
}
}
}
order.php000064400000015451151162557560006413 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopOrderHelper {
var $table = '';
var $pkey = '';
var $groupMap = '';
var $groupVal = '';
var $orderingMap = '';
function order($down = true, $useCID = true) {
$database = JFactory::getDBO();
if($down){
$sign = '>';
$dir = 'ASC';
}else{
$sign = '<';
$dir = 'DESC';
}
$orders = JRequest::getVar( 'order', array(), '',
'array' );
if($useCID) {
$ids = JRequest::getVar( 'cid', array(), '',
'array' );
} else {
$ids = array_keys($orders);
}
$orderingMap = $this->orderingMap;
$id = (int) $ids[0];
$pkey = $this->pkey;
if(!empty($this->main_pkey)){
$main = $this->main_pkey;
}else{
$main = $pkey;
}
$query = 'SELECT a.'.$orderingMap.',a.'.$pkey.'
FROM '.hikashop_table($this->table).' as b,
'.hikashop_table($this->table).' as a';
$query .= ' WHERE a.'.$orderingMap.' '.$sign.'
b.'.$orderingMap.' AND b.'.$main.' =
'.$id.$this->group(false,'a').$this->group(false,'b');
$query .= ' ORDER BY a.'.$orderingMap.' '.$dir.'
LIMIT 1';
$database->setQuery($query);
$secondElement = $database->loadObject();
if(empty($secondElement)) return false;
$firstElement = new stdClass();
if($main==$pkey){
$firstElement->$pkey = $id;
}else{
$database->setQuery('SELECT '.$pkey.' FROM
'.hikashop_table($this->table).' WHERE '.$main.' =
'.$id.$this->group(false));
$firstElement->$pkey = (int)$database->loadResult();
}
$firstElement->$orderingMap = $secondElement->$orderingMap;
if($down)$secondElement->$orderingMap--;
else $secondElement->$orderingMap++;
$status1 =
$database->updateObject(hikashop_table($this->table),$firstElement,$pkey);
$status2 =
$database->updateObject(hikashop_table($this->table),$secondElement,$pkey);
$status = $status1 && $status2;
if($status){
if (!HIKASHOP_PHP5) {
$app =& JFactory::getApplication();
}else{
$app = JFactory::getApplication();
}
$app->enqueueMessage(JText::_( 'NEW_ORDERING_SAVED' ),
'message');
}
return $status;
}
function save($useCID = true) {
$app = JFactory::getApplication();
$pkey = $this->pkey;
if(!empty($this->main_pkey)){
$main = $this->main_pkey;
}else{
$main = $pkey;
}
$orderingMap = $this->orderingMap;
$order = JRequest::getVar('order', array(), 'post',
'array');
if($useCID) {
$cid = JRequest::getVar('cid', array(), 'post',
'array');
JArrayHelper::toInteger($cid);
} else {
$cid = array_keys($order);
}
if(empty($cid)) {
$app->enqueueMessage(JText::_('ERROR_ORDERING'),
'error');
return false;
}
$database = JFactory::getDBO();
if(!empty($this->groupMap)){
$query = 'SELECT `'.$main.'` FROM
'.hikashop_table($this->table).' WHERE `'.$main.'`
IN ('.implode(',',$cid).') '. $this->group();
$database->setQuery($query);
if(!HIKASHOP_J25){
$results = $database->loadResultArray();
} else {
$results = $database->loadColumn();
}
$newcid = array();
$neworder=array();
foreach($cid as $key => $val){
if(in_array($val,$results)){
$newcid[] = $val;
if($useCID) {
$neworder[] = $order[$key];
} else {
$neworder[] = $order[$val];
}
}
}
$cid = $newcid;
$order = $neworder;
if($main!=$pkey){
$query = 'SELECT `'.$main.'`,`'.$pkey.'` FROM
'.hikashop_table($this->table).' WHERE `'.$main.'`
IN ('.implode(',',$cid).') '. $this->group();
$database->setQuery($query);
$results = $database->loadObjectList($main);
$newcid=array();
foreach($cid as $id){
$newcid[] = $results[$id]->$pkey;
}
$cid = $newcid;
}
}
if(empty($cid)) {
$app->enqueueMessage(JText::_( 'ERROR_ORDERING' ),
'error');
return false;
}
$query = 'SELECT `'.$orderingMap.'`,`'.$pkey.'`
FROM '.hikashop_table($this->table).' WHERE
`'.$pkey.'` NOT IN ('.implode(',',$cid).')
' . $this->group();
$query .= ' ORDER BY `'.$orderingMap.'` ASC';
$database->setQuery($query);
$results = $database->loadObjectList($pkey);
$oldResults = $results;
asort($order);
$newOrder = array();
while(!empty($order) || !empty($results)){
$dbElement = reset($results);
if(!empty($order) && empty($dbElement->$orderingMap) ||
(!empty($order) && reset($order) <=
$dbElement->$orderingMap)){
$newOrder[] = $cid[(int)key($order)];
unset($order[key($order)]);
}else{
$newOrder[] = $dbElement->$pkey;
unset($results[$dbElement->$pkey]);
}
}
$i = 1;
$status = true;
$element = new stdClass();
foreach($newOrder as $val){
$element->$pkey = $val;
$element->$orderingMap = $i;
if(!isset($oldResults[$val]) || $oldResults[$val]->$orderingMap !=
$i){
$status =
$database->updateObject(hikashop_table($this->table),$element,$pkey)
&& $status;
}
$i++;
}
if($status){
$app->enqueueMessage(JText::_( 'NEW_ORDERING_SAVED' ),
'message');
}else{
$app->enqueueMessage(JText::_( 'ERROR_ORDERING' ),
'error');
}
return $status;
}
function reOrder() {
$db = JFactory::getDBO();
$orderingMap = $this->orderingMap;
$query = 'SELECT MAX(`'.$orderingMap.'`) FROM
'.hikashop_table($this->table) . $this->group(true);
$db->setQuery($query);
$max = $db->loadResult();
$max++;
$query = 'UPDATE '.hikashop_table($this->table).' SET
`'.$orderingMap.'` ='.$max.' WHERE
`'.$orderingMap.'`=0' . $this->group();
$db->setQuery($query);
$db->query();
$query = 'SELECT
`'.$orderingMap.'`,`'.$this->pkey.'` FROM
'.hikashop_table($this->table) . $this->group(true);
$query .= ' ORDER BY `'.$orderingMap.'` ASC';
$db->setQuery($query);
$results = $db->loadObjectList();
$i = 1;
if(!empty($results)){
foreach($results as $oneResult){
if($oneResult->$orderingMap != $i){
$oneResult->$orderingMap = $i;
$db->updateObject( hikashop_table($this->table), $oneResult,
$this->pkey);
}
$i++;
}
}
}
function group($addWhere = false,$table = '') {
if(!empty($this->groupMap)){
$db = JFactory::getDBO();
if(is_array($this->groupMap)){
$groups = array();
foreach($this->groupMap as $k => $group){
if(!empty($table)){
$group = $table.'.'.$group;
}
$groups[]= $group.' =
'.$db->Quote($this->groupVal[$k]);
}
$groups = ' ' . implode(' AND ',$groups);
}else{
$groups = ' '
.(!empty($table)?$table.'.':'').
$this->groupMap.' = '.$db->Quote($this->groupVal);
}
if($addWhere){
$groups = ' WHERE'.$groups;
}else{
$groups = ' AND'.$groups;
}
}else{
$groups='';
}
return $groups;
}
}
pagination.php000064400000021503151162557560007424 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
jimport('joomla.html.pagination');
class hikashopBridgePaginationHelper extends JPagination {
var $hikaSuffix='';
var $form = '';
function getPagesLinks(){
$app = JFactory::getApplication();
$lang = JFactory::getLanguage();
$data = $this->_buildDataObject();
$list = array();
$itemOverride = false;
$listOverride = false;
$chromePath =
JPATH_THEMES.DS.$app->getTemplate().DS.'html'.DS.'pagination.php';
if (file_exists($chromePath)){
require_once ($chromePath);
if (function_exists('pagination_list_render')) {
$listOverride = true;
if(HIKASHOP_J30 && $app->isAdmin())
$itemOverride = true;
}
}
if ($data->all->base !== null) {
$list['all']['active'] = true;
$list['all']['data'] = ($itemOverride) ?
pagination_item_active($data->all) :
$this->_item_active($data->all);
} else {
$list['all']['active'] = false;
$list['all']['data'] = ($itemOverride) ?
pagination_item_inactive($data->all) :
$this->_item_inactive($data->all);
}
$data->start->start = true;
if ($data->start->base !== null) {
$list['start']['active'] = true;
$list['start']['data'] = ($itemOverride) ?
pagination_item_active($data->start) :
$this->_item_active($data->start);
} else {
$list['start']['active'] = false;
$list['start']['data'] = ($itemOverride) ?
pagination_item_inactive($data->start) :
$this->_item_inactive($data->start);
}
$data->previous->previous = true;
if ($data->previous->base !== null) {
$list['previous']['active'] = true;
$list['previous']['data'] = ($itemOverride) ?
pagination_item_active($data->previous) :
$this->_item_active($data->previous);
} else {
$list['previous']['active'] = false;
$list['previous']['data'] = ($itemOverride) ?
pagination_item_inactive($data->previous) :
$this->_item_inactive($data->previous);
}
$list['pages'] = array(); //make sure it exists
foreach ($data->pages as $i => $page)
{
if ($page->base !== null) {
$list['pages'][$i]['active'] = true;
$list['pages'][$i]['data'] = ($itemOverride) ?
pagination_item_active($page) : $this->_item_active($page);
} else {
$list['pages'][$i]['active'] = false;
$list['pages'][$i]['data'] = ($itemOverride) ?
pagination_item_inactive($page) : $this->_item_inactive($page);
}
}
$data->next->next = true;
if ($data->next->base !== null) {
$list['next']['active'] = true;
$list['next']['data'] = ($itemOverride) ?
pagination_item_active($data->next) :
$this->_item_active($data->next);
} else {
$list['next']['active'] = false;
$list['next']['data'] = ($itemOverride) ?
pagination_item_inactive($data->next) :
$this->_item_inactive($data->next);
}
$data->end->end = true;
if ($data->end->base !== null) {
$list['end']['active'] = true;
$list['end']['data'] = ($itemOverride) ?
pagination_item_active($data->end) :
$this->_item_active($data->end);
} else {
$list['end']['active'] = false;
$list['end']['data'] = ($itemOverride) ?
pagination_item_inactive($data->end) :
$this->_item_inactive($data->end);
}
if($this->total > $this->limit){
return ($listOverride) ? pagination_list_render($list) :
$this->_list_render($list);
}
else{
return '';
}
}
function _list_render($list){
$html = null;
$html .= '<span
class="pagenav_start_chevron"><<
</span>';
$html .= $list['start']['data'];
$html .= '<span class="pagenav_previous_chevron">
< </span>';
$html .= $list['previous']['data'];
foreach( $list['pages'] as $page ) {
$html .= ' '.$page['data'];
}
$html .= ' '. $list['next']['data'];
$html .= '<span class="pagenav_next_chevron">
></span>';
$html .= ' '. $list['end']['data'];
$html .= '<span class="pagenav_end_chevron">
>></span>';
return $html;
}
function _list_footer($list){
$html = '<div
class="list-footer">'."\n";
if(version_compare(JVERSION,'1.6','>=')){
$display = JText::_('JGLOBAL_DISPLAY_NUM');
}else{
$display = JText::_('Display Num');
}
$html .= "\n<div
class=\"limit\">".$display.$list['limitfield']."</div>";
$html .= $list['pageslinks'];
$html .= "\n<div
class=\"counter\">".$list['pagescounter']."</div>";
$html .= "\n<input type=\"hidden\"
name=\"limitstart".$this->hikaSuffix."\"
value=\"".$list['limitstart']."\"
/>";
$html .= "\n</div>";
return $html;
}
function getListFooter($minimum=20){
$list = array();
$list['limit'] = $this->limit;
$list['limitstart'] = $this->limitstart;
$list['total'] = $this->total;
$list['limitfield'] = $this->getLimitBox($minimum);
$list['pagescounter'] = $this->getPagesCounter();
$list['pageslinks'] = $this->getPagesLinks();
if(HIKASHOP_J30) {
$app = JFactory::getApplication();
if(!$app->isAdmin())
return $this->_list_footer($list);
if(empty($this->prefix))
$this->prefix = '';
$list['prefix'] = $this->prefix;
if(function_exists('pagination_list_footer')) {
$ret = pagination_list_footer($list);
if(strpos($ret, $list['limitfield']) === false) {
$display = JText::_('JGLOBAL_DISPLAY_NUM');
$ret = "\n<div
class=\"limit\">".$display.$list['limitfield']
."</div>" . $ret;
}
if(strpos($ret,
'name="limitstart'.$this->hikaSuffix.'"')
=== false)
$ret .= "<input type=\"hidden\"
name=\"limitstart".$this->hikaSuffix."\"
value=\"".$list['limitstart']."\"
/>";
return $ret;
}
}
return $this->_list_footer($list);
}
function getLimitBox($minimum=20){
$limits = array ();
for ($i = $minimum; $i <= $minimum*5; $i += $minimum) {
$limits[] = JHTML::_('select.option', $i);
}
$limits[] = JHTML::_('select.option', '0',
JText::_('HIKA_ALL'));
if(version_compare(JVERSION,'3.0','<')){
$viewall = $this->_viewall;
} else {
$viewall = @$this->viewall;
}
return JHTML::_('select.genericlist', $limits,
'limit'.$this->hikaSuffix, 'class="chzn-done
inputbox" size="1" style="width:70px"
onchange="this.form.submit()"', 'value',
'text', $viewall ? 0 : $this->limit);
}
}
if(HIKASHOP_J30){
class hikashopPaginationHelper extends hikashopBridgePaginationHelper{
function _item_active(JPaginationObject $item){
$class = 'pagenav';
$specials =
array('start','end','previous','next');
foreach($specials as $special){
if(!empty($item->$special)){
$class.=' hikashop_'.$special.'_link';
}
}
if($item->base>0)
return "<a class=\"".$class."\"
title=\"".$item->text."\" onclick=\"javascript:
document.adminForm".$this->hikaSuffix.$this->form.".limitstart".$this->hikaSuffix.".value=".$item->base.";
document.adminForm".$this->hikaSuffix.$this->form.".submit();return
false;\">".$item->text."</a>";
else
return "<a class=\"".$class."\"
title=\"".$item->text."\" onclick=\"javascript:
document.adminForm".$this->hikaSuffix.$this->form.".limitstart".$this->hikaSuffix.".value=0;
document.adminForm".$this->hikaSuffix.$this->form.".submit();return
false;\">".$item->text."</a>";
}
function _item_inactive(JPaginationObject $item){
$mainframe = JFactory::getApplication();
if ($mainframe->isAdmin()) {
return
"<span>".$item->text."</span>";
} else {
$class = 'pagenav';
if(!is_numeric($item->text)){
$class .= ' pagenav_text';
}
return '<span
class="'.$class.'">'.$item->text."</span>";
}
}
}
}else{
class hikashopPaginationHelper extends hikashopBridgePaginationHelper{
function _item_active(&$item){
$class = 'pagenav';
$specials =
array('start','end','previous','next');
foreach($specials as $special){
if(!empty($item->$special)){
$class.=' hikashop_'.$special.'_link';
}
}
if($item->base>0)
return "<a class=\"".$class."\"
title=\"".$item->text."\" onclick=\"javascript:
document.adminForm".$this->hikaSuffix.$this->form.".limitstart".$this->hikaSuffix.".value=".$item->base.";
document.adminForm".$this->hikaSuffix.$this->form.".submit();return
false;\">".$item->text."</a>";
else
return "<a class=\"".$class."\"
title=\"".$item->text."\" onclick=\"javascript:
document.adminForm".$this->hikaSuffix.$this->form.".limitstart".$this->hikaSuffix.".value=0;
document.adminForm".$this->hikaSuffix.$this->form.".submit();return
false;\">".$item->text."</a>";
}
function _item_inactive(&$item){
$mainframe = JFactory::getApplication();
if ($mainframe->isAdmin()) {
return
"<span>".$item->text."</span>";
} else {
$class = 'pagenav';
if(!is_numeric($item->text)){
$class .= ' pagenav_text';
}
return '<span
class="'.$class.'">'.$item->text."</span>";
}
}
}
}
paymentplugin.php000064400000054261151162557560010176 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopPaymentPlugin extends hikashopPlugin {
var $type = 'payment';
var $accepted_currencies = array();
var $doc_form = 'generic';
var $features = array(
'authorize_capture' => false,
'recurring' => false,
'refund' => false
);
function onPaymentDisplay(&$order, &$methods,
&$usable_methods) {
if(empty($methods) || empty($this->name))
return true;
$currencyClass = hikashop_get('class.currency');
if(!empty($order->total)) {
$null = null;
$currency_id =
intval(@$order->total->prices[0]->price_currency_id);
$currency = $currencyClass->getCurrencies($currency_id, $null);
if(!empty($currency) && !empty($this->accepted_currencies)
&& !in_array(@$currency[$currency_id]->currency_code,
$this->accepted_currencies))
return true;
$this->currency = $currency;
$this->currency_id = $currency_id;
}
$this->currencyClass = $currencyClass;
$shippingClass = hikashop_get('class.shipping');
$volumeHelper = hikashop_get('helper.volume');
$weightHelper = hikashop_get('helper.weight');
foreach($methods as $method) {
if($method->payment_type != $this->name || !$method->enabled ||
!$method->payment_published)
continue;
if(method_exists($this, 'needCC')) {
$this->needCC($method);
} else if(!empty($this->ask_cc)) {
$method->ask_cc = true;
if(!empty($this->ask_owner))
$method->ask_owner = true;
if(!empty($method->payment_params->ask_ccv))
$method->ask_ccv = true;
}
$price = null;
if(@$method->payment_params->payment_price_use_tax) {
if(isset($order->order_full_price))
$price = $order->order_full_price;
if(isset($order->total->prices[0]->price_value_with_tax))
$price = $order->total->prices[0]->price_value_with_tax;
if(isset($order->full_total->prices[0]->price_value_with_tax))
$price =
$order->full_total->prices[0]->price_value_with_tax;
if(isset($order->full_total->prices[0]->price_value_without_payment_with_tax))
$price =
$order->full_total->prices[0]->price_value_without_payment_with_tax;
} else {
if(isset($order->order_full_price))
$price = $order->order_full_price;
if(isset($order->total->prices[0]->price_value))
$price = $order->total->prices[0]->price_value;
if(isset($order->full_total->prices[0]->price_value))
$price = $order->full_total->prices[0]->price_value;
if(isset($order->full_total->prices[0]->price_value_without_payment))
$price =
$order->full_total->prices[0]->price_value_without_payment;
}
if(!empty($method->payment_params->payment_min_price) &&
bccomp((float)hikashop_toFloat($method->payment_params->payment_min_price),
(float)$price, 5) == 1) {
$method->errors['min_price'] =
(hikashop_toFloat($method->payment_params->payment_min_price) -
$price);
continue;
}
if(!empty($method->payment_params->payment_max_price) &&
bccomp((float)hikashop_toFloat($method->payment_params->payment_max_price),
(float)$price, 5) == -1){
$method->errors['max_price'] = ($price -
hikashop_toFloat($method->payment_params->payment_max_price));
continue;
}
if(!empty($method->payment_params->payment_max_volume) &&
bccomp((float)@$method->payment_params->payment_max_volume, 0, 3)) {
$method->payment_params->payment_max_volume_orig =
$method->payment_params->payment_max_volume;
$method->payment_params->payment_max_volume =
$volumeHelper->convert($method->payment_params->payment_max_volume,
@$method->payment_params->payment_size_unit);
if(bccomp(sprintf('%.10F',$method->payment_params->payment_max_volume),
sprintf('%.10F',$order->volume), 10) == -1){
$method->errors['max_volume'] =
($method->payment_params->payment_max_volume - $order->volume);
continue;
}
}
if(!empty($method->payment_params->payment_min_volume) &&
bccomp((float)@$method->payment_params->payment_min_volume, 0, 3)) {
$method->payment_params->payment_min_volume_orig =
$method->payment_params->payment_min_volume;
$method->payment_params->payment_min_volume =
$volumeHelper->convert($method->payment_params->payment_min_volume,
@$method->payment_params->payment_size_unit);
if(bccomp(sprintf('%.10F',$method->payment_params->payment_min_volume),
sprintf('%.10F',$order->volume), 10) == 1){
$method->errors['min_volume'] = ($order->volume -
$method->payment_params->payment_min_volume);
continue;
}
}
if(!empty($method->payment_params->payment_max_weight) &&
bccomp((float)@$method->payment_params->payment_max_weight, 0, 3)) {
$method->payment_params->payment_max_weight_orig =
$method->payment_params->payment_max_weight;
$method->payment_params->payment_max_weight =
$weightHelper->convert($method->payment_params->payment_max_weight,
@$method->payment_params->payment_weight_unit);
if(bccomp(sprintf('%.5F',$method->payment_params->payment_max_weight),
sprintf('%.5F',$order->weight), 5) == -1){
$method->errors['max_weight'] =
($method->payment_params->payment_max_weight - $order->weight);
continue;
}
}
if(!empty($method->payment_params->payment_min_weight) &&
bccomp((float)@$method->payment_params->payment_min_weight,0,3)){
$method->payment_params->payment_min_weight_orig =
$method->payment_params->payment_min_weight;
$method->payment_params->payment_min_weight =
$weightHelper->convert($method->payment_params->payment_min_weight,
@$method->payment_params->payment_weight_unit);
if(bccomp(sprintf('%.5F',$method->payment_params->payment_min_weight),
sprintf('%.5F',$order->weight), 5) == 1){
$method->errors['min_weight'] = ($order->weight -
$method->payment_params->payment_min_weight);
continue;
}
}
if(!empty($method->payment_params->payment_max_quantity)
&& (int)$method->payment_params->payment_max_quantity) {
if((int)$method->payment_params->payment_max_quantity <
(int)$order->total_quantity){
$method->errors['max_quantity'] =
($method->payment_params->payment_max_quantity -
$order->total_quantity);
continue;
}
}
if(!empty($method->payment_params->payment_min_quantity)
&& (int)$method->payment_params->payment_min_quantity){
if((int)$method->payment_params->payment_min_quantity >
(int)$order->total_quantity){
$method->errors['min_quantity'] =
($order->total_quantity -
$method->payment_params->payment_min_quantity);
continue;
}
}
$method->features = $this->features;
if(!$this->checkPaymentDisplay($method, $order))
continue;
if(!empty($order->paymentOptions) &&
!empty($order->paymentOptions['recurring']) &&
empty($order->paymentOptions['recurring']['optional'])
&& empty($method->features['recurring']))
continue;
if(!empty($order->paymentOptions) &&
!empty($order->paymentOptions['term']) &&
empty($method->features['authorize_capture']))
continue;
if(!empty($order->paymentOptions) &&
!empty($order->paymentOptions['refund']) &&
empty($method->features['refund']))
continue;
if((int)$method->payment_ordering > 0 &&
!isset($usable_methods[(int)$method->payment_ordering]))
$usable_methods[(int)$method->payment_ordering] = $method;
else
$usable_methods[] = $method;
}
return true;
}
function onPaymentSave(&$cart, &$rates, &$payment_id) {
$usable = array();
$this->onPaymentDisplay($cart, $rates, $usable);
$payment_id = (int)$payment_id;
foreach($usable as $usable_method) {
if($usable_method->payment_id == $payment_id)
return $usable_method;
}
return false;
}
function onPaymentCustomSave(&$cart, &$method, $formData) {
return $formData;
}
function onPaymentConfiguration(&$element) {
$this->pluginConfiguration($element);
if(empty($element) || empty($element->payment_type)) {
$element = new stdClass();
$element->payment_type = $this->pluginName;
$element->payment_params= new stdClass();
$this->getPaymentDefaultValues($element);
}
$this->order_statuses = hikashop_get('type.categorysub');
$this->order_statuses->type = 'status';
$this->currency = hikashop_get('type.currency');
$this->weight = hikashop_get('type.weight');
$this->volume = hikashop_get('type.volume');
}
function onPaymentConfigurationSave(&$element) {
if(empty($this->pluginConfig))
return true;
$formData = hikaInput::get()->get('data', array(),
'array');
if(!isset($formData['payment']['payment_params']))
return true;
foreach($this->pluginConfig as $key => $config) {
if($config[1] == 'textarea' || $config[1] ==
'big-textarea') {
$element->payment_params->$key =
@$formData['payment']['payment_params'][$key];
}
}
return true;
}
function onBeforeOrderCreate(&$order, &$do) {
$app = JFactory::getApplication();
if(hikashop_isClient('administrator'))
return true;
if(empty($order->order_payment_method) ||
$order->order_payment_method != $this->name)
return true;
if(!empty($order->order_type) && $order->order_type !=
'sale')
return true;
$this->loadOrderData($order);
$this->loadPaymentParams($order);
if(empty($this->payment_params)) {
$do = false;
return true;
}
}
function onAfterOrderConfirm(&$order, &$methods, $method_id) {
$this->payment = $methods[$method_id];
$this->payment_params =& $this->payment->payment_params;
$this->payment_name = $this->payment->payment_name;
$this->loadOrderData($order);
$this->order = $order;
}
function onPaymentNotification(&$statuses) {
}
function onOrderPaymentCapture(&$order, $total) { return false; }
function onOrderAuthorizationCancel(&$order) { return false; }
function onOrderAuthorizationRenew(&$order) { return false; }
function onOrderPaymentRefund(&$order, $total) { return false; }
function getOrder($order_id) {
$ret = null;
if(empty($order_id))
return $ret;
$orderClass = hikashop_get('class.order');
$ret = $orderClass->get($order_id);
return $ret;
}
function modifyOrder(&$order_id, $order_status, $history = null,
$email = null, $payment_params = null) {
if(is_object($order_id)) {
$order =& $order_id;
} else {
$order = new stdClass();
$order->order_id = $order_id;
}
if($order_status !== null)
$order->order_status = $order_status;
$history_notified = 0;
$history_amount = '';
$history_data = '';
$history_type = '';
if(!empty($history)) {
if($history === true) {
$history_notified = 1;
} else if(is_array($history)) {
$history_notified = (int)@$history['notified'];
$history_amount = @$history['amount'];
$history_data = @$history['data'];
$history_type = @$history['type'];
} else {
$history_notified = (int)@$history->notified;
$history_amount = @$history->amount;
$history_data = @$history->data;
$history_type = @$history->type;
}
}
$order->history = new stdClass();
$order->history->history_reason =
JText::sprintf('AUTOMATIC_PAYMENT_NOTIFICATION');
$order->history->history_notified = $history_notified;
$order->history->history_payment_method = $this->name;
$order->history->history_type = 'payment';
if(!empty($history_amount))
$order->history->history_amount = $history_amount;
if(!empty($history_data))
$order->history->history_data = $history_data;
if(!empty($history_type))
$order->history->history_type = $history_type;
if($payment_params !== null) {
if(isset($order->order_payment_params)) {
foreach($payment_params as $k => $v) {
$order->order_payment_params->$k = $v;
}
} else {
$order->order_payment_params = $payment_params;
}
}
JPluginHelper::importPlugin('hikashop');
$app = JFactory::getApplication();
$app->triggerEvent('onBeforeModifyOrder', array(&$order,
&$order_status, &$history, &$email));
$orderClass = hikashop_get('class.order');
if(!is_object($order_id) && $order_id !== false) {
$orderClass->save($order);
}
$config =& hikashop_config();
$recipients =
trim($config->get('payment_notification_email',
''));
if(empty($email) || empty($recipients))
return;
$payment_status = $order_status;
$mail_status = hikashop_orderStatus($order_status);
if(is_object($order_id))
$id = @$order->order_id;
else
$id = $order_id;
if(!empty($id)) {
$dbOrder = $orderClass->get($id);
$message = str_replace('<br/>', "\r\n",
JText::sprintf('PAYMENT_NOTIFICATION_STATUS', $this->name,
$payment_status)) . ' ' .
JText::sprintf('ORDER_STATUS_CHANGED', $mail_status) .
"\r\n".JText::sprintf('NOTIFICATION_OF_ORDER_ON_WEBSITE',
$dbOrder->order_number, HIKASHOP_LIVE);
$orderMail = $orderClass->loadNotification((int)$id,
'payment_notification', $message);
if(empty($orderMail->mail->subject))
$orderMail->mail->subject =
JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER', $this->name,
$payment_status, $dbOrder->order_number);
$orderMail->mail->dst_email = $recipients;
$mailClass = hikashop_get('class.mail');
$mailClass->sendMail($orderMail->mail);
return;
}
$mailer = JFactory::getMailer();
$order_number = '';
global $Itemid;
$this->url_itemid = empty($Itemid) ? '' :
'&Itemid=' . $Itemid;
if(is_object($order_id)) {
$subject = JText::sprintf('PAYMENT_NOTIFICATION',
$this->name, $payment_status);
$url =
HIKASHOP_LIVE.'administrator/index.php?option=com_hikashop&ctrl=order&task=listing'.
$this->url_itemid;
if(isset($order->order_id))
$url =
HIKASHOP_LIVE.'administrator/index.php?option=com_hikashop&ctrl=order&task=edit&order_id='
. $order->order_id . $this->url_itemid;
if(isset($order->order_number))
$order_number = $order->order_number;
} elseif($order_id !== false) {
$dbOrder = $orderClass->get($order_id);
$order_number = $dbOrder->order_number;
$subject = JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER',
$this->name, $payment_status, $order_number);
$url =
HIKASHOP_LIVE.'administrator/index.php?option=com_hikashop&ctrl=order&task=edit&order_id='
. $order_id . $this->url_itemid;
}
$order_text = '';
if(is_string($email))
$order_text = "\r\n\r\n" . $email;
$body = str_replace('<br/>', "\r\n",
JText::sprintf('PAYMENT_NOTIFICATION_STATUS', $this->name,
$payment_status)) . ' ' .
JText::sprintf('ORDER_STATUS_CHANGED', $mail_status) .
"\r\n".JText::sprintf('NOTIFICATION_OF_ORDER_ON_WEBSITE',
$order_number, HIKASHOP_LIVE);
if(!empty($url))
$body .= "\r\n".str_replace('<br/>',
"\r\n", JText::sprintf('ACCESS_ORDER_WITH_LINK',
$url));
$body .= $order_text;
if(is_object($email)) {
if(!empty($email->subject))
$subject = $email->subject;
if(!empty($email->body))
$body = $email->body;
}
$sender = array(
$config->get('from_email'),
$config->get('from_name')
);
$mailer->setSender($sender);
$mailer->addRecipient(explode(',', $recipients));
$mailer->setSubject($subject);
$mailer->setBody($body);
$mailer->Send();
}
function loadOrderData(&$order) {
$this->app = JFactory::getApplication();
$lang = JFactory::getLanguage();
$currencyClass = hikashop_get('class.currency');
$cartClass = hikashop_get('class.cart');
$this->currency = 0;
if(!empty($order->order_currency_id)) {
$currencies = null;
$currencies =
$currencyClass->getCurrencies($order->order_currency_id,
$currencies);
$this->currency = $currencies[$order->order_currency_id];
}
hikashop_loadUser(true, true);
$this->user = hikashop_loadUser(true);
$this->locale = strtolower(substr($lang->get('tag'), 0,
2));
$this->url_itemid = '';
if(empty($order->customer->user_cms_id))
$this->url_itemid =
'&order_token='.$order->order_token;
global $Itemid;
$this->url_itemid .= empty($Itemid) ? '' :
'&Itemid=' . $Itemid;
$billing_address =
$this->app->getUserState(HIKASHOP_COMPONENT.'.billing_address');
if(isset($order->cart_billing_address_id))
$billing_address = (int)$order->cart_billing_address_id;
if(isset($order->cart->cart_billing_address_id))
$billing_address = (int)$order->cart->cart_billing_address_id;
if(isset($order->order_billing_address_id))
$billing_address = (int)$order->order_billing_address_id;
if(!empty($billing_address))
$cartClass->loadAddress($order->cart, $billing_address,
'object', 'billing');
$shipping_address =
$this->app->getUserState(HIKASHOP_COMPONENT.'.shipping_address');
if(isset($order->cart_shipping_address_ids))
$shipping_address = (int)$order->cart_shipping_address_ids;
if(isset($order->cart->cart_shipping_address_ids))
$shipping_address = (int)$order->cart->cart_shipping_address_ids;
if(isset($order->order_shipping_address_id))
$shipping_address = (int)$order->order_shipping_address_id;
if(!empty($shipping_address))
$cartClass->loadAddress($order->cart, $shipping_address,
'object', 'shipping');
}
function loadPaymentParams(&$order) {
$payment_id = @$order->order_payment_id;
$this->payment_params = null;
if(!empty($order->order_payment_method) &&
$order->order_payment_method == $this->name &&
!empty($payment_id) && $this->pluginParams($payment_id))
$this->payment_params =& $this->plugin_params;
return ($this->payment_params !== null);
}
function ccLoad($ccv = true) {
$cart_id = hikaInput::get()->getInt('cart_id', 0);
hikashop_get('helper.checkout');
$checkoutHelper = hikashopCheckoutHelper::get($cart_id);
$cc = $checkoutHelper->getCreditCard($this->plugin_data, false);
if(!empty($cc)) {
$fields = array('cc_number' => 'num',
'cc_month' => 'mm', 'cc_year' =>
'yy', 'cc_CCV' => 'ccv',
'cc_type' => 'type', 'cc_owner' =>
'owner');
foreach($fields as $key => $field) {
$this->$key = '';
if(!empty($cc->$field))
$this->$key = $cc->$field;
}
return true;
}
if(!isset($this->app))
$this->app = JFactory::getApplication();
$this->cc_number =
$this->app->getUserState(HIKASHOP_COMPONENT.'.cc_number');
if(!empty($this->cc_number)) $this->cc_number =
base64_decode($this->cc_number);
$this->cc_month =
$this->app->getUserState(HIKASHOP_COMPONENT.'.cc_month');
if(!empty($this->cc_month)) $this->cc_month =
base64_decode($this->cc_month);
$this->cc_year =
$this->app->getUserState(HIKASHOP_COMPONENT.'.cc_year');
if(!empty($this->cc_year)) $this->cc_year =
base64_decode($this->cc_year);
$this->cc_type = $this->app->getUserState(
HIKASHOP_COMPONENT.'.cc_type');
if(!empty($this->cc_type)){
$this->cc_type = base64_decode($this->cc_type);
}
$this->cc_owner = $this->app->getUserState(
HIKASHOP_COMPONENT.'.cc_owner');
if(!empty($this->cc_owner)){
$this->cc_owner = base64_decode($this->cc_owner);
}
$this->cc_CCV = '';
if($ccv) {
$this->cc_CCV =
$this->app->getUserState(HIKASHOP_COMPONENT.'.cc_CCV');
if(!empty($this->cc_CCV)) $this->cc_CCV =
base64_decode($this->cc_CCV);
}
return !empty($this->cc_number);
}
function ccClear() {
if(!isset($this->app))
$this->app = JFactory::getApplication();
$this->app->setUserState(HIKASHOP_COMPONENT.'.cc_number',
'');
$this->app->setUserState(HIKASHOP_COMPONENT.'.cc_month',
'');
$this->app->setUserState(HIKASHOP_COMPONENT.'.cc_year',
'');
$this->app->setUserState(HIKASHOP_COMPONENT.'.cc_type',
'');
$this->app->setUserState(HIKASHOP_COMPONENT.'.cc_owner',
'');
$this->app->setUserState(HIKASHOP_COMPONENT.'.cc_CCV',
'');
$this->app->setUserState(HIKASHOP_COMPONENT.'.cc_valid',
0);
$this->app->setUserState(HIKASHOP_COMPONENT.'.checkout_cc',
null);
}
function cronCheck() {
if(empty($this->name))
return false;
$pluginsClass = hikashop_get('class.plugins');
$type = 'hikashop';
if($this->type == 'payment')
$type = 'hikashoppayment';
if($this->type == 'shipping')
$type = 'hikashopshipping';
$plugin = $pluginsClass->getByName($type, $this->name);
if(empty($plugin))
return false;
if(empty($plugin->params['period']))
$plugin->params['period'] = 7200; // 2 hours
if(!empty($plugin->params['last_cron_update']) &&
((int)$plugin->params['last_cron_update'] +
(int)$plugin->params['period']) > time())
return false;
$plugin->params['last_cron_update'] = time();
$pluginsClass->save($plugin);
return true;
}
function renewalOrdersAuthorizations(&$messages) {
$db = JFactory::getDBO();
$date = hikashop_getDate(time(), '%Y/%m/%d');
$search =
hikashop_getEscaped('s:18:"payment_auth_renew";s:10:"'.$date.'";');
$query = 'SELECT * FROM '.hikashop_table('order').
' WHERE order_type = \'sale\' AND order_payment_method =
'.$db->Quote($this->name).' AND order_payment_params LIKE
\'%'.$search.'%\''.
' ORDER BY order_payment_id';
$db->setQuery($query);
$orders = $db->loadObjectList();
if(!empty($orders)) {
$cpt = 0;
foreach($orders as $order) {
$order->order_payment_params =
hikashop_unserialize($order->order_payment_params);
$ret = $this->onOrderAuthorizationRenew($order);
if($ret) {
$order_payment_params = serialize($order->order_payment_params);
$query = 'UPDATE '.hikashop_table('order').'
SET order_payment_params =
'.$db->quote($order_payment_params).' WHERE order_id =
'.(int)$order->order_id;
$db->setQuery($query);
$db->execute();
$cpt++;
}
unset($order_payment_params);
unset($order->order_payment_params);
unset($order);
}
if($cpt > 0)
$messages[] = '['.ucfirst($this->name).']
'.JText::_sprintf('X_ORDERS_AUTHORIZATION_RENEW', $cpt);
}
}
function getOrderUrl(&$order) {
$url = '#';
$user = JFactory::getUser();
global $Itemid;
$url_itemid = (!empty($Itemid)) ? '&Itemid='.$Itemid :
'';
if(!$user->guest){
$url =
hikashop_completeLink('order&task=show&cid='.@$order->order_id.$url_itemid);
}else{
$url =
hikashop_completeLink('order&task=show&cid='.@$order->order_id.'&order_token='.@$order->order_token.$url_itemid);
}
return $url;
}
function writeToLog($data = null) {
hikashop_writeToLog($data, $this->name);
}
function getPaymentDefaultValues(&$element){}
function checkPaymentDisplay(&$method, &$order) { return true; }
}
popup.php000064400000024072151162557560006442 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopPopupHelper {
function __construct() {
}
function display($text, $title, $url, $id, $params_width, $height = null,
$attr = '', $icon = '', $type = 'button',
$dynamicUrl = false) {
$html = '';
$popupMode = 'mootools';
if(HIKASHOP_J30) {
$config = hikashop_config();
$popupMode = $config->get('popup_mode',
'bootstrap');
if(empty($popupMode) || $popupMode == 'inherit')
$popupMode = 'bootstrap';
}
if(!empty($params_width) && is_array($params_width)) {
$params = $params_width;
} else {
$params = array(
'width' => $params_width,
'height' => $height,
'attr' => $attr,
'icon' => $icon,
'type' => $type,
'dynamicUrl' => $dynamicUrl
);
}
switch($popupMode) {
case 'bootstrap':
return $this->displayBootstrap($text, $title, $url, $id, $params);
case 'mootools':
default:
return $this->displayMootools($text, $title, $url, $id, $params);
}
return $html;
}
// function displayBootstrap($text, $title, $url, $id, $width, $height,
$attr = '', $icon = '', $type = 'button',
$dynamicUrl = false) {
function displayBootstrap($text, $title, $url, $id, $params = array()) {
if(!isset($params['attr'])) $params['attr'] =
'';
if(!isset($params['icon'])) $params['icon'] =
'';
if(!isset($params['type'])) $params['type'] =
'button';
if(!isset($params['dynamicUrl']))
$params['dynamicUrl'] = false;
$isOnclick = (strpos($params['attr'],
'onclick="') !== false);
if($text !== null) {
$attr = $params['attr'];
if($params['type'] == 'button')
$attr = $this->getAttr($params['attr'],'btn
btn-small');
$onclick = '';
if(!$isOnclick) {
$fct_url = '\''.$url.'\'';
if(!empty($id) && $params['type'] ==
'button' && $params['dynamicUrl'])
$fct_url = $url;
if(empty($id) && $params['type'] !=
'button')
$fct_url = 'this.href';
if((!empty($id) && $params['type'] !=
'button') || (empty($id) && $params['type'] ==
'button'))
$fct_url = 'null';
$onclick = '
onclick="window.hikashop.openBox(this,'.$fct_url.',true);
return false;"';
}
$href = '';
if($params['type'] != 'button')
$href = ' href="'. (empty($id) ? $url : '#') .
'"';
$el_id = '';
if(!empty($id))
$el_id = ' id="'.$id.'"';
$html = (($params['type'] ==
'button')?'<button ':'<a ') . $href .
$attr . $el_id . $onclick . '>';
if(!empty($params['icon']))
$html .= '<i
class="icon-16-'.$params['icon'].'"></i>
';
$html .= $text . (($params['type'] ==
'button')?'</button>':'</a>');
} else {
$html = '<a style="display:none;" href="#"
id="'.$id.'"
onclick="window.hikashop.openBox(this,null,true); return
false;"></a>';
}
$additionalClasses = '';
if(!empty($params['modalClass']))
$additionalClasses = ' ' . $params['modalClass'];
$bootstrapParams = array(
'title' => JText::_($title),
'url' => $url,
'height' => $params['height'],
'width' => $params['width']
);
if($params['dynamicUrl']) {
$bootstrapParams['url'] =
'\'+'.$url.'+\'';
}
$domain = 'hikashop';
if(!empty($params['domain']))
$domain = $params['domain'];
if(!empty($id)) {
$footer = '';
if(!empty($params['footer']) &&
$params['footer'] === true) {
$footer = '<div class="modal-footer">'.
'<button class="btn" type="button"
data-dismiss="modal">'.JText::_('HIKA_CANCEL').'</button>'.
'<button class="btn btn-primary"
type="submit"
onclick="window.hikashop.submitPopup(\''.$id.'\');">'.JText::_('HIKA_VALIDATE').'</button>'.
'</div>';
$footer =
str_replace(array("'","\r","\n"),
array("\\'",'',''), $footer);
}
$renderModal = JHtml::_('bootstrap.renderModal',
'modal-'.$id, $bootstrapParams, $footer);
$html .= str_replace(
array(
'id="modal-'.$id.'"',
'<div class="modal hide'
),
array(
'id="modal-'.$id.'"
style="width:'.($params['width']+20).'px;height:'.($params['height']+90).'px;margin-left:-'.(($params['width']+20)/2).'px"',
'<div class="modal hide'.$additionalClasses
),
$renderModal
);
$html .=
'<script>'."\n".'jQuery(document).ready(function(){jQuery("#modal-'.$id.'").appendTo(jQuery(document.getElementById("'.$domain.'_main_content")
||
document.body));});'."\n".'</script>'."\n";
}
return $html;
}
//function displayMootools($text, $title, $url, $id, $width, $height,
$attr = '', $icon = '', $type = 'button',
$dynamicUrl = false) {
function displayMootools($text, $title, $url, $id, $params) {
if(!isset($params['attr'])) $params['attr'] =
'';
if(!isset($params['icon'])) $params['icon'] =
'';
if(!isset($params['type'])) $params['type'] =
'button';
if(!isset($params['dynamicUrl']))
$params['dynamicUrl'] = false;
$isOnclick = (strpos($params['attr'],
'onclick="') !== false);
$html = '';
JHtml::_('behavior.modal');
if($text === null)
return $html;
$onClick = '';
if($params['dynamicUrl']) {
if(!$isOnclick)
$onClick = ' onclick="this.href=' .
str_replace('"', '\"', $url) . '; return
window.hikashop.openBox(this,this.href,false);"';
$isOnclick = true;
$url = '#';
}
$a = $params['attr'];
if(!empty($id) && !$isOnclick &&
empty($params['footer']))
$onClick = ' onclick="return
window.hikashop.openBox(this,null,false);"';
if(!empty($params['footer']) &&
$params['footer'] === true) {
static $createBoxInit = false;
if(!$createBoxInit) {
$doc = JFactory::getDocument();
$js = '
if(!window.localPage) window.localPage = {};
window.localPage.createBox = function(el,href,options) {
if(typeof options == "string")
options = JSON.decode(options, false);
var content = \'<div><div
class="sbox-header">\'+options.title+\'</div>'.
'<iframe id="modal-squeezebox-iframe"
width="\'+options.size.x+\'"
height="\'+options.size.y+\'" frameborder="0"
src="\'+href+\'"></iframe>'.
'<div class="sbox-footer">'.
'<button onclick="window.hikashop.closeBox();"
class="btn"
type="button">'.JText::_('HIKA_CANCEL').'</button>'.
'<button class="btn btn-primary" type="submit"
onclick="window.hikashop.submitPopup(\\\'squeezebox\\\');">'.JText::_('HIKA_VALIDATE').'</button>'.
'</div></div>\';
options.size.x += 10;
options.size.y += 65;
var size = {x: options.size.x, y: options.size.y};
options.handler = "string";
options.content = content;
SqueezeBox.initialize(options);
SqueezeBox.setContent("string",content);
SqueezeBox.resize(size, true);
return false;
}
';
$doc->addScriptDeclaration($js);
$createBoxInit = true;
}
if($params['dynamicUrl']) {
$onClick=' onclick="this.href=' .
str_replace('"', '\"', $url) . '; return
window.localPage.createBox(this,this.href,this.rel);"';
} else {
$onClick=' onclick="return
window.localPage.createBox(this,this.href,this.rel);"';
}
$title = str_replace("'", "\\'",
JText::_($title));
$html = '<a '.$a.$onClick.'
id="'.$id.'" href="'.$url.'"
rel="{title:\''.$title.'\',size:{x:'.$params['width'].',y:'.$params['height'].'}}">';
} else {
$html = '<a '.$a.$onClick.'
id="'.$id.'" href="'.$url.'"
rel="{handler: \'iframe\', size: {x:
'.$params['width'].', y:
'.$params['height'].'}}">';
}
if($params['type'] == 'button')
$html .= '<button class="btn" onclick="return
false">';
$html .= $text;
if($params['type'] == 'button')
$html .= '</button>';
$html .= '</a>';
return $html;
}
function image($content, $url, $id = null, $attr = '', $params =
array()) {
$html = '';
$config = hikashop_config();
$popupMode = $config->get('image_popup_mode',
'mootools');
switch($popupMode) {
case 'shadowbox':
case 'shadowbox-embbeded':
return $this->imageShadowbox($content, $url, $id, $attr, $params);
case 'mootools':
default:
return $this->imageMootools($content, $url, $id, $attr, $params);
}
return $html;
}
function imageMootools($content, $url, $id = null, $attr = '',
$params = array()) {
JHtml::_('behavior.modal');
$html = '';
if($content === null)
return $html;
$isOnclick = (strpos($attr, 'onclick="') !== false);
$onClick = '';
if(!$isOnclick)
$onClick = '
onclick="SqueezeBox.fromElement(this,{parse:\'rel\'});return
false;"';
if(!empty($id))
$id = ' id="'.$id.'"';
else
$id = '';
$html = '<a '.$attr.$onClick.$id.'
href="'.$url.'"
rel="{handler:\'image\'}"
target="_blank">'.$content.'</a>';
return $html;
}
function imageShadowbox($content, $url, $id = null, $attr = '',
$params = array()) {
$html = '';
if($content === null)
return $html;
static $init = false;
if($init === false) {
$config = hikashop_config();
$shadowboxMode = $config->get('image_popup_mode',
'mootools');
if($shadowboxMode != 'shadowbox-embbeded') {
$doc = JFactory::getDocument();
$doc->addStyleSheet('//www.hikashop.com/cdn/shadowbox/shadowbox.css');
$doc->addScript('//www.hikashop.com/cdn/shadowbox/shadowbox.js');
$doc->addScriptDeclaration("\r\n".'Shadowbox.init();'."\r\n");
}
$init = true;
}
$isRel = (strpos($attr, 'rel="') !== false);
$rel = '';
if(!$isRel) {
$rel = ' rel="shadowbox"';
if(!empty($params['gallery'])) {
$rel = '
rel="shadowbox['.str_replace('"','',
$params['gallery']).']"';
}
}
if(!empty($id))
$id = ' id="'.$id.'"';
else
$id = '';
$html = '<a '.$attr.$rel.$id.'
href="'.$url.'">'.$content.'</a>';
return $html;
}
function getAttr($attr, $class) {
if(empty($attr)) {
return 'class="'.$class.'"';
}
$attr = ' '.$attr;
if(strpos($attr, ' class="') !== false) {
$attr = str_replace(' class="', '
class="'.$class.' ', $attr);
} elseif(strpos($attr, ' class=\'') !== false) {
$attr = str_replace(' class=\'', '
class=\''.$class.' ', $attr);
} else {
$attr .= ' class="'.$class.'"';
}
return trim($attr);
}
}
seo.php000064400000006067151162557560006071 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopSeoHelper {
public function getAlias($name) {
$alias = strip_tags($name);
$jConfig = JFactory::getConfig();
if (!$jConfig->get('unicodeslugs')) {
$lang = JFactory::getLanguage();
$alias = str_replace(',', '-',
$lang->transliterate($alias));
}
$app = JFactory::getApplication();
if (method_exists($app, 'stringURLSafe')) {
$alias = $app->stringURLSafe($alias);
} elseif (method_exists('JFilterOutput',
'stringURLUnicodeSlug')) {
$alias = JFilterOutput::stringURLUnicodeSlug($alias);
} else {
$alias = JFilterOutput::stringURLSafe($alias);
}
return $alias;
}
public function autoFillKeywordMeta(&$element, $object) {
$config =& hikashop_config();
$max = (int)$config->get('max_size_of_metadescription', 0);
$description = $object . '_description';
$meta_description = $object . '_meta_description';
$keyword = $object . '_keywords';
if (empty($element->$description))
return;
if (empty($element->$meta_description)) {
if(empty($max) || $max < 1)
$max = 300;
$substr = (function_exists('mb_substr')) ?
'mb_substr' : 'substr';
$element->$meta_description =
$substr($this->clean($element->$description), 0, $max);
}
if (empty($element->$keyword)) {
$txt = $this->clean($element->$description);
$words = array();
if (preg_match_all('~\p{L}+~u', $txt, $matches) > 0) {
foreach ($matches[0] as $w) {
$words[$w] = isset($words[$w]) === false ? 1 : $words[$w] + 1;
}
}
arsort($words);
$i = 0;
$max_keywords = (int)$config->get('keywords_number', 0);
$excluded_words = explode(',',
$config->get('keywords_exclusion_list', ''));
$keywords = array();
$strlen = (function_exists('mb_strlen')) ?
'mb_strlen' : 'strlen';
foreach ($words as $word => $nb) {
if ($strlen($word) < 3)
continue;
$skip = false;
foreach ($excluded_words as $excluded_word) {
if ($word == trim($excluded_word)) {
$skip = true;
break;
}
}
if($skip == true)
continue;
$i++;
if ($i > $max_keywords)
break;
$keywords[$i] = $word;
}
$element->$keyword = implode(',', $keywords);
}
}
public function clean($str) {
$str = strip_tags($str);
if(function_exists('mb_strtolower'))
$str = mb_strtolower($str, 'utf-8');
else
$str = strtolower($str);
return $str;
}
public function substr($str, $start, $length = null) {
if ($length !== null) {
if(function_exists('mb_substr'))
$str = mb_substr($str, $start, $length);
else
$str = substr($str, $start, $length);
} else {
if(function_exists('mb_substr'))
$str = mb_substr($str, $start);
else
$str = substr($str, $start);
}
return $str;
}
}
shippingplugin.php000064400000071354151162557560010344 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 4.4.1
* @author hikashop.com
* @copyright (C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopShippingPlugin extends hikashopPlugin {
var $type = 'shipping';
var $use_cache = true;
public function onShippingDisplay(&$order, &$dbrates,
&$usable_rates, &$messages) {
$config =& hikashop_config();
if(!$config->get('force_shipping') &&
((isset($order->package['weight']) &&
$order->package['weight']['value'] <= 0.0) ||
(isset($order->weight) && bccomp($order->weight, 0, 5) <=
0)))
return false;
if(empty($dbrates) || empty($this->name))
return false;
$rates = array();
foreach($dbrates as $k => $rate) {
if($rate->shipping_type == $this->name &&
!empty($rate->shipping_published)) {
$rates[] = $rate;
}
}
if(empty($rates))
return false;
if($this->use_cache) {
if($this->loadShippingCache($order, $usable_rates, $messages))
return true;
$local_cache_shipping = array();
$local_cache_errors = array();
}
$currencyClass = hikashop_get('class.currency');
$shippingClass = hikashop_get('class.shipping');
$this->volumeHelper = hikashop_get('helper.volume');
$this->weightHelper = hikashop_get('helper.weight');
if(!empty($order->cart_currency_id))
$currentCurrency = $order->cart_currency_id;
else
$currentCurrency = hikashop_getCurrency();
foreach($rates as &$rate) {
$rate->shippingkey =
$shippingClass->getShippingProductsData($order, $order->products);
$shipping_prices = $order->shipping_prices[$rate->shippingkey];
if(!isset($rate->shipping_params->shipping_price_use_tax))
$rate->shipping_params->shipping_price_use_tax = 1;
if(!isset($rate->shipping_params->shipping_virtual_included) ||
$rate->shipping_params->shipping_virtual_included) {
if($rate->shipping_params->shipping_price_use_tax)
$price = $shipping_prices->all_with_tax;
else
$price = $shipping_prices->all_without_tax;
} else {
if($rate->shipping_params->shipping_price_use_tax)
$price = $shipping_prices->real_with_tax;
else
$price = $shipping_prices->real_without_tax;
}
if($rate->shipping_currency_id != $currentCurrency){
$rate->shipping_price =
$currencyClass->convertUniquePrice($rate->shipping_price,
$rate->shipping_currency_id, $currentCurrency);
$rate->shipping_currency_id_orig = $rate->shipping_currency_id;
$rate->shipping_currency_id = $currentCurrency;
}
if(bccomp($price, 0, 5) &&
isset($rate->shipping_params->shipping_percentage) &&
bccomp($rate->shipping_params->shipping_percentage, 0, 3)){
$rate->shipping_price = $rate->shipping_price + $price *
$rate->shipping_params->shipping_percentage / 100;
}
if(!empty($rate->shipping_params->shipping_formula)) {
$formula = str_replace(array('{price}', '{volume}',
'{weight}', '{quantity}'), array($price,
$shipping_prices->volume, $shipping_prices->weight,
$shipping_prices->total_quantity),
$rate->shipping_params->shipping_formula);
$e = hikashop_get('inc.expression');
try {
$result = $e->evaluate($formula);
$rate->shipping_price = $rate->shipping_price + $result;
} catch(Exception $e) {
$app = JFactory::getApplication();
$app->enqueueMessage($e->getMessage());
}
}
$rate->shipping_price =
$currencyClass->round($rate->shipping_price,
$currencyClass->getRounding($rate->shipping_currency_id, true));
if(!empty($rate->shipping_params->shipping_min_price) &&
bccomp((float)hikashop_toFloat($rate->shipping_params->shipping_min_price),
(float)$price, 5) == 1)
$rate->errors['min_price'] =
(hikashop_toFloat($rate->shipping_params->shipping_min_price) -
$price);
if(!empty($rate->shipping_params->shipping_max_price) &&
bccomp((float)hikashop_toFloat($rate->shipping_params->shipping_max_price),
(float)$price, 5) == -1)
$rate->errors['max_price'] = ($price -
hikashop_toFloat($rate->shipping_params->shipping_max_price));
if(!empty($rate->shipping_params->shipping_max_volume) &&
bccomp((float)@$rate->shipping_params->shipping_max_volume, 0, 3)) {
$rate->shipping_params->shipping_max_volume_orig =
$rate->shipping_params->shipping_max_volume;
$rate->shipping_params->shipping_max_volume =
$this->volumeHelper->convert($rate->shipping_params->shipping_max_volume,
@$rate->shipping_params->shipping_size_unit);
if(bccomp(sprintf('%.10F',$rate->shipping_params->shipping_max_volume),
sprintf('%.10F',$shipping_prices->volume), 10) == -1)
$rate->errors['max_volume'] =
($rate->shipping_params->shipping_max_volume -
$shipping_prices->volume);
}
if(!empty($rate->shipping_params->shipping_min_volume) &&
bccomp((float)@$rate->shipping_params->shipping_min_volume, 0, 3)) {
$rate->shipping_params->shipping_min_volume_orig =
$rate->shipping_params->shipping_min_volume;
$rate->shipping_params->shipping_min_volume =
$this->volumeHelper->convert($rate->shipping_params->shipping_min_volume,
@$rate->shipping_params->shipping_size_unit);
if(bccomp(sprintf('%.10F',$rate->shipping_params->shipping_min_volume),
sprintf('%.10F',$shipping_prices->volume), 10) == 1)
$rate->errors['min_volume'] =
($shipping_prices->volume -
$rate->shipping_params->shipping_min_volume);
}
if(!empty($rate->shipping_params->shipping_max_weight) &&
bccomp((float)@$rate->shipping_params->shipping_max_weight, 0, 3)) {
$rate->shipping_params->shipping_max_weight_orig =
$rate->shipping_params->shipping_max_weight;
$rate->shipping_params->shipping_max_weight =
$this->weightHelper->convert($rate->shipping_params->shipping_max_weight,
@$rate->shipping_params->shipping_weight_unit);
if(bccomp(sprintf('%.3F',$rate->shipping_params->shipping_max_weight),
sprintf('%.3F',$shipping_prices->weight), 3) == -1)
$rate->errors['max_weight'] =
($rate->shipping_params->shipping_max_weight -
$shipping_prices->weight);
}
if(!empty($rate->shipping_params->shipping_min_weight) &&
bccomp((float)@$rate->shipping_params->shipping_min_weight,0,3)){
$rate->shipping_params->shipping_min_weight_orig =
$rate->shipping_params->shipping_min_weight;
$rate->shipping_params->shipping_min_weight =
(float)$this->weightHelper->convert($rate->shipping_params->shipping_min_weight,
@$rate->shipping_params->shipping_weight_unit);
if(bccomp(sprintf('%.3F',$rate->shipping_params->shipping_min_weight),
sprintf('%.3F',$shipping_prices->weight), 3) == 1)
$rate->errors['min_weight'] =
($shipping_prices->weight -
$rate->shipping_params->shipping_min_weight);
}
if(!empty($rate->shipping_params->shipping_max_quantity)
&& (int)$rate->shipping_params->shipping_max_quantity) {
if((int)$rate->shipping_params->shipping_max_quantity <
(int)$shipping_prices->total_quantity)
$rate->errors['max_quantity'] =
($rate->shipping_params->shipping_max_quantity -
$shipping_prices->total_quantity);
}
if(!empty($rate->shipping_params->shipping_min_quantity)
&& (int)$rate->shipping_params->shipping_min_quantity){
if((int)$rate->shipping_params->shipping_min_quantity >
(int)$shipping_prices->total_quantity)
$rate->errors['min_quantity'] =
($shipping_prices->total_quantity -
$rate->shipping_params->shipping_min_quantity);
}
if(isset($rate->shipping_params->shipping_per_product) &&
$rate->shipping_params->shipping_per_product) {
if(!isset($order->shipping_prices[$rate->shippingkey]->price_per_product)){
$order->shipping_prices[$rate->shippingkey]->price_per_product
= array();
}
$order->shipping_prices[$rate->shippingkey]->price_per_product[$rate->shipping_id]
= array(
'price' =>
(float)$rate->shipping_params->shipping_price_per_product,
'products' => array()
);
}
unset($rate);
}
foreach($order->shipping_prices as $key => $shipping_price) {
if(empty($shipping_price->price_per_product) ||
empty($shipping_price->products))
continue;
$shipping_ids = array_keys($shipping_price->price_per_product);
hikashop_toInteger($shipping_ids);
$product_ids = array_keys($shipping_price->products);
$query = 'SELECT a.shipping_id, a.shipping_price_ref_id as
`ref_id`, a.shipping_price_min_quantity as `min_quantity`,
a.shipping_price_value as `price`, a.shipping_fee_value as `fee`,
a.shipping_blocked as `blocked`'.
' FROM ' . hikashop_table('shipping_price') .
' AS a '.
' WHERE a.shipping_id IN (' . implode(',',
$shipping_ids) . ') '.
' AND a.shipping_price_ref_id IN (' . implode(',',
$product_ids) . ') AND a.shipping_price_ref_type =
\'product\' '.
' ORDER BY a.shipping_id, a.shipping_price_ref_id,
a.shipping_price_min_quantity';
$db = JFactory::getDBO();
$db->setQuery($query);
$ret = $db->loadObjectList();
if(empty($ret))
continue;
$products_qty = $shipping_price->products;
foreach($order->products as $ordered_product) {
if($ordered_product->product_parent_id == 0)
continue;
foreach($ret as $ship) {
if($ordered_product->product_id == $ship->ref_id) {
$products_qty[ (int)$ordered_product->product_parent_id ] -=
$products_qty[ (int)$ordered_product->product_id ];
}
}
}
foreach($ret as $ship) {
$order->shipping_prices[$key]->price_per_product[$ship->shipping_id]['blocked']
= 0;
if($products_qty[$ship->ref_id] > 0 &&
$ship->min_quantity <= $products_qty[$ship->ref_id] &&
$ship->blocked)
$order->shipping_prices[$key]->price_per_product[$ship->shipping_id]['blocked']
= 1;
if($products_qty[$ship->ref_id] > 0 &&
$ship->min_quantity <= $products_qty[$ship->ref_id])
$order->shipping_prices[$key]->price_per_product[$ship->shipping_id]['products'][$ship->ref_id]
= ($ship->price * $products_qty[$ship->ref_id]) + $ship->fee;
}
unset($products_qty);
}
foreach($rates as &$rate) {
if(!isset($rate->shippingkey))
continue;
$shipping_prices =&
$order->shipping_prices[$rate->shippingkey];
if(isset($shipping_prices->price_per_product[$rate->shipping_id])
&& !empty($order->products)) {
$rate_prices =&
$order->shipping_prices[$rate->shippingkey]->price_per_product[$rate->shipping_id];
$price = 0;
$rate_prices['products']['product_names'] =
array();
foreach($order->products as $k => $row) {
if(!empty($rate->products) &&
!in_array($row->product_id, $rate->products))
continue;
if(isset($rate_prices['products'][$row->product_id])) {
$price += $rate_prices['products'][$row->product_id];
if($rate_prices['blocked'])
$rate_prices['products']['product_names'][] =
'"' . $row->product_name . '"';
$rate_prices['products'][$row->product_id] = 0;
}
elseif(isset($rate_prices['products'][$row->product_parent_id]))
{
$price +=
$rate_prices['products'][$row->product_parent_id];
if($rate_prices['blocked'])
$rate_prices['products']['product_names'][] =
'"' .
$order->products['p'.$row->product_id]->product_name .
'"';
$rate_prices['products'][$row->product_parent_id] = 0;
}
elseif(!isset($rate->shipping_params->shipping_virtual_included) ||
$rate->shipping_params->shipping_virtual_included ||
$row->product_weight > 0) {
$price += $rate_prices['price'] *
$row->cart_product_quantity;
}
}
if(count($rate_prices['products']['product_names']))
{
$rate->errors['X_PRODUCTS_ARE_NOT_SHIPPABLE_TO_YOU'] =
implode($rate_prices['products']['product_names'],
', ');
$rate->errors['X_PRODUCTS_ARE_NOT_SHIPPABLE_TO_YOU'] =
'';
foreach($rate_prices['products']['product_names']
as $product_name) {
if(empty($product_name) || $product_name ==
'""')
continue;
$rate->errors['X_PRODUCTS_ARE_NOT_SHIPPABLE_TO_YOU'] .=
$product_name . ', ';
}
trim($rate->errors['X_PRODUCTS_ARE_NOT_SHIPPABLE_TO_YOU'],
', ');
} else {
if(!isset($rate->shipping_price_base))
$rate->shipping_price_base =
hikashop_toFloat($rate->shipping_price);
else
$rate->shipping_price = $rate->shipping_price_base;
$rate->shipping_price =
$currencyClass->round($rate->shipping_price + $price,
$currencyClass->getRounding($rate->shipping_currency_id, true));
}
unset($rate_prices);
}
unset($shipping_prices);
if(empty($rate->errors)) {
$usable_rates[$rate->shipping_id] = $rate;
if($this->use_cache)
$local_cache_shipping[$rate->shipping_id] = $rate;
} else {
$messages[] = $rate->errors;
if($this->use_cache)
$local_cache_errors[] = $rate->errors;
}
}
if($this->use_cache)
$this->setShippingCache($order, $local_cache_shipping,
$local_cache_errors);
return true;
}
public function onShippingSave(&$cart, &$methods,
&$shipping_id, $warehouse_id = null) {
$usable_methods = array();
$errors = array();
$shipping = hikashop_get('class.shipping');
$usable_methods = $shipping->getShippings($cart);
if(is_numeric($warehouse_id)) $warehouse_id = (int)$warehouse_id;
foreach($usable_methods as $k => $usable_method) {
if(is_numeric($usable_method->shipping_warehouse_id))
$usable_method->shipping_warehouse_id =
(int)$usable_method->shipping_warehouse_id;
if(($usable_method->shipping_id == $shipping_id) &&
($warehouse_id === null || (isset($usable_method->shipping_warehouse_id)
&& $usable_method->shipping_warehouse_id === $warehouse_id)))
return $usable_method;
}
return false;
}
public function onShippingCustomSave(&$cart, &$method, $warehouse,
$formData) {
return $formData;
}
public function onShippingConfiguration(&$element) {
$this->pluginConfiguration($element);
if(empty($element) || empty($element->shipping_type)) {
$element = new stdClass();
$element->shipping_type = $this->pluginName;
$element->shipping_params = new stdClass();
$this->getShippingDefaultValues($element);
}
$this->currency = hikashop_get('type.currency');
$this->weight = hikashop_get('type.weight');
$this->volume = hikashop_get('type.volume');
}
public function onShippingConfigurationSave(&$element) {
if(empty($this->pluginConfig))
return true;
$formData = hikaInput::get()->get('data', array(),
'array');
if(!isset($formData['shipping']['shipping_params']))
return true;
foreach($this->pluginConfig as $key => $config) {
if($config[1] == 'textarea' || $config[1] ==
'big-textarea') {
$element->shipping_params->$key =
@$formData['shipping']['shipping_params'][$key];
}
}
return true;
}
public function onAfterOrderConfirm(&$order, &$methods,
$method_id) {
$this->order = $order;
return true;
}
public function getShippingCache(&$order) {
if(empty($this->name) || empty($order->cache->shipping) ||
empty($order->cache->shipping_key))
return false;
$key = $order->cache->shipping_key;
if(empty($order->cache->shipping[$key]))
return false;
if(isset($order->shipping_warehouse_id)) {
if(isset($order->cache->shipping[$key][(int)$order->shipping_warehouse_id][$this->name]))
return
$order->cache->shipping[$key][(int)$order->shipping_warehouse_id][
$this->name ];
return false;
}
if(isset($order->cache->shipping[$key][$this->name]))
return $order->cache->shipping[$key][ $this->name ];
return false;
}
public function loadShippingCache(&$order, &$usable_rates,
&$messages) {
$cache = $this->getShippingCache($order);
if($cache === false)
return false;
list($methods, $msg) = $cache;
if(!empty($methods)) {
foreach($methods as $i => $rate) {
$usable_rates[$rate->shipping_id] = $rate;
}
}
if(!empty($msg)) {
foreach($msg as $i => $err) {
$messages[] = $err;
}
}
return true;
}
public function setShippingCache(&$order, $data, $messages = null) {
if(empty($this->name) || empty($order->cache->shipping_key))
return false;
$key = $order->cache->shipping_key;
if(empty($order->cache->shipping)) $order->cache->shipping =
array();
if(empty($order->cache->shipping[$key]))
$order->cache->shipping[$key] = array();
if(isset($order->shipping_warehouse_id)) {
if(empty($order->cache->shipping[$key][(int)$order->shipping_warehouse_id]))
$order->cache->shipping[$key][(int)$order->shipping_warehouse_id]
= array();
$order->cache->shipping[$key][(int)$order->shipping_warehouse_id][$this->name]
= array($data, $messages);
return true;
}
$order->cache->shipping[$key][ $this->name ] = array($data,
$messages);
return false;
}
public function getShippingAddress($id = 0, $order = null) {
$app = JFactory::getApplication();
if($id == 0 && !hikashop_isClient('administrator')) {
$id = $app->getUserState(HIKASHOP_COMPONENT.'.shipping_id',
null);
if(!empty($id) && is_array($id))
$id = (int)reset($id);
else
$id = 0;
} elseif(is_array($id)) {
$id = (int)reset($id);
}
if(empty($id))
return false;
$shippingClass = hikashop_get('class.shipping');
$shipping = $shippingClass->get($id);
if(!$shipping || $shipping->shipping_type != $this->name)
return false;
$params = $shipping->shipping_params;
if(is_string($params) && !empty($params))
$params = hikashop_unserialize($params);
$override = 0;
if(isset($params->shipping_override_address)) {
$override = (int)$params->shipping_override_address;
}
switch($override) {
case 4:
if(!empty($params->shipping_override_address_text))
return $params->shipping_override_address_text;
break;
case 3:
if(!empty($params->shipping_override_address_text))
return
str_replace(array("\r\n","\n","\r"),"<br/>",
htmlentities($params->shipping_override_address_text, ENT_COMPAT,
'UTF-8') );
break;
case 2:
return '';
case 1:
$config =& hikashop_config();
return
str_replace(array("\r\n","\n","\r"),"<br/>",
$config->get('store_address'));
case 0:
default:
return false;
}
return false;
}
public function getShippingDefaultValues(&$element) {}
public function getOrderPackage(&$order, $options = array()) {
$ret = array();
if(empty($order->products))
return array('w' => 0, 'x' => 0, 'y'
=> 0, 'z' => 0);
$weight_unit = !empty($order->weight_unit) ? $order->weight_unit :
'lb';
$volume_unit = !empty($order->volume_unit) ? $order->volume_unit :
'in';
if(!empty($options['weight_unit']))
$weight_unit = $options['weight_unit'];
if(!empty($options['volume_unit']))
$volume_unit = $options['volume_unit'];
$current = array('w' => 0, 'x' => 0,
'y' => 0, 'z' => 0);
$error = false;
foreach($order->products as $k => $product) {
$qty = 1;
if(isset($product->cart_product_quantity))
$qty = (int)$product->cart_product_quantity;
if(isset($product->order_product_quantity))
$qty = (int)$product->order_product_quantity;
if($qty == 0)
continue;
$weight = 0;
if($product->product_weight_unit == $weight_unit) {
$weight += ((float)$product->product_weight);
} else if(!empty($product->product_weight_unit_orig) &&
$product->product_weight_unit_orig == $weight_unit) {
$weight +=
((float)hikashop_toFloat($product->product_weight_orig));
} else {
if(empty($this->weightHelper))
$this->weightHelper = hikashop_get('helper.weight');
$weight +=
((float)$this->weightHelper->convert($product->product_weight,
$product->product_weight_unit, $weight_unit));
}
if($weight == 0)
continue;
$w = (float)hikashop_toFloat($product->product_width);
$h = (float)hikashop_toFloat($product->product_height);
$l = (float)hikashop_toFloat($product->product_length);
if($product->product_dimension_unit !== $volume_unit) {
if(empty($this->volumeHelper))
$this->volumeHelper = hikashop_get('helper.volume');
if(!empty($w))
$w = $this->volumeHelper->convert($w,
$product->product_dimension_unit, $volume_unit, 'dimension');
if(!empty($h))
$h = $this->volumeHelper->convert($h,
$product->product_dimension_unit, $volume_unit, 'dimension');
if(!empty($l))
$l = $this->volumeHelper->convert($l,
$product->product_dimension_unit, $volume_unit, 'dimension');
}
$d = array($w,$h,$l);
sort($d); // x = d[0] // y = d[1] // z = d[2]
$p = array(
'w' => $weight,
'x' => $d[0],
'y' => $d[1],
'z' => $d[2]
);
if(!empty($options['required_dimensions'])) {
if(!$this->checkDimensions($product, $p,
$options['required_dimensions'])) {
$error = true;
continue;
}
}
if(!empty($options['limit'])) {
$total_quantity = $qty;
while ($total_quantity > 0) {
foreach ($options['limit'] as $limit_key => $limit_value)
{
$valid = $this->processPackageLimit($limit_key, $limit_value , $p,
$total_quantity, $current, array('weight' => $weight_unit,
'volume' => $volume_unit));
if ($valid === false)
$total_quantity = 0;
else if (is_int($valid))
$total_quantity = min($total_quantity, $valid);
if ($total_quantity === 0)
break;
}
if ($total_quantity === 0) {
if(empty($current['w']) &&
empty($current['x']) && empty($current['y'])
&& empty($current['z']))
return false;
$ret[] = $current;
$total_quantity = $qty;
$current = array('w' => 0, 'x' => 0,
'y' => 0, 'z' => 0);
} else if($total_quantity < $qty) {
$factor = 1;
if(empty($current['w']) &&
empty($current['x']) && empty($current['y'])
&& empty($current['z']) && $total_quantity*2
<= $qty)
$factor = floor($qty / $total_quantity);
$current['w'] += $weight * $total_quantity;
$current['x'] += ($d[0] * $total_quantity);
$current['y'] = max($current['y'], $d[1]);
$current['z'] = max($current['z'], $d[2]);
$ret[] = $current;
for($i = 1; $i < $factor; $i++) {
$ret[] = $current;
}
$current = array('w' => 0, 'x' => 0,
'y' => 0, 'z' => 0);
$qty -= $total_quantity * $factor;
$total_quantity = $qty;
} else
$total_quantity = 0;
}
}
if($qty > 0) {
$current['w'] += $weight * $qty;
$current['x'] += ($d[0] * $qty);
$current['y'] = max($current['y'], $d[1]);
$current['z'] = max($current['z'], $d[2]);
}
}
if($error)
return false;
if(empty($ret))
return $current;
if($current['w'] != 0 || $current['x'] != 0 ||
$current['y'] != 0 || $current['z'] != 0)
$ret[] = $current;
return $ret;
}
public function checkDimensions($product, $dimensions, $requirements =
array()) {
if(empty($requirements) || !count($requirements))
return true;
if(empty($dimensions['w']) &&
empty($dimensions['x']) &&
empty($dimensions['y']) &&
empty($dimensions['z']))
return true;
$available_requirements = array(
'w' => 'PRODUCT_WEIGHT',
'x' => 'PRODUCT_WIDTH',
'y' => 'PRODUCT_LENGTH',
'z' => 'PRODUCT_HEIGHT',
);
$return = true;
static $already = array();
foreach($requirements as $requirement){
if(!empty($dimensions[$requirement]))
continue;
if(!isset($available_requirements[$requirement]))
continue;
$dimension = $available_requirements[$requirement];
if(empty($already[$dimension . '_' .
$product->product_id])) {
$already[$dimension . '_' . $product->product_id] = true;
$app = JFactory::getApplication();
$app->enqueueMessage(JText::sprintf('THE_X_IS_MISSING_FOR_THE_PRODUCT_X',
JText::_($dimension), $product->product_name));
}
$return = false;
}
return $return;
}
public function processPackageLimit($limit_key, $limit_value , $product,
$qty, $package, $units) {
switch ($limit_key) {
case 'unit':
if($qty > $limit_value)
return (int)$limit_value;
return (int)$qty;
case 'x':
if(empty($product['x']) || $product['x'] >
$limit_value)
return false;
$limit_value = max(0.0, $limit_value - $package['x']);
return (int)floor($limit_value / $product['x']);
case 'y':
if(empty($product['y']) || $product['y'] >
$limit_value)
return false;
return (int)floor($limit_value / $product['y']);
case 'z':
if(empty($product['z']) || $product['z'] >
$limit_value)
return false;
return (int)floor($limit_value / $product['z']);
case 'w':
if(empty($product['w']) || $product['w'] >
$limit_value)
return false;
$limit_value = max(0.0, $limit_value - $package['w']);
return (int)floor($limit_value / $product['w']);
}
return 0;
}
public function groupPackages(&$data, $caracs) {
$data['weight_unit'] = $caracs['weight_unit'];
$data['dimension_unit'] = $caracs['dimension_unit'];
$tmpHeight = $data['height'] +
round($caracs['height'], 2);
$tmpLength = $data['length'] +
round($caracs['length'], 2);
$tmpWidth = $data['width'] + round($caracs['width'],
2);
$dim = $tmpLength + (2 * $tmpWidth) + (2 * $tmpHeight);
$d = array($caracs['width'], $caracs['height'],
$caracs['length']);
sort($d);
return array(
'x' => $d[0],
'y' => $d[1],
'z' => $d[2],
'dim' => $dim,
'tmpHeight' => $tmpHeight,
'tmpLength' => $tmpLength,
'tmpWidth' => $tmpWidth,
);
}
function _convertCharacteristics(&$product, $data, $forceUnit = false)
{
$carac = array();
if(!isset($product->product_dimension_unit_orig))
$product->product_dimension_unit_orig =
$product->product_dimension_unit;
if(!isset($product->product_weight_unit_orig))
$product->product_weight_unit_orig =
$product->product_weight_unit;
if(!isset($product->product_weight_orig))
$product->product_weight_orig = $product->product_weight;
if($forceUnit) {
if(empty($this->weightHelper))
$this->weightHelper = hikashop_get('helper.weight');
if(empty($this->volumeHelper))
$this->volumeHelper = hikashop_get('helper.volume');
$carac['weight'] =
$this->weightHelper->convert($product->product_weight_orig,
$product->product_weight_unit_orig, 'lb');
$carac['weight_unit'] = 'LBS';
$carac['height'] =
$this->volumeHelper->convert($product->product_height,
$product->product_dimension_unit_orig, 'in' ,
'dimension');
$carac['length'] =
$this->volumeHelper->convert($product->product_length,
$product->product_dimension_unit_orig, 'in',
'dimension');
$carac['width'] =
$this->volumeHelper->convert($product->product_width,
$product->product_dimension_unit_orig, 'in',
'dimension');
$carac['dimension_unit'] = 'IN';
return $carac;
}
if(empty($data['units']))
$data['units'] = 'kg';
$c = ($data['units'] == 'kg') ? array('v'
=> 'kg', 'vu' => 'KGS', 'd'
=> 'cm', 'du' => 'CM' ) :
array('v' => 'lb', 'vu' =>
'LBS', 'd' => 'in', 'du' =>
'IN');
if($product->product_weight_unit_orig == $c['v']){
$carac['weight'] = $product->product_weight_orig;
$carac['weight_unit'] =
$this->convertUnit[$product->product_weight_unit_orig];
} else {
if(empty($this->weightHelper))
$this->weightHelper = hikashop_get('helper.weight');
$carac['weight'] =
$this->weightHelper->convert($product->product_weight_orig,
$product->product_weight_unit_orig, $c['v']);
$carac['weight_unit'] = $c['vu'];
}
if($product->product_dimension_unit_orig == $c['d']) {
$carac['height'] = $product->product_height;
$carac['length'] = $product->product_length;
$carac['width'] = $product->product_width;
$carac['dimension_unit'] =
$this->convertUnit[$product->product_dimension_unit_orig];
} else {
if(empty($this->volumeHelper))
$this->volumeHelper = hikashop_get('helper.volume');
$carac['height'] =
$this->volumeHelper->convert($product->product_height,
$product->product_dimension_unit_orig, $c['d'],
'dimension');
$carac['length'] =
$this->volumeHelper->convert($product->product_length,
$product->product_dimension_unit_orig, $c['d'],
'dimension');
$carac['width'] =
$this->volumeHelper->convert($product->product_width,
$product->product_dimension_unit_orig, $c['d'],
'dimension');
$carac['dimension_unit'] = $c['du'];
}
return $carac;
}
function _currencyConversion(&$usableMethods, &$order) {
$currency = $this->shipping_currency_id;
$currencyClass = hikashop_get('class.currency');
foreach($usableMethods as $i => $method){
if((int)$method['currency_id'] == (int)$currency)
continue;
$usableMethods[$i]['value'] =
$currencyClass->convertUniquePrice($method['value'],
(int)$method['currency_id'], $currency);
$usableMethods[$i]['old_currency_id'] =
(int)$usableMethods[$i]['currency_id'];
$usableMethods[$i]['old_currency_code'] =
$usableMethods[$i]['currency_code'];
$usableMethods[$i]['currency_id'] = (int)$currency;
$usableMethods[$i]['currency_code'] =
$this->shipping_currency_code;
}
return $usableMethods;
}
function displayDelaySECtoDAY($value, $type) {
$c = array(
0 => 60, // Min
1 => 3600, // Hour
2 => 86400 // Day
);
if(!empty($c[$type]))
return round( (int)$value / $c[$type] );
return $value;
}
}
sliders.php000064400000006726151162557560006752 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopSlidersHelper {
var $ctrl = 'sliders';
var $tabs = null;
var $openPanel = false;
var $mode = null;
var $count = 0;
var $name = '';
var $options = null;
function __construct() {
if(version_compare(JVERSION,'1.6','<')) {
$this->mode = 'pane';
} elseif(version_compare(JVERSION,'3.0','<')) {
$this->mode = 'sliders';
} else {
$this->mode = 'bootstrap';
}
}
function startPane($name) { return $this->start($name); }
function startPanel($text, $id, $child = 0) { return
$this->panel($text, $id, $child); }
function endPanel() { return ''; }
function endPane() { return $this->end(); }
function setOptions($options = array()) {
if($this->options == null)
$this->options = $options;
else
$this->options = array_merge($this->options, $options);
}
function start($name, $options = array()) {
$ret = '';
if($this->mode == 'pane') {
jimport('joomla.html.pane');
if(!empty($this->options))
$options = array_merge($options, $this->options);
$this->tabs = JPane::getInstance('sliders', $options);
$ret .= $this->tabs->startPane($name);
} elseif($this->mode == 'sliders') {
if(!empty($this->options))
$options = array_merge($options, $this->options);
$ret .= JHtml::_('sliders.start', $name, $options);
} else {
if($this->options == null)
$this->options = $options;
else
$this->options = array_merge($this->options, $options);
$this->name = $name;
$this->count = 0;
$ret .= '<div class="accordion"
id="'.$name.'">';
}
return $ret;
}
function panel($text, $id, $child = 0) {
$ret = '';
if($child) $child = 'has-child';
else $child = '';
if($this->mode == 'pane') {
if($this->openPanel)
$ret .= $this->tabs->endPanel();
$ret .= $this->tabs->startPanel($text, $id);
$this->openPanel = true;
} elseif($this->mode == 'sliders') {
$ret .= JHtml::_('sliders.panel', JText::_($text), $id);
} else {
if($this->openPanel)
$ret .= $this->_closePanel();
$open = '';
$this->options['displayFirst'] =
isset($this->options['displayFirst'])?$this->options['displayFirst']:1;
if($this->options['displayFirst'] &&
(isset($this->options['startOffset']) &&
$this->options['startOffset'] == $this->count ||
$this->count == 0))
$open = ' in';
$this->count++;
$ret .= '
<div class="accordion-group">
<div class="accordion-heading '.$child.'">
<a class="accordion-toggle"
data-toggle="collapse"
data-parent="#'.$this->name.'"
href="#'.$id.'">
'.$text.'
</a>
</div>
<div id="'.$id.'" class="accordion-body
collapse'.$open.'">
<div class="accordion-inner">
';
$this->openPanel = true;
}
return $ret;
}
function _closePanel() {
if(!$this->openPanel)
return '';
$this->openPanel = false;
return '</div></div></div>';
}
function end() {
$ret = '';
if($this->mode == 'pane') {
if($this->openPanel)
$ret .= $this->tabs->endPanel();
$ret .= $this->tabs->endPane();
} elseif($this->mode == 'sliders') {
$ret .= JHtml::_('sliders.end');
} else {
if($this->openPanel)
$ret .= $this->_closePanel();
$ret .= '</div>';
}
return $ret;
}
}
spreadsheet.php000064400000007707151162557560007614 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopSpreadsheetHelper {
var $format;
var $filename;
var $separator;
var $currLine;
var $buffer;
var $forceQuote;
var $progressive;
var $headerSent;
function __construct() {
$this->init();
}
function init($format = 'csv', $filename = 'export',
$sep = ';', $forceQuote = false) {
$this->currLine = -1;
$this->buffer = '';
$this->separator = ';';
$this->filename = $filename;
$this->forceQuote = $forceQuote;
$this->progressive = false;
$this->headerSent = false;
switch( strtolower($format) ) {
case 'xls':
$this->format = 1;
break;
default:
case 'csv':
$this->format = 0;
$this->separator = $sep;
break;
}
if( empty($this->filename) )
$this->filename = 'export';
if( $this->format == 1 )
$this->filename .= '.xls';
else
$this->filename .= '.csv';
if( $this->format == 1 )
$this->buffer .= pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0,
0x0);
}
function send() {
if(!$this->headerSent) {
if( $this->format == 1 )
$this->buffer .= pack("ss", 0x0A, 0x00);
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0,
pre-check=0');
header('Content-Type: application/force-download');
header('Content-Type: application/octet-stream');
header('Content-Type: application/download');
header('Content-Disposition:
attachment;filename='.$this->filename.' ');
header('Content-Transfer-Encoding: binary ');
if(!$this->progressive) {
header('Content-Length: '.strlen($this->buffer));
}
$this->headerSent = true;
}
echo $this->buffer;
$this->buffer = '';
if(!$this->progressive)
exit;
}
function flush() {
if($this->progressive){
if(!$this->headerSent) {
$this->send();
} else {
echo $this->buffer;
$this->buffer = '';
}
}
}
function writeNumber($row, $col, $value, $lastOne) {
if( $this->format == 1 ) {
$this->currLine = $row;
$this->buffer .= pack("sssss", 0x203, 14, $row, $col,
0x0);
$this->buffer .= pack("d", $value);
} else {
if( $this->currLine < $row )
$this->newLine();
$this->currLine = $row;
$this->buffer .= $value;
if(!$lastOne)
$this->buffer .= $this->separator;
}
}
function writeText($row, $col, $value, $lastOne) {
if( $this->format == 1 ) {
$this->currLine = $row;
$len = strlen($value);
$this->buffer .= pack("ssssss", 0x204, 8 + $len, $row,
$col, 0x0, $len);
$this->buffer .= $value;
} else {
if( $this->currLine < $row )
$this->newLine();
$this->currLine = $row;
if( empty($value) ) {
$value = '""';
} elseif( strpos($value, '"') !== false ) {
$value = '"' .
str_replace('"','""',$value) .
'"';
} elseif( $this->forceQuote || (strpos($value, $this->separator)
!== false) || (strpos($value, "\n") !== false) || (trim($value)
!= $value) ) {
$value = '"' . $value . '"';
}
$this->buffer .= $value;
if(!$lastOne)
$this->buffer .= $this->separator;
}
}
function newLine() {
if( $this->format == 0 ) {
$this->buffer .= "\r\n";
}
}
function writeLine($data) {
$i = 0;
$this->currLine++;
if( $this->currLine > 0 )
$this->newLine();
end($data);
$last = key($data);
reset($data);
foreach($data as $k => $value) {
$lastOne = false;
if ($last===$k)
$lastOne = true;
if(is_array($value))
continue;
if( is_numeric($value) ) {
$this->writeNumber($this->currLine, $i++, $value, $lastOne);
} else {
$this->writeText($this->currLine, $i++, $value, $lastOne);
}
}
if($this->progressive) {
$this->flush();
}
}
}
tabs.php000064400000011636151162557560006232 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopTabsHelper {
var $ctrl = 'tabs';
var $tabs = null;
var $openPanel = false;
var $mode = null;
var $data = array();
var $options = null;
var $name = '';
function __construct() {
if(!HIKASHOP_J16) {
$this->mode = 'pane';
} elseif(!HIKASHOP_J30) {
$this->mode = 'tabs';
} else {
$this->mode = 'bootstrap';
}
}
function startPane($name) { return $this->start($name); }
function startPanel($text, $id) { return $this->panel($text, $id); }
function endPanel() { return ''; }
function endPane() { return $this->end(); }
function setOptions($options = array()) {
if($this->options == null)
$this->options = $options;
else
$this->options = array_merge($this->options, $options);
}
function start($name, $options = array()) {
$ret = '';
if($this->mode == 'pane') {
jimport('joomla.html.pane');
if(!empty($this->options))
$options = array_merge($options, $this->options);
$this->tabs = JPane::getInstance('tabs', $options);
$ret .= $this->tabs->startPane($name);
} elseif($this->mode == 'tabs') {
if(!empty($this->options))
$options = array_merge($options, $this->options);
$ret .= JHtml::_('tabs.start', $name, $options);
} else {
$this->name = $name;
if($this->options == null)
$this->options = $options;
else
$this->options = array_merge($this->options, $options);
}
return $ret;
}
function panel($text, $id) {
$ret = '';
if($this->mode == 'pane') {
if($this->openPanel)
$ret .= $this->tabs->endPanel();
$ret .= $this->tabs->startPanel($text, $id);
$this->openPanel = true;
} elseif($this->mode == 'tabs') {
$ret .= JHtml::_('tabs.panel', JText::_($text), $id);
} else {
if($this->openPanel)
$this->_closePanel();
$obj = new stdClass();
$obj->text = $text;
$obj->id = $id;
$obj->data = '';
$this->data[] = $obj;
ob_start();
$this->openPanel = true;
}
return $ret;
}
function _closePanel() {
if(!$this->openPanel)
return;
$panel = end($this->data);
$panel->data .= ob_get_clean();
$this->openPanel = false;
}
function end() {
$ret = '';
if($this->mode == 'pane') {
if($this->openPanel)
$ret .= $this->tabs->endPanel();
$ret .= $this->tabs->endPane();
} elseif($this->mode == 'tabs') {
$ret .= JHtml::_('tabs.end');
} else {
static $jsInit = false;
if($this->openPanel)
$this->_closePanel();
$classes = '';
if(isset($this->options['useCookie']) &&
$this->options['useCookie']) {
$classes .= ' nav-remember';
}
$ret .= '<div><ul class="nav
nav-tabs'.$classes.'"
id="'.$this->name.'"
style="width:100%;">'."\r\n";
foreach($this->data as $k => $data) {
$active = '';
if((isset($this->options['startOffset']) &&
$this->options['startOffset'] == $k) || $k == 0)
$active = ' class="active"';
$ret .= ' <li' . $active.'><a
href="#' . $data->id . '"
id="'.$data->id.'_tablink"
data-toggle="tab">' . JText::_($data->text) .
'</a></li>'."\r\n";
}
$ret .= '</ul>'."\r\n".'<div
class="tab-content">'."\r\n";
foreach($this->data as $k => $data) {
$active = '';
if((isset($this->options['startOffset']) &&
$this->options['startOffset'] == $k) || $k == 0)
$active = ' active';
$ret .= ' <div class="tab-pane' .
$active.'" id="' . $data->id .
'">'."\r\n".$data->data."\r\n".' </div>'."\r\n";
unset($data->data);
}
$ret .= '</div></div>';
unset($this->data);
if(!$jsInit) {
$jsInit = true;
$js = 'jQuery(document).ready(function (){
jQuery("ul.nav-remember").each(function(nav){
var id = jQuery(this).attr("id");
jQuery("#" + id + "
a[data-toggle=\"tab\"]").on("shown", function (e)
{
if(localStorage) {
localStorage.setItem("hikashop-lastTab-"+id,
jQuery(e.target).attr("id"));
} else {
var expire = new Date(); expire.setDate(expire.getDate() + 5);
document.cookie =
"hikashop-lastTab-"+id+"="+escape(jQuery(e.target).attr("id"))+";
expires="+expire;
}
});
var lastTab = null;
if(localStorage) {
lastTab = localStorage.getItem("hikashop-lastTab-"+id);
} else {
if(document.cookie.length > 0 &&
document.cookie.indexOf("hikashop-lastTab-"+id+"=") !=
-1) {
var s = "hikashop-lastTab-"+id+"=", o =
document.cookie.indexOf(s) + s.length, e =
document.cookie.indexOf(";",o);
if(e == -1) e = document.cookie.length;
lastTab = unescape(document.cookie.substring(o, e));
}
}
if (lastTab) {
jQuery("#"+lastTab).tab("show");
}
});
});';
$doc = JFactory::getDocument();
$doc->addScriptDeclaration($js);
}
}
return $ret;
}
}
toggle.php000064400000013456151162557560006564 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopToggleHelper{
var $ctrl = 'toggle';
var $extra = '';
var $token = '';
function __construct(){
$this->token =
'&'.hikashop_getFormToken().'=1';
}
function _getToggle($column,$table = ''){
$params = new stdClass();
$params->mode = 'pictures';
if(!HIKASHOP_J16){
$params->pictures =
array(0=>'images/publish_x.png',1=>'images/tick.png',-2=>'images/publish_x.png');
}elseif(!HIKASHOP_J30){
$params->aclass =
array(0=>'grid_false',1=>'grid_true',-2=>'grid_false');
} else {
$params->aclass =
array(0=>'icon-unpublish',1=>'icon-publish',-2=>'icon-unpublish');
}
$params->values = array(0=>1,1=>0,-2=>1);
return $params;
}
function toggle($id,$value,$table,$extra = null){
$column = substr($id,0,strpos($id,'-'));
$params = $this->_getToggle($column,$table);
$newValue = $params->values[$value];
if($params->mode == 'pictures'){
static $pictureincluded = false;
if(!$pictureincluded){
$pictureincluded = true;
$js = "function joomTogglePicture(id,newvalue,table){
window.document.getElementById(id).className = 'onload';
try{
new
Ajax('index.php?option=com_hikashop&tmpl=component&ctrl=".$this->ctrl.$this->token."&task='+id+'&value='+newvalue+'&table='+table,{
method: 'get', update: $(id), onComplete: function()
{ window.document.getElementById(id).className = 'loading';
}}).request();
}catch(err){
new
Request({url:'index.php?option=com_hikashop&tmpl=component&ctrl=".$this->ctrl.$this->token."&task='+id+'&value='+newvalue+'&table='+table,method:
'get', onComplete: function(response) { $(id).innerHTML =
response; window.document.getElementById(id).className =
'loading'; }}).send();
}
}";
if (!HIKASHOP_PHP5) {
$doc =& JFactory::getDocument();
}else{
$doc = JFactory::getDocument();
}
$doc->addScriptDeclaration( $js );
}
$desc = empty($params->description[$value]) ? '' :
$params->description[$value];
if(empty($params->pictures)){
$text = ' ';
$class='class="'.$params->aclass[$value].'"';
}else{
$text = '<img
src="'.$params->pictures[$value].'"/>';
$class = '';
}
return '<a href="javascript:void(0);"
'.$class.'
onclick="joomTogglePicture(\''.$id.'\',\''.$newValue.'\',\''.$table.'\')"
title="'.$desc.'">'.$text.'</a>';
}elseif($params->mode == 'class'){
static $classincluded = false;
if(!$classincluded){
$classincluded = true;
$js = "function joomToggleClass(id,newvalue,table,extra){
var mydiv=$(id); mydiv.innerHTML = ''; mydiv.className =
'onload';
try{
new
Ajax('index.php?option=com_hikashop&tmpl=component&ctrl=".$this->ctrl.$this->token."&task='+id+'&value='+newvalue+'&table='+table+'&extra[color]='+extra,{
method: 'get', update: $(id), onComplete: function()
{ window.document.getElementById(id).className = 'loading';
}}).request();
}catch(err){
new
Request({url:'index.php?option=com_hikashop&tmpl=component&ctrl=".$this->ctrl.$this->token."&task='+id+'&value='+newvalue+'&table='+table+'&extra[color]='+extra,method:
'get', onComplete: function(response) { $(id).innerHTML =
response; window.document.getElementById(id).className =
'loading'; }}).send();
}
}";
if (!HIKASHOP_PHP5) {
$doc =& JFactory::getDocument();
}else{
$doc = JFactory::getDocument();
}
$doc->addScriptDeclaration( $js );
}
$desc = empty($params->description[$value]) ? '' :
$params->description[$value];
$return = '<a class="btn btn-micro active"
href="javascript:void(0);"
onclick="joomToggleClass(\''.$id.'\',\''.$newValue.'\',\''.$table.'\',\''.urlencode($extra['color']).'\');"
title="'.$desc.'"><div class="'.
$params->class[$value] .'"
style="background-color:'.$extra['color'].'">';
if(!empty($extra['tooltip'])) $return .=
JHTML::_('tooltip', $extra['tooltip'],
'','',' ');
$return .= '</div></a>';
return $return;
}
}
function display($column,$value){
$params = $this->_getToggle($column);
if(empty($params->pictures)){
return '<a
class="'.$params->aclass[$value].'"
href="#" style="cursor:default;"> </a>';
}else{
return '<img
src="'.$params->pictures[$value].'"/>';
}
}
function delete($lineId,$elementids,$table,$confirm =
false,$text=''){
$this->addDeleteJS();
if(empty($text)) $text = '<img
src="'.HIKASHOP_IMAGES.'delete.png"/>';
return '<a href="javascript:void(0);"
onclick="joomDelete(\''.$lineId.'\',\''.$elementids.'\',\''.$table.'\','.
($confirm ? 'true' :
'false').')">'.$text.'</a>';
}
function addDeleteJS(){
static $deleteJS = false;
if(!$deleteJS){
$deleteJS = true;
$js = "function joomDelete(lineid,elementids,table,reqconfirm){
if(reqconfirm){
if(!confirm('".JText::_('HIKA_VALIDDELETEITEMS',true)."'))
return false;
}
try{
new
Ajax('index.php?option=com_hikashop&tmpl=component&ctrl=".$this->ctrl.$this->extra.$this->token."&task=delete&value='+elementids+'&table='+table,
{ method: 'get', onComplete: function()
{window.document.getElementById(lineid).style.display =
'none';}}).request();
}catch(err){
new
Request({url:'index.php?option=com_hikashop&tmpl=component&ctrl=".$this->ctrl.$this->extra.$this->token."&task=delete&value='+elementids+'&table='+table,method:
'get', onComplete: function() {
window.document.getElementById(lineid).style.display = 'none';
}}).send();
}
}";
if (!HIKASHOP_PHP5) {
$doc =& JFactory::getDocument();
}else{
$doc = JFactory::getDocument();
}
$doc->addScriptDeclaration( $js );
}
}
}
toolbar.php000064400000015543151162557610006740 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopToolbarHelper {
var $aliases;
function __construct() {
$this->aliases = array();
}
function process($toolbar) {
$config =& hikashop_config();
if (!HIKASHOP_PHP5) {
$bar =& JToolBar::getInstance('toolbar');
}else{
$bar = JToolBar::getInstance('toolbar');
}
foreach($toolbar as $tool) {
if(!empty($tool) && is_string($tool)) {
$tool = array('name' => $tool);
}
if(empty($tool['name']) || (isset($tool['display'])
&& $tool['display'] === false)) {
continue;
}
$toolname = $tool['name'];
$standard = array(
'addNew' =>
array('new','add','New',false),
'makeDefault' =>
array('default','default','Default',false),
'assign' =>
array('assign','assign','Assign',false),
'publish' =>
array('publish','publish','Publish',false),
'publishList' =>
array('publish','publish','Publish',true),
'editList' =>
array('edit','edit','Edit',true),
'unpublish' =>
array('unpublish','unpublish','Unpublish',false),
'unpublishList' =>
array('unpublish','unpublish','Unpublish',true),
'trash' =>
array('trash','remove','Trash',true),
'apply' =>
array('apply','apply','Apply',false),
'copy' =>
array('copy','copy','HIKA_COPY',true),
'save' =>
array('save','save','Save',false),
'save2new' =>
array('save-new','save2new','JTOOLBAR_SAVE_AND_NEW',false),
'save2copy' =>
array('save-copy','save','JTOOLBAR_SAVE_AS_COPY',false),
'cancel' =>
array('cancel','cancel','Cancel',false)
);
if(isset($standard[$toolname])) {
$icon = $standard[$toolname][0];
$task = $standard[$toolname][1];
$alt = $standard[$toolname][2];
if(HIKASHOP_J16 && substr($alt, 0, 5) != 'JTOOL'
&& substr($alt, 0, 5) != 'HIKA_') {
$alt = 'JTOOLBAR_' . strtoupper($alt);
}
$check = $standard[$toolname][3];
if(!empty($tool['icon'])) {
$icon = $tool['icon'];
}
if(!empty($tool['task'])) {
$task = $tool['task'];
}
if(isset($tool['alt'])) {
$alt = $tool['alt'];
}
if(isset($tool['check'])) {
$check = $tool['check'];
}
$bar->appendButton('Standard', $icon, $alt, $task, $check,
false);
continue;
}
$ret = $this->customTool($bar, strtolower($toolname), $tool);
if(!$ret) {
switch(strtolower($toolname)) {
case '-':
$width = '';
if(!empty($tool['width'])) $width =
(int)$tool['width'];
$bar->appendButton('Separator', 'spacer',
$width);
break;
case '|':
$bar->appendButton('Separator', 'divider');
break;
case 'deletelist':
$tool =
array_merge(array('task'=>'remove','alt'=>'HIKA_DELETE','msg'=>'','confirm'=>true),
$tool);
if($tool['confirm'] &&
empty($tool['msg']))
$tool['msg'] =
JText::_('HIKA_VALIDDELETEITEMS');
if(!empty($tool['msg'])) {
$bar->appendButton('Confirm', $tool['msg'],
'delete', $tool['alt'], $tool['task'],
true);
} else {
$bar->appendButton('Standard', 'delete',
$tool['alt'], $tool['task'], true);
}
break;
case 'custom':
$tool =
array_merge(array('icon'=>'','task'=>'','alt'=>'','check'=>true,'hide'=>false),
$tool);
$bar->appendButton('Standard', $tool['icon'],
$tool['alt'], $tool['task'], $tool['check'],
$tool['hide']);
break;
case 'confirm':
$tool =
array_merge(array('icon'=>'','task'=>'','alt'=>'','check'=>true,'hide'=>false,'msg'=>''),
$tool);
$bar->appendButton( 'Confirm',$tool['msg'],
$tool['icon'], $tool['alt'], $tool['task'],
$tool['check'], $tool['hide']);
break;
case 'preview':
if(!empty($tool['target']) ||
!empty($tool['url'])) {
$url = '';
if(!empty($tool['target'])) $url =
$tool['target'];
if(!empty($tool['url'])) $url = $tool['url'];
$bar->appendButton('Popup', 'preview',
'Preview', $url.'&task=preview');
}
break;
case 'preferences':
$tool =
array_merge(array('component'=>'com_hikashop','path'=>''),
$tool);
$component = urlencode($tool['component']);
$path = urlencode($tool['path']);
if(HIKASHOP_J30){
$uri = (string) JUri::getInstance();
$return = urlencode(base64_encode($uri));
$bar->appendButton('Link', 'options',
'JToolbar_Options',
'index.php?option=com_config&view=component&component='
. $component . '&path=' . $path .
'&return=' . $return);
}else{
$top = 0;
$left = 0;
$height = '550';
$width = '875';
$bar->appendButton('Popup', 'options',
'JToolbar_Options',
'index.php?option=com_config&view=component&component='.$component.'&path='.$path.'&tmpl=component',
$width, $height, $top, $left, '');
}
break;
case 'help':
break;
case 'back':
break;
case 'link':
$tool =
array_merge(array('icon'=>'','url'=>'','alt'=>''),
$tool);
$bar->appendButton('Link', $tool['icon'],
$tool['alt'], $tool['url']);
break;
case 'popup':
$tool =
array_merge(array('icon'=>'','url'=>'','alt'=>'','width'=>640,'height'=>480,'top'=>0,'left'=>0,'onClose'=>'','title'=>'','footer'=>''),
$tool);
if(HIKASHOP_J30) {
if(!empty($tool['id']))
$tool['icon'] = $tool['id'] . '#' .
$tool['icon'];
else
$tool['icon'] = $tool['icon'] . '#' .
$tool['icon'];
}
$bar->appendButton('HikaPopup', $tool['icon'],
$tool['alt'], $tool['url'], $tool['width'],
$tool['height'], $tool['top'], $tool['left'],
$tool['onClose'], $tool['title'],
$tool['footer']);
break;
case 'close':
$bar->appendButton('Standard', 'cancel',
JText::_('HIKA_CLOSE'), 'cancel', false, false);
break;
case 'hikacancel':
$cancel_url = JRequest::getVar('cancel_redirect');
if(!empty($cancel_url) || !empty($tool['url'])) {
if(!empty($cancel_url))
$bar->appendButton('Link', 'cancel',
JText::_('HIKA_CANCEL'), base64_decode($cancel_url) );
else
$bar->appendButton('Link', 'cancel',
JText::_('HIKA_CANCEL'), $tool['url'] );
} else {
$bar->appendButton('Standard', 'cancel',
JText::_('HIKA_CANCEL'), 'cancel', false, false);
}
break;
case 'pophelp':
if(!empty($tool['target']))
$bar->appendButton('Pophelp',
$tool['target']);
break;
case 'dashboard':
if(hikashop_isAllowed($config->get('acl_dashboard_view','all')))
$bar->appendButton('Link', 'hikashop',
JText::_('HIKASHOP_CPANEL'),
hikashop_completeLink('dashboard'));
break;
}
}
}
}
function customTool(&$bar, $toolname, $tool) {
return false;
}
}
translation.php000064400000030252151162557610007626 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopTranslationHelper{
var $languages = array();
var $falang = false;
function hikashopTranslationHelper(){
$this->database = JFactory::getDBO();
$app = JFactory::getApplication();
if(version_compare(JVERSION,'1.6','<')){
jimport('joomla.filesystem.folder');
if(JFolder::exists(HIKASHOP_ROOT.'components/com_joomfish/images/flags/')){
$this->flagPath =
'components/com_joomfish/images/flags/';
}else{
$this->flagPath = 'media/com_joomfish/default/flags/';
}
}else{
$this->flagPath = 'media/mod_languages/images/';
}
if($app->isAdmin()){
$this->flagPath = '../'.$this->flagPath;
} else {
$this->flagPath = rtrim(JURI::base(true),'/') .
'/' . $this->flagPath;
}
}
function isMulti($inConfig=false,$level=true){
static $multi=array();
static $falang = false;
$this->falang =& $falang;
$key = (int)$inConfig.'_'.(int)$level;
if(!isset($multi[$key])){
$multi[$key] = false;
$config=&hikashop_config();
if((hikashop_level(1) || !$level) &&
($config->get('multi_language_edit',1) || $inConfig)){
$query='SHOW TABLES LIKE
'.$this->database->Quote($this->database->getPrefix().substr(hikashop_table('falang_content',false),3));
$this->database->setQuery($query);
$table = $this->database->loadResult();
if(!empty($table)){
$falang = true;
$multi[$key] = true;
}else{
$query='SHOW TABLES LIKE
'.$this->database->Quote($this->database->getPrefix().substr(hikashop_table('jf_content',false),3));
$this->database->setQuery($query);
$table = $this->database->loadResult();
if(!empty($table)) $multi[$key] = true;
}
}
}
return $multi[$key];
}
function getFlag($id=0){
$this->loadLanguages();
if(isset($this->languages[$id])){
return '<span style="background:
url('.$this->flagPath.$this->languages[$id]->shortcode.'.gif)
no-repeat;padding-left:20px">'.$this->languages[$id]->code.'</span>';
}
return $this->languages[$id]->code;
}
function loadLanguages($active = true){
if(empty($this->languages)){
if(version_compare(JVERSION,'1.6','<')){
$query = 'SELECT * FROM
'.hikashop_table('languages',false);
$this->database->setQuery($query);
$languages = $this->database->loadObjectList();
if(!empty($languages)){
foreach($languages as $key => $language){
if(!$active
||(isset($language->active)&&$language->active)||(isset($language->published)&&$language->published)){
if(!isset($language->id)){
$language->id=$language->lang_id;
$language->code=$language->lang_code;
$language->shortcode=$language->image;
$language->active=$language->published;
}
$this->languages[$language->id]=$language;
}
}
}
}else{
$query = 'SELECT lang_id as id, lang_code as code, image as
shortcode, published as active FROM
'.hikashop_table('languages',false).($active?' WHERE
published=1':'');
$this->database->setQuery($query);
$this->languages =
$this->database->loadObjectList('id');
}
}
foreach($this->languages as $key => $language){
if(empty($language->shortcode)){
$this->languages[$key]->shortcode =
substr($language->code,0,2);
}
}
return $this->languages;
}
function loadLanguage($id){
if(version_compare(JVERSION,'1.6','<')){
$this->languages = $this->loadLanguages(false);
if(isset($this->languages[$id])){
return $this->languages[$id];
}
}
$query = 'SELECT lang_id as id, lang_code as code, image as
shortcode, published as active FROM
'.hikashop_table('languages',false).' WHERE
lang_id='.(int)$id;
$this->database->setQuery($query);
return $this->database->loadObject();
}
function getId($code){
$this->loadLanguages();
if(empty($this->languages) || !is_array($this->languages)) return
0;
foreach($this->languages as $lg){
if($lg->code==$code) return $lg->id;
}
return 0;
}
function load($table,$id,&$element,$language_id=0){
$where="";
if(empty($language_id)){
$this->loadLanguages();
$languages =& $this->languages;
}else{
$where=' AND language_id='.(int)$language_id;
$languages=array((int)$language_id=>$this->loadLanguage($language_id));
}
$trans_table = 'jf_content';
if($this->falang){
$trans_table = 'falang_content';
}
$query = 'SELECT * FROM
'.hikashop_table($trans_table,false).' WHERE
reference_id='.(int)$id.' AND
reference_table='.$this->database->Quote($table).$where;
$this->database->setQuery($query);
$data = $this->database->loadObjectList();
$element->translations=array();
if(!empty($data)){
foreach($data as $entry){
$field = $entry->reference_field;
$lg = (int)$entry->language_id;
if(!isset($element->translations[$lg])){
$obj = new stdClass();
$obj->$field = $entry;
$element->translations[$lg] = $obj;
}else{
$element->translations[$lg]->$field=$entry;
}
}
}
if(!empty($languages)){
foreach($languages as $lg){
$lgid = (int)$lg->id;
if(!isset($element->translations[$lgid])){
$element->translations[$lgid] = array();
}
}
}
ksort($element->translations);
}
function getTranslations(&$element){
$transArray =
JRequest::getVar('translation',array(),'','array',JREQUEST_ALLOWRAW);
foreach($transArray as $field => $trans){
foreach($trans as $lg => $value){
if(!empty($value)){
$obj = new stdClass();
$obj->reference_field = $field;
$obj->language_id=(int)$lg;
$obj->value = $value;
if(!isset($element->translations)){
$element->translations = array();
}
if(!isset($element->translations[(int)$lg])){
$element->translations[(int)$lg] = new stdClass();
}
$element->translations[(int)$lg]->$field = $obj;
}
}
}
foreach($_POST as $name => $value){
if(preg_match('#^translation_([a-z_]+)_([0-9]+)$#i',$name,$match)){
$html_element =
JRequest::getVar($name,'','','string',JREQUEST_ALLOWRAW);
if(!empty($html_element)){
$obj = new stdClass();
$type = $match[1];
$obj->reference_field = $type;
$obj->language_id=$match[2];
$obj->value = $html_element;
$element->translations[$match[2]]->$type = $obj;
}
}
}
}
function handleTranslations($table,$id,&$element){
$table = 'hikashop_'.$table;
$transArray =
JRequest::getVar('translation',array(),'','array',JREQUEST_ALLOWRAW);
$arrayToSearch = array();
$conditions = array();
foreach($transArray as $field => $trans){
foreach($trans as $lg => $value){
if(!empty($value)){
$lg = (int)$lg;
$field = hikashop_secureField($field);
$arrayToSearch[]=array('value'=>$value,'language_id'=>$lg,'reference_field'=>$field);
$conditions[] = ' language_id = '.$lg.' AND
reference_field = '.$this->database->Quote($field).' AND
reference_table = '.$this->database->Quote($table).' AND
reference_id='.$id;
}
}
}
foreach($_POST as $name => $value){
if(preg_match('#^translation_([a-z_]+)_([0-9]+)$#i',$name,$match)){
$html_element =
JRequest::getVar($name,'','','string',JREQUEST_ALLOWRAW);
if(!empty($html_element)){
$lg = (int)$match[2];
$field = hikashop_secureField($match[1]);
$value = $html_element;
$arrayToSearch[]=array('value'=>$value,'language_id'=>$lg,'reference_field'=>$field);
$conditions[] = ' language_id = '.$lg.' AND
reference_field = '.$this->database->Quote($field).' AND
reference_table = '.$this->database->Quote($table).' AND
reference_id='.$id;
}
}
}
if(!empty($arrayToSearch)){
$this->isMulti();
$trans_table = 'jf_content';
if($this->falang){
$trans_table = 'falang_content';
}
$query='SELECT * FROM
'.hikashop_table($trans_table,false).' WHERE
('.implode(') OR (',$conditions).');';
$this->database->setQuery($query);
$entries = $this->database->loadObjectList('id');
$user = JFactory::getUser();
$userId = $user->get( 'id' );
$toInsert=array();
foreach($arrayToSearch as $item){
$already=false;
if(!empty($entries)){
foreach($entries as $entry_id => $entry){
if($item['language_id']==$entry->language_id
&&$item['reference_field']==$entry->reference_field){
$query='UPDATE '.hikashop_table($trans_table,false).'
SET
value='.$this->database->Quote($item['value']).',
modified_by='.$userId.', modified=NOW() WHERE
id='.$entry_id.';';
$this->database->setQuery($query);
$this->database->query();
$already=true;
break;
}
}
}
if(!$already){
$toInsert[]=$item;
}
}
if(!empty($toInsert)){
$conf =& hikashop_config();
$default_translation_publish =
(int)$conf->get('default_translation_publish','0');
$rows = array();
foreach($toInsert as $item){
$field = $item['reference_field'];
$rows[]=$id.','.$item['language_id'].','.$this->database->Quote($table).','.$this->database->Quote($item['value']).','.$this->database->Quote($field).','.$this->database->Quote(md5($element->$field)).','.$default_translation_publish.','.$userId.',\'\',NOW()';
}
$query = 'INSERT IGNORE INTO
'.hikashop_table($trans_table,false).'
(reference_id,language_id,reference_table,value,reference_field,original_value,published,modified_by,original_text,modified)
VALUES ('.implode('),(',$rows).');';
$this->database->setQuery($query);
$this->database->query();
}
}
}
function deleteTranslations($table,$ids){
if($this->isMulti()){
if(!is_array($ids))$ids = array($ids);
$trans_table = 'jf_content';
if($this->falang){
$trans_table = 'falang_content';
}
$query = 'DELETE FROM
'.hikashop_table($trans_table,false).' WHERE reference_table =
'.$this->database->Quote('hikashop_'.$table).'
AND reference_id IN ('.implode(',',$ids).')';
$this->database->setQuery($query);
$this->database->query();
}
}
function getStatusTrans(){
$config = JFactory::getConfig();
if(HIKASHOP_J30){
$locale = $config->get('language');
} else {
$locale = $config->getValue('config.language');
}
$user = JFactory::getUser();
$current_locale = $user->getParam('language');
if(empty($current_locale)){
$current_locale=$locale;
}
$database = JFactory::getDBO();
$query = 'SELECT a.category_name,a.category_id FROM
'.hikashop_table('category'). ' AS a WHERE
a.category_type=\'status\'';
$database->setQuery($query);
if(class_exists('JFDatabase')){
$statuses =
$database->loadObjectList('category_id',false);
}else{
$statuses = $database->loadObjectList('category_id');
}
if($this->isMulti(true, false)){
$lgid = $this->getId($current_locale);
$trans_table = 'jf_content';
if($this->falang){
$trans_table = 'falang_content';
}
$query = 'SELECT value,reference_id FROM
'.hikashop_table($trans_table,false).' WHERE
reference_table=\'hikashop_category\' AND
reference_field=\'category_name\' AND published=1 AND
language_id='.$lgid.' AND reference_id
IN('.implode(',',array_keys($statuses)).')';
$database->setQuery($query);
$trans = $database->loadObjectList('reference_id');
foreach($statuses as $k => $stat){
if(isset($trans[$k])){
$statuses[$k]->status = $trans[$k]->value;
}else{
$val = str_replace('
','_',strtoupper($statuses[$k]->category_name));
$new = JText::_($val);
if($val!=$new){
$statuses[$k]->status=$new;
}else{
$statuses[$k]->status=$statuses[$k]->category_name;
}
}
}
}else{
foreach($statuses as $k => $stat){
$val = str_replace('
','_',strtoupper($statuses[$k]->category_name));
$new = JText::_($val);
if($val!=$new){
$statuses[$k]->status=$new;
}else{
$statuses[$k]->status=$statuses[$k]->category_name;
}
}
}
$cleaned_statuses = array();
foreach($statuses as $status){
$cleaned_statuses[$status->category_name]=$status->status;
}
return $cleaned_statuses;
}
}
update.php000064400002453407151162557610006567 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopUpdateHelper{
var $db;
function hikashopUpdateHelper(){
$this->db = JFactory::getDBO();
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$this->update = JRequest::getBool('update');
$this->freshinstall = JRequest::getBool('freshinstall');
}
function addDefaultModules(){
}
function createUploadFolders(){
$file = hikashop_get('class.file');
$path = $file->getPath('file');
if(!JFile::exists($path.'.htaccess')){
$text = 'deny from all';
JFile::write($path.'.htaccess',$text);
}
$path = $file->getPath('image');
}
function installExtensions(){
$path = HIKASHOP_BACK.'extensions';
jimport('joomla.filesystem.folder');
$dirs = JFolder::folders( $path );
if(version_compare(JVERSION,'1.6.0') < ''){
$query = "SELECT CONCAT(`folder`,`element`) FROM #__plugins WHERE
`folder` IN (
'hikashop','hikashoppayment','hikashopshipping'
) OR `element` LIKE '%hikashop%' OR (`folder`='system'
AND `element` IN
('vm_redirect','reds_redirect','mijo_redirect','custom_price','custom_quantity_tax','nossloutsidecheckout'))";
$query .= " UNION SELECT `module` FROM #__modules WHERE `module`
LIKE '%hikashop%'";
$this->db->setQuery($query);
$existingExtensions = $this->db->loadResultArray();
}else{
$this->db->setQuery("SELECT CONCAT(`folder`,`element`) FROM
#__extensions WHERE `folder` IN (
'hikashop','hikashoppayment','hikashopshipping'
) OR `element` LIKE '%hikashop%' OR (`folder`='system'
AND `element` IN
('vm_redirect','reds_redirect','mijo_redirect','custom_price','custom_quantity_tax','nossloutsidecheckout'))");
if(!HIKASHOP_J25){
$existingExtensions = $this->db->loadResultArray();
} else {
$existingExtensions = $this->db->loadColumn();
}
}
if(empty($existingExtensions))
$existingExtensions = array();
$success = array();
$plugins = array();
$modules = array();
$extensioninfo = array(
'mod_hikashop' => array('HikaShop Content
Module')
,'mod_hikashop_cart' => array('HikaShop Cart
Module')
,'mod_hikashop_currency' => array('HikaShop Currency
Switcher Module')
,'mod_hikashop_filter' => array('HikaShop Filter
Module',0,0)
,'mod_hikashop_wishlist' => array('HikaShop Wishlist
Module',0,0)
,'plg_acymailing_hikashop' => array('AcyMailing :
HikaShop integration',0,1,1)
,'plg_content_hikashopsocial' => array('Hikashop
Social Networks Plugin',0,0)
,'plg_editors-xtd_hikashopproduct' => array('Hikashop
product tag insertion plugin',0,1)
,'plg_hikashop_acymailing' => array('HikaShop trigger
for AcyMailing filters',0,1)
,'plg_hikashop_datafeed' => array('Hikashop Products
Cron Update Plugin',0,0)
,'plg_hikashop_google_products' => array('Hikashop
Google Products Plugin',0,1)
,'plg_hikashop_group' => array('HikaShop group
plugin',0,1)
,'plg_hikashop_history' => array('HikaShop order
history plugin',0,1)
,'plg_hikashop_massaction_address' => array('Hikashop
Massaction Address Plugin',0,1)
,'plg_hikashop_massaction_category' => array('Hikashop
Massaction Category Plugin',0,1)
,'plg_hikashop_massaction_order' => array('Hikashop
Massaction Order Plugin',0,1)
,'plg_hikashop_massaction_product' => array('Hikashop
Massaction Product Plugin',0,1)
,'plg_hikashop_massaction_user' => array('Hikashop
Massaction User Plugin',0,1)
,'plg_hikashop_order_auto_cancel' => array('Hikashop
Orders Automatic Cancel Plugin',0,0)
,'plg_hikashop_out_of_stock' => array('HikaShop Out of
stock notification Plugin',0,0)
,'plg_hikashop_rates' => array('HikaShop rates auto
update plugin',0,1)
,'plg_hikashop_shippingmanual_prices' =>
array('HikaShop Shipping manual - Prices per product
plugin',0,1)
,'plg_hikashop_user_account' => array('HikaShop joomla
user account link plugin',0,1)
,'plg_hikashop_userpoints' => array('HikaShop User
Points plugin',0,1)
,'plg_hikashop_validate_free_order' => array('HikaShop
Free orders validation Plugin',0,1)
,'plg_hikashop_waitlist_notify' => array('HikaShop
Product Wait List Notification plugin',0,0)
,'plg_hikashoppayment_alertpay' => array('HikaShop
Payza payment plugin',0,0)
,'plg_hikashoppayment_alipay' => array('HikaShop
AliPay payment plugin',0,0)
,'plg_hikashoppayment_amazon' => array('HikaShop
Amazon payment plugin',0,0)
,'plg_hikashoppayment_alphauserpoints' =>
array('Hikashop AlphaUserPoints Plugin',0,0)
,'plg_hikashoppayment_atos' => array('HikaShop SIPS
Atos payment plugin',0,0)
,'plg_hikashoppayment_authorize' => array('HikaShop
Authorize.net payment plugin',0,0)
,'plg_hikashoppayment_banktransfer' => array('HikaShop
bank transfer payment plugin',0,0)
,'plg_hikashoppayment_be2bill' => array('HikaShop
Be2Bill payment plugin',0,0)
,'plg_hikashoppayment_beanstream' => array('HikaShop
Beanstream payment plugin',0,0)
,'plg_hikashoppayment_bf_rbsbusinessgateway' =>
array('HikaShop WorldPay Business Gateway payment plugin',0,0)
,'plg_hikashoppayment_bf_rbsglobalgateway' =>
array('HikaShop WorldPay Global Gateway payment plugin',0,0)
,'plg_hikashoppayment_bluepaid' => array('HikaShop
Bluepaid payment plugin',0,0)
,'plg_hikashoppayment_borgun' => array('HikaShop
Borgun payment plugin',0,0)
,'plg_hikashoppayment_cardsave' => array('HikaShop
CardSave payment plugin',0,0)
,'plg_hikashoppayment_ceca' => array('HikaShop CECA
payment plugin',0,0)
,'plg_hikashoppayment_check' => array('HikaShop check
payment plugin',0,0)
,'plg_hikashoppayment_cmcic' => array('HikaShop CM-CIC
payment plugin',0,0)
,'plg_hikashoppayment_collectondelivery' =>
array('HikaShop collect on delivery payment plugin',0,0)
,'plg_hikashoppayment_common' => array('HikaShop
common payment API plugin',0,1)
,'plg_hikashoppayment_creditcard' => array('HikaShop
credit card payment plugin',0,0)
,'plg_hikashoppayment_epay' => array('HikaShop ePay
payment plugin',0,0)
,'plg_hikashoppayment_eselect' => array('HikaShop
eSelect/Moneris payment plugin',0,0)
,'plg_hikashoppayment_eway' => array('HikaShop eWAY
payment plugin',0,0)
,'plg_hikashoppayment_ewayrapid' => array('HikaShop
eWAY (Rapid 3.0) payment plugin',0,0)
,'plg_hikashoppayment_firstdata' => array('HikaShop
First Data payment plugin',0,0)
,'plg_hikashoppayment_googlecheckout' =>
array('HikaShop Google Checkout payment plugin',0,0)
,'plg_hikashoppayment_hsbc' => array('HikaShop HSBC
payment plugin',0,0)
,'plg_hikashoppayment_innovativegateway' =>
array('HikaShop Innovative Gateway payment plugin',0,0)
,'plg_hikashoppayment_ipaydna' => array('HikaShop
iPayDNA payment plugin',0,0)
,'plg_hikashoppayment_iveri' => array('HikaShop iVeri
payment plugin',0,0)
,'plg_hikashoppayment_liqpay' => array('HikaShop
LiqPay payment plugin',0,0)
,'plg_hikashoppayment_migsvpc' => array('HikaShop MIGS
VPC payment plugin',0,0)
,'plg_hikashoppayment_moneybookers' => array('HikaShop
Moneybookers payment plugin',0,0)
,'plg_hikashoppayment_netgiro' => array('HikaShop
NetGiro payment plugin',0,0)
,'plg_hikashoppayment_nets' => array('HikaShop NETS
payment plugin',0,0)
,'plg_hikashoppayment_ogone' => array('HikaShop Ogone
payment plugin',0,0)
,'plg_hikashoppayment_okpay' => array('HikaShop OKPay
payment plugin',0,0)
,'plg_hikashoppayment_paybox' => array('HikaShop
PayBox payment plugin',0,0)
,'plg_hikashoppayment_payjunction' => array('HikaShop
PayJunction payment plugin',0,0)
,'plg_hikashoppayment_paymentexpress' =>
array('HikaShop Payment Express payment plugin',0,0)
,'plg_hikashoppayment_paypal' => array('HikaShop
Paypal payment plugin',0,0)
,'plg_hikashoppayment_paypalpro' => array('HikaShop
PayPal Pro payment plugin',0,0)
,'plg_hikashoppayment_postfinance' => array('HikaShop
Post Finance payment plugin',0,0)
,'plg_hikashoppayment_privat24' => array('HikaShop
Privat24 payment plugin',0,0)
,'plg_hikashoppayment_pxpay' => array('HikaShop PxPay
payment plugin',0,0)
,'plg_hikashoppayment_sagepay' => array('HikaShop Sage
Pay payment plugin',0,0)
,'plg_hikashoppayment_servired' => array('HikaShop
Servired payment plugin',0,0)
,'plg_hikashoppayment_sofort' => array('HikaShop
Sofort payment plugin',0,0)
,'plg_hikashoppayment_userpoints' => array('HikaShop
User Points payment plugin',0,0)
,'plg_hikashoppayment_virtualmerchant' =>
array('HikaShop VirtualMerchant payment plugin',0,0)
,'plg_hikashoppayment_webmoney' => array('HikaShop
Webmoney payment plugin',0,0)
,'plg_hikashoppayment_westernunion' => array('HikaShop
Western Union payment plugin',0,0)
,'plg_hikashopshipping_aupost' => array('HikaShop
Australia Post shipping plugin',0,0)
,'plg_hikashopshipping_canadapost' => array('HikaShop
Canada Post shipping plugin',0,0)
,'plg_hikashopshipping_fedex' => array('HikaShop Fedex
shipping plugin',0,0)
,'plg_hikashopshipping_manual' => array('HikaShop
manual shipping plugin',0,0)
,'plg_hikashopshipping_ups' => array('HikaShop UPS
shipping plugin',0,0)
,'plg_hikashopshipping_usps' => array('HikaShop USPS
shipping plugin',0,0)
,'plg_quickicons_hikashop' => array('HikaShop
Quickicon plugin',0,1)
,'plg_search_hikashop_categories' => array('HikaShop
categories search plugin',0,1)
,'plg_search_hikashop_products' => array('HikaShop
products search plugin',0,1)
,'plg_system_custom_price' => array('HikaShop Donation
plugin',0,0)
,'plg_system_custom_quantity_tax' => array('HikaShop
tax calculations override plugin',0,0)
,'plg_system_hikashopaffiliate' => array('HikaShop
affiliate plugin',0,1)
,'plg_system_hikashopanalytics' => array('HikaShop
Google Analytics plugin',0,0)
,'plg_system_hikashopgeolocation' => array('HikaShop
geolocation plugin',0,1)
,'plg_system_hikashopmassaction' => array('HikaShop
massaction plugin',0,1)
,'plg_system_hikashopproductinsert' => array('HikaShop
product tag translation plugin',0,1)
,'plg_system_hikashopproducttag' => array('HikaShop
Microdata on Product Page plugin',0,0)
,'plg_system_hikashopregistrationredirect' =>
array('Redirect Joomla registration to HikaShop Plugin',0,0)
,'plg_system_hikashopuser' => array('HikaShop user
synchronization plugin',0,1)
,'plg_system_nossloutsidecheckout' => array('HikaShop
no SSL outside checkout plugin',0,0)
,'plg_system_vm_redirect' => array('VirtueMart
Fallback Redirect Plugin',0,0)
,'plg_system_mijo_redirect' => array('Mijoshop
Fallback Redirect Plugin',0,0)
,'plg_system_reds_redirect' => array('Redshop Fallback
Redirect Plugin',0,0)
);
$listTables = $this->db->getTableList();
$this->errors=array();
foreach($dirs as $oneDir){
$arguments = explode('_',$oneDir);
if(!isset($extensioninfo[$oneDir])) continue;
$report = true;
if(!empty($extensioninfo[$oneDir][3])){
$report = false;
}
$prefix = array_shift($arguments);
if($prefix == 'plg'){
$newPlugin = new stdClass();
$newPlugin->name = $oneDir;
if(isset($extensioninfo[$oneDir][0])) $newPlugin->name =
$extensioninfo[$oneDir][0];
$newPlugin->type = 'plugin';
$newPlugin->folder = array_shift($arguments);
$newPlugin->element = implode('_',$arguments);
$newPlugin->enabled = 1;
if(isset($extensioninfo[$oneDir][2])){
if(is_numeric($extensioninfo[$oneDir][2])) $newPlugin->enabled =
$extensioninfo[$oneDir][2];
}
$newPlugin->params = '{}';
$newPlugin->ordering = 0;
if(isset($extensioninfo[$oneDir][1])) $newPlugin->ordering =
$extensioninfo[$oneDir][1];
if(!hikashop_createDir(HIKASHOP_ROOT.'plugins'.DS.$newPlugin->folder,$report))
continue;
if(version_compare(JVERSION,'1.6.0','<')){
$destinationFolder =
HIKASHOP_ROOT.'plugins'.DS.$newPlugin->folder;
}else{
$destinationFolder =
HIKASHOP_ROOT.'plugins'.DS.$newPlugin->folder.DS.$newPlugin->element;
if(!hikashop_createDir($destinationFolder)) continue;
}
if(!$this->copyFolder($path.DS.$oneDir,$destinationFolder))
continue;
if(in_array($newPlugin->folder.$newPlugin->element,$existingExtensions))
continue;
$plugins[] = $newPlugin;
}elseif($prefix == 'mod'){
$newModule = new stdClass();
$newModule->name = $oneDir;
if(isset($extensioninfo[$oneDir][0])) $newModule->name =
$extensioninfo[$oneDir][0];
$newModule->type = 'module';
$newModule->folder = '';
$newModule->element = $oneDir;
$newModule->enabled = 1;
$newModule->params = '{}';
$newModule->ordering = 0;
if(isset($extensioninfo[$oneDir][1])) $newModule->ordering =
$extensioninfo[$oneDir][1];
$destinationFolder = HIKASHOP_ROOT.'modules'.DS.$oneDir;
if(!hikashop_createDir($destinationFolder)) continue;
if(!$this->copyFolder($path.DS.$oneDir,$destinationFolder))
continue;
if($newModule->element=='mod_hikashop_filter'){
$this->db->setQuery('SELECT id FROM
'.hikashop_table('menu',false).' WHERE
alias=\'hikashop-menu-for-products-listing\'');
$menu_id = $this->db->loadResult();
if($menu_id){
$fileContent =
JFile::read($destinationFolder.DS.'mod_hikashop_filter.xml');
if(!empty($fileContent)){
$fileContent = str_replace('name="itemid"
type="text"
default=""','name="itemid"
type="text"
default="'.$menu_id.'"',$fileContent);
JFile::write($destinationFolder.DS.'mod_hikashop_filter.xml',$fileContent);
}
}
}
if(in_array($newModule->element,$existingExtensions)) continue;
$modules[] = $newModule;
}else{
hikashop_display('Could not handle :
'.$oneDir,'error');
}
}
if(!empty($this->errors))
hikashop_display($this->errors,'error');
if(version_compare(JVERSION,'1.6.0','<')){
$extensions = $plugins;
}else{
$extensions = array_merge($plugins,$modules);
}
$success = array();
if(!empty($extensions)){
if(version_compare(JVERSION,'1.6.0','<')){
$queryExtensions = 'INSERT INTO `#__plugins`
(`name`,`element`,`folder`,`published`,`ordering`) VALUES ';
}else{
$queryExtensions = 'INSERT INTO `#__extensions`
(`name`,`element`,`folder`,`enabled`,`ordering`,`type`,`access`) VALUES
';
}
foreach($extensions as $oneExt){
$queryExtensions .=
'('.$this->db->Quote($oneExt->name).','.$this->db->Quote($oneExt->element).','.$this->db->Quote($oneExt->folder).','.$oneExt->enabled.','.$oneExt->ordering;
if(version_compare(JVERSION,'1.6.0','>='))
$queryExtensions .=
','.$this->db->Quote($oneExt->type).',1';
$queryExtensions .= '),';
if($oneExt->type!='module'){
$success[] =
JText::sprintf('PLUG_INSTALLED',$oneExt->name);
}
}
$queryExtensions = trim($queryExtensions,',');
$this->db->setQuery($queryExtensions);
$this->db->query();
}
if(!empty($modules)){
foreach($modules as $oneModule){
if(version_compare(JVERSION,'1.6.0','<')){
$queryModule = 'INSERT INTO `#__modules`
(`title`,`position`,`published`,`module`) VALUES ';
$queryModule .=
'('.$this->db->Quote($oneModule->name).",'left',0,".$this->db->Quote($oneModule->element).")";
}else{
$queryModule = 'INSERT INTO `#__modules`
(`title`,`position`,`published`,`module`,`access`,`language`) VALUES
';
$queryModule .=
'('.$this->db->Quote($oneModule->name).",'position-7',0,".$this->db->Quote($oneModule->element).",1,'*')";
}
$this->db->setQuery($queryModule);
$this->db->query();
$moduleId = $this->db->insertid();
$this->db->setQuery('INSERT IGNORE INTO `#__modules_menu`
(`moduleid`,`menuid`) VALUES ('.$moduleId.',0)');
$this->db->query();
$success[] =
JText::sprintf('MODULE_INSTALLED',$oneModule->name);
}
}
if(!empty($success)) hikashop_display($success,'success');
}
function copyFolder($from,$to){
$return = true;
$allFiles = JFolder::files($from);
foreach($allFiles as $oneFile){
if(file_exists($to.DS.'index.html') && $oneFile ==
'index.html') continue;
if(JFile::copy($from.DS.$oneFile,$to.DS.$oneFile) !== true){
$this->errors[] = 'Could not copy the file from
'.$from.DS.$oneFile.' to '.$to.DS.$oneFile;
$return = false;
}
if(version_compare(JVERSION,'1.6.0','<')
&& substr($oneFile,-4) == '.xml') {
$data = file_get_contents($to.DS.$oneFile);
if(strpos($data, '<extension ') !== false) {
$data = str_replace(array('<extension
','</extension>','version="2.5"'),
array('<install
','</install>','version="1.5"'),
$data);
JFile::write($to.DS.$oneFile, $data);
}
}
}
$allFolders = JFolder::folders($from);
if(!empty($allFolders)){
foreach($allFolders as $oneFolder){
if(!hikashop_createDir($to.DS.$oneFolder)) continue;
if(!$this->copyFolder($from.DS.$oneFolder,$to.DS.$oneFolder))
$return = false;
}
}
return $return;
}
function installMenu($code = ''){
if(empty($code)){
$lang = JFactory::getLanguage();
$code = $lang->getTag();
}
$path =
JLanguage::getLanguagePath(JPATH_ROOT).DS.$code.DS.$code.'.com_hikashop.ini';
if(!file_exists($path)) return;
$content = file_get_contents($path);
if(empty($content)) return;
$menuFileContent =
'COM_HIKASHOP="HikaShop"'."\r\n".'HIKASHOP="HikaShop"'."\r\n";
$menuStrings =
array('PRODUCTS','CATEGORIES','USERS','ORDERS','CONFIGURATION','DISCOUNTS','HELP','UPDATE_ABOUT');
foreach($menuStrings as $oneString){
preg_match('#(\n|\r)(HIKA_)?'.$oneString.'="(.*)"#i',$content,$matches);
if(empty($matches[3])) continue;
if(version_compare(JVERSION,'1.6.0','<')){
$menuFileContent .=
'COM_HIKASHOP.'.$oneString.'="'.$matches[3].'"'."\r\n";
}else{
$menuFileContent .=
$oneString.'="'.$matches[3].'"'."\r\n";
}
}
preg_match_all('#(\n|\r)(COM_HIKASHOP_.*)="(.*)"#iU',$content,$matches);
if(!empty($matches)){
$menuFileContent .= implode('',$matches[0]);
}
$menuFileContent.="\r\n".'COM_HIKASHOP_CONFIGURATION="HikaShop"';
if(version_compare(JVERSION,'1.6.0','<')){
$menuPath =
HIKASHOP_ROOT.'administrator'.DS.'language'.DS.$code.DS.$code.'.com_hikashop.menu.ini';
if(!JFile::write($menuPath, $menuFileContent)){
hikashop_display(JText::sprintf('FAIL_SAVE',$menuPath),'error');
}
$menuPath =
HIKASHOP_ROOT.'administrator'.DS.'language'.DS.$code.DS.$code.'.com_hikashop.ini';
}else{
$menuPath =
HIKASHOP_ROOT.'administrator'.DS.'language'.DS.$code.DS.$code.'.com_hikashop.sys.ini';
}
if(!JFile::write($menuPath, $menuFileContent)){
hikashop_display(JText::sprintf('FAIL_SAVE',$menuPath),'error');
}
}
function _installOne($folder){
if(empty($folder)) return false;
unset($GLOBALS['_JREQUEST']['installtype']);
unset($GLOBALS['_JREQUEST']['install_directory']);
JRequest::setVar('installtype','folder');
JRequest::setVar('install_directory',$folder);
$_REQUEST['installtype']='folder';
$_REQUEST['install_directory']=$folder;
$controller = new JController(array('base_path'=>
HIKASHOP_ROOT.'administrator'.DS.'components'.DS.'com_installer','name'=>'Installer','default_task'
=> 'installform'));
$model = $controller->getModel('Install');
return $model->install();
}
function getUrl(){
$urls = parse_url(HIKASHOP_LIVE);
$lurl =
preg_replace('#^www2?\.#Ui','',$urls['host'],1);
if(!empty($urls['path'])) $lurl .= $urls['path'];
return strtolower(rtrim($lurl,'/'));
}
function addJoomfishElements($force=true){
$dstFolder =
rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_joomfish'.DS.'contentelements'.DS;
if(JFolder::exists($dstFolder)){
$srcFolder = HIKASHOP_BACK.'translations'.DS;
$files = JFolder::files($srcFolder);
if(!empty($files)){
foreach($files as $file){
if($force || !file_exists($dstFolder.$file))
JFile::copy($srcFolder.$file,$dstFolder.$file);
}
}
}
$dstFolder =
rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_falang'.DS.'contentelements'.DS;
if(JFolder::exists($dstFolder)){
$srcFolder = HIKASHOP_BACK.'falang'.DS;
$files = JFolder::files($srcFolder);
if(!empty($files)){
foreach($files as $file){
if($force || !file_exists($dstFolder.$file))
JFile::copy($srcFolder.$file,$dstFolder.$file);
}
}
}
return true;
}
function addUpdateSite(){
if(version_compare(JVERSION,'1.6.0','<')) return
false;
$config = hikashop_config();
$newconfig = new stdClass();
$newconfig->website = HIKASHOP_LIVE;
$config->save($newconfig);
$query="SELECT update_site_id FROM #__update_sites WHERE location
LIKE '%hikashop%' AND type LIKE 'extension'";
$this->db->setQuery($query);
$update_site_id = $this->db->loadResult();
$object = new stdClass();
$object->name='Hikashop';
$object->type='extension';
if(hikashop_level(1)){
$object->location='http://www.hikashop.com/component/updateme/updatexml/component-hikashop/version-'.$config->get('version').'/level-'.$config->get('level').'/li-'.urlencode(base64_encode(HIKASHOP_LIVE)).'/file-extension.xml';
}else{
$object->location='http://www.hikashop.com/component/updateme/updatexml/component-hikashop/level-'.$config->get('level').'/file-extension.xml';
}
$object->enabled=1;
if(empty($update_site_id)){
$this->db->insertObject("#__update_sites",$object);
$update_site_id = $this->db->insertid();
}else{
$object->update_site_id = $update_site_id;
$this->db->updateObject("#__update_sites",$object,'update_site_id');
}
$query="SELECT extension_id FROM #__extensions WHERE `name` LIKE
'hikashop' AND type LIKE 'component'";
$this->db->setQuery($query);
$extension_id = $this->db->loadResult();
if(empty($update_site_id) OR empty($extension_id)) return false;
$query='INSERT IGNORE INTO #__update_sites_extensions
(update_site_id, extension_id) values
('.$update_site_id.','.$extension_id.')';
$this->db->setQuery($query);
$this->db->query();
return true;
}
function addDefaultData(){
if(version_compare(JVERSION,'1.6','<')){
$query = 'DELETE FROM `#__components` WHERE `admin_menu_link` LIKE
\'%option=com\_hikashop%\' AND `parent`!=0';
$this->db->setQuery($query);
$this->db->query();
$query = 'SELECT id FROM `#__components` WHERE
`option`=\'com_hikashop\' AND `parent`=0';
$this->db->setQuery($query);
$parent = (int)$this->db->loadResult();
$query = "INSERT IGNORE INTO `#__components`
(`admin_menu_link`,`admin_menu_img`,`admin_menu_alt`,`name`,`ordering`,`parent`)
VALUES
('option=com_hikashop&ctrl=product','../includes/js/ThemeOffice/document.png','Products','Products',1,".$parent."),
('option=com_hikashop&ctrl=category&filter_id=product','../includes/js/ThemeOffice/sections.png','Categories','Categories',2,".$parent."),
('option=com_hikashop&ctrl=user&filter_partner=0','../includes/js/ThemeOffice/user.png','Users','Users',3,".$parent."),
('option=com_hikashop&ctrl=order&order_type=sale&filter_partner=0','../includes/js/ThemeOffice/content.png','Orders','Orders',4,".$parent."),
('option=com_hikashop&ctrl=config','../includes/js/ThemeOffice/config.png','Configuration','Configuration',5,".$parent."),
('option=com_hikashop&ctrl=discount','../includes/js/ThemeOffice/credits.png','Discounts','Discounts',6,".$parent."),
('option=com_hikashop&ctrl=documentation','../includes/js/ThemeOffice/help.png','Help','Help',7,".$parent."),
('option=com_hikashop&ctrl=update','../includes/js/ThemeOffice/install.png','Update
/ About','Update / About',8,".$parent.");";
$this->db->setQuery($query);
$this->db->query();
$query="SELECT a.id FROM
".hikashop_table('components',false).' AS a WHERE
a.option=\''.HIKASHOP_COMPONENT.'\'';
$this->db->setQuery($query);
$componentid = $this->db->loadResult();
$query='UPDATE '.hikashop_table('menu',false).'
SET componentid = '.$componentid.' WHERE menutype =
'.$this->db->quote('hikashop_default');
$this->db->setQuery($query);
$this->db->query();
}else{
$query = 'SELECT * FROM `#__menu` WHERE `title` IN
(\'com_hikashop\',\'hikashop\',\'HikaShop\')
AND `parent_id`=1 AND menutype IN
(\'main\',\'mainmenu\',\'menu\')';
$this->db->setQuery($query);
$parentData = $this->db->loadObject();
$parent = $parentData->id;
$query = 'SELECT id FROM `#__menu` WHERE
`parent_id`='.(int)$parent;
$this->db->setQuery($query);
if(!HIKASHOP_J25){
$submenu = $this->db->loadResultArray();
} else {
$submenu = $this->db->loadColumn();
}
$old=count($submenu);
$query = 'DELETE FROM `#__menu` WHERE
`parent_id`='.(int)$parent;
$this->db->setQuery($query);
$this->db->query();
$query = 'UPDATE `#__menu` SET `rgt`=`rgt`-'.($old*2).'
WHERE `rgt`>='.$parentData->rgt;
$this->db->setQuery($query);
$this->db->query();
$query = 'UPDATE `#__menu` SET `rgt`=`rgt`+16 WHERE
`rgt`>='.$parentData->rgt;
$this->db->setQuery($query);
$this->db->query();
$query = 'UPDATE `#__menu` SET `lft`=`lft`+16 WHERE
`lft`>'.$parentData->lft;
$this->db->setQuery($query);
$this->db->query();
$left = $parentData->lft;
$cid = $parentData->component_id;
$query = "INSERT IGNORE INTO `#__menu`
(`type`,`link`,`menutype`,`img`,`alias`,`title`,`client_id`,`parent_id`,`level`,`language`,`lft`,`rgt`,`component_id`)
VALUES
('component','index.php?option=com_hikashop&ctrl=product','menu','./templates/bluestork/images/menu/icon-16-article.png','Products','Products',1,".(int)$parent.",2,'*',".($left+1).",".($left+2).",".$cid."),
('component','index.php?option=com_hikashop&ctrl=category&filter_id=product','menu','./templates/bluestork/images/menu/icon-16-category.png','Categories','Categories',1,".(int)$parent.",2,'*',".($left+3).",".($left+4).",".$cid."),
('component','index.php?option=com_hikashop&ctrl=user&filter_partner=0','menu','./templates/bluestork/images/menu/icon-16-user.png','Users','Users',1,".(int)$parent.",2,'*',".($left+5).",".($left+6).",".$cid."),
('component','index.php?option=com_hikashop&ctrl=order&order_type=sale&filter_partner=0','menu','./templates/bluestork/images/menu/icon-16-content.png','Orders','Orders',1,".(int)$parent.",2,'*',".($left+7).",".($left+8).",".$cid."),
('component','index.php?option=com_hikashop&ctrl=config','menu','./templates/bluestork/images/menu/icon-16-config.png','Configuration','Configuration',1,".(int)$parent.",2,'*',".($left+9).",".($left+10).",".$cid."),
('component','index.php?option=com_hikashop&ctrl=discount','menu','./templates/bluestork/images/menu/icon-16-default.png','Discounts','Discounts',1,".(int)$parent.",2,'*',".($left+11).",".($left+12).",".$cid."),
('component','index.php?option=com_hikashop&ctrl=documentation','menu','./templates/bluestork/images/menu/icon-16-help.png','Help','Help',1,".(int)$parent.",2,'*',".($left+13).",".($left+14).",".$cid."),
('component','index.php?option=com_hikashop&ctrl=update','menu','./templates/bluestork/images/menu/icon-16-help-jrd.png','Update
/ About','Update /
About',1,".(int)$parent.",2,'*',".($left+15).",".($left+16).",".$cid.");
";
$this->db->setQuery($query);
$this->db->query();
$query='UPDATE '.hikashop_table('menu',false).'
SET component_id = '.$cid.' WHERE menutype =
'.$this->db->quote('hikashop_default');
$this->db->setQuery($query);
$this->db->query();
}
$query = 'INSERT IGNORE INTO `#__hikashop_user`
(`user_email`,`user_cms_id`,`user_created`) SELECT `email`,
`id`,'.time().' FROM `#__users`';
$this->db->setQuery($query);
$this->db->query();
$query="INSERT IGNORE INTO `#__hikashop_category` (`category_id`,
`category_parent_id`, `category_type`, `category_name`,
`category_description`, `category_published`, `category_ordering`,
`category_left`, `category_right`, `category_depth`, `category_namekey`)
VALUES
(1, 0, 'root', 'ROOT', '', 0, 0, 1, 22, 0,
'root'),
(2, 1, 'product', 'product category', '', 1,
1, 2, 3, 1, 'product'),
(3, 1, 'tax', 'taxation category', '', 1, 2,
4, 7, 1, 'tax'),
(4, 1, 'status', 'order status', '', 1, 3, 8,
19, 1, 'status'),
(5, 4, 'status', 'created', 'When a customer
finishes a checkout, an order is created with the status created', 1,
1, 9, 10, 2, 'created'),
(6, 4, 'status', 'confirmed', 'When the payment is
confirmed or that the payment is done at delivery the order becomes
confirmed', 1, 2, 11, 12, 2, 'confirmed'),
(7, 4, 'status', 'cancelled', 'When an order is
cancelled before receiving a payment', 1, 3, 13, 14, 2,
'cancelled'),
(8, 4, 'status', 'refunded', 'When an order is
cancelled after receiving a payment', 1, 4, 15, 16, 2,
'refunded'),
(9, 4, 'status', 'shipped', 'When an order has
been shipped', 1, 5, 17, 18, 2, 'shipped'),
(10, 1, 'manufacturer', 'manufacturer', '',
1, 5, 20, 21, 1, 'manufacturer'),
(11, 3, 'tax', 'Default tax category', '', 1,
1, 5, 6, 2, 'default_tax');";
$this->db->setQuery($query);
$this->db->query();
$query=<<<EOD
INSERT IGNORE INTO `#__hikashop_field` (`field_table`, `field_realname`,
`field_namekey`, `field_type`, `field_value`, `field_published`,
`field_ordering`, `field_options`, `field_core`, `field_required`,
`field_backend`, `field_frontcomp`, `field_default`,
`field_backend_listing`) VALUES
('address', 'Title', 'address_title',
'singledropdown',
'Mr::HIKA_TITLE_MR\nMrs::HIKA_TITLE_MRS\nMiss::HIKA_TITLE_MISS\nMs::HIKA_TITLE_MS\nDr::HIKA_TITLE_DR',
1, 1,
'a:5:{s:12:"errormessage";s:0:"";s:4:"cols";s:0:"";s:4:"rows";s:0:"";s:4:"size";s:0:"";s:6:"format";s:0:"";}',
1, 1, 1, 1, '', 0),
('address', 'Firstname', 'address_firstname',
'text', '', 1, 2,
'a:5:{s:12:"errormessage";s:0:"";s:4:"cols";s:0:"";s:4:"rows";s:0:"";s:4:"size";s:0:"";s:6:"format";s:0:"";}',
1, 1, 1, 1, '', 0),
('address', 'Middle name',
'address_middle_name', 'text', '', 0, 3,
'a:5:{s:12:"errormessage";s:0:"";s:4:"cols";s:0:"";s:4:"rows";s:0:"";s:4:"size";s:0:"";s:6:"format";s:0:"";}',
1, 0, 1, 1, '', 0),
('address', 'Lastname', 'address_lastname',
'text', '', 1, 4,
'a:5:{s:12:"errormessage";s:0:"";s:4:"cols";s:0:"";s:4:"rows";s:0:"";s:4:"size";s:0:"";s:6:"format";s:0:"";}',
1, 1, 1, 1, '', 0),
('address', 'Company', 'address_company',
'text', '', 0, 5,
'a:5:{s:12:"errormessage";s:0:"";s:4:"cols";s:0:"";s:4:"rows";s:0:"";s:4:"size";s:0:"";s:6:"format";s:0:"";}',
1, 0, 1, 1, '', 0),
('address', 'Street', 'address_street',
'text', '', 1, 6,
'a:5:{s:12:"errormessage";s:0:"";s:4:"cols";s:0:"";s:4:"rows";s:0:"";s:4:"size";s:0:"";s:6:"format";s:0:"";}',
1, 1, 1, 1, '', 0),
('address', 'Complement', 'address_street2',
'text', '', 0, 7,
'a:5:{s:12:"errormessage";s:0:"";s:4:"cols";s:0:"";s:4:"rows";s:0:"";s:4:"size";s:0:"";s:6:"format";s:0:"";}',
1, 0, 1, 1, '', 0),
('address', 'Post code', 'address_post_code',
'text', '', 1, 8,
'a:5:{s:12:"errormessage";s:0:"";s:4:"cols";s:0:"";s:4:"rows";s:0:"";s:4:"size";s:0:"";s:6:"format";s:0:"";}',
1, 0, 1, 1, '', 0),
('address', 'City', 'address_city',
'text', '', 1, 9,
'a:5:{s:12:"errormessage";s:0:"";s:4:"cols";s:0:"";s:4:"rows";s:0:"";s:4:"size";s:0:"";s:6:"format";s:0:"";}',
1, 1, 1, 1, '', 0),
('address', 'Telephone', 'address_telephone',
'text', '', 1, 10,
'a:5:{s:12:"errormessage";s:0:"";s:4:"cols";s:0:"";s:4:"rows";s:0:"";s:4:"size";s:0:"";s:6:"format";s:0:"";}',
1, 1, 1, 1, '', 0),
('address', 'Telephone',
'address_telephone2', 'text', '', 0, 11,
'a:5:{s:12:"errormessage";s:0:"";s:4:"cols";s:0:"";s:4:"rows";s:0:"";s:4:"size";s:0:"";s:6:"format";s:0:"";}',
1, 0, 1, 1, '', 0),
('address', 'Fax', 'address_fax',
'text', '', 0, 12,
'a:5:{s:12:"errormessage";s:0:"";s:4:"cols";s:0:"";s:4:"rows";s:0:"";s:4:"size";s:0:"";s:6:"format";s:0:"";}',
1, 0, 1, 1, '', 0),
('address', 'State', 'address_state',
'zone', '', 1, 13,
'a:6:{s:12:"errormessage";s:0:"";s:4:"cols";s:0:"";s:4:"rows";s:0:"";s:9:"zone_type";s:5:"state";s:4:"size";s:0:"";s:6:"format";s:0:"";}',
1, 1, 1, 1, 'state_Rh__ne_1375', 0),
('address', 'Country', 'address_country',
'zone', '', 1, 14,
'a:6:{s:12:"errormessage";s:0:"";s:4:"cols";s:0:"";s:4:"rows";s:0:"";s:9:"zone_type";s:7:"country";s:4:"size";s:0:"";s:6:"format";s:0:"";}',
1, 1, 1, 1, 'country_France_73', 0),
('address', 'VAT number', 'address_vat',
'text', '', 0, 15,
'a:6:{s:12:"errormessage";s:0:"";s:4:"cols";s:0:"";s:4:"rows";s:0:"";s:9:"zone_type";s:7:"country";s:4:"size";s:0:"";s:6:"format";s:0:"";}',
1, 0, 1, 1, '', 0);
EOD;
$this->db->setQuery($query);
$this->db->query();
$query=<<<EOD
INSERT IGNORE INTO `#__hikashop_widget` (`widget_id`, `widget_name`,
`widget_params`, `widget_published`, `widget_ordering`, `widget_access`)
VALUES
(1, 'Last seven orders',
'O:8:"stdClass":27:{s:7:"display";s:7:"listing";s:9:"date_type";s:7:"created";s:10:"date_group";s:5:"%j
%Y";s:10:"periodType";s:14:"proposedPeriod";s:14:"proposedPeriod";s:9:"thisMonth";s:6:"period";s:1:"0";s:7:"content";s:6:"orders";s:7:"filters";s:45:"a:1:{s:14:"a.order_status";a:1:{i:0;s:0:"";}}";s:15:"category_childs";s:1:"0";s:9:"customers";s:14:"best_customers";s:15:"customers_order";s:5:"sales";s:8:"partners";s:14:"last_customers";s:14:"partners_order";s:5:"sales";s:12:"compare_with";s:7:"periods";s:14:"period_compare";s:4:"none";s:5:"limit";s:1:"7";s:6:"region";s:5:"world";s:6:"format";s:5:"UTF-8";s:10:"map_source";s:8:"shipping";s:12:"product_data";s:5:"sales";s:16:"product_order_by";s:4:"best";s:15:"orders_order_by";s:4:"last";s:8:"compares";N;s:10:"categories";s:3:"all";s:8:"products";s:6:"a:0:{}";s:7:"coupons";s:6:"a:0:{}";s:6:"status";s:0:"";}',
1, 1, 'all'),
(2, 'Sales this month',
'O:8:"stdClass":27:{s:7:"display";s:5:"graph";s:9:"date_type";s:7:"created";s:10:"date_group";s:5:"%j
%Y";s:10:"periodType";s:14:"proposedPeriod";s:14:"proposedPeriod";s:9:"thisMonth";s:6:"period";s:1:"0";s:7:"content";s:5:"sales";s:7:"filters";s:45:"a:1:{s:14:"a.order_status";a:1:{i:0;s:0:"";}}";s:15:"category_childs";s:1:"0";s:9:"customers";s:14:"last_customers";s:15:"customers_order";s:5:"sales";s:8:"partners";s:14:"last_customers";s:14:"partners_order";s:5:"sales";s:12:"compare_with";s:7:"periods";s:14:"period_compare";s:4:"none";s:5:"limit";s:1:"7";s:6:"region";s:5:"world";s:6:"format";s:5:"UTF-8";s:10:"map_source";s:8:"shipping";s:12:"product_data";s:5:"sales";s:16:"product_order_by";s:4:"best";s:15:"orders_order_by";s:4:"last";s:8:"compares";N;s:10:"categories";s:3:"all";s:8:"products";s:6:"a:0:{}";s:7:"coupons";s:6:"a:0:{}";s:6:"status";s:0:"";}',
1, 2, 'all'),
(3, 'Main Statistics',
'O:8:"stdClass":6:{s:7:"display";s:5:"table";s:10:"categories";s:3:"all";s:7:"coupons";s:6:"a:0:{}";s:5:"table";a:5:{i:0;O:8:"stdClass":2:{s:8:"row_name";s:16:"Sales
this
month";s:13:"widget_params";O:8:"stdClass":15:{s:10:"periodType";s:14:"proposedPeriod";s:14:"proposedPeriod";s:9:"thisMonth";s:5:"start";s:0:"";s:3:"end";s:0:"";s:6:"period";s:1:"0";s:7:"content";s:5:"sales";s:7:"filters";s:45:"a:1:{s:14:"a.order_status";a:1:{i:0;s:0:"";}}";s:7:"payment";s:9:"_multiple";s:15:"category_childs";s:1:"0";s:9:"customers";s:13:"last_customer";s:8:"apply_on";s:7:"product";s:7:"display";s:5:"table";s:10:"categories";s:3:"all";s:8:"products";s:6:"a:0:{}";s:7:"coupons";s:6:"a:0:{}";}}i:1;O:8:"stdClass":2:{s:8:"row_name";s:22:"Best
product this
year";s:13:"widget_params";O:8:"stdClass":14:{s:10:"periodType";s:14:"proposedPeriod";s:14:"proposedPeriod";s:8:"thisYear";s:5:"start";s:0:"";s:3:"end";s:0:"";s:6:"period";s:1:"0";s:7:"content";s:4:"best";s:7:"filters";s:45:"a:1:{s:14:"a.order_status";a:1:{i:0;s:0:"";}}";s:15:"category_childs";s:1:"0";s:9:"customers";s:13:"last_customer";s:8:"apply_on";s:7:"product";s:7:"display";s:5:"table";s:10:"categories";s:3:"all";s:8:"products";s:6:"a:0:{}";s:7:"coupons";s:6:"a:0:{}";}}i:2;O:8:"stdClass":2:{s:8:"row_name";s:22:"Best
customer all
time";s:13:"widget_params";O:8:"stdClass":15:{s:10:"periodType";s:14:"proposedPeriod";s:14:"proposedPeriod";s:3:"all";s:5:"start";s:1:"0";s:3:"end";s:1:"0";s:6:"period";s:1:"0";s:7:"content";s:9:"customers";s:7:"filters";s:45:"a:1:{s:14:"a.order_status";a:1:{i:0;s:0:"";}}";s:15:"category_childs";s:1:"0";s:9:"customers";s:13:"best_customer";s:8:"partners";s:13:"last_partners";s:8:"apply_on";s:7:"product";s:7:"display";s:5:"table";s:10:"categories";s:3:"all";s:8:"products";s:6:"a:0:{}";s:7:"coupons";s:6:"a:0:{}";}}i:3;O:8:"stdClass":2:{s:8:"row_name";s:20:"Orders
created
today";s:13:"widget_params";O:8:"stdClass":15:{s:10:"periodType";s:14:"proposedPeriod";s:14:"proposedPeriod";s:5:"today";s:5:"start";s:0:"";s:3:"end";s:0:"";s:6:"period";s:1:"0";s:7:"content";s:6:"orders";s:7:"filters";s:72:"a:1:{s:14:"a.order_status";a:2:{i:0;s:7:"created";i:1;s:9:"confirmed";}}";s:7:"payment";s:9:"_multiple";s:15:"category_childs";s:1:"0";s:9:"customers";s:13:"last_customer";s:8:"apply_on";s:7:"product";s:7:"display";s:5:"table";s:10:"categories";s:3:"all";s:8:"products";s:6:"a:0:{}";s:7:"coupons";s:6:"a:0:{}";}}i:4;O:8:"stdClass":2:{s:8:"row_name";s:24:"Best
category this
month";s:13:"widget_params";O:8:"stdClass":15:{s:10:"periodType";s:14:"proposedPeriod";s:14:"proposedPeriod";s:8:"thisWeek";s:5:"start";s:0:"";s:3:"end";s:0:"";s:6:"period";s:1:"0";s:7:"content";s:4:"best";s:7:"filters";s:45:"a:1:{s:14:"a.order_status";a:1:{i:0;s:0:"";}}";s:7:"payment";s:9:"_multiple";s:15:"category_childs";s:1:"0";s:9:"customers";s:13:"last_customer";s:8:"apply_on";s:8:"category";s:7:"display";s:5:"table";s:10:"categories";s:3:"all";s:8:"products";s:6:"a:0:{}";s:7:"coupons";s:6:"a:0:{}";}}}s:6:"status";s:0:"";s:8:"products";s:6:"a:0:{}";}',
1, 3, 'all'),
(4, 'Weekly performance',
'O:8:"stdClass":27:{s:7:"display";s:5:"gauge";s:9:"date_type";s:7:"created";s:10:"date_group";s:5:"%u
%Y";s:10:"periodType";s:14:"proposedPeriod";s:14:"proposedPeriod";s:3:"all";s:6:"period";s:1:"0";s:7:"content";s:5:"sales";s:7:"filters";s:45:"a:1:{s:14:"a.order_status";a:1:{i:0;s:0:"";}}";s:15:"category_childs";s:1:"0";s:9:"customers";s:14:"last_customers";s:15:"customers_order";s:5:"sales";s:8:"partners";s:14:"last_customers";s:14:"partners_order";s:5:"sales";s:12:"compare_with";s:7:"periods";s:14:"period_compare";s:4:"none";s:5:"limit";s:1:"7";s:6:"region";s:5:"world";s:6:"format";s:5:"UTF-8";s:10:"map_source";s:8:"shipping";s:12:"product_data";s:5:"sales";s:16:"product_order_by";s:4:"best";s:15:"orders_order_by";s:4:"last";s:8:"compares";N;s:10:"categories";s:3:"all";s:8:"products";s:6:"a:0:{}";s:7:"coupons";s:6:"a:0:{}";s:6:"status";s:0:"";}',
0, 4, 'all'),
(5, 'Top sales',
'O:8:"stdClass":27:{s:7:"display";s:7:"listing";s:9:"date_type";s:7:"created";s:10:"date_group";s:5:"%j
%Y";s:10:"periodType";s:14:"proposedPeriod";s:14:"proposedPeriod";s:9:"thisMonth";s:6:"period";s:1:"0";s:7:"content";s:8:"products";s:7:"filters";s:45:"a:1:{s:14:"a.order_status";a:1:{i:0;s:0:"";}}";s:15:"category_childs";s:1:"0";s:9:"customers";s:14:"last_customers";s:15:"customers_order";s:5:"sales";s:8:"partners";s:14:"last_customers";s:14:"partners_order";s:5:"sales";s:12:"compare_with";s:7:"periods";s:14:"period_compare";s:4:"none";s:5:"limit";s:1:"7";s:6:"region";s:5:"world";s:6:"format";s:5:"UTF-8";s:10:"map_source";s:8:"shipping";s:12:"product_data";s:5:"sales";s:16:"product_order_by";s:4:"best";s:15:"orders_order_by";s:4:"last";s:8:"compares";N;s:10:"categories";s:3:"all";s:8:"products";s:6:"a:0:{}";s:7:"coupons";s:6:"a:0:{}";s:6:"status";s:0:"";}',
0, 5, 'all'),
(6, 'Orders statuses this week',
'O:8:"stdClass":27:{s:7:"display";s:3:"pie";s:9:"date_type";s:7:"created";s:10:"date_group";s:5:"%j
%Y";s:10:"periodType";s:14:"proposedPeriod";s:14:"proposedPeriod";s:8:"thisWeek";s:6:"period";s:1:"0";s:7:"content";s:6:"orders";s:7:"filters";s:45:"a:1:{s:14:"a.order_status";a:1:{i:0;s:0:"";}}";s:15:"category_childs";s:1:"0";s:9:"customers";s:14:"last_customers";s:15:"customers_order";s:5:"sales";s:8:"partners";s:14:"last_customers";s:14:"partners_order";s:5:"sales";s:12:"compare_with";s:7:"periods";s:14:"period_compare";s:4:"none";s:5:"limit";s:1:"7";s:6:"region";s:5:"world";s:6:"format";s:5:"UTF-8";s:10:"map_source";s:8:"shipping";s:12:"product_data";s:5:"sales";s:16:"product_order_by";s:4:"best";s:15:"orders_order_by";s:4:"last";s:8:"compares";N;s:10:"categories";s:3:"all";s:8:"products";s:6:"a:0:{}";s:7:"coupons";s:6:"a:0:{}";s:6:"status";s:0:"";}',
0, 6, 'all'),
(7, 'Sales comparison between this year vs last year',
'O:8:"stdClass":27:{s:7:"display";s:4:"area";s:9:"date_type";s:7:"created";s:10:"date_group";s:5:"%j
%Y";s:10:"periodType";s:14:"proposedPeriod";s:14:"proposedPeriod";s:9:"thisMonth";s:6:"period";s:1:"0";s:7:"content";s:5:"sales";s:7:"filters";s:45:"a:1:{s:14:"a.order_status";a:1:{i:0;s:0:"";}}";s:15:"category_childs";s:1:"0";s:9:"customers";s:14:"last_customers";s:15:"customers_order";s:5:"sales";s:8:"partners";s:14:"last_customers";s:14:"partners_order";s:5:"sales";s:12:"compare_with";s:7:"periods";s:14:"period_compare";s:9:"last_year";s:5:"limit";s:1:"7";s:6:"region";s:5:"world";s:6:"format";s:5:"UTF-8";s:10:"map_source";s:8:"shipping";s:12:"product_data";s:5:"sales";s:16:"product_order_by";s:4:"best";s:15:"orders_order_by";s:4:"last";s:8:"compares";N;s:10:"categories";s:3:"all";s:8:"products";s:6:"a:0:{}";s:7:"coupons";s:6:"a:0:{}";s:6:"status";s:0:"";}',
0, 7, 'all'),
(8, 'Five best categories over the last two weeks',
'O:8:"stdClass":27:{s:7:"display";s:4:"line";s:9:"date_type";s:7:"created";s:10:"date_group";s:5:"%j
%Y";s:10:"periodType";s:14:"specificPeriod";s:5:"start";i:1342367760;s:3:"end";i:1343663760;s:6:"period";s:7:"1296000";s:7:"content";s:6:"orders";s:7:"filters";s:45:"a:1:{s:14:"a.order_status";a:1:{i:0;s:0:"";}}";s:15:"category_childs";s:1:"0";s:9:"customers";s:14:"last_customers";s:15:"customers_order";s:5:"sales";s:8:"partners";s:14:"last_customers";s:14:"partners_order";s:5:"sales";s:12:"compare_with";s:6:"values";s:8:"compares";s:50:"a:1:{s:13:"c.category_id";s:15:"c.category_name";}";s:5:"limit";s:1:"5";s:6:"region";s:5:"world";s:6:"format";s:5:"UTF-8";s:10:"map_source";s:8:"shipping";s:12:"product_data";s:5:"sales";s:16:"product_order_by";s:4:"best";s:15:"orders_order_by";s:4:"last";s:10:"categories";s:3:"all";s:8:"products";s:6:"a:0:{}";s:7:"coupons";s:6:"a:0:{}";s:6:"status";s:0:"";}',
0, 8, 'all'),
(9, 'Map',
'O:8:"stdClass":27:{s:7:"display";s:3:"map";s:9:"date_type";s:7:"created";s:10:"date_group";s:5:"%j
%Y";s:10:"periodType";s:14:"proposedPeriod";s:14:"proposedPeriod";s:3:"all";s:6:"period";s:1:"0";s:7:"content";s:6:"orders";s:7:"filters";s:45:"a:1:{s:14:"a.order_status";a:1:{i:0;s:0:"";}}";s:15:"category_childs";s:1:"0";s:9:"customers";s:14:"best_customers";s:15:"customers_order";s:5:"sales";s:8:"partners";s:14:"last_customers";s:14:"partners_order";s:5:"sales";s:12:"compare_with";s:7:"periods";s:14:"period_compare";s:4:"none";s:5:"limit";s:1:"5";s:6:"region";s:5:"world";s:6:"format";s:5:"UTF-8";s:10:"map_source";s:7:"billing";s:12:"product_data";s:5:"sales";s:16:"product_order_by";s:4:"best";s:15:"orders_order_by";s:4:"best";s:8:"compares";N;s:10:"categories";s:3:"all";s:8:"products";s:6:"a:0:{}";s:7:"coupons";s:6:"a:0:{}";s:6:"status";s:0:"";}',
0, 9, 'all'),
(10, 'Orders by currency',
'O:8:"stdClass":26:{s:7:"display";s:6:"column";s:9:"date_type";s:7:"created";s:10:"date_group";s:5:"%j
%Y";s:10:"periodType";s:14:"proposedPeriod";s:14:"proposedPeriod";s:8:"thisWeek";s:6:"period";s:1:"0";s:7:"content";s:6:"orders";s:7:"filters";s:90:"a:2:{s:14:"a.order_status";a:1:{i:0;s:0:"";}s:19:"a.order_currency_id";a:1:{i:0;s:1:"1";}}";s:15:"category_childs";s:1:"0";s:9:"customers";s:14:"last_customers";s:15:"customers_order";s:5:"sales";s:8:"partners";s:14:"last_customers";s:14:"partners_order";s:5:"sales";s:12:"compare_with";s:6:"values";s:8:"compares";s:56:"a:1:{s:19:"a.order_currency_id";s:15:"d.currency_name";}";s:5:"limit";s:1:"7";s:6:"region";s:5:"world";s:6:"format";s:5:"UTF-8";s:10:"map_source";s:8:"shipping";s:12:"product_data";s:5:"sales";s:16:"product_order_by";s:4:"best";s:15:"orders_order_by";s:4:"last";s:10:"categories";s:3:"all";s:8:"products";s:6:"a:0:{}";s:7:"coupons";s:6:"a:0:{}";s:6:"status";s:0:"";}',
0, 10, 'all'),
(11, 'Order to ship',
'O:8:"stdClass":27:{s:7:"display";s:7:"listing";s:9:"date_type";s:7:"created";s:10:"date_group";s:5:"%j
%Y";s:10:"periodType";s:14:"proposedPeriod";s:14:"proposedPeriod";s:3:"all";s:6:"period";s:1:"0";s:7:"content";s:6:"orders";s:7:"filters";s:54:"a:1:{s:14:"a.order_status";a:1:{i:0;s:9:"confirmed";}}";s:15:"category_childs";s:1:"0";s:9:"customers";s:14:"last_customers";s:15:"customers_order";s:5:"sales";s:8:"partners";s:14:"last_customers";s:14:"partners_order";s:5:"sales";s:12:"compare_with";s:7:"periods";s:14:"period_compare";s:4:"none";s:5:"limit";s:0:"";s:6:"region";s:5:"world";s:6:"format";s:5:"UTF-8";s:10:"map_source";s:8:"shipping";s:12:"product_data";s:5:"sales";s:16:"product_order_by";s:4:"best";s:15:"orders_order_by";s:4:"last";s:8:"compares";N;s:10:"categories";s:3:"all";s:8:"products";s:6:"a:0:{}";s:7:"coupons";s:6:"a:0:{}";s:6:"status";s:0:"";}',
0, 11, 'all');
EOD;
$this->db->setQuery($query);
$this->db->query();
$query = <<<EOD
INSERT IGNORE INTO `#__hikashop_currency` (`currency_id`,
`currency_symbol`, `currency_code`, `currency_format`, `currency_name`,
`currency_published`, `currency_displayed`, `currency_locale`) VALUES
(1, 'âŹ', 'EUR', '%n', 'Euro',
1,1,
'a:13:{s:17:"mon_decimal_point";s:1:",";s:17:"mon_thousands_sep";s:1:".";s:12:"mon_grouping";s:1:"3";s:13:"positive_sign";s:0:"";s:13:"negative_sign";s:1:"-";s:15:"int_frac_digits";i:2;s:11:"frac_digits";i:2;s:13:"p_cs_precedes";i:0;s:14:"p_sep_by_space";i:1;s:13:"n_cs_precedes";i:0;s:14:"n_sep_by_space";i:1;s:11:"p_sign_posn";i:1;s:11:"n_sign_posn";i:1;}'),
(2, '\$', 'USD', '%n', 'United States
dollar', 1, 1,
'a:13:{s:17:"mon_decimal_point";s:1:".";s:17:"mon_thousands_sep";s:1:",";s:12:"mon_grouping";s:1:"3";s:13:"positive_sign";s:0:"";s:13:"negative_sign";s:1:"-";s:15:"int_frac_digits";i:2;s:11:"frac_digits";i:2;s:13:"p_cs_precedes";i:1;s:14:"p_sep_by_space";i:0;s:13:"n_cs_precedes";i:1;s:14:"n_sep_by_space";i:0;s:11:"p_sign_posn";i:4;s:11:"n_sign_posn";i:4;}'),
(3, '„', 'JPY', '%n', 'Japanese
yen', 0, 0,
'a:13:{s:17:"mon_decimal_point";s:1:",";s:17:"mon_thousands_sep";s:1:"
";s:12:"mon_grouping";s:1:"4";s:13:"positive_sign";s:0:"";s:13:"negative_sign";s:1:"-";s:15:"int_frac_digits";i:0;s:11:"frac_digits";i:0;s:13:"p_cs_precedes";i:0;s:14:"p_sep_by_space";i:1;s:13:"n_cs_precedes";i:0;s:14:"n_sep_by_space";i:1;s:11:"p_sign_posn";i:1;s:11:"n_sign_posn";i:1;}'),
(4, 'ÂŁ', 'GBP', '%n', 'British
pound', 0, 0,
'a:13:{s:17:"mon_decimal_point";s:1:".";s:17:"mon_thousands_sep";s:1:",";s:12:"mon_grouping";s:1:"3";s:13:"positive_sign";s:0:"";s:13:"negative_sign";s:1:"-";s:15:"int_frac_digits";i:2;s:11:"frac_digits";i:2;s:13:"p_cs_precedes";i:1;s:14:"p_sep_by_space";i:1;s:13:"n_cs_precedes";i:1;s:14:"n_sep_by_space";i:1;s:11:"p_sign_posn";i:1;s:11:"n_sign_posn";i:1;}'),
(5, '\$', 'CAD', '%i', 'Canadian
dollar', 0, 0,
'a:13:{s:17:"mon_decimal_point";s:1:".";s:17:"mon_thousands_sep";s:1:",";s:12:"mon_grouping";s:1:"3";s:13:"positive_sign";s:0:"";s:13:"negative_sign";s:1:"-";s:15:"int_frac_digits";i:2;s:11:"frac_digits";i:2;s:13:"p_cs_precedes";i:1;s:14:"p_sep_by_space";i:0;s:13:"n_cs_precedes";i:1;s:14:"n_sep_by_space";i:0;s:11:"p_sign_posn";i:4;s:11:"n_sign_posn";i:4;}'),
(6, '\$', 'AUD', '%i', 'Australian
dollar', 0, 0,
'a:13:{s:17:"mon_decimal_point";s:1:".";s:17:"mon_thousands_sep";s:1:",";s:12:"mon_grouping";s:1:"3";s:13:"positive_sign";s:0:"";s:13:"negative_sign";s:1:"-";s:15:"int_frac_digits";i:2;s:11:"frac_digits";i:2;s:13:"p_cs_precedes";i:1;s:14:"p_sep_by_space";i:0;s:13:"n_cs_precedes";i:1;s:14:"n_sep_by_space";i:0;s:11:"p_sign_posn";i:4;s:11:"n_sign_posn";i:4;}'),
(7, '\$', 'NZD', '%i', 'New Zealand
dollar', 0, 0,
'a:13:{s:17:"mon_decimal_point";s:1:",";s:17:"mon_thousands_sep";s:1:".";s:12:"mon_grouping";s:1:"3";s:13:"positive_sign";s:0:"";s:13:"negative_sign";s:1:"-";s:15:"int_frac_digits";i:2;s:11:"frac_digits";i:2;s:13:"p_cs_precedes";i:1;s:14:"p_sep_by_space";i:0;s:13:"n_cs_precedes";i:1;s:14:"n_sep_by_space";i:0;s:11:"p_sign_posn";i:4;s:11:"n_sign_posn";i:4;}'),
(8, 'Ű', 'AFN', '%i', 'Afghan
afghani', 0, 0, ''),
(9, 'Lek', 'ALL', '%i', 'Albanian
lek', 0, 0, ''),
(10, 'ŰŻ.ŰŹ', 'DZD', '%i', 'Algerian
dinar', 0, 0, ''),
(11, 'Kz ', 'AOA', '%i', 'Angolan
kwanza', 0, 0, ''),
(12, '\$', 'ARS', '%i', 'Argentine
peso', 0, 0, ''),
(13, 'Ő€Ö.', 'AMD', '%i', 'Armenian
dram', 0, 0, ''),
(14, 'Æ', 'AWG', '%i', 'Aruban
florin', 0, 0, ''),
(15, 'ĐŒĐ°Đœ', 'AZN', '%i', 'Azerbaijani
manat', 0, 0, ''),
(16, '\$', 'BSD', '%i', 'Bahamian
dollar', 0, 0, ''),
(17, 'Űš.ŰŻ', 'BHD', '%i', 'Bahraini
dinar', 0, 0, ''),
(18, 'à§ł', 'BDT', '%i', 'Bangladeshi
taka', 0, 0, ''),
(19, '\$', 'BBD', '%i', 'Barbadian
dollar', 0, 0, ''),
(20, 'p.', 'BYR', '%i', 'Belarusian
ruble', 0, 0, ''),
(21, 'BZ\$', 'BZD', '%i', 'Belize
dollar', 0, 0, ''),
(22, '\$', 'BMD', '%i', 'Bermudian
dollar', 0, 0, ''),
(23, 'BTN', 'BTN', '%i', 'Bhutanese
ngultrum', 0, 0, ''),
(24, '\$b', 'BOB', '%i', 'Bolivian
boliviano', 0, 0, ''),
(25, 'XBA', 'XBA', '%i', 'Bond
Markets', 0, 0, ''),
(26, 'KM', 'BAM', '%i', 'Bosnia and
Herzegovina convert', 0, 0, ''),
(27, 'P', 'BWP', '%i', 'Botswana
pula', 0, 0, ''),
(28, 'R$', 'BRL', '%i', 'Brazilian
real', 0, 0, ''),
(29, '\$', 'BND', '%i', 'Brunei
dollar', 0, 0, ''),
(30, 'Đ»ĐČ', 'BGN', '%i', 'Bulgarian
lev', 0, 0, ''),
(31, 'Fr ', 'BIF', '%i', 'Burundian
franc', 0, 0, ''),
(32, 'á', 'KHR', '%i', 'Cambodian
riel', 0, 0, ''),
(33, '\$', 'CVE', '%i', 'Cape Verdean
escudo', 0, 0, ''),
(34, '\$', 'KYD', '%i', 'Cayman Islands
dollar', 0, 0, ''),
(35, 'Fr ', 'XAF', '%i', 'Central
African CFA franc', 0, 0, ''),
(36, 'Fr ', 'XPF', '%i', 'CFP
franc', 0, 0, ''),
(37, '\$', 'CLP', '%i', 'Chilean
peso', 0, 0, ''),
(38, 'ć
', 'CNY', '%i', 'Chinese
renminbi yuan', 0, 0, ''),
(39, 'XTS', 'XTS', '%i', 'Codes
specif', 0, 0, ''),
(40, '\$', 'COP', '%i', 'Colombian
peso', 0, 0, ''),
(41, 'Fr ', 'KMF', '%i', 'Comorian
franc', 0, 0, ''),
(42, 'Fr ', 'CDF', '%i', 'Congolese
franc', 0, 0, ''),
(43, 'âĄ', 'CRC', '%i', 'Costa Rican
colĂłn', 0, 0, ''),
(44, 'kn', 'HRK', '%i', 'Croatian
kuna', 0, 0, ''),
(45, 'â±', 'CUP', '%i', 'Cuban
peso', 0, 0, ''),
(46, 'KÄ', 'CZK', '%i', 'Czech
koruna', 0, 0, ''),
(47, 'kr', 'DKK', '%i', 'Danish
krone', 0, 0, ''),
(48, 'Fr ', 'DJF', '%i', 'Djiboutian
franc', 0, 0, ''),
(49, 'RD\$', 'DOP', '%i', 'Dominican
peso', 0, 0, ''),
(50, '\$', 'XCD', '%i', 'East Caribbean
dollar', 0, 0, ''),
(51, 'ÂŁ', 'EGP', '%i', 'Egyptian
pound', 0, 0, ''),
(52, 'Nfk ', 'ERN', '%i', 'Eritrean
nakfa', 0, 0, ''),
(53, 'kr', 'EEK', '%i', 'Estonian
kroon', 0, 0, ''),
(54, 'ETB', 'ETB', '%i', 'Ethiopian
birr', 0, 0, ''),
(55, 'XBB', 'XBB', '%i', 'European
Mon', 0, 0, ''),
(56, 'XBD', 'XBD', '%i', 'European
Uni', 0, 0, ''),
(57, 'XBC', 'XBC', '%i', 'European
Uni', 0, 0, ''),
(58, 'ÂŁ', 'FKP', '%i', 'Falkland
pound', 0, 0, ''),
(59, '$', 'FJD', '%i', 'Fijian
dollar', 0, 0, ''),
(60, 'D ', 'GMD', '%i', 'Gambian
dalasi', 0, 0, ''),
(61, 'á', 'GEL', '%i', 'Georgian
lari', 0, 0, ''),
(62, 'â”', 'GHS', '%i', 'Ghanaian
cedi', 0, 0, ''),
(63, 'ÂŁ', 'GIP', '%i', 'Gibraltar
pound', 0, 0, ''),
(64, 'Gold', 'XAU', '%i', 'Gold',
0, 0, ''),
(65, 'Q', 'GTQ', '%i', 'Guatemalan
quetzal', 0, 0, ''),
(66, 'GWP', 'GWP', '%i',
'Guinea-Bissa', 0, 0, ''),
(67, 'Fr ', 'GNF', '%i', 'Guinean
franc', 0, 0, ''),
(68, '$', 'GYD', '%i', 'Guyanese
dollar', 0, 0, ''),
(69, 'G ', 'HTG', '%i', 'Haitian
gourde', 0, 0, ''),
(70, 'L', 'HNL', '%i', 'Honduran
lempira', 0, 0, ''),
(71, 'ć
', 'HKD', '%i', 'Hong Kong
dollar', 0, 0, ''),
(72, 'Ft', 'HUF', '%i', 'Hungarian
forint', 0, 0, ''),
(73, 'kr', 'ISK', '%i', 'Icelandic
krĂłna', 0, 0, ''),
(74, 'âš', 'INR', '%i', 'Indian
rupee', 0, 0, ''),
(75, 'Rp', 'IDR', '%i', 'Indonesian
rupiah', 0, 0, ''),
(76, '﷌', 'IRR', '%i', 'Iranian
rial', 0, 0, ''),
(77, 'Űč.ŰŻ', 'IQD', '%i', 'Iraqi
dinar', 0, 0, ''),
(78, 'âȘ', 'ILS', '%i', 'Israeli new
sheqel', 0, 0, ''),
(79, 'J$', 'JMD', '%i', 'Jamaican
dollar', 0, 0, ''),
(80, 'ۯ.ۧ', 'JOD', '%i', 'Jordanian
dinar', 0, 0, ''),
(81, 'Đ»ĐČ', 'KZT', '%i', 'Kazakhstani
tenge', 0, 0, ''),
(82, 'Sh ', 'KES', '%i', 'Kenyan
shilling', 0, 0, ''),
(83, 'ŰŻ.Ù', 'KWD', '%i', 'Kuwaiti
dinar', 0, 0, ''),
(84, 'Đ»ĐČ', 'KGS', '%i', 'Kyrgyzstani
som', 0, 0, ''),
(85, 'â', 'LAK', '%i', 'Lao kip',
0, 0, ''),
(86, 'Ls', 'LVL', '%i', 'Latvian
lats', 0, 0, ''),
(87, 'ÂŁ', 'LBP', '%i', 'Lebanese
pound', 0, 0, ''),
(88, 'L ', 'LSL', '%i', 'Lesotho
loti', 0, 0, ''),
(89, '$', 'LRD', '%i', 'Liberian
dollar', 0, 0, ''),
(90, 'Ù.ŰŻ', 'LYD', '%i', 'Libyan
dinar', 0, 0, ''),
(91, 'Lt', 'LTL', '%i', 'Lithuanian
litas', 0, 0, ''),
(92, 'P ', 'MOP', '%i', 'Macanese
pataca', 0, 0, ''),
(93, 'ĐŽĐ”Đœ', 'MKD', '%i', 'Macedonian
denar', 0, 0, ''),
(94, 'MGA', 'MGA', '%i', 'Malagasy
ariary', 0, 0, ''),
(95, 'MK ', 'MWK', '%i', 'Malawian
kwacha', 0, 0, ''),
(96, 'RM', 'MYR', '%i', 'Malaysian
ringgit', 0, 0, ''),
(97, 'Ț.', 'MVR', '%i', 'Maldivian
rufiyaa', 0, 0, ''),
(98, 'UM ', 'MRO', '%i', 'Mauritanian
ouguiya', 0, 0, ''),
(99, 'âš', 'MUR', '%i', 'Mauritian
rupee', 0, 0, ''),
(100, '\$', 'MXN', '%i', 'Mexican
peso', 0, 0, ''),
(101, 'MXV', 'MXV', '%i', 'Mexican
Unid', 0, 0, ''),
(102, 'L ', 'MDL', '%i', 'Moldovan
leu', 0, 0, ''),
(103, 'âź', 'MNT', '%i', 'Mongolian
tögrög', 0, 0, ''),
(104, 'ŰŻ.Ù
.', 'MAD', '%i', 'Moroccan
dirham', 0, 0, ''),
(105, 'MT', 'MZN', '%i', 'Mozambican
metical', 0, 0, ''),
(106, 'BOV', 'BOV', '%i', 'Mvdol',
0, 0, ''),
(107, 'K ', 'MMK', '%i', 'Myanmar
kyat', 0, 0, ''),
(108, '\$', 'NAD', '%i', 'Namibian
dollar', 0, 0, ''),
(109, 'âš', 'NPR', '%i', 'Nepalese
rupee', 0, 0, ''),
(110, 'Æ', 'ANG', '%i', 'Netherlands
Antillean gulden', 0, 0, ''),
(111, 'NT\$', 'TWD', '%i', 'New Taiwan
dollar', 0, 0, ''),
(112, 'C\$', 'NIO', '%i', 'Nicaraguan
cĂłrdoba', 0, 0, ''),
(113, 'âŠ', 'NGN', '%i', 'Nigerian
naira', 0, 0, ''),
(114, 'â©', 'KPW', '%i', 'North Korean
won', 0, 0, ''),
(115, 'kr', 'NOK', '%i', 'Norwegian
krone', 0, 0, ''),
(116, '﷌', 'OMR', '%i', 'Omani
rial', 0, 0, ''),
(117, 'âš', 'PKR', '%i', 'Pakistani
rupee', 0, 0, ''),
(118, 'XPD', 'XPD', '%i',
'Palladium', 0, 0, ''),
(119, 'B/.', 'PAB', '%i', 'Panamanian
balboa', 0, 0, ''),
(120, 'K ', 'PGK', '%i', 'Papua New
Guinean kina', 0, 0, ''),
(121, 'âČ', 'PYG', '%i', 'Paraguayan
guaranĂ', 0, 0, ''),
(122, 'S/.', 'PEN', '%i', 'Peruvian
nuevo sol', 0, 0, ''),
(123, 'â±', 'PHP', '%i', 'Philippine
peso', 0, 0, ''),
(124, 'XPT', 'XPT', '%i',
'Platinum', 0, 0, ''),
(125, 'zĆ', 'PLN', '%i', 'Polish
ZĆoty', 0, 0, ''),
(126, '﷌', 'QAR', '%i', 'Qatari
riyal', 0, 0, ''),
(127, 'lei', 'RON', '%i', 'Romanian
leu', 0, 0, ''),
(128, 'ŃŃб', 'RUB', '%i', 'Russian
ruble', 0, 0, ''),
(129, 'Fr ', 'RWF', '%i', 'Rwandan
franc', 0, 0, ''),
(130, 'ÂŁ', 'SHP', '%i', 'Saint Helenian
pound', 0, 0, ''),
(131, '$', 'SVC', '%i', 'Salvadoran
colĂłn', 0, 0, ''),
(132, 'T ', 'WST', '%i', 'Samoan
tala', 0, 0, ''),
(133, 'Db ', 'STD', '%i', 'São Tomé
and PrĂncipe dobra', 0, 0, ''),
(134, '﷌', 'SAR', '%i', 'Saudi
riyal', 0, 0, ''),
(135, 'XDR', 'XDR', '%i', 'SDR', 0,
0, ''),
(136, 'ĐĐžĐœ.', 'RSD', '%i', 'Serbian
dinar', 0, 0, ''),
(137, 'âš', 'SCR', '%i', 'Seychellois
rupee', 0, 0, ''),
(138, 'Le ', 'SLL', '%i', 'Sierra
Leonean leone', 0, 0, ''),
(139, 'XAG', 'XAG', '%i', 'Silver',
0, 0, ''),
(140, '\$', 'SGD', '%i', 'Singapore
dollar', 0, 0, ''),
(141, 'Sk ', 'SKK', '%i', 'Slovak
koruna', 0, 0, ''),
(142, '\$', 'SBD', '%i', 'Solomon
Islands dollar', 0, 0, ''),
(143, 'S', 'SOS', '%i', 'Somali
shilling', 0, 0, ''),
(144, 'R', 'ZAR', '%i', 'South African
rand', 0, 0, ''),
(145, 'â©', 'KRW', '%i', 'South Korean
won', 0, 0, ''),
(146, 'âš', 'LKR', '%i', 'Sri Lankan
rupee', 0, 0, ''),
(147, 'ÂŁ ', 'SDG', '%i', 'Sudanese
pound', 0, 0, ''),
(148, '$', 'SRD', '%i', 'Surinamese
dollar', 0, 0, ''),
(149, 'L ', 'SZL', '%i', 'Swazi
lilangeni', 0, 0, ''),
(150, 'kr', 'SEK', '%i', 'Swedish
krona', 0, 0, ''),
(151, 'CHF', 'CHF', '%i', 'Swiss
franc', 0, 0, ''),
(152, 'ÂŁ', 'SYP', '%i', 'Syrian
pound', 0, 0, ''),
(153, 'Đ
Đ', 'TJS', '%i', 'Tajikistani
somoni', 0, 0, ''),
(154, 'Sh ', 'TZS', '%i', 'Tanzanian
shilling', 0, 0, ''),
(155, 'àžż', 'THB', '%i', 'Thai
baht', 0, 0, ''),
(156, 'XXX', 'XXX', '%i', 'The codes
as', 0, 0, ''),
(157, 'T$ ', 'TOP', '%i', 'Tongan
paʻanga', 0, 0, ''),
(158, 'TT$', 'TTD', '%i', 'Trinidad and
Tobago dollar', 0, 0, ''),
(159, 'ŰŻ.ŰȘ', 'TND', '%i', 'Tunisian
dinar', 0, 0, ''),
(160, 'YTL', 'TRY', '%i', 'Turkish new
lira', 0, 0, ''),
(161, 'm ', 'TMM', '%i', 'Turkmenistani
manat', 0, 0, ''),
(162, 'Sh ', 'UGX', '%i', 'Ugandan
shilling', 0, 0, ''),
(163, 'XFU', 'XFU', '%i',
'UIC-Franc', 0, 0, ''),
(164, 'âŽ', 'UAH', '%i', 'Ukrainian
hryvnia', 0, 0, ''),
(165, 'COU', 'COU', '%i', 'Unidad de
Va', 0, 0, ''),
(166, 'CLF', 'CLF', '%i', 'Unidades de
', 0, 0, ''),
(167, 'ŰŻ.Ű„', 'AED', '%i', 'United Arab
Emirates dirham', 0, 0, ''),
(168, 'UYI', 'UYI', '%i', 'Uruguay
Peso', 0, 0, ''),
(169, '\$', 'UYU', '%i', 'Uruguayan
peso', 0, 0, ''),
(170, '\$', 'USN', '%i', 'US Dollar
(Next Day)', 0, 0, ''),
(171, '\$', 'USS', '%i', 'US Dollar
(Second Day)', 0, 0, ''),
(172, 'Đ»ĐČ', 'UZS', '%i', 'Uzbekistani
som', 0, 0, ''),
(173, 'Vt ', 'VUV', '%i', 'Vanuatu
vatu', 0, 0, ''),
(174, 'Bs', 'VEF', '%i', 'Venezuelan
bolĂvar', 0, 0, ''),
(175, 'â«', 'VND', '%i', 'Vietnamese
Dong', 0, 0, ''),
(176, 'Fr ', 'XOF', '%i', 'West African
CFA franc', 0, 0, ''),
(177, 'âŹ', 'CHE', '%i', 'WIR
Euro', 0, 0, ''),
(178, 'CHW', 'CHW', '%i', 'WIR
Franc', 0, 0, ''),
(179, '﷌', 'YER', '%i', 'Yemeni
rial', 0, 0, ''),
(180, 'ZK ', 'ZMK', '%i', 'Zambian
kwacha', 0, 0, ''),
(181, 'Z\$', 'ZWD', '%i', 'Zimbabwean
dollar', 0, 0, '');
EOD;
$this->db->setQuery($query);
$this->db->query();
$query="
INSERT IGNORE INTO `#__hikashop_zone` (`zone_id`, `zone_namekey`,
`zone_name`, `zone_name_english`, `zone_code_2`, `zone_code_3`,
`zone_type`, `zone_published`) VALUES
(1, 'country_Afghanistan_1', 'ۧÙŰșۧÙŰłŰȘۧÙ',
'Afghanistan', 'AF', 'AFG',
'country', 1),
(2, 'country_Albania_2', 'Shqipëria',
'Albania', 'AL', 'ALB', 'country',
1),
(3, 'country_Algeria_3', 'ۧÙŰŹŰČۧۊ۱',
'Algeria', 'DZ', 'DZA', 'country',
1),
(4, 'country_American_Samoa_4', 'American Samoa',
'American Samoa', 'AS', 'ASM',
'country', 1),
(5, 'country_Andorra_5', 'Andorra',
'Andorra', 'AD', 'AND', 'country',
1),
(6, 'country_Angola_6', 'Angola', 'Angola',
'AO', 'AGO', 'country', 1),
(7, 'country_Anguilla_7', 'Anguilla',
'Anguilla', 'AI', 'AIA', 'country',
1),
(8, 'country_Antarctica_8', 'Antarctica',
'Antarctica', 'AQ', 'ATA',
'country', 1),
(9, 'country_Antigua_and_Barbuda_9', 'Antigua and
Barbuda', 'Antigua and Barbuda', 'AG',
'ATG', 'country', 1),
(10, 'country_Argentina_10', 'Argentina',
'Argentina', 'AR', 'ARG',
'country', 1),
(11, 'country_Armenia_11', 'ŐŐĄŐ”ŐĄŐœŐżŐĄŐ¶',
'Armenia', 'AM', 'ARM', 'country',
1),
(12, 'country_Aruba_12', 'Aruba', 'Aruba',
'AW', 'ABW', 'country', 1),
(13, 'country_Australia_13', 'Australia',
'Australia', 'AU', 'AUS',
'country', 1),
(14, 'country_Austria_14', 'Ăsterreich',
'Austria', 'AT', 'AUT', 'country',
1),
(15, 'country_Azerbaijan_15', 'AzÉrbaycan',
'Azerbaijan', 'AZ', 'AZE',
'country', 1),
(16, 'country_Bahamas_16', 'Bahamas',
'Bahamas', 'BS', 'BHS', 'country',
1),
(17, 'country_Bahrain_17', 'ۧÙŰšŰ۱ÙÙ',
'Bahrain', 'BH', 'BHR', 'country',
1),
(18, 'country_Bangladesh_18',
'àŠŹàŠŸàŠàŠČàŠŸàŠŠà§àж''', 'Bangladesh',
'BD', 'BGD', 'country', 1),
(19, 'country_Barbados_19', 'Barbados',
'Barbados', 'BB', 'BRB', 'country',
1),
(20, 'country_Belarus_20', 'ĐДлаŃŃŃŃ',
'Belarus', 'BY', 'BLR', 'country',
1),
(21, 'country_Belgium_21', 'BelgiĂ« âą Belgique âą
Belgien', 'Belgium', 'BE', 'BEL',
'country', 1),
(22, 'country_Belize_22', 'Belize', 'Belize',
'BZ', 'BLZ', 'country', 1),
(23, 'country_Benin_23', 'Bénin', 'Benin',
'BJ', 'BEN', 'country', 1),
(24, 'country_Bermuda_24', 'Bermuda',
'Bermuda', 'BM', 'BMU', 'country',
1),
(25, 'country_Bhutan_25',
'àœ àœàŸČàœŽàœàŒàœĄàœŽàœŁàŒ', 'Bhutan',
'BT', 'BTN', 'country', 1),
(26, 'country_Bolivia_26', 'Wuliwya âą VolĂvia âą
Buliwya', 'Bolivia', 'BO', 'BOL',
'country', 1),
(27, 'country_Bosnia_and_Herzegowina_27', 'Bosna i
Hercegovina', 'Bosnia and Herzegowina', 'BA',
'BIH', 'country', 1),
(28, 'country_Botswana_28', 'Botswana',
'Botswana', 'BW', 'BWA', 'country',
1),
(29, 'country_Bouvet_Island_29', 'Bouvet Island',
'Bouvet Island', 'BV', 'BVT',
'country', 1),
(30, 'country_Brazil_30', 'Brazil', 'Brazil',
'BR', 'BRA', 'country', 1),
(31, 'country_British_Indian_Ocean_Territory_31', 'British
Indian Ocean Territory', 'British Indian Ocean Territory',
'IO', 'IOT', 'country', 1),
(32, 'country_Brunei_Darussalam_32', 'Brunei
Darussalam', 'Brunei Darussalam', 'BN',
'BRN', 'country', 1),
(33, 'country_Bulgaria_33', 'ĐŃлгаŃĐžŃ',
'Bulgaria', 'BG', 'BGR', 'country',
1),
(34, 'country_Burkina_Faso_34', 'Burkina Faso',
'Burkina Faso', 'BF', 'BFA',
'country', 1),
(35, 'country_Burundi_35', 'Uburundi',
'Burundi', 'BI', 'BDI', 'country',
1),
(36, 'country_Cambodia_36', 'ááááá»áá¶',
'Cambodia', 'KH', 'KHM', 'country',
1),
(37, 'country_Cameroon_37', 'Cameroun',
'Cameroon', 'CM', 'CMR', 'country',
1),
(38, 'country_Canada_38', 'Canada', 'Canada',
'CA', 'CAN', 'country', 1),
(39, 'country_Cape_Verde_39', 'Cabo Verde', 'Cape
Verde', 'CV', 'CPV', 'country', 1),
(40, 'country_Cayman_Islands_40', 'Cayman Islands',
'Cayman Islands', 'KY', 'CYM',
'country', 1),
(41, 'country_Central_African_Republic_41', 'Centrafrique
âą BĂȘafrĂźka', 'Central African Republic', 'CF',
'CAF', 'country', 1),
(42, 'country_Chad_42', 'Tchad âą ŰȘێۧۯ',
'Chad', 'TD', 'TCD', 'country',
1),
(43, 'country_Chile_43', 'Chile', 'Chile',
'CL', 'CHL', 'country', 1),
(44, 'country_China_44', 'äžć âą äžćœ',
'China', 'CN', 'CHN', 'country',
1),
(45, 'country_Christmas_Island_45', 'Christmas Island',
'Christmas Island', 'CX', 'CXR',
'country', 1),
(46, 'country_Cocos__Keeling__Islands_46', 'Cocos (Keeling)
Islands', 'Cocos (Keeling) Islands', 'CC',
'CCK', 'country', 1),
(47, 'country_Colombia_47', 'Colombia',
'Colombia', 'CO', 'COL', 'country',
1),
(48, 'country_Comoros_48', 'Komori âą Comores âą ŰŹŰČ۱
ۧÙÙÙ
۱', 'Comoros', 'KM', 'COM',
'country', 1),
(49, 'country_Congo_49', 'Congo', 'Congo',
'CG', 'COG', 'country', 1),
(50, 'country_Cook_Islands_50', 'Cook Islands',
'Cook Islands', 'CK', 'COK',
'country', 1),
(51, 'country_Costa_Rica_51', 'Costa Rica', 'Costa
Rica', 'CR', 'CRI', 'country', 1),
(52, 'country_Cote_D_Ivoire_52', 'Cote
D''Ivoire', 'Cote D''Ivoire',
'CI', 'CIV', 'country', 1),
(53, 'country_Croatia_53', 'Hrvatska',
'Croatia', 'HR', 'HRV', 'country',
1),
(54, 'country_Cuba_54', 'Cuba', 'Cuba',
'CU', 'CUB', 'country', 1),
(55, 'country_Cyprus_55', 'ÎÏÏÏÎżÏ âą Kıbrıs',
'Cyprus', 'CY', 'CYP', 'country',
1),
(56, 'country_Czech_Republic_56', 'Äesko', 'Czech
Republic', 'CZ', 'CZE', 'country', 1),
(57, 'country_Denmark_57', 'Danmark',
'Denmark', 'DK', 'DNK', 'country',
1),
(58, 'country_Djibouti_58', 'ŰŹÙŰšÙŰȘÙ',
'Djibouti', 'DJ', 'DJI', 'country',
1),
(59, 'country_Dominica_59', 'Dominica',
'Dominica', 'DM', 'DMA', 'country',
1),
(60, 'country_Dominican_Republic_60', 'RepĂșblica
Dominicana', 'Dominican Republic', 'DO',
'DOM', 'country', 1),
(61, 'country_East_Timor_61', 'TimĂłr-Leste',
'East Timor', 'TP', 'TMP',
'country', 1),
(62, 'country_Ecuador_62', 'Ecuador',
'Ecuador', 'EC', 'ECU', 'country',
1),
(63, 'country_Egypt_63', 'Ù
۔۱', 'Egypt',
'EG', 'EGY', 'country', 1),
(64, 'country_El_Salvador_64', 'El Salvador', 'El
Salvador', 'SV', 'SLV', 'country', 1),
(65, 'country_Equatorial_Guinea_65', 'Guinée
équatoriale', 'Equatorial Guinea', 'GQ',
'GNQ', 'country', 1),
(66, 'country_Eritrea_66', 'á€áá”á« âą
ۄ۱ŰȘ۱Ùۧ', 'Eritrea', 'ER', 'ERI',
'country', 1),
(67, 'country_Estonia_67', 'Eesti',
'Estonia', 'EE', 'EST', 'country',
1),
(68, 'country_Ethiopia_68', 'áąá”áźá”á«',
'Ethiopia', 'ET', 'ETH', 'country',
1),
(69, 'country_Falkland_Islands__Malvinas__69', 'Falkland
Islands (Malvinas)', 'Falkland Islands (Malvinas)',
'FK', 'FLK', 'country', 1),
(70, 'country_Faroe_Islands_70', 'Faroe Islands',
'Faroe Islands', 'FO', 'FRO',
'country', 1),
(71, 'country_Fiji_71', 'Viti âą à€«à€Œà€żà€à„',
'Fiji', 'FJ', 'FJI', 'country',
1),
(72, 'country_Finland_72', 'Suomi',
'Finland', 'FI', 'FIN', 'country',
1),
(73, 'country_France_73', 'France', 'France',
'FR', 'FRA', 'country', 1),
(74, 'country_France__Metropolitan_74', 'France,
Metropolitan', 'France, Metropolitan', 'FX',
'FXX', 'country', 0),
(75, 'country_French_Guiana_75', 'French Guiana',
'French Guiana', 'GF', 'GUF',
'country', 1),
(76, 'country_French_Polynesia_76', 'French Polynesia',
'French Polynesia', 'PF', 'PYF',
'country', 1),
(77, 'country_French_Southern_Territories_77', 'French
Southern Territories', 'French Southern Territories',
'TF', 'ATF', 'country', 1),
(78, 'country_Gabon_78', 'Gabon', 'Gabon',
'GA', 'GAB', 'country', 1),
(79, 'country_Gambia_79', 'Gambia', 'Gambia',
'GM', 'GMB', 'country', 1),
(80, 'country_Georgia_80',
'áĄáá„áá ááááá', 'Georgia',
'GE', 'GEO', 'country', 1),
(81, 'country_Germany_81', 'Deutschland',
'Germany', 'DE', 'DEU', 'country',
1),
(82, 'country_Ghana_82', 'Ghana', 'Ghana',
'GH', 'GHA', 'country', 1),
(83, 'country_Gibraltar_83', 'Gibraltar',
'Gibraltar', 'GI', 'GIB',
'country', 1),
(84, 'country_Greece_84', 'ÎλλΏΎα',
'Greece', 'GR', 'GRC', 'country',
1),
(85, 'country_Greenland_85', 'Greenland',
'Greenland', 'GL', 'GRL',
'country', 1),
(86, 'country_Grenada_86', 'Grenada',
'Grenada', 'GD', 'GRD', 'country',
1),
(87, 'country_Guadeloupe_87', 'Guadeloupe',
'Guadeloupe', 'GP', 'GLP', 'state',
1),
(88, 'country_Guam_88', 'Guam', 'Guam',
'GU', 'GUM', 'country', 1),
(89, 'country_Guatemala_89', 'Guatemala',
'Guatemala', 'GT', 'GTM',
'country', 1),
(90, 'country_Guinea_90', 'Guinée',
'Guinea', 'GN', 'GIN', 'country',
1),
(91, 'country_Guinea_Bissau_91', 'Guiné-Bissau',
'Guinea-Bissau', 'GW', 'GNB',
'country', 1),
(92, 'country_Guyana_92', 'Guyana', 'Guyana',
'GY', 'GUY', 'country', 1),
(93, 'country_Haiti_93', 'HaĂŻti âą Ayiti',
'Haiti', 'HT', 'HTI', 'country',
1),
(94, 'country_Heard_and_McDonald_Islands_94', 'Heard and
McDonald Islands', 'Heard and McDonald Islands',
'HM', 'HMD', 'country', 1),
(95, 'country_Honduras_95', 'Honduras',
'Honduras', 'HN', 'HND', 'country',
1),
(96, 'country_Hong_Kong_96', 'éŠæžŻ', 'Hong
Kong', 'HK', 'HKG', 'country', 1),
(97, 'country_Hungary_97', 'MagyarorszĂĄg',
'Hungary', 'HU', 'HUN', 'country',
1),
(98, 'country_Iceland_98', 'Ăsland',
'Iceland', 'IS', 'ISL', 'country',
1),
(99, 'country_India_99', 'à€à€Ÿà€°à€€',
'India', 'IN', 'IND', 'country',
1),
(100, 'country_Indonesia_100', 'Indonesia',
'Indonesia', 'ID', 'IDN',
'country', 1),
(101, 'country_Iran_101', 'ۧÙ۱ۧÙ',
'Iran', 'IR', 'IRN', 'country',
1),
(102, 'country_Iraq_102', 'ŰčÛŰ±Ű§Ù âą
ۧÙŰč۱ۧÙ', 'Iraq', 'IQ', 'IRQ',
'country', 1),
(103, 'country_Ireland_103', 'Ăire',
'Ireland', 'IE', 'IRL', 'country',
1),
(104, 'country_Israel_104', 'ۄ۳۱ۧۊÙÙ âą
ŚŚ©ŚšŚŚ', 'Israel', 'IL', 'ISR',
'country', 1),
(105, 'country_Italy_105', 'Italia', 'Italy',
'IT', 'ITA', 'country', 1),
(106, 'country_Jamaica_106', 'Jamaica',
'Jamaica', 'JM', 'JAM', 'country',
1),
(107, 'country_Japan_107', 'æ„æŹ', 'Japan',
'JP', 'JPN', 'country', 1),
(108, 'country_Jordan_108', 'ۧÙۣ۱ۯÙÙ',
'Jordan', 'JO', 'JOR', 'country',
1),
(109, 'country_Kazakhstan_109', 'ÒазаÒŃŃĐ°Đœ',
'Kazakhstan', 'KZ', 'KAZ',
'country', 1),
(110, 'country_Kenya_110', 'Kenya', 'Kenya',
'KE', 'KEN', 'country', 1),
(111, 'country_Kiribati_111', 'Kiribati',
'Kiribati', 'KI', 'KIR', 'country',
1),
(112, 'country_Korea__North_112', 'ë¶ìĄ°ì ',
'Korea, North', 'KP', 'PRK',
'country', 1),
(113, 'country_Korea__South_113', 'íê”',
'Korea, South', 'KR', 'KOR',
'country', 1),
(114, 'country_Kuwait_114', 'ۧÙÙÙÙŰȘ',
'Kuwait', 'KW', 'KWT', 'country',
1),
(115, 'country_Kyrgyzstan_115', 'ĐŃŃĐłŃĐ·ŃŃĐ°Đœ',
'Kyrgyzstan', 'KG', 'KGZ',
'country', 1),
(116, 'country_Laos_116', 'à»àșĄàș·àșàșàș„àșČàș§',
'Laos', 'LA', 'LAO', 'country',
1),
(117, 'country_Latvia_117', 'Latvija',
'Latvia', 'LV', 'LVA', 'country',
1),
(118, 'country_Lebanon_118', 'ÙŰšÙۧÙ',
'Lebanon', 'LB', 'LBN', 'country',
1),
(119, 'country_Lesotho_119', 'Lesotho',
'Lesotho', 'LS', 'LSO', 'country',
1),
(120, 'country_Liberia_120', 'Liberia',
'Liberia', 'LR', 'LBR', 'country',
1),
(121, 'country_Libyan_Arab_Jamahiriya_121', 'Libyan Arab
Jamahiriya', 'Libyan Arab Jamahiriya', 'LY',
'LBY', 'country', 1),
(122, 'country_Liechtenstein_122', 'Liechtenstein',
'Liechtenstein', 'LI', 'LIE',
'country', 1),
(123, 'country_Lithuania_123', 'Lietuva',
'Lithuania', 'LT', 'LTU',
'country', 1),
(124, 'country_Luxembourg_124', 'Luxemburg âą
Lëtzebuerg', 'Luxembourg', 'LU', 'LUX',
'country', 1),
(125, 'country_Macau_125', 'æŸłéš âą æŸłé',
'Macau', 'MO', 'MAC', 'country',
1),
(126, 'country_Macedonia_126', 'ĐаĐșĐ”ĐŽĐŸĐœĐžŃа',
'Macedonia', 'MK', 'MKD',
'country', 1),
(127, 'country_Madagascar_127', 'Madagasikara',
'Madagascar', 'MG', 'MDG',
'country', 1),
(128, 'country_Malawi_128', 'MalaƔi',
'Malawi', 'MW', 'MWI', 'country',
1),
(129, 'country_Malaysia_129', 'Malaysia',
'Malaysia', 'MY', 'MYS', 'country',
1),
(130, 'country_Maldives_130',
'ȚȚšȚȚŹȚȚšȚȚ§ȚȚ°ȚȚŹ', 'Maldives', 'MV',
'MDV', 'country', 1),
(131, 'country_Mali_131', 'Mali', 'Mali',
'ML', 'MLI', 'country', 1),
(132, 'country_Malta_132', 'Malta', 'Malta',
'MT', 'MLT', 'country', 1),
(133, 'country_Marshall_Islands_133', 'AelĆnÌ in
M̧ajeČ', 'Marshall Islands', 'MH',
'MHL', 'country', 1),
(134, 'country_Martinique_134', 'Martinique',
'Martinique', 'MQ', 'MTQ', 'state',
1),
(135, 'country_Mauritania_135', 'Ù
Ù۱ÙŰȘۧÙÙۧ âą
Mauritanie', 'Mauritania', 'MR', 'MRT',
'country', 1),
(136, 'country_Mauritius_136', 'Maurice',
'Mauritius', 'MU', 'MUS',
'country', 1),
(137, 'country_Mayotte_137', 'Mayotte',
'Mayotte', 'YT', 'MYT', 'country',
1),
(138, 'country_Mexico_138', 'MĂ©xico âą MÄxihco',
'Mexico', 'MX', 'MEX', 'country',
1),
(139, 'country_Micronesia_139', 'Micronesia',
'Micronesia', 'FM', 'FSM',
'country', 1),
(140, 'country_Moldova_140', 'Moldova',
'Moldova', 'MD', 'MDA', 'country',
1),
(141, 'country_Monaco_141', 'Monaco',
'Monaco', 'MC', 'MCO', 'country',
1),
(142, 'country_Mongolia_142', 'ĐĐŸĐœĐłĐŸĐ» ŃĐ»Ń',
'Mongolia', 'MN', 'MNG', 'country',
1),
(143, 'country_Montserrat_143', 'Montserrat',
'Montserrat', 'MS', 'MSR',
'country', 1),
(144, 'country_Morocco_144', 'ۧÙÙ
Űș۱ۚ',
'Morocco', 'MA', 'MAR', 'country',
1),
(145, 'country_Mozambique_145', 'Moçambique',
'Mozambique', 'MZ', 'MOZ',
'country', 1),
(146, 'country_Myanmar_146', 'Myanmar',
'Myanmar', 'MM', 'MMR', 'country',
1),
(147, 'country_Namibia_147', 'Namibia',
'Namibia', 'NA', 'NAM', 'country',
1),
(148, 'country_Nauru_148', 'Nauru', 'Nauru',
'NR', 'NRU', 'country', 1),
(149, 'country_Nepal_149', 'à€šà„à€Șà€Ÿà€Č',
'Nepal', 'NP', 'NPL', 'country',
1),
(150, 'country_Netherlands_150', 'Nederland',
'Netherlands', 'NL', 'NLD',
'country', 1),
(151, 'country_Netherlands_Antilles_151', 'Netherlands
Antilles', 'Netherlands Antilles', 'AN',
'ANT', 'country', 1),
(152, 'country_New_Caledonia_152',
'Nouvelle-Calédonie', 'New Caledonia', 'NC',
'NCL', 'country', 1),
(153, 'country_New_Zealand_153', 'Aotearoa', 'New
Zealand', 'NZ', 'NZL', 'country', 1),
(154, 'country_Nicaragua_154', 'Nicaragua',
'Nicaragua', 'NI', 'NIC',
'country', 1),
(155, 'country_Niger_155', 'Niger', 'Niger',
'NE', 'NER', 'country', 1),
(156, 'country_Nigeria_156', 'Nigeria',
'Nigeria', 'NG', 'NGA', 'country',
1),
(157, 'country_Niue_157', 'Niue', 'Niue',
'NU', 'NIU', 'country', 1),
(158, 'country_Norfolk_Island_158', 'Norfolk Island',
'Norfolk Island', 'NF', 'NFK',
'country', 1),
(159, 'country_Northern_Mariana_Islands_159', 'Northern
Mariana Islands', 'Northern Mariana Islands',
'MP', 'MNP', 'country', 1),
(160, 'country_Norway_160', 'Norge / Noreg',
'Norway', 'NO', 'NOR', 'country',
1),
(161, 'country_Oman_161', 'ŰčÙ
ۧÙ', 'Oman',
'OM', 'OMN', 'country', 1),
(162, 'country_Pakistan_162', 'ÙŸŰ§Ú©ŰłŰȘۧÙ',
'Pakistan', 'PK', 'PAK', 'country',
1),
(163, 'country_Palau_163', 'Belau', 'Palau',
'PW', 'PLW', 'country', 1),
(164, 'country_Panama_164', 'PanamĂĄ',
'Panama', 'PA', 'PAN', 'country',
1),
(165, 'country_Papua_New_Guinea_165', 'Papua Niugini',
'Papua New Guinea', 'PG', 'PNG',
'country', 1),
(166, 'country_Paraguay_166', 'ParaguĂĄi',
'Paraguay', 'PY', 'PRY', 'country',
1),
(167, 'country_Peru_167', 'PerĂș', 'Peru',
'PE', 'PER', 'country', 1),
(168, 'country_Philippines_168', 'Pilipinas',
'Philippines', 'PH', 'PHL',
'country', 1),
(169, 'country_Pitcairn_169', 'Pitcairn',
'Pitcairn', 'PN', 'PCN', 'country',
1),
(170, 'country_Poland_170', 'Polska',
'Poland', 'PL', 'POL', 'country',
1),
(171, 'country_Portugal_171', 'Portugal',
'Portugal', 'PT', 'PRT', 'country',
1),
(172, 'country_Puerto_Rico_172', 'Puerto Rico',
'Puerto Rico', 'PR', 'PRI',
'country', 1),
(173, 'country_Qatar_173', 'ŰŻÙÙŰ© Ù۷۱',
'Qatar', 'QA', 'QAT', 'country',
1),
(174, 'country_Reunion_174', 'Reunion',
'Reunion', 'RE', 'REU', 'state',
1),
(175, 'country_Romania_175', 'RomĂąnia',
'Romania', 'RO', 'ROM', 'country',
1),
(176, 'country_Russia_176', 'Đ ĐŸŃŃĐžŃ',
'Russia', 'RU', 'RUS', 'country',
1),
(177, 'country_Rwanda_177', 'Rwanda',
'Rwanda', 'RW', 'RWA', 'country',
1),
(178, 'country_Saint_Kitts_and_Nevis_178', 'Saint Kitts and
Nevis', 'Saint Kitts and Nevis', 'KN',
'KNA', 'country', 1),
(179, 'country_Saint_Lucia_179', 'Saint Lucia',
'Saint Lucia', 'LC', 'LCA',
'country', 1),
(180, 'country_Saint_Vincent_and_the_Grenadines_180', 'Saint
Vincent and the Grenadines', 'Saint Vincent and the
Grenadines', 'VC', 'VCT', 'country',
1),
(181, 'country_Samoa_181', 'SÄmoa', 'Samoa',
'WS', 'WSM', 'country', 1),
(182, 'country_San_Marino_182', 'San Marino', 'San
Marino', 'SM', 'SMR', 'country', 1),
(183, 'country_Sao_Tome_and_Principe_183', 'São Tomé e
PrĂncipe', 'Sao Tome and Principe', 'ST',
'STP', 'country', 1),
(184, 'country_Saudi_Arabia_184', 'ۧÙŰč۱ۚÙŰ©
ۧÙŰłŰčÙŰŻÙŰ©', 'Saudi Arabia', 'SA',
'SAU', 'country', 1),
(185, 'country_Senegal_185', 'Sénégal',
'Senegal', 'SN', 'SEN', 'country',
1),
(186, 'country_Seychelles_186', 'Sesel',
'Seychelles', 'SC', 'SYC',
'country', 1),
(187, 'country_Sierra_Leone_187', 'Sierra Leone',
'Sierra Leone', 'SL', 'SLE',
'country', 1),
(188, 'country_Singapore_188', 'æ°ć ćĄ âą Singapura âą
àźàźżàźàŻàźàźȘàŻàźȘàŻàź°àŻ', 'Singapore',
'SG', 'SGP', 'country', 1),
(189, 'country_Slovakia_189', 'Slovensko',
'Slovakia', 'SK', 'SVK', 'country',
1),
(190, 'country_Slovenia_190', 'Slovenija',
'Slovenia', 'SI', 'SVN', 'country',
1),
(191, 'country_Solomon_Islands_191', 'Solomon Islands',
'Solomon Islands', 'SB', 'SLB',
'country', 1),
(192, 'country_Somalia_192', 'Soomaaliya âą
ۧÙŰ”ÙÙ
ۧÙ', 'Somalia', 'SO', 'SOM',
'country', 1),
(193, 'country_South_Africa_193', 'Suid-Afrika',
'South Africa', 'ZA', 'ZAF',
'country', 1),
(194, 'country_South_Georgia_and_the_South_Sandwich_Islands_194',
'South Georgia and the South Sandwich Islands', 'South
Georgia and the South Sandwich Islands', 'GS',
'SGS', 'country', 0),
(195, 'country_Spain_195', 'España',
'Spain', 'ES', 'ESP', 'country',
1),
(196, 'country_Sri_Lanka_196', 'à·à·âà¶»à·
à¶œà¶à¶à·à· âą àźàźČàźàŻàźàŻ', 'Sri Lanka',
'LK', 'LKA', 'country', 1),
(197, 'country_St__Helena_197', 'St. Helena', 'St.
Helena', 'SH', 'SHN', 'country', 1),
(198, 'country_St__Pierre_and_Miquelon_198', 'St. Pierre and
Miquelon', 'St. Pierre and Miquelon', 'PM',
'SPM', 'country', 1),
(199, 'country_Sudan_199', 'ۧÙŰłÙۯۧÙ',
'Sudan', 'SD', 'SDN', 'country',
1),
(200, 'country_Suriname_200', 'Suriname',
'Suriname', 'SR', 'SUR', 'country',
1),
(201, 'country_Svalbard_and_Jan_Mayen_Islands_201',
'Svalbard and Jan Mayen Islands', 'Svalbard and Jan Mayen
Islands', 'SJ', 'SJM', 'country', 1),
(202, 'country_Swaziland_202', 'eSwatini',
'Swaziland', 'SZ', 'SWZ',
'country', 1),
(203, 'country_Sweden_203', 'Sverige',
'Sweden', 'SE', 'SWE', 'country',
1),
(204, 'country_Switzerland_204', 'Schweiz âą Suisse âą
Svizzera âą Svizra', 'Switzerland', 'CH',
'CHE', 'country', 1),
(205, 'country_Syrian_Arab_Republic_205',
'ŰłÙ۱ÙŰ©â', 'Syrian Arab Republic',
'SY', 'SYR', 'country', 1),
(206, 'country_Taiwan_206', 'èșçŁ âą ć°çŁ',
'Taiwan', 'TW', 'TWN', 'country',
1),
(207, 'country_Tajikistan_207', 'ĐąĐŸÒ·ĐžĐșĐžŃŃĐŸĐœ',
'Tajikistan', 'TJ', 'TJK',
'country', 1),
(208, 'country_Tanzania_208', 'Tanzania',
'Tanzania', 'TZ', 'TZA', 'country',
1),
(209, 'country_Thailand_209',
'àžàžŁàž°àčàžàžšàčàžàžą', 'Thailand',
'TH', 'THA', 'country', 1),
(210, 'country_Togo_210', 'Togo', 'Togo',
'TG', 'TGO', 'country', 1),
(211, 'country_Tokelau_211', 'Tokelau',
'Tokelau', 'TK', 'TKL', 'country',
1),
(212, 'country_Tonga_212', 'Tonga', 'Tonga',
'TO', 'TON', 'country', 1),
(213, 'country_Trinidad_and_Tobago_213', 'Trinidad and
Tobago', 'Trinidad and Tobago', 'TT',
'TTO', 'country', 1),
(214, 'country_Tunisia_214', 'ŰȘÙÙŰłâ',
'Tunisia', 'TN', 'TUN', 'country',
1),
(215, 'country_Turkey_215', 'TĂŒrkiye',
'Turkey', 'TR', 'TUR', 'country',
1),
(216, 'country_Turkmenistan_216', 'TĂŒrkmenistan',
'Turkmenistan', 'TM', 'TKM',
'country', 1),
(217, 'country_Turks_and_Caicos_Islands_217', 'Turks and
Caicos Islands', 'Turks and Caicos Islands', 'TC',
'TCA', 'country', 1),
(218, 'country_Tuvalu_218', 'Tuvalu',
'Tuvalu', 'TV', 'TUV', 'country',
1),
(219, 'country_Uganda_219', 'Uganda',
'Uganda', 'UG', 'UGA', 'country',
1),
(220, 'country_Ukraine_220', 'ĐŁĐșŃаŃĐœĐ°',
'Ukraine', 'UA', 'UKR', 'country',
1),
(221, 'country_United_Arab_Emirates_221', 'ۧÙŰ„Ù
ۧ۱ۧŰȘ
ۧÙŰč۱ۚÙŰ© ۧÙÙ
ŰȘŰŰŻŰ©', 'United Arab Emirates',
'AE', 'ARE', 'country', 1),
(222, 'country_United_Kingdom_222', 'United Kingdom',
'United Kingdom', 'GB', 'GBR',
'country', 1),
(223, 'country_United_States_of_America_223', 'United States
of America', 'United States of America', 'US',
'USA', 'country', 1),
(224, 'country_United_States_Minor_Outlying_Islands_224',
'United States Minor Outlying Islands', 'United States Minor
Outlying Islands', 'UM', 'UMI',
'country', 1),
(225, 'country_Uruguay_225', 'Uruguay',
'Uruguay', 'UY', 'URY', 'country',
1),
(226, 'country_Uzbekistan_226', 'Oʻzbekiston',
'Uzbekistan', 'UZ', 'UZB',
'country', 1),
(227, 'country_Vanuatu_227', 'Vanuatu',
'Vanuatu', 'VU', 'VUT', 'country',
1),
(228, 'country_Vatican_City_State__Holy_See__228',
'Vaticanum', 'Vatican City State', 'VA',
'VAT', 'country', 1),
(229, 'country_Venezuela_229', 'Venezuela',
'Venezuela', 'VE', 'VEN',
'country', 1),
(230, 'country_Vietnam_230', 'Viá»t Nam',
'Vietnam', 'VN', 'VNM', 'country',
1),
(231, 'country_Virgin_Islands__British__231', 'Virgin
Islands (British)', 'Virgin Islands (British)',
'VG', 'VGB', 'country', 1),
(232, 'country_Virgin_Islands__U_S___232', 'Virgin Islands
(U.S.)', 'Virgin Islands (U.S.)', 'VI',
'VIR', 'country', 1),
(233, 'country_Wallis_and_Futuna_Islands_233', 'Wallis and
Futuna Islands', 'Wallis and Futuna Islands',
'WF', 'WLF', 'country', 1),
(234, 'country_Western_Sahara_234', 'ۧÙŰ”Ű۱ۧۥ
ۧÙŰș۱ۚÙŰ©', 'Western Sahara', 'EH',
'ESH', 'country', 1),
(235, 'country_Yemen_235', 'ۧÙÙÙ
Ù',
'Yemen', 'YE', 'YEM', 'country',
1),
(236, 'country_Yugoslavia_236', 'Yugoslavia',
'Yugoslavia', 'YU', 'YUG',
'country', 0),
(237, 'country_Zaire_237', 'Zaire', 'Zaire',
'ZR', 'ZAR', 'country', 1),
(238, 'country_Zambia_238', 'Zambia',
'Zambia', 'ZM', 'ZMB', 'country',
1),
(239, 'country_Zimbabwe_239', 'Zimbabwe',
'Zimbabwe', 'ZW', 'ZWE', 'country',
1),
(240, 'state_______________240', 'ۚۯ ۟ێۧÙ',
'ۚۯ ۟ێۧÙ', '', 'BDS',
'state', 1),
(241, 'state______________241', 'ۚۧۯŰșÛŰł',
'ۚۧۯŰșÛŰł', '', 'BDG', 'state',
1),
(242, 'state____________242', 'ŰšŰșÙۧÙ',
'ŰšŰșÙۧÙ', '', 'BGL', 'state',
1),
(243, 'state________243', 'ŰšÙŰź', 'ŰšÙŰź',
'', 'BAL', 'state', 1),
(244, 'state______________244', 'ۚۧÙ
ÛۧÙ',
'ۚۧÙ
ÛۧÙ', '', 'BAM', 'state',
1),
(245, 'state________________245', 'ۯۧÛÚ©ÙŰŻÛ',
'ۯۧÛÚ©ÙŰŻÛ', '', 'DAY',
'state', 1),
(246, 'state__________246', 'Ù۱ۧÙ',
'Ù۱ۧÙ', '', 'FRA', 'state',
1),
(247, 'state______________247', 'Ùۧ۱Ùۧۚ',
'Ùۧ۱Ùۧۚ', '', 'FYB', 'state',
1),
(248, 'state__________248', 'ŰșŰČÙÙ',
'ŰșŰČÙÙ', '', 'GHA', 'state',
1),
(249, 'state________249', 'ŰșÙ۱', 'ŰșÙ۱',
'', 'GHO', 'state', 1),
(250, 'state____________250', 'ÙÙÙ
ÙŰŻ',
'ÙÙÙ
ÙŰŻ', '', 'HEL', 'state',
1),
(251, 'state__________251', 'Ù۱ۧŰȘ',
'Ù۱ۧŰȘ', '', 'HER', 'state',
1),
(252, 'state______________252', 'ŰŹÙŰČۏۧÙ',
'ŰŹÙŰČۏۧÙ', '', 'JOW', 'state',
1),
(253, 'state__________253', 'کۧۚÙ',
'کۧۚÙ', '', 'KAB', 'state',
1),
(254, 'state______________254', 'ÙÙŰŻÚŸŰ§Ű±',
'ÙÙŰŻÚŸŰ§Ű±', '', 'KAN', 'state',
1),
(255, 'state______________255', 'Ú©Ű§ÙŸÙ۳ۧ',
'Ú©Ű§ÙŸÙ۳ۧ', '', 'KAP', 'state',
1),
(256, 'state__________256', 'ŰźÙŰłŰȘ',
'ŰźÙŰłŰȘ', '', 'KHO', 'state',
1),
(257, 'state____________257', 'Ú©ÙÙÙ۱',
'Ú©ÙÙÙ۱', '', 'KNR', 'state',
1),
(258, 'state____________258', 'ÙÙŰŻÙŰČ',
'ÙÙŰŻÙŰČ', '', 'KDZ', 'state',
1),
(259, 'state____________259', 'ÙŰșÙ
ۧÙ',
'ÙŰșÙ
ۧÙ', '', 'LAG', 'state',
1),
(260, 'state__________260', 'ÙÙګ۱',
'ÙÙګ۱', '', 'LOW', 'state',
1),
(261, 'state________________261', 'ÙÙگ۱Ùۧ۱',
'ÙÙگ۱Ùۧ۱', '', 'NAN',
'state', 1),
(262, 'state______________262', 'ÙÛÙ
۱ÙŰČ',
'ÙÛÙ
۱ÙŰČ', '', 'NIM', 'state',
1),
(263, 'state________________263', 'ÙÙ۱۳ŰȘۧÙ',
'ÙÙ۱۳ŰȘۧÙ', '', 'NUR',
'state', 1),
(264, 'state________________264', 'ۀ۱ÙŰČگۧÙ',
'ۀ۱ÙŰČگۧÙ', '', 'ORU',
'state', 1),
(265, 'state____________265', 'ÙŸÚ©ŰȘÛۧ',
'ÙŸÚ©ŰȘÛۧ', '', 'PIA', 'state',
1),
(266, 'state______________266', 'ÙŸÚ©ŰȘÙکۧ',
'ÙŸÚ©ŰȘÙکۧ', '', 'PKA', 'state',
1),
(267, 'state_______________267', 'ÙŸÙŰŹ ŰŽÛ۱',
'ÙŸÙŰŹ ŰŽÛ۱', '', 'PAN',
'state', 1),
(268, 'state____________268', 'ÙŸŰ±ÙۧÙ',
'ÙŸŰ±ÙۧÙ', '', 'PAR', 'state',
1),
(269, 'state______________269', 'ŰłÙ
ÙگۧÙ',
'ŰłÙ
ÙگۧÙ', '', 'SAM', 'state',
1),
(270, 'state___________270', '۳۱ ÙŸÙ', '۳۱
ÙŸÙ', '', 'SAR', 'state', 1),
(271, 'state__________271', 'ŰȘ۟ۧ۱',
'ŰȘ۟ۧ۱', '', 'TAK', 'state',
1),
(272, 'state__________272', 'Ù۱ۯک',
'Ù۱ۯک', '', 'WAR', 'state',
1),
(273, 'state__________273', 'ŰČۧۚÙ',
'ŰČۧۚÙ', '', 'ZAB', 'state',
1),
(274, 'state_Beratit_274', 'Beratit',
'Beratit', '', 'BR', 'state', 1),
(275, 'state_Bulqiz__s_275', 'Bulqizës',
'Bulqizës', '', 'BU', 'state',
1),
(276, 'state_Dibr__s_276', 'Dibrës',
'Dibrës', '', 'DI', 'state', 1),
(277, 'state_Delvin__s_277', 'Delvinës',
'Delvinës', '', 'DL', 'state',
1),
(278, 'state_Durr__sit_278', 'Durrësit',
'Durrësit', '', 'DR', 'state',
1),
(279, 'state_Devollit_279', 'Devollit',
'Devollit', '', 'DV', 'state', 1),
(280, 'state_Elbasanit_280', 'Elbasanit',
'Elbasanit', '', 'EL', 'state',
1),
(281, 'state_Kolonj__s_281', 'Kolonjës',
'Kolonjës', '', 'ER', 'state',
1),
(282, 'state_Fierit_282', 'Fierit', 'Fierit',
'', 'FR', 'state', 1),
(283, 'state_Gjirokastr__s_283', 'Gjirokastrës',
'Gjirokastrës', '', 'GJ', 'state',
1),
(284, 'state_Gramshit_284', 'Gramshit',
'Gramshit', '', 'GR', 'state', 1),
(285, 'state_Hasit_285', 'Hasit', 'Hasit',
'', 'HA', 'state', 1),
(286, 'state_Kavaj__s_286', 'Kavajës',
'Kavajës', '', 'KA', 'state', 1),
(287, 'state_Kurbinit_287', 'Kurbinit',
'Kurbinit', '', 'KB', 'state', 1),
(288, 'state_Ku__ov__s_288', 'Kuçovës',
'Kuçovës', '', 'KC', 'state',
1),
(289, 'state_Kor____s_289', 'Korçës',
'Korçës', '', 'KO', 'state', 1),
(290, 'state_Kruj__s_290', 'Krujës',
'Krujës', '', 'KR', 'state', 1),
(291, 'state_Kuk__sit_291', 'Kukësit',
'Kukësit', '', 'KU', 'state', 1),
(292, 'state_Librazhdit_292', 'Librazhdit',
'Librazhdit', '', 'LB', 'state',
1),
(293, 'state_Lezh__s_293', 'Lezhës',
'Lezhës', '', 'LE', 'state', 1),
(294, 'state_Lushnj__s_294', 'Lushnjës',
'Lushnjës', '', 'LU', 'state',
1),
(295, 'state_Mallakastr__s_295', 'Mallakastrës',
'Mallakastrës', '', 'MK', 'state',
1),
(296, 'state_Mal__sis___s___Madhe_296', 'Malësisë së
Madhe', 'Malësisë së Madhe', '',
'MM', 'state', 1),
(297, 'state_Mirdit__s_297', 'Mirditës',
'Mirditës', '', 'MR', 'state',
1),
(298, 'state_Matit_298', 'Matit', 'Matit',
'', 'MT', 'state', 1),
(299, 'state_Pogradecit_299', 'Pogradecit',
'Pogradecit', '', 'PG', 'state',
1),
(300, 'state_Peqinit_300', 'Peqinit',
'Peqinit', '', 'PQ', 'state', 1),
(301, 'state_P__rmetit_301', 'Përmetit',
'Përmetit', '', 'PR', 'state',
1),
(302, 'state_Puk__s_302', 'Pukës', 'Pukës',
'', 'PU', 'state', 1),
(303, 'state_Shkodr__s_303', 'Shkodrës',
'Shkodrës', '', 'SH', 'state',
1),
(304, 'state_Skraparit_304', 'Skraparit',
'Skraparit', '', 'SK', 'state',
1),
(305, 'state_Sarand__s_305', 'Sarandës',
'Sarandës', '', 'SR', 'state',
1),
(306, 'state_Tepelen__s_306', 'Tepelenës',
'Tepelenës', '', 'TE', 'state',
1),
(307, 'state_Tropoj__s_307', 'Tropojës',
'Tropojës', '', 'TP', 'state',
1),
(308, 'state_Tiran__s_308', 'Tiranës',
'Tiranës', '', 'TR', 'state', 1),
(309, 'state_Vlor__s_309', 'Vlorës',
'Vlorës', '', 'VL', 'state', 1),
(310, 'state_______________________310', 'ÙÙۧÙŰ©
ۣۯ۱ۧ۱', 'ÙÙۧÙŰ© ۣۯ۱ۧ۱', '',
'01', 'state', 1),
(311, 'state_______________________311', 'ÙÙۧÙŰ©
ۧÙŰŽÙÙ', 'ÙÙۧÙŰ© ۧÙŰŽÙÙ', '',
'02', 'state', 1),
(312, 'state___________________________312', 'ÙÙۧÙŰ©
ۧÙŰŁŰșÙۧ۷', 'ÙÙۧÙŰ© ۧÙŰŁŰșÙۧ۷', '',
'03', 'state', 1),
(313, 'state________________________________313',
'ÙÙۧÙŰ© ŰŁÙ
ۧÙŰšÙۧÙÙ', 'ÙÙۧÙŰ© ŰŁÙ
ۧÙŰšÙۧÙÙ', '', '04', 'state', 1),
(314, 'state_______________________314', 'ÙÙۧÙŰ©
ۚۧŰȘÙŰ©', 'ÙÙۧÙŰ© ۚۧŰȘÙŰ©', '',
'05', 'state', 1),
(315, 'state_______________________315', 'ÙÙۧÙŰ©
ۚۏۧÙŰ©', 'ÙÙۧÙŰ© ۚۏۧÙŰ©', '',
'06', 'state', 1),
(316, 'state_______________________316', 'ÙÙۧÙŰ©
ۚ۳Ù۱۩', 'ÙÙۧÙŰ© ۚ۳Ù۱۩', '',
'07', 'state', 1),
(317, 'state_____________________317', 'ÙÙۧÙŰ©
ۚێۧ۱', 'ÙÙۧÙŰ© ۚێۧ۱', '',
'08', 'state', 1),
(318, 'state___________________318',
'ۧÙŰšÙÙŰŻŰ©â', 'ۧÙŰšÙÙŰŻŰ©â', '',
'09', 'state', 1),
(319, 'state___________________________319', 'ÙÙۧÙŰ©
ۧÙŰšÙÙ۱۩', 'ÙÙۧÙŰ© ۧÙŰšÙÙ۱۩', '',
'10', 'state', 1),
(320, 'state___________________________320', 'ÙÙۧÙŰ©
ŰȘÙ
Ù۱ۧ۳ŰȘ', 'ÙÙۧÙŰ© ŰȘÙ
Ù۱ۧ۳ŰȘ', '',
'11', 'state', 1),
(321, 'state_____________________321', 'ÙÙۧÙŰ©
ŰȘۚ۳۩', 'ÙÙۧÙŰ© ŰȘۚ۳۩', '',
'12', 'state', 1),
(322, 'state______________322', 'ŰȘÙÙ
۳ۧÙ',
'ŰȘÙÙ
۳ۧÙ', '', '13', 'state',
1),
(323, 'state_______________________323', 'ÙÙۧÙŰ©
ŰȘÙۧ۱ŰȘ', 'ÙÙۧÙŰ© ŰȘÙۧ۱ŰȘ', '',
'14', 'state', 1),
(324, 'state_________________324', 'ŰȘÙŰČÙ ÙŰČÙ',
'ŰȘÙŰČÙ ÙŰČÙ', '', '15',
'state', 1),
(325, 'state___________________________325', 'ÙÙۧÙŰ©
ۧÙŰŹŰČۧۊ۱', 'ÙÙۧÙŰ© ۧÙŰŹŰČۧۊ۱', '',
'16', 'state', 1),
(326, 'state________________________________326',
'ÙÙۧÙŰ© ŰčÙÙ Ű§ÙŰŻÙÙÙ', 'ÙÙۧÙŰ© ŰčÙÙ
ۧÙŰŻÙÙÙ', '', '17', 'state', 1),
(327, 'state_____________________327', 'ÙÙۧÙŰ©
ŰŹÙŰŹÙ', 'ÙÙۧÙŰ© ŰŹÙŰŹÙ', '',
'18', 'state', 1),
(328, 'state_____________________328', 'ÙÙۧÙŰ©
۳۷ÙÙ', 'ÙÙۧÙŰ© ۳۷ÙÙ', '',
'19', 'state', 1),
(329, 'state_______________________329', 'ÙÙۧÙŰ©
ŰłŰčÙŰŻŰ©', 'ÙÙۧÙŰ© ŰłŰčÙŰŻŰ©', '',
'20', 'state', 1),
(330, 'state__________________330', 'ۧÙŰłÙÙÙŰŻŰ©',
'ۧÙŰłÙÙÙŰŻŰ©', '', '21',
'state', 1),
(331, 'state__________________________________331',
'ÙÙۧÙŰ© ŰłÙŰŻÙ ŰšÙŰčۚۧ۳', 'ÙÙۧÙŰ© ŰłÙŰŻÙ
ŰšÙŰčۚۧ۳', '', '22', 'state', 1),
(332, 'state_______________________332', 'ÙÙۧÙŰ©
ŰčÙۧۚ۩', 'ÙÙۧÙŰ© ŰčÙۧۚ۩', '',
'23', 'state', 1),
(333, 'state_______________________333', 'ÙÙۧÙŰ©
ÙۧÙÙ
Ű©', 'ÙÙۧÙŰ© ÙۧÙÙ
Ű©', '',
'24', 'state', 1),
(334, 'state________________334', 'ÙŰłÙŰ·ÙÙŰ©',
'ÙŰłÙŰ·ÙÙŰ©', '', '25',
'state', 1),
(335, 'state_________________________335', 'ÙÙۧÙŰ©
ۧÙÙ
ŰŻÙŰ©', 'ÙÙۧÙŰ© ۧÙÙ
ŰŻÙŰ©', '',
'26', 'state', 1),
(336, 'state___________________________336', 'ÙÙۧÙŰ©
Ù
ŰłŰȘŰșۧÙÙ
', 'ÙÙۧÙŰ© Ù
ŰłŰȘŰșۧÙÙ
', '',
'27', 'state', 1),
(337, 'state___________________________337', 'ÙÙۧÙŰ©
ۧÙÙ
ŰłÙÙŰ©', 'ÙÙۧÙŰ© ۧÙÙ
ŰłÙÙŰ©', '',
'28', 'state', 1),
(338, 'state_______________________338', 'ÙÙۧÙŰ©
Ù
ŰčŰłÙ۱', 'ÙÙۧÙŰ© Ù
ŰčŰłÙ۱', '',
'29', 'state', 1),
(339, 'state____________339', 'Ù۱ÙÙŰ©',
'Ù۱ÙÙŰ©', '', '30', 'state',
1),
(340, 'state____________340', 'ÙÙ۱ۧÙ',
'ÙÙ۱ۧÙ', '', '31', 'state',
1),
(341, 'state_______________________341', 'ÙÙۧÙŰ©
ۧÙŰšÙ۶', 'ÙÙۧÙŰ© ۧÙŰšÙ۶', '',
'32', 'state', 1),
(342, 'state_______________________342', 'ÙÙۧÙŰ©
ۧÙÙŰČÙ', 'ÙÙۧÙŰ© ۧÙÙŰČÙ', '',
'33', 'state', 1),
(343, 'state____________________________________343',
'ÙÙۧÙŰ© ۚ۱ۏ ŰšÙŰč۱Ù۱ÙŰŹ', 'ÙÙۧÙŰ© ۚ۱ۏ
ŰšÙŰč۱Ù۱ÙŰŹ', '', '34', 'state',
1),
(344, 'state___________________________344', 'ÙÙۧÙŰ©
ŰšÙÙ
۱ۯۧ۳', 'ÙÙۧÙŰ© ŰšÙÙ
۱ۯۧ۳', '',
'35', 'state', 1),
(345, 'state_________________________345', 'ÙÙۧÙŰ©
ۧÙ۷ۧ۱Ù', 'ÙÙۧÙŰ© ۧÙ۷ۧ۱Ù', '',
'36', 'state', 1),
(346, 'state____________346', 'ŰȘÙŰŻÙÙ',
'ŰȘÙŰŻÙÙ', '', '37', 'state',
1),
(347, 'state___________________________347', 'ÙÙۧÙŰ©
ŰȘŰłÙ
ŰłÙÙŰȘ', 'ÙÙۧÙŰ© ŰȘŰłÙ
ŰłÙÙŰȘ', '',
'38', 'state', 1),
(348, 'state_________________________348', 'ÙÙۧÙŰ©
ۧÙÙۧۯÙ', 'ÙÙۧÙŰ© ۧÙÙۧۯÙ', '',
'39', 'state', 1),
(349, 'state_______________________349', 'ÙÙۧÙŰ©
ŰźÙŰŽÙŰ©', 'ÙÙۧÙŰ© ŰźÙŰŽÙŰ©', '',
'40', 'state', 1),
(350, 'state______________________________350', 'ÙÙۧÙŰ©
ŰłÙÙ ŰŁÙ۱ۧ۳', 'ÙÙۧÙŰ© ŰłÙÙ ŰŁÙ۱ۧ۳',
'', '41', 'state', 1),
(351, 'state_________________________351', 'ÙÙۧÙŰ©
ŰȘÙۚۧŰČŰ©', 'ÙÙۧÙŰ© ŰȘÙۚۧŰČŰ©', '',
'42', 'state', 1),
(352, 'state_____________________352', 'ÙÙۧÙŰ©
Ù
ÙÙŰ©', 'ÙÙۧÙŰ© Ù
ÙÙŰ©', '',
'43', 'state', 1),
(353, 'state________________________________353',
'ÙÙۧÙŰ© ŰčÙÙ Ű§ÙŰŻÙÙÙ', 'ÙÙۧÙŰ© ŰčÙÙ
ۧÙŰŻÙÙÙ', '', '44', 'state', 1),
(354, 'state___________________________354', 'ÙÙۧÙŰ©
ۧÙÙŰčۧÙ
Ű©', 'ÙÙۧÙŰ© ۧÙÙŰčۧÙ
Ű©', '',
'45', 'state', 1),
(355, 'state________________________________355',
'ÙÙۧÙŰ© ŰčÙÙ ŰȘÙ
ÙŰŽÙŰȘ', 'ÙÙۧÙŰ© ŰčÙÙ
ŰȘÙ
ÙŰŽÙŰȘ', '', '46', 'state', 1),
(356, 'state_________________________356', 'ÙÙۧÙŰ©
Űș۱ۯۧÙŰ©', 'ÙÙۧÙŰ© Űș۱ۯۧÙŰ©', '',
'47', 'state', 1),
(357, 'state_________________________357', 'ÙÙۧÙŰ©
ŰșÙÙŰČۧÙ', 'ÙÙۧÙŰ© ŰșÙÙŰČۧÙ', '',
'48', 'state', 1),
(358, 'state_Eastern_358', 'Eastern',
'Eastern', '', 'EA', 'state', 1),
(359, 'state_Manu_a_359', 'Manu''a',
'Manu''a', '', 'MA',
'state', 1),
(360, 'state_Rose_Island_360', 'Rose Island',
'Rose Island', '', 'RI', 'state',
1),
(361, 'state_Swains_Island_361', 'Swains Island',
'Swains Island', '', 'SI', 'state',
1),
(362, 'state_Western_362', 'Western',
'Western', '', 'WE', 'state', 1),
(363, 'state_Andorra_la_Vella_363', 'Andorra la Vella',
'Andorra la Vella', '', 'AN',
'state', 1),
(364, 'state_Canillo_364', 'Canillo',
'Canillo', '', 'CA', 'state', 1),
(365, 'state_Encamp_365', 'Encamp', 'Encamp',
'', 'EN', 'state', 1),
(366, 'state_Escaldes_Engordany_366',
'Escaldes-Engordany', 'Escaldes-Engordany',
'', 'LE', 'state', 1),
(367, 'state_La_Massana_367', 'La Massana', 'La
Massana', '', 'LM', 'state', 1),
(368, 'state_Ordino_368', 'Ordino', 'Ordino',
'', 'OR', 'state', 1),
(369, 'state_Sant_Juli___de_L__ria_369', 'Sant JuliĂĄ de
LĂłria', 'Sant JuliĂĄ de LĂłria', '',
'SJ', 'state', 1),
(370, 'state_Bengo_370', 'Bengo', 'Bengo',
'', 'BGO', 'state', 1),
(371, 'state_Benguela_371', 'Benguela',
'Benguela', '', 'BGU', 'state',
1),
(372, 'state_Bi___372', 'Bié', 'Bié',
'', 'BIE', 'state', 1),
(373, 'state_Cabinda_373', 'Cabinda',
'Cabinda', '', 'CAB', 'state', 1),
(374, 'state_Cuando_Cubango_374', 'Cuando Cubango',
'Cuando Cubango', '', 'CCU',
'state', 1),
(375, 'state_Cuanza_Norte_375', 'Cuanza Norte',
'Cuanza Norte', '', 'CNO', 'state',
1),
(376, 'state_Cuanza_Sul_376', 'Cuanza Sul',
'Cuanza Sul', '', 'CUS', 'state',
1),
(377, 'state_Cunene_377', 'Cunene', 'Cunene',
'', 'CNN', 'state', 1),
(378, 'state_Huambo_378', 'Huambo', 'Huambo',
'', 'HUA', 'state', 1),
(379, 'state_Hu__la_379', 'HuĂla', 'HuĂla',
'', 'HUI', 'state', 1),
(380, 'state_Luanda_380', 'Luanda', 'Luanda',
'', 'LUA', 'state', 1),
(381, 'state_Lunda_Norte_381', 'Lunda Norte',
'Lunda Norte', '', 'LNO', 'state',
1),
(382, 'state_Lunda_Sul_382', 'Lunda Sul', 'Lunda
Sul', '', 'LSU', 'state', 1),
(383, 'state_Malanje_383', 'Malanje',
'Malanje', '', 'MAL', 'state', 1),
(384, 'state_Moxico_384', 'Moxico', 'Moxico',
'', 'MOX', 'state', 1),
(385, 'state_Namibe_385', 'Namibe', 'Namibe',
'', 'NAM', 'state', 1),
(386, 'state_U__ge_386', 'UĂge', 'UĂge',
'', 'UIG', 'state', 1),
(387, 'state_Zaire_387', 'Zaire', 'Zaire',
'', 'ZAI', 'state', 1),
(388, 'state_Barbuda_388', 'Barbuda',
'Barbuda', '', 'BAR', 'state', 1),
(389, 'state_Saint_George_389', 'Saint George',
'Saint George', '', 'SGE', 'state',
1),
(390, 'state_Saint_John_390', 'Saint John', 'Saint
John', '', 'SJO', 'state', 1),
(391, 'state_Saint_Mary_391', 'Saint Mary', 'Saint
Mary', '', 'SMA', 'state', 1),
(392, 'state_Saint_Paul_392', 'Saint Paul', 'Saint
Paul', '', 'SPA', 'state', 1),
(393, 'state_Saint_Peter_393', 'Saint Peter',
'Saint Peter', '', 'SPE', 'state',
1),
(394, 'state_Saint_Philip_394', 'Saint Philip',
'Saint Philip', '', 'SPH', 'state',
1),
(395, 'state_Salta_395', 'Salta', 'Salta',
'', 'A', 'state', 1),
(396, 'state_Buenos_Aires_Province_396', 'Buenos Aires
Province', 'Buenos Aires Province', '',
'B', 'state', 1),
(397, 'state_Capital_Federal_397', 'Capital Federal',
'Capital Federal', '', 'C',
'state', 1),
(398, 'state_San_Luis_398', 'San Luis', 'San
Luis', '', 'D', 'state', 1),
(399, 'state_Entre_R__os_399', 'Entre RĂos',
'Entre RĂos', '', 'E', 'state',
1),
(400, 'state_La_Rioja_400', 'La Rioja', 'La
Rioja', '', 'F', 'state', 1),
(401, 'state_Santiago_del_Estero_401', 'Santiago del
Estero', 'Santiago del Estero', '', 'G',
'state', 1),
(402, 'state_Chaco_402', 'Chaco', 'Chaco',
'', 'H', 'state', 1),
(403, 'state_San_Juan_403', 'San Juan', 'San
Juan', '', 'J', 'state', 1),
(404, 'state_Catamarca_404', 'Catamarca',
'Catamarca', '', 'K', 'state', 1),
(405, 'state_La_Pampa_405', 'La Pampa', 'La
Pampa', '', 'L', 'state', 1),
(406, 'state_Mendoza_406', 'Mendoza',
'Mendoza', '', 'M', 'state', 1),
(407, 'state_Misiones_407', 'Misiones',
'Misiones', '', 'N', 'state', 1),
(408, 'state_Formosa_408', 'Formosa',
'Formosa', '', 'P', 'state', 1),
(409, 'state_Neuqu__n_409', 'Neuquén',
'Neuquén', '', 'Q', 'state', 1),
(410, 'state_R__o_Negro_410', 'RĂo Negro', 'RĂo
Negro', '', 'R', 'state', 1),
(411, 'state_Santa_Fe_411', 'Santa Fe', 'Santa
Fe', '', 'S', 'state', 1),
(412, 'state_Tucum__n_412', 'TucumĂĄn',
'TucumĂĄn', '', 'T', 'state', 1),
(413, 'state_Chubut_413', 'Chubut', 'Chubut',
'', 'U', 'state', 1),
(414, 'state_Tierra_del_Fuego_414', 'Tierra del Fuego',
'Tierra del Fuego', '', 'V',
'state', 1),
(415, 'state_Corrientes_415', 'Corrientes',
'Corrientes', '', 'W', 'state',
1),
(416, 'state_C__rdoba_416', 'CĂłrdoba',
'CĂłrdoba', '', 'X', 'state', 1),
(417, 'state_Jujuy_417', 'Jujuy', 'Jujuy',
'', 'Y', 'state', 1),
(418, 'state_Santa_Cruz_418', 'Santa Cruz', 'Santa
Cruz', '', 'Z', 'state', 1),
(419, 'state____________________419',
'Ô±ÖŐĄŐŁŐĄŐźŐžŐżŐ¶', 'Ô±ÖŐĄŐŁŐĄŐźŐžŐżŐ¶',
'', 'AG', 'state', 1),
(420, 'state______________420', 'Ô±ÖŐĄÖŐĄŐż',
'Ô±ÖŐĄÖŐĄŐż', '', 'AR', 'state',
1),
(421, 'state________________421', 'Ô±ÖŐŽŐĄŐŸŐ«Ö',
'Ô±ÖŐŽŐĄŐŸŐ«Ö', '', 'AV',
'state', 1),
(422, 'state____________422', 'Ô”ÖÖŐĄŐ¶',
'Ô”ÖÖŐĄŐ¶', '', 'ER', 'state',
1),
(423, 'state________________________423',
'ÔłŐ„ŐČŐĄÖÖŐžÖŐ¶Ő«Ö', 'ÔłŐ„ŐČŐĄÖÖŐžÖŐ¶Ő«Ö',
'', 'GR', 'state', 1),
(424, 'state______________424', 'ÔżŐžŐżŐĄŐ”Ö',
'ÔżŐžŐżŐĄŐ”Ö', '', 'KT', 'state',
1),
(425, 'state__________425', 'ÔŒŐžŐŒŐ«',
'ÔŒŐžŐŒŐ«', '', 'LO', 'state', 1),
(426, 'state____________426', 'ŐŐ«ÖŐĄŐŻ',
'ŐŐ«ÖŐĄŐŻ', '', 'SH', 'state',
1),
(427, 'state________________427', 'ŐŐ”ŐžÖŐ¶Ő«Ö',
'ŐŐ”ŐžÖŐ¶Ő«Ö', '', 'SU',
'state', 1),
(428, 'state______________428', 'ŐŐĄŐŸŐžÖŐ·',
'ŐŐĄŐŸŐžÖŐ·', '', 'TV', 'state',
1),
(429, 'state___________________429', 'ŐŐĄŐ”ŐžÖ
ŐŐžÖ', 'ŐŐĄŐ”ŐžÖ ŐŐžÖ', '', 'VD',
'state', 1),
(430, 'state_Australian_Capital_Territory_430', 'Australian
Capital Territory', 'Australian Capital Territory',
'', 'ACT', 'state', 1),
(431, 'state_New_South_Wales_431', 'New South Wales',
'New South Wales', '', 'NSW',
'state', 1),
(432, 'state_Northern_Territory_432', 'Northern
Territory', 'Northern Territory', '',
'NT', 'state', 1),
(433, 'state_Queensland_433', 'Queensland',
'Queensland', '', 'QLD', 'state',
1),
(434, 'state_South_Australia_434', 'South Australia',
'South Australia', '', 'SA',
'state', 1),
(435, 'state_Tasmania_435', 'Tasmania',
'Tasmania', '', 'TAS', 'state',
1),
(436, 'state_Victoria_436', 'Victoria',
'Victoria', '', 'VIC', 'state',
1),
(437, 'state_Western_Australia_437', 'Western
Australia', 'Western Australia', '',
'WA', 'state', 1),
(438, 'state_Burgenland_438', 'Burgenland',
'Burgenland', '', '1', 'state',
1),
(439, 'state_K__rnten_439', 'KĂ€rnten',
'KĂ€rnten', '', '2', 'state', 1),
(440, 'state_Nieder__sterreich_440',
'Niederösterreich', 'Niederösterreich', '',
'3', 'state', 1),
(441, 'state_Ober__sterreich_441', 'Oberösterreich',
'Oberösterreich', '', '4',
'state', 1),
(442, 'state_Salzburg_442', 'Salzburg',
'Salzburg', '', '5', 'state', 1),
(443, 'state_Steiermark_443', 'Steiermark',
'Steiermark', '', '6', 'state',
1),
(444, 'state_Tirol_444', 'Tirol', 'Tirol',
'', '7', 'state', 1),
(445, 'state_Voralberg_445', 'Voralberg',
'Voralberg', '', '8', 'state', 1),
(446, 'state_Wien_446', 'Wien', 'Wien',
'', '9', 'state', 1),
(447, 'state___li_Bayraml___447', 'Æli Bayramlı',
'Æli Bayramlı', '', 'AB',
'state', 1),
(448, 'state_Ab__eron_448', 'AbĆeron',
'AbĆeron', '', 'ABS', 'state',
1),
(449, 'state_A__cab__di_449', 'AÄcabÉdi',
'AÄcabÉdi', '', 'AGC', 'state',
1),
(450, 'state_A__dam_450', 'AÄdam', 'AÄdam',
'', 'AGM', 'state', 1),
(451, 'state_A__da___451', 'AÄdaĆ',
'AÄdaĆ', '', 'AGS', 'state', 1),
(452, 'state_A__stafa_452', 'AÄstafa',
'AÄstafa', '', 'AGA', 'state',
1),
(453, 'state_A__su_453', 'AÄsu', 'AÄsu',
'', 'AGU', 'state', 1),
(454, 'state_Astara_454', 'Astara', 'Astara',
'', 'AST', 'state', 1),
(455, 'state_Bak___455', 'Bakı', 'Bakı',
'', 'BA', 'state', 1),
(456, 'state_Bab__k_456', 'BabÉk', 'BabÉk',
'', 'BAB', 'state', 1),
(457, 'state_Balak__n_457', 'BalakÉn',
'BalakÉn', '', 'BAL', 'state',
1),
(458, 'state_B__rd___458', 'BÉrdÉ',
'BÉrdÉ', '', 'BAR', 'state', 1),
(459, 'state_Beyl__qan_459', 'BeylÉqan',
'BeylÉqan', '', 'BEY', 'state',
1),
(460, 'state_Bil__suvar_460', 'BilÉsuvar',
'BilÉsuvar', '', 'BIL', 'state',
1),
(461, 'state_C__bray__l_461', 'CÉbrayıl',
'CÉbrayıl', '', 'CAB', 'state',
1),
(462, 'state_C__lilabab_462', 'CÉlilabab',
'CÉlilabab', '', 'CAL', 'state',
1),
(463, 'state_Julfa_463', 'Julfa', 'Julfa',
'', 'CUL', 'state', 1),
(464, 'state_Da__k__s__n_464', 'DaĆkÉsÉn',
'DaĆkÉsÉn', '', 'DAS', 'state',
1),
(465, 'state_D__v____i_465', 'DÉvÉçi',
'DÉvÉçi', '', 'DAV', 'state',
1),
(466, 'state_F__zuli_466', 'FĂŒzuli',
'FĂŒzuli', '', 'FUZ', 'state', 1),
(467, 'state_G__nc___467', 'GÉncÉ',
'GÉncÉ', '', 'GA', 'state', 1),
(468, 'state_G__d__b__y_468', 'GÉdÉbÉy',
'GÉdÉbÉy', '', 'GAD', 'state',
1),
(469, 'state_Goranboy_469', 'Goranboy',
'Goranboy', '', 'GOR', 'state',
1),
(470, 'state_G__y__ay_470', 'Göyçay',
'Göyçay', '', 'GOY', 'state',
1),
(471, 'state_Hac__qabul_471', 'Hacıqabul',
'Hacıqabul', '', 'HAC', 'state',
1),
(472, 'state___mi__li_472', 'İmiĆli',
'İmiĆli', '', 'IMI', 'state',
1),
(473, 'state___smay__ll___473', 'İsmayıllı',
'İsmayıllı', '', 'ISM', 'state',
1),
(474, 'state_K__lb__c__r_474', 'KÉlbÉcÉr',
'KÉlbÉcÉr', '', 'KAL', 'state',
1),
(475, 'state_K__rd__mir_475', 'KĂŒrdÉmir',
'KĂŒrdÉmir', '', 'KUR', 'state',
1),
(476, 'state_L__nk__ran_476', 'LÉnkÉran',
'LÉnkÉran', '', 'LA', 'state',
1),
(477, 'state_La____n_477', 'Laçın',
'Laçın', '', 'LAC', 'state', 1),
(478, 'state_L__nk__ran_478', 'LÉnkÉran',
'LÉnkÉran', '', 'LAN', 'state',
1),
(479, 'state_Lerik_479', 'Lerik', 'Lerik',
'', 'LER', 'state', 1),
(480, 'state_Masall___480', 'Masallı',
'Masallı', '', 'MAS', 'state',
1),
(481, 'state_Ming____evir_481', 'MingÉçevir',
'MingÉçevir', '', 'MI', 'state',
1),
(482, 'state_Naftalan_482', 'Naftalan',
'Naftalan', '', 'NA', 'state', 1),
(483, 'state_Neft__ala_483', 'Neftçala',
'Neftçala', '', 'NEF', 'state',
1),
(484, 'state_O__uz_484', 'OÄuz', 'OÄuz',
'', 'OGU', 'state', 1),
(485, 'state_Ordubad_485', 'Ordubad',
'Ordubad', '', 'ORD', 'state', 1),
(486, 'state_Q__b__l___486', 'QÉbÉlÉ',
'QÉbÉlÉ', '', 'QAB', 'state',
1),
(487, 'state_Qax_487', 'Qax', 'Qax',
'', 'QAX', 'state', 1),
(488, 'state_Qazax_488', 'Qazax', 'Qazax',
'', 'QAZ', 'state', 1),
(489, 'state_Qobustan_489', 'Qobustan',
'Qobustan', '', 'QOB', 'state',
1),
(490, 'state_Quba_490', 'Quba', 'Quba',
'', 'QBA', 'state', 1),
(491, 'state_Qubadl___491', 'Qubadlı',
'Qubadlı', '', 'QBI', 'state',
1),
(492, 'state_Qusar_492', 'Qusar', 'Qusar',
'', 'QUS', 'state', 1),
(493, 'state_____ki_493', 'ĆÉki', 'ĆÉki',
'', 'SA', 'state', 1),
(494, 'state_Saatl___494', 'Saatlı',
'Saatlı', '', 'SAT', 'state', 1),
(495, 'state_Sabirabad_495', 'Sabirabad',
'Sabirabad', '', 'SAB', 'state',
1),
(496, 'state_S__d__r__k_496', 'SÉdÉrÉk',
'SÉdÉrÉk', '', 'SAD', 'state',
1),
(497, 'state___ahbuz_497', 'Ćahbuz',
'Ćahbuz', '', 'SAH', 'state', 1),
(498, 'state_____ki_498', 'ĆÉki', 'ĆÉki',
'', 'SAK', 'state', 1),
(499, 'state_Salyan_499', 'Salyan', 'Salyan',
'', 'SAL', 'state', 1);";
$this->db->setQuery($query);
$this->db->query();
$query="
INSERT IGNORE INTO `#__hikashop_zone` (`zone_id`, `zone_namekey`,
`zone_name`, `zone_name_english`, `zone_code_2`, `zone_code_3`,
`zone_type`, `zone_published`) VALUES
(500, 'state_Sumqay__t_500', 'Sumqayıt',
'Sumqayıt', '', 'SM', 'state',
1),
(501, 'state___amax___501', 'Ćamaxı',
'Ćamaxı', '', 'SMI', 'state',
1),
(502, 'state_____mkir_502', 'ĆÉmkir',
'ĆÉmkir', '', 'SKR', 'state',
1),
(503, 'state_Samux_503', 'Samux', 'Samux',
'', 'SMX', 'state', 1),
(504, 'state_____rur_504', 'ĆÉrur',
'ĆÉrur', '', 'SAR', 'state', 1),
(505, 'state_Siy__z__n_505', 'SiyÉzÉn',
'SiyÉzÉn', '', 'SIY', 'state',
1),
(506, 'state___u__a__City__506', 'ĆuĆa (City)',
'ĆuĆa (City)', '', 'SS', 'state',
1),
(507, 'state___u__a_507', 'ĆuĆa', 'ĆuĆa',
'', 'SUS', 'state', 1),
(508, 'state_T__rt__r_508', 'TÉrtÉr',
'TÉrtÉr', '', 'TAR', 'state',
1),
(509, 'state_Tovuz_509', 'Tovuz', 'Tovuz',
'', 'TOV', 'state', 1),
(510, 'state_Ucar_510', 'Ucar', 'Ucar',
'', 'UCA', 'state', 1),
(511, 'state_Xank__ndi_511', 'XankÉndi',
'XankÉndi', '', 'XA', 'state',
1),
(512, 'state_Xa__maz_512', 'Xaçmaz',
'Xaçmaz', '', 'XAC', 'state', 1),
(513, 'state_Xanlar_513', 'Xanlar', 'Xanlar',
'', 'XAN', 'state', 1),
(514, 'state_X__z___514', 'Xızı', 'Xızı',
'', 'XIZ', 'state', 1),
(515, 'state_Xocal___515', 'Xocalı',
'Xocalı', '', 'XCI', 'state', 1),
(516, 'state_Xocav__nd_516', 'XocavÉnd',
'XocavÉnd', '', 'XVD', 'state',
1),
(517, 'state_Yard__ml___517', 'Yardımlı',
'Yardımlı', '', 'YAR', 'state',
1),
(518, 'state_Yevlax__City__518', 'Yevlax (City)',
'Yevlax (City)', '', 'YE', 'state',
1),
(519, 'state_Yevlax_519', 'Yevlax', 'Yevlax',
'', 'YEV', 'state', 1),
(520, 'state_Z__ngilan_520', 'ZÉngilan',
'ZÉngilan', '', 'ZAN', 'state',
1),
(521, 'state_Zaqatala_521', 'Zaqatala',
'Zaqatala', '', 'ZAQ', 'state',
1),
(522, 'state_Z__rdab_522', 'ZÉrdab',
'ZÉrdab', '', 'ZAR', 'state', 1),
(523, 'state_Nakhichevan_523', 'Nakhichevan',
'Nakhichevan', '', 'NX', 'state',
1),
(524, 'state_Acklins_and_Crooked_Islands_524', 'Acklins and
Crooked Islands', 'Acklins and Crooked Islands',
'', 'AC', 'state', 1),
(525, 'state_Bimini_525', 'Bimini', 'Bimini',
'', 'BI', 'state', 1),
(526, 'state_Cat_Island_526', 'Cat Island', 'Cat
Island', '', 'CI', 'state', 1),
(527, 'state_Exuma_527', 'Exuma', 'Exuma',
'', 'EX', 'state', 1),
(528, 'state_Freeport_528', 'Freeport',
'Freeport', '', 'FR', 'state', 1),
(529, 'state_Fresh_Creek_529', 'Fresh Creek',
'Fresh Creek', '', 'FC', 'state',
1),
(530, 'state_Governor_s_Harbour_530', 'Governor''s
Harbour', 'Governor''s Harbour', '',
'GH', 'state', 1),
(531, 'state_Green_Turtle_Cay_531', 'Green Turtle Cay',
'Green Turtle Cay', '', 'GT',
'state', 1),
(532, 'state_Harbour_Island_532', 'Harbour Island',
'Harbour Island', '', 'HI',
'state', 1),
(533, 'state_High_Rock_533', 'High Rock', 'High
Rock', '', 'HR', 'state', 1),
(534, 'state_Inagua_534', 'Inagua', 'Inagua',
'', 'IN', 'state', 1),
(535, 'state_Kemps_Bay_535', 'Kemps Bay', 'Kemps
Bay', '', 'KB', 'state', 1),
(536, 'state_Long_Island_536', 'Long Island',
'Long Island', '', 'LI', 'state',
1),
(537, 'state_Marsh_Harbour_537', 'Marsh Harbour',
'Marsh Harbour', '', 'MH', 'state',
1),
(538, 'state_Mayaguana_538', 'Mayaguana',
'Mayaguana', '', 'MA', 'state',
1),
(539, 'state_New_Providence_539', 'New Providence',
'New Providence', '', 'NP',
'state', 1),
(540, 'state_Nicholls_Town_and_Berry_Islands_540', 'Nicholls
Town and Berry Islands', 'Nicholls Town and Berry Islands',
'', 'NT', 'state', 1),
(541, 'state_Ragged_Island_541', 'Ragged Island',
'Ragged Island', '', 'RI', 'state',
1),
(542, 'state_Rock_Sound_542', 'Rock Sound', 'Rock
Sound', '', 'RS', 'state', 1),
(543, 'state_San_Salvador_and_Rum_Cay_543', 'San Salvador
and Rum Cay', 'San Salvador and Rum Cay', '',
'SS', 'state', 1),
(544, 'state_Sandy_Point_544', 'Sandy Point',
'Sandy Point', '', 'SP', 'state',
1),
(545, 'state__________545', 'ۧÙŰŰŻ',
'ۧÙŰŰŻ', '', '01', 'state', 1),
(546, 'state______________546', 'ۧÙÙ
Ű۱Ù',
'ۧÙÙ
Ű۱Ù', '', '02', 'state',
1),
(547, 'state________________547', 'ۧÙÙ
ÙۧÙ
Ű©',
'ۧÙÙ
ÙۧÙ
Ű©', '', '03',
'state', 1),
(548, 'state_____________548', 'ŰŹŰŻ ŰÙŰ”',
'ŰŹŰŻ ŰÙŰ”', '', '04', 'state',
1),
(549, 'state_________________________________549',
'ۧÙÙ
ÙŰ·ÙŰ© ۧÙŰŽÙ
ۧÙÙŰ©', 'ۧÙÙ
ÙŰ·ÙŰ©
ۧÙŰŽÙ
ۧÙÙŰ©', '', '05', 'state',
1),
(550, 'state__________550', 'ŰłŰȘ۱۩',
'ŰłŰȘ۱۩', '', '06', 'state', 1),
(551, 'state_____________________________551',
'ۧÙÙ
ÙŰ·ÙŰ© ۧÙÙ۳۷Ù', 'ۧÙÙ
ÙŰ·ÙŰ©
ۧÙÙ۳۷Ù', '', '07', 'state', 1),
(552, 'state_____________________552', 'Ù
ŰŻÙÙŰ©
ŰčÙŰłÙ', 'Ù
ŰŻÙÙŰ© ŰčÙŰłÙ', '',
'08', 'state', 1),
(553, 'state________________________________________________553',
'ۧÙ۱ÙۧŰč ÙۧÙÙ
ÙŰ·ÙŰ© ۧÙŰŹÙÙŰšÙŰ©',
'ۧÙ۱ÙۧŰč ÙۧÙÙ
ÙŰ·ÙŰ© ۧÙŰŹÙÙŰšÙŰ©', '',
'09', 'state', 1),
(554, 'state_______________________________554',
'ۧÙÙ
ÙŰ·ÙŰ© ۧÙŰș۱ۚÙŰ©', 'ۧÙÙ
ÙŰ·ÙŰ©
ۧÙŰș۱ۚÙŰ©', '', '10', 'state', 1),
(555, 'state_________________555', 'ŰŹŰČ۱ ŰÙۧ۱',
'ŰŹŰČ۱ ŰÙۧ۱', '', '11',
'state', 1),
(556, 'state___________________556', 'Ù
ŰŻÙÙŰ©
ŰÙ
ŰŻ', 'Ù
ŰŻÙÙŰ© ŰÙ
ŰŻ', '', '12',
'state', 1),
(557, 'state_Bandarban_557', 'Bandarban',
'Bandarban', '', '01', 'state',
1),
(558, 'state_Barguna_558', 'Barguna',
'Barguna', '', '02', 'state', 1),
(559, 'state_Bogra_559', 'Bogra', 'Bogra',
'', '03', 'state', 1),
(560, 'state_Brahmanbaria_560', 'Brahmanbaria',
'Brahmanbaria', '', '04', 'state',
1),
(561, 'state_Bagerhat_561', 'Bagerhat',
'Bagerhat', '', '05', 'state', 1),
(562, 'state_Barisal_562', 'Barisal',
'Barisal', '', '06', 'state', 1),
(563, 'state_Bhola_563', 'Bhola', 'Bhola',
'', '07', 'state', 1),
(564, 'state_Comilla_564', 'Comilla',
'Comilla', '', '08', 'state', 1),
(565, 'state_Chandpur_565', 'Chandpur',
'Chandpur', '', '09', 'state', 1),
(566, 'state_Chittagong_566', 'Chittagong',
'Chittagong', '', '10', 'state',
1),
(567, 'state_Cox_s_Bazar_567', 'Cox''s
Bazar', 'Cox''s Bazar', '',
'11', 'state', 1),
(568, 'state_Chuadanga_568', 'Chuadanga',
'Chuadanga', '', '12', 'state',
1),
(569, 'state_Dhaka_569', 'Dhaka', 'Dhaka',
'', '13', 'state', 1),
(570, 'state_Dinajpur_570', 'Dinajpur',
'Dinajpur', '', '14', 'state', 1),
(571, 'state_Faridpur_571', 'Faridpur',
'Faridpur', '', '15', 'state', 1),
(572, 'state_Feni_572', 'Feni', 'Feni',
'', '16', 'state', 1),
(573, 'state_Gopalganj_573', 'Gopalganj',
'Gopalganj', '', '17', 'state',
1),
(574, 'state_Gazipur_574', 'Gazipur',
'Gazipur', '', '18', 'state', 1),
(575, 'state_Gaibandha_575', 'Gaibandha',
'Gaibandha', '', '19', 'state',
1),
(576, 'state_Habiganj_576', 'Habiganj',
'Habiganj', '', '20', 'state', 1),
(577, 'state_Jamalpur_577', 'Jamalpur',
'Jamalpur', '', '21', 'state', 1),
(578, 'state_Jessore_578', 'Jessore',
'Jessore', '', '22', 'state', 1),
(579, 'state_Jhenaidah_579', 'Jhenaidah',
'Jhenaidah', '', '23', 'state',
1),
(580, 'state_Jaipurhat_580', 'Jaipurhat',
'Jaipurhat', '', '24', 'state',
1),
(581, 'state_Jhalakati_581', 'Jhalakati',
'Jhalakati', '', '25', 'state',
1),
(582, 'state_Kishoreganj_582', 'Kishoreganj',
'Kishoreganj', '', '26', 'state',
1),
(583, 'state_Khulna_583', 'Khulna', 'Khulna',
'', '27', 'state', 1),
(584, 'state_Kurigram_584', 'Kurigram',
'Kurigram', '', '28', 'state', 1),
(585, 'state_Khagrachari_585', 'Khagrachari',
'Khagrachari', '', '29', 'state',
1),
(586, 'state_Kushtia_586', 'Kushtia',
'Kushtia', '', '30', 'state', 1),
(587, 'state_Lakshmipur_587', 'Lakshmipur',
'Lakshmipur', '', '31', 'state',
1),
(588, 'state_Lalmonirhat_588', 'Lalmonirhat',
'Lalmonirhat', '', '32', 'state',
1),
(589, 'state_Manikganj_589', 'Manikganj',
'Manikganj', '', '33', 'state',
1),
(590, 'state_Mymensingh_590', 'Mymensingh',
'Mymensingh', '', '34', 'state',
1),
(591, 'state_Munshiganj_591', 'Munshiganj',
'Munshiganj', '', '35', 'state',
1),
(592, 'state_Madaripur_592', 'Madaripur',
'Madaripur', '', '36', 'state',
1),
(593, 'state_Magura_593', 'Magura', 'Magura',
'', '37', 'state', 1),
(594, 'state_Moulvibazar_594', 'Moulvibazar',
'Moulvibazar', '', '38', 'state',
1),
(595, 'state_Meherpur_595', 'Meherpur',
'Meherpur', '', '39', 'state', 1),
(596, 'state_Narayanganj_596', 'Narayanganj',
'Narayanganj', '', '40', 'state',
1),
(597, 'state_Netrakona_597', 'Netrakona',
'Netrakona', '', '41', 'state',
1),
(598, 'state_Narsingdi_598', 'Narsingdi',
'Narsingdi', '', '42', 'state',
1),
(599, 'state_Narail_599', 'Narail', 'Narail',
'', '43', 'state', 1),
(600, 'state_Natore_600', 'Natore', 'Natore',
'', '44', 'state', 1),
(601, 'state_Nawabganj_601', 'Nawabganj',
'Nawabganj', '', '45', 'state',
1),
(602, 'state_Nilphamari_602', 'Nilphamari',
'Nilphamari', '', '46', 'state',
1),
(603, 'state_Noakhali_603', 'Noakhali',
'Noakhali', '', '47', 'state', 1),
(604, 'state_Naogaon_604', 'Naogaon',
'Naogaon', '', '48', 'state', 1),
(605, 'state_Pabna_605', 'Pabna', 'Pabna',
'', '49', 'state', 1),
(606, 'state_Pirojpur_606', 'Pirojpur',
'Pirojpur', '', '50', 'state', 1),
(607, 'state_Patuakhali_607', 'Patuakhali',
'Patuakhali', '', '51', 'state',
1),
(608, 'state_Panchagarh_608', 'Panchagarh',
'Panchagarh', '', '52', 'state',
1),
(609, 'state_Rajbari_609', 'Rajbari',
'Rajbari', '', '53', 'state', 1),
(610, 'state_Rajshahi_610', 'Rajshahi',
'Rajshahi', '', '54', 'state', 1),
(611, 'state_Rangpur_611', 'Rangpur',
'Rangpur', '', '55', 'state', 1),
(612, 'state_Rangamati_612', 'Rangamati',
'Rangamati', '', '56', 'state',
1),
(613, 'state_Sherpur_613', 'Sherpur',
'Sherpur', '', '57', 'state', 1),
(614, 'state_Satkhira_614', 'Satkhira',
'Satkhira', '', '58', 'state', 1),
(615, 'state_Sirajganj_615', 'Sirajganj',
'Sirajganj', '', '59', 'state',
1),
(616, 'state_Sylhet_616', 'Sylhet', 'Sylhet',
'', '60', 'state', 1),
(617, 'state_Sunamganj_617', 'Sunamganj',
'Sunamganj', '', '61', 'state',
1),
(618, 'state_Shariatpur_618', 'Shariatpur',
'Shariatpur', '', '62', 'state',
1),
(619, 'state_Tangail_619', 'Tangail',
'Tangail', '', '63', 'state', 1),
(620, 'state_Thakurgaon_620', 'Thakurgaon',
'Thakurgaon', '', '64', 'state',
1),
(621, 'state_Saint_Andrew_621', 'Saint Andrew',
'Saint Andrew', '', 'A', 'state',
1),
(622, 'state_Christ_Church_622', 'Christ Church',
'Christ Church', '', 'C', 'state',
1),
(623, 'state_Saint_Peter_623', 'Saint Peter',
'Saint Peter', '', 'E', 'state',
1),
(624, 'state_Saint_George_624', 'Saint George',
'Saint George', '', 'G', 'state',
1),
(625, 'state_Saint_John_625', 'Saint John', 'Saint
John', '', 'J', 'state', 1),
(626, 'state_Saint_Lucy_626', 'Saint Lucy', 'Saint
Lucy', '', 'L', 'state', 1),
(627, 'state_Saint_Michael_627', 'Saint Michael',
'Saint Michael', '', 'M', 'state',
1),
(628, 'state_Saint_Joseph_628', 'Saint Joseph',
'Saint Joseph', '', 'O', 'state',
1),
(629, 'state_Saint_Philip_629', 'Saint Philip',
'Saint Philip', '', 'P', 'state',
1),
(630, 'state_Saint_James_630', 'Saint James',
'Saint James', '', 'S', 'state',
1),
(631, 'state_Saint_Thomas_631', 'Saint Thomas',
'Saint Thomas', '', 'T', 'state',
1),
(632, 'state_______________________________________632',
'ĐŃŃÌŃŃĐșĐ°Ń ĐČĐŸÌблаŃŃŃ', 'ĐŃŃÌŃŃĐșаŃ
ĐČĐŸÌблаŃŃŃ', '', 'BR', 'state',
1),
(633, 'state___________________________________________633',
'ĐĐŸÌĐŒĐ”Đ»ŃŃĐșĐ°Ń ĐČĐŸÌблаŃŃŃ',
'ĐĐŸÌĐŒĐ”Đ»ŃŃĐșĐ°Ń ĐČĐŸÌблаŃŃŃ', '',
'HO', 'state', 1),
(634, 'state_____________________________________________634',
'ĐŃĐŸÌĐŽĐ·Đ”ĐœŃĐșĐ°Ń ĐČĐŸÌблаŃŃŃ',
'ĐŃĐŸÌĐŽĐ·Đ”ĐœŃĐșĐ°Ń ĐČĐŸÌблаŃŃŃ', '',
'HR', 'state', 1),
(635, 'state___________________________________________635',
'ĐагŃĐ»ŃŃŃĐșĐ°Ń ĐČĐŸÌблаŃŃŃ',
'ĐагŃĐ»ŃŃŃĐșĐ°Ń ĐČĐŸÌблаŃŃŃ', '',
'MA', 'state', 1),
(636, 'state_____________________________________636',
'ĐŃÌĐœŃĐșĐ°Ń ĐČĐŸÌблаŃŃŃ', 'ĐŃÌĐœŃĐșаŃ
ĐČĐŸÌблаŃŃŃ', '', 'MI', 'state',
1),
(637, 'state_________________________________________637',
'ĐŃÌŃДбŃĐșĐ°Ń ĐČĐŸÌблаŃŃŃ',
'ĐŃÌŃДбŃĐșĐ°Ń ĐČĐŸÌблаŃŃŃ', '',
'VI', 'state', 1),
(638, 'state_Brussel_638', 'Brussel',
'Brussel', '', 'BRU', 'state', 1),
(639, 'state_Antwerpen_639', 'Antwerpen',
'Antwerpen', '', 'VAN', 'state',
1),
(640, 'state_Vlaams_Brabant_640', 'Vlaams-Brabant',
'Vlaams-Brabant', '', 'VBR',
'state', 1),
(641, 'state_Limburg_641', 'Limburg',
'Limburg', '', 'VLI', 'state', 1),
(642, 'state_Oost_Vlaanderen_642', 'Oost-Vlaanderen',
'Oost-Vlaanderen', '', 'VOV',
'state', 1),
(643, 'state_West_Vlaanderen_643', 'West-Vlaanderen',
'West-Vlaanderen', '', 'VWV',
'state', 1),
(644, 'state_Brabant_Wallon_644', 'Brabant Wallon',
'Brabant Wallon', '', 'WBR',
'state', 1),
(645, 'state_Hainaut_645', 'Hainaut',
'Hainaut', '', 'WHT', 'state', 1),
(646, 'state_Li__ge_L__ttich_646', 'LiĂšge/LĂŒttich',
'LiĂšge/LĂŒttich', '', 'WLG',
'state', 1),
(647, 'state_Luxembourg_647', 'Luxembourg',
'Luxembourg', '', 'WLX', 'state',
1),
(648, 'state_Namur_648', 'Namur', 'Namur',
'', 'WNA', 'state', 1),
(649, 'state_Belize_District_649', 'Belize District',
'Belize District', '', 'BZ',
'state', 1),
(650, 'state_Cayo_District_650', 'Cayo District',
'Cayo District', '', 'CY', 'state',
1),
(651, 'state_Corozal_District_651', 'Corozal District',
'Corozal District', '', 'CZL',
'state', 1),
(652, 'state_Orange_Walk_District_652', 'Orange Walk
District', 'Orange Walk District', '',
'OW', 'state', 1),
(653, 'state_Stann_Creek_District_653', 'Stann Creek
District', 'Stann Creek District', '',
'SC', 'state', 1),
(654, 'state_Toledo_District_654', 'Toledo District',
'Toledo District', '', 'TOL',
'state', 1),
(655, 'state_Alibori_655', 'Alibori',
'Alibori', '', 'AL', 'state', 1),
(656, 'state_Atakora_656', 'Atakora',
'Atakora', '', 'AK', 'state', 1),
(657, 'state_Atlantique_657', 'Atlantique',
'Atlantique', '', 'AQ', 'state',
1),
(658, 'state_Borgou_658', 'Borgou', 'Borgou',
'', 'BO', 'state', 1),
(659, 'state_Collines_659', 'Collines',
'Collines', '', 'CO', 'state', 1),
(660, 'state_Donga_660', 'Donga', 'Donga',
'', 'DO', 'state', 1),
(661, 'state_Kouffo_661', 'Kouffo', 'Kouffo',
'', 'KO', 'state', 1),
(662, 'state_Littoral_662', 'Littoral',
'Littoral', '', 'LI', 'state', 1),
(663, 'state_Mono_663', 'Mono', 'Mono',
'', 'MO', 'state', 1),
(664, 'state_Ou__m___664', 'Ouémé',
'Ouémé', '', 'OU', 'state', 1),
(665, 'state_Plateau_665', 'Plateau',
'Plateau', '', 'PL', 'state', 1),
(666, 'state_Zou_666', 'Zou', 'Zou',
'', 'ZO', 'state', 1),
(667, 'state_Devonshire_667', 'Devonshire',
'Devonshire', '', 'DEV', 'state',
1),
(668, 'state_Hamilton_City_668', 'Hamilton City',
'Hamilton City', '', 'HA', 'state',
1),
(669, 'state_Hamilton_669', 'Hamilton',
'Hamilton', '', 'HAM', 'state',
1),
(670, 'state_Paget_670', 'Paget', 'Paget',
'', 'PAG', 'state', 1),
(671, 'state_Pembroke_671', 'Pembroke',
'Pembroke', '', 'PEM', 'state',
1),
(672, 'state_Sandys_672', 'Sandys', 'Sandys',
'', 'SAN', 'state', 1),
(673, 'state_Saint_George_City_673', 'Saint George
City', 'Saint George City', '', 'SG',
'state', 1),
(674, 'state_Saint_George_s_674', 'Saint
George''s', 'Saint George''s',
'', 'SGE', 'state', 1),
(675, 'state_Smiths_675', 'Smiths', 'Smiths',
'', 'SMI', 'state', 1),
(676, 'state_Southampton_676', 'Southampton',
'Southampton', '', 'SOU', 'state',
1),
(677, 'state_Warwick_677', 'Warwick',
'Warwick', '', 'WAR', 'state', 1),
(678, 'state_Paro_678', 'Paro', 'Paro',
'', '11', 'state', 1),
(679, 'state_Chukha_679', 'Chukha', 'Chukha',
'', '12', 'state', 1),
(680, 'state_Haa_680', 'Haa', 'Haa',
'', '13', 'state', 1),
(681, 'state_Samtse_681', 'Samtse', 'Samtse',
'', '14', 'state', 1),
(682, 'state_Thimphu_682', 'Thimphu',
'Thimphu', '', '15', 'state', 1),
(683, 'state_Tsirang_683', 'Tsirang',
'Tsirang', '', '21', 'state', 1),
(684, 'state_Dagana_684', 'Dagana', 'Dagana',
'', '22', 'state', 1),
(685, 'state_Punakha_685', 'Punakha',
'Punakha', '', '23', 'state', 1),
(686, 'state_Wangdue_Phodrang_686', 'Wangdue Phodrang',
'Wangdue Phodrang', '', '24',
'state', 1),
(687, 'state_Sarpang_687', 'Sarpang',
'Sarpang', '', '31', 'state', 1),
(688, 'state_Trongsa_688', 'Trongsa',
'Trongsa', '', '32', 'state', 1),
(689, 'state_Bumthang_689', 'Bumthang',
'Bumthang', '', '33', 'state', 1),
(690, 'state_Zhemgang_690', 'Zhemgang',
'Zhemgang', '', '34', 'state', 1),
(691, 'state_Trashigang_691', 'Trashigang',
'Trashigang', '', '41', 'state',
1),
(692, 'state_Mongar_692', 'Mongar', 'Mongar',
'', '42', 'state', 1),
(693, 'state_Pemagatshel_693', 'Pemagatshel',
'Pemagatshel', '', '43', 'state',
1),
(694, 'state_Luentse_694', 'Luentse',
'Luentse', '', '44', 'state', 1),
(695, 'state_Samdrup_Jongkhar_695', 'Samdrup Jongkhar',
'Samdrup Jongkhar', '', '45',
'state', 1),
(696, 'state_Gasa_696', 'Gasa', 'Gasa',
'', 'GA', 'state', 1),
(697, 'state_Trashiyangse_697', 'Trashiyangse',
'Trashiyangse', '', 'TY', 'state',
1),
(698, 'state_El_Beni_698', 'El Beni', 'El
Beni', '', 'B', 'state', 1),
(699, 'state_Cochabamba_699', 'Cochabamba',
'Cochabamba', '', 'C', 'state',
1),
(700, 'state_Chuquisaca_700', 'Chuquisaca',
'Chuquisaca', '', 'H', 'state',
1),
(701, 'state_La_Paz_701', 'La Paz', 'La Paz',
'', 'L', 'state', 1),
(702, 'state_Pando_702', 'Pando', 'Pando',
'', 'N', 'state', 1),
(703, 'state_Oruro_703', 'Oruro', 'Oruro',
'', 'O', 'state', 1),
(704, 'state_Potos___704', 'PotosĂ',
'PotosĂ', '', 'P', 'state', 1),
(705, 'state_Santa_Cruz_705', 'Santa Cruz', 'Santa
Cruz', '', 'S', 'state', 1),
(706, 'state_Tarija_706', 'Tarija', 'Tarija',
'', 'T', 'state', 1),
(707, 'state_Central_707', 'Central',
'Central', '', 'CE', 'state', 1),
(708, 'state_Ghanzi_708', 'Ghanzi', 'Ghanzi',
'', 'GH', 'state', 1),
(709, 'state_Kgalagadi_709', 'Kgalagadi',
'Kgalagadi', '', 'KG', 'state',
1),
(710, 'state_Kgatleng_710', 'Kgatleng',
'Kgatleng', '', 'KL', 'state', 1),
(711, 'state_Kweneng_711', 'Kweneng',
'Kweneng', '', 'KW', 'state', 1),
(712, 'state_North_East_712', 'North-East',
'North-East', '', 'NE', 'state',
1),
(713, 'state_North_West_713', 'North-West',
'North-West', '', 'NW', 'state',
1),
(714, 'state_South_East_714', 'South-East',
'South-East', '', 'SE', 'state',
1),
(715, 'state_Southern_715', 'Southern',
'Southern', '', 'SO', 'state', 1),
(716, 'state_Acre_716', 'Acre', 'Acre',
'', 'AC', 'state', 1),
(717, 'state_Alagoas_717', 'Alagoas',
'Alagoas', '', 'AL', 'state', 1),
(718, 'state_Amaz__nia_718', 'AmazĂŽnia',
'AmazĂŽnia', '', 'AM', 'state',
1),
(719, 'state_Amap___719', 'AmapĂĄ', 'AmapĂĄ',
'', 'AP', 'state', 1),
(720, 'state_Bahia_720', 'Bahia', 'Bahia',
'', 'BA', 'state', 1),
(721, 'state_Cear___721', 'CearĂĄ', 'CearĂĄ',
'', 'CE', 'state', 1),
(722, 'state_Distrito_Federal_722', 'Distrito Federal',
'Distrito Federal', '', 'DF',
'state', 1),
(723, 'state_Esp__rito_Santo_723', 'EspĂrito Santo',
'EspĂrito Santo', '', 'ES',
'state', 1),
(724, 'state_Goi__s_724', 'GoiĂĄs', 'GoiĂĄs',
'', 'GO', 'state', 1),
(725, 'state_Maranh__o_725', 'MaranhĂŁo',
'MaranhĂŁo', '', 'MA', 'state',
1),
(726, 'state_Minas_Gerais_726', 'Minas Gerais',
'Minas Gerais', '', 'MG', 'state',
1),
(727, 'state_Mato_Grosso_do_Sul_727', 'Mato Grosso do
Sul', 'Mato Grosso do Sul', '', 'MS',
'state', 1),
(728, 'state_Mato_Grosso_728', 'Mato Grosso',
'Mato Grosso', '', 'MT', 'state',
1),
(729, 'state_Par___729', 'ParĂĄ', 'ParĂĄ',
'', 'PA', 'state', 1),
(730, 'state_Para__ba_730', 'ParaĂba',
'ParaĂba', '', 'PB', 'state', 1),
(731, 'state_Pernambuco_731', 'Pernambuco',
'Pernambuco', '', 'PE', 'state',
1),
(732, 'state_Piau___732', 'PiauĂ', 'PiauĂ',
'', 'PI', 'state', 1),
(733, 'state_Paran___733', 'ParanĂĄ',
'ParanĂĄ', '', 'PR', 'state', 1),
(734, 'state_Rio_de_Janeiro_734', 'Rio de Janeiro',
'Rio de Janeiro', '', 'RJ',
'state', 1),
(735, 'state_Rio_Grande_do_Norte_735', 'Rio Grande do
Norte', 'Rio Grande do Norte', '', 'RN',
'state', 1),
(736, 'state_Rond__nia_736', 'RondĂŽnia',
'RondĂŽnia', '', 'RO', 'state',
1),
(737, 'state_Roraima_737', 'Roraima',
'Roraima', '', 'RR', 'state', 1),
(738, 'state_Rio_Grande_do_Sul_738', 'Rio Grande do
Sul', 'Rio Grande do Sul', '', 'RS',
'state', 1),
(739, 'state_Santa_Catarina_739', 'Santa Catarina',
'Santa Catarina', '', 'SC',
'state', 1),
(740, 'state_Sergipe_740', 'Sergipe',
'Sergipe', '', 'SE', 'state', 1),
(741, 'state_S__o_Paulo_741', 'SĂŁo Paulo', 'SĂŁo
Paulo', '', 'SP', 'state', 1),
(742, 'state_Tocantins_742', 'Tocantins',
'Tocantins', '', 'TO', 'state',
1),
(743, 'state_Peros_Banhos_743', 'Peros Banhos',
'Peros Banhos', '', 'PB', 'state',
1),
(744, 'state_Salomon_Islands_744', 'Salomon Islands',
'Salomon Islands', '', 'SI',
'state', 1),
(745, 'state_Nelsons_Island_745', 'Nelsons Island',
'Nelsons Island', '', 'NI',
'state', 1),
(746, 'state_Three_Brothers_746', 'Three Brothers',
'Three Brothers', '', 'TB',
'state', 1),
(747, 'state_Eagle_Islands_747', 'Eagle Islands',
'Eagle Islands', '', 'EA', 'state',
1),
(748, 'state_Danger_Island_748', 'Danger Island',
'Danger Island', '', 'DI', 'state',
1),
(749, 'state_Egmont_Islands_749', 'Egmont Islands',
'Egmont Islands', '', 'EG',
'state', 1),
(750, 'state_Diego_Garcia_750', 'Diego Garcia',
'Diego Garcia', '', 'DG', 'state',
1),
(751, 'state_Belait_751', 'Belait', 'Belait',
'', 'BE', 'state', 1),
(752, 'state_Brunei_Muara_752', 'Brunei-Muara',
'Brunei-Muara', '', 'BM', 'state',
1),
(753, 'state_Temburong_753', 'Temburong',
'Temburong', '', 'TE', 'state',
1),
(754, 'state_Tutong_754', 'Tutong', 'Tutong',
'', 'TU', 'state', 1),
(755, 'state_Blagoevgrad_755', 'Blagoevgrad',
'Blagoevgrad', '', '01', 'state',
1),
(756, 'state_Burgas_756', 'Burgas', 'Burgas',
'', '02', 'state', 1),
(757, 'state_Varna_757', 'Varna', 'Varna',
'', '03', 'state', 1),
(758, 'state_Veliko_Tarnovo_758', 'Veliko Tarnovo',
'Veliko Tarnovo', '', '04',
'state', 1),
(759, 'state_Vidin_759', 'Vidin', 'Vidin',
'', '05', 'state', 1),
(760, 'state_Vratsa_760', 'Vratsa', 'Vratsa',
'', '06', 'state', 1),
(761, 'state_Gabrovo_761', 'Gabrovo',
'Gabrovo', '', '07', 'state', 1),
(762, 'state_Dobrich_762', 'Dobrich',
'Dobrich', '', '08', 'state', 1),
(763, 'state_Kardzhali_763', 'Kardzhali',
'Kardzhali', '', '09', 'state',
1),
(764, 'state_Kyustendil_764', 'Kyustendil',
'Kyustendil', '', '10', 'state',
1),
(765, 'state_Lovech_765', 'Lovech', 'Lovech',
'', '11', 'state', 1),
(766, 'state_Montana_766', 'Montana',
'Montana', '', '12', 'state', 1),
(767, 'state_Pazardzhik_767', 'Pazardzhik',
'Pazardzhik', '', '13', 'state',
1),
(768, 'state_Pernik_768', 'Pernik', 'Pernik',
'', '14', 'state', 1),
(769, 'state_Pleven_769', 'Pleven', 'Pleven',
'', '15', 'state', 1),
(770, 'state_Plovdiv_770', 'Plovdiv',
'Plovdiv', '', '16', 'state', 1),
(771, 'state_Razgrad_771', 'Razgrad',
'Razgrad', '', '17', 'state', 1),
(772, 'state_Ruse_772', 'Ruse', 'Ruse',
'', '18', 'state', 1),
(773, 'state_Silistra_773', 'Silistra',
'Silistra', '', '19', 'state', 1),
(774, 'state_Sliven_774', 'Sliven', 'Sliven',
'', '20', 'state', 1),
(775, 'state_Smolyan_775', 'Smolyan',
'Smolyan', '', '21', 'state', 1),
(776, 'state_Sofia_776', 'Sofia', 'Sofia',
'', '23', 'state', 1),
(777, 'state_Sofia_Province_777', 'Sofia Province',
'Sofia Province', '', '22',
'state', 1),
(778, 'state_Stara_Zagora_778', 'Stara Zagora',
'Stara Zagora', '', '24', 'state',
1),
(779, 'state_Targovishte_779', 'Targovishte',
'Targovishte', '', '25', 'state',
1),
(780, 'state_Haskovo_780', 'Haskovo',
'Haskovo', '', '26', 'state', 1),
(781, 'state_Shumen_781', 'Shumen', 'Shumen',
'', '27', 'state', 1),
(782, 'state_Yambol_782', 'Yambol', 'Yambol',
'', '28', 'state', 1),
(783, 'state_Bal___783', 'Balé', 'Balé',
'', 'BAL', 'state', 1),
(784, 'state_Bam_784', 'Bam', 'Bam',
'', 'BAM', 'state', 1),
(785, 'state_Banwa_785', 'Banwa', 'Banwa',
'', 'BAN', 'state', 1),
(786, 'state_Baz__ga_786', 'BazĂšga',
'BazĂšga', '', 'BAZ', 'state', 1),
(787, 'state_Bougouriba_787', 'Bougouriba',
'Bougouriba', '', 'BGR', 'state',
1),
(788, 'state_Boulgou_788', 'Boulgou',
'Boulgou', '', 'BLG', 'state', 1),
(789, 'state_Boulkiemd___789', 'Boulkiemdé',
'Boulkiemdé', '', 'BLK', 'state',
1),
(790, 'state_Komo___790', 'Komoé', 'Komoé',
'', 'COM', 'state', 1),
(791, 'state_Ganzourgou_791', 'Ganzourgou',
'Ganzourgou', '', 'GAN', 'state',
1),
(792, 'state_Gnagna_792', 'Gnagna', 'Gnagna',
'', 'GNA', 'state', 1),
(793, 'state_Gourma_793', 'Gourma', 'Gourma',
'', 'GOU', 'state', 1),
(794, 'state_Houet_794', 'Houet', 'Houet',
'', 'HOU', 'state', 1),
(795, 'state_Ioba_795', 'Ioba', 'Ioba',
'', 'IOB', 'state', 1),
(796, 'state_Kadiogo_796', 'Kadiogo',
'Kadiogo', '', 'KAD', 'state', 1),
(797, 'state_K__n__dougou_797', 'Kénédougou',
'Kénédougou', '', 'KEN', 'state',
1),
(798, 'state_Komondjari_798', 'Komondjari',
'Komondjari', '', 'KMD', 'state',
1),
(799, 'state_Kompienga_799', 'Kompienga',
'Kompienga', '', 'KMP', 'state',
1),
(800, 'state_Koulp__logo_800', 'Koulpélogo',
'Koulpélogo', '', 'KOP', 'state',
1),
(801, 'state_Kossi_801', 'Kossi', 'Kossi',
'', 'KOS', 'state', 1),
(802, 'state_Kouritenga_802', 'Kouritenga',
'Kouritenga', '', 'KOT', 'state',
1),
(803, 'state_Kourw__ogo_803', 'Kourwéogo',
'Kourwéogo', '', 'KOW', 'state',
1),
(804, 'state_L__raba_804', 'Léraba',
'Léraba', '', 'LER', 'state', 1),
(805, 'state_Loroum_805', 'Loroum', 'Loroum',
'', 'LOR', 'state', 1),
(806, 'state_Mouhoun_806', 'Mouhoun',
'Mouhoun', '', 'MOU', 'state', 1),
(807, 'state_Namentenga_807', 'Namentenga',
'Namentenga', '', 'NAM', 'state',
1),
(808, 'state_Naouri_808', 'Naouri', 'Naouri',
'', 'NAO', 'state', 1),
(809, 'state_Nayala_809', 'Nayala', 'Nayala',
'', 'NAY', 'state', 1),
(810, 'state_Noumbiel_810', 'Noumbiel',
'Noumbiel', '', 'NOU', 'state',
1),
(811, 'state_Oubritenga_811', 'Oubritenga',
'Oubritenga', '', 'OUB', 'state',
1),
(812, 'state_Oudalan_812', 'Oudalan',
'Oudalan', '', 'OUD', 'state', 1),
(813, 'state_Passor___813', 'Passoré',
'Passoré', '', 'PAS', 'state',
1),
(814, 'state_Poni_814', 'Poni', 'Poni',
'', 'PON', 'state', 1),
(815, 'state_S__no_815', 'Séno', 'Séno',
'', 'SEN', 'state', 1),
(816, 'state_Sissili_816', 'Sissili',
'Sissili', '', 'SIS', 'state', 1),
(817, 'state_Sanmatenga_817', 'Sanmatenga',
'Sanmatenga', '', 'SMT', 'state',
1),
(818, 'state_Sangui___818', 'Sanguié',
'Sanguié', '', 'SNG', 'state',
1),
(819, 'state_Soum_819', 'Soum', 'Soum',
'', 'SOM', 'state', 1),
(820, 'state_Sourou_820', 'Sourou', 'Sourou',
'', 'SOR', 'state', 1),
(821, 'state_Tapoa_821', 'Tapoa', 'Tapoa',
'', 'TAP', 'state', 1),
(822, 'state_Tui_822', 'Tui', 'Tui',
'', 'TUI', 'state', 1),
(823, 'state_Yagha_823', 'Yagha', 'Yagha',
'', 'YAG', 'state', 1),
(824, 'state_Yatenga_824', 'Yatenga',
'Yatenga', '', 'YAT', 'state', 1),
(825, 'state_Ziro_825', 'Ziro', 'Ziro',
'', 'ZIR', 'state', 1),
(826, 'state_Zondoma_826', 'Zondoma',
'Zondoma', '', 'ZON', 'state', 1),
(827, 'state_Zoundw__ogo_827', 'Zoundwéogo',
'Zoundwéogo', '', 'ZOU', 'state',
1),
(828, 'state_Bubanza_828', 'Bubanza',
'Bubanza', '', 'BB', 'state', 1),
(829, 'state_Bujumbura_Mairie_829', 'Bujumbura Mairie',
'Bujumbura Mairie', '', 'BJ',
'state', 1),
(830, 'state_Bururi_830', 'Bururi', 'Bururi',
'', 'BR', 'state', 1),
(831, 'state_Cankuzo_831', 'Cankuzo',
'Cankuzo', '', 'CA', 'state', 1),
(832, 'state_Cibitoke_832', 'Cibitoke',
'Cibitoke', '', 'CI', 'state', 1),
(833, 'state_Gitega_833', 'Gitega', 'Gitega',
'', 'GI', 'state', 1),
(834, 'state_Karuzi_834', 'Karuzi', 'Karuzi',
'', 'KR', 'state', 1),
(835, 'state_Kayanza_835', 'Kayanza',
'Kayanza', '', 'KY', 'state', 1),
(836, 'state_Kirundo_836', 'Kirundo',
'Kirundo', '', 'KI', 'state', 1),
(837, 'state_Makamba_837', 'Makamba',
'Makamba', '', 'MA', 'state', 1),
(838, 'state_Muramvya_838', 'Muramvya',
'Muramvya', '', 'MU', 'state', 1),
(839, 'state_Muyinga_839', 'Muyinga',
'Muyinga', '', 'MY', 'state', 1),
(840, 'state_Mwaro_840', 'Mwaro', 'Mwaro',
'', 'MW', 'state', 1),
(841, 'state_Ngozi_841', 'Ngozi', 'Ngozi',
'', 'NG', 'state', 1),
(842, 'state_Rutana_842', 'Rutana', 'Rutana',
'', 'RT', 'state', 1),
(843, 'state_Ruyigi_843', 'Ruyigi', 'Ruyigi',
'', 'RY', 'state', 1),
(844, 'state_Adamaoua_844', 'Adamaoua',
'Adamaoua', '', 'AD', 'state', 1),
(845, 'state_Centre_845', 'Centre', 'Centre',
'', 'CE', 'state', 1),
(846, 'state_Extr__me_Nord_846', 'ExtrĂȘme-Nord',
'ExtrĂȘme-Nord', '', 'EN', 'state',
1),
(847, 'state_Est_847', 'Est', 'Est',
'', 'ES', 'state', 1),
(848, 'state_Littoral_848', 'Littoral',
'Littoral', '', 'LT', 'state', 1),
(849, 'state_Nord_849', 'Nord', 'Nord',
'', 'NO', 'state', 1),
(850, 'state_Nord_Ouest_850', 'Nord-Ouest',
'Nord-Ouest', '', 'NW', 'state',
1),
(851, 'state_Ouest_851', 'Ouest', 'Ouest',
'', 'OU', 'state', 1),
(852, 'state_Sud_852', 'Sud', 'Sud',
'', 'SU', 'state', 1),
(853, 'state_Sud_Ouest_853', 'Sud-Ouest',
'Sud-Ouest', '', 'SW', 'state',
1),
(854, 'state_Alberta_854', 'Alberta',
'Alberta', 'AB', 'AB', 'state',
1),
(855, 'state_British_Columbia_855', 'British Columbia',
'British Columbia', 'BC', 'BC',
'state', 1),
(856, 'state_Manitoba_856', 'Manitoba',
'Manitoba', 'MB', 'MB', 'state',
1),
(857, 'state_New_Brunswick_857', 'New Brunswick',
'New Brunswick', 'NB', 'NB',
'state', 1),
(858, 'state_Newfoundland_and_Labrador_858', 'Newfoundland
and Labrador', 'Newfoundland and Labrador', 'NL',
'NL', 'state', 1),
(859, 'state_Nova_Scotia_859', 'Nova Scotia',
'Nova Scotia', 'NS', 'NS', 'state',
1),
(860, 'state_Northwest_Territories_860', 'Northwest
Territories', 'Northwest Territories', 'NT',
'NT', 'state', 1),
(861, 'state_Nunavut_861', 'Nunavut',
'Nunavut', 'NU', 'NU', 'state',
1),
(862, 'state_Ontario_862', 'Ontario',
'Ontario', 'ON', 'ON', 'state',
1),
(863, 'state_Prince_Edward_Island_863', 'Prince Edward
Island', 'Prince Edward Island', 'PE',
'PE', 'state', 1),
(864, 'state_Quebec_864', 'Quebec', 'Quebec',
'QC', 'QC', 'state', 1),
(865, 'state_Saskatchewan_865', 'Saskatchewan',
'Saskatchewan', 'SK', 'SK',
'state', 1),
(866, 'state_Yukon_Territory_866', 'Yukon Territory',
'Yukon Territory', 'YT', 'YT',
'state', 1),
(867, 'state_Brava_867', 'Brava', 'Brava',
'', 'BR', 'state', 1),
(868, 'state_Boa_Vista_868', 'Boa Vista', 'Boa
Vista', '', 'BV', 'state', 1),
(869, 'state_Santa_Catarina_869', 'Santa Catarina',
'Santa Catarina', '', 'CA',
'state', 1),
(870, 'state_Santa_Cruz_870', 'Santa Cruz', 'Santa
Cruz', '', 'CR', 'state', 1),
(871, 'state_Calheta_de_S__o_Miguel_871', 'Calheta de SĂŁo
Miguel', 'Calheta de SĂŁo Miguel', '',
'CS', 'state', 1),
(872, 'state_Maio_872', 'Maio', 'Maio',
'', 'MA', 'state', 1),
(873, 'state_Mosteiros_873', 'Mosteiros',
'Mosteiros', '', 'MO', 'state',
1),
(874, 'state_Pa__l_874', 'PaĂșl', 'PaĂșl',
'', 'PA', 'state', 1),
(875, 'state_Porto_Novo_875', 'Porto Novo', 'Porto
Novo', '', 'PN', 'state', 1),
(876, 'state_Praia_876', 'Praia', 'Praia',
'', 'PR', 'state', 1),
(877, 'state_Ribeira_Grande_877', 'Ribeira Grande',
'Ribeira Grande', '', 'RG',
'state', 1),
(878, 'state_S__o_Domingos_878', 'SĂŁo Domingos',
'SĂŁo Domingos', '', 'SD', 'state',
1),
(879, 'state_S__o_Filipe_879', 'SĂŁo Filipe',
'SĂŁo Filipe', '', 'SF', 'state',
1),
(880, 'state_Sal_880', 'Sal', 'Sal',
'', 'SL', 'state', 1),
(881, 'state_S__o_Nicolau_881', 'SĂŁo Nicolau',
'SĂŁo Nicolau', '', 'SN', 'state',
1),
(882, 'state_S__o_Vicente_882', 'SĂŁo Vicente',
'SĂŁo Vicente', '', 'SV', 'state',
1),
(883, 'state_Tarrafal_883', 'Tarrafal',
'Tarrafal', '', 'TA', 'state', 1),
(884, 'state_Creek_884', 'Creek', 'Creek',
'', 'CR', 'state', 1),
(886, 'state_Midland_886', 'Midland',
'Midland', '', 'MI', 'state', 1),
(887, 'state_South_Town_887', 'South Town', 'South
Town', '', 'SO', 'state', 1),
(888, 'state_Spot_Bay_888', 'Spot Bay', 'Spot
Bay', '', 'SP', 'state', 1),
(889, 'state_Stake_Bay_889', 'Stake Bay', 'Stake
Bay', '', 'ST', 'state', 1),
(890, 'state_West_End_890', 'West End', 'West
End', '', 'WD', 'state', 1),
(891, 'state_Western_891', 'Western',
'Western', '', 'WN', 'state', 1),
(892, 'state_Ouham_892', 'Ouham', 'Ouham',
'', 'AC ', 'state', 1),
(893, 'state_Bamingui_Bangoran_893',
'Bamingui-Bangoran', 'Bamingui-Bangoran', '',
'BB ', 'state', 1),
(894, 'state_Bangui_894', 'Bangui', 'Bangui',
'', 'BGF', 'state', 1),
(895, 'state_Basse_Kotto_895', 'Basse-Kotto',
'Basse-Kotto', '', 'BK ', 'state',
1),
(896, 'state_Haute_Kotto_896', 'Haute-Kotto',
'Haute-Kotto', '', 'HK ', 'state',
1),
(897, 'state_Haut_Mbomou_897', 'Haut-Mbomou',
'Haut-Mbomou', '', 'HM ', 'state',
1),
(898, 'state_Mamb__r___Kad_____898',
'Mambéré-Kadéï', 'Mambéré-Kadéï', '',
'HS ', 'state', 1),
(899, 'state_Nana_Gr__bizi_899', 'Nana-Grébizi',
'Nana-Grébizi', '', 'KB ',
'state', 1),
(900, 'state_K__mo_900', 'Kémo', 'Kémo',
'', 'KG ', 'state', 1),
(901, 'state_Lobaye_901', 'Lobaye', 'Lobaye',
'', 'LB ', 'state', 1),
(902, 'state_Mbomou_902', 'Mbomou', 'Mbomou',
'', 'MB ', 'state', 1),
(903, 'state_Ombella_M_Poko_903',
'Ombella-M''Poko',
'Ombella-M''Poko', '', 'MP ',
'state', 1),
(904, 'state_Nana_Mamb__r___904', 'Nana-Mambéré',
'Nana-Mambéré', '', 'NM ',
'state', 1),
(905, 'state_Ouham_Pend___905', 'Ouham-Pendé',
'Ouham-Pendé', '', 'OP ', 'state',
1),
(906, 'state_Sangha_Mba__r___906', 'Sangha-Mbaéré',
'Sangha-Mbaéré', '', 'SE ',
'state', 1),
(907, 'state_Ouaka_907', 'Ouaka', 'Ouaka',
'', 'UK ', 'state', 1),
(908, 'state_Vakaga_908', 'Vakaga', 'Vakaga',
'', 'VR ', 'state', 1),
(909, 'state_Batha_909', 'Batha', 'Batha',
'', 'BA ', 'state', 1),
(910, 'state_Borkou_Ennedi_Tibesti_910',
'Borkou-Ennedi-Tibesti', 'Borkou-Ennedi-Tibesti',
'', 'BET', 'state', 1),
(911, 'state_Biltine_911', 'Biltine',
'Biltine', '', 'BI ', 'state', 1),
(912, 'state_Chari_Baguirmi_912', 'Chari-Baguirmi',
'Chari-Baguirmi', '', 'CB ',
'state', 1),
(913, 'state_Gu__ra_913', 'Guéra', 'Guéra',
'', 'GR ', 'state', 1),
(914, 'state_Kanem_914', 'Kanem', 'Kanem',
'', 'KA ', 'state', 1),
(915, 'state_Lac_915', 'Lac', 'Lac',
'', 'LC ', 'state', 1),
(916, 'state_Logone_Oriental_916', 'Logone-Oriental',
'Logone-Oriental', '', 'LR ',
'state', 1),
(917, 'state_Logone_Occidental_917',
'Logone-Occidental', 'Logone-Occidental', '',
'LO ', 'state', 1),
(918, 'state_Moyen_Chari_918', 'Moyen-Chari',
'Moyen-Chari', '', 'MC ', 'state',
1),
(919, 'state_Mayo_K__bbi_919', 'Mayo-Kébbi',
'Mayo-Kébbi', '', 'MK ', 'state',
1),
(920, 'state_Ouadda___920', 'OuaddaĂŻ',
'OuaddaĂŻ', '', 'OD ', 'state',
1),
(921, 'state_Salamat_921', 'Salamat',
'Salamat', '', 'SA ', 'state', 1),
(922, 'state_Tandjil___922', 'Tandjilé',
'Tandjilé', '', 'TA ', 'state',
1),
(923, 'state_Ais__n_del_General_Carlos_Iba__ez_923', 'Aisén
del General Carlos Ibañez', 'Aisén del General Carlos
Ibañez', '', 'AI', 'state', 1),
(924, 'state_Antofagasta_924', 'Antofagasta',
'Antofagasta', '', 'AN', 'state',
1),
(925, 'state_La_Araucan__a_925', 'La AraucanĂa',
'La AraucanĂa', '', 'AR', 'state',
1),
(926, 'state_Atacama_926', 'Atacama',
'Atacama', '', 'AT', 'state', 1),
(927, 'state_Biob__o_927', 'BiobĂo',
'BiobĂo', '', 'BI', 'state', 1),
(928, 'state_Coquimbo_928', 'Coquimbo',
'Coquimbo', '', 'CO', 'state', 1),
(929, 'state_Libertador_Bernardo_O_Higgins_929', 'Libertador
Bernardo O''Higgins', 'Libertador Bernardo
O''Higgins', '', 'LI',
'state', 1),
(930, 'state_Los_Lagos_930', 'Los Lagos', 'Los
Lagos', '', 'LL', 'state', 1),
(931, 'state_Magallanes_y_de_la_Antartica_931', 'Magallanes
y de la Antartica', 'Magallanes y de la Antartica',
'', 'MA', 'state', 1),
(932, 'state_Maule_932', 'Maule', 'Maule',
'', 'ML', 'state', 1),
(933, 'state_Metropolitana_de_Santiago_933', 'Metropolitana
de Santiago', 'Metropolitana de Santiago', '',
'RM', 'state', 1),
(934, 'state_Tarapac___934', 'TarapacĂĄ',
'TarapacĂĄ', '', 'TA', 'state',
1),
(935, 'state_Valpara__so_935', 'ValparaĂso',
'ValparaĂso', '', 'VS', 'state',
1),
(936, 'state________936', 'ćäșŹ', 'ćäșŹ',
'', '11', 'state', 1),
(937, 'state________937', 'ć€©æŽ„', 'ć€©æŽ„',
'', '12', 'state', 1),
(938, 'state________938', 'æČłć', 'æČłć',
'', '13', 'state', 1),
(939, 'state________939', 'ć±±è„ż', 'ć±±è„ż',
'', '14', 'state', 1),
(940, 'state____________________940',
'ć
èć€èȘæČ»ćș', 'ć
èć€èȘæČ»ćș',
'', '15', 'state', 1),
(941, 'state________941', '蟜ćź', '蟜ćź',
'', '21', 'state', 1),
(942, 'state________942', 'ćæ', 'ćæ',
'', '22', 'state', 1),
(943, 'state______________943', 'é»éŸæ±ç',
'é»éŸæ±ç', '', '23', 'state',
1),
(944, 'state________944', 'äžæ”·', 'äžæ”·',
'', '31', 'state', 1),
(945, 'state________945', 'æ±è', 'æ±è',
'', '32', 'state', 1),
(946, 'state________946', 'æ”æ±', 'æ”æ±',
'', '33', 'state', 1),
(947, 'state________947', 'ćźćŸœ', 'ćźćŸœ',
'', '34', 'state', 1),
(948, 'state________948', 'çŠć»ș', 'çŠć»ș',
'', '35', 'state', 1),
(949, 'state________949', 'æ±è„ż', 'æ±è„ż',
'', '36', 'state', 1),
(950, 'state________950', 'ć±±äž', 'ć±±äž',
'', '37', 'state', 1),
(951, 'state________951', 'æČłć', 'æČłć',
'', '41', 'state', 1),
(952, 'state________952', 'æčć', 'æčć',
'', '42', 'state', 1),
(953, 'state________953', 'æčć', 'æčć',
'', '43', 'state', 1),
(954, 'state________954', 'ćčżäž', 'ćčżäž',
'', '44', 'state', 1),
(955, 'state_______________________955',
'ćčżè„żćŁźæèȘæČ»ćș', 'ćčżè„żćŁźæèȘæČ»ćș',
'', '45', 'state', 1),
(956, 'state________956', 'æ”·ć', 'æ”·ć',
'', '46', 'state', 1),
(957, 'state________957', 'éćș', 'éćș',
'', '50', 'state', 1),
(958, 'state________958', 'ćć·', 'ćć·',
'', '51', 'state', 1),
(959, 'state________959', '莔ć·', '莔ć·',
'', '52', 'state', 1),
(960, 'state________960', 'äșć', 'äșć',
'', '53', 'state', 1),
(961, 'state_________________961', 'è„żèèȘæČ»ćș',
'è„żèèȘæČ»ćș', '', '54',
'state', 1),
(962, 'state________962', 'éè„ż', 'éè„ż',
'', '61', 'state', 1),
(963, 'state________963', 'çè', 'çè',
'', '62', 'state', 1),
(964, 'state________964', 'éæ”·', 'éæ”·',
'', '63', 'state', 1),
(965, 'state________965', 'ćźć€', 'ćźć€',
'', '64', 'state', 1),
(966, 'state________966', 'æ°ç', 'æ°ç',
'', '65', 'state', 1),
(967, 'state________967', 'èșçŁ', 'èșçŁ',
'', '71', 'state', 1),
(968, 'state________968', 'éŠæžŻ', 'éŠæžŻ',
'', '91', 'state', 1),
(969, 'state________969', 'æŸłé', 'æŸłé',
'', '92', 'state', 1),
(970, 'state_Direction_Island_970', 'Direction Island',
'Direction Island', '', 'D',
'state', 1),
(971, 'state_Home_Island_971', 'Home Island',
'Home Island', '', 'H', 'state',
1),
(972, 'state_Horsburgh_Island_972', 'Horsburgh Island',
'Horsburgh Island', '', 'O',
'state', 1),
(973, 'state_South_Island_973', 'South Island',
'South Island', '', 'S', 'state',
1),
(974, 'state_West_Island_974', 'West Island',
'West Island', '', 'W', 'state',
1),
(975, 'state_Amazonas_975', 'Amazonas',
'Amazonas', '', 'AMA', 'state',
1),
(976, 'state_Antioquia_976', 'Antioquia',
'Antioquia', '', 'ANT', 'state',
1),
(977, 'state_Arauca_977', 'Arauca', 'Arauca',
'', 'ARA', 'state', 1),
(978, 'state_Atl__ntico_978', 'AtlĂĄntico',
'AtlĂĄntico', '', 'ATL', 'state',
1),
(979, 'state_Bol__var_979', 'BolĂvar',
'BolĂvar', '', 'BOL', 'state',
1),
(980, 'state_Boyac___980', 'BoyacĂĄ',
'BoyacĂĄ', '', 'BOY', 'state', 1),
(981, 'state_Caldas_981', 'Caldas', 'Caldas',
'', 'CAL', 'state', 1),
(982, 'state_Caquet___982', 'CaquetĂĄ',
'CaquetĂĄ', '', 'CAQ', 'state',
1),
(983, 'state_Casanare_983', 'Casanare',
'Casanare', '', 'CAS', 'state',
1),
(984, 'state_Cauca_984', 'Cauca', 'Cauca',
'', 'CAU', 'state', 1),
(985, 'state_Cesar_985', 'Cesar', 'Cesar',
'', 'CES', 'state', 1),
(986, 'state_Choc___986', 'ChocĂł', 'ChocĂł',
'', 'CHO', 'state', 1),
(987, 'state_C__rdoba_987', 'CĂłrdoba',
'CĂłrdoba', '', 'COR', 'state',
1),
(988, 'state_Cundinamarca_988', 'Cundinamarca',
'Cundinamarca', '', 'CUN', 'state',
1),
(989, 'state_Bogot___Distrito_Capital_989', 'BogotĂĄ
Distrito Capital', 'BogotĂĄ Distrito Capital', '',
'DC', 'state', 1),
(990, 'state_Guain__a_990', 'GuainĂa',
'GuainĂa', '', 'GUA', 'state',
1),
(991, 'state_Guaviare_991', 'Guaviare',
'Guaviare', '', 'GUV', 'state',
1),
(993, 'state_La_Guajira_993', 'La Guajira', 'La
Guajira', '', 'LAG', 'state', 1),
(994, 'state_Magdalena_994', 'Magdalena',
'Magdalena', '', 'MAG', 'state',
1),
(995, 'state_Meta_995', 'Meta', 'Meta',
'', 'MET', 'state', 1),
(996, 'state_Nari__o_996', 'Nariño',
'Nariño', '', 'NAR', 'state', 1),
(997, 'state_Norte_de_Santander_997', 'Norte de
Santander', 'Norte de Santander', '',
'NSA', 'state', 1),
(998, 'state_Putumayo_998', 'Putumayo',
'Putumayo', '', 'PUT', 'state',
1),
(999, 'state_Quind__o_999', 'QuindĂo',
'QuindĂo', '', 'QUI', 'state',
1);";
$this->db->setQuery($query);
$this->db->query();
$query="
INSERT IGNORE INTO `#__hikashop_zone` (`zone_id`, `zone_namekey`,
`zone_name`, `zone_name_english`, `zone_code_2`, `zone_code_3`,
`zone_type`, `zone_published`) VALUES
(1000, 'state_Risaralda_1000', 'Risaralda',
'Risaralda', '', 'RIS', 'state',
1),
(1001, 'state_Santander_1001', 'Santander',
'Santander', '', 'SAN', 'state',
1),
(1002, 'state_San_Andr__s_y_Providencia_1002', 'San Andrés
y Providencia', 'San Andrés y Providencia', '',
'SAP', 'state', 1),
(1003, 'state_Sucre_1003', 'Sucre', 'Sucre',
'', 'SUC', 'state', 1),
(1004, 'state_Tolima_1004', 'Tolima',
'Tolima', '', 'TOL', 'state', 1),
(1005, 'state_Valle_del_Cauca_1005', 'Valle del Cauca',
'Valle del Cauca', '', 'VAC',
'state', 1),
(1006, 'state_Vaup__s_1006', 'Vaupés',
'Vaupés', '', 'VAU', 'state', 1),
(1007, 'state_Vichada_1007', 'Vichada',
'Vichada', '', 'VID', 'state', 1),
(1008, 'state_Anjouan_1008', 'Anjouan',
'Anjouan', '', 'A', 'state', 1),
(1009, 'state_Grande_Comore_1009', 'Grande Comore',
'Grande Comore', '', 'G', 'state',
1),
(1010, 'state_Moh__li_1010', 'Mohéli',
'Mohéli', '', 'M', 'state', 1),
(1011, 'state_Congo_Central_1011', 'Congo-Central',
'Congo-Central', '', 'BC', 'state',
1),
(1012, 'state_Bandundu_1012', 'Bandundu',
'Bandundu', '', 'BN', 'state', 1),
(1013, 'state___quateur_1013', 'Ăquateur',
'Ăquateur', '', 'EQ', 'state',
1),
(1014, 'state_Katanga_1014', 'Katanga',
'Katanga', '', 'KA', 'state', 1),
(1015, 'state_Kasai_Oriental_1015', 'Kasai-Oriental',
'Kasai-Oriental', '', 'KE',
'state', 1),
(1016, 'state_Kinshasa_1016', 'Kinshasa',
'Kinshasa', '', 'KN', 'state', 1),
(1017, 'state_Kasai_Occidental_1017',
'Kasai-Occidental', 'Kasai-Occidental', '',
'KW', 'state', 1),
(1018, 'state_Maniema_1018', 'Maniema',
'Maniema', '', 'MA', 'state', 1),
(1019, 'state_Nord_Kivu_1019', 'Nord-Kivu',
'Nord-Kivu', '', 'NK', 'state',
1),
(1020, 'state_Orientale_1020', 'Orientale',
'Orientale', '', 'OR', 'state',
1),
(1021, 'state_Sud_Kivu_1021', 'Sud-Kivu',
'Sud-Kivu', '', 'SK', 'state', 1),
(1022, 'state_Pukapuka_1022', 'Pukapuka',
'Pukapuka', '', 'PU', 'state', 1),
(1023, 'state_Rakahanga_1023', 'Rakahanga',
'Rakahanga', '', 'RK', 'state',
1),
(1024, 'state_Manihiki_1024', 'Manihiki',
'Manihiki', '', 'MK', 'state', 1),
(1025, 'state_Penrhyn_1025', 'Penrhyn',
'Penrhyn', '', 'PE', 'state', 1),
(1026, 'state_Nassau_Island_1026', 'Nassau Island',
'Nassau Island', '', 'NI', 'state',
1),
(1027, 'state_Surwarrow_1027', 'Surwarrow',
'Surwarrow', '', 'SU', 'state',
1),
(1028, 'state_Palmerston_1028', 'Palmerston',
'Palmerston', '', 'PA', 'state',
1),
(1029, 'state_Aitutaki_1029', 'Aitutaki',
'Aitutaki', '', 'AI', 'state', 1),
(1030, 'state_Manuae_1030', 'Manuae',
'Manuae', '', 'MA', 'state', 1),
(1031, 'state_Takutea_1031', 'Takutea',
'Takutea', '', 'TA', 'state', 1),
(1032, 'state_Mitiaro_1032', 'Mitiaro',
'Mitiaro', '', 'MT', 'state', 1),
(1033, 'state_Atiu_1033', 'Atiu', 'Atiu',
'', 'AT', 'state', 1),
(1034, 'state_Mauke_1034', 'Mauke', 'Mauke',
'', 'MU', 'state', 1),
(1035, 'state_Rarotonga_1035', 'Rarotonga',
'Rarotonga', '', 'RR', 'state',
1),
(1036, 'state_Mangaia_1036', 'Mangaia',
'Mangaia', '', 'MG', 'state', 1),
(1037, 'state_Alajuela_1037', 'Alajuela',
'Alajuela', '', 'A', 'state', 1),
(1038, 'state_Cartago_1038', 'Cartago',
'Cartago', '', 'C', 'state', 1),
(1039, 'state_Guanacaste_1039', 'Guanacaste',
'Guanacaste', '', 'G', 'state',
1),
(1040, 'state_Heredia_1040', 'Heredia',
'Heredia', '', 'H', 'state', 1),
(1041, 'state_Lim__n_1041', 'LimĂłn',
'LimĂłn', '', 'L', 'state', 1),
(1042, 'state_Puntarenas_1042', 'Puntarenas',
'Puntarenas', '', 'P', 'state',
1),
(1043, 'state_San_Jos___1043', 'San José', 'San
José', '', 'SJ', 'state', 1),
(1044, 'state_Lagunes_1044', 'Lagunes',
'Lagunes', '', '01', 'state', 1),
(1045, 'state_Haut_Sassandra_1045', 'Haut-Sassandra',
'Haut-Sassandra', '', '02',
'state', 1),
(1046, 'state_Savanes_1046', 'Savanes',
'Savanes', '', '03', 'state', 1),
(1047, 'state_Vall__e_du_Bandama_1047', 'Vallée du
Bandama', 'Vallée du Bandama', '',
'04', 'state', 1),
(1048, 'state_Moyen_Como___1048', 'Moyen-Comoé',
'Moyen-Comoé', '', '05', 'state',
1),
(1049, 'state_Dix_Huit_1049', 'Dix-Huit',
'Dix-Huit', '', '06', 'state', 1),
(1050, 'state_Lacs_1050', 'Lacs', 'Lacs',
'', '07', 'state', 1),
(1051, 'state_Zanzan_1051', 'Zanzan',
'Zanzan', '', '08', 'state', 1),
(1052, 'state_Bas_Sassandra_1052', 'Bas-Sassandra',
'Bas-Sassandra', '', '09', 'state',
1),
(1053, 'state_Dengu__l___1053', 'Denguélé',
'Denguélé', '', '10', 'state',
1),
(1054, 'state_N_zi_Como___1054',
'N''zi-Comoé', 'N''zi-Comoé',
'', '11', 'state', 1),
(1055, 'state_Marahou___1055', 'Marahoué',
'Marahoué', '', '12', 'state',
1),
(1056, 'state_Sud_Como___1056', 'Sud-Comoé',
'Sud-Comoé', '', '13', 'state',
1),
(1057, 'state_Worodouqou_1057', 'Worodouqou',
'Worodouqou', '', '14', 'state',
1),
(1058, 'state_Sud_Bandama_1058', 'Sud-Bandama',
'Sud-Bandama', '', '15', 'state',
1),
(1059, 'state_Agn__bi_1059', 'Agnébi',
'Agnébi', '', '16', 'state', 1),
(1060, 'state_Bafing_1060', 'Bafing',
'Bafing', '', '17', 'state', 1),
(1061, 'state_Fromager_1061', 'Fromager',
'Fromager', '', '18', 'state', 1),
(1062, 'state_Moyen_Cavally_1062', 'Moyen-Cavally',
'Moyen-Cavally', '', '19', 'state',
1),
(1063, 'state_Zagreba__ka___upanija_1063', 'ZagrebaÄka
ĆŸupanija', 'ZagrebaÄka ĆŸupanija', '',
'01', 'state', 1),
(1064, 'state_Krapinsko_zagorska___upanija_1064',
'Krapinsko-zagorska ĆŸupanija', 'Krapinsko-zagorska
ĆŸupanija', '', '02', 'state', 1),
(1065, 'state_Sisa__ko_moslava__ka___upanija_1065',
'SisaÄko-moslavaÄka ĆŸupanija', 'SisaÄko-moslavaÄka
ĆŸupanija', '', '03', 'state', 1),
(1066, 'state_Karlova__ka___upanija_1066', 'KarlovaÄka
ĆŸupanija', 'KarlovaÄka ĆŸupanija', '',
'04', 'state', 1),
(1067, 'state_Vara__dinska___upanija_1067', 'VaraĆŸdinska
ĆŸupanija', 'VaraĆŸdinska ĆŸupanija', '',
'05', 'state', 1),
(1068, 'state_Koprivni__ko_kri__eva__ka___upanija_1068',
'KoprivniÄko-kriĆŸevaÄka ĆŸupanija',
'KoprivniÄko-kriĆŸevaÄka ĆŸupanija', '',
'06', 'state', 1),
(1069, 'state_Bjelovarsko_bilogorska___upanija_1069',
'Bjelovarsko-bilogorska ĆŸupanija', 'Bjelovarsko-bilogorska
ĆŸupanija', '', '07', 'state', 1),
(1070, 'state_Primorsko_goranska___upanija_1070',
'Primorsko-goranska ĆŸupanija', 'Primorsko-goranska
ĆŸupanija', '', '08', 'state', 1),
(1071, 'state_Li__ko_senjska___upanija_1071',
'LiÄko-senjska ĆŸupanija', 'LiÄko-senjska ĆŸupanija',
'', '09', 'state', 1),
(1072, 'state_Viroviti__ko_podravska___upanija_1072',
'VirovitiÄko-podravska ĆŸupanija', 'VirovitiÄko-podravska
ĆŸupanija', '', '10', 'state', 1),
(1073, 'state_Po__e__ko_slavonska___upanija_1073',
'PoĆŸeĆĄko-slavonska ĆŸupanija', 'PoĆŸeĆĄko-slavonska
ĆŸupanija', '', '11', 'state', 1),
(1074, 'state_Brodsko_posavska___upanija_1074',
'Brodsko-posavska ĆŸupanija', 'Brodsko-posavska
ĆŸupanija', '', '12', 'state', 1),
(1075, 'state_Zadarska___upanija_1075', 'Zadarska
ĆŸupanija', 'Zadarska ĆŸupanija', '',
'13', 'state', 1),
(1076, 'state_Osje__ko_baranjska___upanija_1076',
'OsjeÄko-baranjska ĆŸupanija', 'OsjeÄko-baranjska
ĆŸupanija', '', '14', 'state', 1),
(1077, 'state___ibensko_kninska___upanija_1077',
'Ć ibensko-kninska ĆŸupanija', 'Ć ibensko-kninska
ĆŸupanija', '', '15', 'state', 1),
(1078, 'state_Vukovarsko_srijemska___upanija_1078',
'Vukovarsko-srijemska ĆŸupanija', 'Vukovarsko-srijemska
ĆŸupanija', '', '16', 'state', 1),
(1079, 'state_Splitsko_dalmatinska___upanija_1079',
'Splitsko-dalmatinska ĆŸupanija', 'Splitsko-dalmatinska
ĆŸupanija', '', '17', 'state', 1),
(1080, 'state_Istarska___upanija_1080', 'Istarska
ĆŸupanija', 'Istarska ĆŸupanija', '',
'18', 'state', 1),
(1081, 'state_Dubrova__ko_neretvanska___upanija_1081',
'DubrovaÄko-neretvanska ĆŸupanija',
'DubrovaÄko-neretvanska ĆŸupanija', '',
'19', 'state', 1),
(1082, 'state_Me__imurska___upanija_1082', 'MeÄimurska
ĆŸupanija', 'MeÄimurska ĆŸupanija', '',
'20', 'state', 1),
(1083, 'state_Zagreb_1083', 'Zagreb',
'Zagreb', '', '21', 'state', 1),
(1084, 'state_Pinar_del_R__o_1084', 'Pinar del RĂo',
'Pinar del RĂo', '', '01',
'state', 1),
(1085, 'state_La_Habana_1085', 'La Habana', 'La
Habana', '', '02', 'state', 1),
(1086, 'state_Ciudad_de_La_Habana_1086', 'Ciudad de La
Habana', 'Ciudad de La Habana', '',
'03', 'state', 1),
(1087, 'state_Matanzas_1087', 'Matanzas',
'Matanzas', '', '04', 'state', 1),
(1088, 'state_Villa_Clara_1088', 'Villa Clara',
'Villa Clara', '', '05', 'state',
1),
(1089, 'state_Cienfuegos_1089', 'Cienfuegos',
'Cienfuegos', '', '06', 'state',
1),
(1090, 'state_Sancti_Sp__ritus_1090', 'Sancti
SpĂritus', 'Sancti SpĂritus', '',
'07', 'state', 1),
(1091, 'state_Ciego_de___vila_1091', 'Ciego de Ăvila',
'Ciego de Ăvila', '', '08',
'state', 1),
(1092, 'state_Camag__ey_1092', 'CamagĂŒey',
'CamagĂŒey', '', '09', 'state',
1),
(1093, 'state_Las_Tunas_1093', 'Las Tunas', 'Las
Tunas', '', '10', 'state', 1),
(1094, 'state_Holgu__n_1094', 'HolguĂn',
'HolguĂn', '', '11', 'state', 1),
(1095, 'state_Granma_1095', 'Granma',
'Granma', '', '12', 'state', 1),
(1096, 'state_Santiago_de_Cuba_1096', 'Santiago de
Cuba', 'Santiago de Cuba', '', '13',
'state', 1),
(1097, 'state_Guant__namo_1097', 'GuantĂĄnamo',
'GuantĂĄnamo', '', '14', 'state',
1),
(1098, 'state_Isla_de_la_Juventud_1098', 'Isla de la
Juventud', 'Isla de la Juventud', '',
'99', 'state', 1),
(1099, 'state_________v_______1099', 'ÎΔÏÏvΔÎčα',
'ÎΔÏÏvΔÎčα', '', '01',
'state', 1),
(1100, 'state__________________1100',
'ÎΔÏ
ÎșÏÏία', 'ÎΔÏ
ÎșÏÏία', '',
'02', 'state', 1),
(1101, 'state______________________1101',
'ÎΌΌÏÏÏÏÏÎżÏ', 'ÎΌΌÏÏÏÏÏÎżÏ',
'', '03', 'state', 1),
(1102, 'state________________1102', 'ÎÎŹÏΜαÎșα',
'ÎÎŹÏΜαÎșα', '', '04',
'state', 1),
(1103, 'state________________1103', 'ÎΔΌΔÏÏÏ',
'ÎΔΌΔÏÏÏ', '', '05',
'state', 1),
(1104, 'state____________1104', 'Î ÎŹÏÎżÏ',
'Î ÎŹÏÎżÏ', '', '06', 'state',
1),
(1105, 'state_Jiho__esk___kraj_1105', 'JihoÄeskĂœ
kraj', 'JihoÄeskĂœ kraj', '', 'JC',
'state', 1),
(1106, 'state_Jihomoravsk___kraj_1106', 'JihomoravskĂœ
kraj', 'JihomoravskĂœ kraj', '', 'JM',
'state', 1),
(1107, 'state_Karlovarsk___kraj_1107', 'KarlovarskĂœ
kraj', 'KarlovarskĂœ kraj', '', 'KA',
'state', 1),
(1108, 'state_Vyso__ina_kraj_1108', 'VysoÄina kraj',
'VysoÄina kraj', '', 'VY',
'state', 1),
(1109, 'state_Kr__lov__hradeck___kraj_1109',
'KrĂĄlovĂ©hradeckĂœ kraj', 'KrĂĄlovĂ©hradeckĂœ kraj',
'', 'KR', 'state', 1),
(1110, 'state_Libereck___kraj_1110', 'LibereckĂœ kraj',
'LibereckĂœ kraj', '', 'LI',
'state', 1),
(1111, 'state_Moravskoslezsk___kraj_1111', 'MoravskoslezskĂœ
kraj', 'MoravskoslezskĂœ kraj', '',
'MO', 'state', 1),
(1112, 'state_Olomouck___kraj_1112', 'OlomouckĂœ kraj',
'OlomouckĂœ kraj', '', 'OL',
'state', 1),
(1113, 'state_Pardubick___kraj_1113', 'PardubickĂœ
kraj', 'PardubickĂœ kraj', '', 'PA',
'state', 1),
(1114, 'state_Plze__sk___kraj_1114', 'PlzeĆskĂœ kraj',
'PlzeĆskĂœ kraj', '', 'PL',
'state', 1),
(1115, 'state_Hlavn___m__sto_Praha_1115', 'HlavnĂ mÄsto
Praha', 'HlavnĂ mÄsto Praha', '',
'PR', 'state', 1),
(1116, 'state_St__edo__esk___kraj_1116', 'StĆedoÄeskĂœ
kraj', 'StĆedoÄeskĂœ kraj', '', 'ST',
'state', 1),
(1117, 'state___steck___kraj_1117', 'ĂsteckĂœ kraj',
'ĂsteckĂœ kraj', '', 'US',
'state', 1),
(1118, 'state_Zl__nsk___kraj_1118', 'ZlĂnskĂœ kraj',
'ZlĂnskĂœ kraj', '', 'ZL',
'state', 1),
(1119, 'state_Bornholms_Regionskommune_1119', 'Bornholms
Regionskommune', 'Bornholms Regionskommune', '',
'040', 'state', 1),
(1120, 'state_K__benhavn_1120', 'KĂžbenhavn',
'KĂžbenhavn', '', '101', 'state',
1),
(1121, 'state_Frederiksberg_1121', 'Frederiksberg',
'Frederiksberg', '', '147',
'state', 1),
(1122, 'state___rhus_Amt_1122', 'Ă
rhus Amt',
'Ă
rhus Amt', '', '070', 'state',
1),
(1123, 'state_K__benhavns_Amt_1123', 'KĂžbenhavns Amt',
'KĂžbenhavns Amt', '', '015',
'state', 1),
(1124, 'state_Frederiksborg_Amt_1124', 'Frederiksborg
Amt', 'Frederiksborg Amt', '', '020',
'state', 1),
(1125, 'state_Fyns_Amt_1125', 'Fyns Amt', 'Fyns
Amt', '', '042', 'state', 1),
(1126, 'state_Nordjyllands_Amt_1126', 'Nordjyllands
Amt', 'Nordjyllands Amt', '', '080',
'state', 1),
(1127, 'state_Ribe_Amt_1127', 'Ribe Amt', 'Ribe
Amt', '', '055', 'state', 1),
(1128, 'state_Ringkj__bing_Amt_1128', 'RingkjĂžbing
Amt', 'RingkjĂžbing Amt', '', '065',
'state', 1),
(1129, 'state_Roskilde_Amt_1129', 'Roskilde Amt',
'Roskilde Amt', '', '025', 'state',
1),
(1130, 'state_S__nderjyllands_Amt_1130', 'SĂžnderjyllands
Amt', 'SĂžnderjyllands Amt', '', '050',
'state', 1),
(1131, 'state_Storstr__ms_Amt_1131', 'StorstrĂžms Amt',
'StorstrĂžms Amt', '', '035',
'state', 1),
(1132, 'state_Vejle_Amt_1132', 'Vejle Amt', 'Vejle
Amt', '', '060', 'state', 1),
(1133, 'state_Vestsj__llands_Amt_1133', 'VestsjĂŠllands
Amt', 'VestsjĂŠllands Amt', '', '030',
'state', 1),
(1134, 'state_Viborg_Amt_1134', 'Viborg Amt',
'Viborg Amt', '', '076', 'state',
1),
(1135, 'state_Region_d_Ali_Sabieh_1135', 'Region
d''Ali Sabieh', 'Region d''Ali Sabieh',
'', 'AS', 'state', 1),
(1136, 'state_Region_d_Arta_1136', 'Region
d''Arta', 'Region d''Arta',
'', 'AR', 'state', 1),
(1137, 'state_Region_de_Dikhil_1137', 'Region de
Dikhil', 'Region de Dikhil', '', 'DI',
'state', 1),
(1138, 'state_Ville_de_Djibouti_1138', 'Ville de
Djibouti', 'Ville de Djibouti', '',
'DJ', 'state', 1),
(1139, 'state_Region_d_Obock_1139', 'Region
d''Obock', 'Region d''Obock',
'', 'OB', 'state', 1),
(1140, 'state_Region_de_Tadjourah_1140', 'Region de
Tadjourah', 'Region de Tadjourah', '',
'TA', 'state', 1),
(1141, 'state_Saint_Andrew_Parish_1141', 'Saint Andrew
Parish', 'Saint Andrew Parish', '',
'AND', 'state', 1),
(1142, 'state_Saint_David_Parish_1142', 'Saint David
Parish', 'Saint David Parish', '',
'DAV', 'state', 1),
(1143, 'state_Saint_George_Parish_1143', 'Saint George
Parish', 'Saint George Parish', '',
'GEO', 'state', 1),
(1144, 'state_Saint_John_Parish_1144', 'Saint John
Parish', 'Saint John Parish', '', 'JOH',
'state', 1),
(1145, 'state_Saint_Joseph_Parish_1145', 'Saint Joseph
Parish', 'Saint Joseph Parish', '',
'JOS', 'state', 1),
(1146, 'state_Saint_Luke_Parish_1146', 'Saint Luke
Parish', 'Saint Luke Parish', '', 'LUK',
'state', 1),
(1147, 'state_Saint_Mark_Parish_1147', 'Saint Mark
Parish', 'Saint Mark Parish', '', 'MAR',
'state', 1),
(1148, 'state_Saint_Patrick_Parish_1148', 'Saint Patrick
Parish', 'Saint Patrick Parish', '',
'PAT', 'state', 1),
(1149, 'state_Saint_Paul_Parish_1149', 'Saint Paul
Parish', 'Saint Paul Parish', '', 'PAU',
'state', 1),
(1150, 'state_Saint_Peter_Parish_1150', 'Saint Peter
Parish', 'Saint Peter Parish', '',
'PET', 'state', 1),
(1151, 'state_Distrito_Nacional_1151', 'Distrito
Nacional', 'Distrito Nacional', '',
'01', 'state', 1),
(1152, 'state___zua_1152', 'Ăzua', 'Ăzua',
'', '02', 'state', 1),
(1153, 'state_Baoruco_1153', 'Baoruco',
'Baoruco', '', '03', 'state', 1),
(1154, 'state_Barahona_1154', 'Barahona',
'Barahona', '', '04', 'state', 1),
(1155, 'state_Dajab__n_1155', 'DajabĂłn',
'DajabĂłn', '', '05', 'state', 1),
(1156, 'state_Duarte_1156', 'Duarte',
'Duarte', '', '06', 'state', 1),
(1157, 'state_El__as_Pi__a_1157', 'ElĂas Piña',
'ElĂas Piña', '', '07', 'state',
1),
(1158, 'state_El_Seibo_1158', 'El Seibo', 'El
Seibo', '', '08', 'state', 1),
(1159, 'state_Espaillat_1159', 'Espaillat',
'Espaillat', '', '09', 'state',
1),
(1160, 'state_Independencia_1160', 'Independencia',
'Independencia', '', '10', 'state',
1),
(1161, 'state_La_Altagracia_1161', 'La Altagracia',
'La Altagracia', '', '11', 'state',
1),
(1162, 'state_La_Romana_1162', 'La Romana', 'La
Romana', '', '12', 'state', 1),
(1163, 'state_La_Vega_1163', 'La Vega', 'La
Vega', '', '13', 'state', 1),
(1164, 'state_Mar__a_Trinidad_S__nchez_1164', 'MarĂa
Trinidad SĂĄnchez', 'MarĂa Trinidad SĂĄnchez',
'', '14', 'state', 1),
(1165, 'state_Monte_Cristi_1165', 'Monte Cristi',
'Monte Cristi', '', '15', 'state',
1),
(1166, 'state_Pedernales_1166', 'Pedernales',
'Pedernales', '', '16', 'state',
1),
(1167, 'state_Peravia_1167', 'Peravia',
'Peravia', '', '17', 'state', 1),
(1168, 'state_Puerto_Plata_1168', 'Puerto Plata',
'Puerto Plata', '', '18', 'state',
1),
(1169, 'state_Salcedo_1169', 'Salcedo',
'Salcedo', '', '19', 'state', 1),
(1170, 'state_Saman___1170', 'SamanĂĄ',
'SamanĂĄ', '', '20', 'state', 1),
(1171, 'state_San_Crist__bal_1171', 'San CristĂłbal',
'San CristĂłbal', '', '21',
'state', 1),
(1172, 'state_San_Juan_1172', 'San Juan', 'San
Juan', '', '22', 'state', 1),
(1173, 'state_San_Pedro_de_Macor__s_1173', 'San Pedro de
MacorĂs', 'San Pedro de MacorĂs', '',
'23', 'state', 1),
(1174, 'state_S__nchez_Ram__rez_1174', 'SĂĄnchez
RamĂrez', 'SĂĄnchez RamĂrez', '',
'24', 'state', 1),
(1175, 'state_Santiago_1175', 'Santiago',
'Santiago', '', '25', 'state', 1),
(1176, 'state_Santiago_Rodr__guez_1176', 'Santiago
RodrĂguez', 'Santiago RodrĂguez', '',
'26', 'state', 1),
(1177, 'state_Valverde_1177', 'Valverde',
'Valverde', '', '27', 'state', 1),
(1178, 'state_Monse__or_Nouel_1178', 'Monseñor Nouel',
'Monseñor Nouel', '', '28',
'state', 1),
(1179, 'state_Monte_Plata_1179', 'Monte Plata',
'Monte Plata', '', '29', 'state',
1),
(1180, 'state_Hato_Mayor_1180', 'Hato Mayor',
'Hato Mayor', '', '30', 'state',
1),
(1181, 'state_Aileu_1181', 'Aileu', 'Aileu',
'', 'AL', 'state', 1),
(1182, 'state_Ainaro_1182', 'Ainaro',
'Ainaro', '', 'AN', 'state', 1),
(1183, 'state_Baucau_1183', 'Baucau',
'Baucau', '', 'BA', 'state', 1),
(1184, 'state_Bobonaro_1184', 'Bobonaro',
'Bobonaro', '', 'BO', 'state', 1),
(1185, 'state_Cova_Lima_1185', 'Cova-Lima',
'Cova-Lima', '', 'CO', 'state',
1),
(1186, 'state_Dili_1186', 'Dili', 'Dili',
'', 'DI', 'state', 1),
(1187, 'state_Ermera_1187', 'Ermera',
'Ermera', '', 'ER', 'state', 1),
(1188, 'state_Lautem_1188', 'Lautem',
'Lautem', '', 'LA', 'state', 1),
(1189, 'state_Liqui_____1189', 'Liquiçå',
'Liquiçå', '', 'LI', 'state',
1),
(1190, 'state_Manufahi_1190', 'Manufahi',
'Manufahi', '', 'MF', 'state', 1),
(1191, 'state_Manatuto_1191', 'Manatuto',
'Manatuto', '', 'MT', 'state', 1),
(1192, 'state_Oecussi_1192', 'Oecussi',
'Oecussi', '', 'OE', 'state', 1),
(1193, 'state_Viqueque_1193', 'Viqueque',
'Viqueque', '', 'VI', 'state', 1),
(1194, 'state_Azuay_1194', 'Azuay', 'Azuay',
'', 'A', 'state', 1),
(1195, 'state_Bol__var_1195', 'BolĂvar',
'BolĂvar', '', 'B', 'state', 1),
(1196, 'state_Carchi_1196', 'Carchi',
'Carchi', '', 'C', 'state', 1),
(1197, 'state_Orellana_1197', 'Orellana',
'Orellana', '', 'D', 'state', 1),
(1198, 'state_Esmeraldas_1198', 'Esmeraldas',
'Esmeraldas', '', 'E', 'state',
1),
(1199, 'state_Ca__ar_1199', 'Cañar',
'Cañar', '', 'F', 'state', 1),
(1200, 'state_Guayas_1200', 'Guayas',
'Guayas', '', 'G', 'state', 1),
(1201, 'state_Chimborazo_1201', 'Chimborazo',
'Chimborazo', '', 'H', 'state',
1),
(1202, 'state_Imbabura_1202', 'Imbabura',
'Imbabura', '', 'I', 'state', 1),
(1203, 'state_Loja_1203', 'Loja', 'Loja',
'', 'L', 'state', 1),
(1204, 'state_Manab___1204', 'ManabĂ',
'ManabĂ', '', 'M', 'state', 1),
(1205, 'state_Napo_1205', 'Napo', 'Napo',
'', 'N', 'state', 1),
(1206, 'state_El_Oro_1206', 'El Oro', 'El
Oro', '', 'O', 'state', 1),
(1207, 'state_Pichincha_1207', 'Pichincha',
'Pichincha', '', 'P', 'state', 1),
(1208, 'state_Los_R__os_1208', 'Los RĂos', 'Los
RĂos', '', 'R', 'state', 1),
(1209, 'state_Morona_Santiago_1209', 'Morona-Santiago',
'Morona-Santiago', '', 'S',
'state', 1),
(1210, 'state_Tungurahua_1210', 'Tungurahua',
'Tungurahua', '', 'T', 'state',
1),
(1211, 'state_Sucumb__os_1211', 'SucumbĂos',
'SucumbĂos', '', 'U', 'state',
1),
(1212, 'state_Gal__pagos_1212', 'GalĂĄpagos',
'GalĂĄpagos', '', 'W', 'state',
1),
(1213, 'state_Cotopaxi_1213', 'Cotopaxi',
'Cotopaxi', '', 'X', 'state', 1),
(1214, 'state_Pastaza_1214', 'Pastaza',
'Pastaza', '', 'Y', 'state', 1),
(1215, 'state_Zamora_Chinchipe_1215',
'Zamora-Chinchipe', 'Zamora-Chinchipe', '',
'Z', 'state', 1),
(1216, 'state______________________1216',
'ۧÙۄ۳ÙÙۯ۱ÙŰ©', 'ۧÙۄ۳ÙÙۯ۱ÙŰ©',
'', 'ALX', 'state', 1),
(1217, 'state____________1217', 'ŰŁŰłÙۧÙ',
'ŰŁŰłÙۧÙ', '', 'ASN', 'state',
1),
(1218, 'state____________1218', 'ŰŁŰłÙÙŰ·',
'ŰŁŰłÙÙŰ·', '', 'AST', 'state',
1),
(1219, 'state_________________________1219', 'ۧÙŰšŰ۱
ۧÙŰŁŰÙ
۱', 'ۧÙŰšŰ۱ ۧÙŰŁŰÙ
۱', '',
'BA', 'state', 1),
(1220, 'state________________1220', 'ۧÙŰšŰÙ۱۩',
'ۧÙŰšŰÙ۱۩', '', 'BH',
'state', 1),
(1221, 'state_________________1221', 'ŰšÙÙ ŰłÙÙÙ',
'ŰšÙÙ ŰłÙÙÙ', '', 'BNS',
'state', 1),
(1222, 'state________________1222', 'ۧÙÙۧÙ۱۩',
'ۧÙÙۧÙ۱۩', '', 'C', 'state',
1),
(1223, 'state__________________1223',
'ۧÙŰŻÙÙÙÙŰ©', 'ۧÙŰŻÙÙÙÙŰ©', '',
'DK', 'state', 1),
(1224, 'state____________1224', 'ŰŻÙ
Ùۧ۷',
'ŰŻÙ
Ùۧ۷', '', 'DT', 'state',
1),
(1225, 'state______________1225', 'ۧÙÙÙÙÙ
',
'ۧÙÙÙÙÙ
', '', 'FYM', 'state',
1),
(1226, 'state________________1226', 'ۧÙŰș۱ۚÙŰ©',
'ۧÙŰș۱ۚÙŰ©', '', 'GH',
'state', 1),
(1227, 'state______________1227', 'ۧÙŰŹÙŰČŰ©',
'ۧÙŰŹÙŰČŰ©', '', 'GZ', 'state',
1),
(1228, 'state________________________1228',
'ۧÙۄ۳Ù
ۧŰčÙÙÙŰ©', 'ۧÙۄ۳Ù
ۧŰčÙÙÙŰ©',
'', 'IS', 'state', 1),
(1229, 'state_____________________1229', 'ŰŹÙÙŰš
ŰłÙÙۧۥ', 'ŰŹÙÙŰš ŰłÙÙۧۥ', '',
'JS', 'state', 1),
(1230, 'state____________________1230',
'ۧÙÙÙÙÙŰšÙŰ©', 'ۧÙÙÙÙÙŰšÙŰ©',
'', 'KB', 'state', 1),
(1231, 'state___________________1231', 'ÙÙ۱
ۧÙŰŽÙŰź', 'ÙÙ۱ ۧÙŰŽÙŰź', '',
'KFS', 'state', 1),
(1232, 'state________1232', 'ÙÙۧ',
'ÙÙۧ', '', 'KN', 'state', 1),
(1233, 'state___________________________1233', 'Ù
ŰۧÙ۞۩
ۧÙÙ
ÙÙۧ', 'Ù
ŰۧÙ۞۩ ۧÙÙ
ÙÙۧ', '',
'MN', 'state', 1),
(1234, 'state__________________1234',
'ۧÙÙ
ÙÙÙÙŰ©', 'ۧÙÙ
ÙÙÙÙŰ©', '',
'MNF', 'state', 1),
(1235, 'state____________1235', 'Ù
۷۱ÙŰ',
'Ù
۷۱ÙŰ', '', 'MT', 'state',
1),
(1236, 'state______________________________1236',
'Ù
ŰۧÙ۞۩ ŰšÙ۱ ŰłŰčÙŰŻ', 'Ù
ŰۧÙ۞۩ ŰšÙ۱
ŰłŰčÙŰŻ', '', 'PTS', 'state', 1),
(1237, 'state_________________________1237', 'Ù
ŰۧÙ۞۩
ŰłÙÙۧۏ', 'Ù
ŰۧÙ۞۩ ŰłÙÙۧۏ', '',
'SHG', 'state', 1),
(1238, 'state___________________________________1238',
'ۧÙÙ
ŰۧÙ۞۩ ۧÙێ۱ÙÙÙŰ©', 'ۧÙÙ
ŰۧÙ۞۩
ۧÙێ۱ÙÙÙŰ©', '', 'SHR', 'state',
1),
(1239, 'state_____________________1239', 'ŰŽÙ
ۧÙ
ŰłÙÙۧۥ', 'ŰŽÙ
Ű§Ù ŰłÙÙۧۥ', '',
'SIN', 'state', 1),
(1240, 'state______________1240', 'ۧÙŰłÙÙŰł',
'ۧÙŰłÙÙŰł', '', 'SUZ', 'state',
1),
(1241, 'state___________________________1241', 'ۧÙÙۧۯÙ
ۧÙŰŹŰŻÙŰŻ', 'ۧÙÙŰ§ŰŻÙ Ű§ÙŰŹŰŻÙŰŻ', '',
'WAD', 'state', 1),
(1242, 'state_Ahuachap__n_1242', 'AhuachapĂĄn',
'AhuachapĂĄn', '', 'AH', 'state',
1),
(1243, 'state_Caba__as_1243', 'Cabañas',
'Cabañas', '', 'CA', 'state', 1),
(1244, 'state_Chalatenango_1244', 'Chalatenango',
'Chalatenango', '', 'CH', 'state',
1),
(1245, 'state_Cuscatl__n_1245', 'CuscatlĂĄn',
'CuscatlĂĄn', '', 'CU', 'state',
1),
(1246, 'state_La_Libertad_1246', 'La Libertad',
'La Libertad', '', 'LI', 'state',
1),
(1247, 'state_Moraz__n_1247', 'MorazĂĄn',
'MorazĂĄn', '', 'MO', 'state', 1),
(1248, 'state_La_Paz_1248', 'La Paz', 'La
Paz', '', 'PA', 'state', 1),
(1249, 'state_Santa_Ana_1249', 'Santa Ana', 'Santa
Ana', '', 'SA', 'state', 1),
(1250, 'state_San_Miguel_1250', 'San Miguel', 'San
Miguel', '', 'SM', 'state', 1),
(1251, 'state_Sonsonate_1251', 'Sonsonate',
'Sonsonate', '', 'SO', 'state',
1),
(1252, 'state_San_Salvador_1252', 'San Salvador',
'San Salvador', '', 'SS', 'state',
1),
(1253, 'state_San_Vicente_1253', 'San Vicente',
'San Vicente', '', 'SV', 'state',
1),
(1254, 'state_La_Uni__n_1254', 'La UniĂłn', 'La
UniĂłn', '', 'UN', 'state', 1),
(1255, 'state_Usulut__n_1255', 'UsulutĂĄn',
'UsulutĂĄn', '', 'US', 'state',
1),
(1256, 'state_Annob__n_1256', 'AnnobĂłn',
'AnnobĂłn', '', 'AN', 'state', 1),
(1257, 'state_Bioko_Norte_1257', 'Bioko Norte',
'Bioko Norte', '', 'BN', 'state',
1),
(1258, 'state_Bioko_Sur_1258', 'Bioko Sur', 'Bioko
Sur', '', 'BS', 'state', 1),
(1259, 'state_Centro_Sur_1259', 'Centro Sur',
'Centro Sur', '', 'CS', 'state',
1),
(1260, 'state_Ki___Ntem_1260', 'Kié-Ntem',
'Kié-Ntem', '', 'KN', 'state',
1),
(1261, 'state_Litoral_1261', 'Litoral',
'Litoral', '', 'LI', 'state', 1),
(1262, 'state_Wele_Nzas_1262', 'Wele-Nzas',
'Wele-Nzas', '', 'WN', 'state',
1),
(1263, 'state_Zoba_Anseba_1263', 'Zoba Anseba',
'Zoba Anseba', '', 'AN', 'state',
1),
(1264, 'state_Zoba_Debubawi_Keyih_Bahri_1264', 'Zoba
Debubawi Keyih Bahri', 'Zoba Debubawi Keyih Bahri',
'', 'DK', 'state', 1),
(1265, 'state_Zoba_Debub_1265', 'Zoba Debub',
'Zoba Debub', '', 'DU', 'state',
1),
(1266, 'state_Zoba_Gash_Barka_1266', 'Zoba Gash-Barka',
'Zoba Gash-Barka', '', 'GB',
'state', 1),
(1267, 'state_Zoba_Ma_akel_1267', 'Zoba
Ma''akel', 'Zoba Ma''akel',
'', 'MA', 'state', 1),
(1268, 'state_Zoba_Semienawi_Keyih_Bahri_1268', 'Zoba
Semienawi Keyih Bahri', 'Zoba Semienawi Keyih Bahri',
'', 'SK', 'state', 1),
(1269, 'state_Harju_maakond_1269', 'Harju maakond',
'Harju maakond', '', '37', 'state',
1),
(1270, 'state_Hiiu_maakond_1270', 'Hiiu maakond',
'Hiiu maakond', '', '39', 'state',
1),
(1271, 'state_Ida_Viru_maakond_1271', 'Ida-Viru
maakond', 'Ida-Viru maakond', '', '44',
'state', 1),
(1272, 'state_J__geva_maakond_1272', 'JÔgeva maakond',
'JÔgeva maakond', '', '49',
'state', 1),
(1273, 'state_J__rva_maakond_1273', 'JĂ€rva maakond',
'JĂ€rva maakond', '', '51',
'state', 1),
(1274, 'state_L____ne_maakond_1274', 'LÀÀne maakond',
'LÀÀne maakond', '', '57',
'state', 1),
(1275, 'state_L____ne_Viru_maakond_1275', 'LÀÀne-Viru
maakond', 'LÀÀne-Viru maakond', '',
'59', 'state', 1),
(1276, 'state_P__lva_maakond_1276', 'PÔlva maakond',
'PÔlva maakond', '', '65',
'state', 1),
(1277, 'state_P__rnu_maakond_1277', 'PĂ€rnu maakond',
'PĂ€rnu maakond', '', '67',
'state', 1),
(1278, 'state_Rapla_maakond_1278', 'Rapla maakond',
'Rapla maakond', '', '70', 'state',
1),
(1279, 'state_Saare_maakond_1279', 'Saare maakond',
'Saare maakond', '', '74', 'state',
1),
(1280, 'state_Tartu_maakond_1280', 'Tartu maakond',
'Tartu maakond', '', '78', 'state',
1),
(1281, 'state_Valga_maakond_1281', 'Valga maakond',
'Valga maakond', '', '82', 'state',
1),
(1282, 'state_Viljandi_maakond_1282', 'Viljandi
maakond', 'Viljandi maakond', '', '84',
'state', 1),
(1283, 'state_V__ru_maakond_1283', 'VÔru maakond',
'VÔru maakond', '', '86', 'state',
1),
(1284, 'state_____________________1284', 'á áČá”
á á áŁ', 'á áČá” á á áŁ', '',
'AA', 'state', 1),
(1285, 'state___________1285', 'á áá',
'á áá', '', 'AF', 'state',
1),
(1286, 'state___________1286', 'á áá«',
'á áá«', '', 'AH', 'state',
1),
(1287, 'state______________________________1287',
'á€áá»ááá-ááá',
'á€áá»ááá-ááá', '', 'BG',
'state', 1),
(1288, 'state______________1288', 'á”áŹáłá',
'á”áŹáłá', '', 'DD', 'state',
1),
(1289, 'state___________________________1289', 'ááá€á
áááŠáœ', 'ááá€á áááŠáœ', '',
'GB', 'state', 1),
(1290, 'state_____________________1290', 'áášáȘ
ááá„', 'áášáȘ ááá„', '',
'HR', 'state', 1),
(1291, 'state______________1291', 'áŠáźáá«',
'áŠáźáá«', '', 'OR', 'state',
1),
(1292, 'state___________1292', 'á¶áá',
'á¶áá', '', 'SM', 'state',
1),
(1293,
'state___________________________________________________________1293',
'á°áĄá„ á„ááźáœ á„áášá°áŠáœá áááŠáœ',
'á°áĄá„ á„ááźáœ á„áášá°áŠáœá áááŠáœ',
'', 'SN', 'state', 1),
(1294, 'state______________1294', 'á”áá«á',
'á”áá«á', '', 'TG', 'state',
1),
(1295, 'state_Central_1295', 'Central',
'Central', '', 'C', 'state', 1),
(1296, 'state_Northern_1296', 'Northern',
'Northern', '', 'E', 'state', 1),
(1297, 'state_Eastern_1297', 'Eastern',
'Eastern', '', 'N', 'state', 1),
(1298, 'state_Rotuma_1298', 'Rotuma',
'Rotuma', '', 'R', 'state', 1),
(1299, 'state_Western_1299', 'Western',
'Western', '', 'W', 'state', 1),
(1300, 'state_Ahvenanmaan_maakunta_1300', 'Ahvenanmaan
maakunta', 'Ahvenanmaan maakunta', '',
'AL', 'state', 1),
(1301, 'state_Etel___Suomen_l____ni_1301', 'EtelÀ-Suomen
lÀÀni', 'EtelÀ-Suomen lÀÀni', '',
'ES', 'state', 1),
(1302, 'state_It___Suomen_l____ni_1302', 'ItÀ-Suomen
lÀÀni', 'ItÀ-Suomen lÀÀni', '',
'IS', 'state', 1),
(1303, 'state_Lapin_l____ni_1303', 'Lapin lÀÀni',
'Lapin lÀÀni', '', 'LL', 'state',
1),
(1304, 'state_L__nsi_Suomen_l____ni_1304', 'LĂ€nsi-Suomen
lÀÀni', 'LÀnsi-Suomen lÀÀni', '',
'LS', 'state', 1),
(1305, 'state_Oulun_l____ni_1305', 'Oulun lÀÀni',
'Oulun lÀÀni', '', 'OL', 'state',
1),
(1306, 'state_Ain_1306', 'Ain', 'Ain',
'', '01', 'state', 1),
(1307, 'state_Aisne_1307', 'Aisne', 'Aisne',
'', '02', 'state', 1),
(1308, 'state_Allier_1308', 'Allier',
'Allier', '', '03', 'state', 1),
(1309, 'state_Alpes_de_Haute_Provence_1309',
'Alpes-de-Haute-Provence', 'Alpes-de-Haute-Provence',
'', '04', 'state', 1),
(1310, 'state_Hautes_Alpes_1310', 'Hautes-Alpes',
'Hautes-Alpes', '', '05', 'state',
1),
(1311, 'state_Alpes_Maritimes_1311', 'Alpes-Maritimes',
'Alpes-Maritimes', '', '06',
'state', 1),
(1312, 'state_Ard__che_1312', 'ArdĂšche',
'ArdĂšche', '', '07', 'state', 1),
(1313, 'state_Ardennes_1313', 'Ardennes',
'Ardennes', '', '08', 'state', 1),
(1314, 'state_Ari__ge_1314', 'AriĂšge',
'AriĂšge', '', '09', 'state', 1),
(1315, 'state_Aube_1315', 'Aube', 'Aube',
'', '10', 'state', 1),
(1316, 'state_Aude_1316', 'Aude', 'Aude',
'', '11', 'state', 1),
(1317, 'state_Aveyron_1317', 'Aveyron',
'Aveyron', '', '12', 'state', 1),
(1318, 'state_Bouches_du_Rh__ne_1318',
'Bouches-du-RhĂŽne', 'Bouches-du-RhĂŽne', '',
'13', 'state', 1),
(1319, 'state_Calvados_1319', 'Calvados',
'Calvados', '', '14', 'state', 1),
(1320, 'state_Cantal_1320', 'Cantal',
'Cantal', '', '15', 'state', 1),
(1321, 'state_Charente_1321', 'Charente',
'Charente', '', '16', 'state', 1),
(1322, 'state_Charente_Maritime_1322',
'Charente-Maritime', 'Charente-Maritime', '',
'17', 'state', 1),
(1323, 'state_Cher_1323', 'Cher', 'Cher',
'', '18', 'state', 1),
(1324, 'state_Corr__ze_1324', 'CorrĂšze',
'CorrĂšze', '', '19', 'state', 1),
(1325, 'state_C__te_d_Or_1325',
'CĂŽte-d''Or', 'CĂŽte-d''Or',
'', '21', 'state', 1),
(1326, 'state_C__tes_d_Armor_1326',
'CĂŽtes-d''Armor',
'CĂŽtes-d''Armor', '', '22',
'state', 1),
(1327, 'state_Creuse_1327', 'Creuse',
'Creuse', '', '23', 'state', 1),
(1328, 'state_Dordogne_1328', 'Dordogne',
'Dordogne', '', '24', 'state', 1),
(1329, 'state_Doubs_1329', 'Doubs', 'Doubs',
'', '25', 'state', 1),
(1330, 'state_Dr__me_1330', 'DrĂŽme',
'DrĂŽme', '', '26', 'state', 1),
(1331, 'state_Eure_1331', 'Eure', 'Eure',
'', '27', 'state', 1),
(1332, 'state_Eure_et_Loir_1332', 'Eure-et-Loir',
'Eure-et-Loir', '', '28', 'state',
1),
(1333, 'state_Finist__re_1333', 'FinistĂšre',
'FinistĂšre', '', '29', 'state',
1),
(1334, 'state_Corse_du_Sud_1334', 'Corse-du-Sud',
'Corse-du-Sud', '', '2A', 'state',
1),
(1335, 'state_Haute_Corse_1335', 'Haute-Corse',
'Haute-Corse', '', '2B', 'state',
1),
(1336, 'state_Gard_1336', 'Gard', 'Gard',
'', '30', 'state', 1),
(1337, 'state_Haute_Garonne_1337', 'Haute-Garonne',
'Haute-Garonne', '', '31', 'state',
1),
(1338, 'state_Gers_1338', 'Gers', 'Gers',
'', '32', 'state', 1),
(1339, 'state_Gironde_1339', 'Gironde',
'Gironde', '', '33', 'state', 1),
(1340, 'state_H__rault_1340', 'Hérault',
'Hérault', '', '34', 'state', 1),
(1341, 'state_Ille_et_Vilaine_1341', 'Ille-et-Vilaine',
'Ille-et-Vilaine', '', '35',
'state', 1),
(1342, 'state_Indre_1342', 'Indre', 'Indre',
'', '36', 'state', 1),
(1343, 'state_Indre_et_Loire_1343', 'Indre-et-Loire',
'Indre-et-Loire', '', '37',
'state', 1),
(1344, 'state_Is__re_1344', 'IsĂšre',
'IsĂšre', '', '38', 'state', 1),
(1345, 'state_Jura_1345', 'Jura', 'Jura',
'', '39', 'state', 1),
(1346, 'state_Landes_1346', 'Landes',
'Landes', '', '40', 'state', 1),
(1347, 'state_Loir_et_Cher_1347', 'Loir-et-Cher',
'Loir-et-Cher', '', '41', 'state',
1),
(1348, 'state_Loire_1348', 'Loire', 'Loire',
'', '42', 'state', 1),
(1349, 'state_Haute_Loire_1349', 'Haute-Loire',
'Haute-Loire', '', '43', 'state',
1),
(1350, 'state_Loire_Atlantique_1350',
'Loire-Atlantique', 'Loire-Atlantique', '',
'44', 'state', 1),
(1351, 'state_Loiret_1351', 'Loiret',
'Loiret', '', '45', 'state', 1),
(1352, 'state_Lot_1352', 'Lot', 'Lot',
'', '46', 'state', 1),
(1353, 'state_Lot_et_Garonne_1353', 'Lot-et-Garonne',
'Lot-et-Garonne', '', '47',
'state', 1),
(1354, 'state_Loz__re_1354', 'LozĂšre',
'LozĂšre', '', '48', 'state', 1),
(1355, 'state_Maine_et_Loire_1355', 'Maine-et-Loire',
'Maine-et-Loire', '', '49',
'state', 1),
(1356, 'state_Manche_1356', 'Manche',
'Manche', '', '50', 'state', 1),
(1357, 'state_Marne_1357', 'Marne', 'Marne',
'', '51', 'state', 1),
(1358, 'state_Haute_Marne_1358', 'Haute-Marne',
'Haute-Marne', '', '52', 'state',
1),
(1359, 'state_Mayenne_1359', 'Mayenne',
'Mayenne', '', '53', 'state', 1),
(1360, 'state_Meurthe_et_Moselle_1360',
'Meurthe-et-Moselle', 'Meurthe-et-Moselle',
'', '54', 'state', 1),
(1361, 'state_Meuse_1361', 'Meuse', 'Meuse',
'', '55', 'state', 1),
(1362, 'state_Morbihan_1362', 'Morbihan',
'Morbihan', '', '56', 'state', 1),
(1363, 'state_Moselle_1363', 'Moselle',
'Moselle', '', '57', 'state', 1),
(1364, 'state_Ni__vre_1364', 'NiĂšvre',
'NiĂšvre', '', '58', 'state', 1),
(1365, 'state_Nord_1365', 'Nord', 'Nord',
'', '59', 'state', 1),
(1366, 'state_Oise_1366', 'Oise', 'Oise',
'', '60', 'state', 1),
(1367, 'state_Orne_1367', 'Orne', 'Orne',
'', '61', 'state', 1),
(1368, 'state_Pas_de_Calais_1368', 'Pas-de-Calais',
'Pas-de-Calais', '', '62', 'state',
1),
(1369, 'state_Puy_de_D__me_1369', 'Puy-de-DĂŽme',
'Puy-de-DĂŽme', '', '63', 'state',
1),
(1370, 'state_Pyr__n__es_Atlantiques_1370',
'Pyrénées-Atlantiques', 'Pyrénées-Atlantiques',
'', '64', 'state', 1),
(1371, 'state_Hautes_Pyr__n__es_1371',
'Hautes-Pyrénées', 'Hautes-Pyrénées', '',
'65', 'state', 1),
(1372, 'state_Pyr__n__es_Orientales_1372',
'Pyrénées-Orientales', 'Pyrénées-Orientales',
'', '66', 'state', 1),
(1373, 'state_Bas_Rhin_1373', 'Bas-Rhin',
'Bas-Rhin', '', '67', 'state', 1),
(1374, 'state_Haut_Rhin_1374', 'Haut-Rhin',
'Haut-Rhin', '', '68', 'state',
1),
(1375, 'state_Rh__ne_1375', 'RhĂŽne',
'RhĂŽne', '', '69', 'state', 1),
(1376, 'state_Haute_Sa__ne_1376', 'Haute-SaĂŽne',
'Haute-SaĂŽne', '', '70', 'state',
1),
(1377, 'state_Sa__ne_et_Loire_1377', 'SaĂŽne-et-Loire',
'SaĂŽne-et-Loire', '', '71',
'state', 1),
(1378, 'state_Sarthe_1378', 'Sarthe',
'Sarthe', '', '72', 'state', 1),
(1379, 'state_Savoie_1379', 'Savoie',
'Savoie', '', '73', 'state', 1),
(1380, 'state_Haute_Savoie_1380', 'Haute-Savoie',
'Haute-Savoie', '', '74', 'state',
1),
(1381, 'state_Paris_1381', 'Paris', 'Paris',
'', '75', 'state', 1),
(1382, 'state_Seine_Maritime_1382', 'Seine-Maritime',
'Seine-Maritime', '', '76',
'state', 1),
(1383, 'state_Seine_et_Marne_1383', 'Seine-et-Marne',
'Seine-et-Marne', '', '77',
'state', 1),
(1384, 'state_Yvelines_1384', 'Yvelines',
'Yvelines', '', '78', 'state', 1),
(1385, 'state_Deux_S__vres_1385', 'Deux-SĂšvres',
'Deux-SĂšvres', '', '79', 'state',
1),
(1386, 'state_Somme_1386', 'Somme', 'Somme',
'', '80', 'state', 1),
(1387, 'state_Tarn_1387', 'Tarn', 'Tarn',
'', '81', 'state', 1),
(1388, 'state_Tarn_et_Garonne_1388', 'Tarn-et-Garonne',
'Tarn-et-Garonne', '', '82',
'state', 1),
(1389, 'state_Var_1389', 'Var', 'Var',
'', '83', 'state', 1),
(1390, 'state_Vaucluse_1390', 'Vaucluse',
'Vaucluse', '', '84', 'state', 1),
(1391, 'state_Vend__e_1391', 'Vendée',
'Vendée', '', '85', 'state', 1),
(1392, 'state_Vienne_1392', 'Vienne',
'Vienne', '', '86', 'state', 1),
(1393, 'state_Haute_Vienne_1393', 'Haute-Vienne',
'Haute-Vienne', '', '87', 'state',
1),
(1394, 'state_Vosges_1394', 'Vosges',
'Vosges', '', '88', 'state', 1),
(1395, 'state_Yonne_1395', 'Yonne', 'Yonne',
'', '89', 'state', 1),
(1396, 'state_Territoire_de_Belfort_1396', 'Territoire de
Belfort', 'Territoire de Belfort', '',
'90', 'state', 1),
(1397, 'state_Essonne_1397', 'Essonne',
'Essonne', '', '91', 'state', 1),
(1398, 'state_Hauts_de_Seine_1398', 'Hauts-de-Seine',
'Hauts-de-Seine', '', '92',
'state', 1),
(1399, 'state_Seine_Saint_Denis_1399',
'Seine-Saint-Denis', 'Seine-Saint-Denis', '',
'93', 'state', 1),
(1400, 'state_Val_de_Marne_1400', 'Val-de-Marne',
'Val-de-Marne', '', '94', 'state',
1),
(1401, 'state_Val_d_Oise_1401',
'Val-d''Oise', 'Val-d''Oise',
'', '95', 'state', 1),
(1402,
'state_Territoire_des_Nouvelle_Cal__donie_et_Dependances_1402',
'Territoire des Nouvelle-Calédonie et Dependances',
'Territoire des Nouvelle-Calédonie et Dependances',
'', 'NC', 'state', 1),
(1403, 'state_Polyn__sie_Fran__aise_1403', 'Polynésie
Française', 'Polynésie Française', '',
'PF', 'state', 1),
(1404, 'state_Saint_Pierre_et_Miquelon_1404', 'Saint-Pierre
et Miquelon', 'Saint-Pierre et Miquelon', '',
'PM', 'state', 1),
(1405, 'state_Terres_australes_et_antarctiques_fran__aises_1405',
'Terres australes et antarctiques françaises', 'Terres
australes et antarctiques françaises', '', 'TF',
'state', 1),
(1406, 'state_Mayotte_1406', 'Mayotte',
'Mayotte', '', 'YT', 'state', 1),
(1407, 'state_Territoire_des___les_Wallis_et_Futuna_1407',
'Territoire des Ăźles Wallis et Futuna', 'Territoire des
Ăźles Wallis et Futuna', '', 'WF',
'state', 1),
(1408, 'state_Archipel_des_Marquises_1408', 'Archipel des
Marquises', 'Archipel des Marquises', '',
'M', 'state', 1),
(1409, 'state_Archipel_des_Tuamotu_1409', 'Archipel des
Tuamotu', 'Archipel des Tuamotu', '',
'T', 'state', 1),
(1410, 'state_Archipel_des_Tubuai_1410', 'Archipel des
Tubuai', 'Archipel des Tubuai', '', 'I',
'state', 1),
(1411, 'state_Iles_du_Vent_1411', 'Iles du Vent',
'Iles du Vent', '', 'V', 'state',
1),
(1412, 'state_Iles_Sous_le_Vent__1412', 'Iles Sous-le-Vent
', 'Iles Sous-le-Vent ', '', 'S',
'state', 1),
(1413, 'state_Iles_Crozet_1413', 'Iles Crozet',
'Iles Crozet', '', 'C', 'state',
1),
(1414, 'state_Iles_Kerguelen_1414', 'Iles Kerguelen',
'Iles Kerguelen', '', 'K', 'state',
1),
(1415, 'state_Ile_Amsterdam_1415', 'Ile Amsterdam',
'Ile Amsterdam', '', 'A', 'state',
1),
(1416, 'state_Ile_Saint_Paul_1416', 'Ile Saint-Paul',
'Ile Saint-Paul', '', 'P', 'state',
1),
(1417, 'state_Adelie_Land_1417', 'Adelie Land',
'Adelie Land', '', 'D', 'state',
1),
(1418, 'state_Estuaire_1418', 'Estuaire',
'Estuaire', '', 'ES', 'state', 1),
(1419, 'state_Haut_Ogooue_1419', 'Haut-Ogooue',
'Haut-Ogooue', '', 'HO', 'state',
1),
(1420, 'state_Moyen_Ogooue_1420', 'Moyen-Ogooue',
'Moyen-Ogooue', '', 'MO', 'state',
1),
(1421, 'state_Ngounie_1421', 'Ngounie',
'Ngounie', '', 'NG', 'state', 1),
(1422, 'state_Nyanga_1422', 'Nyanga',
'Nyanga', '', 'NY', 'state', 1),
(1423, 'state_Ogooue_Ivindo_1423', 'Ogooue-Ivindo',
'Ogooue-Ivindo', '', 'OI', 'state',
1),
(1424, 'state_Ogooue_Lolo_1424', 'Ogooue-Lolo',
'Ogooue-Lolo', '', 'OL', 'state',
1),
(1425, 'state_Ogooue_Maritime_1425', 'Ogooue-Maritime',
'Ogooue-Maritime', '', 'OM',
'state', 1),
(1426, 'state_Woleu_Ntem_1426', 'Woleu-Ntem',
'Woleu-Ntem', '', 'WN', 'state',
1),
(1427, 'state_Ashanti_1427', 'Ashanti',
'Ashanti', '', 'AH', 'state', 1),
(1428, 'state_Brong_Ahafo_1428', 'Brong-Ahafo',
'Brong-Ahafo', '', 'BA', 'state',
1),
(1429, 'state_Central_1429', 'Central',
'Central', '', 'CP', 'state', 1),
(1430, 'state_Eastern_1430', 'Eastern',
'Eastern', '', 'EP', 'state', 1),
(1431, 'state_Greater_Accra_1431', 'Greater Accra',
'Greater Accra', '', 'AA', 'state',
1),
(1432, 'state_Northern_1432', 'Northern',
'Northern', '', 'NP', 'state', 1),
(1433, 'state_Upper_East_1433', 'Upper East',
'Upper East', '', 'UE', 'state',
1),
(1434, 'state_Upper_West_1434', 'Upper West',
'Upper West', '', 'UW', 'state',
1),
(1435, 'state_Volta_1435', 'Volta', 'Volta',
'', 'TV', 'state', 1),
(1436, 'state_Western_1436', 'Western',
'Western', '', 'WP', 'state', 1),
(1437, 'state__________________________1437',
'áá€áźááááá', 'áá€áźááááá',
'', 'AB', 'state', 1),
(1438, 'state_________________1438', 'áááá á',
'áááá á', '', 'AJ',
'state', 1),
(1439, 'state_________________1439', 'ááŁá áá',
'ááŁá áá', '', 'GU',
'state', 1),
(1440, 'state_______________________1440',
'áááá ááá', 'áááá ááá',
'', 'IM', 'state', 1),
(1441, 'state____________________1441',
'áááźááá', 'áááźááá',
'', 'KA', 'state', 1),
(1442, 'state____________________________________1442',
'á„áááá á„áá ááá', 'á„áááá
á„áá ááá', '', 'KK', 'state',
1),
(1443, 'state_____________________________________________1443',
'ááȘáźááá-áááááááá',
'ááȘáźááá-áááááááá', '',
'MM', 'state', 1),
(1444,
'state_________________________________________________________________________________1444',
'á ááá-ááá©áźáŁáá áá á„áááá
áĄáááááá', 'á ááá-ááá©áźáŁáá
áá á„áááá áĄáááááá', '',
'RL', 'state', 1),
(1445, 'state_____________________________________________1445',
'áĄáááȘáźá-áŻááááźááá',
'áĄáááȘáźá-áŻááááźááá', '',
'SJ', 'state', 1),
(1446, 'state_________________________________1446',
'ášááá á„áá ááá', 'ášááá
á„áá ááá', '', 'SK', 'state',
1),
(1447,
'state________________________________________________________________1447',
'áĄááááá ááá-áááá áĄáááááá',
'áĄááááá ááá-áááá áĄáááááá',
'', 'SZ', 'state', 1),
(1448, 'state_______________________1448',
'ááááááĄá', 'ááááááĄá',
'', 'TB', 'state', 1),
(1449, 'state_Berlin_1449', 'Berlin',
'Berlin', '', 'BE', 'state', 1),
(1450, 'state_Brandenburg_1450', 'Brandenburg',
'Brandenburg', '', 'BR', 'state',
1),
(1451, 'state_Baden_W__rttemberg_1451',
'Baden-WĂŒrttemberg', 'Baden-WĂŒrttemberg',
'', 'BW', 'state', 1),
(1452, 'state_Bayern_1452', 'Bayern',
'Bayern', '', 'BY', 'state', 1),
(1453, 'state_Bremen_1453', 'Bremen',
'Bremen', '', 'HB', 'state', 1),
(1454, 'state_Hessen_1454', 'Hessen',
'Hessen', '', 'HE', 'state', 1),
(1455, 'state_Hamburg_1455', 'Hamburg',
'Hamburg', '', 'HH', 'state', 1),
(1456, 'state_Mecklenburg_Vorpommern_1456',
'Mecklenburg-Vorpommern', 'Mecklenburg-Vorpommern',
'', 'MV', 'state', 1),
(1457, 'state_Niedersachsen_1457', 'Niedersachsen',
'Niedersachsen', '', 'NI', 'state',
1),
(1458, 'state_Nordrhein_Westfalen_1458',
'Nordrhein-Westfalen', 'Nordrhein-Westfalen',
'', 'NW', 'state', 1),
(1459, 'state_Rheinland_Pfalz_1459', 'Rheinland-Pfalz',
'Rheinland-Pfalz', '', 'RP',
'state', 1),
(1460, 'state_Schleswig_Holstein_1460',
'Schleswig-Holstein', 'Schleswig-Holstein',
'', 'SH', 'state', 1),
(1461, 'state_Saarland_1461', 'Saarland',
'Saarland', '', 'SL', 'state', 1),
(1462, 'state_Sachsen_1462', 'Sachsen',
'Sachsen', '', 'SN', 'state', 1),
(1463, 'state_Sachsen_Anhalt_1463', 'Sachsen-Anhalt',
'Sachsen-Anhalt', '', 'ST',
'state', 1),
(1464, 'state_Th__ringen_1464', 'ThĂŒringen',
'ThĂŒringen', '', 'TH', 'state',
1),
(1475, 'state________________________________1475',
'ÎÎčÏÏλοαÎșαÏÎœÎ±ÎœÎŻÎ±',
'ÎÎčÏÏλοαÎșαÏÎœÎ±ÎœÎŻÎ±', '', '01',
'state', 1),
(1476, 'state________________1476', 'ÎÎżÎčÏÏία',
'ÎÎżÎčÏÏία', '', '03',
'state', 1),
(1477, 'state______________1477', 'ÎÏÎČÎżÎčα',
'ÎÏÎČÎżÎčα', '', '04', 'state',
1),
(1478, 'state____________________1478',
'ÎÏ
ÏÏ
ÏÎ±ÎœÎŻÎ±', 'ÎÏ
ÏÏ
ÏÎ±ÎœÎŻÎ±',
'', '05', 'state', 1),
(1479, 'state__________________1479',
'ΊΞÎčÏÏÎčΎα', 'ΊΞÎčÏÏÎčΎα', '',
'06', 'state', 1),
(1480, 'state______________1480', 'ΊÏÎșίΎα',
'ΊÏÎșίΎα', '', '07', 'state',
1),
(1481, 'state__________________1481',
'ÎÏγολίΎα', 'ÎÏγολίΎα', '',
'11', 'state', 1),
(1482, 'state________________1482', 'ÎÏÎșαΎία',
'ÎÏÎșαΎία', '', '12',
'state', 1),
(1483, 'state_____________1483', 'áŒÏαÎα',
'áŒÏαÎα', '', '13', 'state',
1),
(1484, 'state____________1484', 'ÎλΔία',
'ÎλΔία', '', '14', 'state',
1),
(1485, 'state__________________1485',
'ÎÎżÏÎčÎœÎžÎŻÎ±', 'ÎÎżÏÎčÎœÎžÎŻÎ±', '',
'15', 'state', 1),
(1486, 'state________________1486', 'ÎαÎșÏÎœÎŻÎ±',
'ÎαÎșÏÎœÎŻÎ±', '', '16',
'state', 1),
(1487, 'state__________________1487',
'ÎΔÏÏÎ·ÎœÎŻÎ±', 'ÎΔÏÏÎ·ÎœÎŻÎ±', '',
'17', 'state', 1),
(1488, 'state__________________1488',
'ÎÎŹÎșÏ
ÎœÎžÎżÏ', 'ÎÎŹÎșÏ
ÎœÎžÎżÏ', '',
'21', 'state', 1),
(1489, 'state________________1489', 'ÎÎÏÎșÏ
Ïα',
'ÎÎÏÎșÏ
Ïα', '', '22',
'state', 1),
(1490, 'state______________________1490',
'ÎΔÏÎ±Î»Î»ÎżÎœÎčÎŹ', 'ÎΔÏÎ±Î»Î»ÎżÎœÎčÎŹ',
'', '23', 'state', 1),
(1491, 'state________________1491', 'ÎΔÏ
ÎșΏΎα',
'ÎΔÏ
ÎșΏΎα', '', '24',
'state', 1),
(1492, 'state__________1492', 'ÎÏÏα',
'ÎÏÏα', '', '31', 'state', 1),
(1493, 'state____________________1493',
'ÎΔÏÏÏÏÏία', 'ÎΔÏÏÏÏÏία',
'', '32', 'state', 1),
(1494, 'state__________________1494',
'ÎÏÎŹÎœÎœÎčΜα', 'ÎÏÎŹÎœÎœÎčΜα', '',
'33', 'state', 1),
(1495, 'state________________1495', 'Î ÏΔÎČΔζα',
'Î ÏΔÎČΔζα', '', '34',
'state', 1),
(1496, 'state__________________1496',
'ÎαÏÎŽÎŻÏÏα', 'ÎαÏÎŽÎŻÏÏα', '',
'41', 'state', 1),
(1497, 'state______________1497', 'ÎÎŹÏÎčÏα',
'ÎÎŹÏÎčÏα', '', '42', 'state',
1),
(1498, 'state__________________1498',
'ÎÎ±ÎłÎœÎ·Ïία', 'ÎÎ±ÎłÎœÎ·Ïία', '',
'43', 'state', 1),
(1499, 'state________________1499', '΀ÏÎŻÎșαλα',
'΀ÏÎŻÎșαλα', '', '44',
'state', 1);";
$this->db->setQuery($query);
$this->db->query();
$query="
INSERT IGNORE INTO `#__hikashop_zone` (`zone_id`, `zone_namekey`,
`zone_name`, `zone_name_english`, `zone_code_2`, `zone_code_3`,
`zone_type`, `zone_published`) VALUES
(1500, 'state________________1500', 'ÎÏΔÎČÎ”ÎœÎŹ',
'ÎÏΔÎČÎ”ÎœÎŹ', '', '51',
'state', 1),
(1501, 'state____________1501', 'ÎÏÎŹÎŒÎ±',
'ÎÏÎŹÎŒÎ±', '', '52', 'state',
1),
(1502, 'state______________1502', 'ÎÎŒÎ±ÎžÎŻÎ±',
'ÎÎŒÎ±ÎžÎŻÎ±', '', '53', 'state',
1),
(1503, 'state________________________1503',
'ÎΔÏÏÎ±Î»ÎżÎœÎŻÎșη', 'ÎΔÏÏÎ±Î»ÎżÎœÎŻÎșη',
'', '54', 'state', 1),
(1504, 'state______________1504', 'ÎαÎČΏλα',
'ÎαÎČΏλα', '', '55', 'state',
1),
(1505, 'state__________________1505',
'ÎαÏÏÎżÏÎčÎŹ', 'ÎαÏÏÎżÏÎčÎŹ', '',
'56', 'state', 1),
(1506, 'state______________1506', 'ÎÎčλÎșÎŻÏ',
'ÎÎčλÎșÎŻÏ', '', '57', 'state',
1),
(1507, 'state______________1507', 'ÎÎżÎ¶ÎŹÎœÎ·',
'ÎÎżÎ¶ÎŹÎœÎ·', '', '58', 'state',
1),
(1508, 'state____________1508', 'Î Îλλα',
'Î Îλλα', '', '59', 'state',
1),
(1509, 'state______________1509', 'Î ÎčΔÏία',
'Î ÎčΔÏία', '', '61', 'state',
1),
(1510, 'state______________1510', 'ΣΔÏÏÏΜ',
'ΣΔÏÏÏΜ', '', '62', 'state',
1),
(1511, 'state________________1511', 'ΊλÏÏÎčΜα',
'ΊλÏÏÎčΜα', '', '63',
'state', 1),
(1512, 'state____________________1512',
'ΧαλÎșÎčÎŽÎčÎșÎź', 'ΧαλÎșÎčÎŽÎčÎșÎź',
'', '64', 'state', 1),
(1513, 'state___________________1513', 'ÎÏÎżÏ
ÎΞÏÏ', 'ÎÏÎżÏ ÎΞÏÏ', '',
'69', 'state', 1),
(1514, 'state____________1514', 'ÎÎČÏÎżÏ',
'ÎÎČÏÎżÏ', '', '71', 'state',
1),
(1515, 'state____________1515', 'ÎÎŹÎœÎžÎ·',
'ÎÎŹÎœÎžÎ·', '', '72', 'state',
1),
(1516, 'state______________1516', 'ΥοΎÏÏη',
'ΥοΎÏÏη', '', '73', 'state',
1),
(1517, 'state______________________1517',
'ÎÏΎΔÎșÎŹÎœÎ·Ïα', 'ÎÏΎΔÎșÎŹÎœÎ·Ïα',
'', '81', 'state', 1),
(1518, 'state__________________1518',
'ÎÏ
ÎșλΏΎΔÏ', 'ÎÏ
ÎșλΏΎΔÏ', '',
'82', 'state', 1),
(1519, 'state______________1519', 'ÎÎÏÎČÎżÏ
',
'ÎÎÏÎČÎżÏ
', '', '83', 'state',
1),
(1520, 'state____________1520', 'ÎŁÎŹÎŒÎżÏ',
'ÎŁÎŹÎŒÎżÏ', '', '84', 'state',
1),
(1521, 'state__________1521', 'ΧίοÏ',
'ΧίοÏ', '', '85', 'state', 1),
(1522, 'state__________________1522',
'ÎÏÎŹÎșλΔÎčÎż', 'ÎÏÎŹÎșλΔÎčÎż', '',
'91', 'state', 1),
(1523, 'state______________1523', 'ÎαÏίΞÎč',
'ÎαÏίΞÎč', '', '92', 'state',
1),
(1524, 'state________________1524', 'ΥΔΞÏÎŒÎœÎż',
'ΥΔΞÏÎŒÎœÎż', '', '93',
'state', 1),
(1525, 'state______________1525', 'Î§Î±ÎœÎŻÏΜ',
'Î§Î±ÎœÎŻÏΜ', '', '94', 'state',
1),
(1526, 'state______________1526', 'ÎÏÏÎčÎșÎź',
'ÎÏÏÎčÎșÎź', '', 'A1', 'state',
1),
(1527, 'state_Avannaa_1527', 'Avannaa',
'Avannaa', '', 'A', 'state', 1),
(1528, 'state_Tunu__1528', 'Tunu ', 'Tunu ',
'', 'T', 'state', 1),
(1529, 'state_Kitaa_1529', 'Kitaa', 'Kitaa',
'', 'K', 'state', 1),
(1531, 'state_Saint_David_1531', 'Saint David',
'Saint David', '', 'D', 'state',
1),
(1534, 'state_Saint_Mark_1534', 'Saint Mark',
'Saint Mark', '', 'M', 'state',
1),
(1535, 'state_Saint_Patrick_1535', 'Saint Patrick',
'Saint Patrick', '', 'P', 'state',
1),
(1536, 'state_Alta_Verapaz_1536', 'Alta Verapaz',
'Alta Verapaz', '', 'AV', 'state',
1),
(1537, 'state_Baja_Verapaz_1537', 'Baja Verapaz',
'Baja Verapaz', '', 'BV', 'state',
1),
(1538, 'state_Chimaltenango_1538', 'Chimaltenango',
'Chimaltenango', '', 'CM', 'state',
1),
(1539, 'state_Chiquimula_1539', 'Chiquimula',
'Chiquimula', '', 'CQ', 'state',
1),
(1540, 'state_Escuintla_1540', 'Escuintla',
'Escuintla', '', 'ES', 'state',
1),
(1541, 'state_Guatemala_1541', 'Guatemala',
'Guatemala', '', 'GU', 'state',
1),
(1542, 'state_Huehuetenango_1542', 'Huehuetenango',
'Huehuetenango', '', 'HU', 'state',
1),
(1543, 'state_Izabal_1543', 'Izabal',
'Izabal', '', 'IZ', 'state', 1),
(1544, 'state_Jalapa_1544', 'Jalapa',
'Jalapa', '', 'JA', 'state', 1),
(1545, 'state_Jutiapa_1545', 'Jutiapa',
'Jutiapa', '', 'JU', 'state', 1),
(1546, 'state_El_Pet__n_1546', 'El Petén', 'El
Petén', '', 'PE', 'state', 1),
(1547, 'state_El_Progreso_1547', 'El Progreso',
'El Progreso', '', 'PR', 'state',
1),
(1548, 'state_El_Quich___1548', 'El Quiché', 'El
Quiché', '', 'QC', 'state', 1),
(1549, 'state_Quetzaltenango_1549', 'Quetzaltenango',
'Quetzaltenango', '', 'QZ',
'state', 1),
(1550, 'state_Retalhuleu_1550', 'Retalhuleu',
'Retalhuleu', '', 'RE', 'state',
1),
(1551, 'state_Sacatep__quez_1551', 'Sacatepéquez',
'Sacatepéquez', '', 'SA', 'state',
1),
(1552, 'state_San_Marcos_1552', 'San Marcos', 'San
Marcos', '', 'SM', 'state', 1),
(1553, 'state_Solol___1553', 'SololĂĄ',
'SololĂĄ', '', 'SO', 'state', 1),
(1554, 'state_Santa_Rosa_1554', 'Santa Rosa',
'Santa Rosa', '', 'SR', 'state',
1),
(1555, 'state_Suchitep__quez_1555', 'Suchitepéquez',
'Suchitepéquez', '', 'SU',
'state', 1),
(1556, 'state_Totonicap__n_1556', 'TotonicapĂĄn',
'TotonicapĂĄn', '', 'TO', 'state',
1),
(1557, 'state_Zacapa_1557', 'Zacapa',
'Zacapa', '', 'ZA', 'state', 1),
(1558, 'state_Beyla_1558', 'Beyla', 'Beyla',
'', 'BE', 'state', 1),
(1559, 'state_Boffa_1559', 'Boffa', 'Boffa',
'', 'BF', 'state', 1),
(1560, 'state_Bok___1560', 'Boké', 'Boké',
'', 'BK', 'state', 1),
(1561, 'state_Coyah_1561', 'Coyah', 'Coyah',
'', 'CO', 'state', 1),
(1562, 'state_Dabola_1562', 'Dabola',
'Dabola', '', 'DB', 'state', 1),
(1563, 'state_Dinguiraye_1563', 'Dinguiraye',
'Dinguiraye', '', 'DI', 'state',
1),
(1564, 'state_Dalaba_1564', 'Dalaba',
'Dalaba', '', 'DL', 'state', 1),
(1565, 'state_Dubr__ka_1565', 'Dubréka',
'Dubréka', '', 'DU', 'state', 1),
(1566, 'state_Faranah_1566', 'Faranah',
'Faranah', '', 'FA', 'state', 1),
(1567, 'state_For__cariah_1567', 'Forécariah',
'Forécariah', '', 'FO', 'state',
1),
(1568, 'state_Fria_1568', 'Fria', 'Fria',
'', 'FR', 'state', 1),
(1569, 'state_Gaoual_1569', 'Gaoual',
'Gaoual', '', 'GA', 'state', 1),
(1570, 'state_Gu__k__dou_1570', 'Guékédou',
'Guékédou', '', 'GU', 'state',
1),
(1571, 'state_Kankan_1571', 'Kankan',
'Kankan', '', 'KA', 'state', 1),
(1572, 'state_Koubia_1572', 'Koubia',
'Koubia', '', 'KB', 'state', 1),
(1573, 'state_Kindia_1573', 'Kindia',
'Kindia', '', 'KD', 'state', 1),
(1574, 'state_K__rouan___1574', 'Kérouané',
'Kérouané', '', 'KE', 'state',
1),
(1575, 'state_Koundara_1575', 'Koundara',
'Koundara', '', 'KN', 'state', 1),
(1576, 'state_Kouroussa_1576', 'Kouroussa',
'Kouroussa', '', 'KO', 'state',
1),
(1577, 'state_Kissidougou_1577', 'Kissidougou',
'Kissidougou', '', 'KS', 'state',
1),
(1578, 'state_Lab___1578', 'Labé', 'Labé',
'', 'LA', 'state', 1),
(1579, 'state_L__louma_1579', 'Lélouma',
'Lélouma', '', 'LE', 'state', 1),
(1580, 'state_Lola_1580', 'Lola', 'Lola',
'', 'LO', 'state', 1),
(1581, 'state_Macenta_1581', 'Macenta',
'Macenta', '', 'MC', 'state', 1),
(1582, 'state_Mandiana_1582', 'Mandiana',
'Mandiana', '', 'MD', 'state', 1),
(1583, 'state_Mali_1583', 'Mali', 'Mali',
'', 'ML', 'state', 1),
(1584, 'state_Mamou_1584', 'Mamou', 'Mamou',
'', 'MM', 'state', 1),
(1585, 'state_Nz__r__kor___1585', 'Nzérékoré',
'Nzérékoré', '', 'NZ', 'state',
1),
(1586, 'state_Pita_1586', 'Pita', 'Pita',
'', 'PI', 'state', 1),
(1587, 'state_Siguiri_1587', 'Siguiri',
'Siguiri', '', 'SI', 'state', 1),
(1588, 'state_T__lim__l___1588', 'Télimélé',
'Télimélé', '', 'TE', 'state',
1),
(1589, 'state_Tougu___1589', 'Tougué',
'Tougué', '', 'TO', 'state', 1),
(1590, 'state_Yomou_1590', 'Yomou', 'Yomou',
'', 'YO', 'state', 1),
(1591, 'state_Bafata_1591', 'Bafata',
'Bafata', '', 'BF', 'state', 1),
(1592, 'state_Biombo_1592', 'Biombo',
'Biombo', '', 'BB', 'state', 1),
(1593, 'state_Bissau_1593', 'Bissau',
'Bissau', '', 'BS', 'state', 1),
(1594, 'state_Bolama_1594', 'Bolama',
'Bolama', '', 'BL', 'state', 1),
(1595, 'state_Cacheu_1595', 'Cacheu',
'Cacheu', '', 'CA', 'state', 1),
(1596, 'state_Gabu_1596', 'Gabu', 'Gabu',
'', 'GA', 'state', 1),
(1597, 'state_Oio_1597', 'Oio', 'Oio',
'', 'OI', 'state', 1),
(1598, 'state_Quinara_1598', 'Quinara',
'Quinara', '', 'QU', 'state', 1),
(1599, 'state_Tombali_1599', 'Tombali',
'Tombali', '', 'TO', 'state', 1),
(1600, 'state_Barima_Waini_1600', 'Barima-Waini',
'Barima-Waini', '', 'BA', 'state',
1),
(1601, 'state_Cuyuni_Mazaruni_1601', 'Cuyuni-Mazaruni',
'Cuyuni-Mazaruni', '', 'CU',
'state', 1),
(1602, 'state_Demerara_Mahaica_1602',
'Demerara-Mahaica', 'Demerara-Mahaica', '',
'DE', 'state', 1),
(1603, 'state_East_Berbice_Corentyne_1603', 'East
Berbice-Corentyne', 'East Berbice-Corentyne', '',
'EB', 'state', 1),
(1604, 'state_Essequibo_Islands_West_Demerara_1604',
'Essequibo Islands-West Demerara', 'Essequibo Islands-West
Demerara', '', 'ES', 'state', 1),
(1605, 'state_Mahaica_Berbice_1605', 'Mahaica-Berbice',
'Mahaica-Berbice', '', 'MA',
'state', 1),
(1606, 'state_Pomeroon_Supenaam_1606',
'Pomeroon-Supenaam', 'Pomeroon-Supenaam', '',
'PM', 'state', 1),
(1607, 'state_Potaro_Siparuni_1607', 'Potaro-Siparuni',
'Potaro-Siparuni', '', 'PT',
'state', 1),
(1608, 'state_Upper_Demerara_Berbice_1608', 'Upper
Demerara-Berbice', 'Upper Demerara-Berbice', '',
'UD', 'state', 1),
(1609, 'state_Upper_Takutu_Upper_Essequibo_1609', 'Upper
Takutu-Upper Essequibo', 'Upper Takutu-Upper Essequibo',
'', 'UT', 'state', 1),
(1610, 'state_Artibonite_1610', 'Artibonite',
'Artibonite', '', 'AR', 'state',
1),
(1612, 'state_Grand_Anse_1612',
'Grand''Anse', 'Grand''Anse',
'', 'GA', 'state', 1),
(1613, 'state_Nippes_1613', 'Nippes',
'Nippes', '', 'NI', 'state', 1),
(1614, 'state_Nord_1614', 'Nord', 'Nord',
'', 'ND', 'state', 1),
(1615, 'state_Nord_Est_1615', 'Nord-Est',
'Nord-Est', '', 'NE', 'state', 1),
(1616, 'state_Nord_Ouest_1616', 'Nord-Ouest',
'Nord-Ouest', '', 'NO', 'state',
1),
(1618, 'state_Sud_1618', 'Sud', 'Sud',
'', 'SD', 'state', 1),
(1619, 'state_Sud_Est_1619', 'Sud-Est',
'Sud-Est', '', 'SE', 'state', 1),
(1620, 'state_Flat_Island_1620', 'Flat Island',
'Flat Island', '', 'F', 'state',
1),
(1621, 'state_McDonald_Island_1621', 'McDonald Island',
'McDonald Island', '', 'M',
'state', 1),
(1622, 'state_Shag_Island_1622', 'Shag Island',
'Shag Island', '', 'S', 'state',
1),
(1623, 'state_Heard_Island_1623', 'Heard Island',
'Heard Island', '', 'H', 'state',
1),
(1624, 'state_Atl__ntida_1624', 'AtlĂĄntida',
'AtlĂĄntida', '', 'AT', 'state',
1),
(1625, 'state_Choluteca_1625', 'Choluteca',
'Choluteca', '', 'CH', 'state',
1),
(1626, 'state_Col__n_1626', 'ColĂłn',
'ColĂłn', '', 'CL', 'state', 1),
(1627, 'state_Comayagua_1627', 'Comayagua',
'Comayagua', '', 'CM', 'state',
1),
(1628, 'state_Cop__n_1628', 'CopĂĄn',
'CopĂĄn', '', 'CP', 'state', 1),
(1629, 'state_Cort__s_1629', 'Cortés',
'Cortés', '', 'CR', 'state', 1),
(1630, 'state_El_Para__so_1630', 'El ParaĂso',
'El ParaĂso', '', 'EP', 'state',
1),
(1631, 'state_Francisco_Moraz__n_1631', 'Francisco
MorazĂĄn', 'Francisco MorazĂĄn', '',
'FM', 'state', 1),
(1632, 'state_Gracias_a_Dios_1632', 'Gracias a Dios',
'Gracias a Dios', '', 'GD',
'state', 1),
(1633, 'state_Islas_de_la_Bah__a_1633', 'Islas de la
BahĂa', 'Islas de la BahĂa', '', 'IB',
'state', 1),
(1634, 'state_Intibuc___1634', 'IntibucĂĄ',
'IntibucĂĄ', '', 'IN', 'state',
1),
(1635, 'state_Lempira_1635', 'Lempira',
'Lempira', '', 'LE', 'state', 1),
(1636, 'state_La_Paz_1636', 'La Paz', 'La
Paz', '', 'LP', 'state', 1),
(1637, 'state_Ocotepeque_1637', 'Ocotepeque',
'Ocotepeque', '', 'OC', 'state',
1),
(1638, 'state_Olancho_1638', 'Olancho',
'Olancho', '', 'OL', 'state', 1),
(1639, 'state_Santa_B__rbara_1639', 'Santa BĂĄrbara',
'Santa BĂĄrbara', '', 'SB',
'state', 1),
(1640, 'state_Valle_1640', 'Valle', 'Valle',
'', 'VA', 'state', 1),
(1641, 'state_Yoro_1641', 'Yoro', 'Yoro',
'', 'YO', 'state', 1),
(1642, 'state___________1642', 'äžè„żć',
'äžè„żć', '', 'HCW', 'state',
1),
(1643, 'state________1643', 'æ±ć',
'æ±ć', '', 'HEA', 'state', 1),
(1644, 'state________1644', 'ćć',
'ćć', '', 'HSO', 'state', 1),
(1645, 'state___________1645', 'çŁä»ć',
'çŁä»ć', '', 'HWC', 'state',
1),
(1646, 'state______________1646', 'äčéŸćć',
'äčéŸćć', '', 'KKC', 'state',
1),
(1647, 'state___________1647', 'è§ćĄć',
'è§ćĄć', '', 'KKT', 'state',
1),
(1648, 'state______________1648', '深氎ćć',
'深氎ćć', '', 'KSS', 'state',
1),
(1649, 'state______________1649', 'é»ć€§ä»ć',
'é»ć€§ä»ć', '', 'KWT', 'state',
1),
(1650, 'state______________1650', 'æČčć°æșć',
'æČčć°æșć', '', 'KYT', 'state',
1),
(1651, 'state___________1651', 'éąćł¶ć',
'éąćł¶ć', '', 'NIS', 'state',
1),
(1652, 'state___________1652', 'è”éć',
'è”éć', '', 'NKT', 'state',
1),
(1653, 'state________1653', 'ćć',
'ćć', '', 'NNO', 'state', 1),
(1654, 'state___________1654', 'è„żèČąć',
'è„żèČąć', '', 'NSK', 'state',
1),
(1655, 'state___________1655', 'æČç°ć',
'æČç°ć', '', 'NST', 'state',
1),
(1656, 'state___________1656', '性ćć',
'性ćć', '', 'NTP', 'state',
1),
(1657, 'state___________1657', 'èçŁć',
'èçŁć', '', 'NTW', 'state',
1),
(1658, 'state___________1658', '汯éć',
'汯éć', '', 'NTM', 'state',
1),
(1659, 'state___________1659', 'ć
æć',
'ć
æć', '', 'NYL', 'state',
1),
(1660, 'state_Baranja_megye_1660', 'Baranja megye',
'Baranja megye', '', 'BA', 'state',
1),
(1661, 'state_B__k__scsaba_1661', 'Békéscsaba',
'Békéscsaba', '', 'BC', 'state',
1),
(1662, 'state_B__k__s_megye_1662', 'Békés megye',
'Békés megye', '', 'BE', 'state',
1),
(1663, 'state_B__cs_Kiskun_megye_1663', 'BĂĄcs-Kiskun
megye', 'BĂĄcs-Kiskun megye', '', 'BK',
'state', 1),
(1664, 'state_Budapest_1664', 'Budapest',
'Budapest', '', 'BU', 'state', 1),
(1665, 'state_Borsod_Aba__j_Zempl__n_megye_1665',
'Borsod-AbaĂșj-ZemplĂ©n megye', 'Borsod-AbaĂșj-ZemplĂ©n
megye', '', 'BZ', 'state', 1),
(1666, 'state_Csongr__d_megye_1666', 'CsongrĂĄd megye',
'CsongrĂĄd megye', '', 'CS',
'state', 1),
(1667, 'state_Debrecen_1667', 'Debrecen',
'Debrecen', '', 'DE', 'state', 1),
(1668, 'state_Duna__jv__ros_1668', 'DunaĂșjvĂĄros',
'DunaĂșjvĂĄros', '', 'DU', 'state',
1),
(1669, 'state_Eger_1669', 'Eger', 'Eger',
'', 'EG', 'state', 1),
(1670, 'state_Fej__r_megye_1670', 'Fejér megye',
'Fejér megye', '', 'FE', 'state',
1),
(1671, 'state_Gy__r_Moson_Sopron_megye_1671',
'GyĆr-Moson-Sopron megye', 'GyĆr-Moson-Sopron megye',
'', 'GS', 'state', 1),
(1672, 'state_Gy__r_1672', 'GyĆr', 'GyĆr',
'', 'GY', 'state', 1),
(1673, 'state_Hajd___Bihar_megye_1673', 'HajdĂș-Bihar
megye', 'HajdĂș-Bihar megye', '', 'HB',
'state', 1),
(1674, 'state_Heves_megye_1674', 'Heves megye',
'Heves megye', '', 'HE', 'state',
1),
(1675, 'state_H__dmez__v__s__rhely_1675',
'HĂłdmezĆvĂĄsĂĄrhely', 'HĂłdmezĆvĂĄsĂĄrhely',
'', 'HV', 'state', 1),
(1676, 'state_J__sz_Nagykun_Szolnok_megye_1676',
'JĂĄsz-Nagykun-Szolnok megye', 'JĂĄsz-Nagykun-Szolnok
megye', '', 'JN', 'state', 1),
(1677, 'state_Kom__rom_Esztergom_megye_1677',
'KomĂĄrom-Esztergom megye', 'KomĂĄrom-Esztergom megye',
'', 'KE', 'state', 1),
(1678, 'state_Kecskem__t_1678', 'Kecskemét',
'Kecskemét', '', 'KM', 'state',
1),
(1679, 'state_Kaposv__r_1679', 'KaposvĂĄr',
'KaposvĂĄr', '', 'KV', 'state',
1),
(1680, 'state_Miskolc_1680', 'Miskolc',
'Miskolc', '', 'MI', 'state', 1),
(1681, 'state_Nagykanizsa_1681', 'Nagykanizsa',
'Nagykanizsa', '', 'NK', 'state',
1),
(1682, 'state_N__gr__d_megye_1682', 'NĂłgrĂĄd megye',
'NĂłgrĂĄd megye', '', 'NO',
'state', 1),
(1683, 'state_Ny__regyh__za_1683', 'NyĂregyhĂĄza',
'NyĂregyhĂĄza', '', 'NY', 'state',
1),
(1684, 'state_Pest_megye_1684', 'Pest megye',
'Pest megye', '', 'PE', 'state',
1),
(1685, 'state_P__cs_1685', 'Pécs', 'Pécs',
'', 'PS', 'state', 1),
(1686, 'state_Szeged_1686', 'Szeged',
'Szeged', '', 'SD', 'state', 1),
(1687, 'state_Sz__kesfeh__rv__r_1687',
'Székesfehérvår', 'Székesfehérvår', '',
'SF', 'state', 1),
(1688, 'state_Szombathely_1688', 'Szombathely',
'Szombathely', '', 'SH', 'state',
1),
(1689, 'state_Szolnok_1689', 'Szolnok',
'Szolnok', '', 'SK', 'state', 1),
(1690, 'state_Sopron_1690', 'Sopron',
'Sopron', '', 'SN', 'state', 1),
(1691, 'state_Somogy_megye_1691', 'Somogy megye',
'Somogy megye', '', 'SO', 'state',
1),
(1692, 'state_Szeksz__rd_1692', 'SzekszĂĄrd',
'SzekszĂĄrd', '', 'SS', 'state',
1),
(1693, 'state_Salg__tarj__n_1693', 'SalgĂłtarjĂĄn',
'SalgĂłtarjĂĄn', '', 'ST', 'state',
1),
(1694, 'state_Szabolcs_Szatm__r_Bereg_megye_1694',
'Szabolcs-SzatmĂĄr-Bereg megye', 'Szabolcs-SzatmĂĄr-Bereg
megye', '', 'SZ', 'state', 1),
(1695, 'state_Tatab__nya_1695', 'TatabĂĄnya',
'TatabĂĄnya', '', 'TB', 'state',
1),
(1696, 'state_Tolna_megye_1696', 'Tolna megye',
'Tolna megye', '', 'TO', 'state',
1),
(1697, 'state_Vas_megye_1697', 'Vas megye', 'Vas
megye', '', 'VA', 'state', 1),
(1698, 'state_Veszpr__m_megye_1698', 'Veszprém megye',
'Veszprém megye', '', 'VE',
'state', 1),
(1699, 'state_Veszpr__m_1699', 'Veszprém',
'Veszprém', '', 'VM', 'state',
1),
(1700, 'state_Zala_megye_1700', 'Zala megye',
'Zala megye', '', 'ZA', 'state',
1),
(1701, 'state_Zalaegerszeg_1701', 'Zalaegerszeg',
'Zalaegerszeg', '', 'ZE', 'state',
1),
(1702, 'state_H__fu__borgarsv____i___1702',
'HöfuðborgarsvÊðið', 'HöfuðborgarsvÊðið',
'', '1', 'state', 1),
(1703, 'state_Su__urnes_1703', 'Suðurnes',
'Suðurnes', '', '2', 'state', 1),
(1704, 'state_Vesturland_1704', 'Vesturland',
'Vesturland', '', '3', 'state',
1),
(1705, 'state_Vestfir__ir_1705', 'Vestfirðir',
'Vestfirðir', '', '4', 'state',
1),
(1706, 'state_Nor__urland_vestra_1706', 'Norðurland
vestra', 'Norðurland vestra', '', '5',
'state', 1),
(1707, 'state_Nor__urland_eystra_1707', 'Norðurland
eystra', 'Norðurland eystra', '', '6',
'state', 1),
(1708, 'state_Austfir__ir_1708', 'Austfirðir',
'Austfirðir', '', '7', 'state',
1),
(1709, 'state_Su__urland_1709', 'Suðurland',
'Suðurland', '', '8', 'state',
1),
(1710,
'state_________________________________________________________________1710',
'à€
à€à€Ąà€źà€Ÿà€š à€à€° à€šà€żà€à„à€Źà€Ÿà€°
à€Šà„à€”à„à€Ș', 'à€
à€à€Ąà€źà€Ÿà€š à€à€°
à€šà€żà€à„à€Źà€Ÿà€° à€Šà„à€”à„à€Ș', '',
'IN-AN', 'state', 1),
(1711, 'state_______________________________________1711',
'à°à°à°§à±à°° à°Șà±à°°à°Šà±à°¶à±', 'à°à°à°§à±à°°
à°Șà±à°°à°Šà±à°¶à±', '', 'IN-AP',
'state', 1),
(1712, 'state__________________________________________1712',
'à€
à€°à„à€Łà€Ÿà€à€Č à€Șà„à€°à€Šà„à€¶',
'à€
à€°à„à€Łà€Ÿà€à€Č à€Șà„à€°à€Šà„à€¶', '',
'IN-AR', 'state', 1),
(1713, 'state___________1713', 'àŠ
àŠžàŠź',
'àŠ
àŠžàŠź', '', 'IN-AS', 'state',
1),
(1714, 'state_________________1714', 'à€Źà€żà€čà€Ÿà€°',
'à€Źà€żà€čà€Ÿà€°', '', 'IN-BR',
'state', 1),
(1715, 'state_______________________1715',
'à€à€à€Ąà„à€à€ąà€Œ', 'à€à€à€Ąà„à€à€ąà€Œ',
'', 'IN-CH', 'state', 1),
(1716, 'state_____________________________1716',
'à€à€€à„à€€à„à€žà€à€ąà€Œ',
'à€à€€à„à€€à„à€žà€à€ąà€Œ', '', 'IN-CT',
'state', 1),
(1717, 'state_______________________________1717',
'àȘŠàȘźàȘŁ àȘ
àȘšà« àȘŠàȘżàȘ”', 'àȘŠàȘźàȘŁ àȘ
àȘšà«
àȘŠàȘżàȘ”', '', 'IN-DD', 'state', 1),
(1718, 'state____________________1718',
'à€Šà€żà€Čà„à€Čà„', 'à€Šà€żà€Čà„à€Čà„',
'', 'IN-DL', 'state', 1),
(1719,
'state_____________________________________________________1719',
'àȘŠàȘŸàȘŠàȘ°àȘŸ àȘ
àȘšà« àȘšàȘàȘ° àȘčàȘ”à«àȘČà«',
'àȘŠàȘŸàȘŠàȘ°àȘŸ àȘ
àȘšà« àȘšàȘàȘ° àȘčàȘ”à«àȘČà«',
'', 'IN-DN', 'state', 1),
(1720, 'state______________1720', 'à€à„à€à€Ż',
'à€à„à€à€Ż', '', 'IN-GA',
'state', 1),
(1721, 'state____________________1721',
'àȘà«àȘàȘ°àȘŸàȘ€', 'àȘà«àȘàȘ°àȘŸàȘ€',
'', 'IN-GJ', 'state', 1),
(1722, 'state_______________________________________1722',
'à€čà€żà€źà€Ÿà€à€Č à€Șà„à€°à€Šà„à€¶', 'à€čà€żà€źà€Ÿà€à€Č
à€Șà„à€°à€Šà„à€¶', '', 'IN-HP',
'state', 1),
(1723, 'state_______________________1723',
'à€čà€°à€żà€Żà€Ÿà€Łà€Ÿ', 'à€čà€°à€żà€Żà€Ÿà€Łà€Ÿ',
'', 'IN-HR', 'state', 1),
(1724, 'state____________________1724',
'à€à€Ÿà€°à€à€à€Ą', 'à€à€Ÿà€°à€à€à€Ą',
'', 'IN-JH', 'state', 1),
(1725, 'state___________________________________________1725',
'à€à€źà„à€źà„ à€à€° à€à€¶à„à€źà„à€°',
'à€à€źà„à€źà„ à€à€° à€à€¶à„à€źà„à€°', '',
'IN-JK', 'state', 1),
(1726, 'state____________________1726',
'àČàČšàČŸàłŻàČàČ', 'àČàČšàČŸàłŻàČàČ',
'', 'IN-KA', 'state', 1),
(1727, 'state_________________1727', 'àŽà”àŽ°àŽłàŽ',
'àŽà”àŽ°àŽłàŽ', '', 'IN-KL',
'state', 1),
(1728, 'state________________________________1728',
'àŽČàŽà”àŽ·àŽŠà”àŽ”à”àŽȘà”',
'àŽČàŽà”àŽ·àŽŠà”àŽ”à”àŽȘà”', '',
'IN-LD', 'state', 1),
(1729, 'state____________________1729',
'à€źà„à€à€Ÿà€Čà€Ż', 'à€źà„à€à€Ÿà€Čà€Ż',
'', 'IN-ML', 'state', 1),
(1730, 'state________________________________1730',
'à€źà€čà€Ÿà€°à€Ÿà€·à„à€à„à€°',
'à€źà€čà€Ÿà€°à€Ÿà€·à„à€à„à€°', '',
'IN-MH', 'state', 1),
(1731, 'state____________________1731',
'à€źà€Łà€żà€Șà„à€°', 'à€źà€Łà€żà€Șà„à€°',
'', 'IN-MN', 'state', 1),
(1732, 'state_________________________________1732',
'à€źà€§à„à€Ż à€Șà„à€°à€Šà„à€¶', 'à€źà€§à„à€Ż
à€Șà„à€°à€Šà„à€¶', '', 'IN-MP',
'state', 1),
(1733, 'state_______________________1733',
'à€źà€żà€à€Œà„à€°à€ź', 'à€źà€żà€à€Œà„à€°à€ź',
'', 'IN-MZ', 'state', 1),
(1734, 'state__________________________1734',
'à€šà€Ÿà€à€Ÿà€Čà„à€à€Ą', 'à€šà€Ÿà€à€Ÿà€Čà„à€à€Ą',
'', 'IN-NL', 'state', 1),
(1735, 'state____________________1735',
'à€à€Ąà€Œà„à€žà€Ÿ', 'à€à€Ąà€Œà„à€žà€Ÿ',
'', 'IN-OR', 'state', 1),
(1736, 'state_________________1736', 'àšȘà©°àšàšŸàšŹ',
'àšȘà©°àšàšŸàšŹ', '', 'IN-PB',
'state', 1),
(1737, 'state________________________________1737',
'àźȘàŻàź€àŻàźàŻàźàŻàź°àźż',
'àźȘàŻàź€àŻàźàŻàźàŻàź°àźż', '',
'IN-PY', 'state', 1),
(1738, 'state__________________________1738',
'à€°à€Ÿà€à€žà„à€„à€Ÿà€š', 'à€°à€Ÿà€à€žà„à€„à€Ÿà€š',
'', 'IN-RJ', 'state', 1),
(1739, 'state_______________________1739',
'à€žà€żà€à„à€à€żà€ź', 'à€žà€żà€à„à€à€żà€ź',
'', 'IN-SK', 'state', 1),
(1740, 'state______________________________1740',
'àź€àźźàźżàźŽàŻ àźšàźŸàźàŻ', 'àź€àźźàźżàźŽàŻ
àźšàźŸàźàŻ', '', 'IN-TN', 'state',
1),
(1741, 'state__________________________1741',
'àŠ€à§àŠ°àŠżàŠȘà§àŠ°àŠŸ', 'àŠ€à§àŠ°àŠżàŠȘà§àŠ°àŠŸ',
'', 'IN-TR', 'state', 1),
(1742, 'state_____________________________1742',
'à€à€€à„à€€à€°à€Ÿà€à€à€Č',
'à€à€€à„à€€à€°à€Ÿà€à€à€Č', '', 'IN-UL',
'state', 1),
(1743, 'state____________________________________1743',
'à€à€€à„à€€à€° à€Șà„à€°à€Šà„à€¶', 'à€à€€à„à€€à€°
à€Șà„à€°à€Šà„à€¶', '', 'IN-UP',
'state', 1),
(1744, 'state________________________________1744',
'àŠȘàŠ¶à§àŠàŠżàŠźàŠŹàŠà§àŠ',
'àŠȘàŠ¶à§àŠàŠżàŠźàŠŹàŠà§àŠ', '',
'IN-WB', 'state', 1),
(1745, 'state_Aceh_1745', 'Aceh', 'Aceh',
'', 'AC', 'state', 1),
(1746, 'state_Bali_1746', 'Bali', 'Bali',
'', 'BA', 'state', 1),
(1747, 'state_Bangka_Belitung_1747', 'Bangka-Belitung',
'Bangka-Belitung', '', 'BB',
'state', 1),
(1748, 'state_Bengkulu_1748', 'Bengkulu',
'Bengkulu', '', 'BE', 'state', 1),
(1749, 'state_Banten_1749', 'Banten',
'Banten', '', 'BT', 'state', 1),
(1750, 'state_Gorontalo_1750', 'Gorontalo',
'Gorontalo', '', 'GO', 'state',
1),
(1751, 'state_Papua_1751', 'Papua', 'Papua',
'', 'IJ', 'state', 1),
(1752, 'state_Jambi_1752', 'Jambi', 'Jambi',
'', 'JA', 'state', 1),
(1753, 'state_Jawa_Timur_1753', 'Jawa Timur',
'Jawa Timur', '', 'JI', 'state',
1),
(1754, 'state_Jakarta_Raya_1754', 'Jakarta Raya',
'Jakarta Raya', '', 'JK', 'state',
1),
(1755, 'state_Jawa_Barat_1755', 'Jawa Barat',
'Jawa Barat', '', 'JR', 'state',
1),
(1756, 'state_Jawa_Tengah_1756', 'Jawa Tengah',
'Jawa Tengah', '', 'JT', 'state',
1),
(1757, 'state_Kalimantan_Barat_1757', 'Kalimantan
Barat', 'Kalimantan Barat', '', 'KB',
'state', 1),
(1758, 'state_Kalimantan_Timur_1758', 'Kalimantan
Timur', 'Kalimantan Timur', '', 'KI',
'state', 1),
(1759, 'state_Kalimantan_Selatan_1759', 'Kalimantan
Selatan', 'Kalimantan Selatan', '',
'KS', 'state', 1),
(1760, 'state_Kalimantan_Tengah_1760', 'Kalimantan
Tengah', 'Kalimantan Tengah', '', 'KT',
'state', 1),
(1761, 'state_Lampung_1761', 'Lampung',
'Lampung', '', 'LA', 'state', 1),
(1762, 'state_Maluku_1762', 'Maluku',
'Maluku', '', 'MA', 'state', 1),
(1763, 'state_Maluku_Utara_1763', 'Maluku Utara',
'Maluku Utara', '', 'MU', 'state',
1),
(1764, 'state_Nusa_Tenggara_Barat_1764', 'Nusa Tenggara
Barat', 'Nusa Tenggara Barat', '', 'NB',
'state', 1),
(1765, 'state_Nusa_Tenggara_Timur_1765', 'Nusa Tenggara
Timur', 'Nusa Tenggara Timur', '', 'NT',
'state', 1),
(1766, 'state_Riau_1766', 'Riau', 'Riau',
'', 'RI', 'state', 1),
(1767, 'state_Sumatera_Barat_1767', 'Sumatera Barat',
'Sumatera Barat', '', 'SB',
'state', 1),
(1768, 'state_Sulawesi_Tenggara_1768', 'Sulawesi
Tenggara', 'Sulawesi Tenggara', '',
'SG', 'state', 1),
(1769, 'state_Sumatera_Selatan_1769', 'Sumatera
Selatan', 'Sumatera Selatan', '', 'SL',
'state', 1),
(1770, 'state_Sulawesi_Selatan_1770', 'Sulawesi
Selatan', 'Sulawesi Selatan', '', 'SN',
'state', 1),
(1771, 'state_Sulawesi_Tengah_1771', 'Sulawesi Tengah',
'Sulawesi Tengah', '', 'ST',
'state', 1),
(1772, 'state_Sulawesi_Utara_1772', 'Sulawesi Utara',
'Sulawesi Utara', '', 'SW',
'state', 1),
(1773, 'state_Sumatera_Utara_1773', 'Sumatera Utara',
'Sumatera Utara', '', 'SU',
'state', 1),
(1774, 'state_Yogyakarta_1774', 'Yogyakarta',
'Yogyakarta', '', 'YO', 'state',
1),
(1775, 'state__________________________________________1775',
'Ù
ŰۧÙ۞۩ ۹۰۱ۚۧÛŰŹŰ§Ù ŰŽŰ±ÙÙ', 'Ù
ŰۧÙ۞۩
۹۰۱ۚۧÛŰŹŰ§Ù ŰŽŰ±ÙÙ', '', '01',
'state', 1),
(1776, 'state__________________________________________1776',
'Ù
ŰۧÙ۞۩ ۹۰۱ۚۧÛŰŹŰ§Ù Űș۱ۚÙ', 'Ù
ŰۧÙ۞۩
۹۰۱ۚۧÛŰŹŰ§Ù Űș۱ۚÙ', '', '02',
'state', 1),
(1777, 'state___________________________1777', 'Ù
ŰۧÙ۞۩
ۧ۱ۯۚÛÙ', 'Ù
ŰۧÙ۞۩ ۧ۱ۯۚÛÙ', '',
'03', 'state', 1),
(1778, 'state___________________________1778', 'Ù
ŰۧÙ۞۩
ۧ۔ÙÙۧÙ', 'Ù
ŰۧÙ۞۩ ۧ۔ÙÙۧÙ', '',
'04', 'state', 1),
(1779, 'state_________________________1779', 'Ù
ŰۧÙ۞۩
ۧÛÙۧÙ
', 'Ù
ŰۧÙ۞۩ ۧÛÙۧÙ
', '',
'05', 'state', 1),
(1780, 'state_________________________1780', 'Ù
ŰۧÙ۞۩
ŰšÙŰŽÙ۱', 'Ù
ŰۧÙ۞۩ ŰšÙŰŽÙ۱', '',
'06', 'state', 1),
(1781, 'state_________________________1781', 'Ù
ŰۧÙ۞۩
Ű·Ù۱ۧÙ', 'Ù
ŰۧÙ۞۩ Ű·Ù۱ۧÙ', '',
'07', 'state', 1),
(1782,
'state_______________________________________________1782',
'Ù
ŰۧÙ۞۩ ÚÙۧ۱Ù
ŰÙ Ù ŰšŰźŰȘÛۧ۱Ù',
'Ù
ŰۧÙ۞۩ ÚÙۧ۱Ù
ŰÙ Ù ŰšŰźŰȘÛۧ۱Ù', '',
'08', 'state', 1),
(1783, 'state____________________________________1783',
'Ù
ŰۧÙ۞۩ ŰźŰ±Ű§ŰłŰ§Ù Ű±Ű¶ÙÙ', 'Ù
ŰۧÙ۞۩
ŰźŰ±Ű§ŰłŰ§Ù Ű±Ű¶ÙÙ', '', '09',
'state', 1),
(1784, 'state_____________________________1784',
'Ù
ŰۧÙ۞۩ ŰźÙŰČŰłŰȘۧÙ', 'Ù
ŰۧÙ۞۩
ŰźÙŰČŰłŰȘۧÙ', '', '10', 'state', 1),
(1785, 'state_________________________1785', 'Ù
ŰۧÙ۞۩
ŰČÙۏۧÙ', 'Ù
ŰۧÙ۞۩ ŰČÙۏۧÙ', '',
'11', 'state', 1),
(1786, 'state_________________________1786', 'Ù
ŰۧÙ۞۩
ŰłÙ
ÙۧÙ', 'Ù
ŰۧÙ۞۩ ŰłÙ
ÙۧÙ', '',
'12', 'state', 1),
(1787,
'state________________________________________________1787',
'Ù
ŰۧÙ۞۩ ŰłÙŰłŰȘŰ§Ù ÙŰšÙÙŰȘŰŽŰłŰȘۧÙ',
'Ù
ŰۧÙ۞۩ ŰłÙŰłŰȘŰ§Ù ÙŰšÙÙŰȘŰŽŰłŰȘۧÙ', '',
'13', 'state', 1),
(1788, 'state_______________________1788', 'Ù
ŰۧÙ۞۩
Ùۧ۱۳', 'Ù
ŰۧÙ۞۩ Ùۧ۱۳', '',
'14', 'state', 1),
(1789, 'state_________________________1789', 'Ù
ŰۧÙ۞۩
ک۱Ù
ۧÙ', 'Ù
ŰۧÙ۞۩ ک۱Ù
ۧÙ', '',
'15', 'state', 1),
(1790, 'state_____________________________1790',
'Ù
ŰۧÙ۞۩ ک۱ۯ۳ŰȘۧÙ', 'Ù
ŰۧÙ۞۩
ک۱ۯ۳ŰȘۧÙ', '', '16', 'state', 1),
(1791, 'state_______________________________1791',
'Ù
ŰۧÙ۞۩ ک۱Ù
ۧÙێۧÙ', 'Ù
ŰۧÙ۞۩
ک۱Ù
ۧÙێۧÙ', '', '17', 'state',
1),
(1792,
'state____________________________________________________1792',
'Ù
ŰۧÙ۞۩ Ú©ÙÚ©ÛÙÙÛÙ Ù ŰšÙÛ۱ ŰŁŰÙ
ŰŻ',
'Ù
ŰۧÙ۞۩ Ú©ÙÚ©ÛÙÙÛÙ Ù ŰšÙÛ۱ ŰŁŰÙ
ŰŻ',
'', '18', 'state', 1),
(1793, 'state_________________________1793', 'Ù
ŰۧÙ۞۩
ÚŻÛÙۧÙ', 'Ù
ŰۧÙ۞۩ ÚŻÛÙۧÙ', '',
'19', 'state', 1),
(1794, 'state___________________________1794', 'Ù
ŰۧÙ۞۩
Ù۱۳ŰȘۧÙ', 'Ù
ŰۧÙ۞۩ Ù۱۳ŰȘۧÙ', '',
'20', 'state', 1),
(1795, 'state_______________________________1795',
'Ù
ŰۧÙ۞۩ Ù
ۧŰČÙۯ۱ۧÙ', 'Ù
ŰۧÙ۞۩
Ù
ۧŰČÙۯ۱ۧÙ', '', '21', 'state',
1),
(1796, 'state_________________________1796', 'Ù
ŰۧÙ۞۩
Ù
۱کŰČÙ', 'Ù
ŰۧÙ۞۩ Ù
۱کŰČÙ', '',
'22', 'state', 1),
(1797, 'state_____________________________1797',
'Ù
ŰۧÙ۞۩ Ù۱Ù
ŰČگۧÙ', 'Ù
ŰۧÙ۞۩
Ù۱Ù
ŰČگۧÙ', '', '23', 'state', 1),
(1798, 'state_________________________1798', 'Ù
ŰۧÙ۞۩
ÙÙ
ۯۧÙ', 'Ù
ŰۧÙ۞۩ ÙÙ
ۯۧÙ', '',
'24', 'state', 1),
(1799, 'state_____________________1799', 'Ù
ŰۧÙ۞۩
ÛŰČŰŻ', 'Ù
ŰۧÙ۞۩ ÛŰČŰŻ', '',
'25', 'state', 1),
(1800, 'state___________________1800', 'Ù
ŰۧÙ۞۩
ÙÙ
', 'Ù
ŰۧÙ۞۩ ÙÙ
', '', '26',
'state', 1),
(1801, 'state___________________________1801', 'Ù
ŰۧÙ۞۩
ÚŻÙŰłŰȘۧÙ', 'Ù
ŰۧÙ۞۩ ÚŻÙŰłŰȘۧÙ', '',
'27', 'state', 1),
(1802, 'state_________________________1802', 'Ù
ŰۧÙ۞۩
ÙŰČÙÙÙ', 'Ù
ŰۧÙ۞۩ ÙŰČÙÙÙ', '',
'28', 'state', 1),
(1803, 'state_____________________________1803',
'Ù
ŰۧÙ۞۩ ۧÙŰŁÙۚۧ۱', 'Ù
ŰۧÙ۞۩
ۧÙŰŁÙۚۧ۱', '', 'AN', 'state', 1),
(1804, 'state____________1804', 'ۣ۱ۚÙÙ',
'ۣ۱ۚÙÙ', '', 'AR', 'state',
1),
(1805, 'state___________________________1805', 'Ù
ŰۧÙ۞۩
ۧÙۚ۔۱۩', 'Ù
ŰۧÙ۞۩ ۧÙۚ۔۱۩', '',
'BA', 'state', 1),
(1806, 'state__________1806', 'ۚۧۚÙ',
'ۚۧۚÙ', '', 'BB', 'state', 1),
(1807, 'state_________________________1807', 'Ù
ŰۧÙ۞۩
ŰšŰșۯۧۯ', 'Ù
ŰۧÙ۞۩ ŰšŰșۯۧۯ', '',
'BG', 'state', 1),
(1808, 'state__________1808', 'ŰŻÙÙÙ',
'ŰŻÙÙÙ', '', 'DA', 'state', 1),
(1809, 'state____________1809', 'ŰŻÙۧÙÙ',
'ŰŻÙۧÙÙ', '', 'DI', 'state',
1),
(1810, 'state_____________1810', 'Ű°Ù Ùۧ۱',
'Ű°Ù Ùۧ۱', '', 'DQ', 'state',
1),
(1811, 'state______________1811', 'Ù۱ۚÙۧۥ',
'Ù۱ۚÙۧۥ', '', 'KA', 'state',
1),
(1812, 'state____________1812', 'Ù
Ù۳ۧÙ',
'Ù
Ù۳ۧÙ', '', 'MA', 'state',
1),
(1813, 'state______________1813', 'ۧÙÙ
Ű«ÙÙ',
'ۧÙÙ
Ű«ÙÙ', '', 'MU', 'state',
1),
(1814, 'state____________1814', 'ۧÙÙŰŹÙ',
'ۧÙÙŰŹÙ', '', 'NA', 'state',
1),
(1815, 'state____________1815', 'ÙÛÙÙÙ',
'ÙÛÙÙÙ', '', 'NI', 'state',
1),
(1816, 'state__________________1816',
'ۧÙÙۧۯ۳ÙŰ©', 'ۧÙÙۧۯ۳ÙŰ©', '',
'QA', 'state', 1),
(1817, 'state_____________________1817', 'Ű”ÙۧŰ
ۧÙŰŻÙÙ', 'Ű”ÙŰ§Ű Ű§ÙŰŻÙÙ', '',
'SD', 'state', 1),
(1818, 'state___________________________________1818',
'Ù
ŰۧÙ۞۩ ۧÙŰłÙÙÙ
ۧÙÙŰ©', 'Ù
ŰۧÙ۞۩
ۧÙŰłÙÙÙ
ۧÙÙŰ©', '', 'SW',
'state', 1),
(1819, 'state________________1819', 'ۧÙŰȘŰŁÙ
ÛÙ
',
'ۧÙŰȘŰŁÙ
ÛÙ
', '', 'TS',
'state', 1),
(1820, 'state__________1820', 'Ùۧ۳۷',
'Ùۧ۳۷', '', 'WA', 'state', 1),
(1821, 'state_Corcaigh_1821', 'Corcaigh', 'County
Cork', '', 'C', 'state', 1),
(1822, 'state_Contae_an_Chl__ir_1822', 'Contae an
ChlĂĄir', 'County Clare', '', 'CE',
'state', 1),
(1823, 'state_An_Cabh__n_1823', 'An CabhĂĄn',
'County Cavan', '', 'CN', 'state',
1),
(1824, 'state_Ceatharlach_1824', 'Ceatharlach',
'County Carlow', '', 'CW', 'state',
1),
(1825, 'state_Baile___tha_Cliath_1825', 'Baile Ătha
Cliath', 'County Dublin', '', 'D',
'state', 1),
(1826, 'state_D__n_na_nGall_1826', 'DĂșn na nGall',
'County Donegal', '', 'DL',
'state', 1),
(1827, 'state_Gaillimh_1827', 'Gaillimh', 'County
Galway', '', 'G', 'state', 1),
(1828, 'state_Cill_Dara_1828', 'Cill Dara',
'County Kildare', '', 'KE',
'state', 1),
(1829, 'state_Cill_Chainnigh_1829', 'Cill Chainnigh',
'County Kilkenny', '', 'KK',
'state', 1),
(1830, 'state_Contae_Chiarra___1830', 'Contae
ChiarraĂ', 'County Kerry', '', 'KY',
'state', 1),
(1831, 'state_An_Longfort_1831', 'An Longfort',
'County Longford', '', 'LD',
'state', 1),
(1832, 'state_Contae_L___1832', 'Contae LĂș',
'County Louth', '', 'LH', 'state',
1),
(1833, 'state_Luimneach_1833', 'Luimneach',
'County Limerick', '', 'LK',
'state', 1),
(1834, 'state_Contae_Liatroma_1834', 'Contae Liatroma',
'County Leitrim', '', 'LM',
'state', 1),
(1835, 'state_Contae_Laoise_1835', 'Contae Laoise',
'County Laois', '', 'LS', 'state',
1),
(1836, 'state_Contae_na_M___1836', 'Contae na MĂ',
'County Meath', '', 'MH', 'state',
1),
(1837, 'state_Muineach__n_1837', 'MuineachĂĄn',
'County Monaghan', '', 'MN',
'state', 1),
(1838, 'state_Contae_Mhaigh_Eo_1838', 'Contae Mhaigh
Eo', 'County Monaghan', '', 'MO',
'state', 1),
(1839, 'state_Contae_U__bh_Fhail___1839', 'Contae UĂbh
FhailĂ', 'County Offaly', '', 'OY',
'state', 1),
(1840, 'state_Ros_Com__in_1840', 'Ros ComĂĄin',
'County Roscommon', '', 'RN',
'state', 1),
(1841, 'state_Sligeach_1841', 'Sligeach', 'County
Sligo', '', 'SO', 'state', 1),
(1842, 'state_Tiobraid___rann_1842', 'Tiobraid Ărann',
'County Tipperary', '', 'TA',
'state', 1),
(1843, 'state_Port_Lairge_1843', 'Port Lairge',
'County Waterford', '', 'WD',
'state', 1),
(1844, 'state_Contae_na_hIarmh___1844', 'Contae na
hIarmhĂ', 'County Westmeath', '', 'WH',
'state', 1),
(1845, 'state_Cill_Mhant__in_1845', 'Cill MhantĂĄin',
'County Wicklow', '', 'WW',
'state', 1),
(1846, 'state_Loch_Garman_1846', 'Loch Garman',
'County Wexford', '', 'WX',
'state', 1),
(1847, 'state_____________________1847', 'ŚŚŚŚ
ŚŚŚšŚŚ', 'ŚŚŚŚ ŚŚŚšŚŚ', '', 'D
', 'state', 1),
(1848, 'state___________________1848', 'ŚŚŚŚ
ŚŚŚ€Ś', 'ŚŚŚŚ ŚŚŚ€Ś', '',
'HA', 'state', 1),
(1849, 'state________________1849', 'ŚŚšŚŚ©ŚŚŚ',
'ŚŚšŚŚ©ŚŚŚ', '', 'JM',
'state', 1),
(1850, 'state_____________________1850', 'ŚŚŚŚ
ŚŚŚšŚŚ', 'ŚŚŚŚ ŚŚŚšŚŚ', '', 'M
', 'state', 1),
(1851, 'state______________________1851', 'ŚȘŚ
ŚŚŚŚ-ŚŚ€Ś', 'ŚȘŚ ŚŚŚŚ-ŚŚ€Ś', '',
'TA', 'state', 1),
(1852, 'state_____________________1852', 'ŚŚŚŚ
ŚŚŠŚ€ŚŚ', 'ŚŚŚŚ ŚŚŠŚ€ŚŚ', '', 'Z
', 'state', 1),
(1853, 'state_Agrigento_1853', 'Agrigento',
'Agrigento', '', 'AG', 'state',
1),
(1854, 'state_Alessandria_1854', 'Alessandria',
'Alessandria', '', 'AL', 'state',
1),
(1855, 'state_Ancona_1855', 'Ancona',
'Ancona', '', 'AN', 'state', 1),
(1856, 'state_Valle_d_Aosta_1856', 'Valle
d''Aosta', 'Valle d''Aosta',
'', 'AO', 'state', 1),
(1857, 'state_Ascoli_Piceno_1857', 'Ascoli Piceno',
'Ascoli Piceno', '', 'AP', 'state',
1),
(1858, 'state_L_Aquila_1858', 'L''Aquila',
'L''Aquila', '', 'AQ',
'state', 1),
(1859, 'state_Arezzo_1859', 'Arezzo',
'Arezzo', '', 'AR', 'state', 1),
(1860, 'state_Asti_1860', 'Asti', 'Asti',
'', 'AT', 'state', 1),
(1861, 'state_Avellino_1861', 'Avellino',
'Avellino', '', 'AV', 'state', 1),
(1862, 'state_Bari_1862', 'Bari', 'Bari',
'', 'BA', 'state', 1),
(1863, 'state_Bergamo_1863', 'Bergamo',
'Bergamo', '', 'BG', 'state', 1),
(1864, 'state_Biella_1864', 'Biella',
'Biella', '', 'BI', 'state', 1),
(1865, 'state_Belluno_1865', 'Belluno',
'Belluno', '', 'BL', 'state', 1),
(1866, 'state_Benevento_1866', 'Benevento',
'Benevento', '', 'BN', 'state',
1),
(1867, 'state_Bologna_1867', 'Bologna',
'Bologna', '', 'BO', 'state', 1),
(1868, 'state_Brindisi_1868', 'Brindisi',
'Brindisi', '', 'BR', 'state', 1),
(1869, 'state_Brescia_1869', 'Brescia',
'Brescia', '', 'BS', 'state', 1),
(1870, 'state_Barletta_Andria_Trani_1870',
'Barletta-Andria-Trani', 'Barletta-Andria-Trani',
'', 'BT', 'state', 1),
(1871, 'state_Alto_Adige_1871', 'Alto Adige',
'Alto Adige', '', 'BZ', 'state',
1),
(1872, 'state_Cagliari_1872', 'Cagliari',
'Cagliari', '', 'CA', 'state', 1),
(1873, 'state_Campobasso_1873', 'Campobasso',
'Campobasso', '', 'CB', 'state',
1),
(1874, 'state_Caserta_1874', 'Caserta',
'Caserta', '', 'CE', 'state', 1),
(1875, 'state_Chieti_1875', 'Chieti',
'Chieti', '', 'CH', 'state', 1),
(1876, 'state_Carbonia_Iglesias_1876',
'Carbonia-Iglesias', 'Carbonia-Iglesias', '',
'CI', 'state', 1),
(1877, 'state_Caltanissetta_1877', 'Caltanissetta',
'Caltanissetta', '', 'CL', 'state',
1),
(1878, 'state_Cuneo_1878', 'Cuneo', 'Cuneo',
'', 'CN', 'state', 1),
(1879, 'state_Como_1879', 'Como', 'Como',
'', 'CO', 'state', 1),
(1880, 'state_Cremona_1880', 'Cremona',
'Cremona', '', 'CR', 'state', 1),
(1881, 'state_Cosenza_1881', 'Cosenza',
'Cosenza', '', 'CS', 'state', 1),
(1882, 'state_Catania_1882', 'Catania',
'Catania', '', 'CT', 'state', 1),
(1883, 'state_Catanzaro_1883', 'Catanzaro',
'Catanzaro', '', 'CZ', 'state',
1),
(1884, 'state_Enna_1884', 'Enna', 'Enna',
'', 'EN', 'state', 1),
(1885, 'state_Ferrara_1885', 'Ferrara',
'Ferrara', '', 'FE', 'state', 1),
(1886, 'state_Foggia_1886', 'Foggia',
'Foggia', '', 'FG', 'state', 1),
(1887, 'state_Firenze_1887', 'Firenze',
'Firenze', '', 'FI', 'state', 1),
(1888, 'state_Fermo_1888', 'Fermo', 'Fermo',
'', 'FM', 'state', 1),
(1889, 'state_Forl___Cesena_1889', 'ForlĂŹ-Cesena',
'ForlĂŹ-Cesena', '', 'FO', 'state',
1),
(1890, 'state_Frosinone_1890', 'Frosinone',
'Frosinone', '', 'FR', 'state',
1),
(1891, 'state_Genova_1891', 'Genova',
'Genova', '', 'GE', 'state', 1),
(1892, 'state_Gorizia_1892', 'Gorizia',
'Gorizia', '', 'GO', 'state', 1),
(1893, 'state_Grosseto_1893', 'Grosseto',
'Grosseto', '', 'GR', 'state', 1),
(1894, 'state_Imperia_1894', 'Imperia',
'Imperia', '', 'IM', 'state', 1),
(1895, 'state_Isernia_1895', 'Isernia',
'Isernia', '', 'IS', 'state', 1),
(1896, 'state_Crotone_1896', 'Crotone',
'Crotone', '', 'KR', 'state', 1),
(1897, 'state_Lecco_1897', 'Lecco', 'Lecco',
'', 'LC', 'state', 1),
(1898, 'state_Lecce_1898', 'Lecce', 'Lecce',
'', 'LE', 'state', 1),
(1899, 'state_Livorno_1899', 'Livorno',
'Livorno', '', 'LI', 'state', 1),
(1900, 'state_Lodi_1900', 'Lodi', 'Lodi',
'', 'LO', 'state', 1),
(1901, 'state_Latina_1901', 'Latina',
'Latina', '', 'LT', 'state', 1),
(1902, 'state_Lucca_1902', 'Lucca', 'Lucca',
'', 'LU', 'state', 1),
(1903, 'state_Macerata_1903', 'Macerata',
'Macerata', '', 'MC', 'state', 1),
(1904, 'state_Medio_Campidano_1904', 'Medio Campidano',
'Medio Campidano', '', 'MD',
'state', 1),
(1905, 'state_Messina_1905', 'Messina',
'Messina', '', 'ME', 'state', 1),
(1906, 'state_Milano_1906', 'Milano',
'Milano', '', 'MI', 'state', 1),
(1907, 'state_Mantova_1907', 'Mantova',
'Mantova', '', 'MN', 'state', 1),
(1908, 'state_Modena_1908', 'Modena',
'Modena', '', 'MO', 'state', 1),
(1909, 'state_Massa_Carrara_1909', 'Massa-Carrara',
'Massa-Carrara', '', 'MS', 'state',
1),
(1910, 'state_Matera_1910', 'Matera',
'Matera', '', 'MT', 'state', 1),
(1911, 'state_Monza_e_Brianza_1911', 'Monza e Brianza',
'Monza e Brianza', '', 'MZ',
'state', 1),
(1912, 'state_Napoli_1912', 'Napoli',
'Napoli', '', 'NA', 'state', 1),
(1913, 'state_Novara_1913', 'Novara',
'Novara', '', 'NO', 'state', 1),
(1914, 'state_Nuoro_1914', 'Nuoro', 'Nuoro',
'', 'NU', 'state', 1),
(1915, 'state_Ogliastra_1915', 'Ogliastra',
'Ogliastra', '', 'OG', 'state',
1),
(1916, 'state_Oristano_1916', 'Oristano',
'Oristano', '', 'OR', 'state', 1),
(1917, 'state_Olbia_Tempio_1917', 'Olbia-Tempio',
'Olbia-Tempio', '', 'OT', 'state',
1),
(1918, 'state_Palermo_1918', 'Palermo',
'Palermo', '', 'PA', 'state', 1),
(1919, 'state_Piacenza_1919', 'Piacenza',
'Piacenza', '', 'PC', 'state', 1),
(1920, 'state_Padova_1920', 'Padova',
'Padova', '', 'PD', 'state', 1),
(1921, 'state_Pescara_1921', 'Pescara',
'Pescara', '', 'PE', 'state', 1),
(1922, 'state_Perugia_1922', 'Perugia',
'Perugia', '', 'PG', 'state', 1),
(1923, 'state_Pisa_1923', 'Pisa', 'Pisa',
'', 'PI', 'state', 1),
(1924, 'state_Pordenone_1924', 'Pordenone',
'Pordenone', '', 'PN', 'state',
1),
(1925, 'state_Prato_1925', 'Prato', 'Prato',
'', 'PO', 'state', 1),
(1926, 'state_Parma_1926', 'Parma', 'Parma',
'', 'PR', 'state', 1),
(1927, 'state_Pesaro_e_Urbino_1927', 'Pesaro e Urbino',
'Pesaro e Urbino', '', 'PS',
'state', 1),
(1928, 'state_Pistoia_1928', 'Pistoia',
'Pistoia', '', 'PT', 'state', 1),
(1929, 'state_Pavia_1929', 'Pavia', 'Pavia',
'', 'PV', 'state', 1),
(1930, 'state_Potenza_1930', 'Potenza',
'Potenza', '', 'PZ', 'state', 1),
(1931, 'state_Ravenna_1931', 'Ravenna',
'Ravenna', '', 'RA', 'state', 1),
(1932, 'state_Reggio_Calabria_1932', 'Reggio Calabria',
'Reggio Calabria', '', 'RC',
'state', 1),
(1933, 'state_Reggio_Emilia_1933', 'Reggio Emilia',
'Reggio Emilia', '', 'RE', 'state',
1),
(1934, 'state_Ragusa_1934', 'Ragusa',
'Ragusa', '', 'RG', 'state', 1),
(1935, 'state_Rieti_1935', 'Rieti', 'Rieti',
'', 'RI', 'state', 1),
(1936, 'state_Roma_1936', 'Roma', 'Roma',
'', 'RM', 'state', 1),
(1937, 'state_Rimini_1937', 'Rimini',
'Rimini', '', 'RN', 'state', 1),
(1938, 'state_Rovigo_1938', 'Rovigo',
'Rovigo', '', 'RO', 'state', 1),
(1939, 'state_Salerno_1939', 'Salerno',
'Salerno', '', 'SA', 'state', 1),
(1940, 'state_Siena_1940', 'Siena', 'Siena',
'', 'SI', 'state', 1),
(1941, 'state_Sondrio_1941', 'Sondrio',
'Sondrio', '', 'SO', 'state', 1),
(1942, 'state_La_Spezia_1942', 'La Spezia', 'La
Spezia', '', 'SP', 'state', 1),
(1943, 'state_Siracusa_1943', 'Siracusa',
'Siracusa', '', 'SR', 'state', 1),
(1944, 'state_Sassari_1944', 'Sassari',
'Sassari', '', 'SS', 'state', 1),
(1945, 'state_Savona_1945', 'Savona',
'Savona', '', 'SV', 'state', 1),
(1946, 'state_Taranto_1946', 'Taranto',
'Taranto', '', 'TA', 'state', 1),
(1947, 'state_Teramo_1947', 'Teramo',
'Teramo', '', 'TE', 'state', 1),
(1948, 'state_Trento_1948', 'Trento',
'Trento', '', 'TN', 'state', 1),
(1949, 'state_Torino_1949', 'Torino',
'Torino', '', 'TO', 'state', 1),
(1950, 'state_Trapani_1950', 'Trapani',
'Trapani', '', 'TP', 'state', 1),
(1951, 'state_Terni_1951', 'Terni', 'Terni',
'', 'TR', 'state', 1),
(1952, 'state_Trieste_1952', 'Trieste',
'Trieste', '', 'TS', 'state', 1),
(1953, 'state_Treviso_1953', 'Treviso',
'Treviso', '', 'TV', 'state', 1),
(1954, 'state_Udine_1954', 'Udine', 'Udine',
'', 'UD', 'state', 1),
(1955, 'state_Varese_1955', 'Varese',
'Varese', '', 'VA', 'state', 1),
(1956, 'state_Verbano_Cusio_Ossola_1956',
'Verbano-Cusio-Ossola', 'Verbano-Cusio-Ossola',
'', 'VB', 'state', 1),
(1957, 'state_Vercelli_1957', 'Vercelli',
'Vercelli', '', 'VC', 'state', 1),
(1958, 'state_Venezia_1958', 'Venezia',
'Venezia', '', 'VE', 'state', 1),
(1959, 'state_Vicenza_1959', 'Vicenza',
'Vicenza', '', 'VI', 'state', 1),
(1960, 'state_Verona_1960', 'Verona',
'Verona', '', 'VR', 'state', 1),
(1961, 'state_Viterbo_1961', 'Viterbo',
'Viterbo', '', 'VT', 'state', 1),
(1962, 'state_Vibo_Valentia_1962', 'Vibo Valentia',
'Vibo Valentia', '', 'VV', 'state',
1),
(1963, 'state_Lucea_1971', 'Hanover',
'Hanover', '', '01', 'state', 1),
(1964, 'state_Black_River_1973', 'Saint Elizabeth',
'Saint Elizabeth', '', '02',
'state', 1),
(1965, 'state_Montego_Bay_1970', 'Saint James',
'Saint James', '', '03', 'state',
1),
(1966, 'state_Falmouth_1969', 'Trelawny',
'Trelawny', '', '04', 'state', 1),
(1967, 'state_Savanna_la_Mar_1972', 'Westmoreland',
'Westmoreland', '', '05', 'state',
1),
(1968, 'state_May_Pen_1975', 'Clarendon',
'Clarendon', '', '06', 'state',
1),
(1969, 'state_Mandeville_1974', 'Manchester',
'Manchester', '', '07', 'state',
1),
(1970, 'state_Saint_Ann_s_Bay_1968', 'Saint Ann',
'Saint Ann', '', '08', 'state',
1),
(1971, 'state_Spanish_Town_1976', 'Saint Catherine',
'Saint Catherine', '', '09',
'state', 1),
(1972, 'state_Port_Maria_1967', 'Saint Mary',
'Saint Mary', '', '10', 'state',
1),
(1973, 'state_Kingston_1963', 'Kingston',
'Kingston', '', '11', 'state', 1),
(1974, 'state_Port_Antonio_1966', 'Portland',
'Portland', '', '12', 'state', 1),
(1975, 'state_Half_Way_Tree_1964', 'Saint Andrew',
'Saint Andrew', '', '13', 'state',
1),
(1976, 'state_Morant_Bay_1965', 'Saint Thomas',
'Saint Thomas', '', '14', 'state',
1),
(1977, 'state___________1977', 'ćæ”·é',
'1', '', '01', 'state', 1),
(1978, 'state________1978', 'éæŁźç', '2',
'', '02', 'state', 1),
(1979, 'state________1979', 'ćČ©æç', '3',
'', '03', 'state', 1),
(1980, 'state________1980', 'ćźźćç', '4',
'', '04', 'state', 1),
(1981, 'state________1981', 'ç§ç°ç', '5',
'', '05', 'state', 1),
(1982, 'state________1982', 'ć±±ćœąç', '6',
'', '06', 'state', 1),
(1983, 'state________1983', 'çŠćł¶ç', '7',
'', '07', 'state', 1),
(1984, 'state________1984', 'èšćç', '8',
'', '08', 'state', 1),
(1985, 'state________1985', 'æ æšç', '9',
'', '09', 'state', 1),
(1986, 'state________1986', 'çŸ€éŠŹç',
'10', '', '10', 'state', 1),
(1987, 'state________1987', 'ćŒçç',
'11', '', '11', 'state', 1),
(1988, 'state________1988', 'ćèç',
'12', '', '12', 'state', 1),
(1989, 'state________1989', 'æ±äșŹéœ',
'13', '', '13', 'state', 1),
(1990, 'state___________1990', 'ç„ć„ć·ç',
'14', '', '14', 'state', 1),
(1991, 'state________1991', 'æ°æœç',
'15', '', '15', 'state', 1),
(1992, 'state________1992', 'ćŻć±±ç',
'16', '', '16', 'state', 1),
(1993, 'state________1993', 'çłć·ç',
'17', '', '17', 'state', 1),
(1994, 'state________1994', 'çŠäșç',
'18', '', '18', 'state', 1),
(1995, 'state________1995', 'ć±±æąšç',
'19', '', '19', 'state', 1),
(1996, 'state________1996', 'é·éç',
'20', '', '20', 'state', 1),
(1997, 'state________1997', 'ćČéç',
'21', '', '21', 'state', 1),
(1998, 'state________1998', 'éćČĄç',
'22', '', '22', 'state', 1),
(1999, 'state________1999', 'æç„ç',
'23', '', '23', 'state',
1);";
$this->db->setQuery($query);
$this->db->query();
$query="
INSERT IGNORE INTO `#__hikashop_zone` (`zone_id`, `zone_namekey`,
`zone_name`, `zone_name_english`, `zone_code_2`, `zone_code_3`,
`zone_type`, `zone_published`) VALUES
(2000, 'state________2000', 'äžéç',
'24', '', '24', 'state', 1),
(2001, 'state________2001', 'æ»èłç',
'25', '', '25', 'state', 1),
(2002, 'state________2002', 'äșŹéœćș',
'26', '', '26', 'state', 1),
(2003, 'state________2003', '性éȘćș',
'27', '', '27', 'state', 1),
(2004, 'state________2004', 'ć
”ćș«ç',
'28', '', '28', 'state', 1),
(2005, 'state________2005', 'ć„èŻç',
'29', '', '29', 'state', 1),
(2006, 'state___________2006', 'ćæć±±ç',
'30', '', '30', 'state', 1),
(2007, 'state________2007', 'éł„ćç',
'31', '', '31', 'state', 1),
(2008, 'state________2008', 'ćł¶æ čç',
'32', '', '32', 'state', 1),
(2009, 'state________2009', 'ćČĄć±±ç',
'33', '', '33', 'state', 1),
(2010, 'state________2010', 'ćșćł¶ç',
'34', '', '34', 'state', 1),
(2011, 'state________2011', 'ć±±ćŁç',
'35', '', '35', 'state', 1),
(2012, 'state________2012', 'ćŸłćł¶ç',
'36', '', '36', 'state', 1),
(2013, 'state________2013', 'éŠć·ç',
'37', '', '37', 'state', 1),
(2014, 'state________2014', 'æćȘç',
'38', '', '38', 'state', 1),
(2015, 'state________2015', 'é«ç„ç',
'39', '', '39', 'state', 1),
(2016, 'state________2016', 'çŠćČĄç',
'40', '', '40', 'state', 1),
(2017, 'state________2017', 'äœèłç',
'41', '', '41', 'state', 1),
(2018, 'state________2018', 'é·ćŽç',
'42', '', '42', 'state', 1),
(2019, 'state________2019', 'çæŹç',
'43', '', '43', 'state', 1),
(2020, 'state________2020', '性ćç',
'44', '', '44', 'state', 1),
(2021, 'state________2021', 'ćźźćŽç',
'45', '', '45', 'state', 1),
(2022, 'state___________2022', 'éčżć
ćł¶',
'46', '', '46', 'state', 1),
(2023, 'state________2023', 'æČçžç',
'47', '', '47', 'state', 1),
(2024, 'state_________________________2024', 'Ù
ŰۧÙ۞۩
ŰčŰŹÙÙÙ', 'Ù
ŰۧÙ۞۩ ŰčŰŹÙÙÙ', '',
'AJ', 'state', 1),
(2025, 'state_____________________________2025',
'Ù
ŰۧÙ۞۩ ۧÙŰčۧ۔Ù
Ű©', 'Ù
ŰۧÙ۞۩
ۧÙŰčۧ۔Ù
Ű©', '', 'AM', 'state', 1),
(2026, 'state___________________________2026', 'Ù
ŰۧÙ۞۩
ۧÙŰčÙۚ۩', 'Ù
ŰۧÙ۞۩ ۧÙŰčÙۚ۩', '',
'AQ', 'state', 1),
(2027, 'state_____________________________2027',
'Ù
ŰۧÙ۞۩ ۧÙŰ·ÙÙÙŰ©', 'Ù
ŰۧÙ۞۩
ۧÙŰ·ÙÙÙŰ©', '', 'AT', 'state', 1),
(2028, 'state_____________________________2028',
'Ù
ŰۧÙ۞۩ ۧÙŰČ۱Ùۧۥ', 'Ù
ŰۧÙ۞۩
ۧÙŰČ۱Ùۧۥ', '', 'AZ', 'state', 1),
(2029, 'state_____________________________2029',
'Ù
ŰۧÙ۞۩ ۧÙŰšÙÙۧۥ', 'Ù
ŰۧÙ۞۩
ۧÙŰšÙÙۧۥ', '', 'BA', 'state', 1),
(2030, 'state_____________________2030', 'Ù
ŰۧÙ۞۩
ۏ۱ێ', 'Ù
ŰۧÙ۞۩ ۏ۱ێ', '',
'JA', 'state', 1),
(2031, 'state_______________________2031', 'Ù
ŰۧÙ۞۩
ۄ۱ۚۯ', 'Ù
ŰۧÙ۞۩ ۄ۱ۚۯ', '',
'JR', 'state', 1),
(2032, 'state_________________________2032', 'Ù
ŰۧÙ۞۩
ۧÙÙ۱Ù', 'Ù
ŰۧÙ۞۩ ۧÙÙ۱Ù', '',
'KA', 'state', 1),
(2033, 'state___________________________2033', 'Ù
ŰۧÙ۞۩
ۧÙÙ
Ù۱Ù', 'Ù
ŰۧÙ۞۩ ۧÙÙ
Ù۱Ù', '',
'MA', 'state', 1),
(2034, 'state_________________________2034', 'Ù
ŰۧÙ۞۩
Ù
ۧۯۚۧ', 'Ù
ŰۧÙ۞۩ Ù
ۧۯۚۧ', '',
'MD', 'state', 1),
(2035, 'state_______________________2035', 'Ù
ŰۧÙ۞۩
Ù
ŰčۧÙ', 'Ù
ŰۧÙ۞۩ Ù
ŰčۧÙ', '',
'MN', 'state', 1),
(2036, 'state______________2036', 'ĐĐ»ĐŒĐ°ŃŃ',
'ĐĐ»ĐŒĐ°ŃŃ', '', 'AL', 'state',
1),
(2037, 'state_Almaty_City_2037', 'Almaty City',
'Almaty City', '', 'AC', 'state',
1),
(2038, 'state______________2038', 'ĐÒĐŒĐŸĐ»Đ°',
'ĐÒĐŒĐŸĐ»Đ°', '', 'AM', 'state',
1),
(2039, 'state______________2039', 'ĐÒŃөбД',
'ĐÒŃөбД', '', 'AQ', 'state',
1),
(2040, 'state______________2040', 'ĐŃŃĐ°ĐœĐ°',
'ĐŃŃĐ°ĐœĐ°', '', 'AS', 'state',
1),
(2041, 'state______________2041', 'ĐŃŃŃаŃ',
'ĐŃŃŃаŃ', '', 'AT', 'state',
1),
(2042, 'state_______________________________2042',
'ĐаŃŃŃ ÒазаÒŃŃĐ°Đœ', 'ĐаŃŃŃ
ÒазаÒŃŃĐ°Đœ', '', 'BA', 'state',
1),
(2043, 'state__________________2043',
'ĐаĐčÒĐŸÒŁŃŃ', 'ĐаĐčÒĐŸÒŁŃŃ', '',
'BY', 'state', 1),
(2044, 'state____________________2044',
'ĐĐ°ÒŁÒŃŃŃаŃ', 'ĐĐ°ÒŁÒŃŃŃаŃ',
'', 'MA', 'state', 1),
(2045, 'state_____________________________________2045',
'ĐÒŁŃÒŻŃŃŃĐș ÒазаÒŃŃĐ°Đœ', 'ĐÒŁŃÒŻŃŃŃĐș
ÒазаÒŃŃĐ°Đœ', '', 'ON', 'state',
1),
(2046, 'state__________________2046',
'ĐаĐČĐ»ĐŸĐŽĐ°Ń', 'ĐаĐČĐ»ĐŸĐŽĐ°Ń', '',
'PA', 'state', 1),
(2047, 'state____________________2047',
'ÒаŃаÒĐ°ĐœĐŽŃ', 'ÒаŃаÒĐ°ĐœĐŽŃ',
'', 'QA', 'state', 1),
(2048, 'state__________________2048',
'ÒĐŸŃŃĐ°ĐœĐ°Đč', 'ÒĐŸŃŃĐ°ĐœĐ°Đč', '',
'QO', 'state', 1),
(2049, 'state____________________2049',
'ÒŃĐ·ŃĐ»ĐŸŃЎа', 'ÒŃĐ·ŃĐ»ĐŸŃЎа',
'', 'QY', 'state', 1),
(2050, 'state_______________________________2050',
'ĐšŃÒŃŃ ÒазаÒŃŃĐ°Đœ', 'ĐšŃÒŃŃ
ÒазаÒŃŃĐ°Đœ', '', 'SH', 'state',
1),
(2051, 'state_______________________________________2051',
'ĐĄĐŸĐ»ŃÒŻŃŃŃĐș ÒазаÒŃŃĐ°Đœ', 'ĐĄĐŸĐ»ŃÒŻŃŃŃĐș
ÒазаÒŃŃĐ°Đœ', '', 'SO', 'state',
1),
(2052, 'state______________2052', 'ĐĐ°ĐŒĐ±ŃĐ»',
'ĐĐ°ĐŒĐ±ŃĐ»', '', 'ZH', 'state',
1),
(2053, 'state_Nairobi_2053', 'Nairobi',
'Nairobi', '', '110', 'state', 1),
(2054, 'state_Central_2054', 'Central',
'Central', '', '200', 'state', 1),
(2055, 'state_Mombasa_2055', 'Mombasa',
'Mombasa', '', '300', 'state', 1),
(2056, 'state_Eastern_2056', 'Eastern',
'Eastern', '', '400', 'state', 1),
(2057, 'state_North_Eastern_2057', 'North Eastern',
'North Eastern', '', '500',
'state', 1),
(2058, 'state_Nyanza_2058', 'Nyanza',
'Nyanza', '', '600', 'state', 1),
(2059, 'state_Rift_Valley_2059', 'Rift Valley',
'Rift Valley', '', '700', 'state',
1),
(2060, 'state_Western_2060', 'Western',
'Western', '', '900', 'state', 1),
(2061, 'state_Gilbert_Islands_2061', 'Gilbert Islands',
'Gilbert Islands', '', 'G',
'state', 1),
(2062, 'state_Line_Islands_2062', 'Line Islands',
'Line Islands', '', 'L', 'state',
1),
(2063, 'state_Phoenix_Islands_2063', 'Phoenix Islands',
'Phoenix Islands', '', 'P',
'state', 1),
(2064, 'state___________2064', 'ìê°ë',
'ìê°ë', '', 'CHA', 'state',
1),
(2065, 'state_______________2065', 'íšêČœ ë¶ë',
'íšêČœ ë¶ë', '', 'HAB',
'state', 1),
(2066, 'state_______________2066', 'íšêČœ ëšë',
'íšêČœ ëšë', '', 'HAN',
'state', 1),
(2067, 'state_______________2067', 'í©íŽ ë¶ë',
'í©íŽ ë¶ë', '', 'HWB',
'state', 1),
(2068, 'state_______________2068', 'í©íŽ ëšë',
'í©íŽ ëšë', '', 'HWN',
'state', 1),
(2069, 'state___________2069', 'ê°ìë',
'ê°ìë', '', 'KAN', 'state',
1),
(2070, 'state___________2070', 'ê°ì±ì',
'ê°ì±ì', '', 'KAE', 'state',
1),
(2071, 'state__________________2071', 'ëŒì
ì§í ì', 'ëŒì ì§í ì', '',
'NAJ', 'state', 1),
(2072, 'state__________________2072', 'ëšíŹ
íčêžì', 'ëšíŹ íčêžì', '',
'NAM', 'state', 1),
(2073, 'state_______________2073', 'íì ë¶ë',
'íì ë¶ë', '', 'PYB',
'state', 1),
(2074, 'state_______________2074', 'íì ëšë',
'íì ëšë', '', 'PYN',
'state', 1),
(2075, 'state__________________2075', 'íì
ì§í ì', 'íì ì§í ì', '',
'PYO', 'state', 1),
(2076, 'state___________2076', 'ëê°ë',
'ëê°ë', '', 'YAN', 'state',
1),
(2077, 'state_________________2077', 'ììžíčëłì',
'ììžíčëłì', '', '11',
'state', 1),
(2078, 'state__________________2078', 'ë¶ì°
êŽìì', 'ë¶ì° êŽìì', '',
'26', 'state', 1),
(2079, 'state__________________2079', 'ëê”Ź
êŽìì', 'ëê”Ź êŽìì', '',
'27', 'state', 1),
(2080, 'state_________________2080', 'ìžìČêŽìì',
'ìžìČêŽìì', '', '28',
'state', 1),
(2081, 'state__________________2081', 'êŽìŁŒ
êŽìì', 'êŽìŁŒ êŽìì', '',
'29', 'state', 1),
(2082, 'state__________________2082', 'ëì
êŽìì', 'ëì êŽìì', '',
'30', 'state', 1),
(2083, 'state__________________2083', 'ìžì°
êŽìì', 'ìžì° êŽìì', '',
'31', 'state', 1),
(2084, 'state___________2084', 'êČœêž°ë',
'êČœêž°ë', '', '41', 'state',
1),
(2085, 'state___________2085', 'ê°ìë',
'ê°ìë', '', '42', 'state',
1),
(2086, 'state_______________2086', 'ì¶©ìČ ë¶ë',
'ì¶©ìČ ë¶ë', '', '43', 'state',
1),
(2087, 'state_______________2087', 'ì¶©ìČ ëšë',
'ì¶©ìČ ëšë', '', '44', 'state',
1),
(2088, 'state_______________2088', 'ì ëŒ ë¶ë',
'ì ëŒ ë¶ë', '', '45', 'state',
1),
(2089, 'state_______________2089', 'ì ëŒ ëšë',
'ì ëŒ ëšë', '', '46', 'state',
1),
(2090, 'state_______________2090', 'êČœì ë¶ë',
'êČœì ë¶ë', '', '47', 'state',
1),
(2091, 'state_______________2091', 'êČœì ëšë',
'êČœì ëšë', '', '48', 'state',
1),
(2092, 'state_______________________2092',
'ì ìŁŒíčëłììčë', 'ì ìŁŒíčëłììčë',
'', '49', 'state', 1),
(2093, 'state________________2093', 'ۧÙۧŰÙ
ŰŻÙ',
'ۧÙۧŰÙ
ŰŻÙ', '', 'AH',
'state', 1),
(2094, 'state____________________2094',
'ۧÙÙ۱ÙۧÙÙŰ©', 'ۧÙÙ۱ÙۧÙÙŰ©',
'', 'FA', 'state', 1),
(2095, 'state________________2095', 'ۧÙŰŹÙ۱ۧۥ',
'ۧÙŰŹÙ۱ۧۥ', '', 'JA',
'state', 1),
(2096, 'state________________2096', 'ŰŁÙŰčۧ۔Ù
Ù',
'ŰŁÙŰčۧ۔Ù
Ù', '', 'KU',
'state', 1),
(2097, 'state__________2097', 'ŰÙÙÙ',
'ŰÙÙÙ', '', 'HW', 'state', 1),
(2098, 'state_________________________2098', 'Ù
ۚۧ۱Ù
ۧÙÙŰšÙ۱', 'Ù
ŰšŰ§Ű±Ù Ű§ÙÙŰšÙ۱', '',
'MU', 'state', 1),
(2099, 'state_____________________________2099',
'ĐаŃĐșĐ”Đœ ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐаŃĐșĐ”Đœ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'B', 'state', 1),
(2100, 'state_______________________2100', 'Đ§ÒŻĐč
ĐŸĐ±Đ»Đ°ŃŃŃ', 'Đ§ÒŻĐč ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'C', 'state', 1),
(2101, 'state______________2101', 'ĐĐžŃĐșĐ”Đș',
'ĐĐžŃĐșĐ”Đș', '', 'GB', 'state',
1),
(2102, 'state____________________________________2102',
'Đалал-ĐбаЎ ĐŸĐ±Đ»Đ°ŃŃŃ', 'Đалал-ĐбаЎ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'J', 'state', 1),
(2103, 'state___________________________2103', 'ĐаŃŃĐœ
ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐаŃŃĐœ ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'N', 'state', 1),
(2104, 'state_____________________2104', 'ĐŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐŃ ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'O', 'state', 1),
(2105, 'state___________________________2105', 'йалаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐąĐ°Đ»Đ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'T', 'state', 1),
(2106, 'state________________________________2106',
'Đ«ŃŃĐș-ĐÓ©Đ» ĐŸĐ±Đ»Đ°ŃŃŃ', 'Đ«ŃŃĐș-ĐÓ©Đ»
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'Y', 'state', 1),
(2107, 'state_______________________2107',
'àșàș±àșàșàș°àșàș·', 'àșàș±àșàșàș°àșàș·',
'', 'AT', 'state', 1),
(2108, 'state_______________________2108',
'àșà»à»à»àșà»àș§', 'àșà»à»à»àșà»àș§',
'', 'BK', 'state', 1),
(2109, 'state_____________________________2109',
'àșà»àș„àșŽàșà»àșČà»àș',
'àșà»àș„àșŽàșà»àșČà»àș', '', 'BL',
'state', 1),
(2110, 'state__________________________2110',
'àșà»àșČàșàșČàșȘàș±àș', 'àșà»àșČàșàșČàșȘàș±àș',
'', 'CH', 'state', 1),
(2111, 'state____________________2111',
'àș«àș»àș§àșàș±àș', 'àș«àș»àș§àșàș±àș',
'', 'HO', 'state', 1),
(2112, 'state_______________________2112',
'àșà»àșČàșĄà»àș§àș', 'àșà»àșČàșĄà»àș§àș',
'', 'KH', 'state', 1),
(2113, 'state________________________________2113',
'àș«àș„àș§àșàșà»à»àșČàșàșČ',
'àș«àș„àș§àșàșà»à»àșČàșàșČ', '', 'LM',
'state', 1),
(2114, 'state_____________________________2114',
'àș«àș„àș§àșàșàș°àșàșČàș',
'àș«àș„àș§àșàșàș°àșàșČàș', '', 'LP',
'state', 1),
(2115, 'state_______________________2115',
'àșàșžàșàș»àșĄà»àș', 'àșàșžàșàș»àșĄà»àș',
'', 'OU', 'state', 1),
(2116, 'state_______________________2116',
'àșàș»àșàșȘàșČàș„àș”', 'àșàș»àșàșȘàșČàș„àș”',
'', 'PH', 'state', 1),
(2117, 'state_______________________2117',
'àșȘàșČàș„àș°àș§àș±àș', 'àșȘàșČàș„àș°àș§àș±àș',
'', 'SL', 'state', 1),
(2118, 'state___________________________________2118',
'àșȘàș°àș«àș§àș±àșàșàș°à»àșàș',
'àșȘàș°àș«àș§àș±àșàșàș°à»àșàș', '',
'SV', 'state', 1),
(2119, 'state____________________2119',
'àș§àșœàșàșàș±àș', 'àș§àșœàșàșàș±àș',
'', 'VI', 'state', 1),
(2120, 'state____________________2120',
'àș§àșœàșàșàș±àș', 'àș§àșœàșàșàș±àș',
'', 'VT', 'state', 1),
(2121, 'state__________________________2121',
'à»àșàșàș°àșàșčàș„àș”', 'à»àșàșàș°àșàșčàș„àș”',
'', 'XA', 'state', 1),
(2122, 'state_________________2122', 'à»àșàșàșàș',
'à»àșàșàșàș', '', 'XE',
'state', 1),
(2123, 'state_______________________2123',
'àșàșœàșàșàș§àșČàș', 'àșàșœàșàșàș§àșČàș',
'', 'XI', 'state', 1),
(2124, 'state__________________________2124',
'à»àșàșȘàș»àșĄàșàșčàș', 'à»àșàșȘàș»àșĄàșàșčàș',
'', 'XN', 'state', 1),
(2125, 'state_Aizkraukles_rajons_2125', 'Aizkraukles
rajons', 'Aizkraukles rajons', '', 'AI',
'state', 1),
(2126, 'state_Al__ksnes_rajons_2126', 'Alƫksnes
rajons', 'Alƫksnes rajons', '', 'AL',
'state', 1),
(2127, 'state_Balvu_rajons_2127', 'Balvu rajons',
'Balvu rajons', '', 'BL', 'state',
1),
(2128, 'state_Bauskas_rajons_2128', 'Bauskas rajons',
'Bauskas rajons', '', 'BU',
'state', 1),
(2129, 'state_C__su_rajons_2129', 'CÄsu rajons',
'CÄsu rajons', '', 'CE', 'state',
1),
(2130, 'state_Daugavpils_rajons_2130', 'Daugavpils
rajons', 'Daugavpils rajons', '', 'DA',
'state', 1),
(2131, 'state_Daugpilis_2131', 'Daugpilis',
'Daugpilis', '', 'DGV', 'state',
1),
(2132, 'state_Dobeles_rajons_2132', 'Dobeles rajons',
'Dobeles rajons', '', 'DO',
'state', 1),
(2133, 'state_Gulbenes_rajons_2133', 'Gulbenes rajons',
'Gulbenes rajons', '', 'GU',
'state', 1),
(2134, 'state_Jelgava_2134', 'Jelgava',
'Jelgava', '', 'JEL', 'state', 1),
(2135, 'state_J__kabpils_rajons_2135', 'JÄkabpils
rajons', 'JÄkabpils rajons', '', 'JK',
'state', 1),
(2136, 'state_Jelgavas_rajons_2136', 'Jelgavas rajons',
'Jelgavas rajons', '', 'JL',
'state', 1),
(2137, 'state_J__rmala_2137', 'Jƫrmala',
'Jƫrmala', '', 'JUR', 'state',
1),
(2138, 'state_Kr__slavas_rajons_2138', 'KrÄslavas
rajons', 'KrÄslavas rajons', '', 'KR',
'state', 1),
(2139, 'state_Kuld__gas_rajons_2139', 'Kuldīgas
rajons', 'Kuldīgas rajons', '', 'KU',
'state', 1),
(2140, 'state_Liep__jas_rajons_2140', 'LiepÄjas
rajons', 'LiepÄjas rajons', '', 'LE',
'state', 1),
(2141, 'state_Limba__u_rajons_2141', 'LimbaĆŸu rajons',
'LimbaĆŸu rajons', '', 'LM',
'state', 1),
(2142, 'state_Liepoja_2142', 'Liepoja',
'Liepoja', '', 'LPX', 'state', 1),
(2143, 'state_Ludzas_rajons_2143', 'Ludzas rajons',
'Ludzas rajons', '', 'LU', 'state',
1),
(2144, 'state_Madonas_rajons_2144', 'Madonas rajons',
'Madonas rajons', '', 'MA',
'state', 1),
(2145, 'state_Ogres_rajons_2145', 'Ogres rajons',
'Ogres rajons', '', 'OG', 'state',
1),
(2146, 'state_Prei__u_rajons_2146', 'PreiÄŒu rajons',
'PreiÄŒu rajons', '', 'PR',
'state', 1),
(2147, 'state_R__zeknes_rajons_2147', 'RÄzeknes
rajons', 'RÄzeknes rajons', '', 'RE',
'state', 1),
(2148, 'state_R__zekne_2148', 'RÄzekne',
'RÄzekne', '', 'REZ', 'state',
1),
(2149, 'state_R__gas_rajons_2149', 'Rīgas rajons',
'Rīgas rajons', '', 'RI', 'state',
1),
(2150, 'state_R__ga_2150', 'Rīga', 'Rīga',
'', 'RIX', 'state', 1),
(2151, 'state_Saldus_rajons_2151', 'Saldus rajons',
'Saldus rajons', '', 'SA', 'state',
1),
(2152, 'state_Talsu_rajons_2152', 'Talsu rajons',
'Talsu rajons', '', 'TA', 'state',
1),
(2153, 'state_Tukuma_rajons_2153', 'Tukuma rajons',
'Tukuma rajons', '', 'TU', 'state',
1),
(2154, 'state_Ventspils_rajons_2154', 'Ventspils
rajons', 'Ventspils rajons', '', 'VE',
'state', 1),
(2155, 'state_Ventspils_2155', 'Ventspils',
'Ventspils', '', 'VEN', 'state',
1),
(2156, 'state_Valkas_rajons_2156', 'Valkas rajons',
'Valkas rajons', '', 'VK', 'state',
1),
(2157, 'state_Valmieras_rajons_2157', 'Valmieras
rajons', 'Valmieras rajons', '', 'VM',
'state', 1),
(2158, 'state_Maseru_2158', 'Maseru',
'Maseru', '', 'A', 'state', 1),
(2159, 'state_Butha_Buthe_2159', 'Butha-Buthe',
'Butha-Buthe', '', 'B', 'state',
1),
(2160, 'state_Leribe_2160', 'Leribe',
'Leribe', '', 'C', 'state', 1),
(2161, 'state_Berea_2161', 'Berea', 'Berea',
'', 'D', 'state', 1),
(2162, 'state_Mafeteng_2162', 'Mafeteng',
'Mafeteng', '', 'E', 'state', 1),
(2163, 'state_Mohale_s_Hoek_2163', 'Mohale''s
Hoek', 'Mohale''s Hoek', '',
'F', 'state', 1),
(2164, 'state_Quthing_2164', 'Quthing',
'Quthing', '', 'G', 'state', 1),
(2165, 'state_Qacha_s_Nek_2165', 'Qacha''s
Nek', 'Qacha''s Nek', '', 'H',
'state', 1),
(2166, 'state_Mokhotlong_2166', 'Mokhotlong',
'Mokhotlong', '', 'J', 'state',
1),
(2167, 'state_Thaba_Tseka_2167', 'Thaba-Tseka',
'Thaba-Tseka', '', 'K', 'state',
1),
(2168, 'state_Bong_2168', 'Bong', 'Bong',
'', 'BG', 'state', 1),
(2169, 'state_Bomi_2169', 'Bomi', 'Bomi',
'', 'BM', 'state', 1),
(2170, 'state_Grand_Cape_Mount_2170', 'Grand Cape
Mount', 'Grand Cape Mount', '', 'CM',
'state', 1),
(2171, 'state_Grand_Bassa_2171', 'Grand Bassa',
'Grand Bassa', '', 'GB', 'state',
1),
(2172, 'state_Grand_Gedeh_2172', 'Grand Gedeh',
'Grand Gedeh', '', 'GG', 'state',
1),
(2173, 'state_Grand_Kru_2173', 'Grand Kru', 'Grand
Kru', '', 'GK', 'state', 1),
(2174, 'state_Gbarpolu_2174', 'Gbarpolu',
'Gbarpolu', '', 'GP', 'state', 1),
(2175, 'state_Lofa_2175', 'Lofa', 'Lofa',
'', 'LO', 'state', 1),
(2176, 'state_Margibi_2176', 'Margibi',
'Margibi', '', 'MG', 'state', 1),
(2177, 'state_Montserrado_2177', 'Montserrado',
'Montserrado', '', 'MO', 'state',
1),
(2178, 'state_Maryland_2178', 'Maryland',
'Maryland', '', 'MY', 'state', 1),
(2179, 'state_Nimba_2179', 'Nimba', 'Nimba',
'', 'NI', 'state', 1),
(2180, 'state_River_Gee_2180', 'River Gee', 'River
Gee', '', 'RG', 'state', 1),
(2181, 'state_Rivercess_2181', 'Rivercess',
'Rivercess', '', 'RI', 'state',
1),
(2182, 'state_Sinoe_2182', 'Sinoe', 'Sinoe',
'', 'SI', 'state', 1),
(2183, 'state_Ajd__biy___2183', 'AjdÄbiyÄ',
'AjdÄbiyÄ', '', 'AJ', 'state',
1),
(2184, 'state_Bangh__z___2184', 'BanghÄzÄ«',
'BanghÄzÄ«', '', 'BA', 'state',
1),
(2185, 'state_Al_Bu__n__n_2185', 'Al BuĆŁnÄn',
'Al BuĆŁnÄn', '', 'BU', 'state',
1),
(2186, 'state_Ban___Wal__d_2186', 'Banī Walīd',
'Banī Walīd', '', 'BW', 'state',
1),
(2187, 'state_Darnah_2187', 'Darnah',
'Darnah', '', 'DR', 'state', 1),
(2188, 'state_Ghad__mis_2188', 'GhadÄmis',
'GhadÄmis', '', 'GD', 'state',
1),
(2189, 'state_Ghary__n_2189', 'GharyÄn',
'GharyÄn', '', 'GR', 'state', 1),
(2190, 'state_Gh__t_2190', 'GhÄt', 'GhÄt',
'', 'GT', 'state', 1),
(2191, 'state_Al____iz__m_al_Akh___ar_2191', 'Al ážšizÄm al
Akhážar', 'Al ážšizÄm al Akhážar', '',
'HZ', 'state', 1),
(2192, 'state_Al_Jabal_al_Akh___ar_2192', 'Al Jabal al
Akhážar', 'Al Jabal al Akhážar', '',
'JA', 'state', 1),
(2193, 'state_Jaghb__b_2193', 'Jaghbƫb',
'Jaghbƫb', '', 'JB', 'state', 1),
(2194, 'state_Al_Jif__rah_2194', 'Al JifÄrah',
'Al JifÄrah', '', 'JI', 'state',
1),
(2195, 'state_Al_Jufrah_2195', 'Al Jufrah', 'Al
Jufrah', '', 'JU', 'state', 1),
(2196, 'state_Al_Kufrah_2196', 'Al Kufrah', 'Al
Kufrah', '', 'KF', 'state', 1),
(2197, 'state_Al_Marqab_2197', 'Al Marqab', 'Al
Marqab', '', 'MB', 'state', 1),
(2198, 'state_Mi__r__tah_2198', 'MiĆrÄtah',
'MiĆrÄtah', '', 'MI', 'state',
1),
(2199, 'state_Al_Marj_2199', 'Al Marj', 'Al
Marj', '', 'MJ', 'state', 1),
(2200, 'state_Murzuq_2200', 'Murzuq',
'Murzuq', '', 'MQ', 'state', 1),
(2201, 'state_Mizdah_2201', 'Mizdah',
'Mizdah', '', 'MZ', 'state', 1),
(2202, 'state_N__l__t_2202', 'NÄlĆ«t',
'NÄlĆ«t', '', 'NL', 'state', 1),
(2203, 'state_An_Nuqa___al_Khams_2203', 'An NuqaĆŁ al
Khams', 'An NuqaĆŁ al Khams', '', 'NQ',
'state', 1),
(2204, 'state_Al_Qubbah_2204', 'Al Qubbah', 'Al
Qubbah', '', 'QB', 'state', 1),
(2205, 'state_Al_Qa__r__n_2205', 'Al Qaƣrƫn',
'Al Qaƣrƫn', '', 'QT', 'state',
1),
(2206, 'state_Sabh___2206', 'SabhÄ',
'SabhÄ', '', 'SB', 'state', 1),
(2207, 'state_Ash_Sh____i_2207', 'Ash ShÄĆŁi',
'Ash ShÄĆŁi', '', 'SH', 'state',
1),
(2208, 'state_Surt_2208', 'Surt', 'Surt',
'', 'SR', 'state', 1),
(2209, 'state___abr__tah___urm__n_2209', 'ĆabrÄtah
ĆurmÄn', 'ĆabrÄtah ĆurmÄn', '',
'SS', 'state', 1),
(2210, 'state___ar__bulus_2210', 'ĆąarÄbulus',
'ĆąarÄbulus', '', 'TB', 'state',
1),
(2211, 'state_Tarh__nah_Masall__tah_2211',
'TarhĆ«nah-MasallÄtah', 'TarhĆ«nah-MasallÄtah',
'', 'TM', 'state', 1),
(2212, 'state_T__j__r___wa_an_Naw________al_Arb_____2212',
'TÄjĆ«rÄ wa an NawÄឩī al ArbÄÊ»', 'TÄjĆ«rÄ wa an
NawÄឩī al ArbÄÊ»', '', 'TN',
'state', 1),
(2213, 'state_Al_W_____ah_2213', 'Al WÄáž©ah',
'Al WÄáž©ah', '', 'WA', 'state',
1),
(2214, 'state_W__d___al____ay__t_2214', 'WÄdÄ« al
ážšayÄt', 'WÄdÄ« al ážšayÄt', '',
'WD', 'state', 1),
(2215, 'state_Yafran_J__d___2215', 'Yafran-JÄdĆ«',
'Yafran-JÄdĆ«', '', 'YJ', 'state',
1),
(2216, 'state_Az_Z__wiyah_2216', 'Az ZÄwiyah',
'Az ZÄwiyah', '', 'ZA', 'state',
1),
(2217, 'state_Balzers_2217', 'Balzers',
'Balzers', '', 'B', 'state', 1),
(2218, 'state_Eschen_2218', 'Eschen',
'Eschen', '', 'E', 'state', 1),
(2219, 'state_Gamprin_2219', 'Gamprin',
'Gamprin', '', 'G', 'state', 1),
(2220, 'state_Mauren_2220', 'Mauren',
'Mauren', '', 'M', 'state', 1),
(2221, 'state_Planken_2221', 'Planken',
'Planken', '', 'P', 'state', 1),
(2222, 'state_Ruggell_2222', 'Ruggell',
'Ruggell', '', 'R', 'state', 1),
(2223, 'state_Schaan_2223', 'Schaan',
'Schaan', '', 'A', 'state', 1),
(2224, 'state_Schellenberg_2224', 'Schellenberg',
'Schellenberg', '', 'L', 'state',
1),
(2225, 'state_Triesen_2225', 'Triesen',
'Triesen', '', 'N', 'state', 1),
(2226, 'state_Triesenberg_2226', 'Triesenberg',
'Triesenberg', '', 'T', 'state',
1),
(2227, 'state_Vaduz_2227', 'Vaduz', 'Vaduz',
'', 'V', 'state', 1),
(2228, 'state_Alytaus_Apskritis_2228', 'Alytaus
Apskritis', 'Alytaus Apskritis', '',
'AL', 'state', 1),
(2229, 'state_Klaip__dos_Apskritis_2229', 'KlaipÄdos
Apskritis', 'KlaipÄdos Apskritis', '',
'KL', 'state', 1),
(2230, 'state_Kauno_Apskritis_2230', 'Kauno Apskritis',
'Kauno Apskritis', '', 'KU',
'state', 1),
(2231, 'state_Marijampol__s_Apskritis_2231', 'MarijampolÄs
Apskritis', 'MarijampolÄs Apskritis', '',
'MR', 'state', 1),
(2232, 'state_Panev____io_Apskritis_2232', 'PanevÄĆŸio
Apskritis', 'PanevÄĆŸio Apskritis', '',
'PN', 'state', 1),
(2233, 'state___iauli___Apskritis_2233', 'Ć iauliĆł
Apskritis', 'Ć iauliĆł Apskritis', '',
'SA', 'state', 1),
(2234, 'state_Taurag__s_Apskritis_2234', 'TauragÄs
Apskritis', 'TauragÄs Apskritis', '',
'TA', 'state', 1),
(2235, 'state_Tel__i___Apskritis_2235', 'TelĆĄiĆł
Apskritis', 'TelĆĄiĆł Apskritis', '',
'TE', 'state', 1),
(2236, 'state_Utenos_Apskritis_2236', 'Utenos
Apskritis', 'Utenos Apskritis', '',
'UT', 'state', 1),
(2237, 'state_Vilniaus_Apskritis_2237', 'Vilniaus
Apskritis', 'Vilniaus Apskritis', '',
'VL', 'state', 1),
(2238, 'state_Diekirch_2238', 'Diekirch',
'Diekirch', '', 'D', 'state', 1),
(2239, 'state_Grevenmacher_2239', 'Grevenmacher',
'Grevenmacher', '', 'G', 'state',
1),
(2240, 'state_Luxemburg_2240', 'Luxemburg',
'Luxemburg', '', 'L', 'state', 1),
(2241, 'state___________2241', 'æ”·ćł¶ćž',
'æ”·ćł¶ćž', '', 'I', 'state', 1),
(2242, 'state___________2242', 'æŸłéćž',
'æŸłéćž', '', 'M', 'state', 1),
(2243, 'state_Berovo_2243', 'Berovo',
'Berovo', '', 'BR', 'state', 1),
(2244, 'state___________________________________2244',
'ЧДŃĐžĐœĐŸĐČĐŸ-ĐблДŃĐ”ĐČĐŸ',
'ЧДŃĐžĐœĐŸĐČĐŸ-ĐблДŃĐ”ĐČĐŸ', '',
'CH', 'state', 1),
(2245, 'state________________2245', 'ĐДлŃĐ”ĐČĐŸ',
'ĐДлŃĐ”ĐČĐŸ', '', 'DL',
'state', 1),
(2246, 'state__________________2246',
'ĐаŃĐ±ĐžĐœŃĐž', 'ĐаŃĐ±ĐžĐœŃĐž', '',
'KB', 'state', 1),
(2247, 'state______________2247', 'ĐĐŸŃĐ°ĐœĐž',
'ĐĐŸŃĐ°ĐœĐž', '', 'OC', 'state',
1),
(2248, 'state______________2248', 'ĐĐŸĐ·ĐŸĐČĐŸ',
'ĐĐŸĐ·ĐŸĐČĐŸ', '', 'LO', 'state',
1),
(2249, 'state_______________________________________2249',
'ĐаĐșĐ”ĐŽĐŸĐœŃĐșа ĐșĐ°ĐŒĐ”ĐœĐžŃа',
'ĐаĐșĐ”ĐŽĐŸĐœŃĐșа ĐșĐ°ĐŒĐ”ĐœĐžŃа', '',
'MK', 'state', 1),
(2250, 'state________________2250', 'ĐĐ”Ń
ŃĐ”ĐČĐŸ',
'ĐĐ”Ń
ŃĐ”ĐČĐŸ', '', 'PH',
'state', 1),
(2251, 'state____________________2251',
'ĐŃĐŸĐ±ĐžŃŃОп', 'ĐŃĐŸĐ±ĐžŃŃОп',
'', 'PT', 'state', 1),
(2252, 'state__________2252', 'ĐšŃОп',
'ĐšŃОп', '', 'ST', 'state', 1),
(2253, 'state_________________________2253', 'ĐĄĐČĐ”ŃĐž
ĐĐžĐșĐŸĐ»Đ”', 'ĐĄĐČĐ”ŃĐž ĐĐžĐșĐŸĐ»Đ”', '',
'SL', 'state', 1),
(2254, 'state______________2254', 'ĐĐžĐœĐžŃа',
'ĐĐžĐœĐžŃа', '', 'NI', 'state',
1),
(2255, 'state________________2255', 'ĐŃĐœĐŸĐČŃĐž',
'ĐŃĐœĐŸĐČŃĐž', '', 'ZR',
'state', 1),
(2256, 'state________________2256', 'ĐŃаŃĐŸĐČĐŸ',
'ĐŃаŃĐŸĐČĐŸ', '', 'KY',
'state', 1),
(2257, 'state___________________________2257', 'ĐŃĐžĐČа
ĐĐ°Đ»Đ°ĐœĐșа', 'ĐŃĐžĐČа ĐĐ°Đ»Đ°ĐœĐșа', '',
'KZ', 'state', 1),
(2258, 'state__________________2258',
'ĐŃĐŒĐ°ĐœĐŸĐČĐŸ', 'ĐŃĐŒĐ°ĐœĐŸĐČĐŸ', '',
'UM', 'state', 1),
(2259, 'state________________2259', 'ĐОпĐșĐŸĐČĐŸ',
'ĐОпĐșĐŸĐČĐŸ', '', 'LI',
'state', 1),
(2260, 'state__________________2260',
'Đ Đ°ĐœĐșĐŸĐČŃĐ”', 'Đ Đ°ĐœĐșĐŸĐČŃĐ”', '',
'RN', 'state', 1),
(2261, 'state_________________________________2261',
'ĐĄŃаŃĐŸ ĐĐ°ĐłĐŸŃĐžŃĐ°ĐœĐ”', 'ĐĄŃаŃĐŸ
ĐĐ°ĐłĐŸŃĐžŃĐ°ĐœĐ”', '', 'NA',
'state', 1),
(2262, 'state______________2262', 'ĐĐžŃĐŸĐ»Đ°',
'ĐĐžŃĐŸĐ»Đ°', '', 'TL', 'state',
1),
(2263, 'state_______________________2263', 'ĐĐ”ĐŒĐžŃ
ЄОŃаŃ', 'ĐĐ”ĐŒĐžŃ Đ„ĐžŃаŃ', '',
'DM', 'state', 1),
(2264, 'state________________2264', 'ĐĐŸĐ»ĐœĐ”ĐœĐž',
'ĐĐŸĐ»ĐœĐ”ĐœĐž', '', 'DE',
'state', 1),
(2265, 'state__________________________2265',
'ĐŃĐžĐČĐŸĐłĐ°ŃŃĐ°ĐœĐž', 'ĐŃĐžĐČĐŸĐłĐ°ŃŃĐ°ĐœĐž',
'', 'KG', 'state', 1),
(2266, 'state________________2266', 'ĐŃŃŃĐ”ĐČĐŸ',
'ĐŃŃŃĐ”ĐČĐŸ', '', 'KS',
'state', 1),
(2267, 'state______________2267', 'ĐĐŸĐłĐžĐ»Đ°',
'ĐĐŸĐłĐžĐ»Đ°', '', 'MG', 'state',
1),
(2268, 'state______________2268', 'ĐĐŸĐČаŃĐž',
'ĐĐŸĐČаŃĐž', '', 'NV', 'state',
1),
(2269, 'state______________2269', 'ĐŃОлДп',
'ĐŃОлДп', '', 'PP', 'state',
1),
(2270, 'state____________2270', 'Đ Đ”ŃĐ”Đœ',
'Đ Đ”ŃĐ”Đœ', '', 'RE', 'state',
1),
(2271, 'state__________________2271',
'ĐĐŸĐłĐŸĐČĐžŃĐ”', 'ĐĐŸĐłĐŸĐČĐžŃĐ”', '',
'VJ', 'state', 1),
(2272, 'state__________________2272',
'ĐŃĐČĐ”ĐœĐžŃа', 'ĐŃĐČĐ”ĐœĐžŃа', '',
'BN', 'state', 1),
(2273, 'state__________________2273',
'ĐĐŸŃŃĐžĐČаŃ', 'ĐĐŸŃŃĐžĐČаŃ', '',
'GT', 'state', 1),
(2274, 'state____________________2274',
'ĐДгŃĐœĐŸĐČŃĐ”', 'ĐДгŃĐœĐŸĐČŃĐ”',
'', 'JG', 'state', 1),
(2275, 'state__________________________________2275',
'ĐаĐČŃĐŸĐČĐŸ Đž Đ ĐŸŃŃŃŃа', 'ĐаĐČŃĐŸĐČĐŸ Đž
Đ ĐŸŃŃŃŃа', '', 'MR', 'state', 1),
(2276, 'state______________2276', 'йДаŃŃĐ”',
'йДаŃŃĐ”', '', 'TR', 'state',
1),
(2277, 'state______________2277', 'йДŃĐŸĐČĐŸ',
'йДŃĐŸĐČĐŸ', '', 'ET', 'state',
1),
(2278, 'state____________________2278',
'ĐŃапŃĐžŃŃĐ”', 'ĐŃапŃĐžŃŃĐ”',
'', 'VH', 'state', 1),
(2279, 'state______________2279', 'ĐĐ”Đ»ĐžĐœĐŸ',
'ĐĐ”Đ»ĐžĐœĐŸ', '', 'ZE', 'state',
1),
(2280, 'state__________________2280',
'ĐĐ”ŃĐŸĐŽŃĐŸĐŒ', 'ĐĐ”ŃĐŸĐŽŃĐŸĐŒ', '',
'AD', 'state', 1),
(2281, 'state____________________2281',
'ĐŃаŃĐžĐœĐŸĐČĐŸ', 'ĐŃаŃĐžĐœĐŸĐČĐŸ',
'', 'AR', 'state', 1),
(2282, 'state____________2282', 'ĐŃŃДл',
'ĐŃŃДл', '', 'BU', 'state',
1),
(2283, 'state__________2283', 'ЧаОŃ',
'ЧаОŃ', '', 'CI', 'state', 1),
(2284, 'state______________2284', 'ĐŠĐ”ĐœŃаŃ',
'ĐŠĐ”ĐœŃаŃ', '', 'CE', 'state',
1),
(2285, 'state___________________________2285', 'ЧŃŃĐ”Ń
ĐĄĐ°ĐœĐŽĐ”ĐČĐŸ', 'ЧŃŃĐ”Ń ĐĄĐ°ĐœĐŽĐ”ĐČĐŸ', '',
'CS', 'state', 1),
(2286, 'state___________________2286', 'ĐазО
Đаба', 'ĐазО Đаба', '',
'GB', 'state', 1),
(2287, 'state_________________________2287', 'ĐĐŸŃŃĐ”
ĐĐ”ŃŃĐŸĐČ', 'ĐĐŸŃŃĐ” ĐĐ”ŃŃĐŸĐČ', '',
'GP', 'state', 1),
(2288, 'state________________2288', 'ĐĐ»ĐžĐœĐŽĐ”Đœ',
'ĐĐ»ĐžĐœĐŽĐ”Đœ', '', 'IL',
'state', 1),
(2289, 'state______________2289', 'ĐаŃĐżĐŸŃ',
'ĐаŃĐżĐŸŃ', '', 'KX', 'state',
1),
(2290, 'state_______________________2290', 'ĐĐžŃДла
ĐĐŸĐŽĐ°', 'ĐĐžŃДла ĐĐŸĐŽĐ°', '',
'VD', 'state', 1),
(2291, 'state__________________2291',
'ĐĐ”ŃŃĐŸĐČĐ”Ń', 'ĐĐ”ŃŃĐŸĐČĐ”Ń', '',
'PE', 'state', 1),
(2292, 'state____________2292', 'ХаŃаŃ',
'ХаŃаŃ', '', 'AJ', 'state',
1),
(2293, 'state________________2293', 'ĐĄĐŸĐżĐžŃŃĐ”',
'ĐĄĐŸĐżĐžŃŃĐ”', '', 'SS',
'state', 1),
(2294, 'state________________________2294',
'ĐĄŃŃĐŽĐ”ĐœĐžŃĐ°ĐœĐž', 'ĐĄŃŃĐŽĐ”ĐœĐžŃĐ°ĐœĐž',
'', 'SU', 'state', 1),
(2295, 'state_________________________2295', 'ĐšŃŃĐŸ
ĐŃОзаŃĐž', 'ĐšŃŃĐŸ ĐŃОзаŃĐž', '',
'SO', 'state', 1),
(2296, 'state______________________2296',
'ĐĐ”Đ»Đ”ĐœĐžĐșĐŸĐČĐŸ', 'ĐĐ”Đ»Đ”ĐœĐžĐșĐŸĐČĐŸ',
'', 'ZK', 'state', 1),
(2297, 'state__________________2297',
'ĐĐŸĐłĐŽĐ°ĐœŃĐž', 'ĐĐŸĐłĐŽĐ°ĐœŃĐž', '',
'BG', 'state', 1),
(2298, 'state__________________2298',
'ĐĐŸŃĐžĐ»ĐŸĐČĐŸ', 'ĐĐŸŃĐžĐ»ĐŸĐČĐŸ', '',
'BS', 'state', 1),
(2299, 'state____________________2299',
'ĐĐ”ĐČгДлОŃа', 'ĐĐ”ĐČгДлОŃа',
'', 'GV', 'state', 1),
(2300, 'state____________2300', 'ĐĐŸĐœŃĐ”',
'ĐĐŸĐœŃĐ”', '', 'KN', 'state',
1),
(2301, 'state___________________2301', 'ĐĐŸĐČĐŸ
ĐĄĐ”Đ»ĐŸ', 'ĐĐŸĐČĐŸ ĐĄĐ”Đ»ĐŸ', '',
'NS', 'state', 1),
(2302, 'state________________2302', 'Đ Đ°ĐŽĐŸĐČĐžŃ',
'Đ Đ°ĐŽĐŸĐČĐžŃ', '', 'RV',
'state', 1),
(2303, 'state_______________________2303', 'ĐĄŃаŃ
ĐĐŸŃŃĐ°Đœ', 'ĐĄŃĐ°Ń ĐĐŸŃŃĐ°Đœ', '',
'SD', 'state', 1),
(2304, 'state__________________2304',
'ĐĄŃŃŃĐŒĐžŃа', 'ĐĄŃŃŃĐŒĐžŃа', '',
'RU', 'state', 1),
(2305, 'state____________________2305',
'ĐĐ°Đ»Đ°ĐœĐŽĐŸĐČĐŸ', 'ĐĐ°Đ»Đ°ĐœĐŽĐŸĐČĐŸ',
'', 'VA', 'state', 1),
(2306, 'state__________________2306',
'ĐаŃОлДĐČĐŸ', 'ĐаŃОлДĐČĐŸ', '',
'VL', 'state', 1),
(2307, 'state_______________________2307', 'ĐŠĐ”ĐœŃаŃ
ĐŃпа', 'ĐŠĐ”ĐœŃĐ°Ń ĐŃпа', '',
'CZ', 'state', 1),
(2308, 'state____________2308', 'ĐДбаŃ',
'ĐДбаŃ', '', 'DB', 'state',
1),
(2309, 'state________________2309', 'ĐДбаŃŃа',
'ĐДбаŃŃа', '', 'DA',
'state', 1),
(2310, 'state________________2310', 'ĐŃŃĐłĐŸĐČĐŸ',
'ĐŃŃĐłĐŸĐČĐŸ', '', 'DR',
'state', 1),
(2311, 'state______________2311', 'ĐĐžŃĐ”ĐČĐŸ',
'ĐĐžŃĐ”ĐČĐŸ', '', 'KH', 'state',
1),
(2312, 'state_______________________________2312',
'ĐаĐșĐ”ĐŽĐŸĐœŃĐșĐž ĐŃĐŸĐŽ', 'ĐаĐșĐ”ĐŽĐŸĐœŃĐșĐž
ĐŃĐŸĐŽ', '', 'MD', 'state', 1),
(2313, 'state____________2313', 'ĐŃ
ŃОЎ',
'ĐŃ
ŃОЎ', '', 'OD', 'state',
1),
(2314, 'state________________2314', 'ĐŃĐ»ĐŸĐŒĐ”Ń',
'ĐŃĐ»ĐŸĐŒĐ”Ń', '', 'OS',
'state', 1),
(2315, 'state__________________2315',
'ĐлаŃĐœĐžŃа', 'ĐлаŃĐœĐžŃа', '',
'PN', 'state', 1),
(2316, 'state______________2316', 'ĐĄŃŃŃга',
'ĐĄŃŃŃга', '', 'UG', 'state',
1),
(2317, 'state________________2317', 'ĐĐ”ĐČŃĐ°ĐœĐž',
'ĐĐ”ĐČŃĐ°ĐœĐž', '', 'VV',
'state', 1),
(2318, 'state______________________2318',
'ĐŃĐ°ĐœĐ”ŃŃĐžŃа', 'ĐŃĐ°ĐœĐ”ŃŃĐžŃа',
'', 'VC', 'state', 1),
(2319, 'state____________2319', 'ĐаŃаŃ',
'ĐаŃаŃ', '', 'ZA', 'state',
1),
(2320, 'state____________2320', 'ЧаŃĐșа',
'ЧаŃĐșа', '', 'CA', 'state',
1),
(2321, 'state_________________________2321', 'ĐĐ”ĐŒĐžŃ
ĐапОŃа', 'ĐĐ”ĐŒĐžŃ ĐапОŃа', '',
'DK', 'state', 1),
(2322, 'state________________2322', 'ĐŃаЎŃĐșĐŸ',
'ĐŃаЎŃĐșĐŸ', '', 'GR',
'state', 1),
(2323, 'state____________________2323',
'ĐаĐČаЎаŃŃĐž', 'ĐаĐČаЎаŃŃĐž',
'', 'AV', 'state', 1),
(2324, 'state__________________2324',
'ĐĐ”ĐłĐŸŃĐžĐœĐŸ', 'ĐĐ”ĐłĐŸŃĐžĐœĐŸ', '',
'NG', 'state', 1),
(2325, 'state________________2325', 'Đ ĐŸŃĐŸĐŒĐ°Đœ',
'Đ ĐŸŃĐŸĐŒĐ°Đœ', '', 'RM',
'state', 1),
(2326, 'state____________2326', 'ĐДлДŃ',
'ĐДлДŃ', '', 'VE', 'state',
1),
(2327, 'state_Toamasina_2327', 'Toamasina',
'Toamasina', '', 'A', 'state', 1),
(2328, 'state_Antsiranana_2328', 'Antsiranana',
'Antsiranana', '', 'D', 'state',
1),
(2329, 'state_Fianarantsoa_2329', 'Fianarantsoa',
'Fianarantsoa', '', 'F', 'state',
1),
(2330, 'state_Mahajanga_2330', 'Mahajanga',
'Mahajanga', '', 'M', 'state', 1),
(2331, 'state_Antananarivo_2331', 'Antananarivo',
'Antananarivo', '', 'T', 'state',
1),
(2332, 'state_Toliara_2332', 'Toliara',
'Toliara', '', 'U', 'state', 1),
(2333, 'state_Balaka_2333', 'Balaka',
'Balaka', '', 'BA', 'state', 1),
(2334, 'state_Blantyre_2334', 'Blantyre',
'Blantyre', '', 'BL', 'state', 1),
(2336, 'state_Chikwawa_2336', 'Chikwawa',
'Chikwawa', '', 'CK', 'state', 1),
(2337, 'state_Chiradzulu_2337', 'Chiradzulu',
'Chiradzulu', '', 'CR', 'state',
1),
(2338, 'state_Chitipa_2338', 'Chitipa',
'Chitipa', '', 'CT', 'state', 1),
(2339, 'state_Dedza_2339', 'Dedza', 'Dedza',
'', 'DE', 'state', 1),
(2340, 'state_Dowa_2340', 'Dowa', 'Dowa',
'', 'DO', 'state', 1),
(2341, 'state_Karonga_2341', 'Karonga',
'Karonga', '', 'KR', 'state', 1),
(2342, 'state_Kasungu_2342', 'Kasungu',
'Kasungu', '', 'KS', 'state', 1),
(2343, 'state_Likoma_Island_2343', 'Likoma Island',
'Likoma Island', '', 'LK', 'state',
1),
(2344, 'state_Lilongwe_2344', 'Lilongwe',
'Lilongwe', '', 'LI', 'state', 1),
(2345, 'state_Machinga_2345', 'Machinga',
'Machinga', '', 'MH', 'state', 1),
(2346, 'state_Mangochi_2346', 'Mangochi',
'Mangochi', '', 'MG', 'state', 1),
(2347, 'state_Mchinji_2347', 'Mchinji',
'Mchinji', '', 'MC', 'state', 1),
(2348, 'state_Mulanje_2348', 'Mulanje',
'Mulanje', '', 'MU', 'state', 1),
(2349, 'state_Mwanza_2349', 'Mwanza',
'Mwanza', '', 'MW', 'state', 1),
(2350, 'state_Mzimba_2350', 'Mzimba',
'Mzimba', '', 'MZ', 'state', 1),
(2351, 'state_Northern_2351', 'Northern',
'Northern', '', 'N', 'state', 1),
(2352, 'state_Nkhata_2352', 'Nkhata',
'Nkhata', '', 'NB', 'state', 1),
(2353, 'state_Nkhotakota_2353', 'Nkhotakota',
'Nkhotakota', '', 'NK', 'state',
1),
(2354, 'state_Nsanje_2354', 'Nsanje',
'Nsanje', '', 'NS', 'state', 1),
(2355, 'state_Ntcheu_2355', 'Ntcheu',
'Ntcheu', '', 'NU', 'state', 1),
(2356, 'state_Ntchisi_2356', 'Ntchisi',
'Ntchisi', '', 'NI', 'state', 1),
(2357, 'state_Phalombe_2357', 'Phalombe',
'Phalombe', '', 'PH', 'state', 1),
(2358, 'state_Rumphi_2358', 'Rumphi',
'Rumphi', '', 'RU', 'state', 1),
(2359, 'state_Southern_2359', 'Southern',
'Southern', '', 'S', 'state', 1),
(2360, 'state_Salima_2360', 'Salima',
'Salima', '', 'SA', 'state', 1),
(2361, 'state_Thyolo_2361', 'Thyolo',
'Thyolo', '', 'TH', 'state', 1),
(2362, 'state_Zomba_2362', 'Zomba', 'Zomba',
'', 'ZO', 'state', 1),
(2363, 'state_Johor_Darul_Takzim_2363', 'Johor Darul
Takzim', 'Johor Darul Takzim', '', '01',
'state', 1),
(2364, 'state_Kedah_Darul_Aman_2364', 'Kedah Darul
Aman', 'Kedah Darul Aman', '', '02',
'state', 1),
(2365, 'state_Kelantan_Darul_Naim_2365', 'Kelantan Darul
Naim', 'Kelantan Darul Naim', '', '03',
'state', 1),
(2366, 'state_Melaka_Negeri_Bersejarah_2366', 'Melaka Negeri
Bersejarah', 'Melaka Negeri Bersejarah', '',
'04', 'state', 1),
(2367, 'state_Negeri_Sembilan_Darul_Khusus_2367', 'Negeri
Sembilan Darul Khusus', 'Negeri Sembilan Darul Khusus',
'', '05', 'state', 1),
(2368, 'state_Pahang_Darul_Makmur_2368', 'Pahang Darul
Makmur', 'Pahang Darul Makmur', '',
'06', 'state', 1),
(2369, 'state_Pulau_Pinang_2369', 'Pulau Pinang',
'Pulau Pinang', '', '07', 'state',
1),
(2370, 'state_Perak_Darul_Ridzuan_2370', 'Perak Darul
Ridzuan', 'Perak Darul Ridzuan', '',
'08', 'state', 1),
(2371, 'state_Perlis_Indera_Kayangan_2371', 'Perlis Indera
Kayangan', 'Perlis Indera Kayangan', '',
'09', 'state', 1),
(2372, 'state_Selangor_Darul_Ehsan_2372', 'Selangor Darul
Ehsan', 'Selangor Darul Ehsan', '',
'10', 'state', 1),
(2373, 'state_Terengganu_Darul_Iman_2373', 'Terengganu Darul
Iman', 'Terengganu Darul Iman', '',
'11', 'state', 1),
(2374, 'state_Sabah_Negeri_Di_Bawah_Bayu_2374', 'Sabah
Negeri Di Bawah Bayu', 'Sabah Negeri Di Bawah Bayu',
'', '12', 'state', 1),
(2375, 'state_Sarawak_Bumi_Kenyalang_2375', 'Sarawak Bumi
Kenyalang', 'Sarawak Bumi Kenyalang', '',
'13', 'state', 1),
(2376, 'state_Wilayah_Persekutuan_Kuala_Lumpur_2376',
'Wilayah Persekutuan Kuala Lumpur', 'Wilayah Persekutuan
Kuala Lumpur', '', '14', 'state', 1),
(2377, 'state_Wilayah_Persekutuan_Labuan_2377', 'Wilayah
Persekutuan Labuan', 'Wilayah Persekutuan Labuan',
'', '15', 'state', 1),
(2378, 'state_Wilayah_Persekutuan_Putrajaya_2378', 'Wilayah
Persekutuan Putrajaya', 'Wilayah Persekutuan Putrajaya',
'', '16', 'state', 1),
(2379, 'state_Thiladhunmathi_Uthuru_2379', 'Thiladhunmathi
Uthuru', 'Thiladhunmathi Uthuru', '',
'THU', 'state', 1),
(2380, 'state_Thiladhunmathi_Dhekunu_2380', 'Thiladhunmathi
Dhekunu', 'Thiladhunmathi Dhekunu', '',
'THD', 'state', 1),
(2381, 'state_Miladhunmadulu_Uthuru_2381', 'Miladhunmadulu
Uthuru', 'Miladhunmadulu Uthuru', '',
'MLU', 'state', 1),
(2382, 'state_Miladhunmadulu_Dhekunu_2382', 'Miladhunmadulu
Dhekunu', 'Miladhunmadulu Dhekunu', '',
'MLD', 'state', 1),
(2383, 'state_Maalhosmadulu_Uthuru_2383', 'Maalhosmadulu
Uthuru', 'Maalhosmadulu Uthuru', '',
'MAU', 'state', 1),
(2384, 'state_Maalhosmadulu_Dhekunu_2384', 'Maalhosmadulu
Dhekunu', 'Maalhosmadulu Dhekunu', '',
'MAD', 'state', 1),
(2385, 'state_Faadhippolhu_2385', 'Faadhippolhu',
'Faadhippolhu', '', 'FAA', 'state',
1),
(2386, 'state_Male_Atoll_2386', 'Male Atoll',
'Male Atoll', '', 'MAA', 'state',
1),
(2387, 'state_Ari_Atoll_Uthuru_2387', 'Ari Atoll
Uthuru', 'Ari Atoll Uthuru', '', 'AAU',
'state', 1),
(2388, 'state_Ari_Atoll_Dheknu_2388', 'Ari Atoll
Dheknu', 'Ari Atoll Dheknu', '', 'AAD',
'state', 1),
(2389, 'state_Felidhe_Atoll_2389', 'Felidhe Atoll',
'Felidhe Atoll', '', 'FEA',
'state', 1),
(2390, 'state_Mulaku_Atoll_2390', 'Mulaku Atoll',
'Mulaku Atoll', '', 'MUA', 'state',
1),
(2391, 'state_Nilandhe_Atoll_Uthuru_2391', 'Nilandhe Atoll
Uthuru', 'Nilandhe Atoll Uthuru', '',
'NAU', 'state', 1),
(2392, 'state_Nilandhe_Atoll_Dhekunu_2392', 'Nilandhe Atoll
Dhekunu', 'Nilandhe Atoll Dhekunu', '',
'NAD', 'state', 1),
(2393, 'state_Kolhumadulu_2393', 'Kolhumadulu',
'Kolhumadulu', '', 'KLH', 'state',
1),
(2394, 'state_Hadhdhunmathi_2394', 'Hadhdhunmathi',
'Hadhdhunmathi', '', 'HDH',
'state', 1),
(2395, 'state_Huvadhu_Atoll_Uthuru_2395', 'Huvadhu Atoll
Uthuru', 'Huvadhu Atoll Uthuru', '',
'HAU', 'state', 1),
(2396, 'state_Huvadhu_Atoll_Dhekunu_2396', 'Huvadhu Atoll
Dhekunu', 'Huvadhu Atoll Dhekunu', '',
'HAD', 'state', 1),
(2397, 'state_Fua_Mulaku_2397', 'Fua Mulaku', 'Fua
Mulaku', '', 'FMU', 'state', 1),
(2398, 'state_Addu_2398', 'Addu', 'Addu',
'', 'ADD', 'state', 1),
(2399, 'state_Kayes_2399', 'Kayes', 'Kayes',
'', '1', 'state', 1),
(2400, 'state_Koulikoro_2400', 'Koulikoro',
'Koulikoro', '', '2', 'state', 1),
(2401, 'state_Sikasso_2401', 'Sikasso',
'Sikasso', '', '3', 'state', 1),
(2402, 'state_S__gou_2402', 'Ségou',
'Ségou', '', '4', 'state', 1),
(2403, 'state_Mopti_2403', 'Mopti', 'Mopti',
'', '5', 'state', 1),
(2404, 'state_Tombouctou_2404', 'Tombouctou',
'Tombouctou', '', '6', 'state',
1),
(2405, 'state_Gao_2405', 'Gao', 'Gao',
'', '7', 'state', 1),
(2406, 'state_Kidal_2406', 'Kidal', 'Kidal',
'', '8', 'state', 1),
(2407, 'state_Bamako_2407', 'Bamako',
'Bamako', '', 'BK0', 'state', 1),
(2408, 'state_malta_2408', ' ', ' ',
'', 'MLT', 'state', 1),
(2409, 'state_gozo_2409', 'Gozo', 'Gozo',
'', 'GZO', 'state', 1),
(2476, 'state_Ailuk_2476', 'Ailuk', 'Ailuk',
'', 'ALK', 'state', 1),
(2477, 'state_Ailinglapalap_2477', 'Ailinglapalap',
'Ailinglapalap', '', 'ALL',
'state', 1),
(2478, 'state_Arno_2478', 'Arno', 'Arno',
'', 'ARN', 'state', 1),
(2479, 'state_Aur_2479', 'Aur', 'Aur',
'', 'AUR', 'state', 1),
(2480, 'state_Ebon_2480', 'Ebon', 'Ebon',
'', 'EBO', 'state', 1),
(2481, 'state_Eniwetok_2481', 'Eniwetok',
'Eniwetok', '', 'ENI', 'state',
1),
(2482, 'state_Jabat_2482', 'Jabat', 'Jabat',
'', 'JAB', 'state', 1),
(2483, 'state_Jaluit_2483', 'Jaluit',
'Jaluit', '', 'JAL', 'state', 1),
(2484, 'state_Kili_2484', 'Kili', 'Kili',
'', 'KIL', 'state', 1),
(2485, 'state_Kwajalein_2485', 'Kwajalein',
'Kwajalein', '', 'KWA', 'state',
1),
(2486, 'state_Lae_2486', 'Lae', 'Lae',
'', 'LAE', 'state', 1),
(2487, 'state_Lib_2487', 'Lib', 'Lib',
'', 'LIB', 'state', 1),
(2488, 'state_Likiep_2488', 'Likiep',
'Likiep', '', 'LIK', 'state', 1),
(2489, 'state_Majuro_2489', 'Majuro',
'Majuro', '', 'MAJ', 'state', 1),
(2490, 'state_Maloelap_2490', 'Maloelap',
'Maloelap', '', 'MAL', 'state',
1),
(2491, 'state_Mejit_2491', 'Mejit', 'Mejit',
'', 'MEJ', 'state', 1),
(2492, 'state_Mili_2492', 'Mili', 'Mili',
'', 'MIL', 'state', 1),
(2493, 'state_Namorik_2493', 'Namorik',
'Namorik', '', 'NMK', 'state', 1),
(2494, 'state_Namu_2494', 'Namu', 'Namu',
'', 'NMU', 'state', 1),
(2495, 'state_Rongelap_2495', 'Rongelap',
'Rongelap', '', 'RON', 'state',
1),
(2496, 'state_Ujae_2496', 'Ujae', 'Ujae',
'', 'UJA', 'state', 1),
(2497, 'state_Ujelang_2497', 'Ujelang',
'Ujelang', '', 'UJL', 'state', 1),
(2498, 'state_Utirik_2498', 'Utirik',
'Utirik', '', 'UTI', 'state', 1),
(2499, 'state_Wotje_2499', 'Wotje', 'Wotje',
'', 'WTJ', 'state', 1);";
$this->db->setQuery($query);
$this->db->query();
$query="
INSERT IGNORE INTO `#__hikashop_zone` (`zone_id`, `zone_namekey`,
`zone_name`, `zone_name_english`, `zone_code_2`, `zone_code_3`,
`zone_type`, `zone_published`) VALUES
(2500, 'state_Wotho_2500', 'Wotho', 'Wotho',
'', 'WTN', 'state', 1),
(2501, 'state____________________________________2501',
'ÙÙۧÙŰ© ۧÙŰÙ۶ ۧÙێ۱ÙÙ', 'ÙÙۧÙŰ© ۧÙŰÙ۶
ۧÙێ۱ÙÙ', '', '01', 'state', 1),
(2502, 'state____________________________________2502',
'ÙÙۧÙŰ© ۧÙŰÙ۶ ۧÙŰș۱ۚÙ', 'ÙÙۧÙŰ© ۧÙŰÙ۶
ۧÙŰș۱ۚÙ', '', '02', 'state', 1),
(2503, 'state___________________________2503', 'ÙÙۧÙŰ©
ۧÙŰč۔ۧۚ۩', 'ÙÙۧÙŰ© ۧÙŰč۔ۧۚ۩', '',
'03', 'state', 1),
(2504, 'state_______________________2504', 'ÙÙۧÙŰ©
Ù۱ÙÙÙ', 'ÙÙۧÙŰ© Ù۱ÙÙÙ', '',
'04', 'state', 1),
(2505, 'state_____________________________2505', 'ÙÙۧÙŰ©
ۧÙۚ۱ۧÙÙŰ©', 'ÙÙۧÙŰ© ۧÙۚ۱ۧÙÙŰ©',
'', '05', 'state', 1),
(2506, 'state_____________________________2506', 'ÙÙۧÙŰ©
ۧÙŰȘ۱ۧ۱ŰČŰ©', 'ÙÙۧÙŰ© ۧÙŰȘ۱ۧ۱ŰČŰ©',
'', '06', 'state', 1),
(2507, 'state_______________________2507', 'ÙÙۧÙŰ©
۹ۯ۱ۧ۱', 'ÙÙۧÙŰ© ۹ۯ۱ۧ۱', '',
'07', 'state', 1),
(2508, 'state______________________________________2508',
'ÙÙۧÙŰ© ۯۧ۟ÙŰȘ ÙÙۧ۰ÙŰšÙ', 'ÙÙۧÙŰ©
ۯۧ۟ÙŰȘ ÙÙۧ۰ÙŰšÙ', '', '08',
'state', 1),
(2509, 'state_______________________2509', 'ÙÙۧÙŰ©
ŰȘÙۧÙŰȘ', 'ÙÙۧÙŰ© ŰȘÙۧÙŰȘ', '',
'09', 'state', 1),
(2510, 'state______________________________2510',
'ÙÙۧÙŰ© ÙÙŰŻÙ Ù
ۧŰșŰ©', 'ÙÙۧÙŰ© ÙÙŰŻÙ
Ù
ۧŰșŰ©', '', '10', 'state', 1),
(2511, 'state______________________________2511',
'ÙÙۧÙŰ© ŰȘÙ۱۳ ŰČÙ
Ù۱', 'ÙÙۧÙŰ© ŰȘÙ۱۳
ŰČÙ
Ù۱', '', '11', 'state', 1),
(2512, 'state___________________________2512', 'ÙÙۧÙŰ©
Ű„ÙÙŰŽÙ۱Ù', 'ÙÙۧÙŰ© Ű„ÙÙŰŽÙ۱Ù', '',
'12', 'state', 1),
(2513, 'state________________2513', 'ÙÙۧÙŰŽÙŰ·',
'ÙÙۧÙŰŽÙŰ·', '', 'NKC',
'state', 1),
(2514, 'state_Agalega_Islands_2514', 'Agalega Islands',
'Agalega Islands', '', 'AG',
'state', 1),
(2515, 'state_Black_River_2515', 'Black River',
'Black River', '', 'BL', 'state',
1),
(2516, 'state_Beau_Bassin_Rose_Hill_2516', 'Beau Bassin-Rose
Hill', 'Beau Bassin-Rose Hill', '',
'BR', 'state', 1),
(2517, 'state_Cargados_Carajos_Shoals_2517', 'Cargados
Carajos Shoals', 'Cargados Carajos Shoals', '',
'CC', 'state', 1),
(2518, 'state_Curepipe_2518', 'Curepipe',
'Curepipe', '', 'CU', 'state', 1),
(2519, 'state_Flacq_2519', 'Flacq', 'Flacq',
'', 'FL', 'state', 1),
(2520, 'state_Grand_Port_2520', 'Grand Port',
'Grand Port', '', 'GP', 'state',
1),
(2521, 'state_Moka_2521', 'Moka', 'Moka',
'', 'MO', 'state', 1),
(2522, 'state_Pamplemousses_2522', 'Pamplemousses',
'Pamplemousses', '', 'PA', 'state',
1),
(2523, 'state_Port_Louis_2523', 'Port Louis',
'Port Louis', '', 'PL', 'state',
1),
(2524, 'state_Port_Louis_City_2524', 'Port Louis City',
'Port Louis City', '', 'PU',
'state', 1),
(2525, 'state_Plaines_Wilhems_2525', 'Plaines Wilhems',
'Plaines Wilhems', '', 'PW',
'state', 1),
(2526, 'state_Quatre_Bornes_2526', 'Quatre Bornes',
'Quatre Bornes', '', 'QB', 'state',
1),
(2527, 'state_Rodrigues_2527', 'Rodrigues',
'Rodrigues', '', 'RO', 'state',
1),
(2528, 'state_Riviere_du_Rempart_2528', 'Riviere du
Rempart', 'Riviere du Rempart', '',
'RR', 'state', 1),
(2529, 'state_Savanne_2529', 'Savanne',
'Savanne', '', 'SA', 'state', 1),
(2530, 'state_Vacoas_Phoenix_2530', 'Vacoas-Phoenix',
'Vacoas-Phoenix', '', 'VP',
'state', 1),
(2531, 'state_Aguascalientes_2531', 'Aguascalientes',
'Aguascalientes', '', 'AGU',
'state', 1),
(2532, 'state_Baja_California_2532', 'Baja California',
'Baja California', '', 'BCN',
'state', 1),
(2533, 'state_Baja_California_Sur_2533', 'Baja California
Sur', 'Baja California Sur', '', 'BCS',
'state', 1),
(2534, 'state_Campeche_2534', 'Campeche',
'Campeche', '', 'CAM', 'state',
1),
(2535, 'state_Chihuahua_2535', 'Chihuahua',
'Chihuahua', '', 'CHH', 'state',
1),
(2536, 'state_Chiapas_2536', 'Chiapas',
'Chiapas', '', 'CHP', 'state', 1),
(2537, 'state_Coahuila_2537', 'Coahuila',
'Coahuila', '', 'COA', 'state',
1),
(2538, 'state_Colima_2538', 'Colima',
'Colima', '', 'COL', 'state', 1),
(2539, 'state_Distrito_Federal_2539', 'Distrito
Federal', 'Distrito Federal', '', 'DIF',
'state', 1),
(2540, 'state_Durango_2540', 'Durango',
'Durango', '', 'DUR', 'state', 1),
(2541, 'state_Guerrero_2541', 'Guerrero',
'Guerrero', '', 'GRO', 'state',
1),
(2542, 'state_Guanajuato_2542', 'Guanajuato',
'Guanajuato', '', 'GUA', 'state',
1),
(2543, 'state_Hidalgo_2543', 'Hidalgo',
'Hidalgo', '', 'HID', 'state', 1),
(2544, 'state_Jalisco_2544', 'Jalisco',
'Jalisco', '', 'JAL', 'state', 1),
(2545, 'state_Mexico_2545', 'Estado de México',
'Estado de México', '', 'MEX',
'state', 1),
(2546, 'state_Michoac__n_2546', 'MichoacĂĄn',
'MichoacĂĄn', '', 'MIC', 'state',
1),
(2547, 'state_Morelos_2547', 'Morelos',
'Morelos', '', 'MOR', 'state', 1),
(2548, 'state_Nayarit_2548', 'Nayarit',
'Nayarit', '', 'NAY', 'state', 1),
(2549, 'state_Nuevo_Le__n_2549', 'Nuevo LeĂłn',
'Nuevo LeĂłn', '', 'NLE', 'state',
1),
(2550, 'state_Oaxaca_2550', 'Oaxaca',
'Oaxaca', '', 'OAX', 'state', 1),
(2551, 'state_Puebla_2551', 'Puebla',
'Puebla', '', 'PUE', 'state', 1),
(2552, 'state_Quer__taro_2552', 'Querétaro',
'Querétaro', '', 'QUE', 'state',
1),
(2553, 'state_Quintana_Roo_2553', 'Quintana Roo',
'Quintana Roo', '', 'ROO', 'state',
1),
(2554, 'state_Sinaloa_2554', 'Sinaloa',
'Sinaloa', '', 'SIN', 'state', 1),
(2555, 'state_San_Luis_Potos___2555', 'San Luis
PotosĂ', 'San Luis PotosĂ', '', 'SLP',
'state', 1),
(2556, 'state_Sonora_2556', 'Sonora',
'Sonora', '', 'SON', 'state', 1),
(2557, 'state_Tabasco_2557', 'Tabasco',
'Tabasco', '', 'TAB', 'state', 1),
(2558, 'state_Tamaulipas_2558', 'Tamaulipas',
'Tamaulipas', '', 'TAM', 'state',
1),
(2559, 'state_Tlaxcala_2559', 'Tlaxcala',
'Tlaxcala', '', 'TLA', 'state',
1),
(2560, 'state_Veracruz_2560', 'Veracruz',
'Veracruz', '', 'VER', 'state',
1),
(2561, 'state_Yucatan_2561', 'Yucatan',
'Yucatan', '', 'YUC', 'state', 1),
(2562, 'state_Zacatecas_2562', 'Zacatecas',
'Zacatecas', '', 'ZAC', 'state',
1),
(2563, 'state_Kosrae_2563', 'Kosrae',
'Kosrae', '', 'KSA', 'state', 1),
(2564, 'state_Pohnpei_2564', 'Pohnpei',
'Pohnpei', '', 'PNI', 'state', 1),
(2565, 'state_Chuuk_2565', 'Chuuk', 'Chuuk',
'', 'TRK', 'state', 1),
(2566, 'state_Yap_2566', 'Yap', 'Yap',
'', 'YAP', 'state', 1),
(2567, 'state_B__l__i_2567', 'BÄlĆŁi',
'BÄlĆŁi', '', 'BA', 'state', 1),
(2568, 'state_Cahul_2568', 'Cahul', 'Cahul',
'', 'CA', 'state', 1),
(2569, 'state_Chi__in__u_2569', 'ChiĆinÄu',
'ChiĆinÄu', '', 'CU', 'state',
1),
(2570, 'state_Edine___2570', 'EdineĆŁ',
'EdineĆŁ', '', 'ED', 'state', 1),
(2571, 'state_G__g__uzia_2571', 'GÄgÄuzia',
'GÄgÄuzia', '', 'GA', 'state',
1),
(2572, 'state_L__pu__na_2572', 'LÄpuĆna',
'LÄpuĆna', '', 'LA', 'state',
1),
(2573, 'state_Orhei_2573', 'Orhei', 'Orhei',
'', 'OR', 'state', 1),
(2574, 'state_St__nga_Nistrului_2574', 'StĂąnga
Nistrului', 'StĂąnga Nistrului', '',
'SN', 'state', 1),
(2575, 'state_Soroca_2575', 'Soroca',
'Soroca', '', 'SO', 'state', 1),
(2576, 'state_Tighina_2576', 'Tighina',
'Tighina', '', 'TI', 'state', 1),
(2577, 'state_Ungheni_2577', 'Ungheni',
'Ungheni', '', 'UN', 'state', 1),
(2578, 'state_Monte_Carlo_2578', 'Monte Carlo',
'Monte Carlo', '', 'MC', 'state',
1),
(2579, 'state_La_Rousse_2579', 'La Rousse', 'La
Rousse', '', 'LR', 'state', 1),
(2580, 'state_Larvotto_2580', 'Larvotto',
'Larvotto', '', 'LA', 'state', 1),
(2581, 'state_Monaco_Ville_2581', 'Monaco Ville',
'Monaco Ville', '', 'MV', 'state',
1),
(2582, 'state_Saint_Michel_2582', 'Saint Michel',
'Saint Michel', '', 'SM', 'state',
1),
(2583, 'state_Condamine_2583', 'Condamine',
'Condamine', '', 'CO', 'state',
1),
(2584, 'state_La_Colle_2584', 'La Colle', 'La
Colle', '', 'LC', 'state', 1),
(2585, 'state_Les_R__voires_2585', 'Les Révoires',
'Les Révoires', '', 'RE', 'state',
1),
(2586, 'state_Moneghetti_2586', 'Moneghetti',
'Moneghetti', '', 'MO', 'state',
1),
(2587, 'state_Fontvieille_2587', 'Fontvieille',
'Fontvieille', '', 'FV', 'state',
1),
(2588, 'state________________________2588',
'ĐŁĐ»Đ°Đ°ĐœĐ±Đ°Đ°ŃаŃ', 'ĐŁĐ»Đ°Đ°ĐœĐ±Đ°Đ°ŃаŃ',
'', '1', 'state', 1),
(2589, 'state_______________________2589', 'ĐŃŃ
ĐŸĐœ
аĐčĐŒĐ°Đł', 'ĐŃŃ
ĐŸĐœ аĐčĐŒĐ°Đł', '',
'035', 'state', 1),
(2590, 'state________________________________2590',
'ĐаŃŃ
Đ°Đœ-ĐŁŃĐ» аĐčĐŒĐ°Đł', 'ĐаŃŃ
Đ°Đœ-ĐŁŃĐ»
аĐčĐŒĐ°Đł', '', '037', 'state', 1),
(2591, 'state_________________________2591', 'Đ„ŃĐœŃĐžĐč
аĐčĐŒĐ°Đł', 'Đ„ŃĐœŃĐžĐč аĐčĐŒĐ°Đł', '',
'039', 'state', 1),
(2592, 'state___________________________2592',
'ЄөĐČŃĐłÓ©Đ» аĐčĐŒĐ°Đł', 'ЄөĐČŃĐłÓ©Đ»
аĐčĐŒĐ°Đł', '', '041', 'state', 1),
(2593, 'state_____________________2593', 'Đ„ĐŸĐČĐŽ
аĐčĐŒĐ°Đł', 'Đ„ĐŸĐČĐŽ аĐčĐŒĐ°Đł', '',
'043', 'state', 1),
(2594, 'state___________________2594', 'ĐŁĐČŃ
аĐčĐŒĐ°Đł', 'ĐŁĐČŃ Đ°ĐčĐŒĐ°Đł', '',
'046', 'state', 1),
(2595, 'state___________________2595', 'ĐąÓ©ĐČ
аĐčĐŒĐ°Đł', 'ĐąÓ©ĐČ Đ°ĐčĐŒĐ°Đł', '',
'047', 'state', 1),
(2596, 'state___________________________2596',
'ĐĄŃĐ»ŃĐœĐłŃ Đ°ĐčĐŒĐ°Đł', 'ĐĄŃĐ»ŃĐœĐłŃ
аĐčĐŒĐ°Đł', '', '049', 'state', 1),
(2597, 'state_______________________________2597',
'ĐĄÒŻŃ
бааŃĐ°Ń Đ°ĐčĐŒĐ°Đł', 'ĐĄÒŻŃ
бааŃаŃ
аĐčĐŒĐ°Đł', '', '051', 'state', 1),
(2598, 'state_____________________________2598',
'ÓšĐŒĐœÓ©ĐłĐŸĐČŃ Đ°ĐčĐŒĐ°Đł', 'ÓšĐŒĐœÓ©ĐłĐŸĐČŃ
аĐčĐŒĐ°Đł', '', '053', 'state', 1),
(2599, 'state_________________________________2599',
'ÓšĐČÓ©ŃŃ
Đ°ĐœĐłĐ°Đč аĐčĐŒĐ°Đł', 'ÓšĐČÓ©ŃŃ
Đ°ĐœĐłĐ°Đč
аĐčĐŒĐ°Đł', '', '055', 'state', 1),
(2600, 'state_________________________2600', 'ĐаĐČŃ
Đ°Đœ
аĐčĐŒĐ°Đł', 'ĐаĐČŃ
Đ°Đœ аĐčĐŒĐ°Đł', '',
'057', 'state', 1),
(2601, 'state_____________________________2601',
'ĐŃĐœĐŽĐłĐŸĐČŃ Đ°ĐčĐŒĐ°Đł', 'ĐŃĐœĐŽĐłĐŸĐČŃ
аĐčĐŒĐ°Đł', '', '059', 'state', 1),
(2602, 'state_________________________2602', 'ĐĐŸŃĐœĐŸĐŽ
аĐčĐŒĐ°Đł', 'ĐĐŸŃĐœĐŸĐŽ аĐčĐŒĐ°Đł', '',
'061', 'state', 1),
(2603, 'state_______________________________2603',
'ĐĐŸŃĐœĐŸĐłĐŸĐČŃ Đ°ĐčĐŒĐ°Đł', 'ĐĐŸŃĐœĐŸĐłĐŸĐČŃ
аĐčĐŒĐ°Đł', '', '063', 'state', 1),
(2604, 'state_________________________________2604',
'ĐĐŸĐČŃŃÒŻĐŒĐ±ŃŃ Đ°ĐčĐŒĐ°Đł', 'ĐĐŸĐČŃŃÒŻĐŒĐ±ŃŃ
аĐčĐŒĐ°Đł', '', '064', 'state', 1),
(2605, 'state________________________________2605',
'ĐĐŸĐČŃ-ĐĐ»ŃаĐč аĐčĐŒĐ°Đł', 'ĐĐŸĐČŃ-ĐĐ»ŃаĐč
аĐčĐŒĐ°Đł', '', '065', 'state', 1),
(2606, 'state_________________________2606', 'ĐŃĐ»ĐłĐ°Đœ
аĐčĐŒĐ°Đł', 'ĐŃĐ»ĐłĐ°Đœ аĐčĐŒĐ°Đł', '',
'067', 'state', 1),
(2607, 'state_________________________________2607',
'ĐаŃĐœŃ
ĐŸĐœĐłĐŸŃ Đ°ĐčĐŒĐ°Đł', 'ĐаŃĐœŃ
ĐŸĐœĐłĐŸŃ
аĐčĐŒĐ°Đł', '', '069', 'state', 1),
(2608, 'state________________________________2608',
'ĐаŃĐœ ӚлгОĐč аĐčĐŒĐ°Đł', 'ĐаŃĐœ ӚлгОĐč
аĐčĐŒĐ°Đł', '', '071', 'state', 1),
(2609, 'state_____________________________2609',
'ĐŃŃ
Đ°ĐœĐłĐ°Đč аĐčĐŒĐ°Đł', 'ĐŃŃ
Đ°ĐœĐłĐ°Đč
аĐčĐŒĐ°Đł', '', '073', 'state', 1),
(2610, 'state_Saint_Anthony_2610', 'Saint Anthony',
'Saint Anthony', '', 'A', 'state',
1),
(2611, 'state_Saint_Georges_2611', 'Saint Georges',
'Saint Georges', '', 'G', 'state',
1),
(2612, 'state_Saint_Peter_2612', 'Saint Peter',
'Saint Peter', '', 'P', 'state',
1),
(2613, 'state_Niassa_2613', 'Niassa',
'Niassa', '', 'A', 'state', 1),
(2614, 'state_Manica_2614', 'Manica',
'Manica', '', 'B', 'state', 1),
(2615, 'state_Gaza_2615', 'Gaza', 'Gaza',
'', 'G', 'state', 1),
(2616, 'state_Inhambane_2616', 'Inhambane',
'Inhambane', '', 'I', 'state', 1),
(2617, 'state_Maputo_2617', 'Maputo',
'Maputo', '', 'L', 'state', 1),
(2618, 'state_Maputo_cidade_2618', 'Maputo cidade',
'Maputo cidade', '', 'MPM',
'state', 1),
(2619, 'state_Nampula_2619', 'Nampula',
'Nampula', '', 'N', 'state', 1),
(2620, 'state_Cabo_Delgado_2620', 'Cabo Delgado',
'Cabo Delgado', '', 'P', 'state',
1),
(2621, 'state_Zamb__zia_2621', 'Zambézia',
'Zambézia', '', 'Q', 'state', 1),
(2622, 'state_Sofala_2622', 'Sofala',
'Sofala', '', 'S', 'state', 1),
(2623, 'state_Tete_2623', 'Tete', 'Tete',
'', 'T', 'state', 1),
(2624, 'state_________________________________________2624',
'á§ááŹáááźáááŻááčâáž',
'á§ááŹáááźáááŻááčâáž', '',
'AY', 'state', 1),
(2625, 'state______________________________________2625',
'ááČáá°ážááŻáááčâáž',
'ááČáá°ážááŻáááčâáž', '',
'BG', 'state', 1),
(2626, 'state_________________________________________2626',
'ááá±áčáážáááŻááčâáž',
'ááá±áčáážáááŻááčâáž', '',
'MG', 'state', 1),
(2627, 'state____________________________________________2627',
'áááčááá±ážááŻáááčâáž',
'áááčááá±ážááŻáááčâáž', '',
'MD', 'state', 1),
(2628,
'state___________________________________________________________2628',
'á
á
áčâááŻáááčâážâááŻáááčâáž',
'á
á
áčâááŻáááčâážâááŻáááčâáž',
'', 'SG', 'state', 1),
(2629,
'state_______________________________________________2629',
'ááááčááŹááááŻáááčâáž',
'ááááčááŹááááŻáááčâáž', '',
'TN', 'state', 1),
(2630,
'state__________________________________________________2630',
'áááčâááŻááčâááŻáááčâáž',
'áááčâááŻááčâááŻáááčâáž', '',
'YG', 'state', 1),
(2631,
'state_____________________________________________________2631',
'ááčáááčâážááčáááčâáááčâ',
'ááčáááčâážááčáááčâáááčâ',
'', 'CH', 'state', 1),
(2632,
'state_____________________________________________________2632',
'áááčáááčâááčáááčâáááčâ',
'áááčáááčâááčáááčâáááčâ',
'', 'KC', 'state', 1),
(2633,
'state_______________________________________________2633',
'áááŹážâááčáááčâáááčâ',
'áááŹážâááčáááčâáááčâ', '',
'KH', 'state', 1),
(2634,
'state__________________________________________________2634',
'ááááčââááčáááčâáááčâ',
'ááááčââááčáááčâáááčâ', '',
'KN', 'state', 1),
(2635,
'state__________________________________________________2635',
'ááčáááčâááčáááčâáááčâ',
'ááčáááčâááčáááčâáááčâ', '',
'MN', 'state', 1),
(2636,
'state_____________________________________________________2636',
'áááŻáááčâááčáááčâáááčâ',
'áááŻáááčâááčáááčâáááčâ',
'', 'RK', 'state', 1),
(2637,
'state__________________________________________________2637',
'ááŻááčâážááčáááčâáááčâ',
'ááŻááčâážááčáááčâáááčâ', '',
'SH', 'state', 1),
(2638, 'state_Caprivi_2638', 'Caprivi',
'Caprivi', '', 'CA', 'state', 1),
(2639, 'state_Erongo_2639', 'Erongo',
'Erongo', '', 'ER', 'state', 1),
(2640, 'state_Hardap_2640', 'Hardap',
'Hardap', '', 'HA', 'state', 1),
(2641, 'state_Karas_2641', 'Karas', 'Karas',
'', 'KA', 'state', 1),
(2642, 'state_Khomas_2642', 'Khomas',
'Khomas', '', 'KH', 'state', 1),
(2643, 'state_Kunene_2643', 'Kunene',
'Kunene', '', 'KU', 'state', 1),
(2644, 'state_Otjozondjupa_2644', 'Otjozondjupa',
'Otjozondjupa', '', 'OD', 'state',
1),
(2645, 'state_Omaheke_2645', 'Omaheke',
'Omaheke', '', 'OH', 'state', 1),
(2646, 'state_Okavango_2646', 'Okavango',
'Okavango', '', 'OK', 'state', 1),
(2647, 'state_Oshana_2647', 'Oshana',
'Oshana', '', 'ON', 'state', 1),
(2648, 'state_Omusati_2648', 'Omusati',
'Omusati', '', 'OS', 'state', 1),
(2649, 'state_Oshikoto_2649', 'Oshikoto',
'Oshikoto', '', 'OT', 'state', 1),
(2650, 'state_Ohangwena_2650', 'Ohangwena',
'Ohangwena', '', 'OW', 'state',
1),
(2651, 'state_Aiwo_2651', 'Aiwo', 'Aiwo',
'', 'AO', 'state', 1),
(2652, 'state_Anabar_2652', 'Anabar',
'Anabar', '', 'AA', 'state', 1),
(2653, 'state_Anetan_2653', 'Anetan',
'Anetan', '', 'AT', 'state', 1),
(2654, 'state_Anibare_2654', 'Anibare',
'Anibare', '', 'AI', 'state', 1),
(2655, 'state_Baiti_2655', 'Baiti', 'Baiti',
'', 'BA', 'state', 1),
(2656, 'state_Boe_2656', 'Boe', 'Boe',
'', 'BO', 'state', 1),
(2657, 'state_Buada_2657', 'Buada', 'Buada',
'', 'BU', 'state', 1),
(2658, 'state_Denigomodu_2658', 'Denigomodu',
'Denigomodu', '', 'DE', 'state',
1),
(2659, 'state_Ewa_2659', 'Ewa', 'Ewa',
'', 'EW', 'state', 1),
(2660, 'state_Ijuw_2660', 'Ijuw', 'Ijuw',
'', 'IJ', 'state', 1),
(2661, 'state_Meneng_2661', 'Meneng',
'Meneng', '', 'ME', 'state', 1),
(2662, 'state_Nibok_2662', 'Nibok', 'Nibok',
'', 'NI', 'state', 1),
(2663, 'state_Uaboe_2663', 'Uaboe', 'Uaboe',
'', 'UA', 'state', 1),
(2664, 'state_Yaren_2664', 'Yaren', 'Yaren',
'', 'YA', 'state', 1),
(2665, 'state_Bagmati_2665', 'Bagmati',
'Bagmati', '', 'BA', 'state', 1),
(2666, 'state_Bheri_2666', 'Bheri', 'Bheri',
'', 'BH', 'state', 1),
(2667, 'state_Dhawalagiri_2667', 'Dhawalagiri',
'Dhawalagiri', '', 'DH', 'state',
1),
(2668, 'state_Gandaki_2668', 'Gandaki',
'Gandaki', '', 'GA', 'state', 1),
(2669, 'state_Janakpur_2669', 'Janakpur',
'Janakpur', '', 'JA', 'state', 1),
(2670, 'state_Karnali_2670', 'Karnali',
'Karnali', '', 'KA', 'state', 1),
(2671, 'state_Kosi_2671', 'Kosi', 'Kosi',
'', 'KO', 'state', 1),
(2672, 'state_Lumbini_2672', 'Lumbini',
'Lumbini', '', 'LU', 'state', 1),
(2673, 'state_Mahakali_2673', 'Mahakali',
'Mahakali', '', 'MA', 'state', 1),
(2674, 'state_Mechi_2674', 'Mechi', 'Mechi',
'', 'ME', 'state', 1),
(2675, 'state_Narayani_2675', 'Narayani',
'Narayani', '', 'NA', 'state', 1),
(2676, 'state_Rapti_2676', 'Rapti', 'Rapti',
'', 'RA', 'state', 1),
(2677, 'state_Sagarmatha_2677', 'Sagarmatha',
'Sagarmatha', '', 'SA', 'state',
1),
(2678, 'state_Seti_2678', 'Seti', 'Seti',
'', 'SE', 'state', 1),
(2679, 'state_Drenthe_2679', 'Drenthe',
'Drenthe', '', 'DR', 'state', 1),
(2680, 'state_Flevoland_2680', 'Flevoland',
'Flevoland', '', 'FL', 'state',
1),
(2681, 'state_Friesland_2681', 'Friesland',
'Friesland', '', 'FR', 'state',
1),
(2682, 'state_Gelderland_2682', 'Gelderland',
'Gelderland', '', 'GE', 'state',
1),
(2683, 'state_Groningen_2683', 'Groningen',
'Groningen', '', 'GR', 'state',
1),
(2684, 'state_Limburg_2684', 'Limburg',
'Limburg', '', 'LI', 'state', 1),
(2685, 'state_Noord_Brabant_2685', 'Noord-Brabant',
'Noord-Brabant', '', 'NB', 'state',
1),
(2686, 'state_Noord_Holland_2686', 'Noord-Holland',
'Noord-Holland', '', 'NH', 'state',
1),
(2687, 'state_Overijssel_2687', 'Overijssel',
'Overijssel', '', 'OV', 'state',
1),
(2688, 'state_Utrecht_2688', 'Utrecht',
'Utrecht', '', 'UT', 'state', 1),
(2689, 'state_Zeeland_2689', 'Zeeland',
'Zeeland', '', 'ZE', 'state', 1),
(2690, 'state_Zuid_Holland_2690', 'Zuid-Holland',
'Zuid-Holland', '', 'ZH', 'state',
1),
(2691, 'state_Province_des___les_2691', 'Province des
Ăles', 'Province des Ăles', '', 'L',
'state', 1),
(2692, 'state_Province_Nord_2692', 'Province Nord',
'Province Nord', '', 'N', 'state',
1),
(2693, 'state_Province_Sud_2693', 'Province Sud',
'Province Sud', '', 'S', 'state',
1),
(2694, 'state_Auckland_2694', 'Auckland',
'Auckland', '', 'AUK', 'state',
1),
(2695, 'state_Bay_of_Plenty_2695', 'Bay of Plenty',
'Bay of Plenty', '', 'BOP',
'state', 1),
(2696, 'state_Canterbury_2696', 'Canterbury',
'Canterbury', '', 'CAN', 'state',
1),
(2697, 'state_Gisborne_2697', 'Gisborne',
'Gisborne', '', 'GIS', 'state',
1),
(2698, 'state_Hawke_s_Bay_2698', 'Hawke''s
Bay', 'Hawke''s Bay', '',
'HKB', 'state', 1),
(2699, 'state_Marlborough_2699', 'Marlborough',
'Marlborough', '', 'MBH', 'state',
1),
(2700, 'state_Manawatu_Wanganui_2700',
'Manawatu-Wanganui', 'Manawatu-Wanganui', '',
'MWT', 'state', 1),
(2701, 'state_Nelson_2701', 'Nelson',
'Nelson', '', 'NSN', 'state', 1),
(2702, 'state_Northland_2702', 'Northland',
'Northland', '', 'NTL', 'state',
1),
(2703, 'state_Otago_2703', 'Otago', 'Otago',
'', 'OTA', 'state', 1),
(2704, 'state_Southland_2704', 'Southland',
'Southland', '', 'STL', 'state',
1),
(2705, 'state_Tasman_2705', 'Tasman',
'Tasman', '', 'TAS', 'state', 1),
(2706, 'state_Taranaki_2706', 'Taranaki',
'Taranaki', '', 'TKI', 'state',
1),
(2707, 'state_Wellington_2707', 'Wellington',
'Wellington', '', 'WGN', 'state',
1),
(2708, 'state_Waikato_2708', 'Waikato',
'Waikato', '', 'WKO', 'state', 1),
(2709, 'state_West_Coast_2709', 'West Coast',
'West Coast', '', 'WTC', 'state',
1),
(2710, 'state_Atl__ntico_Norte_2710', 'AtlĂĄntico
Norte', 'AtlĂĄntico Norte', '', 'AN',
'state', 1),
(2711, 'state_Atl__ntico_Sur_2711', 'AtlĂĄntico Sur',
'AtlĂĄntico Sur', '', 'AS',
'state', 1),
(2712, 'state_Boaco_2712', 'Boaco', 'Boaco',
'', 'BO', 'state', 1),
(2713, 'state_Carazo_2713', 'Carazo',
'Carazo', '', 'CA', 'state', 1),
(2714, 'state_Chinandega_2714', 'Chinandega',
'Chinandega', '', 'CI', 'state',
1),
(2715, 'state_Chontales_2715', 'Chontales',
'Chontales', '', 'CO', 'state',
1),
(2716, 'state_Estel___2716', 'EstelĂ',
'EstelĂ', '', 'ES', 'state', 1),
(2717, 'state_Granada_2717', 'Granada',
'Granada', '', 'GR', 'state', 1),
(2718, 'state_Jinotega_2718', 'Jinotega',
'Jinotega', '', 'JI', 'state', 1),
(2719, 'state_Le__n_2719', 'LeĂłn', 'LeĂłn',
'', 'LE', 'state', 1),
(2720, 'state_Madriz_2720', 'Madriz',
'Madriz', '', 'MD', 'state', 1),
(2721, 'state_Managua_2721', 'Managua',
'Managua', '', 'MN', 'state', 1),
(2722, 'state_Masaya_2722', 'Masaya',
'Masaya', '', 'MS', 'state', 1),
(2723, 'state_Matagalpa_2723', 'Matagalpa',
'Matagalpa', '', 'MT', 'state',
1),
(2724, 'state_Nueva_Segovia_2724', 'Nueva Segovia',
'Nueva Segovia', '', 'NS', 'state',
1),
(2725, 'state_Rivas_2725', 'Rivas', 'Rivas',
'', 'RI', 'state', 1),
(2726, 'state_R__o_San_Juan_2726', 'RĂo San Juan',
'RĂo San Juan', '', 'SJ', 'state',
1),
(2727, 'state_Agadez_2727', 'Agadez',
'Agadez', '', '1', 'state', 1),
(2728, 'state_Daffa_2728', 'Daffa', 'Daffa',
'', '2', 'state', 1),
(2729, 'state_Dosso_2729', 'Dosso', 'Dosso',
'', '3', 'state', 1),
(2730, 'state_Maradi_2730', 'Maradi',
'Maradi', '', '4', 'state', 1),
(2731, 'state_Tahoua_2731', 'Tahoua',
'Tahoua', '', '5', 'state', 1),
(2732, 'state_Tillab__ry_2732', 'Tillabéry',
'Tillabéry', '', '6', 'state',
1),
(2733, 'state_Zinder_2733', 'Zinder',
'Zinder', '', '7', 'state', 1),
(2734, 'state_Niamey_2734', 'Niamey',
'Niamey', '', '8', 'state', 1),
(2735, 'state_Abia_State_2735', 'Abia State',
'Abia State', '', 'AB', 'state',
1),
(2736, 'state_Adamawa_State_2736', 'Adamawa State',
'Adamawa State', '', 'AD', 'state',
1),
(2737, 'state_Akwa_Ibom_State_2737', 'Akwa Ibom State',
'Akwa Ibom State', '', 'AK',
'state', 1),
(2738, 'state_Anambra_State_2738', 'Anambra State',
'Anambra State', '', 'AN', 'state',
1),
(2739, 'state_Bauchi_State_2739', 'Bauchi State',
'Bauchi State', '', 'BA', 'state',
1),
(2740, 'state_Benue_State_2740', 'Benue State',
'Benue State', '', 'BE', 'state',
1),
(2741, 'state_Borno_State_2741', 'Borno State',
'Borno State', '', 'BO', 'state',
1),
(2742, 'state_Bayelsa_State_2742', 'Bayelsa State',
'Bayelsa State', '', 'BY', 'state',
1),
(2743, 'state_Cross_River_State_2743', 'Cross River
State', 'Cross River State', '', 'CR',
'state', 1),
(2744, 'state_Delta_State_2744', 'Delta State',
'Delta State', '', 'DE', 'state',
1),
(2745, 'state_Ebonyi_State_2745', 'Ebonyi State',
'Ebonyi State', '', 'EB', 'state',
1),
(2746, 'state_Edo_State_2746', 'Edo State', 'Edo
State', '', 'ED', 'state', 1),
(2747, 'state_Ekiti_State_2747', 'Ekiti State',
'Ekiti State', '', 'EK', 'state',
1),
(2748, 'state_Enugu_State_2748', 'Enugu State',
'Enugu State', '', 'EN', 'state',
1),
(2749, 'state_Gombe_State_2749', 'Gombe State',
'Gombe State', '', 'GO', 'state',
1),
(2750, 'state_Imo_State_2750', 'Imo State', 'Imo
State', '', 'IM', 'state', 1),
(2751, 'state_Jigawa_State_2751', 'Jigawa State',
'Jigawa State', '', 'JI', 'state',
1),
(2752, 'state_Kebbi_State_2752', 'Kebbi State',
'Kebbi State', '', 'KB', 'state',
1),
(2753, 'state_Kaduna_State_2753', 'Kaduna State',
'Kaduna State', '', 'KD', 'state',
1),
(2754, 'state_Kano_State_2754', 'Kano State',
'Kano State', '', 'KN', 'state',
1),
(2755, 'state_Kogi_State_2755', 'Kogi State',
'Kogi State', '', 'KO', 'state',
1),
(2756, 'state_Katsina_State_2756', 'Katsina State',
'Katsina State', '', 'KT', 'state',
1),
(2757, 'state_Kwara_State_2757', 'Kwara State',
'Kwara State', '', 'KW', 'state',
1),
(2758, 'state_Lagos_State_2758', 'Lagos State',
'Lagos State', '', 'LA', 'state',
1),
(2759, 'state_Nassarawa_State_2759', 'Nassarawa State',
'Nassarawa State', '', 'NA',
'state', 1),
(2760, 'state_Niger_State_2760', 'Niger State',
'Niger State', '', 'NI', 'state',
1),
(2761, 'state_Ogun_State_2761', 'Ogun State',
'Ogun State', '', 'OG', 'state',
1),
(2762, 'state_Ondo_State_2762', 'Ondo State',
'Ondo State', '', 'ON', 'state',
1),
(2763, 'state_Osun_State_2763', 'Osun State',
'Osun State', '', 'OS', 'state',
1),
(2764, 'state_Oyo_State_2764', 'Oyo State', 'Oyo
State', '', 'OY', 'state', 1),
(2765, 'state_Plateau_State_2765', 'Plateau State',
'Plateau State', '', 'PL', 'state',
1),
(2766, 'state_Rivers_State_2766', 'Rivers State',
'Rivers State', '', 'RI', 'state',
1),
(2767, 'state_Sokoto_State_2767', 'Sokoto State',
'Sokoto State', '', 'SO', 'state',
1),
(2768, 'state_Taraba_State_2768', 'Taraba State',
'Taraba State', '', 'TA', 'state',
1),
(2769, 'state_Zamfara_State_2769', 'Zamfara State',
'Zamfara State', '', 'ZA', 'state',
1),
(2770, 'state_Northern_Islands_2770', 'Northern
Islands', 'Northern Islands', '', 'N',
'state', 1),
(2771, 'state_Rota_2771', 'Rota', 'Rota',
'', 'R', 'state', 1),
(2772, 'state_Saipan_2772', 'Saipan',
'Saipan', '', 'S', 'state', 1),
(2773, 'state_Tinian_2773', 'Tinian',
'Tinian', '', 'T', 'state', 1),
(2774, 'state___stfold_fylke_2774', 'Ăstfold fylke',
'Ăstfold fylke', '', '01',
'state', 1),
(2775, 'state_Akershus_fylke_2775', 'Akershus fylke',
'Akershus fylke', '', '02',
'state', 1),
(2776, 'state_Oslo_fylke_2776', 'Oslo fylke',
'Oslo fylke', '', '03', 'state',
1),
(2777, 'state_Hedmark_fylke_2777', 'Hedmark fylke',
'Hedmark fylke', '', '04', 'state',
1),
(2778, 'state_Oppland_fylke_2778', 'Oppland fylke',
'Oppland fylke', '', '05', 'state',
1),
(2779, 'state_Buskerud_fylke_2779', 'Buskerud fylke',
'Buskerud fylke', '', '06',
'state', 1),
(2780, 'state_Vestfold_fylke_2780', 'Vestfold fylke',
'Vestfold fylke', '', '07',
'state', 1),
(2781, 'state_Telemark_fylke_2781', 'Telemark fylke',
'Telemark fylke', '', '08',
'state', 1),
(2782, 'state_Aust_Agder_fylke_2782', 'Aust-Agder
fylke', 'Aust-Agder fylke', '', '09',
'state', 1),
(2783, 'state_Vest_Agder_fylke_2783', 'Vest-Agder
fylke', 'Vest-Agder fylke', '', '10',
'state', 1),
(2784, 'state_Rogaland_fylke_2784', 'Rogaland fylke',
'Rogaland fylke', '', '11',
'state', 1),
(2785, 'state_Hordaland_fylke_2785', 'Hordaland fylke',
'Hordaland fylke', '', '12',
'state', 1),
(2786, 'state_Sogn_og_Fjordane_fylke_2786', 'Sogn og
Fjordane fylke', 'Sogn og Fjordane fylke', '',
'14', 'state', 1),
(2787, 'state_M__re_og_Romsdal_fylke_2787', 'MĂžre og
Romsdal fylke', 'MĂžre og Romsdal fylke', '',
'15', 'state', 1),
(2788, 'state_S__r_Tr__ndelag_fylke_2788', 'SĂžr-TrĂžndelag
fylke', 'SĂžr-TrĂžndelag fylke', '',
'16', 'state', 1),
(2789, 'state_Nord_Tr__ndelag_fylke_2789', 'Nord-TrĂžndelag
fylke', 'Nord-TrĂžndelag fylke', '',
'17', 'state', 1),
(2790, 'state_Nordland_fylke_2790', 'Nordland fylke',
'Nordland fylke', '', '18',
'state', 1),
(2791, 'state_Troms_fylke_2791', 'Troms fylke',
'Troms fylke', '', '19', 'state',
1),
(2792, 'state_Finnmark_fylke_2792', 'Finnmark fylke',
'Finnmark fylke', '', '20',
'state', 1),
(2793, 'state________________2793', 'ۧÙۚۧ۷ÙŰ©',
'ۧÙۚۧ۷ÙŰ©', '', 'BA',
'state', 1),
(2794, 'state__________________2794',
'ۧÙۯۧ۟ÙÙŰ©', 'ۧÙۯۧ۟ÙÙŰ©', '',
'DA', 'state', 1),
(2795, 'state__________2795', 'ŰžÙۧ۱',
'ŰžÙۧ۱', '', 'DH', 'state', 1),
(2796, 'state__________2796', 'Ù
ŰłÙŰ·',
'Ù
ŰłÙŰ·', '', 'MA', 'state', 1),
(2797, 'state____________2797', 'Ù
ŰłÙŰŻÙ
',
'Ù
ŰłÙŰŻÙ
', '', 'MU', 'state',
1),
(2798, 'state________________2798', 'ۧÙێ۱ÙÙŰ©',
'ۧÙێ۱ÙÙŰ©', '', 'SH',
'state', 1),
(2799, 'state______________2799', 'ۧÙÙ۳۷Ù',
'ۧÙÙ۳۷Ù', '', 'WU', 'state',
1),
(2800, 'state________________2800', 'ۧÙ۞ۧÙ۱۩',
'ۧÙ۞ۧÙ۱۩', '', 'ZA',
'state', 1),
(2801, 'state__________________2801',
'ŰšÙÙÚŰłŰȘۧÙ', 'ŰšÙÙÚŰłŰȘۧÙ', '',
'BA', 'state', 1),
(2802, 'state_________________________________2802',
'ÙÙۧÙÛ ŰŻŰ§Ű±Ű§ÙŰÚ©ÙÙ
ŰȘ', 'ÙÙۧÙÛ
ۯۧ۱ۧÙŰÚ©ÙÙ
ŰȘ', '', 'IS',
'state', 1),
(2803, 'state_____________________2803', 'ŰąŰČۧۯ
Ú©ŰŽÙ
Û۱', 'ŰąŰČۧۯ Ú©ŰŽÙ
Û۱', '',
'JK', 'state', 1),
(2804, 'state______________________________2804',
'ŰŽÙ
ۧÙÛ ŰčÙۧÙÛ ŰŹŰ§ŰȘ', 'ŰŽÙ
ۧÙÛ ŰčÙۧÙÛ
ۏۧŰȘ', '', 'NA', 'state', 1),
(2805, 'state_________________________________________2805',
'ŰŽÙ
Ű§Ù Ù
ŰșŰ±ŰšÛ ŰłŰ±ŰŰŻÛ Ű”ÙŰšÛ', 'ŰŽÙ
ۧÙ
Ù
ŰșŰ±ŰšÛ ŰłŰ±ŰŰŻÛ Ű”ÙŰšÛ', '', 'NW',
'state', 1),
(2806, 'state____________2806', 'ÙŸÙۏۧۚ',
'ÙŸÙۏۧۚ', '', 'PB', 'state',
1),
(2807, 'state__________2807', 'ŰłÙŰŻÚŸ',
'ŰłÙŰŻÚŸ', '', 'SD', 'state', 1),
(2808, 'state___________________________________________2808',
'ÙÙۧÙÛ ÙۚۧۊÙÛ ŰčÙۧÙÛ ŰŹŰ§ŰȘ', 'ÙÙۧÙÛ
ÙۚۧۊÙÛ ŰčÙۧÙÛ ŰŹŰ§ŰȘ', '', 'TA',
'state', 1),
(2809, 'state_Aimeliik_2809', 'Aimeliik',
'Aimeliik', '', 'AM', 'state', 1),
(2810, 'state_Airai_2810', 'Airai', 'Airai',
'', 'AR', 'state', 1),
(2811, 'state_Angaur_2811', 'Angaur',
'Angaur', '', 'AN', 'state', 1),
(2812, 'state_Hatohobei_2812', 'Hatohobei',
'Hatohobei', '', 'HA', 'state',
1),
(2813, 'state_Kayangel_2813', 'Kayangel',
'Kayangel', '', 'KA', 'state', 1),
(2814, 'state_Koror_2814', 'Koror', 'Koror',
'', 'KO', 'state', 1),
(2815, 'state_Melekeok_2815', 'Melekeok',
'Melekeok', '', 'ME', 'state', 1),
(2816, 'state_Ngaraard_2816', 'Ngaraard',
'Ngaraard', '', 'NA', 'state', 1),
(2817, 'state_Ngarchelong_2817', 'Ngarchelong',
'Ngarchelong', '', 'NG', 'state',
1),
(2818, 'state_Ngardmau_2818', 'Ngardmau',
'Ngardmau', '', 'ND', 'state', 1),
(2819, 'state_Ngatpang_2819', 'Ngatpang',
'Ngatpang', '', 'NT', 'state', 1),
(2820, 'state_Ngchesar_2820', 'Ngchesar',
'Ngchesar', '', 'NC', 'state', 1),
(2821, 'state_Ngeremlengui_2821', 'Ngeremlengui',
'Ngeremlengui', '', 'NR', 'state',
1),
(2822, 'state_Ngiwal_2822', 'Ngiwal',
'Ngiwal', '', 'NW', 'state', 1),
(2823, 'state_Peleliu_2823', 'Peleliu',
'Peleliu', '', 'PE', 'state', 1),
(2824, 'state_Sonsorol_2824', 'Sonsorol',
'Sonsorol', '', 'SO', 'state', 1),
(2825, 'state_Bocas_del_Toro_2825', 'Bocas del Toro',
'Bocas del Toro', '', '1', 'state',
1),
(2826, 'state_Cocl___2826', 'Coclé',
'Coclé', '', '2', 'state', 1),
(2827, 'state_Col__n_2827', 'ColĂłn',
'ColĂłn', '', '3', 'state', 1),
(2828, 'state_Chiriqu___2828', 'ChiriquĂ',
'ChiriquĂ', '', '4', 'state', 1),
(2829, 'state_Dari__n_2829', 'Darién',
'Darién', '', '5', 'state', 1),
(2830, 'state_Herrera_2830', 'Herrera',
'Herrera', '', '6', 'state', 1),
(2831, 'state_Los_Santos_2831', 'Los Santos', 'Los
Santos', '', '7', 'state', 1),
(2832, 'state_Panam___2832', 'PanamĂĄ',
'PanamĂĄ', '', '8', 'state', 1),
(2833, 'state_Veraguas_2833', 'Veraguas',
'Veraguas', '', '9', 'state', 1),
(2834, 'state_Kuna_Yala_2834', 'Kuna Yala', 'Kuna
Yala', '', 'Q', 'state', 1),
(2835, 'state_Chimbu_2835', 'Chimbu',
'Chimbu', '', 'CPK', 'state', 1),
(2836, 'state_Central_2836', 'Central',
'Central', '', 'CPM', 'state', 1),
(2837, 'state_East_New_Britain_2837', 'East New
Britain', 'East New Britain', '', 'EBR',
'state', 1),
(2838, 'state_Eastern_Highlands_2838', 'Eastern
Highlands', 'Eastern Highlands', '',
'EHG', 'state', 1),
(2839, 'state_Enga_2839', 'Enga', 'Enga',
'', 'EPW', 'state', 1),
(2840, 'state_East_Sepik_2840', 'East Sepik',
'East Sepik', '', 'ESW', 'state',
1),
(2841, 'state_Gulf_2841', 'Gulf', 'Gulf',
'', 'GPK', 'state', 1),
(2842, 'state_Milne_Bay_2842', 'Milne Bay', 'Milne
Bay', '', 'MBA', 'state', 1),
(2843, 'state_Morobe_2843', 'Morobe',
'Morobe', '', 'MPL', 'state', 1),
(2844, 'state_Madang_2844', 'Madang',
'Madang', '', 'MPM', 'state', 1),
(2845, 'state_Manus_2845', 'Manus', 'Manus',
'', 'MRL', 'state', 1),
(2846, 'state_National_Capital_District_2846', 'National
Capital District', 'National Capital District',
'', 'NCD', 'state', 1),
(2847, 'state_New_Ireland_2847', 'New Ireland',
'New Ireland', '', 'NIK', 'state',
1),
(2848, 'state_Northern_2848', 'Northern',
'Northern', '', 'NPP', 'state',
1),
(2849, 'state_North_Solomons_2849', 'North Solomons',
'North Solomons', '', 'NSA',
'state', 1),
(2850, 'state_Sandaun_2850', 'Sandaun',
'Sandaun', '', 'SAN', 'state', 1),
(2851, 'state_Southern_Highlands_2851', 'Southern
Highlands', 'Southern Highlands', '',
'SHM', 'state', 1),
(2852, 'state_West_New_Britain_2852', 'West New
Britain', 'West New Britain', '', 'WBK',
'state', 1),
(2853, 'state_Western_Highlands_2853', 'Western
Highlands', 'Western Highlands', '',
'WHM', 'state', 1),
(2854, 'state_Western_2854', 'Western',
'Western', '', 'WPD', 'state', 1),
(2855, 'state_Concepci__n_2855', 'ConcepciĂłn',
'ConcepciĂłn', '', '1', 'state',
1),
(2856, 'state_San_Pedro_2856', 'San Pedro', 'San
Pedro', '', '2', 'state', 1),
(2857, 'state_Cordillera_2857', 'Cordillera',
'Cordillera', '', '3', 'state',
1),
(2858, 'state_Guair___2858', 'GuairĂĄ',
'GuairĂĄ', '', '4', 'state', 1),
(2859, 'state_Caaguaz___2859', 'CaaguazĂș',
'CaaguazĂș', '', '5', 'state', 1),
(2860, 'state_Caazap___2860', 'CaazapĂĄ',
'CaazapĂĄ', '', '6', 'state', 1),
(2861, 'state_Itap__a_2861', 'ItapĂșa',
'ItapĂșa', '', '7', 'state', 1),
(2862, 'state_Misiones_2862', 'Misiones',
'Misiones', '', '8', 'state', 1),
(2863, 'state_Paraguar___2863', 'ParaguarĂ',
'ParaguarĂ', '', '9', 'state',
1),
(2864, 'state_Alto_Paran___2864', 'Alto ParanĂĄ',
'Alto ParanĂĄ', '', '10', 'state',
1),
(2865, 'state_Central_2865', 'Central',
'Central', '', '11', 'state', 1),
(2866, 'state___eembuc___2866', 'ĂeembucĂș',
'ĂeembucĂș', '', '12', 'state',
1),
(2867, 'state_Amambay_2867', 'Amambay',
'Amambay', '', '13', 'state', 1),
(2868, 'state_Canindey___2868', 'CanindeyĂș',
'CanindeyĂș', '', '14', 'state',
1),
(2869, 'state_Presidente_Hayes_2869', 'Presidente
Hayes', 'Presidente Hayes', '', '15',
'state', 1),
(2870, 'state_Alto_Paraguay_2870', 'Alto Paraguay',
'Alto Paraguay', '', '16', 'state',
1),
(2871, 'state_Boquer__n_2871', 'BoquerĂłn',
'BoquerĂłn', '', '19', 'state',
1),
(2872, 'state_Asunci__n_2872', 'AsunciĂłn',
'AsunciĂłn', '', 'ASU', 'state',
1),
(2874, 'state_Ancash_2874', 'Ancash',
'Ancash', '', 'ANC', 'state', 1),
(2875, 'state_Apur__mac_2875', 'ApurĂmac',
'ApurĂmac', '', 'APU', 'state',
1),
(2876, 'state_Arequipa_2876', 'Arequipa',
'Arequipa', '', 'ARE', 'state',
1),
(2877, 'state_Ayacucho_2877', 'Ayacucho',
'Ayacucho', '', 'AYA', 'state',
1),
(2878, 'state_Cajamarca_2878', 'Cajamarca',
'Cajamarca', '', 'CAJ', 'state',
1),
(2879, 'state_Callao_2879', 'Callao',
'Callao', '', 'CAL', 'state', 1),
(2880, 'state_Cuzco_2880', 'Cuzco', 'Cuzco',
'', 'CUS', 'state', 1),
(2881, 'state_Hu__nuco_2881', 'HuĂĄnuco',
'HuĂĄnuco', '', 'HUC', 'state',
1),
(2882, 'state_Huancavelica_2882', 'Huancavelica',
'Huancavelica', '', 'HUV', 'state',
1),
(2883, 'state_Ica_2883', 'Ica', 'Ica',
'', 'ICA', 'state', 1),
(2884, 'state_Jun__n_2884', 'JunĂn',
'JunĂn', '', 'JUN', 'state', 1),
(2885, 'state_La_Libertad_2885', 'La Libertad',
'La Libertad', '', 'LAL', 'state',
1),
(2886, 'state_Lambayeque_2886', 'Lambayeque',
'Lambayeque', '', 'LAM', 'state',
1),
(2887, 'state_Lima_2887', 'Lima', 'Lima',
'', 'LIM', 'state', 1),
(2888, 'state_Loreto_2888', 'Loreto',
'Loreto', '', 'LOR', 'state', 1),
(2889, 'state_Madre_de_Dios_2889', 'Madre de Dios',
'Madre de Dios', '', 'MDD',
'state', 1),
(2890, 'state_Moquegua_2890', 'Moquegua',
'Moquegua', '', 'MOQ', 'state',
1),
(2891, 'state_Pasco_2891', 'Pasco', 'Pasco',
'', 'PAS', 'state', 1),
(2892, 'state_Piura_2892', 'Piura', 'Piura',
'', 'PIU', 'state', 1),
(2893, 'state_Puno_2893', 'Puno', 'Puno',
'', 'PUN', 'state', 1),
(2894, 'state_San_Mart__n_2894', 'San MartĂn',
'San MartĂn', '', 'SAM', 'state',
1),
(2895, 'state_Tacna_2895', 'Tacna', 'Tacna',
'', 'TAC', 'state', 1),
(2896, 'state_Tumbes_2896', 'Tumbes',
'Tumbes', '', 'TUM', 'state', 1),
(2897, 'state_Ucayali_2897', 'Ucayali',
'Ucayali', '', 'UCA', 'state', 1),
(2898, 'state_Abra_2898', 'Abra', 'Abra',
'', 'ABR', 'state', 1),
(2899, 'state_Agusan_del_Norte_2899', 'Agusan del
Norte', 'Agusan del Norte', '', 'AGN',
'state', 1),
(2900, 'state_Agusan_del_Sur_2900', 'Agusan del Sur',
'Agusan del Sur', '', 'AGS',
'state', 1),
(2901, 'state_Aklan_2901', 'Aklan', 'Aklan',
'', 'AKL', 'state', 1),
(2902, 'state_Albay_2902', 'Albay', 'Albay',
'', 'ALB', 'state', 1),
(2903, 'state_Antique_2903', 'Antique',
'Antique', '', 'ANT', 'state', 1),
(2904, 'state_Apayao_2904', 'Apayao',
'Apayao', '', 'APA', 'state', 1),
(2905, 'state_Aurora_2905', 'Aurora',
'Aurora', '', 'AUR', 'state', 1),
(2906, 'state_Bataan_2906', 'Bataan',
'Bataan', '', 'BAN', 'state', 1),
(2907, 'state_Basilan_2907', 'Basilan',
'Basilan', '', 'BAS', 'state', 1),
(2908, 'state_Benguet_2908', 'Benguet',
'Benguet', '', 'BEN', 'state', 1),
(2909, 'state_Biliran_2909', 'Biliran',
'Biliran', '', 'BIL', 'state', 1),
(2910, 'state_Bohol_2910', 'Bohol', 'Bohol',
'', 'BOH', 'state', 1),
(2911, 'state_Batangas_2911', 'Batangas',
'Batangas', '', 'BTG', 'state',
1),
(2912, 'state_Batanes_2912', 'Batanes',
'Batanes', '', 'BTN', 'state', 1),
(2913, 'state_Bukidnon_2913', 'Bukidnon',
'Bukidnon', '', 'BUK', 'state',
1),
(2914, 'state_Bulacan_2914', 'Bulacan',
'Bulacan', '', 'BUL', 'state', 1),
(2915, 'state_Cagayan_2915', 'Cagayan',
'Cagayan', '', 'CAG', 'state', 1),
(2916, 'state_Camiguin_2916', 'Camiguin',
'Camiguin', '', 'CAM', 'state',
1),
(2917, 'state_Camarines_Norte_2917', 'Camarines Norte',
'Camarines Norte', '', 'CAN',
'state', 1),
(2918, 'state_Capiz_2918', 'Capiz', 'Capiz',
'', 'CAP', 'state', 1),
(2919, 'state_Camarines_Sur_2919', 'Camarines Sur',
'Camarines Sur', '', 'CAS',
'state', 1),
(2920, 'state_Catanduanes_2920', 'Catanduanes',
'Catanduanes', '', 'CAT', 'state',
1),
(2921, 'state_Cavite_2921', 'Cavite',
'Cavite', '', 'CAV', 'state', 1),
(2922, 'state_Cebu_2922', 'Cebu', 'Cebu',
'', 'CEB', 'state', 1),
(2923, 'state_Compostela_Valley_2923', 'Compostela
Valley', 'Compostela Valley', '', 'COM',
'state', 1),
(2924, 'state_Davao_Oriental_2924', 'Davao Oriental',
'Davao Oriental', '', 'DAO',
'state', 1),
(2925, 'state_Davao_del_Sur_2925', 'Davao del Sur',
'Davao del Sur', '', 'DAS',
'state', 1),
(2926, 'state_Davao_del_Norte_2926', 'Davao del Norte',
'Davao del Norte', '', 'DAV',
'state', 1),
(2927, 'state_Eastern_Samar_2927', 'Eastern Samar',
'Eastern Samar', '', 'EAS',
'state', 1),
(2928, 'state_Guimaras_2928', 'Guimaras',
'Guimaras', '', 'GUI', 'state',
1),
(2929, 'state_Ifugao_2929', 'Ifugao',
'Ifugao', '', 'IFU', 'state', 1),
(2930, 'state_Iloilo_2930', 'Iloilo',
'Iloilo', '', 'ILI', 'state', 1),
(2931, 'state_Ilocos_Norte_2931', 'Ilocos Norte',
'Ilocos Norte', '', 'ILN', 'state',
1),
(2932, 'state_Ilocos_Sur_2932', 'Ilocos Sur',
'Ilocos Sur', '', 'ILS', 'state',
1),
(2933, 'state_Isabela_2933', 'Isabela',
'Isabela', '', 'ISA', 'state', 1),
(2934, 'state_Kalinga_2934', 'Kalinga',
'Kalinga', '', 'KAL', 'state', 1),
(2935, 'state_Laguna_2935', 'Laguna',
'Laguna', '', 'LAG', 'state', 1),
(2936, 'state_Lanao_del_Norte_2936', 'Lanao del Norte',
'Lanao del Norte', '', 'LAN',
'state', 1),
(2937, 'state_Lanao_del_Sur_2937', 'Lanao del Sur',
'Lanao del Sur', '', 'LAS',
'state', 1),
(2938, 'state_Leyte_2938', 'Leyte', 'Leyte',
'', 'LEY', 'state', 1),
(2939, 'state_La_Union_2939', 'La Union', 'La
Union', '', 'LUN', 'state', 1),
(2940, 'state_Marinduque_2940', 'Marinduque',
'Marinduque', '', 'MAD', 'state',
1),
(2941, 'state_Maguindanao_2941', 'Maguindanao',
'Maguindanao', '', 'MAG', 'state',
1),
(2942, 'state_Masbate_2942', 'Masbate',
'Masbate', '', 'MAS', 'state', 1),
(2943, 'state_Mindoro_Occidental_2943', 'Mindoro
Occidental', 'Mindoro Occidental', '',
'MDC', 'state', 1),
(2944, 'state_Mindoro_Oriental_2944', 'Mindoro
Oriental', 'Mindoro Oriental', '',
'MDR', 'state', 1),
(2945, 'state_Mountain_Province_2945', 'Mountain
Province', 'Mountain Province', '',
'MOU', 'state', 1),
(2946, 'state_Misamis_Occidental_2946', 'Misamis
Occidental', 'Misamis Occidental', '',
'MSC', 'state', 1),
(2947, 'state_Misamis_Oriental_2947', 'Misamis
Oriental', 'Misamis Oriental', '',
'MSR', 'state', 1),
(2948, 'state_Cotabato_2948', 'Cotabato',
'Cotabato', '', 'NCO', 'state',
1),
(2949, 'state_Northern_Samar_2949', 'Northern Samar',
'Northern Samar', '', 'NSA',
'state', 1),
(2950, 'state_Negros_Occidental_2950', 'Negros
Occidental', 'Negros Occidental', '',
'NEC', 'state', 1),
(2951, 'state_Negros_Oriental_2951', 'Negros Oriental',
'Negros Oriental', '', 'NER',
'state', 1),
(2952, 'state_Nueva_Ecija_2952', 'Nueva Ecija',
'Nueva Ecija', '', 'NUE', 'state',
1),
(2953, 'state_Nueva_Vizcaya_2953', 'Nueva Vizcaya',
'Nueva Vizcaya', '', 'NUV',
'state', 1),
(2954, 'state_Pampanga_2954', 'Pampanga',
'Pampanga', '', 'PAM', 'state',
1),
(2955, 'state_Pangasinan_2955', 'Pangasinan',
'Pangasinan', '', 'PAN', 'state',
1),
(2956, 'state_Palawan_2956', 'Palawan',
'Palawan', '', 'PLW', 'state', 1),
(2957, 'state_Quezon_2957', 'Quezon',
'Quezon', '', 'QUE', 'state', 1),
(2958, 'state_Quirino_2958', 'Quirino',
'Quirino', '', 'QUI', 'state', 1),
(2959, 'state_Rizal_2959', 'Rizal', 'Rizal',
'', 'RIZ', 'state', 1),
(2960, 'state_Romblon_2960', 'Romblon',
'Romblon', '', 'ROM', 'state', 1),
(2961, 'state_Sarangani_2961', 'Sarangani',
'Sarangani', '', 'SAR', 'state',
1),
(2962, 'state_South_Cotabato_2962', 'South Cotabato',
'South Cotabato', '', 'SCO',
'state', 1),
(2963, 'state_Siquijor_2963', 'Siquijor',
'Siquijor', '', 'SIG', 'state',
1),
(2964, 'state_Southern_Leyte_2964', 'Southern Leyte',
'Southern Leyte', '', 'SLE',
'state', 1),
(2965, 'state_Sulu_2965', 'Sulu', 'Sulu',
'', 'SLU', 'state', 1),
(2966, 'state_Sorsogon_2966', 'Sorsogon',
'Sorsogon', '', 'SOR', 'state',
1),
(2967, 'state_Sultan_Kudarat_2967', 'Sultan Kudarat',
'Sultan Kudarat', '', 'SUK',
'state', 1),
(2968, 'state_Surigao_del_Norte_2968', 'Surigao del
Norte', 'Surigao del Norte', '', 'SUN',
'state', 1),
(2969, 'state_Surigao_del_Sur_2969', 'Surigao del Sur',
'Surigao del Sur', '', 'SUR',
'state', 1),
(2970, 'state_Tarlac_2970', 'Tarlac',
'Tarlac', '', 'TAR', 'state', 1),
(2971, 'state_Tawi_Tawi_2971', 'Tawi-Tawi',
'Tawi-Tawi', '', 'TAW', 'state',
1),
(2972, 'state_Samar_2972', 'Samar', 'Samar',
'', 'WSA', 'state', 1),
(2973, 'state_Zamboanga_del_Norte_2973', 'Zamboanga del
Norte', 'Zamboanga del Norte', '',
'ZAN', 'state', 1),
(2974, 'state_Zamboanga_del_Sur_2974', 'Zamboanga del
Sur', 'Zamboanga del Sur', '', 'ZAS',
'state', 1),
(2975, 'state_Zambales_2975', 'Zambales',
'Zambales', '', 'ZMB', 'state',
1),
(2976, 'state_Zamboanga_Sibugay_2976', 'Zamboanga
Sibugay', 'Zamboanga Sibugay', '',
'ZSI', 'state', 1),
(2977, 'state_Dolno__l__skie_2977', 'DolnoĆlÄ
skie',
'DolnoĆlÄ
skie', '', 'DS',
'state', 1),
(2978, 'state_Kujawsko_Pomorskie_2978',
'Kujawsko-Pomorskie', 'Kujawsko-Pomorskie',
'', 'KP', 'state', 1),
(2979, 'state_Lubelskie_2979', 'Lubelskie',
'Lubelskie', '', 'LU', 'state',
1),
(2980, 'state_Lubuskie_2980', 'Lubuskie',
'Lubuskie', '', 'LB', 'state', 1),
(2981, 'state_____dzkie_2981', 'ĆĂłdzkie',
'ĆĂłdzkie', '', 'LD', 'state',
1),
(2982, 'state_Ma__opolskie_2982', 'MaĆopolskie',
'MaĆopolskie', '', 'MA', 'state',
1),
(2983, 'state_Mazowieckie_2983', 'Mazowieckie',
'Mazowieckie', '', 'MZ', 'state',
1),
(2984, 'state_Opolskie_2984', 'Opolskie',
'Opolskie', '', 'OP', 'state', 1),
(2985, 'state_Podkarpackie_2985', 'Podkarpackie',
'Podkarpackie', '', 'PK', 'state',
1),
(2986, 'state_Podlaskie_2986', 'Podlaskie',
'Podlaskie', '', 'PD', 'state',
1),
(2987, 'state_Pomorskie_2987', 'Pomorskie',
'Pomorskie', '', 'PM', 'state',
1),
(2988, 'state___l__skie_2988', 'ĆlÄ
skie',
'ĆlÄ
skie', '', 'SL', 'state',
1),
(2989, 'state___wi__tokrzyskie_2989',
'ĆwiÄtokrzyskie', 'ĆwiÄtokrzyskie', '',
'SK', 'state', 1),
(2990, 'state_Warmi__sko_Mazurskie_2990',
'WarmiĆsko-Mazurskie', 'WarmiĆsko-Mazurskie',
'', 'WN', 'state', 1),
(2991, 'state_Wielkopolskie_2991', 'Wielkopolskie',
'Wielkopolskie', '', 'WP', 'state',
1),
(2992, 'state_Zachodniopomorskie_2992',
'Zachodniopomorskie', 'Zachodniopomorskie',
'', 'ZP', 'state', 1),
(2993, 'state_Aveiro_2993', 'Aveiro',
'Aveiro', '', '01', 'state', 1),
(2994, 'state_Beja_2994', 'Beja', 'Beja',
'', '02', 'state', 1),
(2995, 'state_Braga_2995', 'Braga', 'Braga',
'', '03', 'state', 1),
(2996, 'state_Bragan__a_2996', 'Bragança',
'Bragança', '', '04', 'state',
1),
(2997, 'state_Castelo_Branco_2997', 'Castelo Branco',
'Castelo Branco', '', '05',
'state', 1),
(2998, 'state_Coimbra_2998', 'Coimbra',
'Coimbra', '', '06', 'state', 1),
(2999, 'state___vora_2999', 'Ăvora',
'Ăvora', '', '07', 'state',
1);";
$this->db->setQuery($query);
$this->db->query();
$query="
INSERT IGNORE INTO `#__hikashop_zone` (`zone_id`, `zone_namekey`,
`zone_name`, `zone_name_english`, `zone_code_2`, `zone_code_3`,
`zone_type`, `zone_published`) VALUES
(3000, 'state_Faro_3000', 'Faro', 'Faro',
'', '08', 'state', 1),
(3001, 'state_Guarda_3001', 'Guarda',
'Guarda', '', '09', 'state', 1),
(3002, 'state_Leiria_3002', 'Leiria',
'Leiria', '', '10', 'state', 1),
(3003, 'state_Lisboa_3003', 'Lisboa',
'Lisboa', '', '11', 'state', 1),
(3004, 'state_Portalegre_3004', 'Portalegre',
'Portalegre', '', '12', 'state',
1),
(3005, 'state_Porto_3005', 'Porto', 'Porto',
'', '13', 'state', 1),
(3006, 'state_Santar__m_3006', 'Santarém',
'Santarém', '', '14', 'state',
1),
(3007, 'state_Set__bal_3007', 'SetĂșbal',
'SetĂșbal', '', '15', 'state', 1),
(3008, 'state_Viana_do_Castelo_3008', 'Viana do
Castelo', 'Viana do Castelo', '', '16',
'state', 1),
(3009, 'state_Vila_Real_3009', 'Vila Real', 'Vila
Real', '', '17', 'state', 1),
(3010, 'state_Viseu_3010', 'Viseu', 'Viseu',
'', '18', 'state', 1),
(3011, 'state_Regi__o_Aut__noma_dos_A__ores_3011', 'RegiĂŁo
Autónoma dos Açores', 'Região Autónoma dos Açores',
'', '20', 'state', 1),
(3012, 'state_Regi__o_Aut__noma_da_Madeira_3012', 'RegiĂŁo
AutĂłnoma da Madeira', 'RegiĂŁo AutĂłnoma da Madeira',
'', '30', 'state', 1),
(3013, 'state______________3013', 'ۧÙŰŻÙŰŰ©',
'ۧÙŰŻÙŰŰ©', '', 'DA', 'state',
1),
(3014, 'state__________________3014',
'ۧÙŰșÙÙ۱ÙŰ©', 'ۧÙŰșÙÙ۱ÙŰ©', '',
'GH', 'state', 1),
(3015, 'state___________________________3015', 'ۏ۱ÙۧÙ
ۧÙۚۧ۷ÙŰ©', 'ۏ۱ÙŰ§Ù Ű§Ùۚۧ۷ÙŰ©', '',
'JB', 'state', 1),
(3016, 'state__________________3016',
'ۧÙŰŹÙ
ÙÙÙŰ©', 'ۧÙŰŹÙ
ÙÙÙŰ©', '',
'JU', 'state', 1),
(3017, 'state____________3017', 'ۧÙŰźÙ۱',
'ۧÙŰźÙ۱', '', 'KH', 'state',
1),
(3018, 'state______________3018', 'Ù
ŰłÙŰčÙŰŻ',
'Ù
ŰłÙŰčÙŰŻ', '', 'ME', 'state',
1),
(3019, 'state______________3019', 'ۧÙŰŽÙ
ۧÙ',
'ۧÙŰŽÙ
ۧÙ', '', 'MS', 'state',
1),
(3020, 'state______________3020', 'ۧÙ۱ÙۧÙ',
'ۧÙ۱ÙۧÙ', '', 'RA', 'state',
1),
(3021, 'state_______________3021', 'ŰŁÙ
Ű”ÙۧÙ',
'ŰŁÙ
Ű”ÙۧÙ', '', 'US', 'state',
1),
(3022, 'state______________3022', 'ۧÙÙÙ۱۩',
'ۧÙÙÙ۱۩', '', 'WA', 'state',
1),
(3023, 'state_Alba_3023', 'Alba', 'Alba',
'', 'AB', 'state', 1),
(3024, 'state_Arge___3024', 'ArgeĆ',
'ArgeĆ', '', 'AG', 'state', 1),
(3025, 'state_Arad_3025', 'Arad', 'Arad',
'', 'AR', 'state', 1),
(3026, 'state_Bucure__ti_3026', 'BucureĆti',
'BucureĆti', '', 'B', 'state',
1),
(3027, 'state_Bac__u_3027', 'BacÄu',
'BacÄu', '', 'BC', 'state', 1),
(3028, 'state_Bihor_3028', 'Bihor', 'Bihor',
'', 'BH', 'state', 1),
(3029, 'state_Bistri__a_N__s__ud_3029',
'BistriĆŁa-NÄsÄud', 'BistriĆŁa-NÄsÄud',
'', 'BN', 'state', 1),
(3030, 'state_Br__ila_3030', 'BrÄila',
'BrÄila', '', 'BR', 'state', 1),
(3031, 'state_Boto__ani_3031', 'BotoĆani',
'BotoĆani', '', 'BT', 'state',
1),
(3032, 'state_Bra__ov_3032', 'BraĆov',
'BraĆov', '', 'BV', 'state', 1),
(3033, 'state_Buz__u_3033', 'BuzÄu',
'BuzÄu', '', 'BZ', 'state', 1),
(3034, 'state_Cluj_3034', 'Cluj', 'Cluj',
'', 'CJ', 'state', 1),
(3035, 'state_C__l__ra__i_3035', 'CÄlÄraĆi',
'CÄlÄraĆi', '', 'CL', 'state',
1),
(3036, 'state_Cara___Severin_3036', 'CaraĆ-Severin',
'CaraĆ-Severin', '', 'CS',
'state', 1),
(3037, 'state_Constan__a_3037', 'ConstanĆŁa',
'ConstanĆŁa', '', 'CT', 'state',
1),
(3038, 'state_Covasna_3038', 'Covasna',
'Covasna', '', 'CV', 'state', 1),
(3039, 'state_D__mbovi__a_3039', 'DĂąmboviĆŁa',
'DĂąmboviĆŁa', '', 'DB', 'state',
1),
(3040, 'state_Dolj_3040', 'Dolj', 'Dolj',
'', 'DJ', 'state', 1),
(3041, 'state_Gorj_3041', 'Gorj', 'Gorj',
'', 'GJ', 'state', 1),
(3042, 'state_Gala__i_3042', 'GalaĆŁi',
'GalaĆŁi', '', 'GL', 'state', 1),
(3043, 'state_Giurgiu_3043', 'Giurgiu',
'Giurgiu', '', 'GR', 'state', 1),
(3044, 'state_Hunedoara_3044', 'Hunedoara',
'Hunedoara', '', 'HD', 'state',
1),
(3045, 'state_Harghita_3045', 'Harghita',
'Harghita', '', 'HG', 'state', 1),
(3046, 'state_Ilfov_3046', 'Ilfov', 'Ilfov',
'', 'IF', 'state', 1),
(3047, 'state_Ialomi__a_3047', 'IalomiĆŁa',
'IalomiĆŁa', '', 'IL', 'state',
1),
(3048, 'state_Ia__i_3048', 'IaĆi', 'IaĆi',
'', 'IS', 'state', 1),
(3049, 'state_Mehedin__i_3049', 'MehedinĆŁi',
'MehedinĆŁi', '', 'MH', 'state',
1),
(3050, 'state_Maramure___3050', 'MaramureĆ',
'MaramureĆ', '', 'MM', 'state',
1),
(3051, 'state_Mure___3051', 'MureĆ',
'MureĆ', '', 'MS', 'state', 1),
(3052, 'state_Neam___3052', 'NeamĆŁ',
'NeamĆŁ', '', 'NT', 'state', 1),
(3053, 'state_Olt_3053', 'Olt', 'Olt',
'', 'OT', 'state', 1),
(3054, 'state_Prahova_3054', 'Prahova',
'Prahova', '', 'PH', 'state', 1),
(3055, 'state_Sibiu_3055', 'Sibiu', 'Sibiu',
'', 'SB', 'state', 1),
(3056, 'state_S__laj_3056', 'SÄlaj',
'SÄlaj', '', 'SJ', 'state', 1),
(3057, 'state_Satu_Mare_3057', 'Satu Mare', 'Satu
Mare', '', 'SM', 'state', 1),
(3058, 'state_Suceava_3058', 'Suceava',
'Suceava', '', 'SV', 'state', 1),
(3059, 'state_Tulcea_3059', 'Tulcea',
'Tulcea', '', 'TL', 'state', 1),
(3060, 'state_Timi___3060', 'TimiĆ',
'TimiĆ', '', 'TM', 'state', 1),
(3061, 'state_Teleorman_3061', 'Teleorman',
'Teleorman', '', 'TR', 'state',
1),
(3062, 'state_V__lcea_3062', 'VĂąlcea',
'VĂąlcea', '', 'VL', 'state', 1),
(3063, 'state_Vrancea_3063', 'Vrancea',
'Vrancea', '', 'VN', 'state', 1),
(3064, 'state_Vaslui_3064', 'Vaslui',
'Vaslui', '', 'VS', 'state', 1),
(3065, 'state_______________________________________3065',
'ĐĐŽŃĐłĐ”Ń Đ Đ”ŃĐżŃблОĐșа', 'ĐĐŽŃгДŃ
Đ Đ”ŃĐżŃблОĐșа', '', 'AD',
'state', 1),
(3066,
'state_____________________________________________________________________________3066',
'ĐĐłĐžĐœŃĐșĐžĐč-ĐŃŃŃŃŃĐșĐžĐč аĐČŃĐŸĐœĐŸĐŒĐœŃĐč
ĐŸĐșŃŃĐł', 'ĐĐłĐžĐœŃĐșĐžĐč-ĐŃŃŃŃŃĐșĐžĐč
аĐČŃĐŸĐœĐŸĐŒĐœŃĐč ĐŸĐșŃŃĐł', '', 'AGB',
'state', 1),
(3067, 'state_____________________________________3067',
'ĐĐ»ŃаĐč Đ Đ”ŃĐżŃблОĐșа', 'ĐĐ»ŃаĐč
Đ Đ”ŃĐżŃблОĐșа', '', 'AL',
'state', 1),
(3068, 'state_______________________________3068',
'ĐĐ»ŃаĐčŃĐșĐžĐč ĐșŃаĐč', 'ĐĐ»ŃаĐčŃĐșĐžĐč
ĐșŃаĐč', '', 'ALT', 'state', 1),
(3069, 'state_____________________________________3069',
'ĐĐŒŃŃŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐĐŒŃŃŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'AMU', 'state',
1),
(3070,
'state_______________________________________________3070',
'ĐŃŃ
Đ°ĐœĐłĐ”Đ»ŃŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐŃŃ
Đ°ĐœĐłĐ”Đ»ŃŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'ARK', 'state', 1),
(3071, 'state_____________________________________________3071',
'ĐŃŃŃаŃ
Đ°ĐœŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐŃŃŃаŃ
Đ°ĐœŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'AST', 'state', 1),
(3072,
'state___________________________________________________3072',
'ĐаŃĐșĐŸŃŃĐŸŃŃĐ°Đœ Đ Đ”ŃĐżŃблОĐșа',
'ĐаŃĐșĐŸŃŃĐŸŃŃĐ°Đœ Đ Đ”ŃĐżŃблОĐșа', '',
'BA', 'state', 1),
(3073, 'state_____________________________________________3073',
'ĐĐ”Đ»ĐłĐŸŃĐŸĐŽŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐĐ”Đ»ĐłĐŸŃĐŸĐŽŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'BEL', 'state', 1),
(3074, 'state_____________________________________3074',
'ĐŃŃĐœŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐŃŃĐœŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'BRY', 'state',
1),
(3075, 'state_________________________________________3075',
'ĐŃŃŃŃĐžŃ Đ Đ”ŃĐżŃблОĐșа', 'ĐŃŃŃŃĐžŃ
Đ Đ”ŃĐżŃблОĐșа', '', 'BU',
'state', 1),
(3076, 'state_____________________________________________3076',
'ЧДŃĐ”ĐœŃĐșĐ°Ń Đ Đ”ŃĐżŃблОĐșа',
'ЧДŃĐ”ĐœŃĐșĐ°Ń Đ Đ”ŃĐżŃблОĐșа', '',
'CE', 'state', 1),
(3077, 'state___________________________________________3077',
'ЧДлŃĐ±ĐžĐœŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ЧДлŃĐ±ĐžĐœŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'CHE', 'state', 1),
(3078, 'state_______________________________________3078',
'ЧОŃĐžĐœŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ЧОŃĐžĐœŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'CHI', 'state',
1),
(3079,
'state__________________________________________________________3079',
'ЧŃĐșĐŸŃŃĐșĐžĐč аĐČŃĐŸĐœĐŸĐŒĐœŃĐč ĐŸĐșŃŃĐł',
'ЧŃĐșĐŸŃŃĐșĐžĐč аĐČŃĐŸĐœĐŸĐŒĐœŃĐč ĐŸĐșŃŃĐł',
'', 'CHU', 'state', 1),
(3080, 'state_____________________________________________3080',
'ЧŃĐČаŃŃĐșĐ°Ń Đ Đ”ŃĐżŃблОĐșа',
'ЧŃĐČаŃŃĐșĐ°Ń Đ Đ”ŃĐżŃблОĐșа', '',
'CU', 'state', 1),
(3081, 'state___________________________________________3081',
'ĐагДŃŃĐ°Đœ Đ Đ”ŃĐżŃблОĐșа', 'ĐагДŃŃĐ°Đœ
Đ Đ”ŃĐżŃблОĐșа', '', 'DA',
'state', 1),
(3082,
'state______________________________________________________________3082',
'ĐĐČĐ”ĐœĐșĐžĐčŃĐșĐžĐč аĐČŃĐŸĐœĐŸĐŒĐœŃĐč ĐŸĐșŃŃĐł',
'ĐĐČĐ”ĐœĐșĐžĐčŃĐșĐžĐč аĐČŃĐŸĐœĐŸĐŒĐœŃĐč ĐŸĐșŃŃĐł',
'', 'EVE', 'state', 1),
(3083, 'state_____________________________________________3083',
'ĐĐœĐłŃŃĐ”ŃĐžŃ Đ Đ”ŃĐżŃблОĐșа',
'ĐĐœĐłŃŃĐ”ŃĐžŃ Đ Đ”ŃĐżŃблОĐșа', '',
'IN', 'state', 1),
(3084, 'state_______________________________________3084',
'ĐŃĐșŃŃŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐŃĐșŃŃŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'IRK', 'state',
1),
(3085, 'state_________________________________________3085',
'ĐĐČĐ°ĐœĐŸĐČŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐĐČĐ°ĐœĐŸĐČŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'IVA', 'state',
1),
(3086, 'state_________________________________________3086',
'ĐĐ°ĐŒŃаŃŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐĐ°ĐŒŃаŃŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'KAM', 'state',
1),
(3087,
'state____________________________________________________________________3087',
'ĐабаŃĐŽĐžĐœĐŸ-ĐалĐșаŃŃĐșĐ°Ń Đ Đ”ŃĐżŃблОĐșа',
'ĐабаŃĐŽĐžĐœĐŸ-ĐалĐșаŃŃĐșĐ°Ń Đ Đ”ŃĐżŃблОĐșа',
'', 'KB', 'state', 1),
(3088,
'state____________________________________________________________________3088',
'ĐаŃаŃаДĐČĐŸ-ЧДŃĐșĐ”ŃŃĐșĐ°Ń Đ Đ”ŃĐżŃблОĐșа',
'ĐаŃаŃаДĐČĐŸ-ЧДŃĐșĐ”ŃŃĐșĐ°Ń Đ Đ”ŃĐżŃблОĐșа',
'', 'KC', 'state', 1),
(3089, 'state_______________________________________3089',
'ĐŃаŃĐœĐŸĐŽĐ°ŃŃĐșĐžĐč ĐșŃаĐč',
'ĐŃаŃĐœĐŸĐŽĐ°ŃŃĐșĐžĐč ĐșŃаĐč', '',
'KDA', 'state', 1),
(3090, 'state___________________________________________3090',
'ĐĐ”ĐŒĐ”ŃĐŸĐČŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐĐ”ĐŒĐ”ŃĐŸĐČŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'KEM', 'state', 1),
(3091,
'state___________________________________________________3091',
'ĐĐ°Đ»ĐžĐœĐžĐœĐłŃаЎŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐĐ°Đ»ĐžĐœĐžĐœĐłŃаЎŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'KGD', 'state', 1),
(3092, 'state_________________________________________3092',
'ĐŃŃĐłĐ°ĐœŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐŃŃĐłĐ°ĐœŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'KGN', 'state',
1),
(3093, 'state___________________________________3093',
'ЄабаŃĐŸĐČŃĐșĐžĐč ĐșŃаĐč', 'ЄабаŃĐŸĐČŃĐșĐžĐč
ĐșŃаĐč', '', 'KHA', 'state', 1),
(3094,
'state______________________________________________________________________________________3094',
'Đ„Đ°ĐœŃŃ-ĐĐ°ĐœŃĐžĐčŃĐșĐžĐč аĐČŃĐŸĐœĐŸĐŒĐœŃĐč
ĐŸĐșŃŃĐłâПгŃа', 'Đ„Đ°ĐœŃŃ-ĐĐ°ĐœŃĐžĐčŃĐșĐžĐč
аĐČŃĐŸĐœĐŸĐŒĐœŃĐč ĐŸĐșŃŃĐłâПгŃа', '',
'KHM', 'state', 1),
(3095, 'state_____________________________________3095',
'ĐŃаŃĐœĐŸŃŃŃĐșĐžĐč ĐșŃаĐč',
'ĐŃаŃĐœĐŸŃŃŃĐșĐžĐč ĐșŃаĐč', '',
'KIA', 'state', 1),
(3096, 'state_______________________________________3096',
'ĐĐžŃĐŸĐČŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐĐžŃĐŸĐČŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'KIR', 'state',
1),
(3097, 'state__________________3097', 'ЄаĐșаŃĐžŃ',
'ЄаĐșаŃĐžŃ', '', 'KK',
'state', 1),
(3098, 'state___________________________________________3098',
'ĐĐ°Đ»ĐŒŃĐșĐžŃ Đ Đ”ŃĐżŃблОĐșа', 'ĐĐ°Đ»ĐŒŃĐșĐžŃ
Đ Đ”ŃĐżŃблОĐșа', '', 'KL',
'state', 1),
(3099, 'state_______________________________________3099',
'ĐалŃжŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐалŃжŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'KLU', 'state',
1),
(3100, 'state___________________________________3100',
'ĐĐŸĐŒĐž Đ Đ”ŃĐżŃблОĐșа', 'ĐĐŸĐŒĐž
Đ Đ”ŃĐżŃблОĐșа', '', 'KO',
'state', 1),
(3101,
'state__________________________________________________________3101',
'ĐĐŸŃŃĐșŃĐșĐžĐč аĐČŃĐŸĐœĐŸĐŒĐœŃĐč ĐŸĐșŃŃĐł',
'ĐĐŸŃŃĐșŃĐșĐžĐč аĐČŃĐŸĐœĐŸĐŒĐœŃĐč ĐŸĐșŃŃĐł',
'', 'KOR', 'state', 1),
(3102, 'state___________________________________________3102',
'ĐĐŸŃŃŃĐŸĐŒŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐĐŸŃŃŃĐŸĐŒŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'KOS', 'state', 1),
(3103, 'state_________________________________________3103',
'ĐаŃĐ”Đ»ĐžŃ Đ Đ”ŃĐżŃблОĐșа', 'ĐаŃДлОŃ
Đ Đ”ŃĐżŃблОĐșа', '', 'KR',
'state', 1),
(3104, 'state___________________________________3104',
'ĐŃŃŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐŃŃŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'KRS', 'state',
1),
(3105,
'state_______________________________________________3105',
'ĐĐ”ĐœĐžĐœĐłŃаЎŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐĐ”ĐœĐžĐœĐłŃаЎŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'LEN', 'state', 1),
(3106, 'state_____________________________________3106',
'ĐОпДŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐОпДŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'LIP', 'state',
1),
(3107, 'state___________________________________________3107',
'ĐĐ°ĐłĐ°ĐŽĐ°ĐœŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐĐ°ĐłĐ°ĐŽĐ°ĐœŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'MAG', 'state', 1),
(3108, 'state__________________________________________3108',
'ĐаŃĐžĐč ĐĐ» Đ Đ”ŃĐżŃблОĐșа', 'ĐаŃĐžĐč ĐĐ»
Đ Đ”ŃĐżŃблОĐșа', '', 'ME',
'state', 1),
(3109, 'state___________________________________________3109',
'ĐĐŸŃĐŽĐŸĐČĐžŃ Đ Đ”ŃĐżŃблОĐșа', 'ĐĐŸŃĐŽĐŸĐČĐžŃ
Đ Đ”ŃĐżŃблОĐșа', '', 'MO',
'state', 1),
(3110, 'state_________________________________________3110',
'ĐĐŸŃĐșĐŸĐČŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐĐŸŃĐșĐŸĐČŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'MOS', 'state',
1),
(3111, 'state________________3111', 'ĐĐŸŃĐșĐČа',
'ĐĐŸŃĐșĐČа', '', 'MOW', 'state',
1),
(3112, 'state_________________________________________3112',
'ĐŃŃĐŒĐ°ĐœŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐŃŃĐŒĐ°ĐœŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'MUR', 'state',
1),
(3113,
'state________________________________________________________3113',
'ĐĐ”ĐœĐ”ŃĐșĐžĐč аĐČŃĐŸĐœĐŸĐŒĐœŃĐč ĐŸĐșŃŃĐł',
'ĐĐ”ĐœĐ”ŃĐșĐžĐč аĐČŃĐŸĐœĐŸĐŒĐœŃĐč ĐŸĐșŃŃĐł', '',
'NEN', 'state', 1),
(3114, 'state_____________________________________________3114',
'ĐĐŸĐČĐłĐŸŃĐŸĐŽŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐĐŸĐČĐłĐŸŃĐŸĐŽŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'NGR', 'state', 1),
(3115,
'state_______________________________________________3115',
'ĐĐžĐ¶Đ”ĐłĐŸŃĐŸĐŽŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐĐžĐ¶Đ”ĐłĐŸŃĐŸĐŽŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'NIZ', 'state', 1),
(3116,
'state_______________________________________________3116',
'ĐĐŸĐČĐŸŃОбОŃŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐĐŸĐČĐŸŃОбОŃŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'NVS', 'state', 1),
(3117, 'state_________________________________3117',
'ĐĐŒŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐĐŒŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'OMS', 'state',
1),
(3118, 'state_____________________________________________3118',
'ĐŃĐ”ĐœĐ±ŃŃĐłŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐŃĐ”ĐœĐ±ŃŃĐłŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'ORE', 'state', 1),
(3119, 'state_______________________________________3119',
'ĐŃĐ»ĐŸĐČŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐŃĐ»ĐŸĐČŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'ORL', 'state',
1),
(3120, 'state_________________________________________3120',
'ĐĐ”ĐœĐ·Đ”ĐœŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐĐ”ĐœĐ·Đ”ĐœŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'PNZ', 'state',
1),
(3121, 'state_________________________________3121',
'ĐŃĐžĐŒĐŸŃŃĐșĐžĐč ĐșŃаĐč', 'ĐŃĐžĐŒĐŸŃŃĐșĐžĐč
ĐșŃаĐč', '', 'PRI', 'state', 1),
(3122, 'state_______________________________________3122',
'ĐŃĐșĐŸĐČŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐŃĐșĐŸĐČŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'PSK', 'state',
1),
(3123, 'state_________________________________________3123',
'Đ ĐŸŃŃĐŸĐČŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'Đ ĐŸŃŃĐŸĐČŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'ROS', 'state',
1),
(3124, 'state_______________________________________3124',
'Đ ŃĐ·Đ°ĐœŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'Đ ŃĐ·Đ°ĐœŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'RYA', 'state',
1),
(3125,
'state____________________________________________________3125',
'ХаŃ
а (ĐŻĐșŃŃĐžŃ) Đ Đ”ŃĐżŃблОĐșа', 'ХаŃ
а
(ĐŻĐșŃŃĐžŃ) Đ Đ”ŃĐżŃблОĐșа', '', 'SA',
'state', 1),
(3126, 'state___________________________________________3126',
'ХаŃ
Đ°Đ»ĐžĐœŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ХаŃ
Đ°Đ»ĐžĐœŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'SAK', 'state', 1),
(3127, 'state_______________________________________3127',
'ĐĄĐ°ĐŒĐ°ŃŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐĄĐ°ĐŒĐ°ŃŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'SAM', 'state',
1),
(3128, 'state___________________________________________3128',
'ХаŃаŃĐŸĐČŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ХаŃаŃĐŸĐČŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'SAR', 'state', 1),
(3129,
'state___________________________________________________________________________3129',
'ĐĄĐ”ĐČĐ”ŃĐœĐ°Ń ĐŃĐ”ŃĐžŃâĐĐ»Đ°ĐœĐžŃ
Đ Đ”ŃĐżŃблОĐșа', 'ĐĄĐ”ĐČĐ”ŃĐœĐ°Ń
ĐŃĐ”ŃĐžŃâĐĐ»Đ°ĐœĐžŃ Đ Đ”ŃĐżŃблОĐșа', '',
'SE', 'state', 1),
(3130, 'state_________________________________________3130',
'ĐĄĐŒĐŸĐ»Đ”ĐœŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐĄĐŒĐŸĐ»Đ”ĐœŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'SMO', 'state',
1),
(3131, 'state_________________________________3131',
'ĐĄĐ°ĐœĐșŃ-ĐĐ”ŃĐ”ŃбŃŃĐł',
'ĐĄĐ°ĐœĐșŃ-ĐĐ”ŃĐ”ŃбŃŃĐł', '', 'SPE',
'state', 1),
(3132, 'state_________________________________________3132',
'ĐĄŃаĐČŃĐŸĐżĐŸĐ»ŃŃĐșĐžĐč ĐșŃаĐč',
'ĐĄŃаĐČŃĐŸĐżĐŸĐ»ŃŃĐșĐžĐč ĐșŃаĐč', '',
'STA', 'state', 1),
(3133, 'state_____________________________________________3133',
'ĐĄĐČĐ”ŃĐŽĐ»ĐŸĐČŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐĄĐČĐ”ŃĐŽĐ»ĐŸĐČŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'SVE', 'state', 1),
(3134, 'state_____________________________________________3134',
'Đ Đ”ŃĐżŃблОĐșа йаŃаŃŃŃĐ°Đœ',
'Đ Đ”ŃĐżŃблОĐșа йаŃаŃŃŃĐ°Đœ', '',
'TA', 'state', 1),
(3135, 'state_________________________________________3135',
'ĐąĐ°ĐŒĐ±ĐŸĐČŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐąĐ°ĐŒĐ±ĐŸĐČŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'TAM', 'state',
1),
(3136,
'state____________________________________________________________3136',
'йаĐčĐŒŃŃŃĐșĐžĐč аĐČŃĐŸĐœĐŸĐŒĐœŃĐč ĐŸĐșŃŃĐł',
'йаĐčĐŒŃŃŃĐșĐžĐč аĐČŃĐŸĐœĐŸĐŒĐœŃĐč ĐŸĐșŃŃĐł',
'', 'TAY', 'state', 1),
(3137, 'state___________________________________3137',
'ĐąĐŸĐŒŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐąĐŸĐŒŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'TOM', 'state',
1),
(3138, 'state_____________________________________3138',
'ĐąŃĐ»ŃŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐąŃĐ»ŃŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'TUL', 'state',
1),
(3139, 'state_____________________________________3139',
'ĐąĐČĐ”ŃŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐąĐČĐ”ŃŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'TVE', 'state',
1),
(3140, 'state___________________________________3140',
'ĐąŃĐČа Đ Đ”ŃĐżŃблОĐșа', 'ĐąŃĐČа
Đ Đ”ŃĐżŃблОĐșа', '', 'TY',
'state', 1),
(3141, 'state_______________________________________3141',
'ĐąŃĐŒĐ”ĐœŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐąŃĐŒĐ”ĐœŃĐșаŃ
ĐŸĐ±Đ»Đ°ŃŃŃ', '', 'TYU', 'state',
1),
(3142,
'state_______________________________________________3142',
'ĐŁĐŽĐŒŃŃŃŃĐșĐ°Ń Đ Đ”ŃĐżŃблОĐșа',
'ĐŁĐŽĐŒŃŃŃŃĐșĐ°Ń Đ Đ”ŃĐżŃблОĐșа', '',
'UD', 'state', 1),
(3143, 'state___________________________________________3143',
'ĐŁĐ»ŃŃĐœĐŸĐČŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐŁĐ»ŃŃĐœĐŸĐČŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'ULY', 'state', 1),
(3144,
'state________________________________________________________________________________________3144',
'ĐŁŃŃŃ-ĐŃĐŽŃĐœŃĐșĐžĐč ĐŃŃŃŃŃĐșĐžĐč аĐČŃĐŸĐœĐŸĐŒĐœŃĐč
ĐŸĐșŃŃĐł', 'ĐŁŃŃŃ-ĐŃĐŽŃĐœŃĐșĐžĐč ĐŃŃŃŃŃĐșĐžĐč
аĐČŃĐŸĐœĐŸĐŒĐœŃĐč ĐŸĐșŃŃĐł', '', 'UOB',
'state', 1),
(3145,
'state_______________________________________________3145',
'ĐĐŸĐ»ĐłĐŸĐłŃаЎŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐĐŸĐ»ĐłĐŸĐłŃаЎŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'VGG', 'state', 1),
(3146, 'state_____________________________________________3146',
'ĐĐ»Đ°ĐŽĐžĐŒĐžŃŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐĐ»Đ°ĐŽĐžĐŒĐžŃŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'VLA', 'state', 1),
(3147, 'state___________________________________________3147',
'ĐĐŸĐ»ĐŸĐłĐŸĐŽŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐĐŸĐ»ĐŸĐłĐŸĐŽŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'VLG', 'state', 1),
(3148, 'state___________________________________________3148',
'ĐĐŸŃĐŸĐœĐ”Đ¶ŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐĐŸŃĐŸĐœĐ”Đ¶ŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'VOR', 'state', 1),
(3149, 'state_____________________________3149',
'ĐĐ”ŃĐŒŃĐșĐžĐč ĐșŃаĐč', 'ĐĐ”ŃĐŒŃĐșĐžĐč
ĐșŃаĐč', '', 'XXX', 'state', 1),
(3150,
'state_____________________________________________________________________3150',
'ĐŻĐŒĐ°Đ»ĐŸ-ĐĐ”ĐœĐ”ŃĐșĐžĐč аĐČŃĐŸĐœĐŸĐŒĐœŃĐč ĐŸĐșŃŃĐł',
'ĐŻĐŒĐ°Đ»ĐŸ-ĐĐ”ĐœĐ”ŃĐșĐžĐč аĐČŃĐŸĐœĐŸĐŒĐœŃĐč ĐŸĐșŃŃĐł',
'', 'YAN', 'state', 1),
(3151, 'state___________________________________________3151',
'ĐŻŃĐŸŃлаĐČŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐŻŃĐŸŃлаĐČŃĐșĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'YAR', 'state', 1),
(3152,
'state______________________________________________________________3152',
'ĐĐČŃĐ”ĐčŃĐșĐ°Ń Đ°ĐČŃĐŸĐœĐŸĐŒĐœĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐĐČŃĐ”ĐčŃĐșĐ°Ń Đ°ĐČŃĐŸĐœĐŸĐŒĐœĐ°Ń ĐŸĐ±Đ»Đ°ŃŃŃ',
'', 'YEV', 'state', 1),
(3153, 'state_Nord_3153', 'Nord', 'Nord',
'', 'N', 'state', 1),
(3154, 'state_Est_3154', 'Est', 'Est',
'', 'E', 'state', 1),
(3155, 'state_Sud_3155', 'Sud', 'Sud',
'', 'S', 'state', 1),
(3156, 'state_Ouest_3156', 'Ouest', 'Ouest',
'', 'O', 'state', 1),
(3157, 'state_Kigali_3157', 'Kigali',
'Kigali', '', 'K', 'state', 1),
(3158, 'state_Saint_Kitts_3158', 'Saint Kitts',
'Saint Kitts', '', 'K', 'state',
1),
(3159, 'state_Nevis_3159', 'Nevis', 'Nevis',
'', 'N', 'state', 1),
(3160, 'state_Anse_la_Raye_3160', 'Anse-la-Raye',
'Anse-la-Raye', '', 'AR', 'state',
1),
(3161, 'state_Castries_3161', 'Castries',
'Castries', '', 'CA', 'state', 1),
(3162, 'state_Choiseul_3162', 'Choiseul',
'Choiseul', '', 'CH', 'state', 1),
(3163, 'state_Dauphin_3163', 'Dauphin',
'Dauphin', '', 'DA', 'state', 1),
(3164, 'state_Dennery_3164', 'Dennery',
'Dennery', '', 'DE', 'state', 1),
(3165, 'state_Gros_Islet_3165', 'Gros-Islet',
'Gros-Islet', '', 'GI', 'state',
1),
(3166, 'state_Laborie_3166', 'Laborie',
'Laborie', '', 'LA', 'state', 1),
(3167, 'state_Micoud_3167', 'Micoud',
'Micoud', '', 'MI', 'state', 1),
(3168, 'state_Praslin_3168', 'Praslin',
'Praslin', '', 'PR', 'state', 1),
(3169, 'state_Soufriere_3169', 'Soufriere',
'Soufriere', '', 'SO', 'state',
1),
(3170, 'state_Vieux_Fort_3170', 'Vieux-Fort',
'Vieux-Fort', '', 'VF', 'state',
1),
(3171, 'state_Charlotte_3171', 'Charlotte',
'Charlotte', '', 'C', 'state', 1),
(3172, 'state_Grenadines_3172', 'Grenadines',
'Grenadines', '', 'R', 'state',
1),
(3177, 'state_A_ana_3177', 'A''ana',
'A''ana', '', 'AA',
'state', 1),
(3178, 'state_Aiga_i_le_Tai_3178', 'Aiga-i-le-Tai',
'Aiga-i-le-Tai', '', 'AL', 'state',
1),
(3179, 'state_Atua_3179', 'Atua', 'Atua',
'', 'AT', 'state', 1),
(3180, 'state_Fa_asaleleaga_3180',
'Fa''asaleleaga', 'Fa''asaleleaga',
'', 'FA', 'state', 1),
(3181, 'state_Gaga_emauga_3181',
'Gaga''emauga', 'Gaga''emauga',
'', 'GE', 'state', 1),
(3182, 'state_Gaga_ifomauga_3182',
'Gaga''ifomauga', 'Gaga''ifomauga',
'', 'GI', 'state', 1),
(3183, 'state_Palauli_3183', 'Palauli',
'Palauli', '', 'PA', 'state', 1),
(3184, 'state_Satupa_itea_3184',
'Satupa''itea', 'Satupa''itea',
'', 'SA', 'state', 1),
(3185, 'state_Tuamasaga_3185', 'Tuamasaga',
'Tuamasaga', '', 'TU', 'state',
1),
(3186, 'state_Va_a_o_Fonoti_3186',
'Va''a-o-Fonoti', 'Va''a-o-Fonoti',
'', 'VF', 'state', 1),
(3187, 'state_Vaisigano_3187', 'Vaisigano',
'Vaisigano', '', 'VS', 'state',
1),
(3188, 'state_Acquaviva_3188', 'Acquaviva',
'Acquaviva', '', 'AC', 'state',
1),
(3189, 'state_Borgo_Maggiore_3189', 'Borgo Maggiore',
'Borgo Maggiore', '', 'BM',
'state', 1),
(3190, 'state_Chiesanuova_3190', 'Chiesanuova',
'Chiesanuova', '', 'CH', 'state',
1),
(3191, 'state_Domagnano_3191', 'Domagnano',
'Domagnano', '', 'DO', 'state',
1),
(3192, 'state_Faetano_3192', 'Faetano',
'Faetano', '', 'FA', 'state', 1),
(3193, 'state_Fiorentino_3193', 'Fiorentino',
'Fiorentino', '', 'FI', 'state',
1),
(3194, 'state_Montegiardino_3194', 'Montegiardino',
'Montegiardino', '', 'MO', 'state',
1),
(3195, 'state_Citta_di_San_Marino_3195', 'Citta di San
Marino', 'Citta di San Marino', '',
'SM', 'state', 1),
(3196, 'state_Serravalle_3196', 'Serravalle',
'Serravalle', '', 'SE', 'state',
1),
(3197, 'state_Pr__ncipe_3197', 'PrĂncipe',
'PrĂncipe', '', 'P', 'state', 1),
(3198, 'state_S__o_Tom___3198', 'São Tomé',
'São Tomé', '', 'S', 'state',
1),
(3199, 'state______________3199', 'ۧÙ۱Ùۧ۶',
'ۧÙ۱Ùۧ۶', '', '01', 'state',
1),
(3200, 'state_______________________3200', 'Ù
ÙŰ©
ۧÙÙ
Ù۱Ù
Ű©', 'Ù
ÙŰ© ۧÙÙ
Ù۱Ù
Ű©', '',
'02', 'state', 1),
(3201, 'state________________3201', 'ۧÙÙ
ŰŻÙÙÙ',
'ۧÙÙ
ŰŻÙÙÙ', '', '03',
'state', 1),
(3202, 'state________________3202', 'ۧÙێ۱ÙÙŰ©',
'ۧÙێ۱ÙÙŰ©', '', '04',
'state', 1),
(3203, 'state______________3203', 'ۧÙÙŰ”ÙÙ
',
'ۧÙÙŰ”ÙÙ
', '', '05', 'state',
1),
(3204, 'state__________3204', 'ŰۧۊÙ',
'ŰۧۊÙ', '', '06', 'state', 1),
(3205, 'state__________3205', 'ŰȘŰšÙÙ',
'ŰȘŰšÙÙ', '', '07', 'state', 1),
(3206, 'state_______________________________3206',
'ۧÙŰŰŻÙŰŻ ۧÙŰŽÙ
ۧÙÙŰ©', 'ۧÙŰŰŻÙŰŻ
ۧÙŰŽÙ
ۧÙÙŰ©', '', '08', 'state',
1),
(3207, 'state____________3207', 'ŰŹÙŰČۧÙ',
'ŰŹÙŰČۧÙ', '', '09', 'state',
1),
(3208, 'state____________3208', 'Ùۏ۱ۧÙ',
'Ùۏ۱ۧÙ', '', '10', 'state',
1),
(3209, 'state______________3209', 'ۧÙۚۧŰŰ©',
'ۧÙۚۧŰŰ©', '', '11', 'state',
1),
(3210, 'state____________3210', 'ۧÙŰŹÙÙ',
'ۧÙŰŹÙÙ', '', '12', 'state',
1),
(3211, 'state__________3211', 'ŰčŰłÙ۱',
'ŰčŰłÙ۱', '', '14', 'state', 1),
(3212, 'state_Dakar_3212', 'Dakar', 'Dakar',
'', 'DA', 'state', 1),
(3213, 'state_Diourbel_3213', 'Diourbel',
'Diourbel', '', 'DI', 'state', 1),
(3214, 'state_Fatick_3214', 'Fatick',
'Fatick', '', 'FA', 'state', 1),
(3215, 'state_Kaolack_3215', 'Kaolack',
'Kaolack', '', 'KA', 'state', 1),
(3216, 'state_Kolda_3216', 'Kolda', 'Kolda',
'', 'KO', 'state', 1),
(3217, 'state_Louga_3217', 'Louga', 'Louga',
'', 'LO', 'state', 1),
(3218, 'state_Matam_3218', 'Matam', 'Matam',
'', 'MA', 'state', 1),
(3219, 'state_Saint_Louis_3219', 'Saint-Louis',
'Saint-Louis', '', 'SL', 'state',
1),
(3220, 'state_Tambacounda_3220', 'Tambacounda',
'Tambacounda', '', 'TA', 'state',
1),
(3221, 'state_Thies__3221', 'Thies ', 'Thies
', '', 'TH', 'state', 1),
(3222, 'state_Ziguinchor_3222', 'Ziguinchor',
'Ziguinchor', '', 'ZI', 'state',
1),
(3223, 'state_Anse_aux_Pins_3223', 'Anse aux Pins',
'Anse aux Pins', '', 'AP', 'state',
1),
(3224, 'state_Anse_Boileau_3224', 'Anse Boileau',
'Anse Boileau', '', 'AB', 'state',
1),
(3225, 'state_Anse_Etoile_3225', 'Anse Etoile',
'Anse Etoile', '', 'AE', 'state',
1),
(3226, 'state_Anse_Louis_3226', 'Anse Louis',
'Anse Louis', '', 'AL', 'state',
1),
(3227, 'state_Anse_Royale_3227', 'Anse Royale',
'Anse Royale', '', 'AR', 'state',
1),
(3228, 'state_Baie_Lazare_3228', 'Baie Lazare',
'Baie Lazare', '', 'BL', 'state',
1),
(3229, 'state_Baie_Sainte_Anne_3229', 'Baie Sainte
Anne', 'Baie Sainte Anne', '', 'BS',
'state', 1),
(3230, 'state_Beau_Vallon_3230', 'Beau Vallon',
'Beau Vallon', '', 'BV', 'state',
1),
(3231, 'state_Bel_Air_3231', 'Bel Air', 'Bel
Air', '', 'BA', 'state', 1),
(3232, 'state_Bel_Ombre_3232', 'Bel Ombre', 'Bel
Ombre', '', 'BO', 'state', 1),
(3233, 'state_Cascade_3233', 'Cascade',
'Cascade', '', 'CA', 'state', 1),
(3234, 'state_Glacis_3234', 'Glacis',
'Glacis', '', 'GL', 'state', 1),
(3235, 'state_Grand__Anse__on_Mahe__3235',
'Grand'' Anse (on Mahe)', 'Grand'' Anse
(on Mahe)', '', 'GM', 'state', 1),
(3236, 'state_Grand__Anse__on_Praslin__3236',
'Grand'' Anse (on Praslin)', 'Grand''
Anse (on Praslin)', '', 'GP', 'state',
1),
(3237, 'state_La_Digue_3237', 'La Digue', 'La
Digue', '', 'DG', 'state', 1),
(3238, 'state_La_Riviere_Anglaise_3238', 'La Riviere
Anglaise', 'La Riviere Anglaise', '',
'RA', 'state', 1),
(3239, 'state_Mont_Buxton_3239', 'Mont Buxton',
'Mont Buxton', '', 'MB', 'state',
1),
(3240, 'state_Mont_Fleuri_3240', 'Mont Fleuri',
'Mont Fleuri', '', 'MF', 'state',
1),
(3241, 'state_Plaisance_3241', 'Plaisance',
'Plaisance', '', 'PL', 'state',
1),
(3242, 'state_Pointe_La_Rue_3242', 'Pointe La Rue',
'Pointe La Rue', '', 'PR', 'state',
1),
(3243, 'state_Port_Glaud_3243', 'Port Glaud',
'Port Glaud', '', 'PG', 'state',
1),
(3244, 'state_Saint_Louis_3244', 'Saint Louis',
'Saint Louis', '', 'SL', 'state',
1),
(3245, 'state_Takamaka_3245', 'Takamaka',
'Takamaka', '', 'TA', 'state', 1),
(3246, 'state_Eastern_3246', 'Eastern',
'Eastern', '', 'E', 'state', 1),
(3250, 'state_Banskobystrick___kraj_3250', 'BanskobystrickĂœ
kraj', 'BanskobystrickĂœ kraj', '',
'BC', 'state', 1),
(3251, 'state_Bratislavsk___kraj_3251', 'BratislavskĂœ
kraj', 'BratislavskĂœ kraj', '', 'BL',
'state', 1),
(3252, 'state_Ko__ick___kraj_3252', 'KoĆĄickĂœ kraj',
'KoĆĄickĂœ kraj', '', 'KI',
'state', 1),
(3253, 'state_Nitriansk___kraj_3253', 'NitrianskĂœ
kraj', 'NitrianskĂœ kraj', '', 'NJ',
'state', 1),
(3254, 'state_Pre__ovsk___kraj_3254', 'PreĆĄovskĂœ
kraj', 'PreĆĄovskĂœ kraj', '', 'PV',
'state', 1),
(3255, 'state_Trnavsk___kraj_3255', 'TrnavskĂœ kraj',
'TrnavskĂœ kraj', '', 'TA',
'state', 1),
(3256, 'state_Tren__iansk___kraj_3256', 'TrenÄianskĂœ
kraj', 'TrenÄianskĂœ kraj', '', 'TC',
'state', 1),
(3257, 'state___ilinsk___kraj_3257', 'ĆœilinskĂœ kraj',
'ĆœilinskĂœ kraj', '', 'ZI',
'state', 1),
(3258, 'state_Ajdov____ina_3258', 'AjdovĆĄÄina',
'AjdovĆĄÄina', '', '001', 'state',
1),
(3259, 'state_Beltinci_3259', 'Beltinci',
'Beltinci', '', '002', 'state',
1),
(3260, 'state_Bled_3260', 'Bled', 'Bled',
'', '003', 'state', 1),
(3261, 'state_Bohinj_3261', 'Bohinj',
'Bohinj', '', '004', 'state', 1),
(3262, 'state_Borovnica_3262', 'Borovnica',
'Borovnica', '', '005', 'state',
1),
(3263, 'state_Bovec_3263', 'Bovec', 'Bovec',
'', '006', 'state', 1),
(3264, 'state_Brda_3264', 'Brda', 'Brda',
'', '007', 'state', 1),
(3265, 'state_Brezovica_3265', 'Brezovica',
'Brezovica', '', '008', 'state',
1),
(3266, 'state_Bre__ice_3266', 'BreĆŸice',
'BreĆŸice', '', '009', 'state',
1),
(3267, 'state_Ti__ina_3267', 'TiĆĄina',
'TiĆĄina', '', '010', 'state', 1),
(3268, 'state_Celje_3268', 'Celje', 'Celje',
'', '011', 'state', 1),
(3269, 'state_Cerklje_na_Gorenjskem_3269', 'Cerklje na
Gorenjskem', 'Cerklje na Gorenjskem', '',
'012', 'state', 1),
(3270, 'state_Cerknica_3270', 'Cerknica',
'Cerknica', '', '013', 'state',
1),
(3271, 'state_Cerkno_3271', 'Cerkno',
'Cerkno', '', '014', 'state', 1),
(3272, 'state___ren__ovci_3272', 'ÄrenĆĄovci',
'ÄrenĆĄovci', '', '015', 'state',
1),
(3273, 'state___rna_na_Koro__kem_3273', 'Ärna na
KoroĆĄkem', 'Ärna na KoroĆĄkem', '',
'016', 'state', 1),
(3274, 'state___rnomelj_3274', 'Ärnomelj',
'Ärnomelj', '', '017', 'state',
1),
(3275, 'state_Destrnik_3275', 'Destrnik',
'Destrnik', '', '018', 'state',
1),
(3276, 'state_Diva__a_3276', 'DivaÄa',
'DivaÄa', '', '019', 'state', 1),
(3277, 'state_Dobrepolje_3277', 'Dobrepolje',
'Dobrepolje', '', '020', 'state',
1),
(3278, 'state_Dobrova_Polhov_Gradec_3278', 'Dobrova-Polhov
Gradec', 'Dobrova-Polhov Gradec', '',
'021', 'state', 1),
(3279, 'state_Dol_pri_Ljubljani_3279', 'Dol pri
Ljubljani', 'Dol pri Ljubljani', '',
'022', 'state', 1),
(3280, 'state_Dom__ale_3280', 'DomĆŸale',
'DomĆŸale', '', '023', 'state',
1),
(3281, 'state_Dornava_3281', 'Dornava',
'Dornava', '', '024', 'state', 1),
(3282, 'state_Dravograd_3282', 'Dravograd',
'Dravograd', '', '025', 'state',
1),
(3283, 'state_Duplek_3283', 'Duplek',
'Duplek', '', '026', 'state', 1),
(3284, 'state_Gorenja_vas_Poljane_3284', 'Gorenja
vas-Poljane', 'Gorenja vas-Poljane', '',
'027', 'state', 1),
(3285, 'state_Gori__nica_3285', 'GoriĆĄnica',
'GoriĆĄnica', '', '028', 'state',
1),
(3286, 'state_Gornja_Radgona_3286', 'Gornja Radgona',
'Gornja Radgona', '', '029',
'state', 1),
(3287, 'state_Gornji_Grad_3287', 'Gornji Grad',
'Gornji Grad', '', '030', 'state',
1),
(3288, 'state_Gornji_Petrovci_3288', 'Gornji Petrovci',
'Gornji Petrovci', '', '031',
'state', 1),
(3289, 'state_Grosuplje_3289', 'Grosuplje',
'Grosuplje', '', '032', 'state',
1),
(3290, 'state___alovci_3290', 'Ć alovci',
'Ć alovci', '', '033', 'state',
1),
(3291, 'state_Hrastnik_3291', 'Hrastnik',
'Hrastnik', '', '034', 'state',
1),
(3292, 'state_Hrpelje_Kozina_3292', 'Hrpelje-Kozina',
'Hrpelje-Kozina', '', '035',
'state', 1),
(3293, 'state_Idrija_3293', 'Idrija',
'Idrija', '', '036', 'state', 1),
(3294, 'state_Ig_3294', 'Ig', 'Ig',
'', '037', 'state', 1),
(3295, 'state_Ilirska_Bistrica_3295', 'Ilirska
Bistrica', 'Ilirska Bistrica', '',
'038', 'state', 1),
(3296, 'state_Ivan__na_Gorica_3296', 'IvanÄna Gorica',
'IvanÄna Gorica', '', '039',
'state', 1),
(3297, 'state_Izola_3297', 'Izola', 'Izola',
'', '040', 'state', 1),
(3298, 'state_Jesenice_3298', 'Jesenice',
'Jesenice', '', '041', 'state',
1),
(3299, 'state_Jur__inci_3299', 'JurĆĄinci',
'JurĆĄinci', '', '042', 'state',
1),
(3300, 'state_Kamnik_3300', 'Kamnik',
'Kamnik', '', '043', 'state', 1),
(3301, 'state_Kanal_ob_So__i_3301', 'Kanal ob SoÄi',
'Kanal ob SoÄi', '', '044',
'state', 1),
(3302, 'state_Kidri__evo_3302', 'KidriÄevo',
'KidriÄevo', '', '045', 'state',
1),
(3303, 'state_Kobarid_3303', 'Kobarid',
'Kobarid', '', '046', 'state', 1),
(3304, 'state_Kobilje_3304', 'Kobilje',
'Kobilje', '', '047', 'state', 1),
(3305, 'state_Ko__evje_3305', 'KoÄevje',
'KoÄevje', '', '048', 'state',
1),
(3306, 'state_Komen_3306', 'Komen', 'Komen',
'', '049', 'state', 1),
(3307, 'state_Koper_3307', 'Koper', 'Koper',
'', '050', 'state', 1),
(3308, 'state_Kozje_3308', 'Kozje', 'Kozje',
'', '051', 'state', 1),
(3309, 'state_Kranj_3309', 'Kranj', 'Kranj',
'', '052', 'state', 1),
(3310, 'state_Kranjska_Gora_3310', 'Kranjska Gora',
'Kranjska Gora', '', '053',
'state', 1),
(3311, 'state_Kr__ko_3311', 'KrĆĄko',
'KrĆĄko', '', '054', 'state', 1),
(3312, 'state_Kungota_3312', 'Kungota',
'Kungota', '', '055', 'state', 1),
(3313, 'state_Kuzma_3313', 'Kuzma', 'Kuzma',
'', '056', 'state', 1),
(3314, 'state_La__ko_3314', 'LaĆĄko',
'LaĆĄko', '', '057', 'state', 1),
(3315, 'state_Lenart_3315', 'Lenart',
'Lenart', '', '058', 'state', 1),
(3316, 'state_Lendava_3316', 'Lendava',
'Lendava', '', '059', 'state', 1),
(3317, 'state_Litija_3317', 'Litija',
'Litija', '', '060', 'state', 1),
(3318, 'state_Ljubljana_3318', 'Ljubljana',
'Ljubljana', '', '061', 'state',
1),
(3319, 'state_Ljubno_3319', 'Ljubno',
'Ljubno', '', '062', 'state', 1),
(3320, 'state_Ljutomer_3320', 'Ljutomer',
'Ljutomer', '', '063', 'state',
1),
(3321, 'state_Logatec_3321', 'Logatec',
'Logatec', '', '064', 'state', 1),
(3322, 'state_Lo__ka_Dolina_3322', 'LoĆĄka Dolina',
'LoĆĄka Dolina', '', '065',
'state', 1),
(3323, 'state_Lo__ki_Potok_3323', 'LoĆĄki Potok',
'LoĆĄki Potok', '', '066', 'state',
1),
(3324, 'state_Lu__e_3324', 'LuÄe', 'LuÄe',
'', '067', 'state', 1),
(3325, 'state_Lukovica_3325', 'Lukovica',
'Lukovica', '', '068', 'state',
1),
(3326, 'state_Maj__perk_3326', 'MajĆĄperk',
'MajĆĄperk', '', '069', 'state',
1),
(3327, 'state_Maribor_3327', 'Maribor',
'Maribor', '', '070', 'state', 1),
(3328, 'state_Medvode_3328', 'Medvode',
'Medvode', '', '071', 'state', 1),
(3329, 'state_Menge___3329', 'MengeĆĄ',
'MengeĆĄ', '', '072', 'state', 1),
(3330, 'state_Metlika_3330', 'Metlika',
'Metlika', '', '073', 'state', 1),
(3331, 'state_Me__ica_3331', 'MeĆŸica',
'MeĆŸica', '', '074', 'state', 1),
(3332, 'state_Miren_Kostanjevica_3332',
'Miren-Kostanjevica', 'Miren-Kostanjevica',
'', '075', 'state', 1),
(3333, 'state_Mislinja_3333', 'Mislinja',
'Mislinja', '', '076', 'state',
1),
(3334, 'state_Morav__e_3334', 'MoravÄe',
'MoravÄe', '', '077', 'state',
1),
(3335, 'state_Moravske_Toplice_3335', 'Moravske
Toplice', 'Moravske Toplice', '', '078',
'state', 1),
(3336, 'state_Mozirje_3336', 'Mozirje',
'Mozirje', '', '079', 'state', 1),
(3337, 'state_Murska_Sobota_3337', 'Murska Sobota',
'Murska Sobota', '', '080',
'state', 1),
(3338, 'state_Muta_3338', 'Muta', 'Muta',
'', '081', 'state', 1),
(3339, 'state_Naklo_3339', 'Naklo', 'Naklo',
'', '082', 'state', 1),
(3340, 'state_Nazarje_3340', 'Nazarje',
'Nazarje', '', '083', 'state', 1),
(3341, 'state_Nova_Gorica_3341', 'Nova Gorica',
'Nova Gorica', '', '084', 'state',
1),
(3342, 'state_Novo_mesto_3342', 'Novo mesto',
'Novo mesto', '', '085', 'state',
1),
(3343, 'state_Odranci_3343', 'Odranci',
'Odranci', '', '086', 'state', 1),
(3344, 'state_Ormo___3344', 'OrmoĆŸ',
'OrmoĆŸ', '', '087', 'state', 1),
(3345, 'state_Osilnica_3345', 'Osilnica',
'Osilnica', '', '088', 'state',
1),
(3346, 'state_Pesnica_3346', 'Pesnica',
'Pesnica', '', '089', 'state', 1),
(3347, 'state_Piran_3347', 'Piran', 'Piran',
'', '090', 'state', 1),
(3348, 'state_Pivka_3348', 'Pivka', 'Pivka',
'', '091', 'state', 1),
(3349, 'state_Pod__etrtek_3349', 'PodÄetrtek',
'PodÄetrtek', '', '092', 'state',
1),
(3350, 'state_Podvelka_3350', 'Podvelka',
'Podvelka', '', '093', 'state',
1),
(3351, 'state_Postojna_3351', 'Postojna',
'Postojna', '', '094', 'state',
1),
(3352, 'state_Preddvor_3352', 'Preddvor',
'Preddvor', '', '095', 'state',
1),
(3353, 'state_Ptuj_3353', 'Ptuj', 'Ptuj',
'', '096', 'state', 1),
(3354, 'state_Puconci_3354', 'Puconci',
'Puconci', '', '097', 'state', 1),
(3355, 'state_Ra__e_Fram_3355', 'RaÄe-Fram',
'RaÄe-Fram', '', '098', 'state',
1),
(3356, 'state_Rade__e_3356', 'RadeÄe',
'RadeÄe', '', '099', 'state', 1),
(3357, 'state_Radenci_3357', 'Radenci',
'Radenci', '', '100', 'state', 1),
(3358, 'state_Radlje_ob_Dravi_3358', 'Radlje ob Dravi',
'Radlje ob Dravi', '', '101',
'state', 1),
(3359, 'state_Radovljica_3359', 'Radovljica',
'Radovljica', '', '102', 'state',
1),
(3360, 'state_Ravne_na_Koro__kem_3360', 'Ravne na
KoroĆĄkem', 'Ravne na KoroĆĄkem', '',
'103', 'state', 1),
(3361, 'state_Ribnica_3361', 'Ribnica',
'Ribnica', '', '104', 'state', 1),
(3362, 'state_Roga__ka_Slatina_3362', 'RogaĆĄka
Slatina', 'RogaĆĄka Slatina', '', '106',
'state', 1),
(3363, 'state_Roga__ovci_3363', 'RogaĆĄovci',
'RogaĆĄovci', '', '105', 'state',
1),
(3364, 'state_Rogatec_3364', 'Rogatec',
'Rogatec', '', '107', 'state', 1),
(3365, 'state_Ru__e_3365', 'RuĆĄe', 'RuĆĄe',
'', '108', 'state', 1),
(3366, 'state_Semi___3366', 'SemiÄ',
'SemiÄ', '', '109', 'state', 1),
(3367, 'state_Sevnica_3367', 'Sevnica',
'Sevnica', '', '110', 'state', 1),
(3368, 'state_Se__ana_3368', 'SeĆŸana',
'SeĆŸana', '', '111', 'state', 1),
(3369, 'state_Slovenj_Gradec_3369', 'Slovenj Gradec',
'Slovenj Gradec', '', '112',
'state', 1),
(3370, 'state_Slovenska_Bistrica_3370', 'Slovenska
Bistrica', 'Slovenska Bistrica', '',
'113', 'state', 1),
(3371, 'state_Slovenske_Konjice_3371', 'Slovenske
Konjice', 'Slovenske Konjice', '',
'114', 'state', 1),
(3372, 'state_Star__e_3372', 'StarĆĄe',
'StarĆĄe', '', '115', 'state', 1),
(3373, 'state_Sveti_Jurij_3373', 'Sveti Jurij',
'Sveti Jurij', '', '116', 'state',
1),
(3374, 'state___en__ur_3374', 'Ć enÄur',
'Ć enÄur', '', '117', 'state',
1),
(3375, 'state___entilj_3375', 'Ć entilj',
'Ć entilj', '', '118', 'state',
1),
(3376, 'state___entjernej_3376', 'Ć entjernej',
'Ć entjernej', '', '119', 'state',
1),
(3377, 'state___entjur_pri_Celju_3377', 'Ć entjur pri
Celju', 'Ć entjur pri Celju', '', '120',
'state', 1),
(3378, 'state___kocjan_3378', 'Ć kocjan',
'Ć kocjan', '', '121', 'state',
1),
(3379, 'state___kofja_Loka_3379', 'Ć kofja Loka',
'Ć kofja Loka', '', '122', 'state',
1),
(3380, 'state___kofljica_3380', 'Ć kofljica',
'Ć kofljica', '', '123', 'state',
1),
(3381, 'state___marje_pri_Jel__ah_3381', 'Ć marje pri
JelĆĄah', 'Ć marje pri JelĆĄah', '',
'124', 'state', 1),
(3382, 'state___martno_ob_Paki_3382', 'Ć martno ob
Paki', 'Ć martno ob Paki', '', '125',
'state', 1),
(3383, 'state___o__tanj_3383', 'Ć oĆĄtanj',
'Ć oĆĄtanj', '', '126', 'state',
1),
(3384, 'state___tore_3384', 'Ć tore',
'Ć tore', '', '127', 'state', 1),
(3385, 'state_Tolmin_3385', 'Tolmin',
'Tolmin', '', '128', 'state', 1),
(3386, 'state_Trbovlje_3386', 'Trbovlje',
'Trbovlje', '', '129', 'state',
1),
(3387, 'state_Trebnje_3387', 'Trebnje',
'Trebnje', '', '130', 'state', 1),
(3388, 'state_Tr__i___3388', 'TrĆŸiÄ',
'TrĆŸiÄ', '', '131', 'state', 1),
(3389, 'state_Turni____e_3389', 'TurniĆĄÄe',
'TurniĆĄÄe', '', '132', 'state',
1),
(3390, 'state_Velenje_3390', 'Velenje',
'Velenje', '', '133', 'state', 1),
(3391, 'state_Velike_La____e_3391', 'Velike LaĆĄÄe',
'Velike LaĆĄÄe', '', '134',
'state', 1),
(3392, 'state_Videm_3392', 'Videm', 'Videm',
'', '135', 'state', 1),
(3393, 'state_Vipava_3393', 'Vipava',
'Vipava', '', '136', 'state', 1),
(3394, 'state_Vitanje_3394', 'Vitanje',
'Vitanje', '', '137', 'state', 1),
(3395, 'state_Vodice_3395', 'Vodice',
'Vodice', '', '138', 'state', 1),
(3396, 'state_Vojnik_3396', 'Vojnik',
'Vojnik', '', '139', 'state', 1),
(3397, 'state_Vrhnika_3397', 'Vrhnika',
'Vrhnika', '', '140', 'state', 1),
(3398, 'state_Vuzenica_3398', 'Vuzenica',
'Vuzenica', '', '141', 'state',
1),
(3399, 'state_Zagorje_ob_Savi_3399', 'Zagorje ob Savi',
'Zagorje ob Savi', '', '142',
'state', 1),
(3400, 'state_Zavr___3400', 'ZavrÄ',
'ZavrÄ', '', '143', 'state', 1),
(3401, 'state_Zre__e_3401', 'ZreÄe',
'ZreÄe', '', '144', 'state', 1),
(3402, 'state___elezniki_3402', 'Ćœelezniki',
'Ćœelezniki', '', '146', 'state',
1),
(3403, 'state___iri_3403', 'Ćœiri', 'Ćœiri',
'', '147', 'state', 1),
(3404, 'state_Benedikt_3404', 'Benedikt',
'Benedikt', '', '148', 'state',
1),
(3405, 'state_Bistrica_ob_Sotli_3405', 'Bistrica ob
Sotli', 'Bistrica ob Sotli', '', '149',
'state', 1),
(3406, 'state_Bloke_3406', 'Bloke', 'Bloke',
'', '150', 'state', 1),
(3407, 'state_Braslov__e_3407', 'BraslovÄe',
'BraslovÄe', '', '151', 'state',
1),
(3408, 'state_Cankova_3408', 'Cankova',
'Cankova', '', '152', 'state', 1),
(3409, 'state_Cerkvenjak_3409', 'Cerkvenjak',
'Cerkvenjak', '', '153', 'state',
1),
(3410, 'state_Dobje_3410', 'Dobje', 'Dobje',
'', '154', 'state', 1),
(3411, 'state_Dobrna_3411', 'Dobrna',
'Dobrna', '', '155', 'state', 1),
(3412, 'state_Dobrovnik_3412', 'Dobrovnik',
'Dobrovnik', '', '156', 'state',
1),
(3413, 'state_Dolenjske_Toplice_3413', 'Dolenjske
Toplice', 'Dolenjske Toplice', '',
'157', 'state', 1),
(3414, 'state_Grad_3414', 'Grad', 'Grad',
'', '158', 'state', 1),
(3415, 'state_Hajdina_3415', 'Hajdina',
'Hajdina', '', '159', 'state', 1),
(3416, 'state_Ho__e_Slivnica_3416', 'HoÄe-Slivnica',
'HoÄe-Slivnica', '', '160',
'state', 1),
(3417, 'state_Hodo___3417', 'HodoĆĄ',
'HodoĆĄ', '', '161', 'state', 1),
(3418, 'state_Horjul_3418', 'Horjul',
'Horjul', '', '162', 'state', 1),
(3419, 'state_Jezersko_3419', 'Jezersko',
'Jezersko', '', '163', 'state',
1),
(3420, 'state_Komenda_3420', 'Komenda',
'Komenda', '', '164', 'state', 1),
(3421, 'state_Kostel_3421', 'Kostel',
'Kostel', '', '165', 'state', 1),
(3422, 'state_Kri__evci_3422', 'KriĆŸevci',
'KriĆŸevci', '', '166', 'state',
1),
(3423, 'state_Lovrenc_na_Pohorju_3423', 'Lovrenc na
Pohorju', 'Lovrenc na Pohorju', '',
'167', 'state', 1),
(3424, 'state_Markovci_3424', 'Markovci',
'Markovci', '', '168', 'state',
1),
(3425, 'state_Miklav___na_Dravskem_polju_3425', 'MiklavĆŸ na
Dravskem polju', 'MiklavĆŸ na Dravskem polju', '',
'169', 'state', 1),
(3426, 'state_Mirna_Pe___3426', 'Mirna PeÄ',
'Mirna PeÄ', '', '170', 'state',
1),
(3427, 'state_Oplotnica_3427', 'Oplotnica',
'Oplotnica', '', '171', 'state',
1),
(3428, 'state_Podlehnik_3428', 'Podlehnik',
'Podlehnik', '', '172', 'state',
1),
(3429, 'state_Polzela_3429', 'Polzela',
'Polzela', '', '173', 'state', 1),
(3430, 'state_Prebold_3430', 'Prebold',
'Prebold', '', '174', 'state', 1),
(3431, 'state_Prevalje_3431', 'Prevalje',
'Prevalje', '', '175', 'state',
1),
(3432, 'state_Razkri__je_3432', 'RazkriĆŸje',
'RazkriĆŸje', '', '176', 'state',
1),
(3433, 'state_Ribnica_na_Pohorju_3433', 'Ribnica na
Pohorju', 'Ribnica na Pohorju', '',
'177', 'state', 1),
(3434, 'state_Selnica_ob_Dravi_3434', 'Selnica ob
Dravi', 'Selnica ob Dravi', '', '178',
'state', 1),
(3435, 'state_Sodra__ica_3435', 'SodraĆŸica',
'SodraĆŸica', '', '179', 'state',
1),
(3436, 'state_Sol__ava_3436', 'SolÄava',
'SolÄava', '', '180', 'state',
1),
(3437, 'state_Sveta_Ana_3437', 'Sveta Ana', 'Sveta
Ana', '', '181', 'state', 1),
(3438, 'state_Sveti_Andra___v_Slovenskih_goricah_3438',
'Sveti AndraĆŸ v Slovenskih goricah', 'Sveti AndraĆŸ v
Slovenskih goricah', '', '182', 'state',
1),
(3439, 'state___empeter_Vrtojba_3439',
'Ć empeter-Vrtojba', 'Ć empeter-Vrtojba', '',
'183', 'state', 1),
(3440, 'state_Tabor_3440', 'Tabor', 'Tabor',
'', '184', 'state', 1),
(3441, 'state_Trnovska_vas_3441', 'Trnovska vas',
'Trnovska vas', '', '185', 'state',
1),
(3442, 'state_Trzin_3442', 'Trzin', 'Trzin',
'', '186', 'state', 1),
(3443, 'state_Velika_Polana_3443', 'Velika Polana',
'Velika Polana', '', '187',
'state', 1),
(3444, 'state_Ver__ej_3444', 'VerĆŸej',
'VerĆŸej', '', '188', 'state', 1),
(3445, 'state_Vransko_3445', 'Vransko',
'Vransko', '', '189', 'state', 1),
(3446, 'state___alec_3446', 'Ćœalec',
'Ćœalec', '', '190', 'state', 1),
(3447, 'state___etale_3447', 'Ćœetale',
'Ćœetale', '', '191', 'state', 1),
(3448, 'state___irovnica_3448', 'Ćœirovnica',
'Ćœirovnica', '', '192', 'state',
1),
(3449, 'state___u__emberk_3449', 'ĆœuĆŸemberk',
'ĆœuĆŸemberk', '', '193', 'state',
1),
(3450, 'state___martno_pri_Litiji_3450', 'Ć martno pri
Litiji', 'Ć martno pri Litiji', '',
'194', 'state', 1),
(3453, 'state_Guadalcanal_3453', 'Guadalcanal',
'Guadalcanal', '', 'GC', 'state',
1),
(3454, 'state_Honiara_3454', 'Honiara',
'Honiara', '', 'HO', 'state', 1),
(3455, 'state_Isabel_3455', 'Isabel',
'Isabel', '', 'IS', 'state', 1),
(3456, 'state_Makira_3456', 'Makira',
'Makira', '', 'MK', 'state', 1),
(3457, 'state_Malaita_3457', 'Malaita',
'Malaita', '', 'ML', 'state', 1),
(3458, 'state_Rennell_and_Bellona_3458', 'Rennell and
Bellona', 'Rennell and Bellona', '',
'RB', 'state', 1),
(3459, 'state_Temotu_3459', 'Temotu',
'Temotu', '', 'TM', 'state', 1),
(3461, 'state_Awdal_3461', 'Awdal', 'Awdal',
'', 'AD', 'state', 1),
(3462, 'state_Bakool_3462', 'Bakool',
'Bakool', '', 'BK', 'state', 1),
(3463, 'state_Banaadir_3463', 'Banaadir',
'Banaadir', '', 'BN', 'state', 1),
(3464, 'state_Bari_3464', 'Bari', 'Bari',
'', 'BR', 'state', 1),
(3465, 'state_Bay_3465', 'Bay', 'Bay',
'', 'BY', 'state', 1),
(3466, 'state_Gedo_3466', 'Gedo', 'Gedo',
'', 'GD', 'state', 1),
(3467, 'state_Galguduud_3467', 'Galguduud',
'Galguduud', '', 'GG', 'state',
1),
(3468, 'state_Hiiraan_3468', 'Hiiraan',
'Hiiraan', '', 'HR', 'state', 1),
(3469, 'state_Jubbada_Dhexe_3469', 'Jubbada Dhexe',
'Jubbada Dhexe', '', 'JD', 'state',
1),
(3470, 'state_Jubbada_Hoose_3470', 'Jubbada Hoose',
'Jubbada Hoose', '', 'JH', 'state',
1),
(3471, 'state_Mudug_3471', 'Mudug', 'Mudug',
'', 'MD', 'state', 1),
(3472, 'state_Nugaal_3472', 'Nugaal',
'Nugaal', '', 'NG', 'state', 1),
(3473, 'state_Shabeellaha_Dhexe_3473', 'Shabeellaha
Dhexe', 'Shabeellaha Dhexe', '', 'SD',
'state', 1),
(3474, 'state_Sanaag_3474', 'Sanaag',
'Sanaag', '', 'SG', 'state', 1),
(3475, 'state_Shabeellaha_Hoose_3475', 'Shabeellaha
Hoose', 'Shabeellaha Hoose', '', 'SH',
'state', 1),
(3476, 'state_Sool_3476', 'Sool', 'Sool',
'', 'SL', 'state', 1),
(3477, 'state_Togdheer_3477', 'Togdheer',
'Togdheer', '', 'TG', 'state', 1),
(3478, 'state_Woqooyi_Galbeed_3478', 'Woqooyi Galbeed',
'Woqooyi Galbeed', '', 'WG',
'state', 1),
(3479, 'state_Eastern_Cape_3479', 'Eastern Cape',
'Eastern Cape', '', 'EC', 'state',
1),
(3480, 'state_Free_State_3480', 'Free State',
'Free State', '', 'FS', 'state',
1),
(3481, 'state_Gauteng_3481', 'Gauteng',
'Gauteng', '', 'GT', 'state', 1),
(3482, 'state_Limpopo_3482', 'Limpopo',
'Limpopo', '', 'LP', 'state', 1),
(3483, 'state_Mpumalanga_3483', 'Mpumalanga',
'Mpumalanga', '', 'MP', 'state',
1),
(3484, 'state_Northern_Cape_3484', 'Northern Cape',
'Northern Cape', '', 'NC', 'state',
1),
(3485, 'state_KwaZulu_Natal_3485', 'KwaZulu-Natal',
'KwaZulu-Natal', '', 'NL', 'state',
1),
(3487, 'state_Western_Cape_3487', 'Western Cape',
'Western Cape', '', 'WC', 'state',
1),
(4556, 'state_North_West_4556', 'North West',
'North West', '', 'NW', 'state',
1),
(3499, 'state_A_Coru__a_3499', 'A Coruña', 'A
Coruña', '', 'C', 'state', 1),
(3490, 'state_Alicante_3490', 'Alicante',
'Alicante', '', 'A', 'state', 1),
(3491, 'state_Albacete_3491', 'Albacete',
'Albacete', '', 'AB', 'state', 1),
(3492, 'state_Almer__a_3492', 'AlmerĂa',
'AlmerĂa', '', 'AL', 'state', 1),
(3548, 'state___lava_3548', 'Ălava',
'Ălava', '', 'VI', 'state', 1),
(3530, 'state_Asturias_3530', 'Asturias',
'Asturias', '', 'O', 'state', 1),
(3494, 'state___vila_3494', 'Ăvila',
'Ăvila', '', 'AV', 'state', 1),
(3496, 'state_Badajoz_3496', 'Badajoz',
'Badajoz', '', 'BA', 'state', 1),
(3533, 'state_Baleares_3533', 'Islas Baleares',
'Islas Baleares', '', 'PM',
'state', 1),
(3495, 'state_Barcelona_3495', 'Barcelona',
'Barcelona', '', 'B', 'state', 1),
(3498, 'state_Burgos_3498', 'Burgos',
'Burgos', '', 'BU', 'state', 1),
(3501, 'state_C__ceres_3501', 'CĂĄceres',
'CĂĄceres', '', 'CC', 'state', 1),
(3500, 'state_C__diz_3500', 'CĂĄdiz',
'CĂĄdiz', '', 'CA', 'state', 1),
(3536, 'state_Cantabria_3536', 'Cantabria',
'Cantabria', '', 'S', 'state', 1),
(3508, 'state_Castell__n_3508', 'CastellĂłn',
'CastellĂłn', '', 'CS', 'state',
1),
(3502, 'state_Ceuta_3502', 'Ceuta', 'Ceuta',
'', 'CE', 'state', 1),
(3507, 'state_Ciudad_Real_3507', 'Ciudad Real',
'Ciudad Real', '', 'CR', 'state',
1),
(3506, 'state_C__rdoba_3506', 'CĂłrdoba',
'CĂłrdoba', '', 'CO', 'state', 1),
(3510, 'state_Cuenca_3510', 'Cuenca',
'Cuenca', '', 'CU', 'state', 1),
(3541, 'state_Guip__zcoa_3541', 'GuipĂșzcoa',
'GuipĂșzcoa', '', 'SS', 'state',
1),
(3514, 'state_Girona_3514', 'Girona',
'Girona', '', 'GI', 'state', 1),
(4504, 'state_Granada_4504', 'Granada',
'Granada', '', 'GR', 'state', 1),
(3516, 'state_Guadalajara_3516', 'Guadalajara',
'Guadalajara', '', 'GU', 'state',
1),
(3517, 'state_Huelva_3517', 'Huelva',
'Huelva', '', 'H', 'state', 1),
(3518, 'state_Huesca_3518', 'Huesca',
'Huesca', '', 'HU', 'state', 1),
(3520, 'state_Ja__n_3520', 'Jaén', 'Jaén',
'', 'J', 'state', 1),
(3523, 'state_La_Rioja_3523', 'La Rioja', 'La
Rioja', '', 'LO', 'state', 1),
(3513, 'state_Las_Palmas_3513', 'Las Palmas', 'Las
Palmas', '', 'GC', 'state', 1),
(4505, 'state_Le__n_4505', 'LeĂłn', 'LeĂłn',
'', 'LE', 'state', 1),
(3521, 'state_Lleida_3521', 'Lleida',
'Lleida', '', 'L', 'state', 1),
(3524, 'state_Lugo_3524', 'Lugo', 'Lugo',
'', 'LU', 'state', 1),
(3525, 'state_Madrid_3525', 'Madrid',
'Madrid', '', 'M', 'state', 1),
(3526, 'state_M__laga_3526', 'MĂĄlaga',
'MĂĄlaga', '', 'MA', 'state', 1),
(3527, 'state_Melilla_3527', 'Melilla',
'Melilla', '', 'ML', 'state', 1),
(3528, 'state_Murcia_3528', 'Murcia',
'Murcia', '', 'MU', 'state', 1),
(3529, 'state_Navarre_3529', 'Navarra',
'Navarra', '', 'NA', 'state', 1),
(3531, 'state_Ourense_3531', 'Ourense',
'Ourense', '', 'OR', 'state', 1),
(3532, 'state_Palencia_3532', 'Palencia',
'Palencia', '', 'P', 'state', 1),
(3534, 'state_Pontevedra_3534', 'Pontevedra',
'Pontevedra', '', 'PO', 'state',
1),
(3537, 'state_Salamanca_3537', 'Salamanca',
'Salamanca', '', 'SA', 'state',
1),
(3539, 'state_Segovia_3539', 'Segovia',
'Segovia', '', 'SG', 'state', 1),
(3538, 'state_Seville_3538', 'Sevilla',
'Sevilla', '', 'SE', 'state', 1),
(3540, 'state_Soria_3540', 'Soria', 'Soria',
'', 'SO', 'state', 1),
(3542, 'state_Tarragona_3542', 'Tarragona',
'Tarragona', '', 'T', 'state', 1),
(3544, 'state_Santa_Cruz_De_Tenerife_3544', 'Santa Cruz de
Tenerife', 'Santa Cruz de Tenerife', '',
'TF', 'state', 1),
(3543, 'state_Teruel_3543', 'Teruel',
'Teruel', '', 'TE', 'state', 1),
(3545, 'state_Toledo_3545', 'Toledo',
'Toledo', '', 'TO', 'state', 1),
(3546, 'state_Valencia_3546', 'Valencia',
'Valencia', '', 'V', 'state', 1),
(3547, 'state_Valladolid_3547', 'Valladolid',
'Valladolid', '', 'VA', 'state',
1),
(3497, 'state_Vizcaya_3497', 'Vizcaya',
'Vizcaya', '', 'BI', 'state', 1),
(3550, 'state_Zamora_3550', 'Zamora',
'Zamora', '', 'ZA', 'state', 1),
(3549, 'state_Zaragoza_3549', 'Zaragoza',
'Zaragoza', '', 'Z', 'state',
1);";
$this->db->setQuery($query);
$this->db->query();
$query="
INSERT IGNORE INTO `#__hikashop_zone` (`zone_id`, `zone_namekey`,
`zone_name`, `zone_name_english`, `zone_code_2`, `zone_code_3`,
`zone_type`, `zone_published`) VALUES
(3552, 'state_North_Central_3552', 'North Central',
'North Central', '', 'NC', 'state',
1),
(3553, 'state_North_3553', 'North', 'North',
'', 'NO', 'state', 1),
(3555, 'state_North_Western_3555', 'North Western',
'North Western', '', 'NW', 'state',
1),
(3557, 'state_Uva_3557', 'Uva', 'Uva',
'', 'UV', 'state', 1),
(3558, 'state_Sabaragamuwa_3558', 'Sabaragamuwa',
'Sabaragamuwa', '', 'SA', 'state',
1),
(3560, 'state_______________________3560', 'ŰŁŰčۧÙÙ
ۧÙÙÙÙ', 'ŰŁŰčۧÙÙ Ű§ÙÙÙÙ', '',
'ANL', 'state', 1),
(3561, 'state_________________________3561', 'ۧÙŰšŰ۱
ۧÙŰŁŰÙ
۱', 'ۧÙŰšŰ۱ ۧÙŰŁŰÙ
۱', '',
'BAM', 'state', 1),
(3562, 'state__________________3562',
'ۧÙŰšŰÙ۱ۧŰȘ', 'ۧÙŰšŰÙ۱ۧŰȘ', '',
'BRT', 'state', 1),
(3563, 'state___________________________3563', 'ÙÙۧÙŰ©
ۧÙŰŹŰČÙ۱۩', 'ÙÙۧÙŰ© ۧÙŰŹŰČÙ۱۩', '',
'JZR', 'state', 1),
(3564, 'state________________3564', 'ۧÙ۟۱۷ÙÙ
',
'ۧÙ۟۱۷ÙÙ
', '', 'KRT',
'state', 1),
(3565, 'state________________3565', 'ۧÙÙ۶ۧ۱Ù',
'ۧÙÙ۶ۧ۱Ù', '', 'QDR',
'state', 1),
(3566, 'state______________3566', 'ۧÙÙŰŰŻŰ©',
'ۧÙÙŰŰŻŰ©', '', 'WDH', 'state',
1),
(3567, 'state_________________________3567', 'ۧÙÙÙÙ
ۧÙŰŁŰšÙ۶', 'ۧÙÙÙÙ Ű§ÙŰŁŰšÙ۶', '',
'ANB', 'state', 1),
(3568, 'state_________________________3568', 'ۧÙÙÙÙ
ۧÙŰŁŰČ۱Ù', 'ۧÙÙÙÙ Ű§ÙŰŁŰČ۱Ù', '',
'ANZ', 'state', 1),
(3569, 'state__________________3569',
'ۧÙŰŽÙ
ۧÙÙŰ©', 'ۧÙŰŽÙ
ۧÙÙŰ©', '',
'ASH', 'state', 1),
(3570, 'state___________________________________3570',
'ۧÙۧ۳ŰȘÙۧۊÙŰ© ۧÙÙ۳۷Ù', 'ۧÙۧ۳ŰȘÙۧۊÙŰ©
ۧÙÙ۳۷Ù', '', 'BJA', 'state', 1),
(3571, 'state_____________________________3571', 'Űș۱ۚ
ۧÙۧ۳ŰȘÙۧۊÙŰ©', 'Űș۱ۚ ۧÙۧ۳ŰȘÙۧۊÙŰ©',
'', 'GIS', 'state', 1),
(3572, 'state____________________________3572', 'Űș۱ۚ
ŰšŰ۱ ۧÙŰșŰČۧÙ', 'Űș۱ۚ ŰšŰ۱ ۧÙŰșŰČۧÙ',
'', 'GBG', 'state', 1),
(3573, 'state_____________________3573', 'Űș۱ۚ
ۯۧ۱ÙÙ۱', 'Űș۱ۚ ۯۧ۱ÙÙ۱', '',
'GDA', 'state', 1),
(3574, 'state_____________________3574', 'Űș۱ۚ
Ù۱ۯÙۧÙ', 'Űș۱ۚ Ù۱ۯÙۧÙ', '',
'GKU', 'state', 1),
(3575, 'state_______________________3575', 'ŰŹÙÙŰš
ۯۧ۱ÙÙ۱', 'ŰŹÙÙŰš ۯۧ۱ÙÙ۱', '',
'JDA', 'state', 1),
(3576, 'state_______________________3576', 'ŰŹÙÙŰš
Ù۱ۯÙۧÙ', 'ŰŹÙÙŰš Ù۱ۯÙۧÙ', '',
'JKU', 'state', 1),
(3577, 'state______________3577', 'ŰŹÙÙÙÙÙ',
'ŰŹÙÙÙÙÙ', '', 'JQL', 'state',
1),
(3578, 'state__________3578', 'ÙŰłÙۧ',
'ÙŰłÙۧ', '', 'KSL', 'state',
1),
(3579, 'state______________________________3579',
'ÙÙۧÙŰ© ÙÙ۱ ۧÙÙÙÙ', 'ÙÙۧÙŰ© ÙÙ۱
ۧÙÙÙÙ', '', 'NNL', 'state', 1),
(3580, 'state______________________________3580', 'ŰŽÙ
ۧÙ
ŰšŰ۱ ۧÙŰșŰČۧÙ', 'ŰŽÙ
Ű§Ù ŰšŰ۱ ۧÙŰșŰČۧÙ',
'', 'SBG', 'state', 1),
(3581, 'state_______________________3581', 'ŰŽÙ
ۧÙ
ۯۧ۱ÙÙ۱', 'ŰŽÙ
Ű§Ù ŰŻŰ§Ű±ÙÙ۱', '',
'SDA', 'state', 1),
(3582, 'state_______________________3582', 'ŰŽÙ
ۧÙ
Ù۱ۯÙۧÙ', 'ŰŽÙ
Ű§Ù Ù۱ۯÙۧÙ', '',
'SKU', 'state', 1),
(3583, 'state_____________________________3583', 'ێ۱Ù
ۧÙۧ۳ŰȘÙۧۊÙŰ©', 'ŰŽŰ±Ù Ű§Ùۧ۳ŰȘÙۧۊÙŰ©',
'', 'SIS', 'state', 1),
(3584, 'state__________3584', 'ŰłÙۧ۱',
'ŰłÙۧ۱', '', 'SNR', 'state',
1),
(3585, 'state____________3585', 'Ùۧ۱ۧۚ',
'Ùۧ۱ۧۚ', '', 'WRB', 'state',
1),
(3586, 'state_Brokopondo_3586', 'Brokopondo',
'Brokopondo', '', 'BR', 'state',
1),
(3587, 'state_Commewijne_3587', 'Commewijne',
'Commewijne', '', 'CM', 'state',
1),
(3588, 'state_Coronie_3588', 'Coronie',
'Coronie', '', 'CR', 'state', 1),
(3589, 'state_Marowijne_3589', 'Marowijne',
'Marowijne', '', 'MA', 'state',
1),
(3590, 'state_Nickerie_3590', 'Nickerie',
'Nickerie', '', 'NI', 'state', 1),
(3591, 'state_Paramaribo_3591', 'Paramaribo',
'Paramaribo', '', 'PM', 'state',
1),
(3592, 'state_Para_3592', 'Para', 'Para',
'', 'PR', 'state', 1),
(3593, 'state_Saramacca_3593', 'Saramacca',
'Saramacca', '', 'SA', 'state',
1),
(3594, 'state_Sipaliwini_3594', 'Sipaliwini',
'Sipaliwini', '', 'SI', 'state',
1),
(3595, 'state_Wanica_3595', 'Wanica',
'Wanica', '', 'WA', 'state', 1),
(3596, 'state_Hhohho_3596', 'Hhohho',
'Hhohho', '', 'HH', 'state', 1),
(3597, 'state_Lubombo_3597', 'Lubombo',
'Lubombo', '', 'LU', 'state', 1),
(3598, 'state_Manzini_3598', 'Manzini',
'Manzini', '', 'MA', 'state', 1),
(3599, 'state_Shiselweni_3599', 'Shiselweni',
'Shiselweni', '', 'SH', 'state',
1),
(3600, 'state_Stockholms_l__n_3600', 'Stockholms lÀn',
'Stockholms lÀn', '', 'AB',
'state', 1),
(3601, 'state_Uppsala_l__n_3601', 'Uppsala lÀn',
'Uppsala lÀn', '', 'C', 'state',
1),
(3602, 'state_S__dermanlands_l__n_3602', 'Södermanlands
lÀn', 'Södermanlands lÀn', '', 'D',
'state', 1),
(3603, 'state___sterg__tlands_l__n_3603', 'Ăstergötlands
lĂ€n', 'Ăstergötlands lĂ€n', '', 'E',
'state', 1),
(3604, 'state_J__nk__pings_l__n_3604', 'Jönköpings
lÀn', 'Jönköpings lÀn', '', 'F',
'state', 1),
(3605, 'state_Kronobergs_l__n_3605', 'Kronobergs lÀn',
'Kronobergs lÀn', '', 'G',
'state', 1),
(3606, 'state_Kalmar_l__n_3606', 'Kalmar lÀn',
'Kalmar lÀn', '', 'H', 'state',
1),
(3607, 'state_Gotlands_l__n_3607', 'Gotlands lÀn',
'Gotlands lÀn', '', 'I', 'state',
1),
(3608, 'state_Blekinge_l__n_3608', 'Blekinge lÀn',
'Blekinge lÀn', '', 'K', 'state',
1),
(3609, 'state_Sk__ne_l__n_3609', 'SkÄne lÀn',
'SkÄne lÀn', '', 'M', 'state',
1),
(3610, 'state_Hallands_l__n_3610', 'Hallands lÀn',
'Hallands lÀn', '', 'N', 'state',
1),
(3611, 'state_V__stra_G__talands_l__n_3611', 'VĂ€stra
Götalands lÀn', 'VÀstra Götalands lÀn', '',
'O', 'state', 1),
(3612, 'state_V__rmlands_l__n__3612', 'VĂ€rmlands
lÀn;', 'VÀrmlands lÀn;', '', 'S',
'state', 1),
(3613, 'state___rebro_l__n_3613', 'Ărebro lĂ€n',
'Ărebro lĂ€n', '', 'T', 'state',
1),
(3614, 'state_V__stmanlands_l__n__3614', 'VĂ€stmanlands
lÀn;', 'VÀstmanlands lÀn;', '', 'U',
'state', 1),
(3615, 'state_Dalarnas_l__n_3615', 'Dalarnas lÀn',
'Dalarnas lÀn', '', 'W', 'state',
1),
(3616, 'state_G__vleborgs_l__n_3616', 'GĂ€vleborgs
lÀn', 'GÀvleborgs lÀn', '', 'X',
'state', 1),
(3617, 'state_V__sternorrlands_l__n_3617', 'VĂ€sternorrlands
lÀn', 'VÀsternorrlands lÀn', '', 'Y',
'state', 1),
(3618, 'state_J__mtlands_l__n_3618', 'JÀmtlands lÀn',
'JÀmtlands lÀn', '', 'Z',
'state', 1),
(3619, 'state_V__sterbottens_l__n_3619', 'VĂ€sterbottens
lÀn', 'VÀsterbottens lÀn', '', 'AC',
'state', 1),
(3620, 'state_Norrbottens_l__n_3620', 'Norrbottens
lÀn', 'Norrbottens lÀn', '', 'BD',
'state', 1),
(3621, 'state_Z__rich_3621', 'ZĂŒrich',
'ZĂŒrich', '', 'ZH', 'state', 1),
(3622, 'state_Bern_3622', 'Bern', 'Bern',
'', 'BE', 'state', 1),
(3623, 'state_Luzern_3623', 'Luzern',
'Luzern', '', 'LU', 'state', 1),
(3624, 'state_Uri_3624', 'Uri', 'Uri',
'', 'UR', 'state', 1),
(3625, 'state_Schwyz_3625', 'Schwyz',
'Schwyz', '', 'SZ', 'state', 1),
(3626, 'state_Obwalden_3626', 'Obwalden',
'Obwalden', '', 'OW', 'state', 1),
(3627, 'state_Nidwalden_3627', 'Nidwalden',
'Nidwalden', '', 'NW', 'state',
1),
(3628, 'state_Glasrus_3628', 'Glarus',
'Glarus', '', 'GL', 'state', 1),
(3629, 'state_Zug_3629', 'Zug', 'Zug',
'', 'ZG', 'state', 1),
(3630, 'state_Fribourg_3630', 'Fribourg',
'Fribourg', '', 'FR', 'state', 1),
(3631, 'state_Solothurn_3631', 'Solothurn',
'Solothurn', '', 'SO', 'state',
1),
(3632, 'state_Basel_Stadt_3632', 'Basel-Stadt',
'Basel-Stadt', '', 'BS', 'state',
1),
(3633, 'state_Basel_Landschaft_3633',
'Basel-Landschaft', 'Basel-Landschaft', '',
'BL', 'state', 1),
(3634, 'state_Schaffhausen_3634', 'Schaffhausen',
'Schaffhausen', '', 'SH', 'state',
1),
(3635, 'state_Appenzell_Ausserrhoden_3635', 'Appenzell
Ausserrhoden', 'Appenzell Ausserrhoden', '',
'AR', 'state', 1),
(3636, 'state_Appenzell_Innerrhoden_3636', 'Appenzell
Innerrhoden', 'Appenzell Innerrhoden', '',
'AI', 'state', 1),
(3637, 'state_Saint_Gallen_3637', 'St. Gallen',
'St. Gallen', '', 'SG', 'state',
1),
(3638, 'state_Graub__nden_3638', 'GraubĂŒnden',
'GraubĂŒnden', '', 'GR', 'state',
1),
(3639, 'state_Aargau_3639', 'Aargau',
'Aargau', '', 'AG', 'state', 1),
(3640, 'state_Thurgau_3640', 'Thurgau',
'Thurgau', '', 'TG', 'state', 1),
(3641, 'state_Ticino_3641', 'Ticino',
'Ticino', '', 'TI', 'state', 1),
(3642, 'state_Vaud_3642', 'Vaud', 'Vaud',
'', 'VD', 'state', 1),
(3643, 'state_Valais_3643', 'Valais',
'Valais', '', 'VS', 'state', 1),
(3644, 'state_Nuech__tel_3644', 'NeuchĂątel',
'NeuchĂątel', '', 'NE', 'state',
1),
(3645, 'state_Gen__ve_3645', 'GenĂšve',
'GenĂšve', '', 'GE', 'state', 1),
(3646, 'state_Jura_3646', 'Jura', 'Jura',
'', 'JU', 'state', 1),
(3647, 'state__________3647', 'ŰŻÙ
ŰŽÙ',
'ŰŻÙ
ŰŽÙ', '', 'DI', 'state', 1),
(3648, 'state__________3648', 'ۯ۱Űčۧ',
'ۯ۱Űčۧ', '', 'DR', 'state', 1),
(3649, 'state___________________3649', 'ŰŻÙ۱
ۧÙŰČÙ۱', 'ŰŻÙ۱ ۧÙŰČÙ۱', '',
'DZ', 'state', 1),
(3650, 'state______________3650', 'ۧÙŰŰłÙŰ©',
'ۧÙŰŰłÙŰ©', '', 'HA', 'state',
1),
(3651, 'state________3651', 'ŰÙ
Ű”',
'ŰÙ
Ű”', '', 'HI', 'state', 1),
(3652, 'state________3652', 'ŰÙŰš',
'ŰÙŰš', '', 'HL', 'state', 1),
(3653, 'state__________3653', 'ŰÙ
ۧÙ',
'ŰÙ
ۧÙ', '', 'HM', 'state', 1),
(3654, 'state__________3654', 'ۧۯÙŰš',
'ۧۯÙŰš', '', 'ID', 'state', 1),
(3655, 'state__________________3655',
'ۧÙÙۧ۰ÙÙŰ©', 'ۧÙÙۧ۰ÙÙŰ©', '',
'LA', 'state', 1),
(3656, 'state__________________3656',
'ۧÙÙÙÙ۷۱۩', 'ۧÙÙÙÙ۷۱۩', '',
'QU', 'state', 1),
(3657, 'state____________3657', 'ۧÙ۱ÙŰ©',
'ۧÙ۱ÙŰ©', '', 'RA', 'state',
1),
(3658, 'state_________________3658', '۱ÛÙ ŰŻÙ
ŰŽÙ',
'۱ÛÙ ŰŻÙ
ŰŽÙ', '', 'RD',
'state', 1),
(3659, 'state__________________3659',
'ۧÙŰłÙÙۯۧۥ', 'ۧÙŰłÙÙۯۧۥ', '',
'SU', 'state', 1),
(3660, 'state____________3660', '۷۱۷ÙŰł',
'۷۱۷ÙŰł', '', 'TA', 'state',
1),
(3661, 'state___________3661', 'ćœ°ć瞣',
'Changhua County', '', 'CHH',
'state', 1),
(3662, 'state___________3662', 'ć矩ćž',
'Chiayi City', '', 'CYC', 'state',
1),
(3663, 'state___________3663', 'ćçŸ©çžŁ',
'Chiayi County', '', 'CYH',
'state', 1),
(3664, 'state___________3664', 'æ°ç«č瞣',
'Hsinchu County', '', 'HCH',
'state', 1),
(3665, 'state___________3665', 'æ°ç«čćž',
'Hsinchu City', '', 'HCC', 'state',
1),
(3666, 'state___________3666', 'è±èźçžŁ',
'Hualien County', '', 'HLH',
'state', 1),
(3667, 'state___________3667', 'ćźè瞣', 'Yilan
County', '', 'YLH', 'state', 1),
(3668, 'state___________3668', 'ćșéćž',
'Keelung City', '', 'KLC', 'state',
1),
(3669, 'state___________3669', 'é«éćž',
'Kaohsiung City', '', 'KHC',
'state', 1),
(3670, 'state___________3670', 'éé瞣',
'Jinmen County', '', 'JMH',
'state', 1),
(3671, 'state___________3671', 'èæ çžŁ',
'Miaoli County', '', 'MLH',
'state', 1),
(3672, 'state___________3672', 'ćæçžŁ',
'Nantou County', '', 'NTH',
'state', 1),
(3673, 'state___________3673', 'æŸæč瞣',
'Penghu County', '', 'PHH',
'state', 1),
(3674, 'state___________3674', '㱿±çžŁ',
'Pingtung County', '', 'PTH',
'state', 1),
(3675, 'state___________3675', 'æĄć瞣',
'Taoyuan County', '', 'TYH',
'state', 1),
(3676, 'state___________3676', 'ć°ććž',
'Tainan City', '', 'TNC', 'state',
1),
(3677, 'state___________3677', 'éŁæ±çžŁ',
'Lianjiang County', '', 'LJH',
'state', 1),
(3678, 'state___________3678', 'ć°ććž',
'Taipei City', '', 'TPC', 'state',
1),
(3679, 'state___________3679', 'æ°ććž', 'New
Taipei City', '', 'NTC', 'state', 1),
(3680, 'state___________3680', 'ć°æ±çžŁ',
'Taitung County', '', 'TTH',
'state', 1),
(3681, 'state___________3681', 'ć°äžćž',
'Taichung City', '', 'TCC',
'state', 1),
(3682, 'state___________3682', 'éČæçžŁ',
'Yunlin County', '', 'YLH',
'state', 1),
(3684, 'state_____________________________3684',
'Ú©ÙÙŰłŰȘŰ§Ù ŰšŰŻŰźŰŽŰ§Ù', 'Ú©ÙÙŰłŰȘۧÙ
ۚۯ۟ێۧÙ', '', 'GB', 'state', 1),
(3685, 'state____________3685', 'ŰźŰȘÙۧÙ',
'ŰźŰȘÙۧÙ', '', 'KT', 'state',
1),
(3686, 'state________3686', 'ŰłŰșŰŻ',
'ŰłŰșŰŻ', '', 'SU', 'state', 1),
(3687, 'state_Arusha_3687', 'Arusha',
'Arusha', '', '01', 'state', 1),
(3688, 'state_Dar_es_Salaam_3688', 'Dar es Salaam',
'Dar es Salaam', '', '02', 'state',
1),
(3689, 'state_Dodoma_3689', 'Dodoma',
'Dodoma', '', '03', 'state', 1),
(3690, 'state_Iringa_3690', 'Iringa',
'Iringa', '', '04', 'state', 1),
(3691, 'state_Kagera_3691', 'Kagera',
'Kagera', '', '05', 'state', 1),
(3692, 'state_Pemba_Sever_3692', 'Pemba Sever',
'Pemba Sever', '', '06', 'state',
1),
(3693, 'state_Zanzibar_Sever_3693', 'Zanzibar Sever',
'Zanzibar Sever', '', '07',
'state', 1),
(3694, 'state_Kigoma_3694', 'Kigoma',
'Kigoma', '', '08', 'state', 1),
(3695, 'state_Kilimanjaro_3695', 'Kilimanjaro',
'Kilimanjaro', '', '09', 'state',
1),
(3696, 'state_Pemba_Jih_3696', 'Pemba Jih', 'Pemba
Jih', '', '10', 'state', 1),
(3697, 'state_Zanzibar_Jih_3697', 'Zanzibar Jih',
'Zanzibar Jih', '', '11', 'state',
1),
(3698, 'state_Lindi_3698', 'Lindi', 'Lindi',
'', '12', 'state', 1),
(3699, 'state_Mara_3699', 'Mara', 'Mara',
'', '13', 'state', 1),
(3700, 'state_Mbeya_3700', 'Mbeya', 'Mbeya',
'', '14', 'state', 1),
(3701, 'state_Zanzibar_Z__pad_3701', 'Zanzibar ZĂĄpad',
'Zanzibar ZĂĄpad', '', '15',
'state', 1),
(3702, 'state_Morogoro_3702', 'Morogoro',
'Morogoro', '', '16', 'state', 1),
(3703, 'state_Mtwara_3703', 'Mtwara',
'Mtwara', '', '17', 'state', 1),
(3704, 'state_Mwanza_3704', 'Mwanza',
'Mwanza', '', '18', 'state', 1),
(3705, 'state_Pwani_3705', 'Pwani', 'Pwani',
'', '19', 'state', 1),
(3706, 'state_Rukwa_3706', 'Rukwa', 'Rukwa',
'', '20', 'state', 1),
(3707, 'state_Ruvuma_3707', 'Ruvuma',
'Ruvuma', '', '21', 'state', 1),
(3708, 'state_Shinyanga_3708', 'Shinyanga',
'Shinyanga', '', '22', 'state',
1),
(3709, 'state_Singida_3709', 'Singida',
'Singida', '', '23', 'state', 1),
(3710, 'state_Tabora_3710', 'Tabora',
'Tabora', '', '24', 'state', 1),
(3711, 'state_Tanga_3711', 'Tanga', 'Tanga',
'', '25', 'state', 1),
(3712, 'state_Manyara_3712', 'Manyara',
'Manyara', '', '26', 'state', 1),
(3713, 'state_________________________________________3713',
'àžàžŁàžžàžàčàžàžàžĄàž«àžČàžàžàžŁ',
'àžàžŁàžžàžàčàžàžàžĄàž«àžČàžàžàžŁ', '',
'TH-10', 'state', 1),
(3714, 'state___________________________________3714',
'àžȘàžĄàžžàžàžŁàžàžŁàžČàžàžČàžŁ',
'àžȘàžĄàžžàžàžŁàžàžŁàžČàžàžČàžŁ', '',
'TH-11', 'state', 1),
(3715, 'state_______________________3715',
'àžàžàžàžàžžàžŁàž”', 'àžàžàžàžàžžàžŁàž”',
'', 'TH-12', 'state', 1),
(3716, 'state__________________________3716',
'àžàžàžžàžĄàžàžČàžàž”', 'àžàžàžžàžĄàžàžČàžàž”',
'', 'TH-13', 'state', 1),
(3717,
'state_______________________________________________3717',
'àžàžŁàž°àžàžàžŁàžšàžŁàž”àžàžąàžžàžàžąàžČ',
'àžàžŁàž°àžàžàžŁàžšàžŁàž”àžàžąàžžàžàžąàžČ', '',
'TH-14', 'state', 1),
(3718, 'state_______________________3718',
'àžàčàžČàžàžàžàž', 'àžàčàžČàžàžàžàž',
'', 'TH-15', 'state', 1),
(3719, 'state____________________3719',
'àž„àžàžàžžàžŁàž”', 'àž„àžàžàžžàžŁàž”',
'', 'TH-16', 'state', 1),
(3720, 'state_____________________________3720',
'àžȘàžŽàžàž«àčàžàžžàžŁàž”',
'àžȘàžŽàžàž«àčàžàžžàžŁàž”', '', 'TH-17',
'state', 1),
(3721, 'state____________________3721',
'àžàž±àžąàžàžČàž', 'àžàž±àžąàžàžČàž',
'', 'TH-18', 'state', 1),
(3722, 'state_______________________3722',
'àžȘàžŁàž°àžàžžàžŁàž”', 'àžȘàžŁàž°àžàžžàžŁàž”',
'', 'TH-19', 'state', 1),
(3723, 'state____________________3723',
'àžàž„àžàžžàžŁàž”', 'àžàž„àžàžžàžŁàž”',
'', 'TH-20', 'state', 1),
(3724, 'state_________________3724', 'àžŁàž°àžąàžàž',
'àžŁàž°àžąàžàž', '', 'TH-21',
'state', 1),
(3725, 'state__________________________3725',
'àžàž±àžàžàžàžžàžŁàž”', 'àžàž±àžàžàžàžžàžŁàž”',
'', 'TH-22', 'state', 1),
(3726, 'state______________3726', 'àžàžŁàžČàž',
'àžàžŁàžČàž', '', 'TH-23',
'state', 1),
(3727, 'state________________________________3727',
'àžàž°àčàžàžŽàžàčàžàžŁàžČ',
'àžàž°àčàžàžŽàžàčàžàžŁàžČ', '',
'TH-24', 'state', 1),
(3728, 'state________________________________3728',
'àžàžŁàžČàžàž”àžàžàžžàžŁàž”',
'àžàžŁàžČàžàž”àžàžàžžàžŁàž”', '',
'TH-25', 'state', 1),
(3729, 'state_______________________3729',
'àžàžàžŁàžàžČàžąàž', 'àžàžàžŁàžàžČàžąàž',
'', 'TH-26', 'state', 1),
(3730, 'state_______________________3730',
'àžȘàžŁàž°àčàžàčàž§', 'àžȘàžŁàž°àčàžàčàž§',
'', 'TH-27', 'state', 1),
(3731, 'state________________________________3731',
'àžàžàžŁàžŁàžČàžàžȘàž”àžĄàžČ',
'àžàžàžŁàžŁàžČàžàžȘàž”àžĄàžČ', '',
'TH-30', 'state', 1),
(3732, 'state_____________________________3732',
'àžàžžàžŁàž”àžŁàž±àžĄàžąàč',
'àžàžžàžŁàž”àžŁàž±àžĄàžąàč', '', 'TH-31',
'state', 1),
(3733, 'state__________________________3733',
'àžȘàžžàžŁàžŽàžàžàžŁàč', 'àžȘàžžàžŁàžŽàžàžàžŁàč',
'', 'TH-32', 'state', 1),
(3734, 'state__________________________3734',
'àžšàžŁàž”àžȘàž°àčàžàž©', 'àžšàžŁàž”àžȘàž°àčàžàž©',
'', 'TH-33', 'state', 1),
(3735, 'state___________________________________3735',
'àžàžžàžàž„àžŁàžČàžàžàžČàžàž”',
'àžàžžàžàž„àžŁàžČàžàžàžČàžàž”', '',
'TH-34', 'state', 1),
(3736, 'state_________________3736', 'àžąàčàžȘàžàžŁ',
'àžąàčàžȘàžàžŁ', '', 'TH-35',
'state', 1),
(3737, 'state_______________________3737',
'àžàž±àžąàž àžčàžĄàžŽ', 'àžàž±àžąàž àžčàžĄàžŽ',
'', 'TH-36', 'state', 1),
(3738, 'state________________________________3738',
'àžàžłàžàžČàžàčàžàžŁàžŽàž',
'àžàžłàžàžČàžàčàžàžŁàžŽàž', '',
'TH-37', 'state', 1),
(3739, 'state___________________________________3739',
'àž«àžàžàžàžàž±àž§àž„àžłàž àžč',
'àž«àžàžàžàžàž±àž§àž„àžłàž àžč', '',
'TH-39', 'state', 1),
(3740, 'state_______________________3740',
'àžàžàžàčàžàčàž', 'àžàžàžàčàžàčàž',
'', 'TH-40', 'state', 1),
(3741, 'state__________________________3741',
'àžàžžàžàžŁàžàžČàžàž”', 'àžàžžàžàžŁàžàžČàžàž”',
'', 'TH-41', 'state', 1),
(3742, 'state___________3742', 'àčàž„àžą',
'àčàž„àžą', '', 'TH-42', 'state',
1),
(3743, 'state_______________________3743',
'àž«àžàžàžàžàžČàžą', 'àž«àžàžàžàžàžČàžą',
'', 'TH-43', 'state', 1),
(3744, 'state_____________________________3744',
'àžĄàž«àžČàžȘàžČàžŁàžàžČàžĄ',
'àžĄàž«àžČàžȘàžČàžŁàžàžČàžĄ', '', 'TH-44',
'state', 1),
(3745, 'state__________________________3745',
'àžŁàčàžàžąàčàžàčàž', 'àžŁàčàžàžąàčàžàčàž',
'', 'TH-45', 'state', 1),
(3746, 'state_____________________________3746',
'àžàžČàžŹàžȘàžŽàžàžàžžàč',
'àžàžČàžŹàžȘàžŽàžàžàžžàč', '', 'TH-46',
'state', 1),
(3747, 'state____________________3747',
'àžȘàžàž„àžàžàžŁ', 'àžȘàžàž„àžàžàžŁ',
'', 'TH-47', 'state', 1),
(3748, 'state____________________3748',
'àžàžàžŁàžàžàžĄ', 'àžàžàžŁàžàžàžĄ',
'', 'TH-48', 'state', 1),
(3749, 'state__________________________3749',
'àžĄàžžàžàžàžČàž«àžČàžŁ', 'àžĄàžžàžàžàžČàž«àžČàžŁ',
'', 'TH-49', 'state', 1),
(3750, 'state_____________________________3750',
'àčàžàž”àžąàžàčàž«àžĄàč',
'àčàžàž”àžąàžàčàž«àžĄàč', '', 'TH-50',
'state', 1),
(3751, 'state_________________3751', 'àž„àžłàžàžčàž',
'àž„àžłàžàžčàž', '', 'TH-51',
'state', 1),
(3752, 'state_________________3752', 'àž„àžłàžàžČàž',
'àž„àžłàžàžČàž', '', 'TH-52',
'state', 1),
(3753, 'state_____________________________3753',
'àžàžžàžàžŁàžàžŽàžàžàč',
'àžàžžàžàžŁàžàžŽàžàžàč', '', 'TH-53',
'state', 1),
(3754, 'state______________3754', 'àžàčàžČàž',
'àžàčàžČàž', '', 'TH-55',
'state', 1),
(3755, 'state_________________3755', 'àžàž°àčàžąàžČ',
'àžàž°àčàžąàžČ', '', 'TH-56',
'state', 1),
(3756, 'state__________________________3756',
'àčàžàž”àžąàžàžŁàžČàžą', 'àčàžàž”àžąàžàžŁàžČàžą',
'', 'TH-57', 'state', 1),
(3757, 'state________________________________3757',
'àčàžĄàčàžźàčàžàžàžȘàžàž',
'àčàžĄàčàžźàčàžàžàžȘàžàž', '',
'TH-58', 'state', 1),
(3758, 'state_____________________________3758',
'àžàžàžŁàžȘàž§àžŁàžŁàžàč',
'àžàžàžŁàžȘàž§àžŁàžŁàžàč', '', 'TH-60',
'state', 1),
(3759, 'state_____________________________3759',
'àžàžžàžàž±àžąàžàžČàžàž”',
'àžàžžàžàž±àžąàžàžČàžàž”', '', 'TH-61',
'state', 1),
(3760, 'state_____________________________3760',
'àžàžłàčàžàžàčàžàžàžŁ',
'àžàžłàčàžàžàčàžàžàžŁ', '', 'TH-62',
'state', 1),
(3761, 'state___________3761', 'àžàžČàž',
'àžàžČàž', '', 'TH-63', 'state',
1),
(3762, 'state_______________________3762',
'àžȘàžžàčàžàžàž±àžą', 'àžȘàžžàčàžàžàž±àžą',
'', 'TH-64', 'state', 1),
(3763, 'state_________________3763', 'àžàžžàžĄàžàžŁ',
'àžàžžàžĄàžàžŁ', '', 'TH-66',
'state', 1),
(3764, 'state____________________3764',
'àžàžŽàžàžŽàžàžŁ', 'àžàžŽàžàžŽàžàžŁ',
'', 'TH-67', 'state', 1),
(3765, 'state_______________________3765',
'àžŁàžČàžàžàžžàžŁàž”', 'àžŁàžČàžàžàžžàžŁàž”',
'', 'TH-70', 'state', 1),
(3766, 'state_____________________________3766',
'àžàžČàžàžàžàžàžžàžŁàž”',
'àžàžČàžàžàžàžàžžàžŁàž”', '', 'TH-71',
'state', 1),
(3767, 'state________________________________3767',
'àžȘàžžàžàžŁàžŁàžàžàžžàžŁàž”',
'àžȘàžžàžàžŁàžŁàžàžàžžàžŁàž”', '',
'TH-72', 'state', 1),
(3768, 'state____________________3768',
'àžàžàžŁàžàžàžĄ', 'àžàžàžŁàžàžàžĄ',
'', 'TH-73', 'state', 1),
(3769, 'state_____________________________3769',
'àžȘàžĄàžžàžàžŁàžȘàžČàžàžŁ',
'àžȘàžĄàžžàžàžŁàžȘàžČàžàžŁ', '', 'TH-74',
'state', 1),
(3770, 'state___________________________________3770',
'àžȘàžĄàžžàžàžŁàžȘàžàžàžŁàžČàžĄ',
'àžȘàžĄàžžàžàžŁàžȘàžàžàžŁàžČàžĄ', '',
'TH-75', 'state', 1),
(3771, 'state__________________________3771',
'àčàžàžàžŁàžàžžàžŁàž”', 'àčàžàžàžŁàžàžžàžŁàž”',
'', 'TH-76', 'state', 1),
(3772,
'state_______________________________________________3772',
'àžàžŁàž°àžàž§àžàžàž”àžŁàž”àžàž±àžàžàč',
'àžàžŁàž°àžàž§àžàžàž”àžŁàž”àžàž±àžàžàč', '',
'TH-77', 'state', 1),
(3773, 'state_________________________________________3773',
'àžàžàžŁàžšàžŁàž”àžàžŁàžŁàžĄàžŁàžČàž',
'àžàžàžŁàžšàžŁàž”àžàžŁàžŁàžĄàžŁàžČàž', '',
'TH-80', 'state', 1),
(3774, 'state____________________3774',
'àžàžŁàž°àžàž”àč', 'àžàžŁàž°àžàž”àč',
'', 'TH-81', 'state', 1),
(3775, 'state_________________3775', 'àžàž±àžàžàžČ',
'àžàž±àžàžàžČ', '', 'TH-82',
'state', 1),
(3776, 'state____________________3776',
'àž àžčàčàžàčàž', 'àž àžčàčàžàčàž',
'', 'TH-83', 'state', 1),
(3777, 'state______________________________________3777',
'àžȘàžžàžŁàžČàž©àžàžŁàčàžàžČàžàž”',
'àžȘàžžàžŁàžČàž©àžàžŁàčàžàžČàžàž”', '',
'TH-84', 'state', 1),
(3778, 'state_________________3778', 'àžŁàž°àžàžàž',
'àžŁàž°àžàžàž', '', 'TH-85',
'state', 1),
(3779, 'state_________________3779', 'àžàžžàžĄàžàžŁ',
'àžàžžàžĄàžàžŁ', '', 'TH-86',
'state', 1),
(3780, 'state_________________3780', 'àžȘàžàžàž„àžČ',
'àžȘàžàžàž„àžČ', '', 'TH-90',
'state', 1),
(3781, 'state______________3781', 'àžȘàžàžčàž„',
'àžȘàžàžčàž„', '', 'TH-91',
'state', 1),
(3782, 'state______________3782', 'àžàžŁàž±àž',
'àžàžŁàž±àž', '', 'TH-92',
'state', 1),
(3783, 'state____________________3783',
'àžàž±àžàž„àžžàž', 'àžàž±àžàž„àžžàž',
'', 'TH-93', 'state', 1),
(3784, 'state_______________________3784',
'àžàž±àžàžàžČàžàž”', 'àžàž±àžàžàžČàžàž”',
'', 'TH-94', 'state', 1),
(3785, 'state______________3785', 'àžąàž°àž„àžČ',
'àžąàž°àž„àžČ', '', 'TH-95',
'state', 1),
(3786, 'state__________________________3786',
'àžàžŁàžČàžàžŽàž§àžČàžȘ', 'àžàžŁàžČàžàžŽàž§àžČàžȘ',
'', 'TH-96', 'state', 1),
(3787, 'state_Centrale_3787', 'Centrale',
'Centrale', '', 'C', 'state', 1),
(3788, 'state_Kara_3788', 'Kara', 'Kara',
'', 'K', 'state', 1),
(3789, 'state_Maritime_3789', 'Maritime',
'Maritime', '', 'M', 'state', 1),
(3790, 'state_Plateaux_3790', 'Plateaux',
'Plateaux', '', 'P', 'state', 1),
(3791, 'state_Savanes_3791', 'Savanes',
'Savanes', '', 'S', 'state', 1),
(3792, 'state_Atafu_3792', 'Atafu', 'Atafu',
'', 'A', 'state', 1),
(3793, 'state_Fakaofo_3793', 'Fakaofo',
'Fakaofo', '', 'F', 'state', 1),
(3794, 'state_Nukunonu_3794', 'Nukunonu',
'Nukunonu', '', 'N', 'state', 1),
(3795, 'state_Ha_apai_3795', 'Ha''apai',
'Ha''apai', '', 'H',
'state', 1),
(3796, 'state_Tongatapu_3796', 'Tongatapu',
'Tongatapu', '', 'T', 'state', 1),
(3797, 'state_Vava_u_3797', 'Vava''u',
'Vava''u', '', 'V',
'state', 1),
(3798, 'state_Arima_3798', 'Arima', 'Arima',
'', 'ARI', 'state', 1),
(3799, 'state_Chaguanas_3799', 'Chaguanas',
'Chaguanas', '', 'CHA', 'state',
1),
(3800, 'state_Couva_Tabaquite_Talparo_3800',
'Couva-Tabaquite-Talparo', 'Couva-Tabaquite-Talparo',
'', 'CTT', 'state', 1),
(3801, 'state_Diego_Martin_3801', 'Diego Martin',
'Diego Martin', '', 'DMN', 'state',
1),
(3802, 'state_Eastern_Tobago_3802', 'Eastern Tobago',
'Eastern Tobago', '', 'ETO',
'state', 1),
(3803, 'state_Rio_Claro_Mayaro_3803', 'Rio
Claro-Mayaro', 'Rio Claro-Mayaro', '',
'RCM', 'state', 1),
(3804, 'state_Penal_Debe_3804', 'Penal-Debe',
'Penal-Debe', '', 'PED', 'state',
1),
(3805, 'state_Point_Fortin_3805', 'Point Fortin',
'Point Fortin', '', 'PTF', 'state',
1),
(3806, 'state_Port_of_Spain_3806', 'Port of Spain',
'Port of Spain', '', 'POS',
'state', 1),
(3807, 'state_Princes_Town_3807', 'Princes Town',
'Princes Town', '', 'PRT', 'state',
1),
(3808, 'state_San_Fernando_3808', 'San Fernando',
'San Fernando', '', 'SFO', 'state',
1),
(3809, 'state_Sangre_Grande_3809', 'Sangre Grande',
'Sangre Grande', '', 'SGE',
'state', 1),
(3810, 'state_San_Juan_Laventille_3810', 'San
Juan-Laventille', 'San Juan-Laventille', '',
'SJL', 'state', 1),
(3811, 'state_Siparia_3811', 'Siparia',
'Siparia', '', 'SIP', 'state', 1),
(3812, 'state_Tunapuna_Piarco_3812', 'Tunapuna-Piarco',
'Tunapuna-Piarco', '', 'TUP',
'state', 1),
(3813, 'state_Western_Tobago_3813', 'Western Tobago',
'Western Tobago', '', 'WTO',
'state', 1),
(3814, 'state_____________________3814', 'ÙÙۧÙŰ©
ŰȘÙÙŰł', 'ÙÙۧÙŰ© ŰȘÙÙŰł', '',
'11', 'state', 1),
(3815, 'state_________________________3815', 'ÙÙۧÙŰ©
ۣ۱ÙۧÙŰ©', 'ÙÙۧÙŰ© ۣ۱ÙۧÙŰ©', '',
'12', 'state', 1),
(3816, 'state__________________________3816', 'ÙÙۧÙŰ©
ŰšÙ Űč۱ÙŰł', 'ÙÙۧÙŰ© ŰšÙ Űč۱ÙŰł', '',
'13', 'state', 1),
(3817, 'state_______________________3817', 'ÙÙۧÙŰ©
Ù
ÙÙۚ۩', 'ÙÙۧÙŰ© Ù
ÙÙۚ۩', '',
'14', 'state', 1),
(3818, 'state_____________________3818', 'ÙÙۧÙŰ©
ÙۧۚÙ', 'ÙÙۧÙŰ© ÙۧۚÙ', '',
'21', 'state', 1),
(3819, 'state_______________________3819', 'ÙÙۧÙŰ©
ŰČŰșÙۧÙ', 'ÙÙۧÙŰ© ŰČŰșÙۧÙ', '',
'22', 'state', 1),
(3820, 'state_______________________3820', 'ÙÙۧÙŰ©
ŰšÙŰČ۱ŰȘ', 'ÙÙۧÙŰ© ŰšÙŰČ۱ŰȘ', '',
'23', 'state', 1),
(3821, 'state_____________________3821', 'ÙÙۧÙŰ©
ۚۧۏ۩', 'ÙÙۧÙŰ© ۚۧۏ۩', '',
'31', 'state', 1),
(3822, 'state_________________________3822', 'ÙÙۧÙŰ©
ŰŹÙŰŻÙۚ۩', 'ÙÙۧÙŰ© ŰŹÙŰŻÙۚ۩', '',
'32', 'state', 1),
(3823, 'state_______________________3823', 'ÙÙۧÙŰ©
ۧÙÙۧÙ', 'ÙÙۧÙŰ© ۧÙÙۧÙ', '',
'33', 'state', 1),
(3824, 'state_________________________3824', 'ÙÙۧÙŰ©
ŰłÙÙۧÙŰ©', 'ÙÙۧÙŰ© ŰłÙÙۧÙŰ©', '',
'34', 'state', 1),
(3825, 'state_____________________________3825', 'ÙÙۧÙŰ©
ۧÙÙÙ۱ÙۧÙ', 'ÙÙۧÙŰ© ۧÙÙÙ۱ÙۧÙ',
'', '41', 'state', 1),
(3826, 'state___________________________3826', 'ÙÙۧÙŰ©
ۧÙÙ۔۱ÙÙ', 'ÙÙۧÙŰ© ۧÙÙ۔۱ÙÙ', '',
'42', 'state', 1),
(3827, 'state________________________________3827',
'ÙÙۧÙŰ© ŰłÙŰŻÙ ŰšÙŰČÙŰŻ', 'ÙÙۧÙŰ© ŰłÙŰŻÙ
ŰšÙŰČÙŰŻ', '', '43', 'state', 1),
(3828, 'state_____________________3828', 'ÙÙۧÙŰ©
ŰłÙ۳۩', 'ÙÙۧÙŰ© ŰłÙ۳۩', '',
'51', 'state', 1),
(3829, 'state_____________________________3829', 'ÙÙۧÙŰ©
ۧÙÙ
ÙŰłŰȘÙ۱', 'ÙÙۧÙŰ© ۧÙÙ
ÙŰłŰȘÙ۱',
'', '52', 'state', 1),
(3830, 'state___________________________3830', 'ÙÙۧÙŰ©
ۧÙÙ
ÙŰŻÙŰ©', 'ÙÙۧÙŰ© ۧÙÙ
ÙŰŻÙŰ©', '',
'53', 'state', 1),
(3831, 'state_______________________3831', 'ÙÙۧÙŰ©
Ű”ÙۧÙŰł', 'ÙÙۧÙŰ© Ű”ÙۧÙŰł', '',
'61', 'state', 1),
(3832, 'state_____________________3832', 'ÙÙۧÙŰ©
ÙÙ۔۩', 'ÙÙۧÙŰ© ÙÙ۔۩', '',
'71', 'state', 1),
(3833, 'state_____________________3833', 'ÙÙۧÙŰ©
ŰȘÙŰČ۱', 'ÙÙۧÙŰ© ŰȘÙŰČ۱', '',
'72', 'state', 1),
(3834, 'state_____________________3834', 'ÙÙۧÙŰ©
ÙŰšÙÙ', 'ÙÙۧÙŰ© ÙŰšÙÙ', '',
'73', 'state', 1),
(3835, 'state_____________________3835', 'ÙÙۧÙŰ©
Ùۧۚ۳', 'ÙÙۧÙŰ© Ùۧۚ۳', '',
'81', 'state', 1),
(3836, 'state_______________________3836', 'ÙÙۧÙŰ©
Ù
ŰŻÙÙÙ', 'ÙÙۧÙŰ© Ù
ŰŻÙÙÙ', '',
'82', 'state', 1),
(3837, 'state_________________________3837', 'ÙÙۧÙŰ©
ŰȘ۷ۧÙÙÙ', 'ÙÙۧÙŰ© ŰȘ۷ۧÙÙÙ', '',
'83', 'state', 1),
(3838, 'state_Adana_3838', 'Adana', 'Adana',
'', '01', 'state', 1),
(3839, 'state_Ad__yaman_3839', 'Adıyaman',
'Adıyaman', '', '02', 'state',
1),
(3840, 'state_Afyonkarahisar_3840', 'Afyonkarahisar',
'Afyonkarahisar', '', '03',
'state', 1),
(3841, 'state_A__r___3841', 'AÄrı',
'AÄrı', '', '04', 'state', 1),
(3842, 'state_Amasya_3842', 'Amasya',
'Amasya', '', '05', 'state', 1),
(3843, 'state_Ankara_3843', 'Ankara',
'Ankara', '', '06', 'state', 1),
(3844, 'state_Antalya_3844', 'Antalya',
'Antalya', '', '07', 'state', 1),
(3845, 'state_Artvin_3845', 'Artvin',
'Artvin', '', '08', 'state', 1),
(3846, 'state_Ayd__n_3846', 'Aydın',
'Aydın', '', '09', 'state', 1),
(3847, 'state_Bal__kesir_3847', 'Balıkesir',
'Balıkesir', '', '10', 'state',
1),
(3848, 'state_Bilecik_3848', 'Bilecik',
'Bilecik', '', '11', 'state', 1),
(3849, 'state_Bing__l_3849', 'Bingöl',
'Bingöl', '', '12', 'state', 1),
(3850, 'state_Bitlis_3850', 'Bitlis',
'Bitlis', '', '13', 'state', 1),
(3851, 'state_Bolu_3851', 'Bolu', 'Bolu',
'', '14', 'state', 1),
(3852, 'state_Burdur_3852', 'Burdur',
'Burdur', '', '15', 'state', 1),
(3853, 'state_Bursa_3853', 'Bursa', 'Bursa',
'', '16', 'state', 1),
(3854, 'state___anakkale_3854', 'Ăanakkale',
'Ăanakkale', '', '17', 'state',
1),
(3855, 'state___ank__r___3855', 'Ăankırı',
'Ăankırı', '', '18', 'state',
1),
(3856, 'state___orum_3856', 'Ăorum',
'Ăorum', '', '19', 'state', 1),
(3857, 'state_Denizli_3857', 'Denizli',
'Denizli', '', '20', 'state', 1),
(3858, 'state_Diyarbak__r_3858', 'Diyarbakır',
'Diyarbakır', '', '21', 'state',
1),
(3859, 'state_Edirne_3859', 'Edirne',
'Edirne', '', '22', 'state', 1),
(3860, 'state_Elaz_____3860', 'ElazıÄ',
'ElazıÄ', '', '23', 'state', 1),
(3861, 'state_Erzincan_3861', 'Erzincan',
'Erzincan', '', '24', 'state', 1),
(3862, 'state_Erzurum_3862', 'Erzurum',
'Erzurum', '', '25', 'state', 1),
(3863, 'state_Eski__ehir_3863', 'EskiĆehir',
'EskiĆehir', '', '26', 'state',
1),
(3864, 'state_Gaziantep_3864', 'Gaziantep',
'Gaziantep', '', '27', 'state',
1),
(3865, 'state_Giresun_3865', 'Giresun',
'Giresun', '', '28', 'state', 1),
(3866, 'state_G__m____hane_3866', 'GĂŒmĂŒĆhane',
'GĂŒmĂŒĆhane', '', '29', 'state',
1),
(3867, 'state_Hakkari_3867', 'Hakkari',
'Hakkari', '', '30', 'state', 1),
(3868, 'state_Hatay_3868', 'Hatay', 'Hatay',
'', '31', 'state', 1),
(3869, 'state_Isparta_3869', 'Isparta',
'Isparta', '', '32', 'state', 1),
(3870, 'state_Mersin_3870', 'Mersin',
'Mersin', '', '33', 'state', 1),
(3871, 'state___stanbul_3871', 'İstanbul',
'İstanbul', '', '34', 'state',
1),
(3872, 'state___zmir_3872', 'İzmir',
'İzmir', '', '35', 'state', 1),
(3873, 'state_Kars_3873', 'Kars', 'Kars',
'', '36', 'state', 1),
(3874, 'state_Kastamonu_3874', 'Kastamonu',
'Kastamonu', '', '37', 'state',
1),
(3875, 'state_Kayseri_3875', 'Kayseri',
'Kayseri', '', '38', 'state', 1),
(3876, 'state_K__rklareli_3876', 'Kırklareli',
'Kırklareli', '', '39', 'state',
1),
(3877, 'state_K__r__ehir_3877', 'KırĆehir',
'KırĆehir', '', '40', 'state',
1),
(3878, 'state_Kocaeli_3878', 'Kocaeli',
'Kocaeli', '', '41', 'state', 1),
(3879, 'state_Konya_3879', 'Konya', 'Konya',
'', '42', 'state', 1),
(3880, 'state_K__tahya_3880', 'KĂŒtahya',
'KĂŒtahya', '', '43', 'state', 1),
(3881, 'state_Malatya_3881', 'Malatya',
'Malatya', '', '44', 'state', 1),
(3882, 'state_Manisa_3882', 'Manisa',
'Manisa', '', '45', 'state', 1),
(3883, 'state_Kahramanmara___3883', 'KahramanmaraĆ',
'KahramanmaraĆ', '', '46',
'state', 1),
(3884, 'state_Mardin_3884', 'Mardin',
'Mardin', '', '47', 'state', 1),
(3885, 'state_Mu__la_3885', 'MuÄla',
'MuÄla', '', '48', 'state', 1),
(3886, 'state_Mu___3886', 'MuĆ', 'MuĆ',
'', '49', 'state', 1),
(3887, 'state_Nev__ehir_3887', 'NevĆehir',
'NevĆehir', '', '50', 'state',
1),
(3888, 'state_Ni__de_3888', 'NiÄde',
'NiÄde', '', '51', 'state', 1),
(3889, 'state_Ordu_3889', 'Ordu', 'Ordu',
'', '52', 'state', 1),
(3890, 'state_Rize_3890', 'Rize', 'Rize',
'', '53', 'state', 1),
(3891, 'state_Sakarya_3891', 'Sakarya',
'Sakarya', '', '54', 'state', 1),
(3892, 'state_Samsun_3892', 'Samsun',
'Samsun', '', '55', 'state', 1),
(3893, 'state_Siirt_3893', 'Siirt', 'Siirt',
'', '56', 'state', 1),
(3894, 'state_Sinop_3894', 'Sinop', 'Sinop',
'', '57', 'state', 1),
(3895, 'state_Sivas_3895', 'Sivas', 'Sivas',
'', '58', 'state', 1),
(3896, 'state_Tekirda___3896', 'TekirdaÄ',
'TekirdaÄ', '', '59', 'state',
1),
(3897, 'state_Tokat_3897', 'Tokat', 'Tokat',
'', '60', 'state', 1),
(3898, 'state_Trabzon_3898', 'Trabzon',
'Trabzon', '', '61', 'state', 1),
(3899, 'state_Tunceli_3899', 'Tunceli',
'Tunceli', '', '62', 'state', 1),
(3900, 'state___anl__urfa_3900', 'Ćanlıurfa',
'Ćanlıurfa', '', '63', 'state',
1),
(3901, 'state_U__ak_3901', 'UĆak', 'UĆak',
'', '64', 'state', 1),
(3902, 'state_Van_3902', 'Van', 'Van',
'', '65', 'state', 1),
(3903, 'state_Yozgat_3903', 'Yozgat',
'Yozgat', '', '66', 'state', 1),
(3904, 'state_Zonguldak_3904', 'Zonguldak',
'Zonguldak', '', '67', 'state',
1),
(3905, 'state_Aksaray_3905', 'Aksaray',
'Aksaray', '', '68', 'state', 1),
(3906, 'state_Bayburt_3906', 'Bayburt',
'Bayburt', '', '69', 'state', 1),
(3907, 'state_Karaman_3907', 'Karaman',
'Karaman', '', '70', 'state', 1),
(3908, 'state_K__r__kkale_3908', 'Kırıkkale',
'Kırıkkale', '', '71', 'state',
1),
(3909, 'state_Batman_3909', 'Batman',
'Batman', '', '72', 'state', 1),
(3910, 'state_____rnak_3910', 'Ćırnak',
'Ćırnak', '', '73', 'state', 1),
(3911, 'state_Bart__n_3911', 'Bartın',
'Bartın', '', '74', 'state', 1),
(3912, 'state_Ardahan_3912', 'Ardahan',
'Ardahan', '', '75', 'state', 1),
(3913, 'state_I__d__r_3913', 'IÄdır',
'IÄdır', '', '76', 'state', 1),
(3914, 'state_Yalova_3914', 'Yalova',
'Yalova', '', '77', 'state', 1),
(3915, 'state_Karab__k_3915', 'KarabĂŒk',
'KarabĂŒk', '', '78', 'state', 1),
(3916, 'state_Kilis_3916', 'Kilis', 'Kilis',
'', '79', 'state', 1),
(3917, 'state_Osmaniye_3917', 'Osmaniye',
'Osmaniye', '', '80', 'state', 1),
(3918, 'state_D__zce_3918', 'DĂŒzce',
'DĂŒzce', '', '81', 'state', 1),
(3919, 'state_Ahal_wela__aty_3919', 'Ahal welaĂœaty',
'Ahal welaĂœaty', '', 'A', 'state',
1),
(3920, 'state_Balkan_wela__aty_3920', 'Balkan
welaĂœaty', 'Balkan welaĂœaty', '', 'B',
'state', 1),
(3921, 'state_Da__oguz_wela__aty_3921', 'DaĆoguz
welaĂœaty', 'DaĆoguz welaĂœaty', '',
'D', 'state', 1),
(3922, 'state_Lebap_wela__aty_3922', 'Lebap welaĂœaty',
'Lebap welaĂœaty', '', 'L',
'state', 1),
(3923, 'state_Mary_wela__aty_3923', 'Mary welaĂœaty',
'Mary welaĂœaty', '', 'M', 'state',
1),
(3924, 'state_Ambergris_Cays_3924', 'Ambergris Cays',
'Ambergris Cays', '', 'AC',
'state', 1),
(3925, 'state_Dellis_Cay_3925', 'Dellis Cay',
'Dellis Cay', '', 'DC', 'state',
1),
(3926, 'state_French_Cay_3926', 'French Cay',
'French Cay', '', 'FC', 'state',
1),
(3927, 'state_Little_Water_Cay_3927', 'Little Water
Cay', 'Little Water Cay', '', 'LW',
'state', 1),
(3928, 'state_Parrot_Cay_3928', 'Parrot Cay',
'Parrot Cay', '', 'RC', 'state',
1),
(3929, 'state_Pine_Cay_3929', 'Pine Cay', 'Pine
Cay', '', 'PN', 'state', 1),
(3930, 'state_Salt_Cay_3930', 'Salt Cay', 'Salt
Cay', '', 'SL', 'state', 1),
(3931, 'state_Grand_Turk_3931', 'Grand Turk',
'Grand Turk', '', 'GT', 'state',
1),
(3932, 'state_South_Caicos_3932', 'South Caicos',
'South Caicos', '', 'SC', 'state',
1),
(3933, 'state_East_Caicos_3933', 'East Caicos',
'East Caicos', '', 'EC', 'state',
1),
(3934, 'state_Middle_Caicos_3934', 'Middle Caicos',
'Middle Caicos', '', 'MC', 'state',
1),
(3935, 'state_North_Caicos_3935', 'North Caicos',
'North Caicos', '', 'NC', 'state',
1),
(3936, 'state_Providenciales_3936', 'Providenciales',
'Providenciales', '', 'PR',
'state', 1),
(3937, 'state_West_Caicos_3937', 'West Caicos',
'West Caicos', '', 'WC', 'state',
1),
(3938, 'state_Funafuti_3938', 'Funafuti',
'Funafuti', '', 'FUN', 'state',
1),
(3939, 'state_Nanumea_3939', 'Nanumea',
'Nanumea', '', 'NMA', 'state', 1),
(3940, 'state_Nanumanga_3940', 'Nanumanga',
'Nanumanga', '', 'NMG', 'state',
1),
(3941, 'state_Niutao_3941', 'Niutao',
'Niutao', '', 'NIT', 'state', 1),
(3942, 'state_Nui_3942', 'Nui', 'Nui',
'', 'NIU', 'state', 1),
(3943, 'state_Nukufetau_3943', 'Nukufetau',
'Nukufetau', '', 'NKF', 'state',
1),
(3944, 'state_Nukulaelae_3944', 'Nukulaelae',
'Nukulaelae', '', 'NKL', 'state',
1),
(3945, 'state_Vaitupu_3945', 'Vaitupu',
'Vaitupu', '', 'VAI', 'state', 1),
(3946, 'state_Kalangala_3946', 'Kalangala',
'Kalangala', '', '101', 'state',
1),
(3947, 'state_Kampala_3947', 'Kampala',
'Kampala', '', '102', 'state', 1),
(3948, 'state_Kiboga_3948', 'Kiboga',
'Kiboga', '', '103', 'state', 1),
(3949, 'state_Luwero_3949', 'Luwero',
'Luwero', '', '104', 'state', 1),
(3950, 'state_Masaka_3950', 'Masaka',
'Masaka', '', '105', 'state', 1),
(3951, 'state_Mpigi_3951', 'Mpigi', 'Mpigi',
'', '106', 'state', 1),
(3952, 'state_Mubende_3952', 'Mubende',
'Mubende', '', '107', 'state', 1),
(3953, 'state_Mukono_3953', 'Mukono',
'Mukono', '', '108', 'state', 1),
(3954, 'state_Nakasongola_3954', 'Nakasongola',
'Nakasongola', '', '109', 'state',
1),
(3955, 'state_Rakai_3955', 'Rakai', 'Rakai',
'', '110', 'state', 1),
(3956, 'state_Sembabule_3956', 'Sembabule',
'Sembabule', '', '111', 'state',
1),
(3957, 'state_Kayunga_3957', 'Kayunga',
'Kayunga', '', '112', 'state', 1),
(3958, 'state_Wakiso_3958', 'Wakiso',
'Wakiso', '', '113', 'state', 1),
(3959, 'state_Bugiri_3959', 'Bugiri',
'Bugiri', '', '201', 'state', 1),
(3960, 'state_Busia_3960', 'Busia', 'Busia',
'', '202', 'state', 1),
(3961, 'state_Iganga_3961', 'Iganga',
'Iganga', '', '203', 'state', 1),
(3962, 'state_Jinja_3962', 'Jinja', 'Jinja',
'', '204', 'state', 1),
(3963, 'state_Kamuli_3963', 'Kamuli',
'Kamuli', '', '205', 'state', 1),
(3964, 'state_Kapchorwa_3964', 'Kapchorwa',
'Kapchorwa', '', '206', 'state',
1),
(3965, 'state_Katakwi_3965', 'Katakwi',
'Katakwi', '', '207', 'state', 1),
(3966, 'state_Kumi_3966', 'Kumi', 'Kumi',
'', '208', 'state', 1),
(3967, 'state_Mbale_3967', 'Mbale', 'Mbale',
'', '209', 'state', 1),
(3968, 'state_Pallisa_3968', 'Pallisa',
'Pallisa', '', '210', 'state', 1),
(3969, 'state_Soroti_3969', 'Soroti',
'Soroti', '', '211', 'state', 1),
(3970, 'state_Tororo_3970', 'Tororo',
'Tororo', '', '212', 'state', 1),
(3971, 'state_Kaberamaido_3971', 'Kaberamaido',
'Kaberamaido', '', '213', 'state',
1),
(3972, 'state_Mayuge_3972', 'Mayuge',
'Mayuge', '', '214', 'state', 1),
(3973, 'state_Sironko_3973', 'Sironko',
'Sironko', '', '215', 'state', 1),
(3974, 'state_Adjumani_3974', 'Adjumani',
'Adjumani', '', '301', 'state',
1),
(3975, 'state_Apac_3975', 'Apac', 'Apac',
'', '302', 'state', 1),
(3976, 'state_Arua_3976', 'Arua', 'Arua',
'', '303', 'state', 1),
(3977, 'state_Gulu_3977', 'Gulu', 'Gulu',
'', '304', 'state', 1),
(3978, 'state_Kitgum_3978', 'Kitgum',
'Kitgum', '', '305', 'state', 1),
(3979, 'state_Kotido_3979', 'Kotido',
'Kotido', '', '306', 'state', 1),
(3980, 'state_Lira_3980', 'Lira', 'Lira',
'', '307', 'state', 1),
(3981, 'state_Moroto_3981', 'Moroto',
'Moroto', '', '308', 'state', 1),
(3982, 'state_Moyo_3982', 'Moyo', 'Moyo',
'', '309', 'state', 1),
(3983, 'state_Nebbi_3983', 'Nebbi', 'Nebbi',
'', '310', 'state', 1),
(3984, 'state_Nakapiripirit_3984', 'Nakapiripirit',
'Nakapiripirit', '', '311',
'state', 1),
(3985, 'state_Pader_3985', 'Pader', 'Pader',
'', '312', 'state', 1),
(3986, 'state_Yumbe_3986', 'Yumbe', 'Yumbe',
'', '313', 'state', 1),
(3987, 'state_Bundibugyo_3987', 'Bundibugyo',
'Bundibugyo', '', '401', 'state',
1),
(3988, 'state_Bushenyi_3988', 'Bushenyi',
'Bushenyi', '', '402', 'state',
1),
(3989, 'state_Hoima_3989', 'Hoima', 'Hoima',
'', '403', 'state', 1),
(3990, 'state_Kabale_3990', 'Kabale',
'Kabale', '', '404', 'state', 1),
(3991, 'state_Kabarole_3991', 'Kabarole',
'Kabarole', '', '405', 'state',
1),
(3992, 'state_Kasese_3992', 'Kasese',
'Kasese', '', '406', 'state', 1),
(3993, 'state_Kibale_3993', 'Kibale',
'Kibale', '', '407', 'state', 1),
(3994, 'state_Kisoro_3994', 'Kisoro',
'Kisoro', '', '408', 'state', 1),
(3995, 'state_Masindi_3995', 'Masindi',
'Masindi', '', '409', 'state', 1),
(3996, 'state_Mbarara_3996', 'Mbarara',
'Mbarara', '', '410', 'state', 1),
(3997, 'state_Ntungamo_3997', 'Ntungamo',
'Ntungamo', '', '411', 'state',
1),
(3998, 'state_Rukungiri_3998', 'Rukungiri',
'Rukungiri', '', '412', 'state',
1),
(3999, 'state_Kamwenge_3999', 'Kamwenge',
'Kamwenge', '', '413', 'state',
1);";
$this->db->setQuery($query);
$this->db->query();
$query="
INSERT IGNORE INTO `#__hikashop_zone` (`zone_id`, `zone_namekey`,
`zone_name`, `zone_name_english`, `zone_code_2`, `zone_code_3`,
`zone_type`, `zone_published`) VALUES
(4000, 'state_Kanungu_4000', 'Kanungu',
'Kanungu', '', '414', 'state', 1),
(4001, 'state_Kyenjojo_4001', 'Kyenjojo',
'Kyenjojo', '', '415', 'state',
1),
(4002, 'state___________________________________4002',
'ĐŃĐœĐœĐžŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐŃĐœĐœĐžŃŃĐșа
ĐŸĐ±Đ»Đ°ŃŃŃ', '', '05', 'state', 1),
(4003, 'state___________________________________4003',
'ĐĐŸĐ»ĐžĐœŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐĐŸĐ»ĐžĐœŃŃĐșа
ĐŸĐ±Đ»Đ°ŃŃŃ', '', '07', 'state', 1),
(4004, 'state___________________________________4004',
'ĐŃĐłĐ°ĐœŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐŃĐłĐ°ĐœŃŃĐșа
ĐŸĐ±Đ»Đ°ŃŃŃ', '', '09', 'state', 1),
(4005,
'state_________________________________________________4005',
'ĐĐœŃĐżŃĐŸĐżĐ”ŃŃĐŸĐČŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐĐœŃĐżŃĐŸĐżĐ”ŃŃĐŸĐČŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'12', 'state', 1),
(4006, 'state_________________________________4006',
'ĐĐŸĐœĐ”ŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐĐŸĐœĐ”ŃŃĐșа
ĐŸĐ±Đ»Đ°ŃŃŃ', '', '14', 'state', 1),
(4007, 'state_______________________________________4007',
'ĐĐžŃĐŸĐŒĐžŃŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐĐžŃĐŸĐŒĐžŃŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'18', 'state', 1),
(4008, 'state_____________________________________4008',
'Đ ŃĐČĐœĐ”ĐœŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', 'Đ ŃĐČĐœĐ”ĐœŃŃĐșа
ĐŸĐ±Đ»Đ°ŃŃŃ', '', '19', 'state', 1),
(4009, 'state_________________________________________4009',
'ĐаĐșаŃпаŃŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐаĐșаŃпаŃŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'21', 'state', 1),
(4010, 'state_____________________________________4010',
'ĐĐ°ĐżĐŸŃŃĐ·ŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐĐ°ĐżĐŸŃŃĐ·ŃĐșа
ĐŸĐ±Đ»Đ°ŃŃŃ', '', '23', 'state', 1),
(4011,
'state__________________________________________________4011',
'ĐĐČĐ°ĐœĐŸ-Đ€ŃĐ°ĐœĐșŃĐČŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐĐČĐ°ĐœĐŸ-Đ€ŃĐ°ĐœĐșŃĐČŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'26', 'state', 1),
(4012, 'state__________4012', 'ĐĐžŃĐČ',
'ĐĐžŃĐČ', '', '30', 'state', 1),
(4013, 'state_________________________________4013',
'ĐĐžŃĐČŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐĐžŃĐČŃŃĐșа
ĐŸĐ±Đ»Đ°ŃŃŃ', '', '32', 'state', 1),
(4014, 'state_____________________________________________4014',
'ĐŃŃĐŸĐČĐŸĐłŃаЎŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐŃŃĐŸĐČĐŸĐłŃаЎŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'35', 'state', 1),
(4015, 'state________________________4015',
'ĐĄĐ”ĐČаŃŃĐŸĐżĐŸĐ»Ń', 'ĐĄĐ”ĐČаŃŃĐŸĐżĐŸĐ»Ń',
'', '40', 'state', 1),
(4016,
'state____________________________________________________4016',
'ĐĐČŃĐŸĐœĐŸĐŒĐœĐ°Ń Đ Đ”ŃĐżŃблОĐșа ĐŃŃĐŒ',
'ĐĐČŃĐŸĐœĐŸĐŒĐœĐ°Ń Đ Đ”ŃĐżŃблОĐșа ĐŃŃĐŒ',
'', '43', 'state', 1),
(4017, 'state___________________________________4017',
'ĐŃĐČŃĐČŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐŃĐČŃĐČŃŃĐșа
ĐŸĐ±Đ»Đ°ŃŃŃ', '', '46', 'state', 1),
(4018, 'state_________________________________________4018',
'ĐĐžĐșĐŸĐ»Đ°ŃĐČŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ',
'ĐĐžĐșĐŸĐ»Đ°ŃĐČŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'48', 'state', 1),
(4019, 'state_______________________________4019',
'ĐĐŽĐ”ŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐĐŽĐ”ŃŃĐșа
ĐŸĐ±Đ»Đ°ŃŃŃ', '', '51', 'state', 1),
(4020, 'state_____________________________________4020',
'ĐĐŸĐ»ŃаĐČŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐĐŸĐ»ŃаĐČŃŃĐșа
ĐŸĐ±Đ»Đ°ŃŃŃ', '', '53', 'state', 1),
(4021, 'state_______________________________4021',
'ĐĄŃĐŒŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', 'ĐĄŃĐŒŃŃĐșа
ĐŸĐ±Đ»Đ°ŃŃŃ', '', '59', 'state', 1),
(4022, 'state___________________________________________4022',
'йДŃĐœĐŸĐżŃĐ»ŃŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ',
'йДŃĐœĐŸĐżŃĐ»ŃŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'61', 'state', 1),
(4023, 'state_____________________________________4023',
'ЄаŃĐșŃĐČŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', 'ЄаŃĐșŃĐČŃŃĐșа
ĐŸĐ±Đ»Đ°ŃŃŃ', '', '63', 'state', 1),
(4024, 'state_____________________________________4024',
'ЄДŃŃĐŸĐœŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', 'ЄДŃŃĐŸĐœŃŃĐșа
ĐŸĐ±Đ»Đ°ŃŃŃ', '', '65', 'state', 1),
(4025, 'state_______________________________________4025',
'Đ„ĐŒĐ”Đ»ŃĐœĐžŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ',
'Đ„ĐŒĐ”Đ»ŃĐœĐžŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'68', 'state', 1),
(4026, 'state___________________________________4026',
'ЧДŃĐșаŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', 'ЧДŃĐșаŃŃĐșа
ĐŸĐ±Đ»Đ°ŃŃŃ', '', '71', 'state', 1),
(4027, 'state_________________________________________4027',
'ЧДŃĐœŃĐłŃĐČŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ',
'ЧДŃĐœŃĐłŃĐČŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'74', 'state', 1),
(4028, 'state_______________________________________4028',
'ЧДŃĐœŃĐČĐ”ŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ',
'ЧДŃĐœŃĐČĐ”ŃŃĐșа ĐŸĐ±Đ»Đ°ŃŃŃ', '',
'77', 'state', 1),
(4031, 'state_Argyll_and_Bute_4031', 'Argyll and Bute',
'Argyll and Bute', '', 'AGB',
'state', 1),
(4037, 'state_Bath_and_North_East_Somerset_4037', 'Bath and
North East Somerset', 'Bath and North East Somerset',
'', 'BAS', 'state', 1),
(4039, 'state_Bedfordshire_4039', 'Bedfordshire',
'Bedfordshire', '', 'BDF', 'state',
1),
(4040, 'state_Berkshire_4040', 'Berkshire',
'Berkshire', '', 'BRK', 'state',
1),
(4045, 'state_Blaenau_Gwent_4045', 'Blaenau Gwent',
'Blaenau Gwent', '', 'BGW',
'state', 1),
(4055, 'state_Borders_4055', 'Borders',
'Borders', '', 'BOR', 'state', 1),
(4060, 'state_Bristol_4060', 'Bristol',
'Bristol', '', 'BST', 'state', 1),
(4061, 'state_Buckinghamshire_4061', 'Buckinghamshire',
'Buckinghamshire', '', 'BKM',
'state', 1),
(4062, 'state_Cambridgeshire_4062', 'Cambridgeshire',
'Cambridgeshire', '', 'CAM',
'state', 1),
(4074, 'state_Carmarthenshire_4074', 'Carmarthenshire',
'Carmarthenshire', '', 'CMN',
'state', 1),
(4064, 'state_Ceredigion_4064', 'Ceredigion',
'Ceredigion', '', 'CGN', 'state',
1),
(4066, 'state_Cheshire_4066', 'Cheshire',
'Cheshire', '', 'CHS', 'state',
1),
(4080, 'state_Conwy_4080', 'Conwy', 'Conwy',
'', 'CWY', 'state', 1),
(4075, 'state_Cornwall_4075', 'Cornwall',
'Cornwall', '', 'CON', 'state',
1),
(4034, 'state_Antrim_4034', 'County Antrim',
'County Antrim', '', 'ANT',
'state', 1),
(4091, 'state_Down_4091', 'County Down', 'County
Down', '', 'DOW', 'state', 1),
(4094, 'state_Durham_4094', 'County Durham',
'County Durham', '', 'DUR',
'state', 1),
(4107, 'state_Fermanagh_4107', 'County Fermanagh',
'County Fermanagh', '', 'FER',
'state', 1),
(4063, 'state_Londonderry_4063', 'County Londonderry',
'County Londonderry', '', 'LDY',
'state', 1),
(4065, 'state_Tyrone_4065', 'County Tyrone',
'County Tyrone', '', 'TYR',
'state', 1),
(4072, 'state_Cumbria_4072', 'Cumbria',
'Cumbria', '', 'CMA', 'state', 1),
(4083, 'state_Denbighshire_4083', 'Denbighshire',
'Denbighshire', '', 'DEN', 'state',
1),
(4082, 'state_Derbyshire_4082', 'Derbyshire',
'Derbyshire', '', 'DBY', 'state',
1),
(4085, 'state_Devon_4085', 'Devon', 'Devon',
'', 'DEV', 'state', 1),
(4090, 'state_Dorset_4090', 'Dorset',
'Dorset', '', 'DOR', 'state', 1),
(4067, 'state_Dumbarton_4065', 'Dumbarton and
Clydebank', 'Dumbarton and Clydebank', '',
'DNB', 'state', 1),
(4087, 'state_Dumfries_and_Galloway_4087', 'Dumfries and
Galloway', 'Dumfries and Galloway', '',
'DGY', 'state', 1),
(4093, 'state_Dyfed_4093', 'Dyfed', 'Dyfed',
'', 'DFD', 'state', 1),
(4096, 'state_East_Ayrshire_4096', 'East Ayrshire',
'East Ayrshire', '', 'EAY',
'state', 1),
(4098, 'state_East_Dunbartonshire_4098', 'East
Dunbartonshire', 'East Dunbartonshire', '',
'EDU', 'state', 1),
(4102, 'state_East_Renfrewshire_4102', 'East
Renfrewshire', 'East Renfrewshire', '',
'ERW', 'state', 1),
(4103, 'state_East_Riding_of_Yorkshire_4103', 'East Riding
of Yorkshire', 'East Riding of Yorkshire', '',
'ERY', 'state', 1),
(4105, 'state_East_Sussex_4105', 'East Sussex',
'East Sussex', '', 'ESX', 'state',
1),
(4097, 'state_Edinburgh_4097', 'Edinburgh',
'Edinburgh', '', 'EDH', 'state',
1),
(4104, 'state_Essex_4104', 'Essex', 'Essex',
'', 'ESS', 'state', 1),
(4108, 'state_Fife_4108', 'Fife', 'Fife',
'', 'FIF', 'state', 1),
(4109, 'state_Flintshire_4109', 'Flintshire',
'Flintshire', '', 'FLN', 'state',
1),
(4068, 'state_Glamorgan_4068', 'Glamorgan',
'Glamorgan', '', 'GLA', 'state',
1),
(4111, 'state_Glasgow_4111', 'Glasgow',
'Glasgow', '', 'GLG', 'state', 1),
(4112, 'state_Gloucestershire_4112', 'Gloucestershire',
'Gloucestershire', '', 'GLS',
'state', 1),
(4110, 'state_Grampian_4110', 'Grampian',
'Grampian', '', 'GMP', 'state',
1),
(4113, 'state_Greater_Manchester_4113', 'Greater
Manchester', 'Greater Manchester', '',
'GTM', 'state', 1),
(4114, 'state_Gwent_4114', 'Gwent', 'Gwent',
'', 'GNT', 'state', 1),
(4115, 'state_Gwynedd_4115', 'Gwynedd',
'Gwynedd', '', 'GWN', 'state', 1),
(4117, 'state_Hampshire_4117', 'Hampshire',
'Hampshire', '', 'HAM', 'state',
1),
(4120, 'state_Herefordshire_4120', 'Herefordshire',
'Herefordshire', '', 'HEF',
'state', 1),
(4126, 'state_Hertfordshire_4126', 'Hertfordshire',
'Hertfordshire', '', 'HRT',
'state', 1),
(4132, 'state_Inverclyde_4132', 'Inverclyde',
'Inverclyde', '', 'IVC', 'state',
1),
(4130, 'state_Isle_of_Wight_4130', 'Isle of Wight',
'Isle of Wight', '', 'IOW',
'state', 1),
(4135, 'state_Kent_4135', 'Kent', 'Kent',
'', 'KEN', 'state', 1),
(4140, 'state_Lancashire_4140', 'Lancashire',
'Lancashire', '', 'LAN', 'state',
1),
(4144, 'state_Leicestershire_4144', 'Leicestershire',
'Leicestershire', '', 'LEC',
'state', 1),
(4146, 'state_Lincolnshire_4146', 'Lincolnshire',
'Lincolnshire', '', 'LIN', 'state',
1),
(4149, 'state_London_4149', 'London',
'London', '', 'LND', 'state', 1),
(4153, 'state_Manchester_4153', 'Manchester',
'Manchester', '', 'MAN', 'state',
1),
(4069, 'state_Middlesex_4069', 'Middlesex',
'Middlesex', '', 'MDX', 'state',
1),
(4070, 'state_Merseyside_4070', 'Merseyside',
'Merseyside', '', 'MSY', 'state',
1),
(4169, 'state_Norfolk_4169', 'Norfolk',
'Norfolk', '', 'NFK', 'state', 1),
(4164, 'state_North_Ayrshire_4164', 'North Ayrshire',
'North Ayrshire', '', 'NAY',
'state', 1),
(4171, 'state_North_Lanarkshire_4171', 'North
Lanarkshire', 'North Lanarkshire', '',
'NLK', 'state', 1),
(4071, 'state_North_West_Highlands_4071', 'North West
Highlands', 'North West Highlands', '',
'NWH', 'state', 1),
(4181, 'state_North_Yorkshire_4181', 'North Yorkshire',
'North Yorkshire', '', 'NYK',
'state', 1),
(4175, 'state_Northamptonshire_4175',
'Northamptonshire', 'Northamptonshire', '',
'NTH', 'state', 1),
(4165, 'state_Northumberland_4165', 'Northumberland',
'Northumberland', '', 'NBL',
'state', 1),
(4177, 'state_Nottinghamshire_4177', 'Nottinghamshire',
'Nottinghamshire', '', 'NTT',
'state', 1),
(4186, 'state_Oxfordshire_4186', 'Oxfordshire',
'Oxfordshire', '', 'OXF', 'state',
1),
(4187, 'state_Pembrokeshire_4187', 'Pembrokeshire',
'Pembrokeshire', '', 'PEM',
'state', 1),
(4192, 'state_Powys_4192', 'Powys', 'Powys',
'', 'POW', 'state', 1),
(4199, 'state_Renfrewshire_4199', 'Renfrewshire',
'Renfrewshire', '', 'RFW', 'state',
1),
(4196, 'state_Rhondda_Cynon_Taf_4196', 'Rhondda Cynon
Taf', 'Rhondda Cynon Taf', '', 'RCT',
'state', 1),
(4211, 'state_Shropshire_4211', 'Shropshire',
'Shropshire', '', 'SHR', 'state',
1),
(4218, 'state_Somerset_4218', 'Somerset',
'Somerset', '', 'SOM', 'state',
1),
(4204, 'state_South_Ayrshire_4204', 'South Ayrshire',
'South Ayrshire', '', 'SAY',
'state', 1),
(4208, 'state_South_Gloucestershire_4208', 'South
Gloucestershire', 'South Gloucestershire', '',
'SGC', 'state', 1),
(4215, 'state_South_Lanarkshire_4215', 'South
Lanarkshire', 'South Lanarkshire', '',
'SLK', 'state', 1),
(4228, 'state_South_Yorkshire_4228', 'South Yorkshire',
'South Yorkshire', '', 'SYK',
'state', 1),
(4226, 'state_Staffordshire_4226', 'Staffordshire',
'Staffordshire', '', 'STS',
'state', 1),
(4206, 'state_Suffolk_4206', 'Suffolk',
'Suffolk', '', 'SFK', 'state', 1),
(4220, 'state_Surrey_4220', 'Surrey',
'Surrey', '', 'SRY', 'state', 1),
(4235, 'state_Tayside_4235', 'Tayside',
'Tayside', '', 'TAY', 'state', 1),
(4236, 'state_Torfaen_4236', 'Torfaen',
'Torfaen', '', 'TOF', 'state', 1),
(4237, 'state_Tyne_and_Wear_4237', 'Tyne & Wear',
'Tyne & Wear', '', 'TWR',
'state', 1),
(4240, 'state_Warwickshire_4240', 'Warwickshire',
'Warwickshire', '', 'WAR', 'state',
1),
(4248, 'state_West_Lothian_4248', 'West Lothian',
'West Lothian', '', 'WLN', 'state',
1),
(4073, 'state_West_Midlands_4073', 'West Midlands',
'West Midlands', '', 'WMD',
'state', 1),
(4257, 'state_West_Sussex_4257', 'West Sussex',
'West Sussex', '', 'WSX', 'state',
1),
(4076, 'state_West_Yorkshire_4076', 'West Yorkshire',
'West Yorkshire', '', 'WYK',
'state', 1),
(4245, 'state_Wiltshire_4245', 'Wiltshire',
'Wiltshire', '', 'WIL', 'state',
1),
(4252, 'state_Worcestershire_4252', 'Worcestershire',
'Worcestershire', '', 'WOR',
'state', 1),
(4260, 'state_Alaska_4260', 'Alaska',
'Alaska', '', 'AK', 'state', 1),
(4261, 'state_Alabama_4261', 'Alabama',
'Alabama', '', 'AL', 'state', 1),
(4262, 'state_American_Samoa_4262', 'American Samoa',
'American Samoa', '', 'AS',
'state', 1),
(4263, 'state_Arkansas_4263', 'Arkansas',
'Arkansas', '', 'AR', 'state', 1),
(4264, 'state_Arizona_4264', 'Arizona',
'Arizona', '', 'AZ', 'state', 1),
(4265, 'state_California_4265', 'California',
'California', '', 'CA', 'state',
1),
(4266, 'state_Colorado_4266', 'Colorado',
'Colorado', '', 'CO', 'state', 1),
(4267, 'state_Connecticut_4267', 'Connecticut',
'Connecticut', '', 'CT', 'state',
1),
(4268, 'state_District_of_Columbia_4268', 'District of
Columbia', 'District of Columbia', '',
'DC', 'state', 1),
(4269, 'state_Delaware_4269', 'Delaware',
'Delaware', '', 'DE', 'state', 1),
(4270, 'state_Florida_4270', 'Florida',
'Florida', '', 'FL', 'state', 1),
(4271, 'state_Georgia_4271', 'Georgia',
'Georgia', '', 'GA', 'state', 1),
(4272, 'state_Guam_4272', 'Guam', 'Guam',
'', 'GU', 'state', 1),
(4273, 'state_Hawaii_4273', 'Hawaii',
'Hawaii', '', 'HI', 'state', 1),
(4274, 'state_Iowa_4274', 'Iowa', 'Iowa',
'', 'IA', 'state', 1),
(4275, 'state_Idaho_4275', 'Idaho', 'Idaho',
'', 'ID', 'state', 1),
(4276, 'state_Illinois_4276', 'Illinois',
'Illinois', '', 'IL', 'state', 1),
(4277, 'state_Indiana_4277', 'Indiana',
'Indiana', '', 'IN', 'state', 1),
(4278, 'state_Kansas_4278', 'Kansas',
'Kansas', '', 'KS', 'state', 1),
(4279, 'state_Kentucky_4279', 'Kentucky',
'Kentucky', '', 'KY', 'state', 1),
(4280, 'state_Louisiana_4280', 'Louisiana',
'Louisiana', '', 'LA', 'state',
1),
(4281, 'state_Massachusetts_4281', 'Massachusetts',
'Massachusetts', '', 'MA', 'state',
1),
(4282, 'state_Maryland_4282', 'Maryland',
'Maryland', '', 'MD', 'state', 1),
(4283, 'state_Maine_4283', 'Maine', 'Maine',
'', 'ME', 'state', 1),
(4284, 'state_Michigan_4284', 'Michigan',
'Michigan', '', 'MI', 'state', 1),
(4285, 'state_Minnesota_4285', 'Minnesota',
'Minnesota', '', 'MN', 'state',
1),
(4286, 'state_Missouri_4286', 'Missouri',
'Missouri', '', 'MO', 'state', 1),
(4287, 'state_Mississippi_4287', 'Mississippi',
'Mississippi', '', 'MS', 'state',
1),
(4288, 'state_Montana_4288', 'Montana',
'Montana', '', 'MT', 'state', 1),
(4289, 'state_North_Carolina_4289', 'North Carolina',
'North Carolina', '', 'NC',
'state', 1),
(4290, 'state_North_Dakota_4290', 'North Dakota',
'North Dakota', '', 'ND', 'state',
1),
(4291, 'state_Nebraska_4291', 'Nebraska',
'Nebraska', '', 'NE', 'state', 1),
(4292, 'state_New_Hampshire_4292', 'New Hampshire',
'New Hampshire', '', 'NH', 'state',
1),
(4293, 'state_New_Jersey_4293', 'New Jersey', 'New
Jersey', '', 'NJ', 'state', 1),
(4294, 'state_New_Mexico_4294', 'New Mexico', 'New
Mexico', '', 'NM', 'state', 1),
(4295, 'state_Nevada_4295', 'Nevada',
'Nevada', '', 'NV', 'state', 1),
(4296, 'state_New_York_4296', 'New York', 'New
York', '', 'NY', 'state', 1),
(4297, 'state_Northern_Mariana_Islands_4297', 'Northern
Mariana Islands', 'Northern Mariana Islands', '',
'MP', 'state', 1),
(4298, 'state_Ohio_4298', 'Ohio', 'Ohio',
'', 'OH', 'state', 1),
(4299, 'state_Oklahoma_4299', 'Oklahoma',
'Oklahoma', '', 'OK', 'state', 1),
(4300, 'state_Oregon_4300', 'Oregon',
'Oregon', '', 'OR', 'state', 1),
(4301, 'state_Pennsylvania_4301', 'Pennsylvania',
'Pennsylvania', '', 'PA', 'state',
1),
(4302, 'state_Puerto_Rico_4302', 'Puerto Rico',
'Puerto Rico', '', 'PR', 'state',
1),
(4303, 'state_Rhode_Island_4303', 'Rhode Island',
'Rhode Island', '', 'RI', 'state',
1),
(4304, 'state_South_Carolina_4304', 'South Carolina',
'South Carolina', '', 'SC',
'state', 1),
(4305, 'state_South_Dakota_4305', 'South Dakota',
'South Dakota', '', 'SD', 'state',
1),
(4306, 'state_Tennessee_4306', 'Tennessee',
'Tennessee', '', 'TN', 'state',
1),
(4307, 'state_Texas_4307', 'Texas', 'Texas',
'', 'TX', 'state', 1),
(4308, 'state_U_S__Minor_Outlying_Islands_4308', 'U.S. Minor
Outlying Islands', 'U.S. Minor Outlying Islands',
'', 'UM', 'state', 1),
(4309, 'state_Utah_4309', 'Utah', 'Utah',
'', 'UT', 'state', 1),
(4310, 'state_Virginia_4310', 'Virginia',
'Virginia', '', 'VA', 'state', 1),
(4311, 'state_Virgin_Islands_of_the_U_S__4311', 'Virgin
Islands of the U.S.', 'Virgin Islands of the U.S.',
'', 'VI', 'state', 1),
(4312, 'state_Vermont_4312', 'Vermont',
'Vermont', '', 'VT', 'state', 1),
(4313, 'state_Washington_4313', 'Washington',
'Washington', '', 'WA', 'state',
1),
(4314, 'state_Wisconsin_4314', 'Wisconsin',
'Wisconsin', '', 'WI', 'state',
1),
(4315, 'state_West_Virginia_4315', 'West Virginia',
'West Virginia', '', 'WV', 'state',
1),
(4316, 'state_Wyoming_4316', 'Wyoming',
'Wyoming', '', 'WY', 'state', 1),
(4317, 'state_Baker_Island_4317', 'Baker Island',
'Baker Island', '', 'BI', 'state',
1),
(4318, 'state_Howland_Island_4318', 'Howland Island',
'Howland Island', '', 'HI',
'state', 1),
(4319, 'state_Jarvis_Island_4319', 'Jarvis Island',
'Jarvis Island', '', 'JI', 'state',
1),
(4320, 'state_Johnston_Atoll_4320', 'Johnston Atoll',
'Johnston Atoll', '', 'JA',
'state', 1),
(4321, 'state_Kingman_Reef_4321', 'Kingman Reef',
'Kingman Reef', '', 'KR', 'state',
1),
(4322, 'state_Midway_Atoll_4322', 'Midway Atoll',
'Midway Atoll', '', 'MA', 'state',
1),
(4323, 'state_Navassa_Island_4323', 'Navassa Island',
'Navassa Island', '', 'NI',
'state', 1),
(4324, 'state_Palmyra_Atoll_4324', 'Palmyra Atoll',
'Palmyra Atoll', '', 'PA', 'state',
1),
(4325, 'state_Wake_Island_4325', 'Wake Island',
'Wake Island', '', 'WI', 'state',
1),
(4326, 'state_Artigas_4326', 'Artigas',
'Artigas', '', 'AR', 'state', 1),
(4327, 'state_Canelones_4327', 'Canelones',
'Canelones', '', 'CA', 'state',
1),
(4328, 'state_Cerro_Largo_4328', 'Cerro Largo',
'Cerro Largo', '', 'CL', 'state',
1),
(4329, 'state_Colonia_4329', 'Colonia',
'Colonia', '', 'CO', 'state', 1),
(4330, 'state_Durazno_4330', 'Durazno',
'Durazno', '', 'DU', 'state', 1),
(4331, 'state_Florida_4331', 'Florida',
'Florida', '', 'FD', 'state', 1),
(4332, 'state_Flores_4332', 'Flores',
'Flores', '', 'FS', 'state', 1),
(4333, 'state_Lavalleja_4333', 'Lavalleja',
'Lavalleja', '', 'LA', 'state',
1),
(4334, 'state_Maldonado_4334', 'Maldonado',
'Maldonado', '', 'MA', 'state',
1),
(4335, 'state_Montevideo_4335', 'Montevideo',
'Montevideo', '', 'MO', 'state',
1),
(4336, 'state_Paysandu_4336', 'Paysandu',
'Paysandu', '', 'PA', 'state', 1),
(4337, 'state_R__o_Negro_4337', 'RĂo Negro',
'RĂo Negro', '', 'RN', 'state',
1),
(4338, 'state_Rocha_4338', 'Rocha', 'Rocha',
'', 'RO', 'state', 1),
(4339, 'state_Rivera_4339', 'Rivera',
'Rivera', '', 'RV', 'state', 1),
(4340, 'state_Salto_4340', 'Salto', 'Salto',
'', 'SA', 'state', 1),
(4342, 'state_Soriano_4342', 'Soriano',
'Soriano', '', 'SO', 'state', 1),
(4343, 'state_Tacuaremb___4343', 'TacuarembĂł',
'TacuarembĂł', '', 'TA', 'state',
1),
(4344, 'state_Treinta_y_Tres_4344', 'Treinta y Tres',
'Treinta y Tres', '', 'TT',
'state', 1),
(4345, 'state_Andijon_viloyati_4345', 'Andijon
viloyati', 'Andijon viloyati', '', 'AN',
'state', 1),
(4346, 'state_Buxoro_viloyati_4346', 'Buxoro viloyati',
'Buxoro viloyati', '', 'BU',
'state', 1),
(4347, 'state_Farg_ona_viloyati_4347', 'Farg''ona
viloyati', 'Farg''ona viloyati', '',
'FA', 'state', 1),
(4348, 'state_Jizzax_viloyati_4348', 'Jizzax viloyati',
'Jizzax viloyati', '', 'JI',
'state', 1),
(4349, 'state_Namangan_viloyati_4349', 'Namangan
viloyati', 'Namangan viloyati', '',
'NG', 'state', 1),
(4350, 'state_Navoiy_viloyati_4350', 'Navoiy viloyati',
'Navoiy viloyati', '', 'NW',
'state', 1),
(4351, 'state_Qashqadaryo_viloyati_4351', 'Qashqadaryo
viloyati', 'Qashqadaryo viloyati', '',
'QA', 'state', 1),
(4352, 'state_Qoraqalpog_iston_Respublikasi_4352',
'Qoraqalpog''iston Respublikasi',
'Qoraqalpog''iston Respublikasi', '',
'QR', 'state', 1),
(4353, 'state_Samarqand_viloyati_4353', 'Samarqand
viloyati', 'Samarqand viloyati', '',
'SA', 'state', 1),
(4354, 'state_Sirdaryo_viloyati_4354', 'Sirdaryo
viloyati', 'Sirdaryo viloyati', '',
'SI', 'state', 1),
(4355, 'state_Surxondaryo_viloyati_4355', 'Surxondaryo
viloyati', 'Surxondaryo viloyati', '',
'SU', 'state', 1),
(4356, 'state_Toshkent_4356', 'Toshkent',
'Toshkent', '', 'TK', 'state', 1),
(4357, 'state_Toshkent_viloyati_4357', 'Toshkent
viloyati', 'Toshkent viloyati', '',
'TO', 'state', 1),
(4358, 'state_Xorazm_viloyati_4358', 'Xorazm viloyati',
'Xorazm viloyati', '', 'XO',
'state', 1),
(4359, 'state_Malampa_4359', 'Malampa',
'Malampa', '', 'MAP', 'state', 1),
(4360, 'state_P__nama_4360', 'Pénama',
'Pénama', '', 'PAM', 'state', 1),
(4361, 'state_Sanma_4361', 'Sanma', 'Sanma',
'', 'SAM', 'state', 1),
(4362, 'state_Sh__fa_4362', 'Shéfa',
'Shéfa', '', 'SEE', 'state', 1),
(4363, 'state_Taf__a_4363', 'Taféa',
'Taféa', '', 'TAE', 'state', 1),
(4364, 'state_Torba_4364', 'Torba', 'Torba',
'', 'TOB', 'state', 1),
(4365, 'state_Distrito_Capital_4365', 'Distrito
Capital', 'Distrito Capital', '', 'A',
'state', 1),
(4366, 'state_Anzo__tegui_4366', 'AnzoĂĄtegui',
'AnzoĂĄtegui', '', 'B', 'state',
1),
(4367, 'state_Apure_4367', 'Apure', 'Apure',
'', 'C', 'state', 1),
(4368, 'state_Aragua_4368', 'Aragua',
'Aragua', '', 'D', 'state', 1),
(4369, 'state_Barinas_4369', 'Barinas',
'Barinas', '', 'E', 'state', 1),
(4370, 'state_Bol__var_4370', 'BolĂvar',
'BolĂvar', '', 'F', 'state', 1),
(4371, 'state_Carabobo_4371', 'Carabobo',
'Carabobo', '', 'G', 'state', 1),
(4372, 'state_Cojedes_4372', 'Cojedes',
'Cojedes', '', 'H', 'state', 1),
(4373, 'state_Falc__n_4373', 'FalcĂłn',
'FalcĂłn', '', 'I', 'state', 1),
(4374, 'state_Gu__rico_4374', 'GuĂĄrico',
'GuĂĄrico', '', 'J', 'state', 1),
(4375, 'state_Lara_4375', 'Lara', 'Lara',
'', 'K', 'state', 1),
(4376, 'state_M__rida_4376', 'Mérida',
'Mérida', '', 'L', 'state', 1),
(4377, 'state_Miranda_4377', 'Miranda',
'Miranda', '', 'M', 'state', 1),
(4378, 'state_Monagas_4378', 'Monagas',
'Monagas', '', 'N', 'state', 1),
(4379, 'state_Nueva_Esparta_4379', 'Nueva Esparta',
'Nueva Esparta', '', 'O', 'state',
1),
(4380, 'state_Portuguesa_4380', 'Portuguesa',
'Portuguesa', '', 'P', 'state',
1),
(4381, 'state_Sucre_4381', 'Sucre', 'Sucre',
'', 'R', 'state', 1),
(4382, 'state_Tachira_4382', 'Tachira',
'Tachira', '', 'S', 'state', 1),
(4383, 'state_Trujillo_4383', 'Trujillo',
'Trujillo', '', 'T', 'state', 1),
(4384, 'state_Yaracuy_4384', 'Yaracuy',
'Yaracuy', '', 'U', 'state', 1),
(4385, 'state_Zulia_4385', 'Zulia', 'Zulia',
'', 'V', 'state', 1),
(4386, 'state_Capital_Dependencia_4386', 'Capital
Dependencia', 'Capital Dependencia', '',
'W', 'state', 1),
(4387, 'state_Vargas_4387', 'Vargas',
'Vargas', '', 'X', 'state', 1),
(4388, 'state_Delta_Amacuro_4388', 'Delta Amacuro',
'Delta Amacuro', '', 'Y', 'state',
1),
(4389, 'state_Amazonas_4389', 'Amazonas',
'Amazonas', '', 'Z', 'state', 1),
(4390, 'state_Lai_Ch__u_4390', 'Lai ChĂąu', 'Lai
ChĂąu', '', '01', 'state', 1),
(4391, 'state_L__o_Cai_4391', 'LĂ o Cai', 'LĂ o
Cai', '', '02', 'state', 1),
(4392, 'state_H___Giang_4392', 'HĂ Giang', 'HĂ
Giang', '', '03', 'state', 1),
(4393, 'state_Cao_B___ng_4393', 'Cao Báș±ng', 'Cao
Báș±ng', '', '04', 'state', 1),
(4394, 'state_S__n_La_4394', 'SÆĄn La', 'SÆĄn
La', '', '05', 'state', 1),
(4395, 'state_Y__n_B__i_4395', 'YĂȘn BĂĄi', 'YĂȘn
BĂĄi', '', '06', 'state', 1),
(4396, 'state_Tuy__n_Quang_4396', 'TuyĂȘn Quang',
'TuyĂȘn Quang', '', '07', 'state',
1),
(4397, 'state_L___ng_S__n_4397', 'LáșĄng SÆĄn',
'LáșĄng SÆĄn', '', '09', 'state',
1),
(4398, 'state_Qu___ng_Ninh_4398', 'QuáșŁng Ninh',
'QuáșŁng Ninh', '', '13', 'state',
1),
(4399, 'state_H__a_B__nh_4399', 'HĂČa BĂŹnh',
'HĂČa BĂŹnh', '', '14', 'state',
1),
(4400, 'state_H___T__y_4400', 'HĂ TĂąy', 'HĂ
TĂąy', '', '15', 'state', 1),
(4401, 'state_Ninh_B__nh_4401', 'Ninh BĂŹnh',
'Ninh BĂŹnh', '', '18', 'state',
1),
(4402, 'state_Th__i_B__nh_4402', 'ThĂĄi BĂŹnh',
'ThĂĄi BĂŹnh', '', '20', 'state',
1),
(4403, 'state_Thanh_H__a_4403', 'Thanh HĂła',
'Thanh HĂła', '', '21', 'state',
1),
(4404, 'state_Ngh____An_4404', 'Nghá» An',
'Nghá» An', '', '22', 'state',
1),
(4405, 'state_H___T__nh_4405', 'HĂ TÄ©nh', 'HĂ
Tĩnh', '', '23', 'state', 1),
(4406, 'state_Qu___ng_B__nh_4406', 'QuáșŁng BĂŹnh',
'QuáșŁng BĂŹnh', '', '24', 'state',
1),
(4407, 'state_Qu___ng_Tr____4407', 'QuáșŁng Trá»',
'QuáșŁng Trá»', '', '25', 'state',
1),
(4408, 'state_Th___a_Thi__n_Hu____4408', 'Thừa
ThiĂȘn-Huáșż', 'Thừa ThiĂȘn-Huáșż', '',
'26', 'state', 1),
(4409, 'state_Qu___ng_Nam_4409', 'QuáșŁng Nam',
'QuáșŁng Nam', '', '27', 'state',
1),
(4410, 'state_Kon_Tum_4410', 'Kon Tum', 'Kon
Tum', '', '28', 'state', 1),
(4411, 'state_Qu___ng_Ng__i_4411', 'QuáșŁng NgĂŁi',
'QuáșŁng NgĂŁi', '', '29', 'state',
1),
(4412, 'state_Gia_Lai_4412', 'Gia Lai', 'Gia
Lai', '', '30', 'state', 1),
(4413, 'state_B__nh______nh_4413', 'BĂŹnh Äá»nh',
'BĂŹnh Äá»nh', '', '31', 'state',
1),
(4414, 'state_Ph___Y__n_4414', 'PhĂș YĂȘn', 'PhĂș
YĂȘn', '', '32', 'state', 1),
(4415, 'state______k_L___k_4415', 'ÄáșŻk LáșŻk',
'ÄáșŻk LáșŻk', '', '33', 'state',
1),
(4416, 'state_Kh__nh_H__a_4416', 'KhĂĄnh HĂČa',
'KhĂĄnh HĂČa', '', '34', 'state',
1),
(4417, 'state_L__m______ng_4417', 'LĂąm Äá»ng',
'LĂąm Äá»ng', '', '35', 'state',
1),
(4418, 'state_Ninh_Thu___n_4418', 'Ninh Thuáșn',
'Ninh Thuáșn', '', '36', 'state',
1),
(4419, 'state_T__y_Ninh_4419', 'TĂąy Ninh', 'TĂąy
Ninh', '', '37', 'state', 1),
(4420, 'state______ng_Nai_4420', 'Äá»ng Nai',
'Äá»ng Nai', '', '39', 'state',
1),
(4421, 'state_B__nh_Thu___n_4421', 'BĂŹnh Thuáșn',
'BĂŹnh Thuáșn', '', '40', 'state',
1),
(4422, 'state_Long_An_4422', 'Long An', 'Long
An', '', '41', 'state', 1),
(4423, 'state_B___R___a_V__ng_T__u_4423', 'BĂ Rá»a-VĆ©ng
TĂ u', 'BĂ Rá»a-VĆ©ng TĂ u', '', '43',
'state', 1),
(4424, 'state_An_Giang_4424', 'An Giang', 'An
Giang', '', '44', 'state', 1),
(4425, 'state______ng_Th__p_4425', 'Äá»ng ThĂĄp',
'Äá»ng ThĂĄp', '', '45', 'state',
1),
(4426, 'state_Ti___n_Giang_4426', 'Tiá»n Giang',
'Tiá»n Giang', '', '46', 'state',
1),
(4427, 'state_Ki__n_Giang_4427', 'KiĂȘn Giang',
'KiĂȘn Giang', '', '47', 'state',
1),
(4428, 'state_C___n_Th___4428', 'Cáș§n ThÆĄ',
'Cáș§n ThÆĄ', '', '48', 'state',
1),
(4429, 'state_V__nh_Long_4429', 'Vĩnh Long',
'Vĩnh Long', '', '49', 'state',
1),
(4430, 'state_B___n_Tre_4430', 'Báșżn Tre', 'Báșżn
Tre', '', '50', 'state', 1),
(4431, 'state_Tr___Vinh_4431', 'TrĂ Vinh', 'TrĂ
Vinh', '', '51', 'state', 1),
(4432, 'state_S__c_Tr__ng_4432', 'SĂłc TrÄng',
'SĂłc TrÄng', '', '52', 'state',
1),
(4433, 'state_B___c_K___n_4433', 'BáșŻc KáșĄn',
'BáșŻc KáșĄn', '', '53', 'state',
1),
(4434, 'state_B___c_Giang_4434', 'BáșŻc Giang',
'BáșŻc Giang', '', '54', 'state',
1),
(4435, 'state_B___c_Li__u_4435', 'BáșĄc LiĂȘu',
'BáșĄc LiĂȘu', '', '55', 'state',
1),
(4436, 'state_B___c_Ninh_4436', 'BáșŻc Ninh',
'BáșŻc Ninh', '', '56', 'state',
1),
(4437, 'state_B__nh_D____ng_4437', 'BĂŹnh DÆ°ÆĄng',
'BĂŹnh DÆ°ÆĄng', '', '57', 'state',
1),
(4438, 'state_B__nh_Ph_____c_4438', 'BĂŹnh Phưá»c',
'BĂŹnh Phưá»c', '', '58',
'state', 1),
(4439, 'state_C___Mau_4439', 'CĂ Mau', 'CĂ
Mau', '', '59', 'state', 1),
(4440, 'state______N___ng_4440', 'ÄĂ Náș”ng',
'ÄĂ Náș”ng', '', '60', 'state',
1),
(4441, 'state_H___i_D____ng_4441', 'HáșŁi DÆ°ÆĄng',
'HáșŁi DÆ°ÆĄng', '', '61', 'state',
1),
(4442, 'state_H___i_Ph__ng_4442', 'HáșŁi PhĂČng',
'HáșŁi PhĂČng', '', '62', 'state',
1),
(4443, 'state_H___Nam_4443', 'HĂ Nam', 'HĂ
Nam', '', '63', 'state', 1),
(4444, 'state_H___N___i_4444', 'HĂ Ná»i', 'HĂ
Ná»i', '', '64', 'state', 1),
(4445, 'state_S__i_G__n_4445', 'SĂ i GĂČn', 'SĂ i
GĂČn', '', '65', 'state', 1),
(4446, 'state_H__ng_Y__n_4446', 'Hưng YĂȘn',
'Hưng YĂȘn', '', '66', 'state',
1),
(4447, 'state_Nam______nh_4447', 'Nam Äá»nh',
'Nam Äá»nh', '', '67', 'state',
1),
(4448, 'state_Ph___Th____4448', 'PhĂș Thá»',
'PhĂș Thá»', '', '68', 'state',
1),
(4449, 'state_Th__i_Nguy__n_4449', 'ThĂĄi NguyĂȘn',
'ThĂĄi NguyĂȘn', '', '69', 'state',
1),
(4450, 'state_V__nh_Ph__c_4450', 'VÄ©nh PhĂșc',
'VÄ©nh PhĂșc', '', '70', 'state',
1),
(4451, 'state___i___n_Bi__n_4451', 'Äiá»n BiĂȘn',
'Äiá»n BiĂȘn', '', '71', 'state',
1),
(4452, 'state______k_N__ng_4452', 'ÄáșŻk NĂŽng',
'ÄáșŻk NĂŽng', '', '72', 'state',
1),
(4453, 'state_H___u_Giang_4453', 'Háșu Giang',
'Háșu Giang', '', '73', 'state',
1),
(4454, 'state_Saint_Croix_4454', 'Saint Croix',
'Saint Croix', '', 'C', 'state',
1),
(4457, 'state_Alo_4457', 'Alo', 'Alo',
'', 'A', 'state', 1),
(4458, 'state_Sigave_4458', 'Sigave',
'Sigave', '', 'S', 'state', 1),
(4459, 'state_Wallis_4459', 'Wallis',
'Wallis', '', 'W', 'state', 1),
(4460, 'state_____________4460', 'ŰŁŰšÙÙâ',
'ŰŁŰšÙÙâ', '', 'AB', 'state',
1),
(4461, 'state________4461', 'ŰčŰŻÙ',
'ŰčŰŻÙ', '', 'AD', 'state', 1),
(4462, 'state____________4462', 'ŰčÙ
۱ۧÙ',
'ŰčÙ
۱ۧÙ', '', 'AM', 'state',
1),
(4463, 'state________________4463', 'ۧÙŰšÙ۶ۧۥ',
'ۧÙŰšÙ۶ۧۥ', '', 'BA',
'state', 1),
(4464, 'state______________4464', 'ۧÙ۶ۧÙŰč',
'ۧÙ۶ۧÙŰč', '', 'DA', 'state',
1),
(4465, 'state__________4465', '۰Ù
ۧ۱',
'۰Ù
ۧ۱', '', 'DH', 'state', 1),
(4466, 'state______________4466', 'Ű۶۱Ù
ÙŰȘ',
'Ű۶۱Ù
ÙŰȘ', '', 'HD', 'state',
1),
(4467, 'state________4467', 'ŰŰŹŰ©',
'ŰŰŹŰ©', '', 'HJ', 'state', 1),
(4468, 'state________________4468', 'ۧÙŰŰŻÙŰŻŰ©',
'ۧÙŰŰŻÙŰŻŰ©', '', 'HU',
'state', 1),
(4469, 'state______4469', 'ۄۚ', 'ۄۚ',
'', 'IB', 'state', 1),
(4470, 'state____________4470', 'ۧÙŰŹÙÙ',
'ۧÙŰŹÙÙ', '', 'JA', 'state',
1),
(4471, 'state________4471', 'ÙŰŰŹ',
'ÙŰŰŹ', '', 'LA', 'state', 1),
(4472, 'state__________4472', 'Ù
ۣ۱ۚ',
'Ù
ۣ۱ۚ', '', 'MA', 'state', 1),
(4473, 'state______________4473', 'ۧÙÙ
Ù۱۩',
'ۧÙÙ
Ù۱۩', '', 'MR', 'state',
1),
(4474, 'state________________4474', 'ۧÙÙ
ŰÙÙŰȘ',
'ۧÙÙ
ŰÙÙŰȘ', '', 'MW',
'state', 1),
(4475, 'state__________4475', 'Ű”ŰčŰŻŰ©',
'Ű”ŰčŰŻŰ©', '', 'SD', 'state', 1),
(4476, 'state____________4476', 'Ű”ÙŰčۧۥ',
'Ű”ÙŰčۧۥ', '', 'SN', 'state',
1),
(4477, 'state__________4477', 'ŰŽŰšÙŰ©',
'ŰŽŰšÙŰ©', '', 'SH', 'state', 1),
(4478, 'state________4478', 'ŰȘŰčŰČ',
'ŰȘŰčŰČ', '', 'TA', 'state', 1),
(4479, 'state_Western_4479', 'Western',
'Western', '', '01', 'state', 1),
(4480, 'state_Central_4480', 'Central',
'Central', '', '02', 'state', 1),
(4481, 'state_Eastern_4481', 'Eastern',
'Eastern', '', '03', 'state', 1),
(4482, 'state_Luapula_4482', 'Luapula',
'Luapula', '', '04', 'state', 1),
(4483, 'state_Northern_4483', 'Northern',
'Northern', '', '05', 'state', 1),
(4484, 'state_North_Western_4484', 'North-Western',
'North-Western', '', '06', 'state',
1),
(4485, 'state_Southern_4485', 'Southern',
'Southern', '', '07', 'state', 1),
(4486, 'state_Copperbelt_4486', 'Copperbelt',
'Copperbelt', '', '08', 'state',
1),
(4487, 'state_Lusaka_4487', 'Lusaka',
'Lusaka', '', '09', 'state', 1),
(4488, 'state_Manicaland_4488', 'Manicaland',
'Manicaland', '', 'MA', 'state',
1),
(4489, 'state_Mashonaland_Central_4489', 'Mashonaland
Central', 'Mashonaland Central', '',
'MC', 'state', 1),
(4490, 'state_Mashonaland_East_4490', 'Mashonaland
East', 'Mashonaland East', '', 'ME',
'state', 1),
(4491, 'state_Midlands_4491', 'Midlands',
'Midlands', '', 'MI', 'state', 1),
(4492, 'state_Matabeleland_North_4492', 'Matabeleland
North', 'Matabeleland North', '', 'MN',
'state', 1),
(4493, 'state_Matabeleland_South_4493', 'Matabeleland
South', 'Matabeleland South', '', 'MS',
'state', 1),
(4494, 'state_Masvingo_4494', 'Masvingo',
'Masvingo', '', 'MV', 'state', 1),
(4495, 'state_Mashonaland_West_4495', 'Mashonaland
West', 'Mashonaland West', '', 'MW',
'state', 1),
(4501, 'tax_europe_9728', 'Europe', 'Europe',
'EU', '', 'tax', 1),
(4502, 'country_Montenegro_19668', 'ĐŠŃĐœĐ° ĐĐŸŃа',
'Montenegro', 'ME', 'MNE',
'country', 1),
(4503, 'country_Serbia_4503', 'ĐĄŃбОŃа',
'Serbia', 'RS', 'SRB', 'country',
1),
('4554', 'state_Aberdeenshire_4554',
'Aberdeenshire', 'Aberdeenshire', '',
'ABR', 'state', '1'),
('4555', 'state_Anglesey_4555', 'Anglesey',
'Anglesey', '', 'ANG', 'state',
'1'),
('4506', 'state_Angus_4506', 'Angus',
'Angus', '', 'AGS', 'state',
'1'),
('4507', 'state_Argyllshire_4507',
'Argyllshire', 'Argyllshire', '',
'AGL', 'state', '1'),
('4508', 'state_Ayrshire_4508', 'Ayrshire',
'Ayrshire', '', 'AYR', 'state',
'1'),
('4509', 'state_Banffshire_4509',
'Banffshire', 'Banffshire', '',
'ANF', 'state', '1'),
('4510', 'state_Berwickshire_4510',
'Berwickshire', 'Berwickshire', '',
'BRW', 'state', '1'),
('4511', 'state_Brecknockshire_4511',
'Brecknockshire', 'Brecknockshire', '',
'BRC', 'state', '1'),
('4512', 'state_Buteshire_4512', 'Buteshire',
'Buteshire', '', 'BTS', 'state',
'1'),
('4513', 'state_Caernarfonshire_4513',
'Caernarfonshire', 'Caernarfonshire', '',
'CRN', 'state', '1'),
('4514', 'state_Caithness_4514', 'Caithness',
'Caithness', '', 'CTN', 'state',
'1'),
('4515', 'state_Cardiganshire_4515',
'Cardiganshire', 'Cardiganshire', '',
'CGN', 'state', '1'),
('4516', 'state_Channel_Isles_4516', 'Channel
Isles', 'Channel Isles', '', 'CHI',
'state', '1'),
('4517', 'state_Clackmannanshire_4517',
'Clackmannanshire', 'Clackmannanshire', '',
'CLK', 'state', '1'),
('4518', 'state_County_Armagh_4518', 'County
Armagh', 'County Armagh', '', 'CAM',
'state', '1'),
('4519', 'state_Cumberland_4519',
'Cumberland', 'Cumberland', '',
'CRL', 'state', '1'),
('4520', 'state_Dumfriesshire_4520',
'Dumfriesshire', 'Dumfriesshire', '',
'DFS', 'state', '1'),
('4521', 'state_Dunbartonshire_4521',
'Dunbartonshire', 'Dunbartonshire', '',
'DBT', 'state', '1'),
('4522', 'state_East_Lothian_4522', 'East
Lothian', 'East Lothian', '', 'ELT',
'state', '1'),
('4523', 'state_Huntingdonshire_4523',
'Huntingdonshire', 'Huntingdonshire', '',
'HTG', 'state', '1'),
('4524', 'state_Inverness-shire_4524',
'Inverness-shire', 'Inverness-shire', '',
'INV', 'state', '1'),
('4525', 'state_Isle_ of_Islay_4525', 'Isle of
Islay', 'Isle of Islay', '', 'IOI',
'state', '1'),
('4526', 'state_Isle_of_Lewis_4526', 'Isle of
Lewis', 'Isle of Lewis', '', 'IOL',
'state', '1'),
('4527', 'state_Isle_of_Man_4527', 'Isle of
Man', 'Isle of Man', '', 'IOM',
'state', '1'),
('4528', 'state_Isle_of_Skye_4528', 'Isle of
Skye', 'Isle of Skye', '', 'IOS',
'state', '1'),
('4529', 'state_Isles_of_Scilly_4529', 'Isles of
Scilly', 'Isles of Scilly', '', 'ISC',
'state', '1'),
('4530', 'state_Kincardineshire_4530',
'Kincardineshire', 'Kincardineshire', '',
'KNC', 'state', '1'),
('4531', 'state_Kinross-Shire_4531',
'Kinross-Shire', 'Kinross-Shire', '',
'KNR', 'state', '1'),
('4532', 'state_Kirkcudbrightshire_4532',
'Kirkcudbrightshire', 'Kirkcudbrightshire',
'', 'KKC', 'state', '1'),
('4533', 'state_Lanarkshire_4533',
'Lanarkshire', 'Lanarkshire', '',
'LNK', 'state', '1'),
('4534', 'state_Merioneth_4534', 'Merioneth',
'Merioneth', '', 'MRN', 'state',
'1'),
('4535', 'state_Midlothian_4535',
'Midlothian', 'Midlothian', '',
'MDL', 'state', '1'),
('4536', 'state_Monmouthshire_4536',
'Monmouthshire', 'Monmouthshire', '',
'MMS', 'state', '1'),
('4537', 'state_Montgomeryshire_4537',
'Montgomeryshire', 'Montgomeryshire', '',
'MGY', 'state', '1'),
('4538', 'state_Morayshire_4538',
'Morayshire', 'Morayshire', '',
'MRY', 'state', '1'),
('4539', 'state_Nairnshire_4539',
'Nairnshire', 'Nairnshire', '',
'NNS', 'state', '1'),
('4540', 'state_Orkney_4540', 'Orkney',
'Orkney', '', 'OKY', 'state',
'1'),
('4541', 'state_Peeblesshire_4541',
'Peeblesshire', 'Peeblesshire', '',
'PBL', 'state', '1'),
('4542', 'state_Perthshire_4542',
'Perthshire', 'Perthshire', '',
'PTS', 'state', '1'),
('4543', 'state_Radnorshire_4543',
'Radnorshire', 'Radnorshire', '',
'RDN', 'state', '1'),
('4544', 'state_Ross-shire_4544',
'Ross-shire', 'Ross-shire', '',
'RSS', 'state', '1'),
('4545', 'state_Roxburghshire_4545',
'Roxburghshire', 'Roxburghshire', '',
'RXB', 'state', '1'),
('4546', 'state_Rutland_4546', 'Rutland',
'Rutland', '', 'RTL', 'state',
'1'),
('4547', 'state_Selkirkshire_4547',
'Selkirkshire', 'Selkirkshire', '',
'SKK', 'state', '1'),
('4548', 'state_Shetland_4548', 'Shetland',
'Shetland', '', 'SHL', 'state',
'1'),
('4549', 'state_Stirlingshire_4549',
'Stirlingshire', 'Stirlingshire', '',
'STG', 'state', '1'),
('4550', 'state_Sussex_4550', 'Sussex',
'Sussex', '', 'SSX', 'state',
'1'),
('4551', 'state_Sutherland_4551',
'Sutherland', 'Sutherland', '',
'STH', 'state', '1'),
('4552', 'state_Westmorland_4552',
'Westmorland', 'Westmorland', '',
'WSM', 'state', '1'),
('4553', 'state_Wigtownshire_4553',
'Wigtownshire', 'Wigtownshire', '',
'WGT', 'state', '1'),
('4554', 'country_isle_of_man_4554', 'Isle of
Man', 'Isle of Man', 'IM', 'IMN',
'country', '1'),
('4555', 'country_Moldova_4555', 'Moldova',
'Moldova', 'MD', 'MDA', 'country',
'1');";
$this->db->setQuery($query);
$this->db->query();
if($this->update) return true;
$query=<<<EOD
INSERT IGNORE INTO `#__hikashop_widget` (`widget_id`, `widget_name`,
`widget_params`) VALUES
(1, 'Last 7 orders',
'O:8:"stdClass":11:{s:7:"content";s:6:"orders";s:7:"display";s:7:"listing";s:9:"date_type";s:7:"created";s:10:"date_group";s:5:"%j
%Y";s:5:"start";s:0:"";s:3:"end";s:0:"";s:6:"period";s:1:"0";s:6:"status";s:0:"";s:5:"limit";s:1:"7";s:6:"region";s:5:"world";s:6:"format";s:5:"UTF-8";}'),
(2, 'Sales over the last 30 days',
'O:8:"stdClass":11:{s:7:"content";s:5:"sales";s:7:"display";s:5:"graph";s:9:"date_type";s:7:"created";s:10:"date_group";s:5:"%j
%Y";s:5:"start";s:0:"";s:3:"end";s:0:"";s:6:"period";s:7:"2592000";s:6:"status";s:17:"confirmed,shipped";s:5:"limit";s:0:"";s:6:"region";s:5:"world";s:6:"format";s:5:"UTF-8";}'),
(3, 'Last 7 customers',
'O:8:"stdClass":11:{s:7:"content";s:9:"customers";s:7:"display";s:7:"listing";s:9:"date_type";s:7:"created";s:10:"date_group";s:5:"%j
%Y";s:5:"start";s:0:"";s:3:"end";s:0:"";s:6:"period";s:1:"0";s:6:"status";s:0:"";s:5:"limit";s:1:"7";s:6:"region";s:5:"world";s:6:"format";s:5:"UTF-8";}');
EOD;
$this->db->setQuery($query);
$this->db->query();
$query="INSERT IGNORE INTO `#__hikashop_zone_link`
(`zone_parent_namekey`, `zone_child_namekey`) VALUES
('country_Afghanistan_1', 'state_______________240'),
('country_Afghanistan_1', 'state______________241'),
('country_Afghanistan_1', 'state____________242'),
('country_Afghanistan_1', 'state________243'),
('country_Afghanistan_1', 'state______________244'),
('country_Afghanistan_1', 'state________________245'),
('country_Afghanistan_1', 'state__________246'),
('country_Afghanistan_1', 'state______________247'),
('country_Afghanistan_1', 'state__________248'),
('country_Afghanistan_1', 'state________249'),
('country_Afghanistan_1', 'state____________250'),
('country_Afghanistan_1', 'state__________251'),
('country_Afghanistan_1', 'state______________252'),
('country_Afghanistan_1', 'state__________253'),
('country_Afghanistan_1', 'state______________254'),
('country_Afghanistan_1', 'state______________255'),
('country_Afghanistan_1', 'state__________256'),
('country_Afghanistan_1', 'state____________257'),
('country_Afghanistan_1', 'state____________258'),
('country_Afghanistan_1', 'state____________259'),
('country_Afghanistan_1', 'state__________260'),
('country_Afghanistan_1', 'state________________261'),
('country_Afghanistan_1', 'state______________262'),
('country_Afghanistan_1', 'state________________263'),
('country_Afghanistan_1', 'state________________264'),
('country_Afghanistan_1', 'state____________265'),
('country_Afghanistan_1', 'state______________266'),
('country_Afghanistan_1', 'state_______________267'),
('country_Afghanistan_1', 'state____________268'),
('country_Afghanistan_1', 'state______________269'),
('country_Afghanistan_1', 'state___________270'),
('country_Afghanistan_1', 'state__________271'),
('country_Afghanistan_1', 'state__________272'),
('country_Afghanistan_1', 'state__________273'),
('country_Albania_2', 'state_Beratit_274'),
('country_Albania_2', 'state_Bulqiz__s_275'),
('country_Albania_2', 'state_Dibr__s_276'),
('country_Albania_2', 'state_Delvin__s_277'),
('country_Albania_2', 'state_Durr__sit_278'),
('country_Albania_2', 'state_Devollit_279'),
('country_Albania_2', 'state_Elbasanit_280'),
('country_Albania_2', 'state_Kolonj__s_281'),
('country_Albania_2', 'state_Fierit_282'),
('country_Albania_2', 'state_Gjirokastr__s_283'),
('country_Albania_2', 'state_Gramshit_284'),
('country_Albania_2', 'state_Hasit_285'),
('country_Albania_2', 'state_Kavaj__s_286'),
('country_Albania_2', 'state_Kurbinit_287'),
('country_Albania_2', 'state_Ku__ov__s_288'),
('country_Albania_2', 'state_Kor____s_289'),
('country_Albania_2', 'state_Kruj__s_290'),
('country_Albania_2', 'state_Kuk__sit_291'),
('country_Albania_2', 'state_Librazhdit_292'),
('country_Albania_2', 'state_Lezh__s_293'),
('country_Albania_2', 'state_Lushnj__s_294'),
('country_Albania_2', 'state_Mallakastr__s_295'),
('country_Albania_2',
'state_Mal__sis___s___Madhe_296'),
('country_Albania_2', 'state_Mirdit__s_297'),
('country_Albania_2', 'state_Matit_298'),
('country_Albania_2', 'state_Pogradecit_299'),
('country_Albania_2', 'state_Peqinit_300'),
('country_Albania_2', 'state_P__rmetit_301'),
('country_Albania_2', 'state_Puk__s_302'),
('country_Albania_2', 'state_Shkodr__s_303'),
('country_Albania_2', 'state_Skraparit_304'),
('country_Albania_2', 'state_Sarand__s_305'),
('country_Albania_2', 'state_Tepelen__s_306'),
('country_Albania_2', 'state_Tropoj__s_307'),
('country_Albania_2', 'state_Tiran__s_308'),
('country_Albania_2', 'state_Vlor__s_309'),
('country_Algeria_3',
'state_______________________310'),
('country_Algeria_3',
'state_______________________311'),
('country_Algeria_3',
'state___________________________312'),
('country_Algeria_3',
'state________________________________313'),
('country_Algeria_3',
'state_______________________314'),
('country_Algeria_3',
'state_______________________315'),
('country_Algeria_3',
'state_______________________316'),
('country_Algeria_3',
'state_____________________317'),
('country_Algeria_3', 'state___________________318'),
('country_Algeria_3',
'state___________________________319'),
('country_Algeria_3',
'state___________________________320'),
('country_Algeria_3',
'state_____________________321'),
('country_Algeria_3', 'state______________322'),
('country_Algeria_3',
'state_______________________323'),
('country_Algeria_3', 'state_________________324'),
('country_Algeria_3',
'state___________________________325'),
('country_Algeria_3',
'state________________________________326'),
('country_Algeria_3',
'state_____________________327'),
('country_Algeria_3',
'state_____________________328'),
('country_Algeria_3',
'state_______________________329'),
('country_Algeria_3', 'state__________________330'),
('country_Algeria_3',
'state__________________________________331'),
('country_Algeria_3',
'state_______________________332'),
('country_Algeria_3',
'state_______________________333'),
('country_Algeria_3', 'state________________334'),
('country_Algeria_3',
'state_________________________335'),
('country_Algeria_3',
'state___________________________336'),
('country_Algeria_3',
'state___________________________337'),
('country_Algeria_3',
'state_______________________338'),
('country_Algeria_3', 'state____________339'),
('country_Algeria_3', 'state____________340'),
('country_Algeria_3',
'state_______________________341'),
('country_Algeria_3',
'state_______________________342'),
('country_Algeria_3',
'state____________________________________343'),
('country_Algeria_3',
'state___________________________344'),
('country_Algeria_3',
'state_________________________345'),
('country_Algeria_3', 'state____________346'),
('country_Algeria_3',
'state___________________________347'),
('country_Algeria_3',
'state_________________________348'),
('country_Algeria_3',
'state_______________________349'),
('country_Algeria_3',
'state______________________________350'),
('country_Algeria_3',
'state_________________________351'),
('country_Algeria_3',
'state_____________________352'),
('country_Algeria_3',
'state________________________________353'),
('country_Algeria_3',
'state___________________________354'),
('country_Algeria_3',
'state________________________________355'),
('country_Algeria_3',
'state_________________________356'),
('country_Algeria_3',
'state_________________________357'),
('country_American_Samoa_4', 'state_Eastern_358'),
('country_American_Samoa_4', 'state_Manu_a_359'),
('country_American_Samoa_4', 'state_Rose_Island_360'),
('country_American_Samoa_4',
'state_Swains_Island_361'),
('country_American_Samoa_4', 'state_Western_362'),
('country_Andorra_5', 'state_Andorra_la_Vella_363'),
('country_Andorra_5', 'state_Canillo_364'),
('country_Andorra_5', 'state_Encamp_365'),
('country_Andorra_5', 'state_Escaldes_Engordany_366'),
('country_Andorra_5', 'state_La_Massana_367'),
('country_Andorra_5', 'state_Ordino_368'),
('country_Andorra_5',
'state_Sant_Juli___de_L__ria_369'),
('country_Angola_6', 'state_Bengo_370'),
('country_Angola_6', 'state_Benguela_371'),
('country_Angola_6', 'state_Bi___372'),
('country_Angola_6', 'state_Cabinda_373'),
('country_Angola_6', 'state_Cuando_Cubango_374'),
('country_Angola_6', 'state_Cuanza_Norte_375'),
('country_Angola_6', 'state_Cuanza_Sul_376'),
('country_Angola_6', 'state_Cunene_377'),
('country_Angola_6', 'state_Huambo_378'),
('country_Angola_6', 'state_Hu__la_379'),
('country_Angola_6', 'state_Luanda_380'),
('country_Angola_6', 'state_Lunda_Norte_381'),
('country_Angola_6', 'state_Lunda_Sul_382'),
('country_Angola_6', 'state_Malanje_383'),
('country_Angola_6', 'state_Moxico_384'),
('country_Angola_6', 'state_Namibe_385'),
('country_Angola_6', 'state_U__ge_386'),
('country_Angola_6', 'state_Zaire_387'),
('country_Antigua_and_Barbuda_9',
'state_Barbuda_388'),
('country_Antigua_and_Barbuda_9',
'state_Saint_George_389'),
('country_Antigua_and_Barbuda_9',
'state_Saint_John_390'),
('country_Antigua_and_Barbuda_9',
'state_Saint_Mary_391'),
('country_Antigua_and_Barbuda_9',
'state_Saint_Paul_392'),
('country_Antigua_and_Barbuda_9',
'state_Saint_Peter_393'),
('country_Antigua_and_Barbuda_9',
'state_Saint_Philip_394'),
('country_Argentina_10', 'state_Salta_395'),
('country_Argentina_10',
'state_Buenos_Aires_Province_396'),
('country_Argentina_10', 'state_Capital_Federal_397'),
('country_Argentina_10', 'state_San_Luis_398'),
('country_Argentina_10', 'state_Entre_R__os_399'),
('country_Argentina_10', 'state_La_Rioja_400'),
('country_Argentina_10',
'state_Santiago_del_Estero_401'),
('country_Argentina_10', 'state_Chaco_402'),
('country_Argentina_10', 'state_San_Juan_403'),
('country_Argentina_10', 'state_Catamarca_404'),
('country_Argentina_10', 'state_La_Pampa_405'),
('country_Argentina_10', 'state_Mendoza_406'),
('country_Argentina_10', 'state_Misiones_407'),
('country_Argentina_10', 'state_Formosa_408'),
('country_Argentina_10', 'state_Neuqu__n_409'),
('country_Argentina_10', 'state_R__o_Negro_410'),
('country_Argentina_10', 'state_Santa_Fe_411'),
('country_Argentina_10', 'state_Tucum__n_412'),
('country_Argentina_10', 'state_Chubut_413'),
('country_Argentina_10',
'state_Tierra_del_Fuego_414'),
('country_Argentina_10', 'state_Corrientes_415'),
('country_Argentina_10', 'state_C__rdoba_416'),
('country_Argentina_10', 'state_Jujuy_417'),
('country_Argentina_10', 'state_Santa_Cruz_418'),
('country_Armenia_11',
'state____________________419'),
('country_Armenia_11', 'state______________420'),
('country_Armenia_11', 'state________________421'),
('country_Armenia_11', 'state____________422'),
('country_Armenia_11',
'state________________________423'),
('country_Armenia_11', 'state______________424'),
('country_Armenia_11', 'state__________425'),
('country_Armenia_11', 'state____________426'),
('country_Armenia_11', 'state________________427'),
('country_Armenia_11', 'state______________428'),
('country_Armenia_11', 'state___________________429'),
('country_Australia_13',
'state_Australian_Capital_Territory_430'),
('country_Australia_13', 'state_New_South_Wales_431'),
('country_Australia_13',
'state_Northern_Territory_432'),
('country_Australia_13', 'state_Queensland_433'),
('country_Australia_13', 'state_South_Australia_434'),
('country_Australia_13', 'state_Tasmania_435'),
('country_Australia_13', 'state_Victoria_436'),
('country_Australia_13',
'state_Western_Australia_437'),
('country_Austria_14', 'state_Burgenland_438'),
('country_Austria_14', 'state_K__rnten_439'),
('country_Austria_14', 'state_Nieder__sterreich_440'),
('country_Austria_14', 'state_Ober__sterreich_441'),
('country_Austria_14', 'state_Salzburg_442'),
('country_Austria_14', 'state_Steiermark_443'),
('country_Austria_14', 'state_Tirol_444'),
('country_Austria_14', 'state_Voralberg_445'),
('country_Austria_14', 'state_Wien_446'),
('country_Azerbaijan_15', 'state___li_Bayraml___447'),
('country_Azerbaijan_15', 'state_Ab__eron_448'),
('country_Azerbaijan_15', 'state_A__cab__di_449'),
('country_Azerbaijan_15', 'state_A__dam_450'),
('country_Azerbaijan_15', 'state_A__da___451'),
('country_Azerbaijan_15', 'state_A__stafa_452'),
('country_Azerbaijan_15', 'state_A__su_453'),
('country_Azerbaijan_15', 'state_Astara_454'),
('country_Azerbaijan_15', 'state_Bak___455'),
('country_Azerbaijan_15', 'state_Bab__k_456'),
('country_Azerbaijan_15', 'state_Balak__n_457'),
('country_Azerbaijan_15', 'state_B__rd___458'),
('country_Azerbaijan_15', 'state_Beyl__qan_459'),
('country_Azerbaijan_15', 'state_Bil__suvar_460'),
('country_Azerbaijan_15', 'state_C__bray__l_461'),
('country_Azerbaijan_15', 'state_C__lilabab_462'),
('country_Azerbaijan_15', 'state_Julfa_463'),
('country_Azerbaijan_15', 'state_Da__k__s__n_464'),
('country_Azerbaijan_15', 'state_D__v____i_465'),
('country_Azerbaijan_15', 'state_F__zuli_466'),
('country_Azerbaijan_15', 'state_G__nc___467'),
('country_Azerbaijan_15', 'state_G__d__b__y_468'),
('country_Azerbaijan_15', 'state_Goranboy_469'),
('country_Azerbaijan_15', 'state_G__y__ay_470'),
('country_Azerbaijan_15', 'state_Hac__qabul_471'),
('country_Azerbaijan_15', 'state___mi__li_472'),
('country_Azerbaijan_15', 'state___smay__ll___473'),
('country_Azerbaijan_15', 'state_K__lb__c__r_474'),
('country_Azerbaijan_15', 'state_K__rd__mir_475'),
('country_Azerbaijan_15', 'state_L__nk__ran_476'),
('country_Azerbaijan_15', 'state_La____n_477'),
('country_Azerbaijan_15', 'state_L__nk__ran_478'),
('country_Azerbaijan_15', 'state_Lerik_479'),
('country_Azerbaijan_15', 'state_Masall___480'),
('country_Azerbaijan_15', 'state_Ming____evir_481'),
('country_Azerbaijan_15', 'state_Naftalan_482'),
('country_Azerbaijan_15', 'state_Neft__ala_483'),
('country_Azerbaijan_15', 'state_O__uz_484'),
('country_Azerbaijan_15', 'state_Ordubad_485'),
('country_Azerbaijan_15', 'state_Q__b__l___486'),
('country_Azerbaijan_15', 'state_Qax_487'),
('country_Azerbaijan_15', 'state_Qazax_488'),
('country_Azerbaijan_15', 'state_Qobustan_489'),
('country_Azerbaijan_15', 'state_Quba_490'),
('country_Azerbaijan_15', 'state_Qubadl___491'),
('country_Azerbaijan_15', 'state_Qusar_492'),
('country_Azerbaijan_15', 'state_____ki_493'),
('country_Azerbaijan_15', 'state_Saatl___494'),
('country_Azerbaijan_15', 'state_Sabirabad_495'),
('country_Azerbaijan_15', 'state_S__d__r__k_496'),
('country_Azerbaijan_15', 'state___ahbuz_497'),
('country_Azerbaijan_15', 'state_____ki_498'),
('country_Azerbaijan_15', 'state_Salyan_499'),
('country_Azerbaijan_15', 'state_Sumqay__t_500'),
('country_Azerbaijan_15', 'state___amax___501'),
('country_Azerbaijan_15', 'state_____mkir_502'),
('country_Azerbaijan_15', 'state_Samux_503'),
('country_Azerbaijan_15', 'state_____rur_504'),
('country_Azerbaijan_15', 'state_Siy__z__n_505'),
('country_Azerbaijan_15', 'state___u__a__City__506'),
('country_Azerbaijan_15', 'state___u__a_507'),
('country_Azerbaijan_15', 'state_T__rt__r_508'),
('country_Azerbaijan_15', 'state_Tovuz_509'),
('country_Azerbaijan_15', 'state_Ucar_510'),
('country_Azerbaijan_15', 'state_Xank__ndi_511'),
('country_Azerbaijan_15', 'state_Xa__maz_512'),
('country_Azerbaijan_15', 'state_Xanlar_513'),
('country_Azerbaijan_15', 'state_X__z___514'),
('country_Azerbaijan_15', 'state_Xocal___515'),
('country_Azerbaijan_15', 'state_Xocav__nd_516'),
('country_Azerbaijan_15', 'state_Yard__ml___517'),
('country_Azerbaijan_15', 'state_Yevlax__City__518'),
('country_Azerbaijan_15', 'state_Yevlax_519'),
('country_Azerbaijan_15', 'state_Z__ngilan_520'),
('country_Azerbaijan_15', 'state_Zaqatala_521'),
('country_Azerbaijan_15', 'state_Z__rdab_522'),
('country_Azerbaijan_15', 'state_Nakhichevan_523'),
('country_Bahamas_16',
'state_Acklins_and_Crooked_Islands_524'),
('country_Bahamas_16', 'state_Bimini_525'),
('country_Bahamas_16', 'state_Cat_Island_526'),
('country_Bahamas_16', 'state_Exuma_527'),
('country_Bahamas_16', 'state_Freeport_528'),
('country_Bahamas_16', 'state_Fresh_Creek_529'),
('country_Bahamas_16',
'state_Governor_s_Harbour_530'),
('country_Bahamas_16', 'state_Green_Turtle_Cay_531'),
('country_Bahamas_16', 'state_Harbour_Island_532'),
('country_Bahamas_16', 'state_High_Rock_533'),
('country_Bahamas_16', 'state_Inagua_534'),
('country_Bahamas_16', 'state_Kemps_Bay_535'),
('country_Bahamas_16', 'state_Long_Island_536'),
('country_Bahamas_16', 'state_Marsh_Harbour_537'),
('country_Bahamas_16', 'state_Mayaguana_538'),
('country_Bahamas_16', 'state_New_Providence_539'),
('country_Bahamas_16',
'state_Nicholls_Town_and_Berry_Islands_540'),
('country_Bahamas_16', 'state_Ragged_Island_541'),
('country_Bahamas_16', 'state_Rock_Sound_542'),
('country_Bahamas_16',
'state_San_Salvador_and_Rum_Cay_543'),
('country_Bahamas_16', 'state_Sandy_Point_544'),
('country_Bahrain_17', 'state__________545'),
('country_Bahrain_17', 'state______________546'),
('country_Bahrain_17', 'state________________547'),
('country_Bahrain_17', 'state_____________548'),
('country_Bahrain_17',
'state_________________________________549'),
('country_Bahrain_17', 'state__________550'),
('country_Bahrain_17',
'state_____________________________551'),
('country_Bahrain_17',
'state_____________________552'),
('country_Bahrain_17',
'state________________________________________________553'),
('country_Bahrain_17',
'state_______________________________554'),
('country_Bahrain_17', 'state_________________555'),
('country_Bahrain_17', 'state___________________556'),
('country_Bangladesh_18', 'state_Bandarban_557'),
('country_Bangladesh_18', 'state_Barguna_558'),
('country_Bangladesh_18', 'state_Bogra_559'),
('country_Bangladesh_18', 'state_Brahmanbaria_560'),
('country_Bangladesh_18', 'state_Bagerhat_561'),
('country_Bangladesh_18', 'state_Barisal_562'),
('country_Bangladesh_18', 'state_Bhola_563'),
('country_Bangladesh_18', 'state_Comilla_564'),
('country_Bangladesh_18', 'state_Chandpur_565'),
('country_Bangladesh_18', 'state_Chittagong_566'),
('country_Bangladesh_18', 'state_Cox_s_Bazar_567'),
('country_Bangladesh_18', 'state_Chuadanga_568'),
('country_Bangladesh_18', 'state_Dhaka_569'),
('country_Bangladesh_18', 'state_Dinajpur_570'),
('country_Bangladesh_18', 'state_Faridpur_571'),
('country_Bangladesh_18', 'state_Feni_572'),
('country_Bangladesh_18', 'state_Gopalganj_573'),
('country_Bangladesh_18', 'state_Gazipur_574'),
('country_Bangladesh_18', 'state_Gaibandha_575'),
('country_Bangladesh_18', 'state_Habiganj_576'),
('country_Bangladesh_18', 'state_Jamalpur_577'),
('country_Bangladesh_18', 'state_Jessore_578'),
('country_Bangladesh_18', 'state_Jhenaidah_579'),
('country_Bangladesh_18', 'state_Jaipurhat_580'),
('country_Bangladesh_18', 'state_Jhalakati_581'),
('country_Bangladesh_18', 'state_Kishoreganj_582'),
('country_Bangladesh_18', 'state_Khulna_583'),
('country_Bangladesh_18', 'state_Kurigram_584'),
('country_Bangladesh_18', 'state_Khagrachari_585'),
('country_Bangladesh_18', 'state_Kushtia_586'),
('country_Bangladesh_18', 'state_Lakshmipur_587'),
('country_Bangladesh_18', 'state_Lalmonirhat_588'),
('country_Bangladesh_18', 'state_Manikganj_589'),
('country_Bangladesh_18', 'state_Mymensingh_590'),
('country_Bangladesh_18', 'state_Munshiganj_591'),
('country_Bangladesh_18', 'state_Madaripur_592'),
('country_Bangladesh_18', 'state_Magura_593'),
('country_Bangladesh_18', 'state_Moulvibazar_594'),
('country_Bangladesh_18', 'state_Meherpur_595'),
('country_Bangladesh_18', 'state_Narayanganj_596'),
('country_Bangladesh_18', 'state_Netrakona_597'),
('country_Bangladesh_18', 'state_Narsingdi_598'),
('country_Bangladesh_18', 'state_Narail_599'),
('country_Bangladesh_18', 'state_Natore_600'),
('country_Bangladesh_18', 'state_Nawabganj_601'),
('country_Bangladesh_18', 'state_Nilphamari_602'),
('country_Bangladesh_18', 'state_Noakhali_603'),
('country_Bangladesh_18', 'state_Naogaon_604'),
('country_Bangladesh_18', 'state_Pabna_605'),
('country_Bangladesh_18', 'state_Pirojpur_606'),
('country_Bangladesh_18', 'state_Patuakhali_607'),
('country_Bangladesh_18', 'state_Panchagarh_608'),
('country_Bangladesh_18', 'state_Rajbari_609'),
('country_Bangladesh_18', 'state_Rajshahi_610'),
('country_Bangladesh_18', 'state_Rangpur_611'),
('country_Bangladesh_18', 'state_Rangamati_612'),
('country_Bangladesh_18', 'state_Sherpur_613'),
('country_Bangladesh_18', 'state_Satkhira_614'),
('country_Bangladesh_18', 'state_Sirajganj_615'),
('country_Bangladesh_18', 'state_Sylhet_616'),
('country_Bangladesh_18', 'state_Sunamganj_617'),
('country_Bangladesh_18', 'state_Shariatpur_618'),
('country_Bangladesh_18', 'state_Tangail_619'),
('country_Bangladesh_18', 'state_Thakurgaon_620'),
('country_Barbados_19', 'state_Saint_Andrew_621'),
('country_Barbados_19', 'state_Christ_Church_622'),
('country_Barbados_19', 'state_Saint_Peter_623'),
('country_Barbados_19', 'state_Saint_George_624'),
('country_Barbados_19', 'state_Saint_John_625'),
('country_Barbados_19', 'state_Saint_Lucy_626'),
('country_Barbados_19', 'state_Saint_Michael_627'),
('country_Barbados_19', 'state_Saint_Joseph_628'),
('country_Barbados_19', 'state_Saint_Philip_629'),
('country_Barbados_19', 'state_Saint_James_630'),
('country_Barbados_19', 'state_Saint_Thomas_631'),
('country_Belarus_20',
'state_______________________________________632'),
('country_Belarus_20',
'state___________________________________________633'),
('country_Belarus_20',
'state_____________________________________________634'),
('country_Belarus_20',
'state___________________________________________635'),
('country_Belarus_20',
'state_____________________________________636'),
('country_Belarus_20',
'state_________________________________________637'),
('country_Belgium_21', 'state_Brussel_638'),
('country_Belgium_21', 'state_Antwerpen_639'),
('country_Belgium_21', 'state_Vlaams_Brabant_640'),
('country_Belgium_21', 'state_Limburg_641'),
('country_Belgium_21', 'state_Oost_Vlaanderen_642'),
('country_Belgium_21', 'state_West_Vlaanderen_643'),
('country_Belgium_21', 'state_Brabant_Wallon_644'),
('country_Belgium_21', 'state_Hainaut_645'),
('country_Belgium_21', 'state_Li__ge_L__ttich_646'),
('country_Belgium_21', 'state_Luxembourg_647'),
('country_Belgium_21', 'state_Namur_648'),
('country_Belize_22', 'state_Belize_District_649'),
('country_Belize_22', 'state_Cayo_District_650'),
('country_Belize_22', 'state_Corozal_District_651'),
('country_Belize_22',
'state_Orange_Walk_District_652'),
('country_Belize_22',
'state_Stann_Creek_District_653'),
('country_Belize_22', 'state_Toledo_District_654'),
('country_Benin_23', 'state_Alibori_655'),
('country_Benin_23', 'state_Atakora_656'),
('country_Benin_23', 'state_Atlantique_657'),
('country_Benin_23', 'state_Borgou_658'),
('country_Benin_23', 'state_Collines_659'),
('country_Benin_23', 'state_Donga_660'),
('country_Benin_23', 'state_Kouffo_661'),
('country_Benin_23', 'state_Littoral_662'),
('country_Benin_23', 'state_Mono_663'),
('country_Benin_23', 'state_Ou__m___664'),
('country_Benin_23', 'state_Plateau_665'),
('country_Benin_23', 'state_Zou_666'),
('country_Bermuda_24', 'state_Devonshire_667'),
('country_Bermuda_24', 'state_Hamilton_City_668'),
('country_Bermuda_24', 'state_Hamilton_669'),
('country_Bermuda_24', 'state_Paget_670'),
('country_Bermuda_24', 'state_Pembroke_671'),
('country_Bermuda_24', 'state_Sandys_672'),
('country_Bermuda_24', 'state_Saint_George_City_673'),
('country_Bermuda_24', 'state_Saint_George_s_674'),
('country_Bermuda_24', 'state_Smiths_675'),
('country_Bermuda_24', 'state_Southampton_676'),
('country_Bermuda_24', 'state_Warwick_677'),
('country_Bhutan_25', 'state_Paro_678'),
('country_Bhutan_25', 'state_Chukha_679'),
('country_Bhutan_25', 'state_Haa_680'),
('country_Bhutan_25', 'state_Samtse_681'),
('country_Bhutan_25', 'state_Thimphu_682'),
('country_Bhutan_25', 'state_Tsirang_683'),
('country_Bhutan_25', 'state_Dagana_684'),
('country_Bhutan_25', 'state_Punakha_685'),
('country_Bhutan_25', 'state_Wangdue_Phodrang_686'),
('country_Bhutan_25', 'state_Sarpang_687'),
('country_Bhutan_25', 'state_Trongsa_688'),
('country_Bhutan_25', 'state_Bumthang_689'),
('country_Bhutan_25', 'state_Zhemgang_690'),
('country_Bhutan_25', 'state_Trashigang_691'),
('country_Bhutan_25', 'state_Mongar_692'),
('country_Bhutan_25', 'state_Pemagatshel_693'),
('country_Bhutan_25', 'state_Luentse_694'),
('country_Bhutan_25', 'state_Samdrup_Jongkhar_695'),
('country_Bhutan_25', 'state_Gasa_696'),
('country_Bhutan_25', 'state_Trashiyangse_697'),
('country_Bolivia_26', 'state_El_Beni_698'),
('country_Bolivia_26', 'state_Cochabamba_699'),
('country_Bolivia_26', 'state_Chuquisaca_700'),
('country_Bolivia_26', 'state_La_Paz_701'),
('country_Bolivia_26', 'state_Pando_702'),
('country_Bolivia_26', 'state_Oruro_703'),
('country_Bolivia_26', 'state_Potos___704'),
('country_Bolivia_26', 'state_Santa_Cruz_705'),
('country_Bolivia_26', 'state_Tarija_706'),
('country_Botswana_28', 'state_Central_707'),
('country_Botswana_28', 'state_Ghanzi_708'),
('country_Botswana_28', 'state_Kgalagadi_709'),
('country_Botswana_28', 'state_Kgatleng_710'),
('country_Botswana_28', 'state_Kweneng_711'),
('country_Botswana_28', 'state_North_East_712'),
('country_Botswana_28', 'state_North_West_713'),
('country_Botswana_28', 'state_South_East_714'),
('country_Botswana_28', 'state_Southern_715'),
('country_Brazil_30', 'state_Acre_716'),
('country_Brazil_30', 'state_Alagoas_717'),
('country_Brazil_30', 'state_Amaz__nia_718'),
('country_Brazil_30', 'state_Amap___719'),
('country_Brazil_30', 'state_Bahia_720'),
('country_Brazil_30', 'state_Cear___721'),
('country_Brazil_30', 'state_Distrito_Federal_722'),
('country_Brazil_30', 'state_Esp__rito_Santo_723'),
('country_Brazil_30', 'state_Goi__s_724'),
('country_Brazil_30', 'state_Maranh__o_725'),
('country_Brazil_30', 'state_Minas_Gerais_726'),
('country_Brazil_30', 'state_Mato_Grosso_do_Sul_727'),
('country_Brazil_30', 'state_Mato_Grosso_728'),
('country_Brazil_30', 'state_Par___729'),
('country_Brazil_30', 'state_Para__ba_730'),
('country_Brazil_30', 'state_Pernambuco_731'),
('country_Brazil_30', 'state_Piau___732'),
('country_Brazil_30', 'state_Paran___733'),
('country_Brazil_30', 'state_Rio_de_Janeiro_734'),
('country_Brazil_30',
'state_Rio_Grande_do_Norte_735'),
('country_Brazil_30', 'state_Rond__nia_736'),
('country_Brazil_30', 'state_Roraima_737'),
('country_Brazil_30', 'state_Rio_Grande_do_Sul_738'),
('country_Brazil_30',
'state_Santa_Catarina_739')";
$this->db->setQuery($query);
$this->db->query();
$query="INSERT IGNORE INTO `#__hikashop_zone_link`
(`zone_parent_namekey`, `zone_child_namekey`) VALUES
('country_Brazil_30', 'state_Sergipe_740'),
('country_Brazil_30', 'state_S__o_Paulo_741'),
('country_Brazil_30', 'state_Tocantins_742'),
('country_British_Indian_Ocean_Territory_31',
'state_Peros_Banhos_743'),
('country_British_Indian_Ocean_Territory_31',
'state_Salomon_Islands_744'),
('country_British_Indian_Ocean_Territory_31',
'state_Nelsons_Island_745'),
('country_British_Indian_Ocean_Territory_31',
'state_Three_Brothers_746'),
('country_British_Indian_Ocean_Territory_31',
'state_Eagle_Islands_747'),
('country_British_Indian_Ocean_Territory_31',
'state_Danger_Island_748'),
('country_British_Indian_Ocean_Territory_31',
'state_Egmont_Islands_749'),
('country_British_Indian_Ocean_Territory_31',
'state_Diego_Garcia_750'),
('country_Brunei_Darussalam_32', 'state_Belait_751'),
('country_Brunei_Darussalam_32',
'state_Brunei_Muara_752'),
('country_Brunei_Darussalam_32',
'state_Temburong_753'),
('country_Brunei_Darussalam_32', 'state_Tutong_754'),
('country_Bulgaria_33', 'state_Blagoevgrad_755'),
('country_Bulgaria_33', 'state_Burgas_756'),
('country_Bulgaria_33', 'state_Varna_757'),
('country_Bulgaria_33', 'state_Veliko_Tarnovo_758'),
('country_Bulgaria_33', 'state_Vidin_759'),
('country_Bulgaria_33', 'state_Vratsa_760'),
('country_Bulgaria_33', 'state_Gabrovo_761'),
('country_Bulgaria_33', 'state_Dobrich_762'),
('country_Bulgaria_33', 'state_Kardzhali_763'),
('country_Bulgaria_33', 'state_Kyustendil_764'),
('country_Bulgaria_33', 'state_Lovech_765'),
('country_Bulgaria_33', 'state_Montana_766'),
('country_Bulgaria_33', 'state_Pazardzhik_767'),
('country_Bulgaria_33', 'state_Pernik_768'),
('country_Bulgaria_33', 'state_Pleven_769'),
('country_Bulgaria_33', 'state_Plovdiv_770'),
('country_Bulgaria_33', 'state_Razgrad_771'),
('country_Bulgaria_33', 'state_Ruse_772'),
('country_Bulgaria_33', 'state_Silistra_773'),
('country_Bulgaria_33', 'state_Sliven_774'),
('country_Bulgaria_33', 'state_Smolyan_775'),
('country_Bulgaria_33', 'state_Sofia_776'),
('country_Bulgaria_33', 'state_Sofia_Province_777'),
('country_Bulgaria_33', 'state_Stara_Zagora_778'),
('country_Bulgaria_33', 'state_Targovishte_779'),
('country_Bulgaria_33', 'state_Haskovo_780'),
('country_Bulgaria_33', 'state_Shumen_781'),
('country_Bulgaria_33', 'state_Yambol_782'),
('country_Burkina_Faso_34', 'state_Bal___783'),
('country_Burkina_Faso_34', 'state_Bam_784'),
('country_Burkina_Faso_34', 'state_Banwa_785'),
('country_Burkina_Faso_34', 'state_Baz__ga_786'),
('country_Burkina_Faso_34', 'state_Bougouriba_787'),
('country_Burkina_Faso_34', 'state_Boulgou_788'),
('country_Burkina_Faso_34', 'state_Boulkiemd___789'),
('country_Burkina_Faso_34', 'state_Komo___790'),
('country_Burkina_Faso_34', 'state_Ganzourgou_791'),
('country_Burkina_Faso_34', 'state_Gnagna_792'),
('country_Burkina_Faso_34', 'state_Gourma_793'),
('country_Burkina_Faso_34', 'state_Houet_794'),
('country_Burkina_Faso_34', 'state_Ioba_795'),
('country_Burkina_Faso_34', 'state_Kadiogo_796'),
('country_Burkina_Faso_34', 'state_K__n__dougou_797'),
('country_Burkina_Faso_34', 'state_Komondjari_798'),
('country_Burkina_Faso_34', 'state_Kompienga_799'),
('country_Burkina_Faso_34', 'state_Koulp__logo_800'),
('country_Burkina_Faso_34', 'state_Kossi_801'),
('country_Burkina_Faso_34', 'state_Kouritenga_802'),
('country_Burkina_Faso_34', 'state_Kourw__ogo_803'),
('country_Burkina_Faso_34', 'state_L__raba_804'),
('country_Burkina_Faso_34', 'state_Loroum_805'),
('country_Burkina_Faso_34', 'state_Mouhoun_806'),
('country_Burkina_Faso_34', 'state_Namentenga_807'),
('country_Burkina_Faso_34', 'state_Naouri_808'),
('country_Burkina_Faso_34', 'state_Nayala_809'),
('country_Burkina_Faso_34', 'state_Noumbiel_810'),
('country_Burkina_Faso_34', 'state_Oubritenga_811'),
('country_Burkina_Faso_34', 'state_Oudalan_812'),
('country_Burkina_Faso_34', 'state_Passor___813'),
('country_Burkina_Faso_34', 'state_Poni_814'),
('country_Burkina_Faso_34', 'state_S__no_815'),
('country_Burkina_Faso_34', 'state_Sissili_816'),
('country_Burkina_Faso_34', 'state_Sanmatenga_817'),
('country_Burkina_Faso_34', 'state_Sangui___818'),
('country_Burkina_Faso_34', 'state_Soum_819'),
('country_Burkina_Faso_34', 'state_Sourou_820'),
('country_Burkina_Faso_34', 'state_Tapoa_821'),
('country_Burkina_Faso_34', 'state_Tui_822'),
('country_Burkina_Faso_34', 'state_Yagha_823'),
('country_Burkina_Faso_34', 'state_Yatenga_824'),
('country_Burkina_Faso_34', 'state_Ziro_825'),
('country_Burkina_Faso_34', 'state_Zondoma_826'),
('country_Burkina_Faso_34', 'state_Zoundw__ogo_827'),
('country_Burundi_35', 'state_Bubanza_828'),
('country_Burundi_35', 'state_Bujumbura_Mairie_829'),
('country_Burundi_35', 'state_Bururi_830'),
('country_Burundi_35', 'state_Cankuzo_831'),
('country_Burundi_35', 'state_Cibitoke_832'),
('country_Burundi_35', 'state_Gitega_833'),
('country_Burundi_35', 'state_Karuzi_834'),
('country_Burundi_35', 'state_Kayanza_835'),
('country_Burundi_35', 'state_Kirundo_836'),
('country_Burundi_35', 'state_Makamba_837'),
('country_Burundi_35', 'state_Muramvya_838'),
('country_Burundi_35', 'state_Muyinga_839'),
('country_Burundi_35', 'state_Mwaro_840'),
('country_Burundi_35', 'state_Ngozi_841'),
('country_Burundi_35', 'state_Rutana_842'),
('country_Burundi_35', 'state_Ruyigi_843'),
('country_Cameroon_37', 'state_Adamaoua_844'),
('country_Cameroon_37', 'state_Centre_845'),
('country_Cameroon_37', 'state_Extr__me_Nord_846'),
('country_Cameroon_37', 'state_Est_847'),
('country_Cameroon_37', 'state_Littoral_848'),
('country_Cameroon_37', 'state_Nord_849'),
('country_Cameroon_37', 'state_Nord_Ouest_850'),
('country_Cameroon_37', 'state_Ouest_851'),
('country_Cameroon_37', 'state_Sud_852'),
('country_Cameroon_37', 'state_Sud_Ouest_853'),
('country_Canada_38', 'state_Alberta_854'),
('country_Canada_38', 'state_British_Columbia_855'),
('country_Canada_38', 'state_Manitoba_856'),
('country_Canada_38', 'state_New_Brunswick_857'),
('country_Canada_38',
'state_Newfoundland_and_Labrador_858'),
('country_Canada_38', 'state_Nova_Scotia_859'),
('country_Canada_38',
'state_Northwest_Territories_860'),
('country_Canada_38', 'state_Nunavut_861'),
('country_Canada_38', 'state_Ontario_862'),
('country_Canada_38',
'state_Prince_Edward_Island_863'),
('country_Canada_38', 'state_Quebec_864'),
('country_Canada_38', 'state_Saskatchewan_865'),
('country_Canada_38', 'state_Yukon_Territory_866'),
('country_Cape_Verde_39', 'state_Brava_867'),
('country_Cape_Verde_39', 'state_Boa_Vista_868'),
('country_Cape_Verde_39', 'state_Santa_Catarina_869'),
('country_Cape_Verde_39', 'state_Santa_Cruz_870'),
('country_Cape_Verde_39',
'state_Calheta_de_S__o_Miguel_871'),
('country_Cape_Verde_39', 'state_Maio_872'),
('country_Cape_Verde_39', 'state_Mosteiros_873'),
('country_Cape_Verde_39', 'state_Pa__l_874'),
('country_Cape_Verde_39', 'state_Porto_Novo_875'),
('country_Cape_Verde_39', 'state_Praia_876'),
('country_Cape_Verde_39', 'state_Ribeira_Grande_877'),
('country_Cape_Verde_39', 'state_S__o_Domingos_878'),
('country_Cape_Verde_39', 'state_S__o_Filipe_879'),
('country_Cape_Verde_39', 'state_Sal_880'),
('country_Cape_Verde_39', 'state_S__o_Nicolau_881'),
('country_Cape_Verde_39', 'state_S__o_Vicente_882'),
('country_Cape_Verde_39', 'state_Tarrafal_883'),
('country_Cayman_Islands_40', 'state_Creek_884'),
('country_Cayman_Islands_40', 'state_Midland_886'),
('country_Cayman_Islands_40', 'state_South_Town_887'),
('country_Cayman_Islands_40', 'state_Spot_Bay_888'),
('country_Cayman_Islands_40', 'state_Stake_Bay_889'),
('country_Cayman_Islands_40', 'state_West_End_890'),
('country_Cayman_Islands_40', 'state_Western_891'),
('country_Central_African_Republic_41',
'state_Ouham_892'),
('country_Central_African_Republic_41',
'state_Bamingui_Bangoran_893'),
('country_Central_African_Republic_41',
'state_Bangui_894'),
('country_Central_African_Republic_41',
'state_Basse_Kotto_895'),
('country_Central_African_Republic_41',
'state_Haute_Kotto_896'),
('country_Central_African_Republic_41',
'state_Haut_Mbomou_897'),
('country_Central_African_Republic_41',
'state_Mamb__r___Kad_____898'),
('country_Central_African_Republic_41',
'state_Nana_Gr__bizi_899'),
('country_Central_African_Republic_41',
'state_K__mo_900'),
('country_Central_African_Republic_41',
'state_Lobaye_901'),
('country_Central_African_Republic_41',
'state_Mbomou_902'),
('country_Central_African_Republic_41',
'state_Ombella_M_Poko_903'),
('country_Central_African_Republic_41',
'state_Nana_Mamb__r___904'),
('country_Central_African_Republic_41',
'state_Ouham_Pend___905'),
('country_Central_African_Republic_41',
'state_Sangha_Mba__r___906'),
('country_Central_African_Republic_41',
'state_Ouaka_907'),
('country_Central_African_Republic_41',
'state_Vakaga_908'),
('country_Chad_42', 'state_Batha_909'),
('country_Chad_42',
'state_Borkou_Ennedi_Tibesti_910'),
('country_Chad_42', 'state_Biltine_911'),
('country_Chad_42', 'state_Chari_Baguirmi_912'),
('country_Chad_42', 'state_Gu__ra_913'),
('country_Chad_42', 'state_Kanem_914'),
('country_Chad_42', 'state_Lac_915'),
('country_Chad_42', 'state_Logone_Oriental_916'),
('country_Chad_42', 'state_Logone_Occidental_917'),
('country_Chad_42', 'state_Moyen_Chari_918'),
('country_Chad_42', 'state_Mayo_K__bbi_919'),
('country_Chad_42', 'state_Ouadda___920'),
('country_Chad_42', 'state_Salamat_921'),
('country_Chad_42', 'state_Tandjil___922'),
('country_Chile_43',
'state_Ais__n_del_General_Carlos_Iba__ez_923'),
('country_Chile_43', 'state_Antofagasta_924'),
('country_Chile_43', 'state_La_Araucan__a_925'),
('country_Chile_43', 'state_Atacama_926'),
('country_Chile_43', 'state_Biob__o_927'),
('country_Chile_43', 'state_Coquimbo_928'),
('country_Chile_43',
'state_Libertador_Bernardo_O_Higgins_929'),
('country_Chile_43', 'state_Los_Lagos_930'),
('country_Chile_43',
'state_Magallanes_y_de_la_Antartica_931'),
('country_Chile_43', 'state_Maule_932'),
('country_Chile_43',
'state_Metropolitana_de_Santiago_933'),
('country_Chile_43', 'state_Tarapac___934'),
('country_Chile_43', 'state_Valpara__so_935'),
('country_China_44', 'state________936'),
('country_China_44', 'state________937'),
('country_China_44', 'state________938'),
('country_China_44', 'state________939'),
('country_China_44', 'state____________________940'),
('country_China_44', 'state________941'),
('country_China_44', 'state________942'),
('country_China_44', 'state______________943'),
('country_China_44', 'state________944'),
('country_China_44', 'state________945'),
('country_China_44', 'state________946'),
('country_China_44', 'state________947'),
('country_China_44', 'state________948'),
('country_China_44', 'state________949'),
('country_China_44', 'state________950'),
('country_China_44', 'state________951'),
('country_China_44', 'state________952'),
('country_China_44', 'state________953'),
('country_China_44', 'state________954'),
('country_China_44',
'state_______________________955'),
('country_China_44', 'state________956'),
('country_China_44', 'state________957'),
('country_China_44', 'state________958'),
('country_China_44', 'state________959'),
('country_China_44', 'state________960'),
('country_China_44', 'state_________________961'),
('country_China_44', 'state________962'),
('country_China_44', 'state________963'),
('country_China_44', 'state________964'),
('country_China_44', 'state________965'),
('country_China_44', 'state________966'),
('country_China_44', 'state________967'),
('country_China_44', 'state________968'),
('country_China_44', 'state________969'),
('country_Cocos__Keeling__Islands_46',
'state_Direction_Island_970'),
('country_Cocos__Keeling__Islands_46',
'state_Home_Island_971'),
('country_Cocos__Keeling__Islands_46',
'state_Horsburgh_Island_972'),
('country_Cocos__Keeling__Islands_46',
'state_South_Island_973'),
('country_Cocos__Keeling__Islands_46',
'state_West_Island_974'),
('country_Colombia_47', 'state_Amazonas_975'),
('country_Colombia_47', 'state_Antioquia_976'),
('country_Colombia_47', 'state_Arauca_977'),
('country_Colombia_47', 'state_Atl__ntico_978'),
('country_Colombia_47', 'state_Bol__var_979'),
('country_Colombia_47', 'state_Boyac___980'),
('country_Colombia_47', 'state_Caldas_981'),
('country_Colombia_47', 'state_Caquet___982'),
('country_Colombia_47', 'state_Casanare_983'),
('country_Colombia_47', 'state_Cauca_984'),
('country_Colombia_47', 'state_Cesar_985'),
('country_Colombia_47', 'state_Choc___986'),
('country_Colombia_47', 'state_C__rdoba_987'),
('country_Colombia_47', 'state_Cundinamarca_988'),
('country_Colombia_47',
'state_Bogot___Distrito_Capital_989'),
('country_Colombia_47', 'state_Guain__a_990'),
('country_Colombia_47', 'state_Guaviare_991'),
('country_Colombia_47', 'state_La_Guajira_993'),
('country_Colombia_47', 'state_Magdalena_994'),
('country_Colombia_47', 'state_Meta_995'),
('country_Colombia_47', 'state_Nari__o_996'),
('country_Colombia_47',
'state_Norte_de_Santander_997'),
('country_Colombia_47', 'state_Putumayo_998'),
('country_Colombia_47', 'state_Quind__o_999'),
('country_Colombia_47', 'state_Risaralda_1000'),
('country_Colombia_47', 'state_Santander_1001'),
('country_Colombia_47',
'state_San_Andr__s_y_Providencia_1002'),
('country_Colombia_47', 'state_Sucre_1003'),
('country_Colombia_47', 'state_Tolima_1004'),
('country_Colombia_47', 'state_Valle_del_Cauca_1005'),
('country_Colombia_47', 'state_Vaup__s_1006'),
('country_Colombia_47', 'state_Vichada_1007'),
('country_Comoros_48', 'state_Anjouan_1008'),
('country_Comoros_48', 'state_Grande_Comore_1009'),
('country_Comoros_48', 'state_Moh__li_1010'),
('country_Congo_49', 'state_Congo_Central_1011'),
('country_Congo_49', 'state_Bandundu_1012'),
('country_Congo_49', 'state___quateur_1013'),
('country_Congo_49', 'state_Katanga_1014'),
('country_Congo_49', 'state_Kasai_Oriental_1015'),
('country_Congo_49', 'state_Kinshasa_1016'),
('country_Congo_49', 'state_Kasai_Occidental_1017'),
('country_Congo_49', 'state_Maniema_1018'),
('country_Congo_49', 'state_Nord_Kivu_1019'),
('country_Congo_49', 'state_Orientale_1020'),
('country_Congo_49', 'state_Sud_Kivu_1021'),
('country_Cook_Islands_50', 'state_Pukapuka_1022'),
('country_Cook_Islands_50', 'state_Rakahanga_1023'),
('country_Cook_Islands_50', 'state_Manihiki_1024'),
('country_Cook_Islands_50', 'state_Penrhyn_1025'),
('country_Cook_Islands_50',
'state_Nassau_Island_1026'),
('country_Cook_Islands_50', 'state_Surwarrow_1027'),
('country_Cook_Islands_50', 'state_Palmerston_1028'),
('country_Cook_Islands_50', 'state_Aitutaki_1029'),
('country_Cook_Islands_50', 'state_Manuae_1030'),
('country_Cook_Islands_50', 'state_Takutea_1031'),
('country_Cook_Islands_50', 'state_Mitiaro_1032'),
('country_Cook_Islands_50', 'state_Atiu_1033'),
('country_Cook_Islands_50', 'state_Mauke_1034'),
('country_Cook_Islands_50', 'state_Rarotonga_1035'),
('country_Cook_Islands_50', 'state_Mangaia_1036'),
('country_Costa_Rica_51', 'state_Alajuela_1037'),
('country_Costa_Rica_51', 'state_Cartago_1038'),
('country_Costa_Rica_51', 'state_Guanacaste_1039'),
('country_Costa_Rica_51', 'state_Heredia_1040'),
('country_Costa_Rica_51', 'state_Lim__n_1041'),
('country_Costa_Rica_51', 'state_Puntarenas_1042'),
('country_Costa_Rica_51', 'state_San_Jos___1043'),
('country_Cote_D_Ivoire_52', 'state_Lagunes_1044'),
('country_Cote_D_Ivoire_52',
'state_Haut_Sassandra_1045'),
('country_Cote_D_Ivoire_52', 'state_Savanes_1046'),
('country_Cote_D_Ivoire_52',
'state_Vall__e_du_Bandama_1047'),
('country_Cote_D_Ivoire_52',
'state_Moyen_Como___1048'),
('country_Cote_D_Ivoire_52', 'state_Dix_Huit_1049'),
('country_Cote_D_Ivoire_52', 'state_Lacs_1050'),
('country_Cote_D_Ivoire_52', 'state_Zanzan_1051'),
('country_Cote_D_Ivoire_52',
'state_Bas_Sassandra_1052'),
('country_Cote_D_Ivoire_52', 'state_Dengu__l___1053'),
('country_Cote_D_Ivoire_52',
'state_N_zi_Como___1054'),
('country_Cote_D_Ivoire_52', 'state_Marahou___1055'),
('country_Cote_D_Ivoire_52', 'state_Sud_Como___1056'),
('country_Cote_D_Ivoire_52', 'state_Worodouqou_1057'),
('country_Cote_D_Ivoire_52',
'state_Sud_Bandama_1058'),
('country_Cote_D_Ivoire_52', 'state_Agn__bi_1059'),
('country_Cote_D_Ivoire_52', 'state_Bafing_1060'),
('country_Cote_D_Ivoire_52', 'state_Fromager_1061'),
('country_Cote_D_Ivoire_52',
'state_Moyen_Cavally_1062'),
('country_Croatia_53',
'state_Zagreba__ka___upanija_1063'),
('country_Croatia_53',
'state_Krapinsko_zagorska___upanija_1064'),
('country_Croatia_53',
'state_Sisa__ko_moslava__ka___upanija_1065'),
('country_Croatia_53',
'state_Karlova__ka___upanija_1066'),
('country_Croatia_53',
'state_Vara__dinska___upanija_1067'),
('country_Croatia_53',
'state_Koprivni__ko_kri__eva__ka___upanija_1068'),
('country_Croatia_53',
'state_Bjelovarsko_bilogorska___upanija_1069'),
('country_Croatia_53',
'state_Primorsko_goranska___upanija_1070'),
('country_Croatia_53',
'state_Li__ko_senjska___upanija_1071'),
('country_Croatia_53',
'state_Viroviti__ko_podravska___upanija_1072'),
('country_Croatia_53',
'state_Po__e__ko_slavonska___upanija_1073'),
('country_Croatia_53',
'state_Brodsko_posavska___upanija_1074'),
('country_Croatia_53',
'state_Zadarska___upanija_1075'),
('country_Croatia_53',
'state_Osje__ko_baranjska___upanija_1076'),
('country_Croatia_53',
'state___ibensko_kninska___upanija_1077'),
('country_Croatia_53',
'state_Vukovarsko_srijemska___upanija_1078'),
('country_Croatia_53',
'state_Splitsko_dalmatinska___upanija_1079'),
('country_Croatia_53',
'state_Istarska___upanija_1080'),
('country_Croatia_53',
'state_Dubrova__ko_neretvanska___upanija_1081'),
('country_Croatia_53',
'state_Me__imurska___upanija_1082'),
('country_Croatia_53', 'state_Zagreb_1083'),
('country_Cuba_54', 'state_Pinar_del_R__o_1084'),
('country_Cuba_54', 'state_La_Habana_1085'),
('country_Cuba_54', 'state_Ciudad_de_La_Habana_1086'),
('country_Cuba_54', 'state_Matanzas_1087'),
('country_Cuba_54', 'state_Villa_Clara_1088'),
('country_Cuba_54', 'state_Cienfuegos_1089'),
('country_Cuba_54', 'state_Sancti_Sp__ritus_1090'),
('country_Cuba_54', 'state_Ciego_de___vila_1091'),
('country_Cuba_54', 'state_Camag__ey_1092'),
('country_Cuba_54', 'state_Las_Tunas_1093'),
('country_Cuba_54', 'state_Holgu__n_1094'),
('country_Cuba_54', 'state_Granma_1095'),
('country_Cuba_54', 'state_Santiago_de_Cuba_1096'),
('country_Cuba_54', 'state_Guant__namo_1097'),
('country_Cuba_54', 'state_Isla_de_la_Juventud_1098'),
('country_Cyprus_55', 'state_________v_______1099'),
('country_Cyprus_55', 'state__________________1100'),
('country_Cyprus_55',
'state______________________1101'),
('country_Cyprus_55', 'state________________1102'),
('country_Cyprus_55', 'state________________1103'),
('country_Cyprus_55', 'state____________1104'),
('country_Czech_Republic_56',
'state_Jiho__esk___kraj_1105'),
('country_Czech_Republic_56',
'state_Jihomoravsk___kraj_1106'),
('country_Czech_Republic_56',
'state_Karlovarsk___kraj_1107'),
('country_Czech_Republic_56',
'state_Vyso__ina_kraj_1108'),
('country_Czech_Republic_56',
'state_Kr__lov__hradeck___kraj_1109'),
('country_Czech_Republic_56',
'state_Libereck___kraj_1110'),
('country_Czech_Republic_56',
'state_Moravskoslezsk___kraj_1111'),
('country_Czech_Republic_56',
'state_Olomouck___kraj_1112'),
('country_Czech_Republic_56',
'state_Pardubick___kraj_1113'),
('country_Czech_Republic_56',
'state_Plze__sk___kraj_1114'),
('country_Czech_Republic_56',
'state_Hlavn___m__sto_Praha_1115'),
('country_Czech_Republic_56',
'state_St__edo__esk___kraj_1116'),
('country_Czech_Republic_56',
'state___steck___kraj_1117'),
('country_Czech_Republic_56',
'state_Zl__nsk___kraj_1118'),
('country_Denmark_57',
'state_Bornholms_Regionskommune_1119'),
('country_Denmark_57', 'state_K__benhavn_1120'),
('country_Denmark_57', 'state_Frederiksberg_1121'),
('country_Denmark_57', 'state___rhus_Amt_1122'),
('country_Denmark_57', 'state_K__benhavns_Amt_1123'),
('country_Denmark_57',
'state_Frederiksborg_Amt_1124'),
('country_Denmark_57', 'state_Fyns_Amt_1125'),
('country_Denmark_57', 'state_Nordjyllands_Amt_1126'),
('country_Denmark_57', 'state_Ribe_Amt_1127'),
('country_Denmark_57', 'state_Ringkj__bing_Amt_1128'),
('country_Denmark_57', 'state_Roskilde_Amt_1129'),
('country_Denmark_57',
'state_S__nderjyllands_Amt_1130'),
('country_Denmark_57', 'state_Storstr__ms_Amt_1131'),
('country_Denmark_57', 'state_Vejle_Amt_1132'),
('country_Denmark_57',
'state_Vestsj__llands_Amt_1133'),
('country_Denmark_57', 'state_Viborg_Amt_1134'),
('country_Djibouti_58',
'state_Region_d_Ali_Sabieh_1135'),
('country_Djibouti_58', 'state_Region_d_Arta_1136'),
('country_Djibouti_58',
'state_Region_de_Dikhil_1137'),
('country_Djibouti_58',
'state_Ville_de_Djibouti_1138'),
('country_Djibouti_58', 'state_Region_d_Obock_1139'),
('country_Djibouti_58',
'state_Region_de_Tadjourah_1140'),
('country_Dominica_59',
'state_Saint_Andrew_Parish_1141'),
('country_Dominica_59',
'state_Saint_David_Parish_1142'),
('country_Dominica_59',
'state_Saint_George_Parish_1143'),
('country_Dominica_59',
'state_Saint_John_Parish_1144'),
('country_Dominica_59',
'state_Saint_Joseph_Parish_1145'),
('country_Dominica_59',
'state_Saint_Luke_Parish_1146'),
('country_Dominica_59',
'state_Saint_Mark_Parish_1147'),
('country_Dominica_59',
'state_Saint_Patrick_Parish_1148'),
('country_Dominica_59',
'state_Saint_Paul_Parish_1149'),
('country_Dominica_59',
'state_Saint_Peter_Parish_1150'),
('country_Dominican_Republic_60',
'state_Distrito_Nacional_1151'),
('country_Dominican_Republic_60', 'state___zua_1152'),
('country_Dominican_Republic_60',
'state_Baoruco_1153'),
('country_Dominican_Republic_60',
'state_Barahona_1154'),
('country_Dominican_Republic_60',
'state_Dajab__n_1155'),
('country_Dominican_Republic_60',
'state_Duarte_1156'),
('country_Dominican_Republic_60',
'state_El__as_Pi__a_1157'),
('country_Dominican_Republic_60',
'state_El_Seibo_1158'),
('country_Dominican_Republic_60',
'state_Espaillat_1159'),
('country_Dominican_Republic_60',
'state_Independencia_1160'),
('country_Dominican_Republic_60',
'state_La_Altagracia_1161'),
('country_Dominican_Republic_60',
'state_La_Romana_1162'),
('country_Dominican_Republic_60',
'state_La_Vega_1163'),
('country_Dominican_Republic_60',
'state_Mar__a_Trinidad_S__nchez_1164'),
('country_Dominican_Republic_60',
'state_Monte_Cristi_1165'),
('country_Dominican_Republic_60',
'state_Pedernales_1166'),
('country_Dominican_Republic_60',
'state_Peravia_1167'),
('country_Dominican_Republic_60',
'state_Puerto_Plata_1168'),
('country_Dominican_Republic_60',
'state_Salcedo_1169'),
('country_Dominican_Republic_60',
'state_Saman___1170'),
('country_Dominican_Republic_60',
'state_San_Crist__bal_1171'),
('country_Dominican_Republic_60',
'state_San_Juan_1172'),
('country_Dominican_Republic_60',
'state_San_Pedro_de_Macor__s_1173'),
('country_Dominican_Republic_60',
'state_S__nchez_Ram__rez_1174'),
('country_Dominican_Republic_60',
'state_Santiago_1175'),
('country_Dominican_Republic_60',
'state_Santiago_Rodr__guez_1176'),
('country_Dominican_Republic_60',
'state_Valverde_1177'),
('country_Dominican_Republic_60',
'state_Monse__or_Nouel_1178'),
('country_Dominican_Republic_60',
'state_Monte_Plata_1179'),
('country_Dominican_Republic_60',
'state_Hato_Mayor_1180'),
('country_East_Timor_61', 'state_Aileu_1181'),
('country_East_Timor_61', 'state_Ainaro_1182'),
('country_East_Timor_61', 'state_Baucau_1183'),
('country_East_Timor_61', 'state_Bobonaro_1184'),
('country_East_Timor_61', 'state_Cova_Lima_1185'),
('country_East_Timor_61', 'state_Dili_1186'),
('country_East_Timor_61', 'state_Ermera_1187'),
('country_East_Timor_61', 'state_Lautem_1188'),
('country_East_Timor_61', 'state_Liqui_____1189'),
('country_East_Timor_61', 'state_Manufahi_1190'),
('country_East_Timor_61', 'state_Manatuto_1191'),
('country_East_Timor_61', 'state_Oecussi_1192'),
('country_East_Timor_61', 'state_Viqueque_1193'),
('country_Ecuador_62', 'state_Azuay_1194'),
('country_Ecuador_62', 'state_Bol__var_1195'),
('country_Ecuador_62', 'state_Carchi_1196'),
('country_Ecuador_62', 'state_Orellana_1197'),
('country_Ecuador_62', 'state_Esmeraldas_1198'),
('country_Ecuador_62', 'state_Ca__ar_1199'),
('country_Ecuador_62', 'state_Guayas_1200'),
('country_Ecuador_62', 'state_Chimborazo_1201'),
('country_Ecuador_62', 'state_Imbabura_1202'),
('country_Ecuador_62', 'state_Loja_1203'),
('country_Ecuador_62', 'state_Manab___1204'),
('country_Ecuador_62', 'state_Napo_1205'),
('country_Ecuador_62', 'state_El_Oro_1206'),
('country_Ecuador_62', 'state_Pichincha_1207'),
('country_Ecuador_62', 'state_Los_R__os_1208'),
('country_Ecuador_62', 'state_Morona_Santiago_1209'),
('country_Ecuador_62', 'state_Tungurahua_1210'),
('country_Ecuador_62', 'state_Sucumb__os_1211'),
('country_Ecuador_62', 'state_Gal__pagos_1212'),
('country_Ecuador_62', 'state_Cotopaxi_1213'),
('country_Ecuador_62', 'state_Pastaza_1214'),
('country_Ecuador_62', 'state_Zamora_Chinchipe_1215'),
('country_Egypt_63',
'state______________________1216'),
('country_Egypt_63', 'state____________1217'),
('country_Egypt_63', 'state____________1218'),
('country_Egypt_63',
'state_________________________1219'),
('country_Egypt_63', 'state________________1220'),
('country_Egypt_63', 'state_________________1221'),
('country_Egypt_63', 'state________________1222'),
('country_Egypt_63', 'state__________________1223'),
('country_Egypt_63', 'state____________1224'),
('country_Egypt_63', 'state______________1225'),
('country_Egypt_63', 'state________________1226'),
('country_Egypt_63', 'state______________1227'),
('country_Egypt_63',
'state________________________1228'),
('country_Egypt_63',
'state_____________________1229'),
('country_Egypt_63', 'state____________________1230'),
('country_Egypt_63', 'state___________________1231'),
('country_Egypt_63', 'state________1232'),
('country_Egypt_63',
'state___________________________1233'),
('country_Egypt_63', 'state__________________1234'),
('country_Egypt_63', 'state____________1235'),
('country_Egypt_63',
'state______________________________1236'),
('country_Egypt_63',
'state_________________________1237'),
('country_Egypt_63',
'state___________________________________1238')";
$this->db->setQuery($query);
$this->db->query();
$query="INSERT IGNORE INTO `#__hikashop_zone_link`
(`zone_parent_namekey`, `zone_child_namekey`) VALUES
('country_Egypt_63',
'state_____________________1239'),
('country_Egypt_63', 'state______________1240'),
('country_Egypt_63',
'state___________________________1241'),
('country_El_Salvador_64', 'state_Ahuachap__n_1242'),
('country_El_Salvador_64', 'state_Caba__as_1243'),
('country_El_Salvador_64', 'state_Chalatenango_1244'),
('country_El_Salvador_64', 'state_Cuscatl__n_1245'),
('country_El_Salvador_64', 'state_La_Libertad_1246'),
('country_El_Salvador_64', 'state_Moraz__n_1247'),
('country_El_Salvador_64', 'state_La_Paz_1248'),
('country_El_Salvador_64', 'state_Santa_Ana_1249'),
('country_El_Salvador_64', 'state_San_Miguel_1250'),
('country_El_Salvador_64', 'state_Sonsonate_1251'),
('country_El_Salvador_64', 'state_San_Salvador_1252'),
('country_El_Salvador_64', 'state_San_Vicente_1253'),
('country_El_Salvador_64', 'state_La_Uni__n_1254'),
('country_El_Salvador_64', 'state_Usulut__n_1255'),
('country_Equatorial_Guinea_65',
'state_Annob__n_1256'),
('country_Equatorial_Guinea_65',
'state_Bioko_Norte_1257'),
('country_Equatorial_Guinea_65',
'state_Bioko_Sur_1258'),
('country_Equatorial_Guinea_65',
'state_Centro_Sur_1259'),
('country_Equatorial_Guinea_65',
'state_Ki___Ntem_1260'),
('country_Equatorial_Guinea_65',
'state_Litoral_1261'),
('country_Equatorial_Guinea_65',
'state_Wele_Nzas_1262'),
('country_Eritrea_66', 'state_Zoba_Anseba_1263'),
('country_Eritrea_66',
'state_Zoba_Debubawi_Keyih_Bahri_1264'),
('country_Eritrea_66', 'state_Zoba_Debub_1265'),
('country_Eritrea_66', 'state_Zoba_Gash_Barka_1266'),
('country_Eritrea_66', 'state_Zoba_Ma_akel_1267'),
('country_Eritrea_66',
'state_Zoba_Semienawi_Keyih_Bahri_1268'),
('country_Estonia_67', 'state_Harju_maakond_1269'),
('country_Estonia_67', 'state_Hiiu_maakond_1270'),
('country_Estonia_67', 'state_Ida_Viru_maakond_1271'),
('country_Estonia_67', 'state_J__geva_maakond_1272'),
('country_Estonia_67', 'state_J__rva_maakond_1273'),
('country_Estonia_67', 'state_L____ne_maakond_1274'),
('country_Estonia_67',
'state_L____ne_Viru_maakond_1275'),
('country_Estonia_67', 'state_P__lva_maakond_1276'),
('country_Estonia_67', 'state_P__rnu_maakond_1277'),
('country_Estonia_67', 'state_Rapla_maakond_1278'),
('country_Estonia_67', 'state_Saare_maakond_1279'),
('country_Estonia_67', 'state_Tartu_maakond_1280'),
('country_Estonia_67', 'state_Valga_maakond_1281'),
('country_Estonia_67', 'state_Viljandi_maakond_1282'),
('country_Estonia_67', 'state_V__ru_maakond_1283'),
('country_Ethiopia_68',
'state_____________________1284'),
('country_Ethiopia_68', 'state___________1285'),
('country_Ethiopia_68', 'state___________1286'),
('country_Ethiopia_68',
'state______________________________1287'),
('country_Ethiopia_68', 'state______________1288'),
('country_Ethiopia_68',
'state___________________________1289'),
('country_Ethiopia_68',
'state_____________________1290'),
('country_Ethiopia_68', 'state______________1291'),
('country_Ethiopia_68', 'state___________1292'),
('country_Ethiopia_68',
'state___________________________________________________________1293'),
('country_Ethiopia_68', 'state______________1294'),
('country_Fiji_71', 'state_Central_1295'),
('country_Fiji_71', 'state_Northern_1296'),
('country_Fiji_71', 'state_Eastern_1297'),
('country_Fiji_71', 'state_Rotuma_1298'),
('country_Fiji_71', 'state_Western_1299'),
('country_Finland_72',
'state_Ahvenanmaan_maakunta_1300'),
('country_Finland_72',
'state_Etel___Suomen_l____ni_1301'),
('country_Finland_72',
'state_It___Suomen_l____ni_1302'),
('country_Finland_72', 'state_Lapin_l____ni_1303'),
('country_Finland_72',
'state_L__nsi_Suomen_l____ni_1304'),
('country_Finland_72', 'state_Oulun_l____ni_1305'),
('country_France_73', 'state_Ain_1306'),
('country_France_73', 'state_Aisne_1307'),
('country_France_73', 'state_Allier_1308'),
('country_France_73',
'state_Alpes_de_Haute_Provence_1309'),
('country_France_73', 'state_Hautes_Alpes_1310'),
('country_France_73', 'state_Alpes_Maritimes_1311'),
('country_France_73', 'state_Ard__che_1312'),
('country_France_73', 'state_Ardennes_1313'),
('country_France_73', 'state_Ari__ge_1314'),
('country_France_73', 'state_Aube_1315'),
('country_France_73', 'state_Aude_1316'),
('country_France_73', 'state_Aveyron_1317'),
('country_France_73', 'state_Bouches_du_Rh__ne_1318'),
('country_France_73', 'state_Calvados_1319'),
('country_France_73', 'state_Cantal_1320'),
('country_France_73', 'state_Charente_1321'),
('country_France_73', 'state_Charente_Maritime_1322'),
('country_France_73', 'state_Cher_1323'),
('country_France_73', 'state_Corr__ze_1324'),
('country_France_73', 'state_C__te_d_Or_1325'),
('country_France_73', 'state_C__tes_d_Armor_1326'),
('country_France_73', 'state_Creuse_1327'),
('country_France_73', 'state_Dordogne_1328'),
('country_France_73', 'state_Doubs_1329'),
('country_France_73', 'state_Dr__me_1330'),
('country_France_73', 'state_Eure_1331'),
('country_France_73', 'state_Eure_et_Loir_1332'),
('country_France_73', 'state_Finist__re_1333'),
('country_France_73', 'state_Corse_du_Sud_1334'),
('country_France_73', 'state_Haute_Corse_1335'),
('country_France_73', 'state_Gard_1336'),
('country_France_73', 'state_Haute_Garonne_1337'),
('country_France_73', 'state_Gers_1338'),
('country_France_73', 'state_Gironde_1339'),
('country_France_73', 'state_H__rault_1340'),
('country_France_73', 'state_Ille_et_Vilaine_1341'),
('country_France_73', 'state_Indre_1342'),
('country_France_73', 'state_Indre_et_Loire_1343'),
('country_France_73', 'state_Is__re_1344'),
('country_France_73', 'state_Jura_1345'),
('country_France_73', 'state_Landes_1346'),
('country_France_73', 'state_Loir_et_Cher_1347'),
('country_France_73', 'state_Loire_1348'),
('country_France_73', 'state_Haute_Loire_1349'),
('country_France_73', 'state_Loire_Atlantique_1350'),
('country_France_73', 'state_Loiret_1351'),
('country_France_73', 'state_Lot_1352'),
('country_France_73', 'state_Lot_et_Garonne_1353'),
('country_France_73', 'state_Loz__re_1354'),
('country_France_73', 'state_Maine_et_Loire_1355'),
('country_France_73', 'state_Manche_1356'),
('country_France_73', 'state_Marne_1357'),
('country_France_73', 'state_Haute_Marne_1358'),
('country_France_73', 'state_Mayenne_1359'),
('country_France_73',
'state_Meurthe_et_Moselle_1360'),
('country_France_73', 'state_Meuse_1361'),
('country_France_73', 'state_Morbihan_1362'),
('country_France_73', 'state_Moselle_1363'),
('country_France_73', 'state_Ni__vre_1364'),
('country_France_73', 'state_Nord_1365'),
('country_France_73', 'state_Oise_1366'),
('country_France_73', 'state_Orne_1367'),
('country_France_73', 'state_Pas_de_Calais_1368'),
('country_France_73', 'state_Puy_de_D__me_1369'),
('country_France_73',
'state_Pyr__n__es_Atlantiques_1370'),
('country_France_73', 'state_Hautes_Pyr__n__es_1371'),
('country_France_73',
'state_Pyr__n__es_Orientales_1372'),
('country_France_73', 'state_Bas_Rhin_1373'),
('country_France_73', 'state_Haut_Rhin_1374'),
('country_France_73', 'state_Rh__ne_1375'),
('country_France_73', 'state_Haute_Sa__ne_1376'),
('country_France_73', 'state_Sa__ne_et_Loire_1377'),
('country_France_73', 'state_Sarthe_1378'),
('country_France_73', 'state_Savoie_1379'),
('country_France_73', 'state_Haute_Savoie_1380'),
('country_France_73', 'state_Paris_1381'),
('country_France_73', 'state_Seine_Maritime_1382'),
('country_France_73', 'state_Seine_et_Marne_1383'),
('country_France_73', 'state_Yvelines_1384'),
('country_France_73', 'state_Deux_S__vres_1385'),
('country_France_73', 'state_Somme_1386'),
('country_France_73', 'state_Tarn_1387'),
('country_France_73', 'state_Tarn_et_Garonne_1388'),
('country_France_73', 'state_Var_1389'),
('country_France_73', 'state_Vaucluse_1390'),
('country_France_73', 'state_Vend__e_1391'),
('country_France_73', 'state_Vienne_1392'),
('country_France_73', 'state_Haute_Vienne_1393'),
('country_France_73', 'state_Vosges_1394'),
('country_France_73', 'state_Yonne_1395'),
('country_France_73',
'state_Territoire_de_Belfort_1396'),
('country_France_73', 'state_Essonne_1397'),
('country_France_73', 'state_Hauts_de_Seine_1398'),
('country_France_73', 'state_Seine_Saint_Denis_1399'),
('country_France_73', 'state_Val_de_Marne_1400'),
('country_France_73', 'state_Val_d_Oise_1401'),
('country_France_73',
'state_Territoire_des_Nouvelle_Cal__donie_et_Dependances_1402'),
('country_France_73',
'state_Polyn__sie_Fran__aise_1403'),
('country_France_73',
'state_Saint_Pierre_et_Miquelon_1404'),
('country_France_73',
'state_Terres_australes_et_antarctiques_fran__aises_1405'),
('country_France_73', 'state_Mayotte_1406'),
('country_France_73',
'state_Territoire_des___les_Wallis_et_Futuna_1407'),
('country_France_73', 'country_Guadeloupe_87'),
('country_France_73', 'country_Reunion_174'),
('country_France_73', 'country_Martinique_134'),
('country_French_Polynesia_76',
'state_Archipel_des_Marquises_1408'),
('country_French_Polynesia_76',
'state_Archipel_des_Tuamotu_1409'),
('country_French_Polynesia_76',
'state_Archipel_des_Tubuai_1410'),
('country_French_Polynesia_76',
'state_Iles_du_Vent_1411'),
('country_French_Polynesia_76',
'state_Iles_Sous_le_Vent__1412'),
('country_French_Southern_Territories_77',
'state_Iles_Crozet_1413'),
('country_French_Southern_Territories_77',
'state_Iles_Kerguelen_1414'),
('country_French_Southern_Territories_77',
'state_Ile_Amsterdam_1415'),
('country_French_Southern_Territories_77',
'state_Ile_Saint_Paul_1416'),
('country_French_Southern_Territories_77',
'state_Adelie_Land_1417'),
('country_Gabon_78', 'state_Estuaire_1418'),
('country_Gabon_78', 'state_Haut_Ogooue_1419'),
('country_Gabon_78', 'state_Moyen_Ogooue_1420'),
('country_Gabon_78', 'state_Ngounie_1421'),
('country_Gabon_78', 'state_Nyanga_1422'),
('country_Gabon_78', 'state_Ogooue_Ivindo_1423'),
('country_Gabon_78', 'state_Ogooue_Lolo_1424'),
('country_Gabon_78', 'state_Ogooue_Maritime_1425'),
('country_Gabon_78', 'state_Woleu_Ntem_1426'),
('country_Gambia_79', 'state_Ashanti_1427'),
('country_Gambia_79', 'state_Brong_Ahafo_1428'),
('country_Gambia_79', 'state_Central_1429'),
('country_Gambia_79', 'state_Eastern_1430'),
('country_Gambia_79', 'state_Greater_Accra_1431'),
('country_Gambia_79', 'state_Northern_1432'),
('country_Gambia_79', 'state_Upper_East_1433'),
('country_Gambia_79', 'state_Upper_West_1434'),
('country_Gambia_79', 'state_Volta_1435'),
('country_Gambia_79', 'state_Western_1436'),
('country_Georgia_80',
'state__________________________1437'),
('country_Georgia_80', 'state_________________1438'),
('country_Georgia_80', 'state_________________1439'),
('country_Georgia_80',
'state_______________________1440'),
('country_Georgia_80',
'state____________________1441'),
('country_Georgia_80',
'state____________________________________1442'),
('country_Georgia_80',
'state_____________________________________________1443'),
('country_Georgia_80',
'state_________________________________________________________________________________1444'),
('country_Georgia_80',
'state_____________________________________________1445'),
('country_Georgia_80',
'state_________________________________1446'),
('country_Georgia_80',
'state________________________________________________________________1447'),
('country_Georgia_80',
'state_______________________1448'),
('country_Germany_81', 'state_Berlin_1449'),
('country_Germany_81', 'state_Brandenburg_1450'),
('country_Germany_81',
'state_Baden_W__rttemberg_1451'),
('country_Germany_81', 'state_Bayern_1452'),
('country_Germany_81', 'state_Bremen_1453'),
('country_Germany_81', 'state_Hessen_1454'),
('country_Germany_81', 'state_Hamburg_1455'),
('country_Germany_81',
'state_Mecklenburg_Vorpommern_1456'),
('country_Germany_81', 'state_Niedersachsen_1457'),
('country_Germany_81',
'state_Nordrhein_Westfalen_1458'),
('country_Germany_81', 'state_Rheinland_Pfalz_1459'),
('country_Germany_81',
'state_Schleswig_Holstein_1460'),
('country_Germany_81', 'state_Saarland_1461'),
('country_Germany_81', 'state_Sachsen_1462'),
('country_Germany_81', 'state_Sachsen_Anhalt_1463'),
('country_Germany_81', 'state_Th__ringen_1464'),
('country_Greece_84',
'state________________________________1475'),
('country_Greece_84', 'state________________1476'),
('country_Greece_84', 'state______________1477'),
('country_Greece_84',
'state____________________1478'),
('country_Greece_84', 'state__________________1479'),
('country_Greece_84', 'state______________1480'),
('country_Greece_84', 'state__________________1481'),
('country_Greece_84', 'state________________1482'),
('country_Greece_84', 'state_____________1483'),
('country_Greece_84', 'state____________1484'),
('country_Greece_84', 'state__________________1485'),
('country_Greece_84', 'state________________1486'),
('country_Greece_84', 'state__________________1487'),
('country_Greece_84', 'state__________________1488'),
('country_Greece_84', 'state________________1489'),
('country_Greece_84',
'state______________________1490'),
('country_Greece_84', 'state________________1491'),
('country_Greece_84', 'state__________1492'),
('country_Greece_84',
'state____________________1493'),
('country_Greece_84', 'state__________________1494'),
('country_Greece_84', 'state________________1495'),
('country_Greece_84', 'state__________________1496'),
('country_Greece_84', 'state______________1497'),
('country_Greece_84', 'state__________________1498'),
('country_Greece_84', 'state________________1499'),
('country_Greece_84', 'state________________1500'),
('country_Greece_84', 'state____________1501'),
('country_Greece_84', 'state______________1502'),
('country_Greece_84',
'state________________________1503'),
('country_Greece_84', 'state______________1504'),
('country_Greece_84', 'state__________________1505'),
('country_Greece_84', 'state______________1506'),
('country_Greece_84', 'state______________1507'),
('country_Greece_84', 'state____________1508'),
('country_Greece_84', 'state______________1509'),
('country_Greece_84', 'state______________1510'),
('country_Greece_84', 'state________________1511'),
('country_Greece_84',
'state____________________1512'),
('country_Greece_84', 'state___________________1513'),
('country_Greece_84', 'state____________1514'),
('country_Greece_84', 'state____________1515'),
('country_Greece_84', 'state______________1516'),
('country_Greece_84',
'state______________________1517'),
('country_Greece_84', 'state__________________1518'),
('country_Greece_84', 'state______________1519'),
('country_Greece_84', 'state____________1520'),
('country_Greece_84', 'state__________1521'),
('country_Greece_84', 'state__________________1522'),
('country_Greece_84', 'state______________1523'),
('country_Greece_84', 'state________________1524'),
('country_Greece_84', 'state______________1525'),
('country_Greece_84', 'state______________1526'),
('country_Greenland_85', 'state_Avannaa_1527'),
('country_Greenland_85', 'state_Tunu__1528'),
('country_Greenland_85', 'state_Kitaa_1529'),
('country_Grenada_86', 'state_Saint_David_1531'),
('country_Grenada_86', 'state_Saint_Mark_1534'),
('country_Grenada_86', 'state_Saint_Patrick_1535'),
('country_Guatemala_89', 'state_Alta_Verapaz_1536'),
('country_Guatemala_89', 'state_Baja_Verapaz_1537'),
('country_Guatemala_89', 'state_Chimaltenango_1538'),
('country_Guatemala_89', 'state_Chiquimula_1539'),
('country_Guatemala_89', 'state_Escuintla_1540'),
('country_Guatemala_89', 'state_Guatemala_1541'),
('country_Guatemala_89', 'state_Huehuetenango_1542'),
('country_Guatemala_89', 'state_Izabal_1543'),
('country_Guatemala_89', 'state_Jalapa_1544'),
('country_Guatemala_89', 'state_Jutiapa_1545'),
('country_Guatemala_89', 'state_El_Pet__n_1546'),
('country_Guatemala_89', 'state_El_Progreso_1547'),
('country_Guatemala_89', 'state_El_Quich___1548'),
('country_Guatemala_89', 'state_Quetzaltenango_1549'),
('country_Guatemala_89', 'state_Retalhuleu_1550'),
('country_Guatemala_89', 'state_Sacatep__quez_1551'),
('country_Guatemala_89', 'state_San_Marcos_1552'),
('country_Guatemala_89', 'state_Solol___1553'),
('country_Guatemala_89', 'state_Santa_Rosa_1554'),
('country_Guatemala_89', 'state_Suchitep__quez_1555'),
('country_Guatemala_89', 'state_Totonicap__n_1556'),
('country_Guatemala_89', 'state_Zacapa_1557'),
('country_Guinea_90', 'state_Beyla_1558'),
('country_Guinea_90', 'state_Boffa_1559'),
('country_Guinea_90', 'state_Bok___1560'),
('country_Guinea_90', 'state_Coyah_1561'),
('country_Guinea_90', 'state_Dabola_1562'),
('country_Guinea_90', 'state_Dinguiraye_1563'),
('country_Guinea_90', 'state_Dalaba_1564'),
('country_Guinea_90', 'state_Dubr__ka_1565'),
('country_Guinea_90', 'state_Faranah_1566'),
('country_Guinea_90', 'state_For__cariah_1567'),
('country_Guinea_90', 'state_Fria_1568'),
('country_Guinea_90', 'state_Gaoual_1569'),
('country_Guinea_90', 'state_Gu__k__dou_1570'),
('country_Guinea_90', 'state_Kankan_1571'),
('country_Guinea_90', 'state_Koubia_1572'),
('country_Guinea_90', 'state_Kindia_1573'),
('country_Guinea_90', 'state_K__rouan___1574'),
('country_Guinea_90', 'state_Koundara_1575'),
('country_Guinea_90', 'state_Kouroussa_1576'),
('country_Guinea_90', 'state_Kissidougou_1577'),
('country_Guinea_90', 'state_Lab___1578'),
('country_Guinea_90', 'state_L__louma_1579'),
('country_Guinea_90', 'state_Lola_1580'),
('country_Guinea_90', 'state_Macenta_1581'),
('country_Guinea_90', 'state_Mandiana_1582'),
('country_Guinea_90', 'state_Mali_1583'),
('country_Guinea_90', 'state_Mamou_1584'),
('country_Guinea_90', 'state_Nz__r__kor___1585'),
('country_Guinea_90', 'state_Pita_1586'),
('country_Guinea_90', 'state_Siguiri_1587'),
('country_Guinea_90', 'state_T__lim__l___1588'),
('country_Guinea_90', 'state_Tougu___1589'),
('country_Guinea_90', 'state_Yomou_1590'),
('country_Guinea_Bissau_91', 'state_Bafata_1591'),
('country_Guinea_Bissau_91', 'state_Biombo_1592'),
('country_Guinea_Bissau_91', 'state_Bissau_1593'),
('country_Guinea_Bissau_91', 'state_Bolama_1594'),
('country_Guinea_Bissau_91', 'state_Cacheu_1595'),
('country_Guinea_Bissau_91', 'state_Gabu_1596'),
('country_Guinea_Bissau_91', 'state_Oio_1597'),
('country_Guinea_Bissau_91', 'state_Quinara_1598'),
('country_Guinea_Bissau_91', 'state_Tombali_1599'),
('country_Guyana_92', 'state_Barima_Waini_1600'),
('country_Guyana_92', 'state_Cuyuni_Mazaruni_1601'),
('country_Guyana_92', 'state_Demerara_Mahaica_1602'),
('country_Guyana_92',
'state_East_Berbice_Corentyne_1603'),
('country_Guyana_92',
'state_Essequibo_Islands_West_Demerara_1604'),
('country_Guyana_92', 'state_Mahaica_Berbice_1605'),
('country_Guyana_92', 'state_Pomeroon_Supenaam_1606'),
('country_Guyana_92', 'state_Potaro_Siparuni_1607'),
('country_Guyana_92',
'state_Upper_Demerara_Berbice_1608'),
('country_Guyana_92',
'state_Upper_Takutu_Upper_Essequibo_1609'),
('country_Haiti_93', 'state_Artibonite_1610'),
('country_Haiti_93', 'state_Grand_Anse_1612'),
('country_Haiti_93', 'state_Nippes_1613'),
('country_Haiti_93', 'state_Nord_1614'),
('country_Haiti_93', 'state_Nord_Est_1615'),
('country_Haiti_93', 'state_Nord_Ouest_1616'),
('country_Haiti_93', 'state_Sud_1618'),
('country_Haiti_93', 'state_Sud_Est_1619'),
('country_Heard_and_McDonald_Islands_94',
'state_Flat_Island_1620'),
('country_Heard_and_McDonald_Islands_94',
'state_McDonald_Island_1621'),
('country_Heard_and_McDonald_Islands_94',
'state_Shag_Island_1622'),
('country_Heard_and_McDonald_Islands_94',
'state_Heard_Island_1623'),
('country_Honduras_95', 'state_Atl__ntida_1624'),
('country_Honduras_95', 'state_Choluteca_1625'),
('country_Honduras_95', 'state_Col__n_1626'),
('country_Honduras_95', 'state_Comayagua_1627'),
('country_Honduras_95', 'state_Cop__n_1628'),
('country_Honduras_95', 'state_Cort__s_1629'),
('country_Honduras_95', 'state_El_Para__so_1630'),
('country_Honduras_95',
'state_Francisco_Moraz__n_1631'),
('country_Honduras_95', 'state_Gracias_a_Dios_1632'),
('country_Honduras_95',
'state_Islas_de_la_Bah__a_1633'),
('country_Honduras_95', 'state_Intibuc___1634'),
('country_Honduras_95', 'state_Lempira_1635'),
('country_Honduras_95', 'state_La_Paz_1636'),
('country_Honduras_95', 'state_Ocotepeque_1637'),
('country_Honduras_95', 'state_Olancho_1638'),
('country_Honduras_95', 'state_Santa_B__rbara_1639'),
('country_Honduras_95', 'state_Valle_1640'),
('country_Honduras_95', 'state_Yoro_1641'),
('country_Hong_Kong_96', 'state___________1642'),
('country_Hong_Kong_96', 'state________1643'),
('country_Hong_Kong_96', 'state________1644'),
('country_Hong_Kong_96', 'state___________1645'),
('country_Hong_Kong_96', 'state______________1646'),
('country_Hong_Kong_96', 'state___________1647'),
('country_Hong_Kong_96', 'state______________1648'),
('country_Hong_Kong_96', 'state______________1649'),
('country_Hong_Kong_96', 'state______________1650'),
('country_Hong_Kong_96', 'state___________1651'),
('country_Hong_Kong_96', 'state___________1652'),
('country_Hong_Kong_96', 'state________1653'),
('country_Hong_Kong_96', 'state___________1654'),
('country_Hong_Kong_96', 'state___________1655'),
('country_Hong_Kong_96', 'state___________1656'),
('country_Hong_Kong_96', 'state___________1657'),
('country_Hong_Kong_96', 'state___________1658'),
('country_Hong_Kong_96', 'state___________1659'),
('country_Hungary_97', 'state_Baranja_megye_1660'),
('country_Hungary_97', 'state_B__k__scsaba_1661'),
('country_Hungary_97', 'state_B__k__s_megye_1662'),
('country_Hungary_97',
'state_B__cs_Kiskun_megye_1663'),
('country_Hungary_97', 'state_Budapest_1664'),
('country_Hungary_97',
'state_Borsod_Aba__j_Zempl__n_megye_1665'),
('country_Hungary_97', 'state_Csongr__d_megye_1666'),
('country_Hungary_97', 'state_Debrecen_1667'),
('country_Hungary_97', 'state_Duna__jv__ros_1668'),
('country_Hungary_97', 'state_Eger_1669'),
('country_Hungary_97', 'state_Fej__r_megye_1670'),
('country_Hungary_97',
'state_Gy__r_Moson_Sopron_megye_1671'),
('country_Hungary_97', 'state_Gy__r_1672'),
('country_Hungary_97',
'state_Hajd___Bihar_megye_1673'),
('country_Hungary_97', 'state_Heves_megye_1674'),
('country_Hungary_97',
'state_H__dmez__v__s__rhely_1675'),
('country_Hungary_97',
'state_J__sz_Nagykun_Szolnok_megye_1676'),
('country_Hungary_97',
'state_Kom__rom_Esztergom_megye_1677'),
('country_Hungary_97', 'state_Kecskem__t_1678'),
('country_Hungary_97', 'state_Kaposv__r_1679'),
('country_Hungary_97', 'state_Miskolc_1680'),
('country_Hungary_97', 'state_Nagykanizsa_1681'),
('country_Hungary_97', 'state_N__gr__d_megye_1682'),
('country_Hungary_97', 'state_Ny__regyh__za_1683'),
('country_Hungary_97', 'state_Pest_megye_1684'),
('country_Hungary_97', 'state_P__cs_1685'),
('country_Hungary_97', 'state_Szeged_1686'),
('country_Hungary_97',
'state_Sz__kesfeh__rv__r_1687'),
('country_Hungary_97', 'state_Szombathely_1688'),
('country_Hungary_97', 'state_Szolnok_1689'),
('country_Hungary_97', 'state_Sopron_1690'),
('country_Hungary_97', 'state_Somogy_megye_1691'),
('country_Hungary_97', 'state_Szeksz__rd_1692'),
('country_Hungary_97', 'state_Salg__tarj__n_1693'),
('country_Hungary_97',
'state_Szabolcs_Szatm__r_Bereg_megye_1694'),
('country_Hungary_97', 'state_Tatab__nya_1695'),
('country_Hungary_97', 'state_Tolna_megye_1696'),
('country_Hungary_97', 'state_Vas_megye_1697'),
('country_Hungary_97', 'state_Veszpr__m_megye_1698'),
('country_Hungary_97', 'state_Veszpr__m_1699'),
('country_Hungary_97', 'state_Zala_megye_1700'),
('country_Hungary_97', 'state_Zalaegerszeg_1701'),
('country_Iceland_98',
'state_H__fu__borgarsv____i___1702'),
('country_Iceland_98', 'state_Su__urnes_1703'),
('country_Iceland_98', 'state_Vesturland_1704'),
('country_Iceland_98', 'state_Vestfir__ir_1705'),
('country_Iceland_98',
'state_Nor__urland_vestra_1706'),
('country_Iceland_98',
'state_Nor__urland_eystra_1707'),
('country_Iceland_98', 'state_Austfir__ir_1708'),
('country_Iceland_98', 'state_Su__urland_1709'),
('country_India_99',
'state_________________________________________________________________1710'),
('country_India_99',
'state_______________________________________1711'),
('country_India_99',
'state__________________________________________1712'),
('country_India_99', 'state___________1713'),
('country_India_99', 'state_________________1714'),
('country_India_99',
'state_______________________1715'),
('country_India_99',
'state_____________________________1716'),
('country_India_99',
'state_______________________________1717'),
('country_India_99', 'state____________________1718'),
('country_India_99',
'state_____________________________________________________1719'),
('country_India_99', 'state______________1720'),
('country_India_99', 'state____________________1721'),
('country_India_99',
'state_______________________________________1722'),
('country_India_99',
'state_______________________1723'),
('country_India_99', 'state____________________1724'),
('country_India_99',
'state___________________________________________1725'),
('country_India_99', 'state____________________1726'),
('country_India_99', 'state_________________1727'),
('country_India_99',
'state________________________________1728'),
('country_India_99', 'state____________________1729'),
('country_India_99',
'state________________________________1730'),
('country_India_99', 'state____________________1731'),
('country_India_99',
'state_________________________________1732'),
('country_India_99',
'state_______________________1733'),
('country_India_99',
'state__________________________1734'),
('country_India_99', 'state____________________1735'),
('country_India_99', 'state_________________1736'),
('country_India_99',
'state________________________________1737'),
('country_India_99',
'state__________________________1738'),
('country_India_99',
'state_______________________1739'),
('country_India_99',
'state______________________________1740'),
('country_India_99',
'state__________________________1741'),
('country_India_99',
'state_____________________________1742'),
('country_India_99',
'state____________________________________1743'),
('country_India_99',
'state________________________________1744'),
('country_Indonesia_100', 'state_Aceh_1745'),
('country_Indonesia_100', 'state_Bali_1746'),
('country_Indonesia_100',
'state_Bangka_Belitung_1747'),
('country_Indonesia_100', 'state_Bengkulu_1748'),
('country_Indonesia_100', 'state_Banten_1749'),
('country_Indonesia_100',
'state_Gorontalo_1750')";
$this->db->setQuery($query);
$this->db->query();
$query="INSERT IGNORE INTO `#__hikashop_zone_link`
(`zone_parent_namekey`, `zone_child_namekey`) VALUES
('country_Indonesia_100', 'state_Papua_1751'),
('country_Indonesia_100', 'state_Jambi_1752'),
('country_Indonesia_100', 'state_Jawa_Timur_1753'),
('country_Indonesia_100', 'state_Jakarta_Raya_1754'),
('country_Indonesia_100', 'state_Jawa_Barat_1755'),
('country_Indonesia_100', 'state_Jawa_Tengah_1756'),
('country_Indonesia_100',
'state_Kalimantan_Barat_1757'),
('country_Indonesia_100',
'state_Kalimantan_Timur_1758'),
('country_Indonesia_100',
'state_Kalimantan_Selatan_1759'),
('country_Indonesia_100',
'state_Kalimantan_Tengah_1760'),
('country_Indonesia_100', 'state_Lampung_1761'),
('country_Indonesia_100', 'state_Maluku_1762'),
('country_Indonesia_100', 'state_Maluku_Utara_1763'),
('country_Indonesia_100',
'state_Nusa_Tenggara_Barat_1764'),
('country_Indonesia_100',
'state_Nusa_Tenggara_Timur_1765'),
('country_Indonesia_100', 'state_Riau_1766'),
('country_Indonesia_100',
'state_Sumatera_Barat_1767'),
('country_Indonesia_100',
'state_Sulawesi_Tenggara_1768'),
('country_Indonesia_100',
'state_Sumatera_Selatan_1769'),
('country_Indonesia_100',
'state_Sulawesi_Selatan_1770'),
('country_Indonesia_100',
'state_Sulawesi_Tengah_1771'),
('country_Indonesia_100',
'state_Sulawesi_Utara_1772'),
('country_Indonesia_100',
'state_Sumatera_Utara_1773'),
('country_Indonesia_100', 'state_Yogyakarta_1774'),
('country_Iran_101',
'state__________________________________________1775'),
('country_Iran_101',
'state__________________________________________1776'),
('country_Iran_101',
'state___________________________1777'),
('country_Iran_101',
'state___________________________1778'),
('country_Iran_101',
'state_________________________1779'),
('country_Iran_101',
'state_________________________1780'),
('country_Iran_101',
'state_________________________1781'),
('country_Iran_101',
'state_______________________________________________1782'),
('country_Iran_101',
'state____________________________________1783'),
('country_Iran_101',
'state_____________________________1784'),
('country_Iran_101',
'state_________________________1785'),
('country_Iran_101',
'state_________________________1786'),
('country_Iran_101',
'state________________________________________________1787'),
('country_Iran_101',
'state_______________________1788'),
('country_Iran_101',
'state_________________________1789'),
('country_Iran_101',
'state_____________________________1790'),
('country_Iran_101',
'state_______________________________1791'),
('country_Iran_101',
'state____________________________________________________1792'),
('country_Iran_101',
'state_________________________1793'),
('country_Iran_101',
'state___________________________1794'),
('country_Iran_101',
'state_______________________________1795'),
('country_Iran_101',
'state_________________________1796'),
('country_Iran_101',
'state_____________________________1797'),
('country_Iran_101',
'state_________________________1798'),
('country_Iran_101',
'state_____________________1799'),
('country_Iran_101', 'state___________________1800'),
('country_Iran_101',
'state___________________________1801'),
('country_Iran_101',
'state_________________________1802'),
('country_Iraq_102',
'state_____________________________1803'),
('country_Iraq_102', 'state____________1804'),
('country_Iraq_102',
'state___________________________1805'),
('country_Iraq_102', 'state__________1806'),
('country_Iraq_102',
'state_________________________1807'),
('country_Iraq_102', 'state__________1808'),
('country_Iraq_102', 'state____________1809'),
('country_Iraq_102', 'state_____________1810'),
('country_Iraq_102', 'state______________1811'),
('country_Iraq_102', 'state____________1812'),
('country_Iraq_102', 'state______________1813'),
('country_Iraq_102', 'state____________1814'),
('country_Iraq_102', 'state____________1815'),
('country_Iraq_102', 'state__________________1816'),
('country_Iraq_102',
'state_____________________1817'),
('country_Iraq_102',
'state___________________________________1818'),
('country_Iraq_102', 'state________________1819'),
('country_Iraq_102', 'state__________1820'),
('country_Ireland_103', 'state_Corcaigh_1821'),
('country_Ireland_103',
'state_Contae_an_Chl__ir_1822'),
('country_Ireland_103', 'state_An_Cabh__n_1823'),
('country_Ireland_103', 'state_Ceatharlach_1824'),
('country_Ireland_103',
'state_Baile___tha_Cliath_1825'),
('country_Ireland_103', 'state_D__n_na_nGall_1826'),
('country_Ireland_103', 'state_Gaillimh_1827'),
('country_Ireland_103', 'state_Cill_Dara_1828'),
('country_Ireland_103', 'state_Cill_Chainnigh_1829'),
('country_Ireland_103',
'state_Contae_Chiarra___1830'),
('country_Ireland_103', 'state_An_Longfort_1831'),
('country_Ireland_103', 'state_Contae_L___1832'),
('country_Ireland_103', 'state_Luimneach_1833'),
('country_Ireland_103', 'state_Contae_Liatroma_1834'),
('country_Ireland_103', 'state_Contae_Laoise_1835'),
('country_Ireland_103', 'state_Contae_na_M___1836'),
('country_Ireland_103', 'state_Muineach__n_1837'),
('country_Ireland_103',
'state_Contae_Mhaigh_Eo_1838'),
('country_Ireland_103',
'state_Contae_U__bh_Fhail___1839'),
('country_Ireland_103', 'state_Ros_Com__in_1840'),
('country_Ireland_103', 'state_Sligeach_1841'),
('country_Ireland_103', 'state_Tiobraid___rann_1842'),
('country_Ireland_103', 'state_Port_Lairge_1843'),
('country_Ireland_103',
'state_Contae_na_hIarmh___1844'),
('country_Ireland_103', 'state_Cill_Mhant__in_1845'),
('country_Ireland_103', 'state_Loch_Garman_1846'),
('country_Israel_104',
'state_____________________1847'),
('country_Israel_104',
'state___________________1848'),
('country_Israel_104', 'state________________1849'),
('country_Israel_104',
'state_____________________1850'),
('country_Israel_104',
'state______________________1851'),
('country_Israel_104',
'state_____________________1852'),
('country_Italy_105', 'state_Agrigento_1853'),
('country_Italy_105', 'state_Alessandria_1854'),
('country_Italy_105', 'state_Ancona_1855'),
('country_Italy_105', 'state_Valle_d_Aosta_1856'),
('country_Italy_105', 'state_Ascoli_Piceno_1857'),
('country_Italy_105', 'state_L_Aquila_1858'),
('country_Italy_105', 'state_Arezzo_1859'),
('country_Italy_105', 'state_Asti_1860'),
('country_Italy_105', 'state_Avellino_1861'),
('country_Italy_105', 'state_Bari_1862'),
('country_Italy_105', 'state_Bergamo_1863'),
('country_Italy_105', 'state_Biella_1864'),
('country_Italy_105', 'state_Belluno_1865'),
('country_Italy_105', 'state_Benevento_1866'),
('country_Italy_105', 'state_Bologna_1867'),
('country_Italy_105', 'state_Brindisi_1868'),
('country_Italy_105', 'state_Brescia_1869'),
('country_Italy_105',
'state_Barletta_Andria_Trani_1870'),
('country_Italy_105', 'state_Alto_Adige_1871'),
('country_Italy_105', 'state_Cagliari_1872'),
('country_Italy_105', 'state_Campobasso_1873'),
('country_Italy_105', 'state_Caserta_1874'),
('country_Italy_105', 'state_Chieti_1875'),
('country_Italy_105', 'state_Carbonia_Iglesias_1876'),
('country_Italy_105', 'state_Caltanissetta_1877'),
('country_Italy_105', 'state_Cuneo_1878'),
('country_Italy_105', 'state_Como_1879'),
('country_Italy_105', 'state_Cremona_1880'),
('country_Italy_105', 'state_Cosenza_1881'),
('country_Italy_105', 'state_Catania_1882'),
('country_Italy_105', 'state_Catanzaro_1883'),
('country_Italy_105', 'state_Enna_1884'),
('country_Italy_105', 'state_Ferrara_1885'),
('country_Italy_105', 'state_Foggia_1886'),
('country_Italy_105', 'state_Firenze_1887'),
('country_Italy_105', 'state_Fermo_1888'),
('country_Italy_105', 'state_Forl___Cesena_1889'),
('country_Italy_105', 'state_Frosinone_1890'),
('country_Italy_105', 'state_Genova_1891'),
('country_Italy_105', 'state_Gorizia_1892'),
('country_Italy_105', 'state_Grosseto_1893'),
('country_Italy_105', 'state_Imperia_1894'),
('country_Italy_105', 'state_Isernia_1895'),
('country_Italy_105', 'state_Crotone_1896'),
('country_Italy_105', 'state_Lecco_1897'),
('country_Italy_105', 'state_Lecce_1898'),
('country_Italy_105', 'state_Livorno_1899'),
('country_Italy_105', 'state_Lodi_1900'),
('country_Italy_105', 'state_Latina_1901'),
('country_Italy_105', 'state_Lucca_1902'),
('country_Italy_105', 'state_Macerata_1903'),
('country_Italy_105', 'state_Medio_Campidano_1904'),
('country_Italy_105', 'state_Messina_1905'),
('country_Italy_105', 'state_Milano_1906'),
('country_Italy_105', 'state_Mantova_1907'),
('country_Italy_105', 'state_Modena_1908'),
('country_Italy_105', 'state_Massa_Carrara_1909'),
('country_Italy_105', 'state_Matera_1910'),
('country_Italy_105', 'state_Monza_e_Brianza_1911'),
('country_Italy_105', 'state_Napoli_1912'),
('country_Italy_105', 'state_Novara_1913'),
('country_Italy_105', 'state_Nuoro_1914'),
('country_Italy_105', 'state_Ogliastra_1915'),
('country_Italy_105', 'state_Oristano_1916'),
('country_Italy_105', 'state_Olbia_Tempio_1917'),
('country_Italy_105', 'state_Palermo_1918'),
('country_Italy_105', 'state_Piacenza_1919'),
('country_Italy_105', 'state_Padova_1920'),
('country_Italy_105', 'state_Pescara_1921'),
('country_Italy_105', 'state_Perugia_1922'),
('country_Italy_105', 'state_Pisa_1923'),
('country_Italy_105', 'state_Pordenone_1924'),
('country_Italy_105', 'state_Prato_1925'),
('country_Italy_105', 'state_Parma_1926'),
('country_Italy_105', 'state_Pesaro_e_Urbino_1927'),
('country_Italy_105', 'state_Pistoia_1928'),
('country_Italy_105', 'state_Pavia_1929'),
('country_Italy_105', 'state_Potenza_1930'),
('country_Italy_105', 'state_Ravenna_1931'),
('country_Italy_105', 'state_Reggio_Calabria_1932'),
('country_Italy_105', 'state_Reggio_Emilia_1933'),
('country_Italy_105', 'state_Ragusa_1934'),
('country_Italy_105', 'state_Rieti_1935'),
('country_Italy_105', 'state_Roma_1936'),
('country_Italy_105', 'state_Rimini_1937'),
('country_Italy_105', 'state_Rovigo_1938'),
('country_Italy_105', 'state_Salerno_1939'),
('country_Italy_105', 'state_Siena_1940'),
('country_Italy_105', 'state_Sondrio_1941'),
('country_Italy_105', 'state_La_Spezia_1942'),
('country_Italy_105', 'state_Siracusa_1943'),
('country_Italy_105', 'state_Sassari_1944'),
('country_Italy_105', 'state_Savona_1945'),
('country_Italy_105', 'state_Taranto_1946'),
('country_Italy_105', 'state_Teramo_1947'),
('country_Italy_105', 'state_Trento_1948'),
('country_Italy_105', 'state_Torino_1949'),
('country_Italy_105', 'state_Trapani_1950'),
('country_Italy_105', 'state_Terni_1951'),
('country_Italy_105', 'state_Trieste_1952'),
('country_Italy_105', 'state_Treviso_1953'),
('country_Italy_105', 'state_Udine_1954'),
('country_Italy_105', 'state_Varese_1955'),
('country_Italy_105',
'state_Verbano_Cusio_Ossola_1956'),
('country_Italy_105', 'state_Vercelli_1957'),
('country_Italy_105', 'state_Venezia_1958'),
('country_Italy_105', 'state_Vicenza_1959'),
('country_Italy_105', 'state_Verona_1960'),
('country_Italy_105', 'state_Viterbo_1961'),
('country_Italy_105', 'state_Vibo_Valentia_1962'),
('country_Jamaica_106', 'state_Kingston_1963'),
('country_Jamaica_106', 'state_Half_Way_Tree_1964'),
('country_Jamaica_106', 'state_Morant_Bay_1965'),
('country_Jamaica_106', 'state_Port_Antonio_1966'),
('country_Jamaica_106', 'state_Port_Maria_1967'),
('country_Jamaica_106', 'state_Saint_Ann_s_Bay_1968'),
('country_Jamaica_106', 'state_Falmouth_1969'),
('country_Jamaica_106', 'state_Montego_Bay_1970'),
('country_Jamaica_106', 'state_Lucea_1971'),
('country_Jamaica_106', 'state_Savanna_la_Mar_1972'),
('country_Jamaica_106', 'state_Black_River_1973'),
('country_Jamaica_106', 'state_Mandeville_1974'),
('country_Jamaica_106', 'state_May_Pen_1975'),
('country_Jamaica_106', 'state_Spanish_Town_1976'),
('country_Japan_', '1977'),
('country_Japan_107', 'state________1978'),
('country_Japan_107', 'state________1979'),
('country_Japan_107', 'state________1980'),
('country_Japan_107', 'state________1981'),
('country_Japan_107', 'state________1982'),
('country_Japan_107', 'state________1983'),
('country_Japan_107', 'state________1984'),
('country_Japan_107', 'state________1985'),
('country_Japan_107', 'state________1986'),
('country_Japan_107', 'state________1987'),
('country_Japan_107', 'state________1988'),
('country_Japan_107', 'state________1989'),
('country_Japan_107', 'state___________1990'),
('country_Japan_107', 'state________1991'),
('country_Japan_107', 'state________1992'),
('country_Japan_107', 'state________1993'),
('country_Japan_107', 'state________1994'),
('country_Japan_107', 'state________1995'),
('country_Japan_107', 'state________1996'),
('country_Japan_107', 'state________1997'),
('country_Japan_107', 'state________1998'),
('country_Japan_107', 'state________1999'),
('country_Japan_107', 'state________2000'),
('country_Japan_107', 'state________2001'),
('country_Japan_107', 'state________2002'),
('country_Japan_107', 'state________2003'),
('country_Japan_107', 'state________2004'),
('country_Japan_107', 'state________2005'),
('country_Japan_107', 'state___________2006'),
('country_Japan_107', 'state________2007'),
('country_Japan_107', 'state________2008'),
('country_Japan_107', 'state________2009'),
('country_Japan_107', 'state________2010'),
('country_Japan_107', 'state________2011'),
('country_Japan_107', 'state________2012'),
('country_Japan_107', 'state________2013'),
('country_Japan_107', 'state________2014'),
('country_Japan_107', 'state________2015'),
('country_Japan_107', 'state________2016'),
('country_Japan_107', 'state________2017'),
('country_Japan_107', 'state________2018'),
('country_Japan_107', 'state________2019'),
('country_Japan_107', 'state________2020'),
('country_Japan_107', 'state________2021'),
('country_Japan_107', 'state___________2022'),
('country_Japan_107', 'state________2023'),
('country_Jordan_108',
'state_________________________2024'),
('country_Jordan_108',
'state_____________________________2025'),
('country_Jordan_108',
'state___________________________2026'),
('country_Jordan_108',
'state_____________________________2027'),
('country_Jordan_108',
'state_____________________________2028'),
('country_Jordan_108',
'state_____________________________2029'),
('country_Jordan_108',
'state_____________________2030'),
('country_Jordan_108',
'state_______________________2031'),
('country_Jordan_108',
'state_________________________2032'),
('country_Jordan_108',
'state___________________________2033'),
('country_Jordan_108',
'state_________________________2034'),
('country_Jordan_108',
'state_______________________2035'),
('country_Kazakhstan_109', 'state______________2036'),
('country_Kazakhstan_109', 'state_Almaty_City_2037'),
('country_Kazakhstan_109', 'state______________2038'),
('country_Kazakhstan_109', 'state______________2039'),
('country_Kazakhstan_109', 'state______________2040'),
('country_Kazakhstan_109', 'state______________2041'),
('country_Kazakhstan_109',
'state_______________________________2042'),
('country_Kazakhstan_109',
'state__________________2043'),
('country_Kazakhstan_109',
'state____________________2044'),
('country_Kazakhstan_109',
'state_____________________________________2045'),
('country_Kazakhstan_109',
'state__________________2046'),
('country_Kazakhstan_109',
'state____________________2047'),
('country_Kazakhstan_109',
'state__________________2048'),
('country_Kazakhstan_109',
'state____________________2049'),
('country_Kazakhstan_109',
'state_______________________________2050'),
('country_Kazakhstan_109',
'state_______________________________________2051'),
('country_Kazakhstan_109', 'state______________2052'),
('country_Kenya_110', 'state_Nairobi_2053'),
('country_Kenya_110', 'state_Central_2054'),
('country_Kenya_110', 'state_Mombasa_2055'),
('country_Kenya_110', 'state_Eastern_2056'),
('country_Kenya_110', 'state_North_Eastern_2057'),
('country_Kenya_110', 'state_Nyanza_2058'),
('country_Kenya_110', 'state_Rift_Valley_2059'),
('country_Kenya_110', 'state_Western_2060'),
('country_Kiribati_111',
'state_Gilbert_Islands_2061'),
('country_Kiribati_111', 'state_Line_Islands_2062'),
('country_Kiribati_111',
'state_Phoenix_Islands_2063'),
('country_Korea__North_112', 'state___________2064'),
('country_Korea__North_112',
'state_______________2065'),
('country_Korea__North_112',
'state_______________2066'),
('country_Korea__North_112',
'state_______________2067'),
('country_Korea__North_112',
'state_______________2068'),
('country_Korea__North_112', 'state___________2069'),
('country_Korea__North_112', 'state___________2070'),
('country_Korea__North_112',
'state__________________2071'),
('country_Korea__North_112',
'state__________________2072'),
('country_Korea__North_112',
'state_______________2073'),
('country_Korea__North_112',
'state_______________2074'),
('country_Korea__North_112',
'state__________________2075'),
('country_Korea__North_112', 'state___________2076'),
('country_Korea__South_113',
'state_________________2077'),
('country_Korea__South_113',
'state__________________2078'),
('country_Korea__South_113',
'state__________________2079'),
('country_Korea__South_113',
'state_________________2080'),
('country_Korea__South_113',
'state__________________2081'),
('country_Korea__South_113',
'state__________________2082'),
('country_Korea__South_113',
'state__________________2083'),
('country_Korea__South_113', 'state___________2084'),
('country_Korea__South_113', 'state___________2085'),
('country_Korea__South_113',
'state_______________2086'),
('country_Korea__South_113',
'state_______________2087'),
('country_Korea__South_113',
'state_______________2088'),
('country_Korea__South_113',
'state_______________2089'),
('country_Korea__South_113',
'state_______________2090'),
('country_Korea__South_113',
'state_______________2091'),
('country_Korea__South_113',
'state_______________________2092'),
('country_Kuwait_114', 'state________________2093'),
('country_Kuwait_114',
'state____________________2094'),
('country_Kuwait_114', 'state________________2095'),
('country_Kuwait_114', 'state________________2096'),
('country_Kuwait_114', 'state__________2097'),
('country_Kuwait_114',
'state_________________________2098'),
('country_Kyrgyzstan_115',
'state_____________________________2099'),
('country_Kyrgyzstan_115',
'state_______________________2100'),
('country_Kyrgyzstan_115', 'state______________2101'),
('country_Kyrgyzstan_115',
'state____________________________________2102'),
('country_Kyrgyzstan_115',
'state___________________________2103'),
('country_Kyrgyzstan_115',
'state_____________________2104'),
('country_Kyrgyzstan_115',
'state___________________________2105'),
('country_Kyrgyzstan_115',
'state________________________________2106'),
('country_Laos_116',
'state_______________________2107'),
('country_Laos_116',
'state_______________________2108'),
('country_Laos_116',
'state_____________________________2109'),
('country_Laos_116',
'state__________________________2110'),
('country_Laos_116', 'state____________________2111'),
('country_Laos_116',
'state_______________________2112'),
('country_Laos_116',
'state________________________________2113'),
('country_Laos_116',
'state_____________________________2114'),
('country_Laos_116',
'state_______________________2115'),
('country_Laos_116',
'state_______________________2116'),
('country_Laos_116',
'state_______________________2117'),
('country_Laos_116',
'state___________________________________2118'),
('country_Laos_116', 'state____________________2119'),
('country_Laos_116', 'state____________________2120'),
('country_Laos_116',
'state__________________________2121'),
('country_Laos_116', 'state_________________2122'),
('country_Laos_116',
'state_______________________2123'),
('country_Laos_116',
'state__________________________2124'),
('country_Latvia_117',
'state_Aizkraukles_rajons_2125'),
('country_Latvia_117', 'state_Al__ksnes_rajons_2126'),
('country_Latvia_117', 'state_Balvu_rajons_2127'),
('country_Latvia_117', 'state_Bauskas_rajons_2128'),
('country_Latvia_117', 'state_C__su_rajons_2129'),
('country_Latvia_117',
'state_Daugavpils_rajons_2130'),
('country_Latvia_117', 'state_Daugpilis_2131'),
('country_Latvia_117', 'state_Dobeles_rajons_2132'),
('country_Latvia_117', 'state_Gulbenes_rajons_2133'),
('country_Latvia_117', 'state_Jelgava_2134'),
('country_Latvia_117',
'state_J__kabpils_rajons_2135'),
('country_Latvia_117', 'state_Jelgavas_rajons_2136'),
('country_Latvia_117', 'state_J__rmala_2137'),
('country_Latvia_117',
'state_Kr__slavas_rajons_2138'),
('country_Latvia_117', 'state_Kuld__gas_rajons_2139'),
('country_Latvia_117', 'state_Liep__jas_rajons_2140'),
('country_Latvia_117', 'state_Limba__u_rajons_2141'),
('country_Latvia_117', 'state_Liepoja_2142'),
('country_Latvia_117', 'state_Ludzas_rajons_2143'),
('country_Latvia_117', 'state_Madonas_rajons_2144'),
('country_Latvia_117', 'state_Ogres_rajons_2145'),
('country_Latvia_117', 'state_Prei__u_rajons_2146'),
('country_Latvia_117', 'state_R__zeknes_rajons_2147'),
('country_Latvia_117', 'state_R__zekne_2148'),
('country_Latvia_117', 'state_R__gas_rajons_2149'),
('country_Latvia_117', 'state_R__ga_2150'),
('country_Latvia_117', 'state_Saldus_rajons_2151'),
('country_Latvia_117', 'state_Talsu_rajons_2152'),
('country_Latvia_117', 'state_Tukuma_rajons_2153'),
('country_Latvia_117', 'state_Ventspils_rajons_2154'),
('country_Latvia_117', 'state_Ventspils_2155'),
('country_Latvia_117', 'state_Valkas_rajons_2156'),
('country_Latvia_117', 'state_Valmieras_rajons_2157'),
('country_Lesotho_119', 'state_Maseru_2158'),
('country_Lesotho_119', 'state_Butha_Buthe_2159'),
('country_Lesotho_119', 'state_Leribe_2160'),
('country_Lesotho_119', 'state_Berea_2161'),
('country_Lesotho_119', 'state_Mafeteng_2162'),
('country_Lesotho_119', 'state_Mohale_s_Hoek_2163'),
('country_Lesotho_119', 'state_Quthing_2164'),
('country_Lesotho_119', 'state_Qacha_s_Nek_2165'),
('country_Lesotho_119', 'state_Mokhotlong_2166'),
('country_Lesotho_119', 'state_Thaba_Tseka_2167'),
('country_Liberia_120', 'state_Bong_2168'),
('country_Liberia_120', 'state_Bomi_2169'),
('country_Liberia_120',
'state_Grand_Cape_Mount_2170'),
('country_Liberia_120', 'state_Grand_Bassa_2171'),
('country_Liberia_120', 'state_Grand_Gedeh_2172'),
('country_Liberia_120', 'state_Grand_Kru_2173'),
('country_Liberia_120', 'state_Gbarpolu_2174'),
('country_Liberia_120', 'state_Lofa_2175'),
('country_Liberia_120', 'state_Margibi_2176'),
('country_Liberia_120', 'state_Montserrado_2177'),
('country_Liberia_120', 'state_Maryland_2178'),
('country_Liberia_120', 'state_Nimba_2179'),
('country_Liberia_120', 'state_River_Gee_2180'),
('country_Liberia_120', 'state_Rivercess_2181'),
('country_Liberia_120', 'state_Sinoe_2182'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Ajd__biy___2183'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Bangh__z___2184'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Al_Bu__n__n_2185'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Ban___Wal__d_2186'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Darnah_2187'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Ghad__mis_2188'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Ghary__n_2189'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Gh__t_2190'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Al____iz__m_al_Akh___ar_2191'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Al_Jabal_al_Akh___ar_2192'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Jaghb__b_2193'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Al_Jif__rah_2194'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Al_Jufrah_2195'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Al_Kufrah_2196'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Al_Marqab_2197'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Mi__r__tah_2198'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Al_Marj_2199'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Murzuq_2200'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Mizdah_2201'),
('country_Libyan_Arab_Jamahiriya_121',
'state_N__l__t_2202'),
('country_Libyan_Arab_Jamahiriya_121',
'state_An_Nuqa___al_Khams_2203'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Al_Qubbah_2204'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Al_Qa__r__n_2205'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Sabh___2206'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Ash_Sh____i_2207'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Surt_2208'),
('country_Libyan_Arab_Jamahiriya_121',
'state___abr__tah___urm__n_2209'),
('country_Libyan_Arab_Jamahiriya_121',
'state___ar__bulus_2210'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Tarh__nah_Masall__tah_2211'),
('country_Libyan_Arab_Jamahiriya_121',
'state_T__j__r___wa_an_Naw________al_Arb_____2212'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Al_W_____ah_2213'),
('country_Libyan_Arab_Jamahiriya_121',
'state_W__d___al____ay__t_2214'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Yafran_J__d___2215'),
('country_Libyan_Arab_Jamahiriya_121',
'state_Az_Z__wiyah_2216'),
('country_Liechtenstein_122', 'state_Balzers_2217'),
('country_Liechtenstein_122', 'state_Eschen_2218'),
('country_Liechtenstein_122', 'state_Gamprin_2219'),
('country_Liechtenstein_122', 'state_Mauren_2220'),
('country_Liechtenstein_122', 'state_Planken_2221'),
('country_Liechtenstein_122', 'state_Ruggell_2222'),
('country_Liechtenstein_122', 'state_Schaan_2223'),
('country_Liechtenstein_122',
'state_Schellenberg_2224'),
('country_Liechtenstein_122', 'state_Triesen_2225'),
('country_Liechtenstein_122',
'state_Triesenberg_2226'),
('country_Liechtenstein_122', 'state_Vaduz_2227'),
('country_Lithuania_123',
'state_Alytaus_Apskritis_2228'),
('country_Lithuania_123',
'state_Klaip__dos_Apskritis_2229'),
('country_Lithuania_123',
'state_Kauno_Apskritis_2230'),
('country_Lithuania_123',
'state_Marijampol__s_Apskritis_2231'),
('country_Lithuania_123',
'state_Panev____io_Apskritis_2232'),
('country_Lithuania_123',
'state___iauli___Apskritis_2233'),
('country_Lithuania_123',
'state_Taurag__s_Apskritis_2234'),
('country_Lithuania_123',
'state_Tel__i___Apskritis_2235'),
('country_Lithuania_123',
'state_Utenos_Apskritis_2236'),
('country_Lithuania_123',
'state_Vilniaus_Apskritis_2237'),
('country_Luxembourg_124', 'state_Diekirch_2238'),
('country_Luxembourg_124', 'state_Grevenmacher_2239'),
('country_Luxembourg_124', 'state_Luxemburg_2240'),
('country_Macau_125', 'state___________2241'),
('country_Macau_125', 'state___________2242'),
('country_Macedonia_126', 'state_Berovo_2243'),
('country_Macedonia_126',
'state___________________________________2244'),
('country_Macedonia_126',
'state________________2245'),
('country_Macedonia_126',
'state__________________2246'),
('country_Macedonia_126',
'state______________2247')";
$this->db->setQuery($query);
$this->db->query();
$query="INSERT IGNORE INTO `#__hikashop_zone_link`
(`zone_parent_namekey`, `zone_child_namekey`) VALUES
('country_Macedonia_126', 'state______________2248'),
('country_Macedonia_126',
'state_______________________________________2249'),
('country_Macedonia_126',
'state________________2250'),
('country_Macedonia_126',
'state____________________2251'),
('country_Macedonia_126', 'state__________2252'),
('country_Macedonia_126',
'state_________________________2253'),
('country_Macedonia_126', 'state______________2254'),
('country_Macedonia_126',
'state________________2255'),
('country_Macedonia_126',
'state________________2256'),
('country_Macedonia_126',
'state___________________________2257'),
('country_Macedonia_126',
'state__________________2258'),
('country_Macedonia_126',
'state________________2259'),
('country_Macedonia_126',
'state__________________2260'),
('country_Macedonia_126',
'state_________________________________2261'),
('country_Macedonia_126', 'state______________2262'),
('country_Macedonia_126',
'state_______________________2263'),
('country_Macedonia_126',
'state________________2264'),
('country_Macedonia_126',
'state__________________________2265'),
('country_Macedonia_126',
'state________________2266'),
('country_Macedonia_126', 'state______________2267'),
('country_Macedonia_126', 'state______________2268'),
('country_Macedonia_126', 'state______________2269'),
('country_Macedonia_126', 'state____________2270'),
('country_Macedonia_126',
'state__________________2271'),
('country_Macedonia_126',
'state__________________2272'),
('country_Macedonia_126',
'state__________________2273'),
('country_Macedonia_126',
'state____________________2274'),
('country_Macedonia_126',
'state__________________________________2275'),
('country_Macedonia_126', 'state______________2276'),
('country_Macedonia_126', 'state______________2277'),
('country_Macedonia_126',
'state____________________2278'),
('country_Macedonia_126', 'state______________2279'),
('country_Macedonia_126',
'state__________________2280'),
('country_Macedonia_126',
'state____________________2281'),
('country_Macedonia_126', 'state____________2282'),
('country_Macedonia_126', 'state__________2283'),
('country_Macedonia_126', 'state______________2284'),
('country_Macedonia_126',
'state___________________________2285'),
('country_Macedonia_126',
'state___________________2286'),
('country_Macedonia_126',
'state_________________________2287'),
('country_Macedonia_126',
'state________________2288'),
('country_Macedonia_126', 'state______________2289'),
('country_Macedonia_126',
'state_______________________2290'),
('country_Macedonia_126',
'state__________________2291'),
('country_Macedonia_126', 'state____________2292'),
('country_Macedonia_126',
'state________________2293'),
('country_Macedonia_126',
'state________________________2294'),
('country_Macedonia_126',
'state_________________________2295'),
('country_Macedonia_126',
'state______________________2296'),
('country_Macedonia_126',
'state__________________2297'),
('country_Macedonia_126',
'state__________________2298'),
('country_Macedonia_126',
'state____________________2299'),
('country_Macedonia_126', 'state____________2300'),
('country_Macedonia_126',
'state___________________2301'),
('country_Macedonia_126',
'state________________2302'),
('country_Macedonia_126',
'state_______________________2303'),
('country_Macedonia_126',
'state__________________2304'),
('country_Macedonia_126',
'state____________________2305'),
('country_Macedonia_126',
'state__________________2306'),
('country_Macedonia_126',
'state_______________________2307'),
('country_Macedonia_126', 'state____________2308'),
('country_Macedonia_126',
'state________________2309'),
('country_Macedonia_126',
'state________________2310'),
('country_Macedonia_126', 'state______________2311'),
('country_Macedonia_126',
'state_______________________________2312'),
('country_Macedonia_126', 'state____________2313'),
('country_Macedonia_126',
'state________________2314'),
('country_Macedonia_126',
'state__________________2315'),
('country_Macedonia_126', 'state______________2316'),
('country_Macedonia_126',
'state________________2317'),
('country_Macedonia_126',
'state______________________2318'),
('country_Macedonia_126', 'state____________2319'),
('country_Macedonia_126', 'state____________2320'),
('country_Macedonia_126',
'state_________________________2321'),
('country_Macedonia_126',
'state________________2322'),
('country_Macedonia_126',
'state____________________2323'),
('country_Macedonia_126',
'state__________________2324'),
('country_Macedonia_126',
'state________________2325'),
('country_Macedonia_126', 'state____________2326'),
('country_Madagascar_127', 'state_Toamasina_2327'),
('country_Madagascar_127', 'state_Antsiranana_2328'),
('country_Madagascar_127', 'state_Fianarantsoa_2329'),
('country_Madagascar_127', 'state_Mahajanga_2330'),
('country_Madagascar_127', 'state_Antananarivo_2331'),
('country_Madagascar_127', 'state_Toliara_2332'),
('country_Malawi_128', 'state_Balaka_2333'),
('country_Malawi_128', 'state_Blantyre_2334'),
('country_Malawi_128', 'state_Chikwawa_2336'),
('country_Malawi_128', 'state_Chiradzulu_2337'),
('country_Malawi_128', 'state_Chitipa_2338'),
('country_Malawi_128', 'state_Dedza_2339'),
('country_Malawi_128', 'state_Dowa_2340'),
('country_Malawi_128', 'state_Karonga_2341'),
('country_Malawi_128', 'state_Kasungu_2342'),
('country_Malawi_128', 'state_Likoma_Island_2343'),
('country_Malawi_128', 'state_Lilongwe_2344'),
('country_Malawi_128', 'state_Machinga_2345'),
('country_Malawi_128', 'state_Mangochi_2346'),
('country_Malawi_128', 'state_Mchinji_2347'),
('country_Malawi_128', 'state_Mulanje_2348'),
('country_Malawi_128', 'state_Mwanza_2349'),
('country_Malawi_128', 'state_Mzimba_2350'),
('country_Malawi_128', 'state_Northern_2351'),
('country_Malawi_128', 'state_Nkhata_2352'),
('country_Malawi_128', 'state_Nkhotakota_2353'),
('country_Malawi_128', 'state_Nsanje_2354'),
('country_Malawi_128', 'state_Ntcheu_2355'),
('country_Malawi_128', 'state_Ntchisi_2356'),
('country_Malawi_128', 'state_Phalombe_2357'),
('country_Malawi_128', 'state_Rumphi_2358'),
('country_Malawi_128', 'state_Southern_2359'),
('country_Malawi_128', 'state_Salima_2360'),
('country_Malawi_128', 'state_Thyolo_2361'),
('country_Malawi_128', 'state_Zomba_2362'),
('country_Malaysia_129',
'state_Johor_Darul_Takzim_2363'),
('country_Malaysia_129',
'state_Kedah_Darul_Aman_2364'),
('country_Malaysia_129',
'state_Kelantan_Darul_Naim_2365'),
('country_Malaysia_129',
'state_Melaka_Negeri_Bersejarah_2366'),
('country_Malaysia_129',
'state_Negeri_Sembilan_Darul_Khusus_2367'),
('country_Malaysia_129',
'state_Pahang_Darul_Makmur_2368'),
('country_Malaysia_129', 'state_Pulau_Pinang_2369'),
('country_Malaysia_129',
'state_Perak_Darul_Ridzuan_2370'),
('country_Malaysia_129',
'state_Perlis_Indera_Kayangan_2371'),
('country_Malaysia_129',
'state_Selangor_Darul_Ehsan_2372'),
('country_Malaysia_129',
'state_Terengganu_Darul_Iman_2373'),
('country_Malaysia_129',
'state_Sabah_Negeri_Di_Bawah_Bayu_2374'),
('country_Malaysia_129',
'state_Sarawak_Bumi_Kenyalang_2375'),
('country_Malaysia_129',
'state_Wilayah_Persekutuan_Kuala_Lumpur_2376'),
('country_Malaysia_129',
'state_Wilayah_Persekutuan_Labuan_2377'),
('country_Malaysia_129',
'state_Wilayah_Persekutuan_Putrajaya_2378'),
('country_Maldives_130',
'state_Thiladhunmathi_Uthuru_2379'),
('country_Maldives_130',
'state_Thiladhunmathi_Dhekunu_2380'),
('country_Maldives_130',
'state_Miladhunmadulu_Uthuru_2381'),
('country_Maldives_130',
'state_Miladhunmadulu_Dhekunu_2382'),
('country_Maldives_130',
'state_Maalhosmadulu_Uthuru_2383'),
('country_Maldives_130',
'state_Maalhosmadulu_Dhekunu_2384'),
('country_Maldives_130', 'state_Faadhippolhu_2385'),
('country_Maldives_130', 'state_Male_Atoll_2386'),
('country_Maldives_130',
'state_Ari_Atoll_Uthuru_2387'),
('country_Maldives_130',
'state_Ari_Atoll_Dheknu_2388'),
('country_Maldives_130', 'state_Felidhe_Atoll_2389'),
('country_Maldives_130', 'state_Mulaku_Atoll_2390'),
('country_Maldives_130',
'state_Nilandhe_Atoll_Uthuru_2391'),
('country_Maldives_130',
'state_Nilandhe_Atoll_Dhekunu_2392'),
('country_Maldives_130', 'state_Kolhumadulu_2393'),
('country_Maldives_130', 'state_Hadhdhunmathi_2394'),
('country_Maldives_130',
'state_Huvadhu_Atoll_Uthuru_2395'),
('country_Maldives_130',
'state_Huvadhu_Atoll_Dhekunu_2396'),
('country_Maldives_130', 'state_Fua_Mulaku_2397'),
('country_Maldives_130', 'state_Addu_2398'),
('country_Mali_131', 'state_Kayes_2399'),
('country_Mali_131', 'state_Koulikoro_2400'),
('country_Mali_131', 'state_Sikasso_2401'),
('country_Mali_131', 'state_S__gou_2402'),
('country_Mali_131', 'state_Mopti_2403'),
('country_Mali_131', 'state_Tombouctou_2404'),
('country_Mali_131', 'state_Gao_2405'),
('country_Mali_131', 'state_Kidal_2406'),
('country_Mali_131', 'state_Bamako_2407'),
('country_Malta_132', 'state_malta_2408'),
('country_Malta_132', 'state_gozo_2409'),
('country_Marshall_Islands_133', 'state_Ailuk_2476'),
('country_Marshall_Islands_133',
'state_Ailinglapalap_2477'),
('country_Marshall_Islands_133', 'state_Arno_2478'),
('country_Marshall_Islands_133', 'state_Aur_2479'),
('country_Marshall_Islands_133', 'state_Ebon_2480'),
('country_Marshall_Islands_133',
'state_Eniwetok_2481'),
('country_Marshall_Islands_133', 'state_Jabat_2482'),
('country_Marshall_Islands_133', 'state_Jaluit_2483'),
('country_Marshall_Islands_133', 'state_Kili_2484'),
('country_Marshall_Islands_133',
'state_Kwajalein_2485'),
('country_Marshall_Islands_133', 'state_Lae_2486'),
('country_Marshall_Islands_133', 'state_Lib_2487'),
('country_Marshall_Islands_133', 'state_Likiep_2488'),
('country_Marshall_Islands_133', 'state_Majuro_2489'),
('country_Marshall_Islands_133',
'state_Maloelap_2490'),
('country_Marshall_Islands_133', 'state_Mejit_2491'),
('country_Marshall_Islands_133', 'state_Mili_2492'),
('country_Marshall_Islands_133',
'state_Namorik_2493'),
('country_Marshall_Islands_133', 'state_Namu_2494'),
('country_Marshall_Islands_133',
'state_Rongelap_2495'),
('country_Marshall_Islands_133', 'state_Ujae_2496'),
('country_Marshall_Islands_133',
'state_Ujelang_2497'),
('country_Marshall_Islands_133', 'state_Utirik_2498'),
('country_Marshall_Islands_133', 'state_Wotje_2499'),
('country_Marshall_Islands_133', 'state_Wotho_2500'),
('country_Mauritania_135',
'state____________________________________2501'),
('country_Mauritania_135',
'state____________________________________2502'),
('country_Mauritania_135',
'state___________________________2503'),
('country_Mauritania_135',
'state_______________________2504'),
('country_Mauritania_135',
'state_____________________________2505'),
('country_Mauritania_135',
'state_____________________________2506'),
('country_Mauritania_135',
'state_______________________2507'),
('country_Mauritania_135',
'state______________________________________2508'),
('country_Mauritania_135',
'state_______________________2509'),
('country_Mauritania_135',
'state______________________________2510'),
('country_Mauritania_135',
'state______________________________2511'),
('country_Mauritania_135',
'state___________________________2512'),
('country_Mauritania_135',
'state________________2513'),
('country_Mauritius_136',
'state_Agalega_Islands_2514'),
('country_Mauritius_136', 'state_Black_River_2515'),
('country_Mauritius_136',
'state_Beau_Bassin_Rose_Hill_2516'),
('country_Mauritius_136',
'state_Cargados_Carajos_Shoals_2517'),
('country_Mauritius_136', 'state_Curepipe_2518'),
('country_Mauritius_136', 'state_Flacq_2519'),
('country_Mauritius_136', 'state_Grand_Port_2520'),
('country_Mauritius_136', 'state_Moka_2521'),
('country_Mauritius_136', 'state_Pamplemousses_2522'),
('country_Mauritius_136', 'state_Port_Louis_2523'),
('country_Mauritius_136',
'state_Port_Louis_City_2524'),
('country_Mauritius_136',
'state_Plaines_Wilhems_2525'),
('country_Mauritius_136', 'state_Quatre_Bornes_2526'),
('country_Mauritius_136', 'state_Rodrigues_2527'),
('country_Mauritius_136',
'state_Riviere_du_Rempart_2528'),
('country_Mauritius_136', 'state_Savanne_2529'),
('country_Mauritius_136',
'state_Vacoas_Phoenix_2530'),
('country_Mexico_138', 'state_Aguascalientes_2531'),
('country_Mexico_138', 'state_Baja_California_2532'),
('country_Mexico_138',
'state_Baja_California_Sur_2533'),
('country_Mexico_138', 'state_Campeche_2534'),
('country_Mexico_138', 'state_Chihuahua_2535'),
('country_Mexico_138', 'state_Chiapas_2536'),
('country_Mexico_138', 'state_Coahuila_2537'),
('country_Mexico_138', 'state_Colima_2538'),
('country_Mexico_138', 'state_Distrito_Federal_2539'),
('country_Mexico_138', 'state_Durango_2540'),
('country_Mexico_138', 'state_Guerrero_2541'),
('country_Mexico_138', 'state_Guanajuato_2542'),
('country_Mexico_138', 'state_Hidalgo_2543'),
('country_Mexico_138', 'state_Jalisco_2544'),
('country_Mexico_138', 'state_Mexico_2545'),
('country_Mexico_138', 'state_Michoac__n_2546'),
('country_Mexico_138', 'state_Morelos_2547'),
('country_Mexico_138', 'state_Nayarit_2548'),
('country_Mexico_138', 'state_Nuevo_Le__n_2549'),
('country_Mexico_138', 'state_Oaxaca_2550'),
('country_Mexico_138', 'state_Puebla_2551'),
('country_Mexico_138', 'state_Quer__taro_2552'),
('country_Mexico_138', 'state_Quintana_Roo_2553'),
('country_Mexico_138', 'state_Sinaloa_2554'),
('country_Mexico_138', 'state_San_Luis_Potos___2555'),
('country_Mexico_138', 'state_Sonora_2556'),
('country_Mexico_138', 'state_Tabasco_2557'),
('country_Mexico_138', 'state_Tamaulipas_2558'),
('country_Mexico_138', 'state_Tlaxcala_2559'),
('country_Mexico_138', 'state_Veracruz_2560'),
('country_Mexico_138', 'state_Yucatan_2561'),
('country_Mexico_138', 'state_Zacatecas_2562'),
('country_Micronesia_139', 'state_Kosrae_2563'),
('country_Micronesia_139', 'state_Pohnpei_2564'),
('country_Micronesia_139', 'state_Chuuk_2565'),
('country_Micronesia_139', 'state_Yap_2566'),
('country_Moldova_140', 'state_B__l__i_2567'),
('country_Moldova_140', 'state_Cahul_2568'),
('country_Moldova_140', 'state_Chi__in__u_2569'),
('country_Moldova_140', 'state_Edine___2570'),
('country_Moldova_140', 'state_G__g__uzia_2571'),
('country_Moldova_140', 'state_L__pu__na_2572'),
('country_Moldova_140', 'state_Orhei_2573'),
('country_Moldova_140',
'state_St__nga_Nistrului_2574'),
('country_Moldova_140', 'state_Soroca_2575'),
('country_Moldova_140', 'state_Tighina_2576'),
('country_Moldova_140', 'state_Ungheni_2577'),
('country_Monaco_141', 'state_Monte_Carlo_2578'),
('country_Monaco_141', 'state_La_Rousse_2579'),
('country_Monaco_141', 'state_Larvotto_2580'),
('country_Monaco_141', 'state_Monaco_Ville_2581'),
('country_Monaco_141', 'state_Saint_Michel_2582'),
('country_Monaco_141', 'state_Condamine_2583'),
('country_Monaco_141', 'state_La_Colle_2584'),
('country_Monaco_141', 'state_Les_R__voires_2585'),
('country_Monaco_141', 'state_Moneghetti_2586'),
('country_Monaco_141', 'state_Fontvieille_2587'),
('country_Mongolia_142',
'state________________________2588'),
('country_Mongolia_142',
'state_______________________2589'),
('country_Mongolia_142',
'state________________________________2590'),
('country_Mongolia_142',
'state_________________________2591'),
('country_Mongolia_142',
'state___________________________2592'),
('country_Mongolia_142',
'state_____________________2593'),
('country_Mongolia_142',
'state___________________2594'),
('country_Mongolia_142',
'state___________________2595'),
('country_Mongolia_142',
'state___________________________2596'),
('country_Mongolia_142',
'state_______________________________2597'),
('country_Mongolia_142',
'state_____________________________2598'),
('country_Mongolia_142',
'state_________________________________2599'),
('country_Mongolia_142',
'state_________________________2600'),
('country_Mongolia_142',
'state_____________________________2601'),
('country_Mongolia_142',
'state_________________________2602'),
('country_Mongolia_142',
'state_______________________________2603'),
('country_Mongolia_142',
'state_________________________________2604'),
('country_Mongolia_142',
'state________________________________2605'),
('country_Mongolia_142',
'state_________________________2606'),
('country_Mongolia_142',
'state_________________________________2607'),
('country_Mongolia_142',
'state________________________________2608'),
('country_Mongolia_142',
'state_____________________________2609'),
('country_Montserrat_143',
'state_Saint_Anthony_2610'),
('country_Montserrat_143',
'state_Saint_Georges_2611'),
('country_Montserrat_143', 'state_Saint_Peter_2612'),
('country_Mozambique_145', 'state_Niassa_2613'),
('country_Mozambique_145', 'state_Manica_2614'),
('country_Mozambique_145', 'state_Gaza_2615'),
('country_Mozambique_145', 'state_Inhambane_2616'),
('country_Mozambique_145', 'state_Maputo_2617'),
('country_Mozambique_145',
'state_Maputo_cidade_2618'),
('country_Mozambique_145', 'state_Nampula_2619'),
('country_Mozambique_145', 'state_Cabo_Delgado_2620'),
('country_Mozambique_145', 'state_Zamb__zia_2621'),
('country_Mozambique_145', 'state_Sofala_2622'),
('country_Mozambique_145', 'state_Tete_2623'),
('country_Myanmar_146',
'state_________________________________________2624'),
('country_Myanmar_146',
'state______________________________________2625'),
('country_Myanmar_146',
'state_________________________________________2626'),
('country_Myanmar_146',
'state____________________________________________2627'),
('country_Myanmar_146',
'state___________________________________________________________2628'),
('country_Myanmar_146',
'state_______________________________________________2629'),
('country_Myanmar_146',
'state__________________________________________________2630'),
('country_Myanmar_146',
'state_____________________________________________________2631'),
('country_Myanmar_146',
'state_____________________________________________________2632'),
('country_Myanmar_146',
'state_______________________________________________2633'),
('country_Myanmar_146',
'state__________________________________________________2634'),
('country_Myanmar_146',
'state__________________________________________________2635'),
('country_Myanmar_146',
'state_____________________________________________________2636'),
('country_Myanmar_146',
'state__________________________________________________2637'),
('country_Namibia_147', 'state_Caprivi_2638'),
('country_Namibia_147', 'state_Erongo_2639'),
('country_Namibia_147', 'state_Hardap_2640'),
('country_Namibia_147', 'state_Karas_2641'),
('country_Namibia_147', 'state_Khomas_2642'),
('country_Namibia_147', 'state_Kunene_2643'),
('country_Namibia_147', 'state_Otjozondjupa_2644'),
('country_Namibia_147', 'state_Omaheke_2645'),
('country_Namibia_147', 'state_Okavango_2646'),
('country_Namibia_147', 'state_Oshana_2647'),
('country_Namibia_147', 'state_Omusati_2648'),
('country_Namibia_147', 'state_Oshikoto_2649'),
('country_Namibia_147', 'state_Ohangwena_2650'),
('country_Nauru_148', 'state_Aiwo_2651'),
('country_Nauru_148', 'state_Anabar_2652'),
('country_Nauru_148', 'state_Anetan_2653'),
('country_Nauru_148', 'state_Anibare_2654'),
('country_Nauru_148', 'state_Baiti_2655'),
('country_Nauru_148', 'state_Boe_2656'),
('country_Nauru_148', 'state_Buada_2657'),
('country_Nauru_148', 'state_Denigomodu_2658'),
('country_Nauru_148', 'state_Ewa_2659'),
('country_Nauru_148', 'state_Ijuw_2660'),
('country_Nauru_148', 'state_Meneng_2661'),
('country_Nauru_148', 'state_Nibok_2662'),
('country_Nauru_148', 'state_Uaboe_2663'),
('country_Nauru_148', 'state_Yaren_2664'),
('country_Nepal_149', 'state_Bagmati_2665'),
('country_Nepal_149', 'state_Bheri_2666'),
('country_Nepal_149', 'state_Dhawalagiri_2667'),
('country_Nepal_149', 'state_Gandaki_2668'),
('country_Nepal_149', 'state_Janakpur_2669'),
('country_Nepal_149', 'state_Karnali_2670'),
('country_Nepal_149', 'state_Kosi_2671'),
('country_Nepal_149', 'state_Lumbini_2672'),
('country_Nepal_149', 'state_Mahakali_2673'),
('country_Nepal_149', 'state_Mechi_2674'),
('country_Nepal_149', 'state_Narayani_2675'),
('country_Nepal_149', 'state_Rapti_2676'),
('country_Nepal_149', 'state_Sagarmatha_2677'),
('country_Nepal_149', 'state_Seti_2678'),
('country_Netherlands_150', 'state_Drenthe_2679'),
('country_Netherlands_150', 'state_Flevoland_2680'),
('country_Netherlands_150', 'state_Friesland_2681'),
('country_Netherlands_150', 'state_Gelderland_2682'),
('country_Netherlands_150', 'state_Groningen_2683'),
('country_Netherlands_150', 'state_Limburg_2684'),
('country_Netherlands_150',
'state_Noord_Brabant_2685'),
('country_Netherlands_150',
'state_Noord_Holland_2686'),
('country_Netherlands_150', 'state_Overijssel_2687'),
('country_Netherlands_150', 'state_Utrecht_2688'),
('country_Netherlands_150', 'state_Zeeland_2689'),
('country_Netherlands_150',
'state_Zuid_Holland_2690'),
('country_New_Caledonia_152',
'state_Province_des___les_2691'),
('country_New_Caledonia_152',
'state_Province_Nord_2692'),
('country_New_Caledonia_152',
'state_Province_Sud_2693'),
('country_New_Zealand_153', 'state_Auckland_2694'),
('country_New_Zealand_153',
'state_Bay_of_Plenty_2695'),
('country_New_Zealand_153', 'state_Canterbury_2696'),
('country_New_Zealand_153', 'state_Gisborne_2697'),
('country_New_Zealand_153', 'state_Hawke_s_Bay_2698'),
('country_New_Zealand_153', 'state_Marlborough_2699'),
('country_New_Zealand_153',
'state_Manawatu_Wanganui_2700'),
('country_New_Zealand_153', 'state_Nelson_2701'),
('country_New_Zealand_153', 'state_Northland_2702'),
('country_New_Zealand_153', 'state_Otago_2703'),
('country_New_Zealand_153', 'state_Southland_2704'),
('country_New_Zealand_153', 'state_Tasman_2705'),
('country_New_Zealand_153', 'state_Taranaki_2706'),
('country_New_Zealand_153', 'state_Wellington_2707'),
('country_New_Zealand_153', 'state_Waikato_2708'),
('country_New_Zealand_153', 'state_West_Coast_2709'),
('country_Nicaragua_154',
'state_Atl__ntico_Norte_2710'),
('country_Nicaragua_154',
'state_Atl__ntico_Sur_2711'),
('country_Nicaragua_154', 'state_Boaco_2712'),
('country_Nicaragua_154', 'state_Carazo_2713'),
('country_Nicaragua_154', 'state_Chinandega_2714'),
('country_Nicaragua_154', 'state_Chontales_2715'),
('country_Nicaragua_154', 'state_Estel___2716'),
('country_Nicaragua_154', 'state_Granada_2717'),
('country_Nicaragua_154', 'state_Jinotega_2718'),
('country_Nicaragua_154', 'state_Le__n_2719'),
('country_Nicaragua_154', 'state_Madriz_2720'),
('country_Nicaragua_154', 'state_Managua_2721'),
('country_Nicaragua_154', 'state_Masaya_2722'),
('country_Nicaragua_154', 'state_Matagalpa_2723'),
('country_Nicaragua_154', 'state_Nueva_Segovia_2724'),
('country_Nicaragua_154', 'state_Rivas_2725'),
('country_Nicaragua_154', 'state_R__o_San_Juan_2726'),
('country_Niger_155', 'state_Agadez_2727'),
('country_Niger_155', 'state_Daffa_2728'),
('country_Niger_155', 'state_Dosso_2729'),
('country_Niger_155', 'state_Maradi_2730'),
('country_Niger_155', 'state_Tahoua_2731'),
('country_Niger_155', 'state_Tillab__ry_2732'),
('country_Niger_155', 'state_Zinder_2733'),
('country_Niger_155', 'state_Niamey_2734'),
('country_Nigeria_156', 'state_Abia_State_2735'),
('country_Nigeria_156', 'state_Adamawa_State_2736'),
('country_Nigeria_156', 'state_Akwa_Ibom_State_2737'),
('country_Nigeria_156', 'state_Anambra_State_2738'),
('country_Nigeria_156', 'state_Bauchi_State_2739'),
('country_Nigeria_156', 'state_Benue_State_2740'),
('country_Nigeria_156', 'state_Borno_State_2741'),
('country_Nigeria_156', 'state_Bayelsa_State_2742'),
('country_Nigeria_156',
'state_Cross_River_State_2743'),
('country_Nigeria_156', 'state_Delta_State_2744'),
('country_Nigeria_156', 'state_Ebonyi_State_2745'),
('country_Nigeria_156', 'state_Edo_State_2746'),
('country_Nigeria_156', 'state_Ekiti_State_2747'),
('country_Nigeria_156',
'state_Enugu_State_2748')";
$this->db->setQuery($query);
$this->db->query();
$query="INSERT IGNORE INTO `#__hikashop_zone_link`
(`zone_parent_namekey`, `zone_child_namekey`) VALUES
('country_Nigeria_156', 'state_Gombe_State_2749'),
('country_Nigeria_156', 'state_Imo_State_2750'),
('country_Nigeria_156', 'state_Jigawa_State_2751'),
('country_Nigeria_156', 'state_Kebbi_State_2752'),
('country_Nigeria_156', 'state_Kaduna_State_2753'),
('country_Nigeria_156', 'state_Kano_State_2754'),
('country_Nigeria_156', 'state_Kogi_State_2755'),
('country_Nigeria_156', 'state_Katsina_State_2756'),
('country_Nigeria_156', 'state_Kwara_State_2757'),
('country_Nigeria_156', 'state_Lagos_State_2758'),
('country_Nigeria_156', 'state_Nassarawa_State_2759'),
('country_Nigeria_156', 'state_Niger_State_2760'),
('country_Nigeria_156', 'state_Ogun_State_2761'),
('country_Nigeria_156', 'state_Ondo_State_2762'),
('country_Nigeria_156', 'state_Osun_State_2763'),
('country_Nigeria_156', 'state_Oyo_State_2764'),
('country_Nigeria_156', 'state_Plateau_State_2765'),
('country_Nigeria_156', 'state_Rivers_State_2766'),
('country_Nigeria_156', 'state_Sokoto_State_2767'),
('country_Nigeria_156', 'state_Taraba_State_2768'),
('country_Nigeria_156', 'state_Zamfara_State_2769'),
('country_Northern_Mariana_Islands_159',
'state_Northern_Islands_2770'),
('country_Northern_Mariana_Islands_159',
'state_Rota_2771'),
('country_Northern_Mariana_Islands_159',
'state_Saipan_2772'),
('country_Northern_Mariana_Islands_159',
'state_Tinian_2773'),
('country_Norway_160', 'state___stfold_fylke_2774'),
('country_Norway_160', 'state_Akershus_fylke_2775'),
('country_Norway_160', 'state_Oslo_fylke_2776'),
('country_Norway_160', 'state_Hedmark_fylke_2777'),
('country_Norway_160', 'state_Oppland_fylke_2778'),
('country_Norway_160', 'state_Buskerud_fylke_2779'),
('country_Norway_160', 'state_Vestfold_fylke_2780'),
('country_Norway_160', 'state_Telemark_fylke_2781'),
('country_Norway_160', 'state_Aust_Agder_fylke_2782'),
('country_Norway_160', 'state_Vest_Agder_fylke_2783'),
('country_Norway_160', 'state_Rogaland_fylke_2784'),
('country_Norway_160', 'state_Hordaland_fylke_2785'),
('country_Norway_160',
'state_Sogn_og_Fjordane_fylke_2786'),
('country_Norway_160',
'state_M__re_og_Romsdal_fylke_2787'),
('country_Norway_160',
'state_S__r_Tr__ndelag_fylke_2788'),
('country_Norway_160',
'state_Nord_Tr__ndelag_fylke_2789'),
('country_Norway_160', 'state_Nordland_fylke_2790'),
('country_Norway_160', 'state_Troms_fylke_2791'),
('country_Norway_160', 'state_Finnmark_fylke_2792'),
('country_Oman_161', 'state________________2793'),
('country_Oman_161', 'state__________________2794'),
('country_Oman_161', 'state__________2795'),
('country_Oman_161', 'state__________2796'),
('country_Oman_161', 'state____________2797'),
('country_Oman_161', 'state________________2798'),
('country_Oman_161', 'state______________2799'),
('country_Oman_161', 'state________________2800'),
('country_Pakistan_162',
'state__________________2801'),
('country_Pakistan_162',
'state_________________________________2802'),
('country_Pakistan_162',
'state_____________________2803'),
('country_Pakistan_162',
'state______________________________2804'),
('country_Pakistan_162',
'state_________________________________________2805'),
('country_Pakistan_162', 'state____________2806'),
('country_Pakistan_162', 'state__________2807'),
('country_Pakistan_162',
'state___________________________________________2808'),
('country_Palau_163', 'state_Aimeliik_2809'),
('country_Palau_163', 'state_Airai_2810'),
('country_Palau_163', 'state_Angaur_2811'),
('country_Palau_163', 'state_Hatohobei_2812'),
('country_Palau_163', 'state_Kayangel_2813'),
('country_Palau_163', 'state_Koror_2814'),
('country_Palau_163', 'state_Melekeok_2815'),
('country_Palau_163', 'state_Ngaraard_2816'),
('country_Palau_163', 'state_Ngarchelong_2817'),
('country_Palau_163', 'state_Ngardmau_2818'),
('country_Palau_163', 'state_Ngatpang_2819'),
('country_Palau_163', 'state_Ngchesar_2820'),
('country_Palau_163', 'state_Ngeremlengui_2821'),
('country_Palau_163', 'state_Ngiwal_2822'),
('country_Palau_163', 'state_Peleliu_2823'),
('country_Palau_163', 'state_Sonsorol_2824'),
('country_Panama_164', 'state_Bocas_del_Toro_2825'),
('country_Panama_164', 'state_Cocl___2826'),
('country_Panama_164', 'state_Col__n_2827'),
('country_Panama_164', 'state_Chiriqu___2828'),
('country_Panama_164', 'state_Dari__n_2829'),
('country_Panama_164', 'state_Herrera_2830'),
('country_Panama_164', 'state_Los_Santos_2831'),
('country_Panama_164', 'state_Panam___2832'),
('country_Panama_164', 'state_Veraguas_2833'),
('country_Panama_164', 'state_Kuna_Yala_2834'),
('country_Papua_New_Guinea_165', 'state_Chimbu_2835'),
('country_Papua_New_Guinea_165',
'state_Central_2836'),
('country_Papua_New_Guinea_165',
'state_East_New_Britain_2837'),
('country_Papua_New_Guinea_165',
'state_Eastern_Highlands_2838'),
('country_Papua_New_Guinea_165', 'state_Enga_2839'),
('country_Papua_New_Guinea_165',
'state_East_Sepik_2840'),
('country_Papua_New_Guinea_165', 'state_Gulf_2841'),
('country_Papua_New_Guinea_165',
'state_Milne_Bay_2842'),
('country_Papua_New_Guinea_165', 'state_Morobe_2843'),
('country_Papua_New_Guinea_165', 'state_Madang_2844'),
('country_Papua_New_Guinea_165', 'state_Manus_2845'),
('country_Papua_New_Guinea_165',
'state_National_Capital_District_2846'),
('country_Papua_New_Guinea_165',
'state_New_Ireland_2847'),
('country_Papua_New_Guinea_165',
'state_Northern_2848'),
('country_Papua_New_Guinea_165',
'state_North_Solomons_2849'),
('country_Papua_New_Guinea_165',
'state_Sandaun_2850'),
('country_Papua_New_Guinea_165',
'state_Southern_Highlands_2851'),
('country_Papua_New_Guinea_165',
'state_West_New_Britain_2852'),
('country_Papua_New_Guinea_165',
'state_Western_Highlands_2853'),
('country_Papua_New_Guinea_165',
'state_Western_2854'),
('country_Paraguay_166', 'state_Concepci__n_2855'),
('country_Paraguay_166', 'state_San_Pedro_2856'),
('country_Paraguay_166', 'state_Cordillera_2857'),
('country_Paraguay_166', 'state_Guair___2858'),
('country_Paraguay_166', 'state_Caaguaz___2859'),
('country_Paraguay_166', 'state_Caazap___2860'),
('country_Paraguay_166', 'state_Itap__a_2861'),
('country_Paraguay_166', 'state_Misiones_2862'),
('country_Paraguay_166', 'state_Paraguar___2863'),
('country_Paraguay_166', 'state_Alto_Paran___2864'),
('country_Paraguay_166', 'state_Central_2865'),
('country_Paraguay_166', 'state___eembuc___2866'),
('country_Paraguay_166', 'state_Amambay_2867'),
('country_Paraguay_166', 'state_Canindey___2868'),
('country_Paraguay_166',
'state_Presidente_Hayes_2869'),
('country_Paraguay_166', 'state_Alto_Paraguay_2870'),
('country_Paraguay_166', 'state_Boquer__n_2871'),
('country_Paraguay_166', 'state_Asunci__n_2872'),
('country_Peru_167', 'state_Ancash_2874'),
('country_Peru_167', 'state_Apur__mac_2875'),
('country_Peru_167', 'state_Arequipa_2876'),
('country_Peru_167', 'state_Ayacucho_2877'),
('country_Peru_167', 'state_Cajamarca_2878'),
('country_Peru_167', 'state_Callao_2879'),
('country_Peru_167', 'state_Cuzco_2880'),
('country_Peru_167', 'state_Hu__nuco_2881'),
('country_Peru_167', 'state_Huancavelica_2882'),
('country_Peru_167', 'state_Ica_2883'),
('country_Peru_167', 'state_Jun__n_2884'),
('country_Peru_167', 'state_La_Libertad_2885'),
('country_Peru_167', 'state_Lambayeque_2886'),
('country_Peru_167', 'state_Lima_2887'),
('country_Peru_167', 'state_Loreto_2888'),
('country_Peru_167', 'state_Madre_de_Dios_2889'),
('country_Peru_167', 'state_Moquegua_2890'),
('country_Peru_167', 'state_Pasco_2891'),
('country_Peru_167', 'state_Piura_2892'),
('country_Peru_167', 'state_Puno_2893'),
('country_Peru_167', 'state_San_Mart__n_2894'),
('country_Peru_167', 'state_Tacna_2895'),
('country_Peru_167', 'state_Tumbes_2896'),
('country_Peru_167', 'state_Ucayali_2897'),
('country_Philippines_168', 'state_Abra_2898'),
('country_Philippines_168',
'state_Agusan_del_Norte_2899'),
('country_Philippines_168',
'state_Agusan_del_Sur_2900'),
('country_Philippines_168', 'state_Aklan_2901'),
('country_Philippines_168', 'state_Albay_2902'),
('country_Philippines_168', 'state_Antique_2903'),
('country_Philippines_168', 'state_Apayao_2904'),
('country_Philippines_168', 'state_Aurora_2905'),
('country_Philippines_168', 'state_Bataan_2906'),
('country_Philippines_168', 'state_Basilan_2907'),
('country_Philippines_168', 'state_Benguet_2908'),
('country_Philippines_168', 'state_Biliran_2909'),
('country_Philippines_168', 'state_Bohol_2910'),
('country_Philippines_168', 'state_Batangas_2911'),
('country_Philippines_168', 'state_Batanes_2912'),
('country_Philippines_168', 'state_Bukidnon_2913'),
('country_Philippines_168', 'state_Bulacan_2914'),
('country_Philippines_168', 'state_Cagayan_2915'),
('country_Philippines_168', 'state_Camiguin_2916'),
('country_Philippines_168',
'state_Camarines_Norte_2917'),
('country_Philippines_168', 'state_Capiz_2918'),
('country_Philippines_168',
'state_Camarines_Sur_2919'),
('country_Philippines_168', 'state_Catanduanes_2920'),
('country_Philippines_168', 'state_Cavite_2921'),
('country_Philippines_168', 'state_Cebu_2922'),
('country_Philippines_168',
'state_Compostela_Valley_2923'),
('country_Philippines_168',
'state_Davao_Oriental_2924'),
('country_Philippines_168',
'state_Davao_del_Sur_2925'),
('country_Philippines_168',
'state_Davao_del_Norte_2926'),
('country_Philippines_168',
'state_Eastern_Samar_2927'),
('country_Philippines_168', 'state_Guimaras_2928'),
('country_Philippines_168', 'state_Ifugao_2929'),
('country_Philippines_168', 'state_Iloilo_2930'),
('country_Philippines_168',
'state_Ilocos_Norte_2931'),
('country_Philippines_168', 'state_Ilocos_Sur_2932'),
('country_Philippines_168', 'state_Isabela_2933'),
('country_Philippines_168', 'state_Kalinga_2934'),
('country_Philippines_168', 'state_Laguna_2935'),
('country_Philippines_168',
'state_Lanao_del_Norte_2936'),
('country_Philippines_168',
'state_Lanao_del_Sur_2937'),
('country_Philippines_168', 'state_Leyte_2938'),
('country_Philippines_168', 'state_La_Union_2939'),
('country_Philippines_168', 'state_Marinduque_2940'),
('country_Philippines_168', 'state_Maguindanao_2941'),
('country_Philippines_168', 'state_Masbate_2942'),
('country_Philippines_168',
'state_Mindoro_Occidental_2943'),
('country_Philippines_168',
'state_Mindoro_Oriental_2944'),
('country_Philippines_168',
'state_Mountain_Province_2945'),
('country_Philippines_168',
'state_Misamis_Occidental_2946'),
('country_Philippines_168',
'state_Misamis_Oriental_2947'),
('country_Philippines_168', 'state_Cotabato_2948'),
('country_Philippines_168',
'state_Northern_Samar_2949'),
('country_Philippines_168',
'state_Negros_Occidental_2950'),
('country_Philippines_168',
'state_Negros_Oriental_2951'),
('country_Philippines_168', 'state_Nueva_Ecija_2952'),
('country_Philippines_168',
'state_Nueva_Vizcaya_2953'),
('country_Philippines_168', 'state_Pampanga_2954'),
('country_Philippines_168', 'state_Pangasinan_2955'),
('country_Philippines_168', 'state_Palawan_2956'),
('country_Philippines_168', 'state_Quezon_2957'),
('country_Philippines_168', 'state_Quirino_2958'),
('country_Philippines_168', 'state_Rizal_2959'),
('country_Philippines_168', 'state_Romblon_2960'),
('country_Philippines_168', 'state_Sarangani_2961'),
('country_Philippines_168',
'state_South_Cotabato_2962'),
('country_Philippines_168', 'state_Siquijor_2963'),
('country_Philippines_168',
'state_Southern_Leyte_2964'),
('country_Philippines_168', 'state_Sulu_2965'),
('country_Philippines_168', 'state_Sorsogon_2966'),
('country_Philippines_168',
'state_Sultan_Kudarat_2967'),
('country_Philippines_168',
'state_Surigao_del_Norte_2968'),
('country_Philippines_168',
'state_Surigao_del_Sur_2969'),
('country_Philippines_168', 'state_Tarlac_2970'),
('country_Philippines_168', 'state_Tawi_Tawi_2971'),
('country_Philippines_168', 'state_Samar_2972'),
('country_Philippines_168',
'state_Zamboanga_del_Norte_2973'),
('country_Philippines_168',
'state_Zamboanga_del_Sur_2974'),
('country_Philippines_168', 'state_Zambales_2975'),
('country_Philippines_168',
'state_Zamboanga_Sibugay_2976'),
('country_Poland_170', 'state_Dolno__l__skie_2977'),
('country_Poland_170',
'state_Kujawsko_Pomorskie_2978'),
('country_Poland_170', 'state_Lubelskie_2979'),
('country_Poland_170', 'state_Lubuskie_2980'),
('country_Poland_170', 'state_____dzkie_2981'),
('country_Poland_170', 'state_Ma__opolskie_2982'),
('country_Poland_170', 'state_Mazowieckie_2983'),
('country_Poland_170', 'state_Opolskie_2984'),
('country_Poland_170', 'state_Podkarpackie_2985'),
('country_Poland_170', 'state_Podlaskie_2986'),
('country_Poland_170', 'state_Pomorskie_2987'),
('country_Poland_170', 'state___l__skie_2988'),
('country_Poland_170', 'state___wi__tokrzyskie_2989'),
('country_Poland_170',
'state_Warmi__sko_Mazurskie_2990'),
('country_Poland_170', 'state_Wielkopolskie_2991'),
('country_Poland_170',
'state_Zachodniopomorskie_2992'),
('country_Portugal_171', 'state_Aveiro_2993'),
('country_Portugal_171', 'state_Beja_2994'),
('country_Portugal_171', 'state_Braga_2995'),
('country_Portugal_171', 'state_Bragan__a_2996'),
('country_Portugal_171', 'state_Castelo_Branco_2997'),
('country_Portugal_171', 'state_Coimbra_2998'),
('country_Portugal_171', 'state___vora_2999'),
('country_Portugal_171', 'state_Faro_3000'),
('country_Portugal_171', 'state_Guarda_3001'),
('country_Portugal_171', 'state_Leiria_3002'),
('country_Portugal_171', 'state_Lisboa_3003'),
('country_Portugal_171', 'state_Portalegre_3004'),
('country_Portugal_171', 'state_Porto_3005'),
('country_Portugal_171', 'state_Santar__m_3006'),
('country_Portugal_171', 'state_Set__bal_3007'),
('country_Portugal_171',
'state_Viana_do_Castelo_3008'),
('country_Portugal_171', 'state_Vila_Real_3009'),
('country_Portugal_171', 'state_Viseu_3010'),
('country_Portugal_171',
'state_Regi__o_Aut__noma_dos_A__ores_3011'),
('country_Portugal_171',
'state_Regi__o_Aut__noma_da_Madeira_3012'),
('country_Qatar_173', 'state______________3013'),
('country_Qatar_173', 'state__________________3014'),
('country_Qatar_173',
'state___________________________3015'),
('country_Qatar_173', 'state__________________3016'),
('country_Qatar_173', 'state____________3017'),
('country_Qatar_173', 'state______________3018'),
('country_Qatar_173', 'state______________3019'),
('country_Qatar_173', 'state______________3020'),
('country_Qatar_173', 'state_______________3021'),
('country_Qatar_173', 'state______________3022'),
('country_Romania_175', 'state_Alba_3023'),
('country_Romania_175', 'state_Arge___3024'),
('country_Romania_175', 'state_Arad_3025'),
('country_Romania_175', 'state_Bucure__ti_3026'),
('country_Romania_175', 'state_Bac__u_3027'),
('country_Romania_175', 'state_Bihor_3028'),
('country_Romania_175',
'state_Bistri__a_N__s__ud_3029'),
('country_Romania_175', 'state_Br__ila_3030'),
('country_Romania_175', 'state_Boto__ani_3031'),
('country_Romania_175', 'state_Bra__ov_3032'),
('country_Romania_175', 'state_Buz__u_3033'),
('country_Romania_175', 'state_Cluj_3034'),
('country_Romania_175', 'state_C__l__ra__i_3035'),
('country_Romania_175', 'state_Cara___Severin_3036'),
('country_Romania_175', 'state_Constan__a_3037'),
('country_Romania_175', 'state_Covasna_3038'),
('country_Romania_175', 'state_D__mbovi__a_3039'),
('country_Romania_175', 'state_Dolj_3040'),
('country_Romania_175', 'state_Gorj_3041'),
('country_Romania_175', 'state_Gala__i_3042'),
('country_Romania_175', 'state_Giurgiu_3043'),
('country_Romania_175', 'state_Hunedoara_3044'),
('country_Romania_175', 'state_Harghita_3045'),
('country_Romania_175', 'state_Ilfov_3046'),
('country_Romania_175', 'state_Ialomi__a_3047'),
('country_Romania_175', 'state_Ia__i_3048'),
('country_Romania_175', 'state_Mehedin__i_3049'),
('country_Romania_175', 'state_Maramure___3050'),
('country_Romania_175', 'state_Mure___3051'),
('country_Romania_175', 'state_Neam___3052'),
('country_Romania_175', 'state_Olt_3053'),
('country_Romania_175', 'state_Prahova_3054'),
('country_Romania_175', 'state_Sibiu_3055'),
('country_Romania_175', 'state_S__laj_3056'),
('country_Romania_175', 'state_Satu_Mare_3057'),
('country_Romania_175', 'state_Suceava_3058'),
('country_Romania_175', 'state_Tulcea_3059'),
('country_Romania_175', 'state_Timi___3060'),
('country_Romania_175', 'state_Teleorman_3061'),
('country_Romania_175', 'state_V__lcea_3062'),
('country_Romania_175', 'state_Vrancea_3063'),
('country_Romania_175', 'state_Vaslui_3064'),
('country_Russia_176',
'state_______________________________________3065'),
('country_Russia_176',
'state_____________________________________________________________________________3066'),
('country_Russia_176',
'state_____________________________________3067'),
('country_Russia_176',
'state_______________________________3068'),
('country_Russia_176',
'state_____________________________________3069'),
('country_Russia_176',
'state_______________________________________________3070'),
('country_Russia_176',
'state_____________________________________________3071'),
('country_Russia_176',
'state___________________________________________________3072'),
('country_Russia_176',
'state_____________________________________________3073'),
('country_Russia_176',
'state_____________________________________3074'),
('country_Russia_176',
'state_________________________________________3075'),
('country_Russia_176',
'state_____________________________________________3076'),
('country_Russia_176',
'state___________________________________________3077'),
('country_Russia_176',
'state_______________________________________3078'),
('country_Russia_176',
'state__________________________________________________________3079'),
('country_Russia_176',
'state_____________________________________________3080'),
('country_Russia_176',
'state___________________________________________3081'),
('country_Russia_176',
'state______________________________________________________________3082'),
('country_Russia_176',
'state_____________________________________________3083'),
('country_Russia_176',
'state_______________________________________3084'),
('country_Russia_176',
'state_________________________________________3085'),
('country_Russia_176',
'state_________________________________________3086'),
('country_Russia_176',
'state____________________________________________________________________3087'),
('country_Russia_176',
'state____________________________________________________________________3088'),
('country_Russia_176',
'state_______________________________________3089'),
('country_Russia_176',
'state___________________________________________3090'),
('country_Russia_176',
'state___________________________________________________3091'),
('country_Russia_176',
'state_________________________________________3092'),
('country_Russia_176',
'state___________________________________3093'),
('country_Russia_176',
'state______________________________________________________________________________________3094'),
('country_Russia_176',
'state_____________________________________3095'),
('country_Russia_176',
'state_______________________________________3096'),
('country_Russia_176', 'state__________________3097'),
('country_Russia_176',
'state___________________________________________3098'),
('country_Russia_176',
'state_______________________________________3099'),
('country_Russia_176',
'state___________________________________3100'),
('country_Russia_176',
'state__________________________________________________________3101'),
('country_Russia_176',
'state___________________________________________3102'),
('country_Russia_176',
'state_________________________________________3103'),
('country_Russia_176',
'state___________________________________3104'),
('country_Russia_176',
'state_______________________________________________3105'),
('country_Russia_176',
'state_____________________________________3106'),
('country_Russia_176',
'state___________________________________________3107'),
('country_Russia_176',
'state__________________________________________3108'),
('country_Russia_176',
'state___________________________________________3109'),
('country_Russia_176',
'state_________________________________________3110'),
('country_Russia_176', 'state________________3111'),
('country_Russia_176',
'state_________________________________________3112'),
('country_Russia_176',
'state________________________________________________________3113'),
('country_Russia_176',
'state_____________________________________________3114'),
('country_Russia_176',
'state_______________________________________________3115'),
('country_Russia_176',
'state_______________________________________________3116'),
('country_Russia_176',
'state_________________________________3117'),
('country_Russia_176',
'state_____________________________________________3118'),
('country_Russia_176',
'state_______________________________________3119'),
('country_Russia_176',
'state_________________________________________3120'),
('country_Russia_176',
'state_________________________________3121'),
('country_Russia_176',
'state_______________________________________3122'),
('country_Russia_176',
'state_________________________________________3123'),
('country_Russia_176',
'state_______________________________________3124'),
('country_Russia_176',
'state____________________________________________________3125'),
('country_Russia_176',
'state___________________________________________3126'),
('country_Russia_176',
'state_______________________________________3127'),
('country_Russia_176',
'state___________________________________________3128'),
('country_Russia_176',
'state___________________________________________________________________________3129'),
('country_Russia_176',
'state_________________________________________3130'),
('country_Russia_176',
'state_________________________________3131'),
('country_Russia_176',
'state_________________________________________3132'),
('country_Russia_176',
'state_____________________________________________3133'),
('country_Russia_176',
'state_____________________________________________3134'),
('country_Russia_176',
'state_________________________________________3135'),
('country_Russia_176',
'state____________________________________________________________3136'),
('country_Russia_176',
'state___________________________________3137'),
('country_Russia_176',
'state_____________________________________3138'),
('country_Russia_176',
'state_____________________________________3139'),
('country_Russia_176',
'state___________________________________3140'),
('country_Russia_176',
'state_______________________________________3141'),
('country_Russia_176',
'state_______________________________________________3142'),
('country_Russia_176',
'state___________________________________________3143'),
('country_Russia_176',
'state________________________________________________________________________________________3144'),
('country_Russia_176',
'state_______________________________________________3145'),
('country_Russia_176',
'state_____________________________________________3146'),
('country_Russia_176',
'state___________________________________________3147'),
('country_Russia_176',
'state___________________________________________3148'),
('country_Russia_176',
'state_____________________________3149'),
('country_Russia_176',
'state_____________________________________________________________________3150'),
('country_Russia_176',
'state___________________________________________3151'),
('country_Russia_176',
'state______________________________________________________________3152'),
('country_Rwanda_177', 'state_Nord_3153'),
('country_Rwanda_177', 'state_Est_3154'),
('country_Rwanda_177', 'state_Sud_3155'),
('country_Rwanda_177', 'state_Ouest_3156'),
('country_Rwanda_177', 'state_Kigali_3157'),
('country_Saint_Kitts_and_Nevis_178',
'state_Saint_Kitts_3158'),
('country_Saint_Kitts_and_Nevis_178',
'state_Nevis_3159'),
('country_Saint_Lucia_179',
'state_Anse_la_Raye_3160'),
('country_Saint_Lucia_179', 'state_Castries_3161'),
('country_Saint_Lucia_179', 'state_Choiseul_3162'),
('country_Saint_Lucia_179', 'state_Dauphin_3163'),
('country_Saint_Lucia_179', 'state_Dennery_3164'),
('country_Saint_Lucia_179', 'state_Gros_Islet_3165'),
('country_Saint_Lucia_179', 'state_Laborie_3166'),
('country_Saint_Lucia_179', 'state_Micoud_3167'),
('country_Saint_Lucia_179', 'state_Praslin_3168'),
('country_Saint_Lucia_179', 'state_Soufriere_3169'),
('country_Saint_Lucia_179', 'state_Vieux_Fort_3170'),
('country_Saint_Vincent_and_the_Grenadines_180',
'state_Charlotte_3171'),
('country_Saint_Vincent_and_the_Grenadines_180',
'state_Grenadines_3172'),
('country_Samoa_181', 'state_A_ana_3177'),
('country_Samoa_181', 'state_Aiga_i_le_Tai_3178'),
('country_Samoa_181', 'state_Atua_3179'),
('country_Samoa_181', 'state_Fa_asaleleaga_3180'),
('country_Samoa_181', 'state_Gaga_emauga_3181'),
('country_Samoa_181', 'state_Gaga_ifomauga_3182'),
('country_Samoa_181', 'state_Palauli_3183'),
('country_Samoa_181', 'state_Satupa_itea_3184'),
('country_Samoa_181', 'state_Tuamasaga_3185'),
('country_Samoa_181', 'state_Va_a_o_Fonoti_3186'),
('country_Samoa_181', 'state_Vaisigano_3187'),
('country_San_Marino_182', 'state_Acquaviva_3188'),
('country_San_Marino_182',
'state_Borgo_Maggiore_3189'),
('country_San_Marino_182', 'state_Chiesanuova_3190'),
('country_San_Marino_182', 'state_Domagnano_3191'),
('country_San_Marino_182', 'state_Faetano_3192'),
('country_San_Marino_182', 'state_Fiorentino_3193'),
('country_San_Marino_182',
'state_Montegiardino_3194'),
('country_San_Marino_182',
'state_Citta_di_San_Marino_3195'),
('country_San_Marino_182', 'state_Serravalle_3196'),
('country_Sao_Tome_and_Principe_183',
'state_Pr__ncipe_3197'),
('country_Sao_Tome_and_Principe_183',
'state_S__o_Tom___3198'),
('country_Saudi_Arabia_184',
'state______________3199'),
('country_Saudi_Arabia_184',
'state_______________________3200'),
('country_Saudi_Arabia_184',
'state________________3201'),
('country_Saudi_Arabia_184',
'state________________3202'),
('country_Saudi_Arabia_184',
'state______________3203'),
('country_Saudi_Arabia_184', 'state__________3204'),
('country_Saudi_Arabia_184', 'state__________3205'),
('country_Saudi_Arabia_184',
'state_______________________________3206'),
('country_Saudi_Arabia_184', 'state____________3207'),
('country_Saudi_Arabia_184', 'state____________3208'),
('country_Saudi_Arabia_184',
'state______________3209'),
('country_Saudi_Arabia_184', 'state____________3210'),
('country_Saudi_Arabia_184', 'state__________3211'),
('country_Senegal_185', 'state_Dakar_3212'),
('country_Senegal_185', 'state_Diourbel_3213'),
('country_Senegal_185', 'state_Fatick_3214'),
('country_Senegal_185', 'state_Kaolack_3215'),
('country_Senegal_185', 'state_Kolda_3216'),
('country_Senegal_185', 'state_Louga_3217'),
('country_Senegal_185', 'state_Matam_3218'),
('country_Senegal_185', 'state_Saint_Louis_3219'),
('country_Senegal_185', 'state_Tambacounda_3220'),
('country_Senegal_185', 'state_Thies__3221'),
('country_Senegal_185', 'state_Ziguinchor_3222'),
('country_Seychelles_186',
'state_Anse_aux_Pins_3223'),
('country_Seychelles_186', 'state_Anse_Boileau_3224'),
('country_Seychelles_186', 'state_Anse_Etoile_3225'),
('country_Seychelles_186', 'state_Anse_Louis_3226'),
('country_Seychelles_186', 'state_Anse_Royale_3227'),
('country_Seychelles_186', 'state_Baie_Lazare_3228'),
('country_Seychelles_186',
'state_Baie_Sainte_Anne_3229'),
('country_Seychelles_186', 'state_Beau_Vallon_3230'),
('country_Seychelles_186', 'state_Bel_Air_3231'),
('country_Seychelles_186', 'state_Bel_Ombre_3232'),
('country_Seychelles_186', 'state_Cascade_3233'),
('country_Seychelles_186', 'state_Glacis_3234'),
('country_Seychelles_186',
'state_Grand__Anse__on_Mahe__3235'),
('country_Seychelles_186',
'state_Grand__Anse__on_Praslin__3236'),
('country_Seychelles_186', 'state_La_Digue_3237'),
('country_Seychelles_186',
'state_La_Riviere_Anglaise_3238'),
('country_Seychelles_186', 'state_Mont_Buxton_3239'),
('country_Seychelles_186', 'state_Mont_Fleuri_3240'),
('country_Seychelles_186', 'state_Plaisance_3241'),
('country_Seychelles_186',
'state_Pointe_La_Rue_3242'),
('country_Seychelles_186', 'state_Port_Glaud_3243'),
('country_Seychelles_186', 'state_Saint_Louis_3244'),
('country_Seychelles_186', 'state_Takamaka_3245'),
('country_Sierra_Leone_187', 'state_Eastern_3246'),
('country_Slovakia_189',
'state_Banskobystrick___kraj_3250'),
('country_Slovakia_189',
'state_Bratislavsk___kraj_3251'),
('country_Slovakia_189', 'state_Ko__ick___kraj_3252'),
('country_Slovakia_189',
'state_Nitriansk___kraj_3253')";
$this->db->setQuery($query);
$this->db->query();
$query="INSERT IGNORE INTO `#__hikashop_zone_link`
(`zone_parent_namekey`, `zone_child_namekey`) VALUES
('country_Slovakia_189',
'state_Pre__ovsk___kraj_3254'),
('country_Slovakia_189', 'state_Trnavsk___kraj_3255'),
('country_Slovakia_189',
'state_Tren__iansk___kraj_3256'),
('country_Slovakia_189',
'state___ilinsk___kraj_3257'),
('country_Slovenia_190', 'state_Ajdov____ina_3258'),
('country_Slovenia_190', 'state_Beltinci_3259'),
('country_Slovenia_190', 'state_Bled_3260'),
('country_Slovenia_190', 'state_Bohinj_3261'),
('country_Slovenia_190', 'state_Borovnica_3262'),
('country_Slovenia_190', 'state_Bovec_3263'),
('country_Slovenia_190', 'state_Brda_3264'),
('country_Slovenia_190', 'state_Brezovica_3265'),
('country_Slovenia_190', 'state_Bre__ice_3266'),
('country_Slovenia_190', 'state_Ti__ina_3267'),
('country_Slovenia_190', 'state_Celje_3268'),
('country_Slovenia_190',
'state_Cerklje_na_Gorenjskem_3269'),
('country_Slovenia_190', 'state_Cerknica_3270'),
('country_Slovenia_190', 'state_Cerkno_3271'),
('country_Slovenia_190', 'state___ren__ovci_3272'),
('country_Slovenia_190',
'state___rna_na_Koro__kem_3273'),
('country_Slovenia_190', 'state___rnomelj_3274'),
('country_Slovenia_190', 'state_Destrnik_3275'),
('country_Slovenia_190', 'state_Diva__a_3276'),
('country_Slovenia_190', 'state_Dobrepolje_3277'),
('country_Slovenia_190',
'state_Dobrova_Polhov_Gradec_3278'),
('country_Slovenia_190',
'state_Dol_pri_Ljubljani_3279'),
('country_Slovenia_190', 'state_Dom__ale_3280'),
('country_Slovenia_190', 'state_Dornava_3281'),
('country_Slovenia_190', 'state_Dravograd_3282'),
('country_Slovenia_190', 'state_Duplek_3283'),
('country_Slovenia_190',
'state_Gorenja_vas_Poljane_3284'),
('country_Slovenia_190', 'state_Gori__nica_3285'),
('country_Slovenia_190', 'state_Gornja_Radgona_3286'),
('country_Slovenia_190', 'state_Gornji_Grad_3287'),
('country_Slovenia_190',
'state_Gornji_Petrovci_3288'),
('country_Slovenia_190', 'state_Grosuplje_3289'),
('country_Slovenia_190', 'state___alovci_3290'),
('country_Slovenia_190', 'state_Hrastnik_3291'),
('country_Slovenia_190', 'state_Hrpelje_Kozina_3292'),
('country_Slovenia_190', 'state_Idrija_3293'),
('country_Slovenia_190', 'state_Ig_3294'),
('country_Slovenia_190',
'state_Ilirska_Bistrica_3295'),
('country_Slovenia_190',
'state_Ivan__na_Gorica_3296'),
('country_Slovenia_190', 'state_Izola_3297'),
('country_Slovenia_190', 'state_Jesenice_3298'),
('country_Slovenia_190', 'state_Jur__inci_3299'),
('country_Slovenia_190', 'state_Kamnik_3300'),
('country_Slovenia_190', 'state_Kanal_ob_So__i_3301'),
('country_Slovenia_190', 'state_Kidri__evo_3302'),
('country_Slovenia_190', 'state_Kobarid_3303'),
('country_Slovenia_190', 'state_Kobilje_3304'),
('country_Slovenia_190', 'state_Ko__evje_3305'),
('country_Slovenia_190', 'state_Komen_3306'),
('country_Slovenia_190', 'state_Koper_3307'),
('country_Slovenia_190', 'state_Kozje_3308'),
('country_Slovenia_190', 'state_Kranj_3309'),
('country_Slovenia_190', 'state_Kranjska_Gora_3310'),
('country_Slovenia_190', 'state_Kr__ko_3311'),
('country_Slovenia_190', 'state_Kungota_3312'),
('country_Slovenia_190', 'state_Kuzma_3313'),
('country_Slovenia_190', 'state_La__ko_3314'),
('country_Slovenia_190', 'state_Lenart_3315'),
('country_Slovenia_190', 'state_Lendava_3316'),
('country_Slovenia_190', 'state_Litija_3317'),
('country_Slovenia_190', 'state_Ljubljana_3318'),
('country_Slovenia_190', 'state_Ljubno_3319'),
('country_Slovenia_190', 'state_Ljutomer_3320'),
('country_Slovenia_190', 'state_Logatec_3321'),
('country_Slovenia_190', 'state_Lo__ka_Dolina_3322'),
('country_Slovenia_190', 'state_Lo__ki_Potok_3323'),
('country_Slovenia_190', 'state_Lu__e_3324'),
('country_Slovenia_190', 'state_Lukovica_3325'),
('country_Slovenia_190', 'state_Maj__perk_3326'),
('country_Slovenia_190', 'state_Maribor_3327'),
('country_Slovenia_190', 'state_Medvode_3328'),
('country_Slovenia_190', 'state_Menge___3329'),
('country_Slovenia_190', 'state_Metlika_3330'),
('country_Slovenia_190', 'state_Me__ica_3331'),
('country_Slovenia_190',
'state_Miren_Kostanjevica_3332'),
('country_Slovenia_190', 'state_Mislinja_3333'),
('country_Slovenia_190', 'state_Morav__e_3334'),
('country_Slovenia_190',
'state_Moravske_Toplice_3335'),
('country_Slovenia_190', 'state_Mozirje_3336'),
('country_Slovenia_190', 'state_Murska_Sobota_3337'),
('country_Slovenia_190', 'state_Muta_3338'),
('country_Slovenia_190', 'state_Naklo_3339'),
('country_Slovenia_190', 'state_Nazarje_3340'),
('country_Slovenia_190', 'state_Nova_Gorica_3341'),
('country_Slovenia_190', 'state_Novo_mesto_3342'),
('country_Slovenia_190', 'state_Odranci_3343'),
('country_Slovenia_190', 'state_Ormo___3344'),
('country_Slovenia_190', 'state_Osilnica_3345'),
('country_Slovenia_190', 'state_Pesnica_3346'),
('country_Slovenia_190', 'state_Piran_3347'),
('country_Slovenia_190', 'state_Pivka_3348'),
('country_Slovenia_190', 'state_Pod__etrtek_3349'),
('country_Slovenia_190', 'state_Podvelka_3350'),
('country_Slovenia_190', 'state_Postojna_3351'),
('country_Slovenia_190', 'state_Preddvor_3352'),
('country_Slovenia_190', 'state_Ptuj_3353'),
('country_Slovenia_190', 'state_Puconci_3354'),
('country_Slovenia_190', 'state_Ra__e_Fram_3355'),
('country_Slovenia_190', 'state_Rade__e_3356'),
('country_Slovenia_190', 'state_Radenci_3357'),
('country_Slovenia_190',
'state_Radlje_ob_Dravi_3358'),
('country_Slovenia_190', 'state_Radovljica_3359'),
('country_Slovenia_190',
'state_Ravne_na_Koro__kem_3360'),
('country_Slovenia_190', 'state_Ribnica_3361'),
('country_Slovenia_190',
'state_Roga__ka_Slatina_3362'),
('country_Slovenia_190', 'state_Roga__ovci_3363'),
('country_Slovenia_190', 'state_Rogatec_3364'),
('country_Slovenia_190', 'state_Ru__e_3365'),
('country_Slovenia_190', 'state_Semi___3366'),
('country_Slovenia_190', 'state_Sevnica_3367'),
('country_Slovenia_190', 'state_Se__ana_3368'),
('country_Slovenia_190', 'state_Slovenj_Gradec_3369'),
('country_Slovenia_190',
'state_Slovenska_Bistrica_3370'),
('country_Slovenia_190',
'state_Slovenske_Konjice_3371'),
('country_Slovenia_190', 'state_Star__e_3372'),
('country_Slovenia_190', 'state_Sveti_Jurij_3373'),
('country_Slovenia_190', 'state___en__ur_3374'),
('country_Slovenia_190', 'state___entilj_3375'),
('country_Slovenia_190', 'state___entjernej_3376'),
('country_Slovenia_190',
'state___entjur_pri_Celju_3377'),
('country_Slovenia_190', 'state___kocjan_3378'),
('country_Slovenia_190', 'state___kofja_Loka_3379'),
('country_Slovenia_190', 'state___kofljica_3380'),
('country_Slovenia_190',
'state___marje_pri_Jel__ah_3381'),
('country_Slovenia_190',
'state___martno_ob_Paki_3382'),
('country_Slovenia_190', 'state___o__tanj_3383'),
('country_Slovenia_190', 'state___tore_3384'),
('country_Slovenia_190', 'state_Tolmin_3385'),
('country_Slovenia_190', 'state_Trbovlje_3386'),
('country_Slovenia_190', 'state_Trebnje_3387'),
('country_Slovenia_190', 'state_Tr__i___3388'),
('country_Slovenia_190', 'state_Turni____e_3389'),
('country_Slovenia_190', 'state_Velenje_3390'),
('country_Slovenia_190', 'state_Velike_La____e_3391'),
('country_Slovenia_190', 'state_Videm_3392'),
('country_Slovenia_190', 'state_Vipava_3393'),
('country_Slovenia_190', 'state_Vitanje_3394'),
('country_Slovenia_190', 'state_Vodice_3395'),
('country_Slovenia_190', 'state_Vojnik_3396'),
('country_Slovenia_190', 'state_Vrhnika_3397'),
('country_Slovenia_190', 'state_Vuzenica_3398'),
('country_Slovenia_190',
'state_Zagorje_ob_Savi_3399'),
('country_Slovenia_190', 'state_Zavr___3400'),
('country_Slovenia_190', 'state_Zre__e_3401'),
('country_Slovenia_190', 'state___elezniki_3402'),
('country_Slovenia_190', 'state___iri_3403'),
('country_Slovenia_190', 'state_Benedikt_3404'),
('country_Slovenia_190',
'state_Bistrica_ob_Sotli_3405'),
('country_Slovenia_190', 'state_Bloke_3406'),
('country_Slovenia_190', 'state_Braslov__e_3407'),
('country_Slovenia_190', 'state_Cankova_3408'),
('country_Slovenia_190', 'state_Cerkvenjak_3409'),
('country_Slovenia_190', 'state_Dobje_3410'),
('country_Slovenia_190', 'state_Dobrna_3411'),
('country_Slovenia_190', 'state_Dobrovnik_3412'),
('country_Slovenia_190',
'state_Dolenjske_Toplice_3413'),
('country_Slovenia_190', 'state_Grad_3414'),
('country_Slovenia_190', 'state_Hajdina_3415'),
('country_Slovenia_190', 'state_Ho__e_Slivnica_3416'),
('country_Slovenia_190', 'state_Hodo___3417'),
('country_Slovenia_190', 'state_Horjul_3418'),
('country_Slovenia_190', 'state_Jezersko_3419'),
('country_Slovenia_190', 'state_Komenda_3420'),
('country_Slovenia_190', 'state_Kostel_3421'),
('country_Slovenia_190', 'state_Kri__evci_3422'),
('country_Slovenia_190',
'state_Lovrenc_na_Pohorju_3423'),
('country_Slovenia_190', 'state_Markovci_3424'),
('country_Slovenia_190',
'state_Miklav___na_Dravskem_polju_3425'),
('country_Slovenia_190', 'state_Mirna_Pe___3426'),
('country_Slovenia_190', 'state_Oplotnica_3427'),
('country_Slovenia_190', 'state_Podlehnik_3428'),
('country_Slovenia_190', 'state_Polzela_3429'),
('country_Slovenia_190', 'state_Prebold_3430'),
('country_Slovenia_190', 'state_Prevalje_3431'),
('country_Slovenia_190', 'state_Razkri__je_3432'),
('country_Slovenia_190',
'state_Ribnica_na_Pohorju_3433'),
('country_Slovenia_190',
'state_Selnica_ob_Dravi_3434'),
('country_Slovenia_190', 'state_Sodra__ica_3435'),
('country_Slovenia_190', 'state_Sol__ava_3436'),
('country_Slovenia_190', 'state_Sveta_Ana_3437'),
('country_Slovenia_190',
'state_Sveti_Andra___v_Slovenskih_goricah_3438'),
('country_Slovenia_190',
'state___empeter_Vrtojba_3439'),
('country_Slovenia_190', 'state_Tabor_3440'),
('country_Slovenia_190', 'state_Trnovska_vas_3441'),
('country_Slovenia_190', 'state_Trzin_3442'),
('country_Slovenia_190', 'state_Velika_Polana_3443'),
('country_Slovenia_190', 'state_Ver__ej_3444'),
('country_Slovenia_190', 'state_Vransko_3445'),
('country_Slovenia_190', 'state___alec_3446'),
('country_Slovenia_190', 'state___etale_3447'),
('country_Slovenia_190', 'state___irovnica_3448'),
('country_Slovenia_190', 'state___u__emberk_3449'),
('country_Slovenia_190',
'state___martno_pri_Litiji_3450'),
('country_Solomon_Islands_191',
'state_Guadalcanal_3453'),
('country_Solomon_Islands_191', 'state_Honiara_3454'),
('country_Solomon_Islands_191', 'state_Isabel_3455'),
('country_Solomon_Islands_191', 'state_Makira_3456'),
('country_Solomon_Islands_191', 'state_Malaita_3457'),
('country_Solomon_Islands_191',
'state_Rennell_and_Bellona_3458'),
('country_Solomon_Islands_191', 'state_Temotu_3459'),
('country_Somalia_192', 'state_Awdal_3461'),
('country_Somalia_192', 'state_Bakool_3462'),
('country_Somalia_192', 'state_Banaadir_3463'),
('country_Somalia_192', 'state_Bari_3464'),
('country_Somalia_192', 'state_Bay_3465'),
('country_Somalia_192', 'state_Gedo_3466'),
('country_Somalia_192', 'state_Galguduud_3467'),
('country_Somalia_192', 'state_Hiiraan_3468'),
('country_Somalia_192', 'state_Jubbada_Dhexe_3469'),
('country_Somalia_192', 'state_Jubbada_Hoose_3470'),
('country_Somalia_192', 'state_Mudug_3471'),
('country_Somalia_192', 'state_Nugaal_3472'),
('country_Somalia_192',
'state_Shabeellaha_Dhexe_3473'),
('country_Somalia_192', 'state_Sanaag_3474'),
('country_Somalia_192',
'state_Shabeellaha_Hoose_3475'),
('country_Somalia_192', 'state_Sool_3476'),
('country_Somalia_192', 'state_Togdheer_3477'),
('country_Somalia_192', 'state_Woqooyi_Galbeed_3478'),
('country_South_Africa_193',
'state_Eastern_Cape_3479'),
('country_South_Africa_193', 'state_Free_State_3480'),
('country_South_Africa_193', 'state_Gauteng_3481'),
('country_South_Africa_193', 'state_Limpopo_3482'),
('country_South_Africa_193', 'state_Mpumalanga_3483'),
('country_South_Africa_193',
'state_Northern_Cape_3484'),
('country_South_Africa_193',
'state_KwaZulu_Natal_3485'),
('country_South_Africa_193',
'state_Western_Cape_3487'),
('country_South_Africa_193', 'state_North_West_4556'),
('country_Spain_195', 'state_Granada_4504'),
('country_Spain_195', 'state_Le__n_4505'),
('country_Spain_195', 'state_Alicante_3490'),
('country_Spain_195', 'state_Albacete_3491'),
('country_Spain_195', 'state_Almer__a_3492'),
('country_Spain_195', 'state___vila_3494'),
('country_Spain_195', 'state_Barcelona_3495'),
('country_Spain_195', 'state_Badajoz_3496'),
('country_Spain_195', 'state_Vizcaya_3497'),
('country_Spain_195', 'state_Burgos_3498'),
('country_Spain_195', 'state_A_Coru__a_3499'),
('country_Spain_195', 'state_C__diz_3500'),
('country_Spain_195', 'state_C__ceres_3501'),
('country_Spain_195', 'state_Ceuta_3502'),
('country_Spain_195', 'state_C__rdoba_3506'),
('country_Spain_195', 'state_Ciudad_Real_3507'),
('country_Spain_195', 'state_Castell__n_3508'),
('country_Spain_195', 'state_Cuenca_3510'),
('country_Spain_195', 'state_Las_Palmas_3513'),
('country_Spain_195', 'state_Girona_3514'),
('country_Spain_195', 'state_Guadalajara_3516'),
('country_Spain_195', 'state_Huelva_3517'),
('country_Spain_195', 'state_Huesca_3518'),
('country_Spain_195', 'state_Ja__n_3520'),
('country_Spain_195', 'state_Lleida_3521'),
('country_Spain_195', 'state_La_Rioja_3523'),
('country_Spain_195', 'state_Lugo_3524'),
('country_Spain_195', 'state_Madrid_3525'),
('country_Spain_195', 'state_M__laga_3526'),
('country_Spain_195', 'state_Melilla_3527'),
('country_Spain_195', 'state_Murcia_3528'),
('country_Spain_195', 'state_Navarre_3529'),
('country_Spain_195', 'state_Asturias_3530'),
('country_Spain_195', 'state_Ourense_3531'),
('country_Spain_195', 'state_Palencia_3532'),
('country_Spain_195', 'state_Baleares_3533'),
('country_Spain_195', 'state_Pontevedra_3534'),
('country_Spain_195', 'state_Cantabria_3536'),
('country_Spain_195', 'state_Salamanca_3537'),
('country_Spain_195', 'state_Seville_3538'),
('country_Spain_195', 'state_Segovia_3539'),
('country_Spain_195', 'state_Soria_3540'),
('country_Spain_195', 'state_Guip__zcoa_3541'),
('country_Spain_195', 'state_Tarragona_3542'),
('country_Spain_195', 'state_Teruel_3543'),
('country_Spain_195',
'state_Santa_Cruz_De_Tenerife_3544'),
('country_Spain_195', 'state_Toledo_3545'),
('country_Spain_195', 'state_Valencia_3546'),
('country_Spain_195', 'state_Valladolid_3547'),
('country_Spain_195', 'state___lava_3548'),
('country_Spain_195', 'state_Zaragoza_3549'),
('country_Spain_195', 'state_Zamora_3550'),
('country_Sri_Lanka_196', 'state_North_Central_3552'),
('country_Sri_Lanka_196', 'state_North_3553'),
('country_Sri_Lanka_196', 'state_North_Western_3555'),
('country_Sri_Lanka_196', 'state_Uva_3557'),
('country_Sri_Lanka_196', 'state_Sabaragamuwa_3558'),
('country_Sudan_199',
'state_______________________3560'),
('country_Sudan_199',
'state_________________________3561'),
('country_Sudan_199', 'state__________________3562'),
('country_Sudan_199',
'state___________________________3563'),
('country_Sudan_199', 'state________________3564'),
('country_Sudan_199', 'state________________3565'),
('country_Sudan_199', 'state______________3566'),
('country_Sudan_199',
'state_________________________3567'),
('country_Sudan_199',
'state_________________________3568'),
('country_Sudan_199', 'state__________________3569'),
('country_Sudan_199',
'state___________________________________3570'),
('country_Sudan_199',
'state_____________________________3571'),
('country_Sudan_199',
'state____________________________3572'),
('country_Sudan_199',
'state_____________________3573'),
('country_Sudan_199',
'state_____________________3574'),
('country_Sudan_199',
'state_______________________3575'),
('country_Sudan_199',
'state_______________________3576'),
('country_Sudan_199', 'state______________3577'),
('country_Sudan_199', 'state__________3578'),
('country_Sudan_199',
'state______________________________3579'),
('country_Sudan_199',
'state______________________________3580'),
('country_Sudan_199',
'state_______________________3581'),
('country_Sudan_199',
'state_______________________3582'),
('country_Sudan_199',
'state_____________________________3583'),
('country_Sudan_199', 'state__________3584'),
('country_Sudan_199', 'state____________3585'),
('country_Suriname_200', 'state_Brokopondo_3586'),
('country_Suriname_200', 'state_Commewijne_3587'),
('country_Suriname_200', 'state_Coronie_3588'),
('country_Suriname_200', 'state_Marowijne_3589'),
('country_Suriname_200', 'state_Nickerie_3590'),
('country_Suriname_200', 'state_Paramaribo_3591'),
('country_Suriname_200', 'state_Para_3592'),
('country_Suriname_200', 'state_Saramacca_3593'),
('country_Suriname_200', 'state_Sipaliwini_3594'),
('country_Suriname_200', 'state_Wanica_3595'),
('country_Swaziland_202', 'state_Hhohho_3596'),
('country_Swaziland_202', 'state_Lubombo_3597'),
('country_Swaziland_202', 'state_Manzini_3598'),
('country_Swaziland_202', 'state_Shiselweni_3599'),
('country_Sweden_203', 'state_Stockholms_l__n_3600'),
('country_Sweden_203', 'state_Uppsala_l__n_3601'),
('country_Sweden_203',
'state_S__dermanlands_l__n_3602'),
('country_Sweden_203',
'state___sterg__tlands_l__n_3603'),
('country_Sweden_203',
'state_J__nk__pings_l__n_3604'),
('country_Sweden_203', 'state_Kronobergs_l__n_3605'),
('country_Sweden_203', 'state_Kalmar_l__n_3606'),
('country_Sweden_203', 'state_Gotlands_l__n_3607'),
('country_Sweden_203', 'state_Blekinge_l__n_3608'),
('country_Sweden_203', 'state_Sk__ne_l__n_3609'),
('country_Sweden_203', 'state_Hallands_l__n_3610'),
('country_Sweden_203',
'state_V__stra_G__talands_l__n_3611'),
('country_Sweden_203', 'state_V__rmlands_l__n__3612'),
('country_Sweden_203', 'state___rebro_l__n_3613'),
('country_Sweden_203',
'state_V__stmanlands_l__n__3614'),
('country_Sweden_203', 'state_Dalarnas_l__n_3615'),
('country_Sweden_203', 'state_G__vleborgs_l__n_3616'),
('country_Sweden_203',
'state_V__sternorrlands_l__n_3617'),
('country_Sweden_203', 'state_J__mtlands_l__n_3618'),
('country_Sweden_203',
'state_V__sterbottens_l__n_3619'),
('country_Sweden_203', 'state_Norrbottens_l__n_3620'),
('country_Switzerland_204', 'state_Z__rich_3621'),
('country_Switzerland_204', 'state_Bern_3622'),
('country_Switzerland_204', 'state_Luzern_3623'),
('country_Switzerland_204', 'state_Uri_3624'),
('country_Switzerland_204', 'state_Schwyz_3625'),
('country_Switzerland_204', 'state_Obwalden_3626'),
('country_Switzerland_204', 'state_Nidwalden_3627'),
('country_Switzerland_204', 'state_Glasrus_3628'),
('country_Switzerland_204', 'state_Zug_3629'),
('country_Switzerland_204', 'state_Fribourg_3630'),
('country_Switzerland_204', 'state_Solothurn_3631'),
('country_Switzerland_204', 'state_Basel_Stadt_3632'),
('country_Switzerland_204',
'state_Basel_Landschaft_3633'),
('country_Switzerland_204',
'state_Schaffhausen_3634'),
('country_Switzerland_204',
'state_Appenzell_Ausserrhoden_3635'),
('country_Switzerland_204',
'state_Appenzell_Innerrhoden_3636'),
('country_Switzerland_204',
'state_Saint_Gallen_3637'),
('country_Switzerland_204', 'state_Graub__nden_3638'),
('country_Switzerland_204', 'state_Aargau_3639'),
('country_Switzerland_204', 'state_Thurgau_3640'),
('country_Switzerland_204', 'state_Ticino_3641'),
('country_Switzerland_204', 'state_Vaud_3642'),
('country_Switzerland_204', 'state_Valais_3643'),
('country_Switzerland_204', 'state_Nuech__tel_3644'),
('country_Switzerland_204', 'state_Gen__ve_3645'),
('country_Switzerland_204', 'state_Jura_3646'),
('country_Syrian_Arab_Republic_205',
'state__________3647'),
('country_Syrian_Arab_Republic_205',
'state__________3648'),
('country_Syrian_Arab_Republic_205',
'state___________________3649'),
('country_Syrian_Arab_Republic_205',
'state______________3650'),
('country_Syrian_Arab_Republic_205',
'state________3651'),
('country_Syrian_Arab_Republic_205',
'state________3652'),
('country_Syrian_Arab_Republic_205',
'state__________3653'),
('country_Syrian_Arab_Republic_205',
'state__________3654'),
('country_Syrian_Arab_Republic_205',
'state__________________3655'),
('country_Syrian_Arab_Republic_205',
'state__________________3656'),
('country_Syrian_Arab_Republic_205',
'state____________3657'),
('country_Syrian_Arab_Republic_205',
'state_________________3658'),
('country_Syrian_Arab_Republic_205',
'state__________________3659'),
('country_Syrian_Arab_Republic_205',
'state____________3660'),
('country_Taiwan_206', 'state___________3661'),
('country_Taiwan_206', 'state___________3662'),
('country_Taiwan_206', 'state___________3663'),
('country_Taiwan_206', 'state___________3664'),
('country_Taiwan_206', 'state___________3665'),
('country_Taiwan_206', 'state___________3666'),
('country_Taiwan_206', 'state___________3667'),
('country_Taiwan_206', 'state___________3668'),
('country_Taiwan_206', 'state___________3669'),
('country_Taiwan_206', 'state___________3670'),
('country_Taiwan_206', 'state___________3671'),
('country_Taiwan_206', 'state___________3672'),
('country_Taiwan_206', 'state___________3673'),
('country_Taiwan_206', 'state___________3674'),
('country_Taiwan_206', 'state___________3675'),
('country_Taiwan_206', 'state___________3676'),
('country_Taiwan_206', 'state___________3677'),
('country_Taiwan_206', 'state___________3678'),
('country_Taiwan_206', 'state___________3679'),
('country_Taiwan_206', 'state___________3680'),
('country_Taiwan_206', 'state___________3681'),
('country_Taiwan_206', 'state___________3682'),
('country_Taiwan_206', 'state___________3683'),
('country_Tajikistan_207',
'state_____________________________3684'),
('country_Tajikistan_207', 'state____________3685'),
('country_Tajikistan_207', 'state________3686'),
('country_Tanzania_208', 'state_Arusha_3687'),
('country_Tanzania_208', 'state_Dar_es_Salaam_3688'),
('country_Tanzania_208', 'state_Dodoma_3689'),
('country_Tanzania_208', 'state_Iringa_3690'),
('country_Tanzania_208', 'state_Kagera_3691'),
('country_Tanzania_208', 'state_Pemba_Sever_3692'),
('country_Tanzania_208', 'state_Zanzibar_Sever_3693'),
('country_Tanzania_208', 'state_Kigoma_3694'),
('country_Tanzania_208', 'state_Kilimanjaro_3695'),
('country_Tanzania_208', 'state_Pemba_Jih_3696'),
('country_Tanzania_208', 'state_Zanzibar_Jih_3697'),
('country_Tanzania_208', 'state_Lindi_3698'),
('country_Tanzania_208', 'state_Mara_3699'),
('country_Tanzania_208', 'state_Mbeya_3700'),
('country_Tanzania_208',
'state_Zanzibar_Z__pad_3701'),
('country_Tanzania_208', 'state_Morogoro_3702'),
('country_Tanzania_208', 'state_Mtwara_3703'),
('country_Tanzania_208', 'state_Mwanza_3704'),
('country_Tanzania_208', 'state_Pwani_3705'),
('country_Tanzania_208', 'state_Rukwa_3706'),
('country_Tanzania_208', 'state_Ruvuma_3707'),
('country_Tanzania_208', 'state_Shinyanga_3708'),
('country_Tanzania_208', 'state_Singida_3709'),
('country_Tanzania_208', 'state_Tabora_3710'),
('country_Tanzania_208', 'state_Tanga_3711'),
('country_Tanzania_208', 'state_Manyara_3712'),
('country_Thailand_209',
'state_________________________________________3713'),
('country_Thailand_209',
'state___________________________________3714'),
('country_Thailand_209',
'state_______________________3715'),
('country_Thailand_209',
'state__________________________3716'),
('country_Thailand_209',
'state_______________________________________________3717'),
('country_Thailand_209',
'state_______________________3718'),
('country_Thailand_209',
'state____________________3719'),
('country_Thailand_209',
'state_____________________________3720'),
('country_Thailand_209',
'state____________________3721'),
('country_Thailand_209',
'state_______________________3722'),
('country_Thailand_209',
'state____________________3723'),
('country_Thailand_209',
'state_________________3724'),
('country_Thailand_209',
'state__________________________3725'),
('country_Thailand_209', 'state______________3726'),
('country_Thailand_209',
'state________________________________3727'),
('country_Thailand_209',
'state________________________________3728'),
('country_Thailand_209',
'state_______________________3729'),
('country_Thailand_209',
'state_______________________3730'),
('country_Thailand_209',
'state________________________________3731'),
('country_Thailand_209',
'state_____________________________3732'),
('country_Thailand_209',
'state__________________________3733'),
('country_Thailand_209',
'state__________________________3734'),
('country_Thailand_209',
'state___________________________________3735'),
('country_Thailand_209',
'state_________________3736'),
('country_Thailand_209',
'state_______________________3737'),
('country_Thailand_209',
'state________________________________3738'),
('country_Thailand_209',
'state___________________________________3739'),
('country_Thailand_209',
'state_______________________3740'),
('country_Thailand_209',
'state__________________________3741'),
('country_Thailand_209', 'state___________3742'),
('country_Thailand_209',
'state_______________________3743'),
('country_Thailand_209',
'state_____________________________3744'),
('country_Thailand_209',
'state__________________________3745'),
('country_Thailand_209',
'state_____________________________3746'),
('country_Thailand_209',
'state____________________3747'),
('country_Thailand_209',
'state____________________3748'),
('country_Thailand_209',
'state__________________________3749'),
('country_Thailand_209',
'state_____________________________3750'),
('country_Thailand_209',
'state_________________3751'),
('country_Thailand_209',
'state_________________3752'),
('country_Thailand_209',
'state_____________________________3753'),
('country_Thailand_209', 'state______________3754'),
('country_Thailand_209',
'state_________________3755'),
('country_Thailand_209',
'state__________________________3756'),
('country_Thailand_209',
'state________________________________3757'),
('country_Thailand_209',
'state_____________________________3758'),
('country_Thailand_209',
'state_____________________________3759'),
('country_Thailand_209',
'state_____________________________3760'),
('country_Thailand_209',
'state___________3761')";
$this->db->setQuery($query);
$this->db->query();
$query="INSERT IGNORE INTO `#__hikashop_zone_link`
(`zone_parent_namekey`, `zone_child_namekey`) VALUES
('country_Thailand_209',
'state_______________________3762'),
('country_Thailand_209',
'state_________________3763'),
('country_Thailand_209',
'state____________________3764'),
('country_Thailand_209',
'state_______________________3765'),
('country_Thailand_209',
'state_____________________________3766'),
('country_Thailand_209',
'state________________________________3767'),
('country_Thailand_209',
'state____________________3768'),
('country_Thailand_209',
'state_____________________________3769'),
('country_Thailand_209',
'state___________________________________3770'),
('country_Thailand_209',
'state__________________________3771'),
('country_Thailand_209',
'state_______________________________________________3772'),
('country_Thailand_209',
'state_________________________________________3773'),
('country_Thailand_209',
'state____________________3774'),
('country_Thailand_209',
'state_________________3775'),
('country_Thailand_209',
'state____________________3776'),
('country_Thailand_209',
'state______________________________________3777'),
('country_Thailand_209',
'state_________________3778'),
('country_Thailand_209',
'state_________________3779'),
('country_Thailand_209',
'state_________________3780'),
('country_Thailand_209', 'state______________3781'),
('country_Thailand_209', 'state______________3782'),
('country_Thailand_209',
'state____________________3783'),
('country_Thailand_209',
'state_______________________3784'),
('country_Thailand_209', 'state______________3785'),
('country_Thailand_209',
'state__________________________3786'),
('country_Togo_210', 'state_Centrale_3787'),
('country_Togo_210', 'state_Kara_3788'),
('country_Togo_210', 'state_Maritime_3789'),
('country_Togo_210', 'state_Plateaux_3790'),
('country_Togo_210', 'state_Savanes_3791'),
('country_Tokelau_211', 'state_Atafu_3792'),
('country_Tokelau_211', 'state_Fakaofo_3793'),
('country_Tokelau_211', 'state_Nukunonu_3794'),
('country_Tonga_212', 'state_Ha_apai_3795'),
('country_Tonga_212', 'state_Tongatapu_3796'),
('country_Tonga_212', 'state_Vava_u_3797'),
('country_Trinidad_and_Tobago_213',
'state_Arima_3798'),
('country_Trinidad_and_Tobago_213',
'state_Chaguanas_3799'),
('country_Trinidad_and_Tobago_213',
'state_Couva_Tabaquite_Talparo_3800'),
('country_Trinidad_and_Tobago_213',
'state_Diego_Martin_3801'),
('country_Trinidad_and_Tobago_213',
'state_Eastern_Tobago_3802'),
('country_Trinidad_and_Tobago_213',
'state_Rio_Claro_Mayaro_3803'),
('country_Trinidad_and_Tobago_213',
'state_Penal_Debe_3804'),
('country_Trinidad_and_Tobago_213',
'state_Point_Fortin_3805'),
('country_Trinidad_and_Tobago_213',
'state_Port_of_Spain_3806'),
('country_Trinidad_and_Tobago_213',
'state_Princes_Town_3807'),
('country_Trinidad_and_Tobago_213',
'state_San_Fernando_3808'),
('country_Trinidad_and_Tobago_213',
'state_Sangre_Grande_3809'),
('country_Trinidad_and_Tobago_213',
'state_San_Juan_Laventille_3810'),
('country_Trinidad_and_Tobago_213',
'state_Siparia_3811'),
('country_Trinidad_and_Tobago_213',
'state_Tunapuna_Piarco_3812'),
('country_Trinidad_and_Tobago_213',
'state_Western_Tobago_3813'),
('country_Tunisia_214',
'state_____________________3814'),
('country_Tunisia_214',
'state_________________________3815'),
('country_Tunisia_214',
'state__________________________3816'),
('country_Tunisia_214',
'state_______________________3817'),
('country_Tunisia_214',
'state_____________________3818'),
('country_Tunisia_214',
'state_______________________3819'),
('country_Tunisia_214',
'state_______________________3820'),
('country_Tunisia_214',
'state_____________________3821'),
('country_Tunisia_214',
'state_________________________3822'),
('country_Tunisia_214',
'state_______________________3823'),
('country_Tunisia_214',
'state_________________________3824'),
('country_Tunisia_214',
'state_____________________________3825'),
('country_Tunisia_214',
'state___________________________3826'),
('country_Tunisia_214',
'state________________________________3827'),
('country_Tunisia_214',
'state_____________________3828'),
('country_Tunisia_214',
'state_____________________________3829'),
('country_Tunisia_214',
'state___________________________3830'),
('country_Tunisia_214',
'state_______________________3831'),
('country_Tunisia_214',
'state_____________________3832'),
('country_Tunisia_214',
'state_____________________3833'),
('country_Tunisia_214',
'state_____________________3834'),
('country_Tunisia_214',
'state_____________________3835'),
('country_Tunisia_214',
'state_______________________3836'),
('country_Tunisia_214',
'state_________________________3837'),
('country_Turkey_215', 'state_Adana_3838'),
('country_Turkey_215', 'state_Ad__yaman_3839'),
('country_Turkey_215', 'state_Afyonkarahisar_3840'),
('country_Turkey_215', 'state_A__r___3841'),
('country_Turkey_215', 'state_Amasya_3842'),
('country_Turkey_215', 'state_Ankara_3843'),
('country_Turkey_215', 'state_Antalya_3844'),
('country_Turkey_215', 'state_Artvin_3845'),
('country_Turkey_215', 'state_Ayd__n_3846'),
('country_Turkey_215', 'state_Bal__kesir_3847'),
('country_Turkey_215', 'state_Bilecik_3848'),
('country_Turkey_215', 'state_Bing__l_3849'),
('country_Turkey_215', 'state_Bitlis_3850'),
('country_Turkey_215', 'state_Bolu_3851'),
('country_Turkey_215', 'state_Burdur_3852'),
('country_Turkey_215', 'state_Bursa_3853'),
('country_Turkey_215', 'state___anakkale_3854'),
('country_Turkey_215', 'state___ank__r___3855'),
('country_Turkey_215', 'state___orum_3856'),
('country_Turkey_215', 'state_Denizli_3857'),
('country_Turkey_215', 'state_Diyarbak__r_3858'),
('country_Turkey_215', 'state_Edirne_3859'),
('country_Turkey_215', 'state_Elaz_____3860'),
('country_Turkey_215', 'state_Erzincan_3861'),
('country_Turkey_215', 'state_Erzurum_3862'),
('country_Turkey_215', 'state_Eski__ehir_3863'),
('country_Turkey_215', 'state_Gaziantep_3864'),
('country_Turkey_215', 'state_Giresun_3865'),
('country_Turkey_215', 'state_G__m____hane_3866'),
('country_Turkey_215', 'state_Hakkari_3867'),
('country_Turkey_215', 'state_Hatay_3868'),
('country_Turkey_215', 'state_Isparta_3869'),
('country_Turkey_215', 'state_Mersin_3870'),
('country_Turkey_215', 'state___stanbul_3871'),
('country_Turkey_215', 'state___zmir_3872'),
('country_Turkey_215', 'state_Kars_3873'),
('country_Turkey_215', 'state_Kastamonu_3874'),
('country_Turkey_215', 'state_Kayseri_3875'),
('country_Turkey_215', 'state_K__rklareli_3876'),
('country_Turkey_215', 'state_K__r__ehir_3877'),
('country_Turkey_215', 'state_Kocaeli_3878'),
('country_Turkey_215', 'state_Konya_3879'),
('country_Turkey_215', 'state_K__tahya_3880'),
('country_Turkey_215', 'state_Malatya_3881'),
('country_Turkey_215', 'state_Manisa_3882'),
('country_Turkey_215', 'state_Kahramanmara___3883'),
('country_Turkey_215', 'state_Mardin_3884'),
('country_Turkey_215', 'state_Mu__la_3885'),
('country_Turkey_215', 'state_Mu___3886'),
('country_Turkey_215', 'state_Nev__ehir_3887'),
('country_Turkey_215', 'state_Ni__de_3888'),
('country_Turkey_215', 'state_Ordu_3889'),
('country_Turkey_215', 'state_Rize_3890'),
('country_Turkey_215', 'state_Sakarya_3891'),
('country_Turkey_215', 'state_Samsun_3892'),
('country_Turkey_215', 'state_Siirt_3893'),
('country_Turkey_215', 'state_Sinop_3894'),
('country_Turkey_215', 'state_Sivas_3895'),
('country_Turkey_215', 'state_Tekirda___3896'),
('country_Turkey_215', 'state_Tokat_3897'),
('country_Turkey_215', 'state_Trabzon_3898'),
('country_Turkey_215', 'state_Tunceli_3899'),
('country_Turkey_215', 'state___anl__urfa_3900'),
('country_Turkey_215', 'state_U__ak_3901'),
('country_Turkey_215', 'state_Van_3902'),
('country_Turkey_215', 'state_Yozgat_3903'),
('country_Turkey_215', 'state_Zonguldak_3904'),
('country_Turkey_215', 'state_Aksaray_3905'),
('country_Turkey_215', 'state_Bayburt_3906'),
('country_Turkey_215', 'state_Karaman_3907'),
('country_Turkey_215', 'state_K__r__kkale_3908'),
('country_Turkey_215', 'state_Batman_3909'),
('country_Turkey_215', 'state_____rnak_3910'),
('country_Turkey_215', 'state_Bart__n_3911'),
('country_Turkey_215', 'state_Ardahan_3912'),
('country_Turkey_215', 'state_I__d__r_3913'),
('country_Turkey_215', 'state_Yalova_3914'),
('country_Turkey_215', 'state_Karab__k_3915'),
('country_Turkey_215', 'state_Kilis_3916'),
('country_Turkey_215', 'state_Osmaniye_3917'),
('country_Turkey_215', 'state_D__zce_3918'),
('country_Turkmenistan_216',
'state_Ahal_wela__aty_3919'),
('country_Turkmenistan_216',
'state_Balkan_wela__aty_3920'),
('country_Turkmenistan_216',
'state_Da__oguz_wela__aty_3921'),
('country_Turkmenistan_216',
'state_Lebap_wela__aty_3922'),
('country_Turkmenistan_216',
'state_Mary_wela__aty_3923'),
('country_Turks_and_Caicos_Islands_217',
'state_Ambergris_Cays_3924'),
('country_Turks_and_Caicos_Islands_217',
'state_Dellis_Cay_3925'),
('country_Turks_and_Caicos_Islands_217',
'state_French_Cay_3926'),
('country_Turks_and_Caicos_Islands_217',
'state_Little_Water_Cay_3927'),
('country_Turks_and_Caicos_Islands_217',
'state_Parrot_Cay_3928'),
('country_Turks_and_Caicos_Islands_217',
'state_Pine_Cay_3929'),
('country_Turks_and_Caicos_Islands_217',
'state_Salt_Cay_3930'),
('country_Turks_and_Caicos_Islands_217',
'state_Grand_Turk_3931'),
('country_Turks_and_Caicos_Islands_217',
'state_South_Caicos_3932'),
('country_Turks_and_Caicos_Islands_217',
'state_East_Caicos_3933'),
('country_Turks_and_Caicos_Islands_217',
'state_Middle_Caicos_3934'),
('country_Turks_and_Caicos_Islands_217',
'state_North_Caicos_3935'),
('country_Turks_and_Caicos_Islands_217',
'state_Providenciales_3936'),
('country_Turks_and_Caicos_Islands_217',
'state_West_Caicos_3937'),
('country_Tuvalu_218', 'state_Funafuti_3938'),
('country_Tuvalu_218', 'state_Nanumea_3939'),
('country_Tuvalu_218', 'state_Nanumanga_3940'),
('country_Tuvalu_218', 'state_Niutao_3941'),
('country_Tuvalu_218', 'state_Nui_3942'),
('country_Tuvalu_218', 'state_Nukufetau_3943'),
('country_Tuvalu_218', 'state_Nukulaelae_3944'),
('country_Tuvalu_218', 'state_Vaitupu_3945'),
('country_Uganda_219', 'state_Kalangala_3946'),
('country_Uganda_219', 'state_Kampala_3947'),
('country_Uganda_219', 'state_Kiboga_3948'),
('country_Uganda_219', 'state_Luwero_3949'),
('country_Uganda_219', 'state_Masaka_3950'),
('country_Uganda_219', 'state_Mpigi_3951'),
('country_Uganda_219', 'state_Mubende_3952'),
('country_Uganda_219', 'state_Mukono_3953'),
('country_Uganda_219', 'state_Nakasongola_3954'),
('country_Uganda_219', 'state_Rakai_3955'),
('country_Uganda_219', 'state_Sembabule_3956'),
('country_Uganda_219', 'state_Kayunga_3957'),
('country_Uganda_219', 'state_Wakiso_3958'),
('country_Uganda_219', 'state_Bugiri_3959'),
('country_Uganda_219', 'state_Busia_3960'),
('country_Uganda_219', 'state_Iganga_3961'),
('country_Uganda_219', 'state_Jinja_3962'),
('country_Uganda_219', 'state_Kamuli_3963'),
('country_Uganda_219', 'state_Kapchorwa_3964'),
('country_Uganda_219', 'state_Katakwi_3965'),
('country_Uganda_219', 'state_Kumi_3966'),
('country_Uganda_219', 'state_Mbale_3967'),
('country_Uganda_219', 'state_Pallisa_3968'),
('country_Uganda_219', 'state_Soroti_3969'),
('country_Uganda_219', 'state_Tororo_3970'),
('country_Uganda_219', 'state_Kaberamaido_3971'),
('country_Uganda_219', 'state_Mayuge_3972'),
('country_Uganda_219', 'state_Sironko_3973'),
('country_Uganda_219', 'state_Adjumani_3974'),
('country_Uganda_219', 'state_Apac_3975'),
('country_Uganda_219', 'state_Arua_3976'),
('country_Uganda_219', 'state_Gulu_3977'),
('country_Uganda_219', 'state_Kitgum_3978'),
('country_Uganda_219', 'state_Kotido_3979'),
('country_Uganda_219', 'state_Lira_3980'),
('country_Uganda_219', 'state_Moroto_3981'),
('country_Uganda_219', 'state_Moyo_3982'),
('country_Uganda_219', 'state_Nebbi_3983'),
('country_Uganda_219', 'state_Nakapiripirit_3984'),
('country_Uganda_219', 'state_Pader_3985'),
('country_Uganda_219', 'state_Yumbe_3986'),
('country_Uganda_219', 'state_Bundibugyo_3987'),
('country_Uganda_219', 'state_Bushenyi_3988'),
('country_Uganda_219', 'state_Hoima_3989'),
('country_Uganda_219', 'state_Kabale_3990'),
('country_Uganda_219', 'state_Kabarole_3991'),
('country_Uganda_219', 'state_Kasese_3992'),
('country_Uganda_219', 'state_Kibale_3993'),
('country_Uganda_219', 'state_Kisoro_3994'),
('country_Uganda_219', 'state_Masindi_3995'),
('country_Uganda_219', 'state_Mbarara_3996'),
('country_Uganda_219', 'state_Ntungamo_3997'),
('country_Uganda_219', 'state_Rukungiri_3998'),
('country_Uganda_219', 'state_Kamwenge_3999'),
('country_Uganda_219', 'state_Kanungu_4000'),
('country_Uganda_219', 'state_Kyenjojo_4001'),
('country_Ukraine_220',
'state___________________________________4002'),
('country_Ukraine_220',
'state___________________________________4003'),
('country_Ukraine_220',
'state___________________________________4004'),
('country_Ukraine_220',
'state_________________________________________________4005'),
('country_Ukraine_220',
'state_________________________________4006'),
('country_Ukraine_220',
'state_______________________________________4007'),
('country_Ukraine_220',
'state_____________________________________4008'),
('country_Ukraine_220',
'state_________________________________________4009'),
('country_Ukraine_220',
'state_____________________________________4010'),
('country_Ukraine_220',
'state__________________________________________________4011'),
('country_Ukraine_220', 'state__________4012'),
('country_Ukraine_220',
'state_________________________________4013'),
('country_Ukraine_220',
'state_____________________________________________4014'),
('country_Ukraine_220',
'state________________________4015'),
('country_Ukraine_220',
'state____________________________________________________4016'),
('country_Ukraine_220',
'state___________________________________4017'),
('country_Ukraine_220',
'state_________________________________________4018'),
('country_Ukraine_220',
'state_______________________________4019'),
('country_Ukraine_220',
'state_____________________________________4020'),
('country_Ukraine_220',
'state_______________________________4021'),
('country_Ukraine_220',
'state___________________________________________4022'),
('country_Ukraine_220',
'state_____________________________________4023'),
('country_Ukraine_220',
'state_____________________________________4024'),
('country_Ukraine_220',
'state_______________________________________4025'),
('country_Ukraine_220',
'state___________________________________4026'),
('country_Ukraine_220',
'state_________________________________________4027'),
('country_Ukraine_220',
'state_______________________________________4028'),
('country_United_Kingdom_222',
'state_Argyll_and_Bute_4031'),
('country_United_Kingdom_222',
'state_Bath_and_North_East_Somerset_4037'),
('country_United_Kingdom_222',
'state_Bedfordshire_4039'),
('country_United_Kingdom_222',
'state_Berkshire_4040'),
('country_United_Kingdom_222',
'state_Blaenau_Gwent_4045'),
('country_United_Kingdom_222', 'state_Borders_4055'),
('country_United_Kingdom_222', 'state_Bristol_4060'),
('country_United_Kingdom_222',
'state_Buckinghamshire_4061'),
('country_United_Kingdom_222',
'state_Cambridgeshire_4062'),
('country_United_Kingdom_222',
'state_Carmarthenshire_4074'),
('country_United_Kingdom_222',
'state_Ceredigion_4064'),
('country_United_Kingdom_222', 'state_Cheshire_4066'),
('country_United_Kingdom_222', 'state_Conwy_4080'),
('country_United_Kingdom_222', 'state_Cornwall_4075'),
('country_United_Kingdom_222', 'state_Antrim_4034'),
('country_United_Kingdom_222', 'state_Down_4091'),
('country_United_Kingdom_222', 'state_Durham_4094'),
('country_United_Kingdom_222',
'state_Fermanagh_4107'),
('country_United_Kingdom_222',
'state_Londonderry_4063'),
('country_United_Kingdom_222', 'state_Tyrone_4065'),
('country_United_Kingdom_222', 'state_Cumbria_4072'),
('country_United_Kingdom_222',
'state_Denbighshire_4083'),
('country_United_Kingdom_222',
'state_Derbyshire_4082'),
('country_United_Kingdom_222', 'state_Devon_4085'),
('country_United_Kingdom_222', 'state_Dorset_4090'),
('country_United_Kingdom_222',
'state_Dumbarton_4065'),
('country_United_Kingdom_222',
'state_Dumfries_and_Galloway_4087'),
('country_United_Kingdom_222', 'state_Dyfed_4093'),
('country_United_Kingdom_222',
'state_East_Ayrshire_4096'),
('country_United_Kingdom_222',
'state_East_Dunbartonshire_4098'),
('country_United_Kingdom_222',
'state_East_Renfrewshire_4102'),
('country_United_Kingdom_222',
'state_East_Riding_of_Yorkshire_4103'),
('country_United_Kingdom_222',
'state_East_Sussex_4105'),
('country_United_Kingdom_222',
'state_Edinburgh_4097'),
('country_United_Kingdom_222', 'state_Essex_4104'),
('country_United_Kingdom_222', 'state_Fife_4108'),
('country_United_Kingdom_222',
'state_Flintshire_4109'),
('country_United_Kingdom_222',
'state_Glamorgan_4068'),
('country_United_Kingdom_222', 'state_Glasgow_4111'),
('country_United_Kingdom_222',
'state_Gloucestershire_4112'),
('country_United_Kingdom_222', 'state_Grampian_4110'),
('country_United_Kingdom_222',
'state_Greater_Manchester_4113'),
('country_United_Kingdom_222', 'state_Gwent_4114'),
('country_United_Kingdom_222', 'state_Gwynedd_4115'),
('country_United_Kingdom_222',
'state_Hampshire_4117'),
('country_United_Kingdom_222',
'state_Herefordshire_4120'),
('country_United_Kingdom_222',
'state_Hertfordshire_4126'),
('country_United_Kingdom_222',
'state_Inverclyde_4132'),
('country_United_Kingdom_222',
'state_Isle_of_Wight_4130'),
('country_United_Kingdom_222', 'state_Kent_4135'),
('country_United_Kingdom_222',
'state_Lancashire_4140'),
('country_United_Kingdom_222',
'state_Leicestershire_4144'),
('country_United_Kingdom_222',
'state_Lincolnshire_4146'),
('country_United_Kingdom_222', 'state_London_4149'),
('country_United_Kingdom_222',
'state_Manchester_4153'),
('country_United_Kingdom_222',
'state_Middlesex_4069'),
('country_United_Kingdom_222',
'state_Merseyside_4070'),
('country_United_Kingdom_222', 'state_Norfolk_4169'),
('country_United_Kingdom_222',
'state_North_Ayrshire_4164'),
('country_United_Kingdom_222',
'state_North_Lanarkshire_4171'),
('country_United_Kingdom_222',
'state_North_West_Highlands_4071'),
('country_United_Kingdom_222',
'state_North_Yorkshire_4181'),
('country_United_Kingdom_222',
'state_Northamptonshire_4175'),
('country_United_Kingdom_222',
'state_Northumberland_4165'),
('country_United_Kingdom_222',
'state_Nottinghamshire_4177'),
('country_United_Kingdom_222',
'state_Oxfordshire_4186'),
('country_United_Kingdom_222',
'state_Pembrokeshire_4187'),
('country_United_Kingdom_222', 'state_Powys_4192'),
('country_United_Kingdom_222',
'state_Renfrewshire_4199'),
('country_United_Kingdom_222',
'state_Rhondda_Cynon_Taf_4196'),
('country_United_Kingdom_222',
'state_Shropshire_4211'),
('country_United_Kingdom_222', 'state_Somerset_4218'),
('country_United_Kingdom_222',
'state_South_Ayrshire_4204'),
('country_United_Kingdom_222',
'state_South_Gloucestershire_4208'),
('country_United_Kingdom_222',
'state_South_Lanarkshire_4215'),
('country_United_Kingdom_222',
'state_South_Yorkshire_4228'),
('country_United_Kingdom_222',
'state_Staffordshire_4226'),
('country_United_Kingdom_222', 'state_Suffolk_4206'),
('country_United_Kingdom_222', 'state_Surrey_4220'),
('country_United_Kingdom_222', 'state_Tayside_4235'),
('country_United_Kingdom_222', 'state_Torfaen_4236'),
('country_United_Kingdom_222',
'state_Tyne_and_Wear_4237'),
('country_United_Kingdom_222',
'state_Warwickshire_4240'),
('country_United_Kingdom_222',
'state_West_Lothian_4248'),
('country_United_Kingdom_222',
'state_West_Midlands_4073'),
('country_United_Kingdom_222',
'state_West_Sussex_4257'),
('country_United_Kingdom_222',
'state_West_Yorkshire_4076'),
('country_United_Kingdom_222',
'state_Wiltshire_4245'),
('country_United_Kingdom_222',
'state_Worcestershire_4252'),
('country_United_Kingdom_222',
'state_Aberdeenshire_4554'),
('country_United_Kingdom_222', 'state_Anglesey_4555'),
('country_United_Kingdom_222', 'state_Angus_4506'),
('country_United_Kingdom_222',
'state_Argyllshire_4507'),
('country_United_Kingdom_222', 'state_Ayrshire_4508'),
('country_United_Kingdom_222',
'state_Banffshire_4509'),
('country_United_Kingdom_222',
'state_Berwickshire_4510'),
('country_United_Kingdom_222',
'state_Brecknockshire_4511'),
('country_United_Kingdom_222',
'state_Buteshire_4512'),
('country_United_Kingdom_222',
'state_Caernarfonshire_4513'),
('country_United_Kingdom_222',
'state_Caithness_4514'),
('country_United_Kingdom_222',
'state_Cardiganshire_4515'),
('country_United_Kingdom_222',
'state_Channel_Isles_4516'),
('country_United_Kingdom_222',
'state_Clackmannanshire_4517'),
('country_United_Kingdom_222',
'state_County_Armagh_4518'),
('country_United_Kingdom_222',
'state_Cumberland_4519'),
('country_United_Kingdom_222',
'state_Dumfriesshire_4520'),
('country_United_Kingdom_222',
'state_Dunbartonshire_4521'),
('country_United_Kingdom_222',
'state_East_Lothian_4522'),
('country_United_Kingdom_222',
'state_Huntingdonshire_4523'),
('country_United_Kingdom_222',
'state_Inverness-shire_4524'),
('country_United_Kingdom_222', 'state_Isle_
of_Islay_4525'),
('country_United_Kingdom_222',
'state_Isle_of_Lewis_4526'),
('country_United_Kingdom_222',
'state_Isle_of_Man_4527'),
('country_United_Kingdom_222',
'state_Isle_of_Skye_4528'),
('country_United_Kingdom_222',
'state_Isles_of_Scilly_4529'),
('country_United_Kingdom_222',
'state_Kincardineshire_4530'),
('country_United_Kingdom_222',
'state_Kinross-Shire_4531'),
('country_United_Kingdom_222',
'state_Kirkcudbrightshire_4532'),
('country_United_Kingdom_222',
'state_Lanarkshire_4533'),
('country_United_Kingdom_222',
'state_Merioneth_4534'),
('country_United_Kingdom_222',
'state_Midlothian_4535'),
('country_United_Kingdom_222',
'state_Monmouthshire_4536'),
('country_United_Kingdom_222',
'state_Montgomeryshire_4537'),
('country_United_Kingdom_222',
'state_Morayshire_4538'),
('country_United_Kingdom_222',
'state_Nairnshire_4539'),
('country_United_Kingdom_222', 'state_Orkney_4540'),
('country_United_Kingdom_222',
'state_Peeblesshire_4541'),
('country_United_Kingdom_222',
'state_Perthshire_4542'),
('country_United_Kingdom_222',
'state_Radnorshire_4543'),
('country_United_Kingdom_222',
'state_Ross-shire_4544'),
('country_United_Kingdom_222',
'state_Roxburghshire_4545'),
('country_United_Kingdom_222', 'state_Rutland_4546'),
('country_United_Kingdom_222',
'state_Selkirkshire_4547'),
('country_United_Kingdom_222', 'state_Shetland_4548'),
('country_United_Kingdom_222',
'state_Stirlingshire_4549'),
('country_United_Kingdom_222', 'state_Sussex_4550'),
('country_United_Kingdom_222',
'state_Sutherland_4551'),
('country_United_Kingdom_222',
'state_Westmorland_4552'),
('country_United_Kingdom_222',
'state_Wigtownshire_4553')";
$this->db->setQuery($query);
$this->db->query();
$query="INSERT IGNORE INTO `#__hikashop_zone_link`
(`zone_parent_namekey`, `zone_child_namekey`) VALUES
('country_United_States_of_America_223',
'state_Alaska_4260'),
('country_United_States_of_America_223',
'state_Alabama_4261'),
('country_United_States_of_America_223',
'state_American_Samoa_4262'),
('country_United_States_of_America_223',
'state_Arkansas_4263'),
('country_United_States_of_America_223',
'state_Arizona_4264'),
('country_United_States_of_America_223',
'state_California_4265'),
('country_United_States_of_America_223',
'state_Colorado_4266'),
('country_United_States_of_America_223',
'state_Connecticut_4267'),
('country_United_States_of_America_223',
'state_District_of_Columbia_4268'),
('country_United_States_of_America_223',
'state_Delaware_4269'),
('country_United_States_of_America_223',
'state_Florida_4270'),
('country_United_States_of_America_223',
'state_Georgia_4271'),
('country_United_States_of_America_223',
'state_Guam_4272'),
('country_United_States_of_America_223',
'state_Hawaii_4273'),
('country_United_States_of_America_223',
'state_Iowa_4274'),
('country_United_States_of_America_223',
'state_Idaho_4275'),
('country_United_States_of_America_223',
'state_Illinois_4276'),
('country_United_States_of_America_223',
'state_Indiana_4277'),
('country_United_States_of_America_223',
'state_Kansas_4278'),
('country_United_States_of_America_223',
'state_Kentucky_4279'),
('country_United_States_of_America_223',
'state_Louisiana_4280'),
('country_United_States_of_America_223',
'state_Massachusetts_4281'),
('country_United_States_of_America_223',
'state_Maryland_4282'),
('country_United_States_of_America_223',
'state_Maine_4283'),
('country_United_States_of_America_223',
'state_Michigan_4284'),
('country_United_States_of_America_223',
'state_Minnesota_4285'),
('country_United_States_of_America_223',
'state_Missouri_4286'),
('country_United_States_of_America_223',
'state_Mississippi_4287'),
('country_United_States_of_America_223',
'state_Montana_4288'),
('country_United_States_of_America_223',
'state_North_Carolina_4289'),
('country_United_States_of_America_223',
'state_North_Dakota_4290'),
('country_United_States_of_America_223',
'state_Nebraska_4291'),
('country_United_States_of_America_223',
'state_New_Hampshire_4292'),
('country_United_States_of_America_223',
'state_New_Jersey_4293'),
('country_United_States_of_America_223',
'state_New_Mexico_4294'),
('country_United_States_of_America_223',
'state_Nevada_4295'),
('country_United_States_of_America_223',
'state_New_York_4296'),
('country_United_States_of_America_223',
'state_Northern_Mariana_Islands_4297'),
('country_United_States_of_America_223',
'state_Ohio_4298'),
('country_United_States_of_America_223',
'state_Oklahoma_4299'),
('country_United_States_of_America_223',
'state_Oregon_4300'),
('country_United_States_of_America_223',
'state_Pennsylvania_4301'),
('country_United_States_of_America_223',
'state_Puerto_Rico_4302'),
('country_United_States_of_America_223',
'state_Rhode_Island_4303'),
('country_United_States_of_America_223',
'state_South_Carolina_4304'),
('country_United_States_of_America_223',
'state_South_Dakota_4305'),
('country_United_States_of_America_223',
'state_Tennessee_4306'),
('country_United_States_of_America_223',
'state_Texas_4307'),
('country_United_States_of_America_223',
'state_U_S__Minor_Outlying_Islands_4308'),
('country_United_States_of_America_223',
'state_Utah_4309'),
('country_United_States_of_America_223',
'state_Virginia_4310'),
('country_United_States_of_America_223',
'state_Virgin_Islands_of_the_U_S__4311'),
('country_United_States_of_America_223',
'state_Vermont_4312'),
('country_United_States_of_America_223',
'state_Washington_4313'),
('country_United_States_of_America_223',
'state_Wisconsin_4314'),
('country_United_States_of_America_223',
'state_West_Virginia_4315'),
('country_United_States_of_America_223',
'state_Wyoming_4316'),
('country_United_States_Minor_Outlying_Islands_224',
'state_Baker_Island_4317'),
('country_United_States_Minor_Outlying_Islands_224',
'state_Howland_Island_4318'),
('country_United_States_Minor_Outlying_Islands_224',
'state_Jarvis_Island_4319'),
('country_United_States_Minor_Outlying_Islands_224',
'state_Johnston_Atoll_4320'),
('country_United_States_Minor_Outlying_Islands_224',
'state_Kingman_Reef_4321'),
('country_United_States_Minor_Outlying_Islands_224',
'state_Midway_Atoll_4322'),
('country_United_States_Minor_Outlying_Islands_224',
'state_Navassa_Island_4323'),
('country_United_States_Minor_Outlying_Islands_224',
'state_Palmyra_Atoll_4324'),
('country_United_States_Minor_Outlying_Islands_224',
'state_Wake_Island_4325'),
('country_Uruguay_225', 'state_Artigas_4326'),
('country_Uruguay_225', 'state_Canelones_4327'),
('country_Uruguay_225', 'state_Cerro_Largo_4328'),
('country_Uruguay_225', 'state_Colonia_4329'),
('country_Uruguay_225', 'state_Durazno_4330'),
('country_Uruguay_225', 'state_Florida_4331'),
('country_Uruguay_225', 'state_Flores_4332'),
('country_Uruguay_225', 'state_Lavalleja_4333'),
('country_Uruguay_225', 'state_Maldonado_4334'),
('country_Uruguay_225', 'state_Montevideo_4335'),
('country_Uruguay_225', 'state_Paysandu_4336'),
('country_Uruguay_225', 'state_R__o_Negro_4337'),
('country_Uruguay_225', 'state_Rocha_4338'),
('country_Uruguay_225', 'state_Rivera_4339'),
('country_Uruguay_225', 'state_Salto_4340'),
('country_Uruguay_225', 'state_Soriano_4342'),
('country_Uruguay_225', 'state_Tacuaremb___4343'),
('country_Uruguay_225', 'state_Treinta_y_Tres_4344'),
('country_Uzbekistan_226',
'state_Andijon_viloyati_4345'),
('country_Uzbekistan_226',
'state_Buxoro_viloyati_4346'),
('country_Uzbekistan_226',
'state_Farg_ona_viloyati_4347'),
('country_Uzbekistan_226',
'state_Jizzax_viloyati_4348'),
('country_Uzbekistan_226',
'state_Namangan_viloyati_4349'),
('country_Uzbekistan_226',
'state_Navoiy_viloyati_4350'),
('country_Uzbekistan_226',
'state_Qashqadaryo_viloyati_4351'),
('country_Uzbekistan_226',
'state_Qoraqalpog_iston_Respublikasi_4352'),
('country_Uzbekistan_226',
'state_Samarqand_viloyati_4353'),
('country_Uzbekistan_226',
'state_Sirdaryo_viloyati_4354'),
('country_Uzbekistan_226',
'state_Surxondaryo_viloyati_4355'),
('country_Uzbekistan_226', 'state_Toshkent_4356'),
('country_Uzbekistan_226',
'state_Toshkent_viloyati_4357'),
('country_Uzbekistan_226',
'state_Xorazm_viloyati_4358'),
('country_Vanuatu_227', 'state_Malampa_4359'),
('country_Vanuatu_227', 'state_P__nama_4360'),
('country_Vanuatu_227', 'state_Sanma_4361'),
('country_Vanuatu_227', 'state_Sh__fa_4362'),
('country_Vanuatu_227', 'state_Taf__a_4363'),
('country_Vanuatu_227', 'state_Torba_4364'),
('country_Venezuela_229',
'state_Distrito_Capital_4365'),
('country_Venezuela_229', 'state_Anzo__tegui_4366'),
('country_Venezuela_229', 'state_Apure_4367'),
('country_Venezuela_229', 'state_Aragua_4368'),
('country_Venezuela_229', 'state_Barinas_4369'),
('country_Venezuela_229', 'state_Bol__var_4370'),
('country_Venezuela_229', 'state_Carabobo_4371'),
('country_Venezuela_229', 'state_Cojedes_4372'),
('country_Venezuela_229', 'state_Falc__n_4373'),
('country_Venezuela_229', 'state_Gu__rico_4374'),
('country_Venezuela_229', 'state_Lara_4375'),
('country_Venezuela_229', 'state_M__rida_4376'),
('country_Venezuela_229', 'state_Miranda_4377'),
('country_Venezuela_229', 'state_Monagas_4378'),
('country_Venezuela_229', 'state_Nueva_Esparta_4379'),
('country_Venezuela_229', 'state_Portuguesa_4380'),
('country_Venezuela_229', 'state_Sucre_4381'),
('country_Venezuela_229', 'state_Tachira_4382'),
('country_Venezuela_229', 'state_Trujillo_4383'),
('country_Venezuela_229', 'state_Yaracuy_4384'),
('country_Venezuela_229', 'state_Zulia_4385'),
('country_Venezuela_229',
'state_Capital_Dependencia_4386'),
('country_Venezuela_229', 'state_Vargas_4387'),
('country_Venezuela_229', 'state_Delta_Amacuro_4388'),
('country_Venezuela_229', 'state_Amazonas_4389'),
('country_Vietnam_230', 'state_Lai_Ch__u_4390'),
('country_Vietnam_230', 'state_L__o_Cai_4391'),
('country_Vietnam_230', 'state_H___Giang_4392'),
('country_Vietnam_230', 'state_Cao_B___ng_4393'),
('country_Vietnam_230', 'state_S__n_La_4394'),
('country_Vietnam_230', 'state_Y__n_B__i_4395'),
('country_Vietnam_230', 'state_Tuy__n_Quang_4396'),
('country_Vietnam_230', 'state_L___ng_S__n_4397'),
('country_Vietnam_230', 'state_Qu___ng_Ninh_4398'),
('country_Vietnam_230', 'state_H__a_B__nh_4399'),
('country_Vietnam_230', 'state_H___T__y_4400'),
('country_Vietnam_230', 'state_Ninh_B__nh_4401'),
('country_Vietnam_230', 'state_Th__i_B__nh_4402'),
('country_Vietnam_230', 'state_Thanh_H__a_4403'),
('country_Vietnam_230', 'state_Ngh____An_4404'),
('country_Vietnam_230', 'state_H___T__nh_4405'),
('country_Vietnam_230', 'state_Qu___ng_B__nh_4406'),
('country_Vietnam_230', 'state_Qu___ng_Tr____4407'),
('country_Vietnam_230',
'state_Th___a_Thi__n_Hu____4408'),
('country_Vietnam_230', 'state_Qu___ng_Nam_4409'),
('country_Vietnam_230', 'state_Kon_Tum_4410'),
('country_Vietnam_230', 'state_Qu___ng_Ng__i_4411'),
('country_Vietnam_230', 'state_Gia_Lai_4412'),
('country_Vietnam_230', 'state_B__nh______nh_4413'),
('country_Vietnam_230', 'state_Ph___Y__n_4414'),
('country_Vietnam_230', 'state______k_L___k_4415'),
('country_Vietnam_230', 'state_Kh__nh_H__a_4416'),
('country_Vietnam_230', 'state_L__m______ng_4417'),
('country_Vietnam_230', 'state_Ninh_Thu___n_4418'),
('country_Vietnam_230', 'state_T__y_Ninh_4419'),
('country_Vietnam_230', 'state______ng_Nai_4420'),
('country_Vietnam_230', 'state_B__nh_Thu___n_4421'),
('country_Vietnam_230', 'state_Long_An_4422'),
('country_Vietnam_230',
'state_B___R___a_V__ng_T__u_4423'),
('country_Vietnam_230', 'state_An_Giang_4424'),
('country_Vietnam_230', 'state______ng_Th__p_4425'),
('country_Vietnam_230', 'state_Ti___n_Giang_4426'),
('country_Vietnam_230', 'state_Ki__n_Giang_4427'),
('country_Vietnam_230', 'state_C___n_Th___4428'),
('country_Vietnam_230', 'state_V__nh_Long_4429'),
('country_Vietnam_230', 'state_B___n_Tre_4430'),
('country_Vietnam_230', 'state_Tr___Vinh_4431'),
('country_Vietnam_230', 'state_S__c_Tr__ng_4432'),
('country_Vietnam_230', 'state_B___c_K___n_4433'),
('country_Vietnam_230', 'state_B___c_Giang_4434'),
('country_Vietnam_230', 'state_B___c_Li__u_4435'),
('country_Vietnam_230', 'state_B___c_Ninh_4436'),
('country_Vietnam_230', 'state_B__nh_D____ng_4437'),
('country_Vietnam_230', 'state_B__nh_Ph_____c_4438'),
('country_Vietnam_230', 'state_C___Mau_4439'),
('country_Vietnam_230', 'state______N___ng_4440'),
('country_Vietnam_230', 'state_H___i_D____ng_4441'),
('country_Vietnam_230', 'state_H___i_Ph__ng_4442'),
('country_Vietnam_230', 'state_H___Nam_4443'),
('country_Vietnam_230', 'state_H___N___i_4444'),
('country_Vietnam_230', 'state_S__i_G__n_4445'),
('country_Vietnam_230', 'state_H__ng_Y__n_4446'),
('country_Vietnam_230', 'state_Nam______nh_4447'),
('country_Vietnam_230', 'state_Ph___Th____4448'),
('country_Vietnam_230', 'state_Th__i_Nguy__n_4449'),
('country_Vietnam_230', 'state_V__nh_Ph__c_4450'),
('country_Vietnam_230', 'state___i___n_Bi__n_4451'),
('country_Vietnam_230', 'state______k_N__ng_4452'),
('country_Vietnam_230', 'state_H___u_Giang_4453'),
('country_Virgin_Islands__U_S___232',
'state_Saint_Croix_4454'),
('country_Wallis_and_Futuna_Islands_233',
'state_Alo_4457'),
('country_Wallis_and_Futuna_Islands_233',
'state_Sigave_4458'),
('country_Wallis_and_Futuna_Islands_233',
'state_Wallis_4459'),
('country_Yemen_235', 'state_____________4460'),
('country_Yemen_235', 'state________4461'),
('country_Yemen_235', 'state____________4462'),
('country_Yemen_235', 'state________________4463'),
('country_Yemen_235', 'state______________4464'),
('country_Yemen_235', 'state__________4465'),
('country_Yemen_235', 'state______________4466'),
('country_Yemen_235', 'state________4467'),
('country_Yemen_235', 'state________________4468'),
('country_Yemen_235', 'state______4469'),
('country_Yemen_235', 'state____________4470'),
('country_Yemen_235', 'state________4471'),
('country_Yemen_235', 'state__________4472'),
('country_Yemen_235', 'state______________4473'),
('country_Yemen_235', 'state________________4474'),
('country_Yemen_235', 'state__________4475'),
('country_Yemen_235', 'state____________4476'),
('country_Yemen_235', 'state__________4477'),
('country_Yemen_235', 'state________4478'),
('country_Zambia_238', 'state_Western_4479'),
('country_Zambia_238', 'state_Central_4480'),
('country_Zambia_238', 'state_Eastern_4481'),
('country_Zambia_238', 'state_Luapula_4482'),
('country_Zambia_238', 'state_Northern_4483'),
('country_Zambia_238', 'state_North_Western_4484'),
('country_Zambia_238', 'state_Southern_4485'),
('country_Zambia_238', 'state_Copperbelt_4486'),
('country_Zambia_238', 'state_Lusaka_4487'),
('country_Zimbabwe_239', 'state_Manicaland_4488'),
('country_Zimbabwe_239',
'state_Mashonaland_Central_4489'),
('country_Zimbabwe_239',
'state_Mashonaland_East_4490'),
('country_Zimbabwe_239', 'state_Midlands_4491'),
('country_Zimbabwe_239',
'state_Matabeleland_North_4492'),
('country_Zimbabwe_239',
'state_Matabeleland_South_4493'),
('country_Zimbabwe_239', 'state_Masvingo_4494'),
('country_Zimbabwe_239',
'state_Mashonaland_West_4495'),
('country_Afghanistan_', '1977'),
('country_Afghanistan_', '1978'),
('country_Japan_107', 'state___________1977'),
('tax_europe_9728', 'country_Germany_81'),
('tax_europe_9728', 'country_Austria_14'),
('tax_europe_9728', 'country_Belgium_21'),
('tax_europe_9728', 'country_Bulgaria_33'),
('tax_europe_9728', 'country_Croatia_53'),
('tax_europe_9728', 'country_Cyprus_55'),
('tax_europe_9728', 'country_Denmark_57'),
('tax_europe_9728', 'country_Spain_195'),
('tax_europe_9728', 'country_Estonia_67'),
('tax_europe_9728', 'country_Finland_72'),
('tax_europe_9728', 'country_France_73'),
('tax_europe_9728',
'country_France__Metropolitan_74'),
('tax_europe_9728', 'country_United_Kingdom_222'),
('tax_europe_9728', 'country_Greece_84'),
('tax_europe_9728', 'country_Hungary_97'),
('tax_europe_9728', 'country_Ireland_103'),
('tax_europe_9728', 'country_Italy_105'),
('tax_europe_9728', 'country_Latvia_117'),
('tax_europe_9728', 'country_Lithuania_123'),
('tax_europe_9728', 'country_Luxembourg_124'),
('tax_europe_9728', 'country_Malta_132'),
('tax_europe_9728', 'country_Netherlands_150'),
('tax_europe_9728', 'country_Poland_170'),
('tax_europe_9728', 'country_Portugal_171'),
('tax_europe_9728', 'country_Czech_Republic_56'),
('tax_europe_9728', 'country_Romania_175'),
('tax_europe_9728', 'country_Slovakia_189'),
('tax_europe_9728', 'country_Slovenia_190'),
('tax_europe_9728', 'country_Sweden_203');";
$this->db->setQuery($query);
$this->db->query();
}
}
upload.php000064400000027342151162557620006563 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopUploadHelper {
protected $options;
protected $imagesExt = array('jpg', 'jpeg',
'gif', 'png');
public function __construct() {
$this->setOptions();
}
public function setOptions($options = null) {
$this->options = array(
'upload_dir' => HIKASHOP_MEDIA.'upload'.DS,
'upload_url' =>
JURI::base(true).'/media/'.HIKASHOP_COMPONENT.'/upload/',
'param_name' => 'files',
'delete_type' => 'DELETE',
'max_file_size' => null,
'min_file_size' => 1,
'accept_file_types' => '/.+$/i',
'max_number_of_files' => null,
'max_width' => null,
'max_height' => null,
'min_width' => 1,
'min_height' => 1,
'discard_aborted_uploads' => true,
'orient_image' => false,
'image_versions' => array()
);
if(!empty($options)) {
foreach($options as $k => $v) {
if(!is_array($v) || empty($this->options[$k])) {
$this->options[$k] = $v;
} else {
foreach($v as $kV => $vV) {
$this->options[$k][$kV] = $vV;
}
}
}
}
}
public function process($options = null) {
if(!empty($options)) {
$this->setOptions($options);
}
header('Pragma: no-cache');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Content-Disposition: inline;
filename="files.json"');
header('X-Content-Type-Options: nosniff');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header('Access-Control-Allow-Headers: X-File-Name, X-File-Type,
X-File-Size');
switch($_SERVER['REQUEST_METHOD']) {
case 'OPTIONS':
break;
case 'HEAD':
case 'GET':
return $this->get();
break;
case 'POST':
return $this->post($options);
default:
header('HTTP/1.1 405 Method Not Allowed');
}
return false;
}
public function processFallback($options = null) {
JRequest::checkToken() || die('Invalid Token');
if(!empty($options)) {
$this->setOptions($options);
}
$upload = isset($_FILES[$this->options['param_name']]) ?
$_FILES[$this->options['param_name']] : reset($_FILES);
$info = array();
if($upload && is_array($upload['tmp_name'])) {
foreach ($upload['tmp_name'] as $index => $value) {
$info[] = $this->handle_file_upload(
$upload['tmp_name'][$index],
isset($_SERVER['HTTP_X_FILE_NAME']) ?
$_SERVER['HTTP_X_FILE_NAME'] :
$upload['name'][$index],
isset($_SERVER['HTTP_X_FILE_SIZE']) ?
$_SERVER['HTTP_X_FILE_SIZE'] :
$upload['size'][$index],
isset($_SERVER['HTTP_X_FILE_TYPE']) ?
$_SERVER['HTTP_X_FILE_TYPE'] :
$upload['type'][$index],
$upload['error'][$index],
$options,
$index
);
}
} else if($upload || isset($_SERVER['HTTP_X_FILE_NAME'])) {
$info[] = $this->handle_file_upload(
isset($upload['tmp_name']) ? $upload['tmp_name'] :
null,
isset($_SERVER['HTTP_X_FILE_NAME']) ?
$_SERVER['HTTP_X_FILE_NAME'] : (isset($upload['name'])
? $upload['name'] : null),
isset($_SERVER['HTTP_X_FILE_SIZE']) ?
$_SERVER['HTTP_X_FILE_SIZE'] : (isset($upload['size'])
? $upload['size'] : null),
isset($_SERVER['HTTP_X_FILE_TYPE']) ?
$_SERVER['HTTP_X_FILE_TYPE'] : (isset($upload['type'])
? $upload['type'] : null),
isset($upload['error']) ? $upload['error'] : null,
$options
);
}
return $info;
}
protected function get_file_object($file_name) {
$file_path = $this->options['upload_dir'].$file_name;
if (is_file($file_path) && $file_name[0] !== '.') {
$file = new stdClass();
$file->name = $file_name;
$file->path = $file_path;
$file->size = filesize($file_path);
$file->url =
$this->options['upload_url'].rawurlencode($file->name);
return $file;
}
return null;
}
protected function get_file_objects() {
if(!is_dir($this->options['upload_dir']))
return array();
return array_values( array_filter( array_map( array($this,
'get_file_object'),
scandir($this->options['upload_dir']) ) ) );
}
protected function validate($uploaded_file, $file, $error, $index) {
if($error) {
$file->error = $error;
return false;
}
if(!$file->name) {
$file->error = 'missingFileName';
return false;
}
if(!preg_match($this->options['accept_file_types'],
$file->name)) {
$file->error = 'acceptFileTypes';
return false;
}
if($uploaded_file && is_uploaded_file($uploaded_file)) {
$file_size = filesize($uploaded_file);
} else {
$file_size = $_SERVER['CONTENT_LENGTH'];
}
if($this->options['max_file_size'] && ( $file_size
> $this->options['max_file_size'] || $file->size >
$this->options['max_file_size']) ) {
$file->error = 'maxFileSize';
return false;
}
if($this->options['min_file_size'] && $file_size
< $this->options['min_file_size']) {
$file->error = 'minFileSize';
return false;
}
if(is_int($this->options['max_number_of_files']) &&
( count($this->get_file_objects()) >=
$this->options['max_number_of_files']) ) {
$file->error = 'maxNumberOfFiles';
return false;
}
list($img_width, $img_height) = @getimagesize($uploaded_file);
if(is_int($img_width)) {
if($this->options['max_width'] && $img_width >
$this->options['max_width'] ||
$this->options['max_height'] && $img_height >
$this->options['max_height']) {
$file->error = 'maxResolution';
return false;
}
if($this->options['min_width'] && $img_width <
$this->options['min_width'] ||
$this->options['min_height'] && $img_height <
$this->options['min_height']) {
$file->error = 'minResolution';
return false;
}
}
return true;
}
protected function upcount_name_callback($matches) {
$index = isset($matches[1]) ? intval($matches[1]) + 1 : 1;
$ext = isset($matches[2]) ? $matches[2] : '';
return ' ('.$index.')'.$ext;
}
protected function upcount_name($name) {
return preg_replace_callback(
'/(?:(?: \(([\d]+)\))?(\.[^.]+))?$/',
array($this, 'upcount_name_callback'),
$name,
1
);
}
protected function trim_file_name($name, $type, $index) {
$file_name = trim(basename(stripslashes($name)),
".\x00..\x20");
if(strpos($file_name, '.') === false &&
preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) {
$file_name .= '.'.$matches[1];
}
if($this->options['discard_aborted_uploads']) {
while(is_file($this->options['upload_dir'].$file_name)) {
$file_name = $this->upcount_name($file_name);
}
}
return $file_name;
}
protected function orient_image($file_path) {
$exif = @exif_read_data($file_path);
if($exif === false)
return false;
$orientation = intval(@$exif['Orientation']);
if(!in_array($orientation, array(3, 6, 8)))
return false;
$image = @imagecreatefromjpeg($file_path);
switch ($orientation) {
case 3:
$image = @imagerotate($image, 180, 0);
break;
case 6:
$image = @imagerotate($image, 270, 0);
break;
case 8:
$image = @imagerotate($image, 90, 0);
break;
default:
return false;
}
$success = imagejpeg($image, $file_path);
@imagedestroy($image);
return $success;
}
protected function handle_file_upload($uploaded_file, $name, $size, $type,
$error, $options, $index = null) {
$file = new stdClass();
$file->name = $this->trim_file_name($name, $type, $index);
$file->size = intval($size);
$file->type = $type;
if(empty($this->options['sub_folder']))
$this->options['sub_folder'] = '';
if($this->validate($uploaded_file, $file, $error, $index)) {
$shopConfig = hikashop_config();
if($options['type'] == 'file') {
$allowed = $shopConfig->get('allowedfiles');
} else {
$allowed = $shopConfig->get('allowedimages');
}
$file_path = strtolower(JFile::makeSafe($name));
if(!preg_match('#\.('.str_replace(array(',','.'),
array('|','\.'), $allowed).')$#Ui',
$file_path,$extension) ||
preg_match('#\.(php.?|.?htm.?|pl|py|jsp|asp|sh|cgi)$#Ui',
$file_path)) {
$file->error = JText::sprintf('ACCEPTED_TYPE',
substr($file_path,strrpos($file_path, '.') + 1), $allowed);
return $file;
}
$file_path = str_replace(array('.',' '),
'_', substr($file_path, 0, strpos($file_path,$extension[0]))) .
$extension[0];
if(JFile::exists($this->options['upload_dir'] .
$this->options['sub_folder'] . $file_path)) {
$pos = strrpos($file_path,'.');
$file_path =
substr($file_path,0,$pos).'_'.rand().'.'.substr($file_path,$pos+1);
}
if(!JFile::upload($uploaded_file,
$this->options['upload_dir'] .
$this->options['sub_folder'] . $file_path)) {
if(!move_uploaded_file($uploaded_file,
$this->options['upload_dir'] .
$this->options['sub_folder'] . $file_path)) {
$file->error =
JText::sprintf('FAIL_UPLOAD',$uploaded_file,$this->options['upload_dir']
. $this->options['sub_folder'] . $file_path);
return $file;
}
}
$file_size = filesize($this->options['upload_dir'] .
$this->options['sub_folder'] . $file_path);
$file->name = $file_path;
$file->path = $this->options['upload_dir'] .
$this->options['sub_folder'] . $file_path;
$file->url =
$this->options['upload_url'].$this->options['sub_folder'].rawurlencode($file->name);
if(strpos($file->name, '.') !== false) {
$ext = strtolower(substr($file->name, strrpos($file->name,
'.') + 1));
if(!in_array($ext, $this->imagesExt)) {
if ($this->options['orient_image']) {
$this->orient_image($this->options['upload_dir']
.$this->options['sub_folder']. $file_path);
}
}
}
}
return $file;
}
private function get() {
$file_name = isset($_REQUEST['file']) ?
basename(stripslashes($_REQUEST['file'])) : null;
if($file_name) {
$info = $this->get_file_object($file_name);
} else {
$info = $this->get_file_objects();
}
header('Content-type: application/json');
return $info;
}
private function post($options) {
$upload = isset($_FILES[$this->options['param_name']]) ?
$_FILES[$this->options['param_name']] : reset($_FILES);
$info = array();
if($upload && is_array($upload['tmp_name'])) {
foreach ($upload['tmp_name'] as $index => $value) {
$info[] = $this->handle_file_upload(
$upload['tmp_name'][$index],
isset($_SERVER['HTTP_X_FILE_NAME']) ?
$_SERVER['HTTP_X_FILE_NAME'] :
$upload['name'][$index],
isset($_SERVER['HTTP_X_FILE_SIZE']) ?
$_SERVER['HTTP_X_FILE_SIZE'] :
$upload['size'][$index],
isset($_SERVER['HTTP_X_FILE_TYPE']) ?
$_SERVER['HTTP_X_FILE_TYPE'] :
$upload['type'][$index],
$upload['error'][$index],
$options,
$index
);
}
} else if($upload || isset($_SERVER['HTTP_X_FILE_NAME'])) {
$info[] = $this->handle_file_upload(
isset($upload['tmp_name']) ? $upload['tmp_name'] :
null,
isset($_SERVER['HTTP_X_FILE_NAME']) ?
$_SERVER['HTTP_X_FILE_NAME'] : (isset($upload['name'])
? $upload['name'] : null),
isset($_SERVER['HTTP_X_FILE_SIZE']) ?
$_SERVER['HTTP_X_FILE_SIZE'] : (isset($upload['size'])
? $upload['size'] : null),
isset($_SERVER['HTTP_X_FILE_TYPE']) ?
$_SERVER['HTTP_X_FILE_TYPE'] : (isset($upload['type'])
? $upload['type'] : null),
isset($upload['error']) ? $upload['error'] : null,
$options
);
}
header('Vary: Accept');
$redirect = isset($_REQUEST['redirect']) ?
stripslashes($_REQUEST['redirect']) : null;
if($redirect) {
$json = json_encode($info);
header('Location: '.sprintf($redirect, rawurlencode($json)));
return;
}
if(isset($_SERVER['HTTP_ACCEPT']) &&
(strpos($_SERVER['HTTP_ACCEPT'], 'application/json')
!== false)) {
header('Content-type: application/json');
} else {
header('Content-type: text/plain');
}
return $info;
}
}
vat.php000064400000014055151162557620006066 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopVatHelper{
function isValid(&$vat){
$class = hikashop_get('class.zone');
$zone = $class->get(@$vat->address_country);
if(empty($zone->zone_code_2) ||
!in_array($zone->zone_code_2,array('AT','BE','BG','CY','CZ','DK','EE','EL','DE','PT','GR','ES','FI','HU','LU','MT','SI',
'FR','GB','IE','IT','LV','LT','NL','PL','SK','RO','SE','HR'))){
return true;
}
static $vat_check = null;
if(!isset($vat_check)){
$config = hikashop_config();
$vat_check = (int)$config->get('vat_check',2);
}
if($zone->zone_code_2 == 'GR') $zone->zone_code_2 =
'EL';
switch($vat_check){
case 1:
case 2:
if(is_object($vat)){
$vat_number =& $vat->address_vat;
}else{
$vat_number =& $vat;
}
$regex = $this->getRegex($vat_number);
if($regex===false){
if(is_object($vat) && !empty($vat->address_country)){
if(!empty($zone->zone_code_2)){
$vat_number = $zone->zone_code_2.$vat_number;
$regex = $this->getRegex($vat_number);
}
}
if($regex===false){
$app = JFactory::getApplication();
$this->message = JText::_('VAT_NOT_FOR_YOUR_COUNTRY');
if($_REQUEST['tmpl']=='component'){
hikashop_display($this->message,'error');
}else{
$app->enqueueMessage($this->message);
}
return false;
}
}
if(!$this->regexCheck($vat_number,$regex)){
return false;
}
$vat_number = strtoupper(str_replace(array('
','.','-'),array('','',''),$vat_number));
$code = substr($vat_number,0, 2);
if($code == 'GR'){
$code = 'EL';
$vat_number = $code.substr($vat_number,2);
}
if($zone->zone_code_2 != $code){
$app = JFactory::getApplication();
$this->message = 'Your VAT number can not be used with the
country you selected. Please select the right country ( CODE:
'.$code.') or make sure your VAT starts with
'.$zone->zone_code_2;
if($_REQUEST['tmpl']=='component'){
hikashop_display($this->message,'error');
}else{
$app->enqueueMessage($this->message);
}
return false;
}
if($vat_check==2){
return $this->onlineCheck($vat_number);
}
case 0:
default:
}
return true;
}
function regexCheck( $vat , $regex) {
if(!preg_match($regex, str_replace(array('
','.','-'),array('','',''),$vat))){
$app = JFactory::getApplication();
$this->message = JText::_('VAT_NUMBER_NOT_VALID');
if(@$_REQUEST['tmpl']=='component'){
hikashop_display($this->message,'error');
}else{
$app->enqueueMessage($this->message);
}
return false;
}
return true;
}
function getRegex($vat){
$regex = false;
switch(strtoupper(substr(str_replace(array('
','.','-'),array('','',''),$vat),0,
2))) {
case 'AT':
$regex = '/^(AT){0,1}U[0-9]{8}$/i';
break;
case 'BE':
$regex = '/^(BE){0,1}[0]{0,1}[0-9]{9}[0-9]{0,2}$/i';
break;
case 'BG':
$regex = '/^(BG){0,1}[0-9]{9,10}$/i';
break;
case 'CY':
$regex = '/^(CY){0,1}[0-9]{8}[A-Z]$/i';
break;
case 'CZ':
$regex = '/^(CZ){0,1}[0-9]{8,10}$/i';
break;
case 'DK':
$regex = '/^(DK){0,1}([0-9]{2}[\ ]{0,1}){3}[0-9]{2}$/i';
break;
case 'EE':
case 'DE':
case 'PT':
case 'EL':
case 'GR':
$regex = '/^(EE|EL|DE|GR|PT){0,1}[0-9]{9}$/i';
break;
case 'ES':
$regex =
'/^(ES){0,1}([0-9A-Z][0-9]{7}[A-Z])|([A-Z][0-9]{7}[0-9A-Z])$/i';
break;
case 'FI':
case 'HU':
case 'LU':
case 'MT':
case 'SI':
$regex = '/^(FI|HU|LU|MT|SI){0,1}[0-9]{8}$/i';
break;
case 'FR':
$regex = '/^(FR){0,1}[0-9A-Z]{2}[\ ]{0,1}[0-9]{9}$/i';
break;
case 'GB':
$regex = '/^(GB){0,1}([1-9][0-9]{2}[\ ]{0,1}[0-9]{4}[\
]{0,1}[0-9]{2})|([1-9][0-9]{2}[\ ]{0,1}[0-9]{4}[\ ]{0,1}[0-9]{2}[\
]{0,1}[0-9]{3})|((GD|HA)[0-9]{3})$/i';
break;
case 'IE':
$regex = '/^(IE){0,1}[0-9][0-9A-Z\+\*][0-9]{5}[A-Z]$/i';
break;
case 'IT':
case 'LV':
$regex = '/^(IT|LV){0,1}[0-9]{11}$/i';
break;
case 'LT':
$regex = '/^(LT){0,1}([0-9]{9}|[0-9]{12})$/i';
break;
case 'NL':
$regex = '/^(NL){0,1}[0-9]{9}B[0-9]{2}$/i';
break;
case 'PL':
case 'SK':
$regex = '/^(PL|SK){0,1}[0-9]{10}$/i';
break;
case 'RO':
$regex = '/^(RO){0,1}[1-9][0-9]{1,9}$/i';
break;
case 'SE':
$regex = '/^(SE){0,1}[0-9]{12}$/i';
break;
default:
break;
}
return $regex;
}
function onlineCheck($vat){
if (extension_loaded('soap')) {
try{
$client = new
SoapClient("http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl");
$countryCode = substr($vat, 0, 2);
$result = $client->checkVat(array('countryCode' =>
$countryCode, 'vatNumber' => substr($vat, 2)));
if(empty($result) || !$result->valid) {
$this->message = JText::_('VAT_NUMBER_NOT_VALID');
}
}catch(SoapFault $e) {
$this->message = $e->__toString();
return true;
}catch (Exception $e) {
$this->message = $e->__toString();
return true;
}
if ($result === false || empty($result) || !$result->valid ) {
$app = JFactory::getApplication();
if($_REQUEST['tmpl']=='component'){
hikashop_display($this->message,'error');
}else{
$app->enqueueMessage($this->message);
}
return false;
}
}else{
$app = JFactory::getApplication();
$this->message = JText::_('SOAP_EXTENSION_NOT_FOUND');
if($_REQUEST['tmpl']=='component'){
hikashop_display($this->message,'error');
}else{
$app->enqueueMessage($this->message);
}
return false;
}
return true;
}
}
volume.php000064400000005411151162557620006577 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopVolumeHelper{
var $conversion = array(
'm'=>array('dm'=>1000,'cm'=>1000000,'mm'=>1000000000,'ft'=>35.31466672,'in'=>61023.74409473,'yd'=>1.30795062),
'dm'=>array('m'=>0.001,'cm'=>1000,'mm'=>1000000,'ft'=>0.03531466672,'in'=>61.02374409473,'yd'=>0.00130795062),
'cm'=>array('m'=>0.000001,'dm'=>0.001,'mm'=>1000,'ft'=>0.00003531,'in'=>0.06102374,'yd'=>0.00000131),
'mm'=>array('m'=>0.000000001,'dm'=>0.000001,'cm'=>0.001,'ft'=>0.000000035312274,'in'=>0.00006102,'yd'=>0.0000000013078621),
'in'=>array('m'=>0.00001639,'dm'=>0.016387064,'cm'=>16.387064,'mm'=>16387.064,'ft'=>0.0005787,'yd'=>0.00002143),
'ft'=>array('m'=>0.02831685,'dm'=>28.316846592,'cm'=>28316.846592,'mm'=>28316846.592,'in'=>1728,'yd'=>0.03703704),
'yd'=>array('m'=>0.76455486,'dm'=>764.554857984,'cm'=>764554.857984,'mm'=>764554857.9839998,'in'=>46656,'ft'=>27),
);
var $conversionDimension = array(
'm'=>array('dm'=>10,'cm'=>100,'mm'=>1000,'ft'=>3.2808399,'in'=>39.3700787,'yd'=>1.0936133),
'dm'=>array('m'=>0.1,'cm'=>10,'mm'=>100,'ft'=>0.32808399,'in'=>3.93700787,'yd'=>0.10936133),
'cm'=>array('m'=>0.01,'dm'=>0.1,'mm'=>10,'ft'=>0.032808399,'in'=>0.393700787,'yd'=>0.010936133),
'mm'=>array('m'=>0.001,'dm'=>0.01,'cm'=>0.1,'ft'=>0.0032808399,'in'=>0.0393700787,'yd'=>0.0010936133),
'in'=>array('m'=> 0.0254,'dm'=>
0.254,'cm'=>
2.54,'mm'=>25.4,'ft'=>0.0833333333,'yd'=>0.0277777778),
'ft'=>array('m'=>0.3048,'dm'=>3.048,'cm'=>30.48,'mm'=>304.8,'in'=>12,'yd'=>0.333333333),
'yd'=>array('m'=>0.9144,'dm'=>9.144,'cm'=>91.44,'mm'=>914.4,'in'=>36,'ft'=>3),
);
function hikashopVolumeHelper(){
$this->getSymbol();
}
function convert($weight,$symbol_used='',$target='',
$mode='volume'){
if(empty($target)){
$target=$this->main_symbol;
}
if(empty($symbol_used)){
$symbol_used=$this->main_symbol;
}
if($symbol_used != $target){
if($mode=='volume'){
$convert = $this->conversion[$symbol_used][$target];
return $weight*$convert;
}
if($mode=='dimension'){
$convert = $this->conversionDimension[$symbol_used][$target];
return $weight*$convert;
}
}
return $weight;
}
function getSymbol(){
if(empty($this->main_symbol)){
$config =& hikashop_config();
$this->symbols =
explode(',',$config->get('volume_symbols','m,dm,cm,mm,in,ft,yd'));
foreach($this->symbols as $k => $symbol){
$this->symbols[$k] = trim($symbol);
}
$this->main_symbol = array_shift($this->symbols);
}
return $this->main_symbol;
}
}
weight.php000064400000004362151162557620006563 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopWeightHelper{
var $conversion = array(
'mg'=>array('g'=>0.001,'dag'=>0.0001,'kg'=>0.000001,'lb'=>0.00000220462234,'oz'=>0.000035273962,'ozt'=>0.0000321507466),
'g'=>array('kg'=>0.001,'mg'=>1000,'dag'=>0.1,'lb'=>0.00220462234,'oz'=>0.035273962,'ozt'=>0.0321507466),
'dag'=>array('kg'=>0.01,'mg'=>10000,'lb'=>0.0220462234,'oz'=>0.35273962,'ozt'=>0.321507466),
'kg'=>array('g'=>1000,'dag'=>100,'lb'=>2.20462234,'oz'=>35.273962,'ozt'=>32.1507466),
'lb'=>array('kg'=>0.45359237,'dag'=>45.359237,'g'=>453.59237,'mg'=>453592.37,'oz'=>16,'ozt'=>14.5833333),
'oz'=>array('kg'=>0.028349523125,'dag'=>2.8349523125,'g'=>28.349523125,'mg'=>28349.523125,'lb'=>0.0625,'ozt'=>0.911458333),
'ozt'=>array('kg'=>0.0311034768,'dag'=>3.11034768,'g'=>31.1034768,'mg'=>31103.4768,'lb'=>0.0685714286,'oz'=>1.09714286)
);
function __construct(){
$this->getSymbol();
}
function convert($weight,$symbol_used='',$target=''){
if(empty($target)){
$target=$this->main_symbol;
}
if(empty($symbol_used)){
$symbol_used=$this->main_symbol;
}
switch($target){
case 'l':
$target = 'kg';
break;
case 'cl':
$target = 'dag';
break;
case 'ml':
$target = 'g';
break;
default:
break;
}
switch($symbol_used){
case 'l':
$symbol_used = 'kg';
break;
case 'cl':
$symbol_used = 'dag';
break;
case 'ml':
$symbol_used = 'g';
break;
default:
break;
}
if($symbol_used != $target){
$convert = $this->conversion[$symbol_used][$target];
return $weight*$convert;
}
return $weight;
}
function getSymbol(){
if(empty($this->main_symbol)){
$config =& hikashop_config();
$this->symbols =
explode(',',$config->get('weight_symbols','kg,dag,g,mg,lb,oz,ozt'));
foreach($this->symbols as $k => $symbol){
$this->symbols[$k] = trim($symbol);
}
$this->main_symbol = array_shift($this->symbols);
}
return $this->main_symbol;
}
}
importmijo.php000064400000170224151162557620007466 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
include(HIKASHOP_ROOT .
'components/com_mijoshop/opencart/admin/config.php');
class hikashopImportmijoHelper extends hikashopImportHelper
{
var $importcurrencies;
function __construct()
{
parent::__construct();
$this->importName = 'mijo';
$this->copyImgDir = HTTPS_IMAGE;
$this->copyCatImgDir = HTTPS_IMAGE;
$this->copyDownloadDir = DIR_DOWNLOAD;
jimport('joomla.filesystem.file');
}
function importFromMijo()
{
@ob_clean();
echo $this->getHtmlPage();
$this->token = hikashop_getFormToken();
flush();
if( isset($_GET['import']) && $_GET['import']
== '1' )
{
$this->importcurrencies =
JRequest::getInt('importcurrencies');
$time = microtime(true);
$processed = $this->doImport();
if( $processed )
{
$elasped = microtime(true) - $time;
if( !$this->refreshPage )
echo
'<p></br><a'.$this->linkstyle.'href="'.hikashop_completeLink('import&task=import&importfrom=mijo&'.$this->token.'=1&import=1&importcurrencies='.$this->importcurrencies).'">'.JText::_('HIKA_NEXT').'</a></p>';
echo '<p style="font-size:0.85em;
color:#605F5D;">Elasped time: ' . round($elasped * 1000, 2) .
'ms</p>';
}
else
{
echo
'<a'.$this->linkstyle.'href="'.hikashop_completeLink('import&task=show').'">'.JText::_('HIKA_BACK').'</a>';
}
}
else
{
echo $this-> getStartPage();
}
if( $this->refreshPage )
{
echo "<script type=\"text/javascript\">\r\nr =
true;\r\n</script>";
}
echo '</body></html>';
exit;
}
function getStartPage()
{
$this->importcurrencies =
JRequest::getInt('import_currencies');
return '<span style="color:#297F93;
font-size:1.2em;text-decoration:underline;">Step
0</span><br/><br/>'.
'Make a backup of your database.<br/>'.
'When ready, click on <a '.$this->linkstyle.'
href="'.hikashop_completeLink('import&task=import&importfrom=mijo&'.$this->token.'=1&import=1&importcurrencies='.$this->importcurrencies).'">'.JText::_('HIKA_NEXT').'</a>,
otherwise '.
'<a'.$this->linkstyle.'
href="'.hikashop_completeLink('import&task=show').'">'.JText::_('HIKA_BACK').'</a>.';
}
function doImport()
{
if( $this->db == null )
return false;
$this->loadConfiguration();
$current = $this->options->current;
$ret = true;
$next = false;
switch($this->options->state)
{
case 0:
$next = $this->createTables();
break;
case 1:
$next = $this->importTaxes();
break;
case 2:
$next = $this->importManufacturers();
break;
case 3:
$next = $this->importCategories();
break;
case 4:
$next = $this->importProducts();
break;
case 5:
$next = $this->importProductPrices();
break;
case 6:
$next = $this->importProductCategory();
break;
case 7:
$next = $this->importUsers();
break;
case 8:
$next = $this->importDiscount();
break;
case 9:
$next = $this->importOrders();
break;
case 10:
$next = $this->importOrderItems();
break;
case 11:
$next = $this->importDownloads();
break;
case MAX_IMPORT_ID:
$next = $this->finishImport();
$ret = false;
break;
case MAX_IMPORT_ID+1:
$next = false;
$ret = $this->proposeReImport();
break;
default:
$ret = false;
break;
}
if( $ret && $next )
{
$sql = "UPDATE `#__hikashop_config` SET
config_value=(config_value+1) WHERE config_namekey =
'mijo_import_state'; ";
$this->db->setQuery($sql);
$this->db->query();
$sql = "UPDATE `#__hikashop_config` SET config_value=0 WHERE
config_namekey = 'mijo_import_current';";
$this->db->setQuery($sql);
$this->db->query();
}
else if( $current != $this->options->current )
{
$sql = "UPDATE `#__hikashop_config` SET
config_value=".$this->options->current." WHERE
config_namekey = 'mijo_import_current';";
$this->db->setQuery($sql);
$this->db->query();
}
return $ret;
}
function loadConfiguration()
{
$this->options = null;
$firsttime = false;
$data = array(
'uploadfolder',
'uploadsecurefolder',
'main_currency',
'mijo_import_state',
'mijo_import_current',
'mijo_import_tax_id',
'mijo_import_main_cat_id',
'mijo_import_max_hk_cat',
'mijo_import_max_hk_prod',
'mijo_import_last_mijo_cat',
'mijo_import_last_mijo_prod',
'mijo_import_last_mijo_user',
'mijo_import_last_mijo_order',
'mijo_import_last_mijo_pfile',
'mijo_import_last_mijo_coupon',
'mijo_import_last_mijo_voucher',
'mijo_import_last_mijo_taxrate',
'mijo_import_last_mijo_taxclass',
'mijo_import_last_mijo_manufacturer'
);
$this->db->setQuery('SELECT config_namekey, config_value FROM
`#__hikashop_config` WHERE config_namekey IN
('."'".implode("','",$data)."'".');');
$result = $this->db->loadObjectList();
if (!empty($result))
{
foreach($result as $o)
{
if( substr($o->config_namekey, 0, 12) == 'mijo_import_' )
$nk = substr($o->config_namekey, 12);
else
$nk = $o->config_namekey;
$this->options->$nk = $o->config_value;
}
}
else
{
$firsttime = true;
}
$this->options->uploadfolder =
rtrim(JPath::clean(html_entity_decode($this->options->uploadfolder)),DS.'
').DS;
if(!preg_match('#^([A-Z]:)?/.*#',$this->options->uploadfolder)){
if(!$this->options->uploadfolder[0]=='/' ||
!is_dir($this->options->uploadfolder)){
$this->options->uploadfolder =
JPath::clean(HIKASHOP_ROOT.DS.trim($this->options->uploadfolder,DS.'
').DS);
}
}
$this->options->uploadsecurefolder =
rtrim(JPath::clean(html_entity_decode($this->options->uploadsecurefolder)),DS.'
').DS;
if(!preg_match('#^([A-Z]:)?/.*#',$this->options->uploadsecurefolder)){
if(!$this->options->uploadsecurefolder[0]=='/' ||
!is_dir($this->options->uploadsecurefolder)){
$this->options->uploadsecurefolder =
JPath::clean(HIKASHOP_ROOT.DS.trim($this->options->uploadsecurefolder,DS.'
').DS);
}
}
if( $firsttime )
{
$this->options->state = 0;
$this->options->current = 0;
$this->options->tax_id = 0;
$this->options->last_mijo_coupon = 0;
$this->options->last_mijo_voucher = 0;
$this->options->last_mijo_pfile = 0;
$this->options->last_mijo_taxrate = 0;
$this->options->last_mijo_taxclass = 0;
$this->options->last_mijo_manufacturer = 0;
$element = 'product';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$this->options->main_cat_id = $element;
$this->db->setQuery("SELECT max(category_id) as
'max' FROM `#__hikashop_category`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(product_id) as
'max' FROM `#__hikashop_product`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_prod = (int)($data[0]->max);
$query='SHOW TABLES LIKE
'.$this->db->Quote($this->db->getPrefix().substr(hikashop_table('mijo_cat'),3));
$this->db->setQuery($query);
$table = $this->db->loadResult();
if(!empty($table))
{
$this->db->setQuery("SELECT max(mijo_id) as 'max'
FROM `#__hikashop_mijo_cat`;");
$data = $this->db->loadObjectList();
if( $data )
$this->options->last_mijo_cat = (int)($data[0]->max);
else
$this->options->last_mijo_cat = 0;
$this->db->setQuery("SELECT max(mijo_id) as 'max'
FROM `#__hikashop_mijo_prod`;");
$data = $this->db->loadObjectList();
if( $data )
$this->options->last_mijo_prod = (int)($data[0]->max);
else
$this->options->last_mijo_prod = 0;
$this->db->setQuery("SELECT max(order_mijo_id) as
'max' FROM `#__hikashop_order`;");
$data = $this->db->loadObjectList();
if( $data )
$this->options->last_mijo_order = (int)($data[0]->max);
else
$this->options->last_mijo_order = 0;
}
else
{
$this->options->last_mijo_cat = 0;
$this->options->last_mijo_prod = 0;
$this->options->last_mijo_order = 0;
}
$this->options->last_mijo_user = 0;
$sql = 'INSERT IGNORE INTO `#__hikashop_config`
(`config_namekey`,`config_value`,`config_default`) VALUES '.
"('mijo_import_state',".$this->options->state.",".$this->options->state.")".
",('mijo_import_current',".$this->options->current.",".$this->options->current.")".
",('mijo_import_tax_id',".$this->options->tax_id.",".$this->options->tax_id.")".
",('mijo_import_main_cat_id',".$this->options->main_cat_id.",".$this->options->main_cat_id.")".
",('mijo_import_max_hk_cat',".$this->options->max_hk_cat.",".$this->options->max_hk_cat.")".
",('mijo_import_max_hk_prod',".$this->options->max_hk_prod.",".$this->options->max_hk_prod.")".
",('mijo_import_last_mijo_cat',".$this->options->last_mijo_cat.",".$this->options->last_mijo_cat.")".
",('mijo_import_last_mijo_prod',".$this->options->last_mijo_prod.",".$this->options->last_mijo_prod.")".
",('mijo_import_last_mijo_user',".$this->options->last_mijo_user.",".$this->options->last_mijo_user.")".
",('mijo_import_last_mijo_order',".$this->options->last_mijo_order.",".$this->options->last_mijo_order.")".
",('mijo_import_last_mijo_pfile',".$this->options->last_mijo_pfile.",".$this->options->last_mijo_pfile.")".
",('mijo_import_last_mijo_coupon',".$this->options->last_mijo_coupon.",".$this->options->last_mijo_coupon.")".
",('mijo_import_last_mijo_voucher',".$this->options->last_mijo_voucher.",".$this->options->last_mijo_voucher.")".
",('mijo_import_last_mijo_taxrate',".$this->options->last_mijo_taxrate.",".$this->options->last_mijo_taxrate.")".
",('mijo_import_last_mijo_taxclass',".$this->options->last_mijo_taxclass.",".$this->options->last_mijo_taxclass.")".
",('mijo_import_last_mijo_manufacturer',".$this->options->last_mijo_manufacturer.",".$this->options->last_mijo_manufacturer.")".
';';
$this->db->setQuery($sql);
$this->db->query();
}
}
function createTables()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
1 :</span>Â Initialization Tables</p>';
$create = true;
$query='SHOW TABLES LIKE
'.$this->db->Quote($this->db->getPrefix().substr(hikashop_table('mijo_cat'),3));
$this->db->setQuery($query);
$table = $this->db->loadResult();
if (!empty($table))
$create = false;
if ($create)
{
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_mijo_prod` (`mijo_id` int(11) unsigned NOT NULL DEFAULT
'0', `hk_id` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`mijo_id`)) ENGINE=MyISAM");
$this->db->query();
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_mijo_cat` (`mijo_cat_id` INT(11) unsigned NOT NULL
AUTO_INCREMENT, `mijo_id` int(11) unsigned NOT NULL DEFAULT '0',
`hk_id` int(11) unsigned NOT NULL DEFAULT '0', `category_type`
varchar(255) NULL, PRIMARY KEY (`mijo_cat_id`)) ENGINE=MyISAM");
$this->db->query();
$this->db->setQuery('ALTER IGNORE TABLE `#__hikashop_address`
ADD `address_mijo_order_info_id` INT(11) NULL');
$this->db->query();
$this->db->setQuery('ALTER IGNORE TABLE `#__hikashop_order`
ADD `order_mijo_id` INT(11) NULL');
$this->db->query();
$this->db->setQuery('ALTER IGNORE TABLE `#__hikashop_order`
ADD INDEX ( `order_mijo_id` )');
$this->db->query();
$this->db->setQuery('ALTER IGNORE TABLE
`#__hikashop_taxation` ADD `tax_mijo_id` INT(11) NULL');
$this->db->query();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
All table created</p>';
}
else
{
echo '<p>Tables have been already created.</p>';
$this->refreshPage = true; //toComment ?
}
return true;
}
function importTaxes()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
2 :</span>Â Import Taxes<p>';
$ret = false;
$data = array(
'tax_namekey' => "CONCAT('MIJO_TAX_',
mjt.tax_rate_id)",
'tax_rate' => 'mjt.rate'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_tax`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__mijoshop_tax_rate` AS mjt '.
'WHERE mjt.tax_rate_id > ' .
(int)$this->options->last_mijo_taxrate;
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported taxes: ' . $total . '</p>';
$element = 'tax';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$data = array(
'category_type' => "'tax'",
'category_name' => "CONCAT('Tax imported
(', mtc.title,')')",
'category_published' => '1',
'category_parent_id' => $element,
'category_namekey' => "
CONCAT('MIJO_TAX_CATEGORY_', mtc.tax_class_id)" //"case
when hkz.zone_id IS NULL then CONCAT('MIJO_TAX_',
mjtr.tax_rate_id,'_0') else CONCAT('MIJO_TAX_',
mjtr.tax_rate_id,'_',hkz.zone_id) end",
);
$sql = 'INSERT IGNORE INTO `#__hikashop_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__mijoshop_tax_class` AS mtc ';
'WHERE mtc.tax_class_id > ' .
(int)$this->options->last_mijo_taxclass;
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Taxes Categories: ' . $total . '</p>';
if( $total > 0 ) {
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'mijo_import_max_hk_cat'; ");
$this->db->query();
$this->importRebuildTree();
}
$data = array(
'zone_namekey' => "case when hkz.zone_namekey IS NULL
then '' else hkz.zone_namekey end",
'category_namekey' =>
"CONCAT('MIJO_TAX_CATEGORY_', mjtc.tax_class_id)",
//"case when hkz.zone_id IS NULL then CONCAT('MIJO_TAX_',
mjtr.tax_rate_id,'_0') else CONCAT('MIJO_TAX_',
mjtr.tax_rate_id,'_',hkz.zone_id) end",
'tax_namekey' => "CONCAT('MIJO_TAX_',
mjtra.tax_rate_id)",
'taxation_published' => '1',
'taxation_type' => "''",
'tax_mijo_id' => 'mjtc.tax_class_id'
//'mjtra.tax_rate_id' See import product
);
$sql = 'INSERT IGNORE INTO `#__hikashop_taxation`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__mijoshop_tax_class` AS mjtc '.
'INNER JOIN `#__mijoshop_tax_rule` AS mjtr ON mjtc.tax_class_id =
mjtr.tax_class_id '.
'INNER JOIN `#__mijoshop_tax_rate` AS mjtra ON mjtr.tax_rate_id =
mjtra.tax_rate_id '.
'LEFT JOIN `#__mijoshop_zone_to_geo_zone` AS mjz ON
mjtra.geo_zone_id = mjz.geo_zone_id '.
'LEFT JOIN `#__mijoshop_country` AS mjc ON mjz.country_id =
mjc.country_id ' .
"LEFT JOIN `#__hikashop_zone` hkz ON mjc.iso_code_3 =
hkz.zone_code_3 AND hkz.zone_type = 'country' ".
'WHERE mjtra.tax_rate_id > ' .
(int)$this->options->last_mijo_taxrate;
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Taxations: ' . $total . '</p>';
$ret = true;
return $ret;
}
function importManufacturers()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
3 :</span>Â Import Manufacturers</p>';
$ret = false;
$count = 100;
$rebuild = false;
$sql1 = 'SELECT * FROM `#__mijoshop_manufacturer` mjm '.
'LEFT JOIN `#__hikashop_mijo_cat` hkmj ON mjm.manufacturer_id =
hkmj.mijo_id AND category_type=\'manufacturer\' '.
'WHERE mjm.manufacturer_id > ' .
(int)$this->options->last_mijo_manufacturer;
'ORDER BY mjm.manufacturer_id ASC;';
$this->db->setQuery($sql1);
$this->db->query();
$datas = $this->db->loadObjectList();
$sql2 = 'INSERT INTO `#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_published`,'.
'`category_namekey`,`category_description`,`category_menu`) VALUES
';
$sql3 = 'INSERT INTO `#__hikashop_mijo_cat`
(`mijo_id`,`hk_id`,`category_type`) VALUES ';
$sql4 = 'INSERT INTO `#__hikashop_file`
(`file_name`,`file_description`,`file_path`,`file_type`,`file_ref_id`)
VALUES ';
$doSql3 = false;
$doSql4 = false;
$i = $this->options->max_hk_cat + 1;
$ids = array( 0 => $this->options->main_cat_id);
$sep = '';
$sep2 = '';
$cpt=0;
$echo=false;
if( empty($datas) )
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported manufacturers : 0</p>';
return true;
}
else
{
foreach($datas as $data)
{
if( !empty($data->mijo_id) )
{
$ids[$data->manufacturer_id] = $data->hk_id;
}
else
{
$doSql3 = true;
$ids[$data->manufacturer_id] = $i;
$sql3 .=
$sep.'('.$data->manufacturer_id.','.$i.',\'manufacturer\')';
$i++;
$sep = ',';
}
$cpt++;
if( $cpt >= $count )
break;
}
$sql3 .= ';';
$cpt = 0;
$sep = '';
foreach($datas as $data)
{
if( !empty($data->mijo_id) )
continue;
$id = $ids[$data->manufacturer_id];
$element = 'manufacturer';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$d = array(
$id,
$element,
"'manufacturer'",
$this->db->quote($data->name),
'1',
"CONCAT('MIJO_MANUFAC_',
".$data->manufacturer_id .")",
"'manufacturer imported from Mijoshop'",
'0'
);
$sql2 .= $sep.'('.implode(',',$d).')';
if( !empty($data->image))
{
$this->copyCatImgDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode($this->copyCatImgDir)),DS.'
').DS);
if (!$echo)
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying manufacturers images... </p>';
$echo=true;
}
$doSql4 = true;
$sql4 .=
$sep2."(".$this->db->quote($data->name).",'',".$this->db->quote($data->image).",'category',".$id.')';
//type = category / manufacturer ?
$sep2 = ',';
$file_name =
str_replace('\\','/',$data->image);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyCatImgDir,$data->image,
str_replace('//','/',str_replace('\\','/',$this->options->uploadfolder.$file_name)));
}
$sep = ',';
$cpt++;
if( $cpt >= $count )
break;
}
}
if($cpt > 0)
{
$sql2 .= ';';
$sql4 .= ';';
$this->db->setQuery($sql2);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Manufacturers : ' . $total . '</p>';
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Manufacturers : 0</p>';
}
if( isset($total) && $total > 0)
{
$rebuild = true;
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'mijo_import_max_hk_cat'; ");
$this->db->query();
}
if ($doSql3)
{
$this->db->setQuery($sql3);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links : ' . $total . '</p>';
}
if($doSql4)
{
$this->db->setQuery($sql4);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Manufacturers files : ' . $total . '</p>';
}
if( $rebuild )
$this->importRebuildTree();
if( $cpt < $count )
$ret = true;
return $ret;
}
function importCategories()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
4 :</span>Â Import General Categories</p>';
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$rebuild = false;
$ret = false;
$offset = 0;
$count = 100;
$cpt = 0;
$sep = '';
$sep2 = '';
$echo=false;
$statuses = array(
'P' => 'created',
'C' => 'confirmed',
'X' => 'cancelled',
'R'=> 'refunded' ,
'S' => 'shipped'
);
$this->db->setQuery("SELECT category_keywords,
category_parent_id FROM `#__hikashop_category` WHERE category_type =
'status' AND category_name = 'confirmed'");
$data = $this->db->loadObject();
$status_category = $data->category_parent_id;
if( $data->category_keywords != 'C' ) {
foreach($statuses as $k => $v) {
$this->db->setQuery("UPDATE `#__hikashop_category` SET
category_keywords = '".$k."' WHERE category_type =
'status' AND category_name = '".$v."';
");
$this->db->query();
}
}
$this->db->setQuery("SELECT order_status_id, name FROM
`#__mijoshop_order_status` WHERE name NOT IN
('".implode("','",$statuses)."','canceled');");
$data = $this->db->loadObjectList();
if( count($data) > 0 )
{
$sql0 = 'INSERT IGNORE INTO `#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_description`,`category_published`,'.
'`category_namekey`,`category_access`,`category_menu`,`category_keywords`)
VALUES ';
$id = $this->options->max_hk_cat + 1;
$sep = '';
foreach($data as $c) {
$d = array(
$id++,
$status_category,
"'status'",
$this->db->quote( strtolower($c->name) ),
"'Order status imported from Mijoshop'",
'1',
$this->db->quote('status_mijo_import_'.strtolower(str_replace('
','_',$c->name))),
"'all'",
'0',
$this->db->quote( $c->order_status_id )
);
$sql0 .= $sep.'('.implode(',',$d).')';
$sep = ',';
}
$this->db->setQuery($sql0);
$this->db->query();
$total = $this->db->getAffectedRows();
if( $total > 0 ) {
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported order status categories : ' . $total .
'</p>';
$rebuild = true;
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'mijo_import_max_hk_cat'; ");
$this->db->query();
$sql0 = '';
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported order status categories : 0</p>';
}
}
$sql1 = 'SELECT * FROM `#__mijoshop_category` mjc '.
'INNER JOIN `#__mijoshop_category_description` mjcd ON
mjc.category_id = mjcd.category_id '.
'LEFT JOIN `#__hikashop_mijo_cat` hkmj ON mjc.category_id =
hkmj.mijo_id AND category_type=\'category\' '.
'WHERE mjc.category_id >
'.$this->options->last_mijo_cat.' '.
'ORDER BY mjc.parent_id ASC, mjc.category_id ASC;';
$this->db->setQuery($sql1);
$this->db->query();
$datas = $this->db->loadObjectList();
$sql2 = 'INSERT INTO `#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_description`,`category_published`,'.
'`category_ordering`,`category_namekey`,`category_created`,`category_modified`,`category_access`,`category_menu`)
VALUES ';
$sql3 = 'INSERT INTO `#__hikashop_mijo_cat`
(`mijo_id`,`hk_id`,`category_type`) VALUES ';
$sql4 = 'INSERT INTO `#__hikashop_file`
(`file_name`,`file_description`,`file_path`,`file_type`,`file_ref_id`)
VALUES ';
$doSql3 = false;
$doSql4 = false;
$i = $this->options->max_hk_cat + 1;
$ids = array( 0 => $this->options->main_cat_id);
$sep = '';
if( empty($datas) )
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported category : 0</p>';
if( $rebuild )
$this->importRebuildTree();
return true;
}
else
{
foreach($datas as $data)
{
if( !empty($data->mijo_id) )
{
$ids[$data->category_id] = $data->hk_id;
}
else
{
$doSql3 = true;
$ids[$data->category_id] = $i;
$sql3 .=
$sep.'('.$data->category_id.','.$i.',\'category\')';
$i++;
$sep = ',';
}
$cpt++;
if( $cpt >= $count )
break;
}
$sql3 .= ';';
$cpt = 0;
$sep = '';
foreach($datas as $data)
{
if( !empty($data->mijo_id) )
continue;
$id = $ids[$data->category_id];
if(!empty($ids[$data->parent_id]))
$pid = (int)$ids[$data->parent_id];
else
$pid = $ids[0];
$element = new stdClass();
$element->category_id = $id;
$element->category_parent_id = $pid;
$element->category_name = $data->name;
$nameKey = $categoryClass->getNameKey($element);
$d = array(
$id,
$pid,
"'product'",
$this->db->quote($data->name),
$this->db->quote($data->description),
'1',
$data->sort_order,
$this->db->quote($nameKey),
"'".$data->date_added."'",
"'".$data->date_modified."'",
"'all'",
'0'
);
$sql2 .= $sep.'('.implode(',',$d).')';
if( !empty($data->image))
{
$this->copyCatImgDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode($this->copyCatImgDir)),DS.'
').DS);
if (!$echo)
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying categories images... </p>';
$echo=true;
}
$doSql4 = true;
$sql4 .=
$sep2."('','','".$data->image."','category',".$id.')';
$sep2 = ',';
$file_name =
str_replace('\\','/',$data->image);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyCatImgDir,$data->image,
str_replace('//','/',str_replace('\\','/',$this->options->uploadfolder.$file_name)));
}
$sep = ',';
$cpt++;
if( $cpt >= $count )
break;
}
}
if($cpt > 0)
{
$sql2 .= ';';
$sql4 .= ';';
$this->db->setQuery($sql2);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Categories : ' . $total . '</p>';
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported category : 0</p>';
}
if( isset($total) && $total > 0)
{
$rebuild = true;
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'mijo_import_max_hk_cat'; ");
$this->db->query();
}
if ($doSql3)
{
$this->db->setQuery($sql3);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links : ' . $total . '</p>';
}
if($doSql4)
{
$this->db->setQuery($sql4);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Categories files : ' . $total . '</p>';
}
if( $rebuild )
$this->importRebuildTree();
if( $cpt < $count )
$ret = true;
return $ret;
}
function importProducts()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
5 :</span>Â Import Products</p>';
$ret = false;
$count = 100;
$offset = $this->options->current;
$max = 0;
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$this->db->setQuery('SELECT mjp.product_id, mjpi.image FROM
`#__mijoshop_product` mjp '.
'LEFT JOIN `#__mijoshop_product_image` mjpi ON mjp.product_id =
mjpi.product_id '.
'LEFT JOIN `#__hikashop_mijo_prod` hkprod ON mjp.product_id =
hkprod.mijo_id '.
"WHERE mjp.product_id > ".$offset." AND
hkprod.hk_id IS NULL AND (mjp.image IS NOT NULL) AND mjp.image <>
'' ".
'ORDER BY product_id ASC LIMIT '.$count.';'
);
$datas = $this->db->loadObjectList();
$this->copyImgDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode($this->copyImgDir)),DS.'
').DS);
if (!empty($datas))
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying products images... </p>';
foreach($datas as $data) {
if( !empty($data->image) ) {
$file_name =
str_replace('\\','/',$data->image);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyImgDir,$data->image,
$this->options->uploadfolder.$file_name);
$max = $data->product_id;
}
}
}
if( $max > 0 )
{
echo '<p>Copying files...(last proccessed product id: '
. $max . ')</p>';
$this->options->current = $max;
$this->refreshPage = true;
return $ret;
}
$data = array(
'product_name' => 'mjpd.name',
'product_description' => 'mjpd.description',
'product_quantity' => 'case when mjp.quantity IS NULL
or mjp.quantity < 0 then 0 else mjp.quantity end',
'product_code' => 'mjp.hika_sku',
'product_published' => 'mjp.status',
'product_hit' => 'mjp.viewed',
'product_created' => 'mjp.date_added',
'product_modified' => 'mjp.date_modified',
'product_sale_start' => 'mjp.date_available',
'product_tax_id' => 'hkc.category_id',
'product_type' => "'main'",
'product_url' => "''",
'product_weight' => 'mjp.weight',
'product_weight_unit' => "LOWER(mjwcd.unit)",
'product_dimension_unit' => "LOWER(mjlcd.unit)",
'product_min_per_order' => 'mjp.minimum',
'product_sales' => '0',
'product_width' => 'mjp.width',
'product_length' => 'mjp.length',
'product_height' => 'mjp.height',
'product_parent_id' => '0'
);
$sql1 = 'INSERT IGNORE INTO `#__hikashop_product`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__mijoshop_product` AS mjp '.
'INNER JOIN `#__mijoshop_weight_class_description` mjwcd ON
mjp.weight_class_id = mjwcd.weight_class_id '.
'INNER JOIN `#__mijoshop_length_class_description` mjlcd ON
mjp.length_class_id = mjlcd.length_class_id '.
'INNER JOIN `#__mijoshop_product_description` mjpd ON mjp.product_id
= mjpd.product_id '.
'LEFT JOIN `#__hikashop_taxation` hkt ON hkt.tax_mijo_id =
mjp.tax_class_id '.
'LEFT JOIN `#__hikashop_category` hkc ON hkc.category_namekey =
hkt.category_namekey '.
'LEFT JOIN `#__hikashop_mijo_prod` AS hkp ON mjp.product_id =
hkp.mijo_id '.
'WHERE hkp.hk_id IS NULL ORDER BY mjp.product_id ASC;';
$this->db->setQuery("SHOW COLUMNS FROM `#__mijoshop_product`
LIKE 'hika_sku';");
$data = $this->db->loadObjectList();
if (empty($data))
{
$this->db->setQuery('ALTER TABLE `#__mijoshop_product` ADD
COLUMN `hika_sku` VARCHAR(255) NOT NULL;');
$this->db->query();
}
$this->db->setQuery('UPDATE `#__mijoshop_product` AS mjp SET
mjp.hika_sku = mjp.sku;');
$this->db->query();
$this->db->setQuery("UPDATE `#__mijoshop_product` AS mjp SET
mjp.hika_sku = CONCAT(mjp.model,'_',mjp.product_id) WHERE
mjp.hika_sku='';");
$this->db->query();
$this->db->setQuery('SELECT hika_sku FROM
`#__mijoshop_product` GROUP BY hika_sku HAVING
COUNT(hika_sku)>1');
$data = $this->db->loadObjectList();
if (!empty($data))
{
foreach ($data as $d)
{
$this->db->setQuery("UPDATE `#__mijoshop_product` AS mjp SET
mjp.hika_sku = CONCAT(mjp.hika_sku,'_',mjp.product_id) WHERE
mjp.hika_sku = '".$d->hika_sku."';");
$this->db->query();
}
}
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
SKU generated: '.count($data).'</p>';
$data = array(
'mijo_id' => 'mjp.product_id',
'hk_id' => 'hkp.product_id'
);
$sql2 = 'INSERT IGNORE INTO `#__hikashop_mijo_prod`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__mijoshop_product` AS mjp '.
'INNER JOIN `#__hikashop_product` AS hkp ON CONVERT(mjp.hika_sku
USING utf8) = CONVERT(hkp.product_code USING utf8) '.
'LEFT JOIN `#__hikashop_mijo_prod` hkmjp ON hkmjp.mijo_id =
mjp.product_id '.
'WHERE hkmjp.hk_id IS NULL;';
$data = array(
'file_name' => "''",
'file_description' => "''",
'file_path' =>
"SUBSTRING_INDEX(mjpi.image,'/',-1)",
'file_type' => "'product'",
'file_ref_id' => 'hkmjp.hk_id'
);
$sql4 = 'INSERT IGNORE INTO `#__hikashop_file`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__mijoshop_product` AS mjp '.
'INNER JOIN `#__mijoshop_product_image` mjpi ON mjp.product_id =
mjpi.product_id '.
'INNER JOIN `#__hikashop_mijo_prod` AS hkmjp ON mjp.product_id =
hkmjp.mijo_id '.
'WHERE mjp.product_id >
'.$this->options->last_mijo_prod. ' AND (mjpi.image IS NOT
NULL) AND (mjpi.image <>'." '');";
$sql5 = 'UPDATE `#__hikashop_product` AS hkp '.
'INNER JOIN `#__hikashop_mijo_prod` AS hkmjp ON hkp.product_id =
hkmjp.hk_id '.
'INNER JOIN `#__mijoshop_product` AS mjp ON hkmjp.mijo_id =
mjp.product_id '.
"INNER JOIN `#__hikashop_category` AS hkc ON hkc.category_type =
'manufacturer' AND mjp.manufacturer_id = hkc.category_menu
".
'SET hkp.product_manufacturer_id = hkc.category_id '.
'WHERE mjp.manufacturer_id >
'.$this->options->last_mijo_manufacturer.' OR
mjp.product_id >
'.$this->options->last_mijo_prod.';';
$this->db->setQuery($sql1);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products: ' . $total . '</p>';
$this->db->setQuery($sql2);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links: ' . $total . '</p>';
$this->db->setQuery($sql4);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products files: ' . $total . '</p>';
$this->db->setQuery($sql5);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating products manufacturers: ' . $total . '</p>';
$ret = true;
return $ret;
}
function importVariant()
{
}
function importProductPrices()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
6 :</span>Â Import Product Prices</p>';
$ret = false;
$cpt = 0;
$this->db->setQuery('SELECT hkcur.currency_id FROM
`#__mijoshop_currency` mjc '.
'INNER JOIN `#__hikashop_currency` hkcur ON CONVERT(mjc.code
USING utf8) = CONVERT( hkcur.currency_code USING utf8) '.
"WHERE mjc.value = '1.0';");
$data = $this->db->loadObjectList();
if (!empty($data))
{
$this->db->setQuery('INSERT IGNORE INTO `#__hikashop_price`
(`price_product_id`,`price_value`,`price_currency_id`,`price_min_quantity`,`price_access`)
'
."SELECT hkprod.hk_Id, mjp.price,
'".$data[0]->currency_id."', '0',
'all' "
.'FROM `#__mijoshop_product` mjp INNER JOIN
`#__hikashop_mijo_prod` hkprod ON mjp.product_id = hkprod.mijo_id '
.'WHERE mjp.product_id > ' .
(int)$this->options->last_mijo_prod
);
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Prices imported : 0</p>';
}
$ret = $this->db->query();
$cpt = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Prices imported : ' . $cpt .'</p>';
if ($this->importcurrencies)
$this->importCurrencies();
return $ret;
}
function importProductCategory()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
7 :</span>Â Import Product Category</p>';
$ret = false;
$data = array(
'category_id' => 'hmjc.hk_id',
'product_id' => 'hmjp.hk_id',
'ordering' => '0',
);
$sql = 'INSERT IGNORE INTO `#__hikashop_product_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__mijoshop_product_to_category` mjpc '.
'INNER JOIN #__hikashop_mijo_cat hmjc ON mjpc.category_id =
hmjc.mijo_id AND category_type=\'category\' '.
'INNER JOIN #__hikashop_mijo_prod hmjp ON mjpc.product_id =
hmjp.mijo_id '.
'WHERE hmjp.mijo_id > ' .
(int)$this->options->last_mijo_prod . ' OR hmjc.mijo_id >
' . (int)$this->options->last_mijo_cat;
$this->db->setQuery($sql);
$ret = $this->db->query();
$total = $this->db->getAffectedRows();
$this->importRebuildTree();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products categories: ' . $total . '</p>';
return $ret;
}
function importUsers()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
8 :</span>Â Import Users</p>';
$ret = false;
$sql0 = 'INSERT IGNORE INTO `#__hikashop_user`
(`user_cms_id`,`user_email`) '.
'SELECT u.id, u.email FROM `#__mijoshop_customer` mjc '.
'INNER JOIN `#__mijoshop_juser_ocustomer_map` mjju ON
mjju.ocustomer_id = mjc.customer_id '.
'INNER JOIN `#__users` u ON mjju.juser_id = u.id '.
'LEFT JOIN `#__hikashop_user` AS hkusr ON mjju.juser_id =
hkusr.user_cms_id '.
'WHERE hkusr.user_cms_id IS NULL;';
$data = array(
'address_user_id' => 'hku.user_id',
'address_title' => "'Mr'",
'address_firstname' => 'mja.firstname',
'address_lastname' => 'mja.lastname',
'address_company' => 'mja.company',
'address_street' => 'CONCAT(mja.address_1,\'
\',mja.address_2)',
'address_post_code' => 'mja.postcode',
'address_city' => 'mja.city',
'address_telephone' => 'mjcu.telephone',
'address_fax' => 'mjcu.fax',
'address_state' => 'hkzsta.zone_namekey',
'address_country' => 'hkzcou.zone_namekey',
'address_published' => 4
);
$sql1 = 'INSERT IGNORE INTO `#__hikashop_address`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__mijoshop_customer` AS mjcu '.
'INNER JOIN `#__mijoshop_address` AS mja ON mjcu.customer_id =
mja.customer_id '.
'INNER JOIN `#__mijoshop_juser_ocustomer_map` mjju ON
mja.customer_id = mjju.ocustomer_id '.
'INNER JOIN `#__users` u ON mjju.juser_id = u.id '.
'INNER JOIN `#__hikashop_user` AS hku ON mjju.juser_id =
hku.user_cms_id '.
'INNER JOIN `#__mijoshop_country` AS mjc ON mja.country_id =
mjc.country_id '.
'INNER JOIN `#__mijoshop_zone` AS mjz ON mja.zone_id = mjz.zone_id
'.
'LEFT JOIN `#__hikashop_zone` AS hkzcou ON mjc.iso_code_3 =
hkzcou.zone_code_3 AND hkzcou.zone_type=\'country\' '.
'INNER JOIN `#__hikashop_zone_link` AS hkzl ON hkzcou.zone_namekey
= hkzl.zone_parent_namekey '.
'INNER JOIN `#__hikashop_zone` AS hkzsta ON mjz.code =
hkzsta.zone_code_3 AND hkzsta.zone_type=\'state\' AND
hkzsta.zone_namekey = hkzl.zone_child_namekey '.
'WHERE mjcu.customer_id >
'.$this->options->last_mijo_user.' ORDER BY mja.customer_id
ASC';
$sql2 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone` AS hkz ON (a.address_country =
hkz.zone_code_3 AND hkz.zone_type = "country") '.
'SET address_country = hkz.zone_namekey, address_published = 3
WHERE address_published = 4;';
$sql3 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone_link` AS zl ON (a.address_country =
zl.zone_parent_namekey) '.
'JOIN `#__hikashop_zone` AS hks ON (hks.zone_namekey =
zl.zone_child_namekey AND hks.zone_type = "state" AND
hks.zone_code_3 = a.address_state) '.
'SET address_state = hks.zone_namekey, address_published = 2 WHERE
address_published = 3;';
$sql4 = "UPDATE `#__hikashop_address` AS a SET a.address_country =
'' WHERE address_published > 3;";
$sql5 = "UPDATE `#__hikashop_address` AS a SET a.address_state =
'' WHERE address_published > 2;";
$sql6 = 'UPDATE `#__hikashop_address` AS a SET a.address_published =
1 WHERE address_published > 1;';
$this->db->setQuery($sql0);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Users: ' . $total . '</p>';
$this->db->setQuery($sql1);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses: ' . $total . '</p>';
$this->db->setQuery($sql2);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses countries: ' . $total . '</p>';
$this->db->setQuery($sql3);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses states: ' . $total . '</p>';
$this->db->setQuery($sql4);
$this->db->query();
$this->db->setQuery($sql5);
$this->db->query();
$this->db->setQuery($sql6);
$this->db->query();
$ret = true;
return $ret;
}
function importOrders()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
10 :</span>Â Import Orders</p>';
$ret = false;
$offset = $this->options->current;
$count = 100;
$total = 0;
$vat_cols = "''";
$data = array(
'order_number' => 'mjo.order_id',
'order_mijo_id' => 'mjo.order_id',
'order_user_id' => 'hkusr.user_id',
'order_status' => 'hkc.category_name',
'order_created' => 'mjo.date_added',
'order_ip' => 'mjo.ip',
'order_currency_id' => 'hkcur.currency_id',
'order_shipping_price' => "''", //?
'order_shipping_method' =>
'mjo.shipping_method',
'order_shipping_id' => '1',
'order_payment_id' => 0,
'order_payment_method' => 'mjo.payment_method',
'order_full_price' => 'mjot.value',
'order_modified' => 'mjo.date_modified',
'order_partner_id' => 0,
'order_partner_price' => 0,
'order_partner_paid' => 0,
'order_type' => "'sale'",
'order_partner_currency_id' => 0,
'order_shipping_tax' => "''", //?
'order_discount_tax' => 0
);
$sql1 = 'INSERT IGNORE INTO `#__hikashop_order`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__mijoshop_order` AS mjo '.
'INNER JOIN `#__mijoshop_order_product` mjop ON mjop.order_id =
mjo.order_id '.
'INNER JOIN `#__mijoshop_order_status` AS mjos ON
mjo.order_status_id = mjos.order_status_id '.
'INNER JOIN `#__hikashop_category` AS hkc ON mjos.name =
hkc.category_name AND hkc.category_type = \'status\' '.
'INNER JOIN `#__hikashop_currency` AS hkcur ON
CONVERT(mjo.currency_code USING utf8) = CONVERT(hkcur.currency_code USING
utf8) '.
'INNER JOIN `#__mijoshop_order_total` mjot ON mjo.order_id =
mjot.order_id AND code=\'total\' '.
'INNER JOIN `#__mijoshop_juser_ocustomer_map` mjju ON
mjo.customer_id = mjju.ocustomer_id '.
'INNER JOIN `#__users` u ON mjju.juser_id = u.id '.
'INNER JOIN `#__hikashop_user` AS hkusr ON mjju.juser_id =
hkusr.user_cms_id '.
'WHERE mjo.order_id > ' .
(int)$this->options->last_mijo_order . ' '.
'GROUP BY mjo.order_id '.
'ORDER BY mjo.order_id ASC;';
$sql1_1 = 'UPDATE `#__hikashop_order` AS hko '.
'INNER JOIN `#__mijoshop_voucher` AS mjv ON hko.order_mijo_id =
mjv.order_id '.
'INNER JOIN `#__hikashop_discount` AS hkd ON hkd.discount_code =
mjv.code '.
'SET hko.order_discount_code = hkd.discount_code AND
hko.order_discount_price = hkd.discount_flat_amount';
$data = array(
'address_user_id' => 'mjo.customer_id',
'address_firstname' => 'mjo.payment_firstname',
'address_lastname' => 'mjo.payment_lastname',
'address_company' => 'mjo.payment_company',
'address_street' =>
'CONCAT(mjo.payment_address_1,\'
\',mjo.payment_address_2)',
'address_post_code' => 'mjo.payment_postcode',
'address_city' => 'mjo.payment_city ',
'address_telephone' => 'mjo.telephone',
'address_fax' => 'mjo.fax',
'address_state' => 'hkzsta.zone_namekey',
'address_country' => 'hkzcou.zone_namekey',
'address_published' => '7',
'address_vat' => $vat_cols,
'address_mijo_order_info_id' => 'mjo.order_id'
//8
);
$sql2_1 = 'INSERT IGNORE INTO `#__hikashop_address`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__mijoshop_order` AS mjo '.
'INNER JOIN `#__mijoshop_country` AS mjc ON mjo.payment_country_id
= mjc.country_id '.
'INNER JOIN `#__mijoshop_zone` AS mjz ON mjo.payment_zone_id =
mjz.zone_id '.
'INNER JOIN `#__hikashop_zone` AS hkzcou ON mjc.iso_code_3 =
hkzcou.zone_code_3 AND hkzcou.zone_type=\'country\' '.
'INNER JOIN `#__hikashop_zone_link` AS hkzl ON hkzcou.zone_namekey
= hkzl.zone_parent_namekey '.
'INNER JOIN `#__hikashop_zone` AS hkzsta ON mjz.code =
hkzsta.zone_code_3 AND hkzsta.zone_type=\'state\' AND
hkzsta.zone_namekey = hkzl.zone_child_namekey '.
'WHERE mjo.order_id > ' .
(int)$this->options->last_mijo_order;
$sql2_2 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone` AS hkz ON (a.address_country =
hkz.zone_code_3 AND hkz.zone_type = "country") '.
'SET address_country = hkz.zone_namekey, address_published = 6
WHERE address_published >= 7;';
$sql2_3 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone_link` AS zl ON (a.address_country =
zl.zone_parent_namekey) '.
'JOIN `#__hikashop_zone` AS hks ON (hks.zone_namekey =
zl.zone_child_namekey AND hks.zone_type = "state" AND
hks.zone_code_3 = a.address_state) '.
'SET address_state = hks.zone_namekey, address_published = 5 WHERE
address_published = 6;';
$sql2_4 = 'UPDATE `#__hikashop_address` AS a '.
'SET address_published = 0 WHERE address_published > 4;';
$sql3 = 'UPDATE `#__hikashop_order` AS o '.
'INNER JOIN `#__hikashop_address` AS a ON
a.address_mijo_order_info_id = o.order_mijo_id '.
'SET o.order_billing_address_id = a.address_id,
o.order_shipping_address_id = a.address_id '.
"WHERE o.order_billing_address_id = 0 AND address_published >= 7
;";
$sql4 = 'UPDATE `#__hikashop_order` AS o '.
'INNER JOIN `#__hikashop_address` AS a ON
a.address_mijo_order_info_id = o.order_mijo_id '.
'SET o.order_shipping_address_id = a.address_id '.
"WHERE o.order_shipping_address_id = 0 AND address_published >=
8 ;";
$sql5 = 'UPDATE `#__hikashop_order` AS hko '.
'JOIN `#__mijoshop_order` AS mjo ON hko.order_mijo_id =
mjo.order_id '.
"SET hko.order_payment_method = CONCAT('mijo import: ',
mjo.payment_method) ".
'WHERE hko.order_mijo_id > ' .
(int)$this->options->last_mijo_order;
$this->db->setQuery($sql1);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported orders: ' . $total . '</p>';
$this->db->setQuery($sql1_1);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating discount orders: ' . $total . '</p>';
$this->db->setQuery($sql2_1);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported orders addresses: ' . $total . '</p>';
$this->db->setQuery($sql3);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating billing addresses: ' . $total . '</p>';
$this->db->setQuery($sql4);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating shipping addresses: ' . $total . '</p>';
$this->db->setQuery($sql5);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating order payments: ' . $total . '</p>';
$this->db->setQuery($sql2_2);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating orders: ' . $total;
$this->db->setQuery($sql2_3);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '/' . $total;
$this->db->setQuery($sql2_4);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '/' . $total . '</p>';
$ret = true;
return $ret;
}
function importOrderItems()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
11 :</span>Â Import Order Items</p>';
$ret = false;
$offset = $this->options->current;
$count = 100;
$data = array(
'order_id' => 'hko.order_id',
'product_id' => 'hkp.hk_id',
'order_product_quantity' => 'mjop.quantity',
'order_product_name' => 'mjop.name',
'order_product_code' => 'mjp.hika_sku',
'order_product_price' => 'mjop.price',
'order_product_tax' => 'mjop.tax',
'order_product_options' => "''"
);
$sql = 'INSERT IGNORE INTO `#__hikashop_order_product`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__mijoshop_order_product` AS mjop '.
'INNER JOIN `#__mijoshop_product` mjp ON
mjop.product_id=mjp.product_id '.
'INNER JOIN `#__hikashop_order` AS hko ON mjop.order_id =
hko.order_mijo_id '.
'INNER JOIN `#__hikashop_mijo_prod` AS hkp ON hkp.mijo_id =
mjop.product_id '.
'WHERE mjop.order_id > ' .
(int)$this->options->last_mijo_order . ';';
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Orders Items : '. $total .'</p>';
$ret = true;
return $ret;
}
function importDownloads()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
12 :</span>Â Import Downloads</p>';
$ret = false;
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$count = 100;
$offset = $this->options->current;
if( $offset == 0 )
$offset = $this->options->last_mijo_pfile;
$sql = "SELECT `config_value` FROM `#__hikashop_config` WHERE
config_namekey = 'download_number_limit';";
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$dl_limit = $data[0]->config_value;
$sql = 'SELECT mjd.download_id, mjd.filename FROM
`#__mijoshop_download` AS mjd WHERE mjd.download_id >
'.$offset.';'; //Why no Mask FFS
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$max = 0;
if (!empty($data))
{
$this->copyDownloadDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode($this->copyDownloadDir)),DS.'
').DS);
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying downloads files... </p>';
foreach($data as $c)
{
$file_name =
end(explode('/',str_replace('\\','/',$c->filename)));
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$dstFolder = $this->options->uploadfolder; //secure ?
$this->copyFile($this->copyDownloadDir, $c->filename,
$dstFolder.$file_name);
$max = $c->download_id;
}
if( $max > 0 )
{
echo '<p>Copying files...<br/>(Last processed file id:
' . $max . '</p>';
$this->options->current = $max;
$this->refreshPage = true;
return $ret;
}
}
$data = array(
'file_name' => 'mjdd.name',
'file_description' => "''",
'file_path' => "SUBSTRING_INDEX(mjd.filename
,'/',-1)", //Why no filename ?
'file_type' => "'file'",
'file_ref_id' => 'hkmjp.hk_id'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_file`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__mijoshop_download` AS mjd '.
'INNER JOIN `#__mijoshop_download_description` mjdd ON
mjd.download_id = mjdd.download_id '.
'LEFT JOIN `#__mijoshop_product_to_download` mjpd ON mjd.download_id
= mjpd.download_id '.
'LEFT JOIN `#__hikashop_mijo_prod` AS hkmjp ON mjpd.product_id =
hkmjp.mijo_id '.
'WHERE mjd.download_id >
'.$this->options->last_mijo_pfile;
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Downloable files imported : ' . $total . '</p>';
$data = array(
'file_id' => 'hkf.file_id',
'order_id' => 'hko.order_id',
'download_number' => '(' . $dl_limit . '-
mjd.remaining)' //$dl_limit ?
);
$sql = 'INSERT IGNORE INTO `#__hikashop_download`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__mijoshop_download` AS mjd '.
'INNER JOIN `#__mijoshop_download_description` mjdd ON
mjd.download_id = mjdd.download_id '.
'INNER JOIN `#__hikashop_file` AS hkf ON ( CONVERT(hkf.file_name
USING utf8) = CONVERT(mjdd.name USING utf8) )'.
'INNER JOIN `#__mijoshop_product_to_download` AS mjpd ON
mjd.download_id = mjpd.download_id '.
'INNER JOIN `#__mijoshop_order_product` AS mjop ON mjpd.product_id
= mjop.product_id '.
'INNER JOIN `#__hikashop_order` AS hko ON hko.order_mijo_id =
mjop.order_id '.
'WHERE mjd.download_id >
'.$this->options->last_mijo_pfile;
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Downloable order files imported : ' . $total .
'</p>';
$ret = true;
return $ret;
}
function importDiscount()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
9 :</span>Â Import Discount</p>';
$ret = false;
$sql = "SELECT `config_value` FROM `#__hikashop_config` WHERE
config_namekey = 'main_currency';";
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$main_currency = $data[0]->config_value;
$data = array(
'discount_type' => "'coupon'",
'discount_start' => 'date_start',
'discount_end' => 'date_end',
'discount_quota' => 'uses_total',
'discount_quota_per_user' => 'uses_customer',
'discount_published' => 'status',
'discount_code' => 'code',
'discount_currency_id' => $main_currency,
'discount_flat_amount' => "case when type =
'F' then discount else 0 end",
'discount_percent_amount' => "case when type =
'P' then discount else 0 end",
'discount_quota' => '0'
);
$sql = 'INSERT IGNORE INTO #__hikashop_discount
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
#__mijoshop_coupon WHERE coupon_id > ' .
(int)$this->options->last_mijo_coupon;
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Discount codes/coupons imported : ' . $total .
'</p>';
$data = array(
'discount_type' => "'coupon'",
'discount_code' => 'code',
'discount_currency_id' => $main_currency,
'discount_flat_amount' => 'amount',
'discount_percent_amount' => '0',
'discount_published' => 'status',
);
$sql = 'INSERT IGNORE INTO #__hikashop_discount
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
#__mijoshop_voucher WHERE voucher_id > ' .
(int)$this->options->last_mijo_voucher;
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Vouchers imported : ' . $total . '</p>';
$ret = true;
return $ret;
}
function importCurrencies()
{
if( $this->db == null )
return false;
$this->db->setQuery('UPDATE `#__hikashop_currency` AS hkcur
'.
'INNER JOIN `#__mijoshop_currency` mjc ON CONVERT(mjc.code USING
utf8) = CONVERT( hkcur.currency_code USING utf8) '.
'SET hkcur.currency_rate = mjc.value'
);
$ret = $this->db->query();
$cpt = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Currencies values imported : ' . $cpt .'</p>';
return true;
}
function finishImport()
{
$this->db->setQuery("SELECT max(category_id) as
'max' FROM `#__hikashop_category`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(product_id) as 'max'
FROM `#__hikashop_product`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_prod = (int)($data[0]->max);
$this->db->setQuery("SELECT max(mijo_id) as 'max'
FROM `#__hikashop_mijo_cat`;");
$data = $this->db->loadObjectList();
$this->options->last_mijo_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(mijo_id) as 'max'
FROM `#__hikashop_mijo_prod`;");
$data = $this->db->loadObjectList();
$this->options->last_mijo_prod = (int)($data[0]->max);
$this->db->setQuery("SELECT max(customer_id) as
'max' FROM `#__mijoshop_customer`;");
$data = $this->db->loadObjectList();
$this->options->last_mijo_user = (int)($data[0]->max);
$this->db->setQuery("SELECT max(order_mijo_id) as
'max' FROM `#__hikashop_order`;");
$data = $this->db->loadObjectList();
$this->options->last_mijo_order = (int)($data[0]->max);
$this->db->setQuery("SELECT max(mjpi.product_image_id) as
'max' FROM `#__mijoshop_product_image` mjpi INNER JOIN
`#__mijoshop_product` mjp ON mjpi.product_id = mjp.product_id");
$data = $this->db->loadObject();
$this->options->last_mijo_pfile = (int)($data->max);
$this->db->setQuery("SELECT max(coupon_id) as 'max'
FROM `#__mijoshop_coupon`;");
$data = $this->db->loadObject();
$this->options->last_mijo_coupon = (int)($data->max);
$this->db->setQuery("SELECT max(voucher_id) as 'max'
FROM `#__mijoshop_voucher`;");
$data = $this->db->loadObject();
$this->options->last_mijo_voucher = (int)($data->max);
$this->db->setQuery("SELECT max(tax_rate_id) as
'max' FROM `#__mijoshop_tax_rate`;");
$data = $this->db->loadObject();
$this->options->last_mijo_taxrate = (int)($data->max);
$this->db->setQuery("SELECT max(tax_class_id) as
'max' FROM `#__mijoshop_tax_class`;");
$data = $this->db->loadObject();
$this->options->last_mijo_taxclass = (int)($data->max);
$this->db->setQuery("SELECT max(manufacturer_id) as
'max' FROM `#__mijoshop_manufacturer`;");
$data = $this->db->loadObjectList();
$this->options->last_mijo_manufacturer = (int)($data[0]->max);
$this->options->state = (MAX_IMPORT_ID+1);
$query = 'REPLACE INTO `#__hikashop_config`
(`config_namekey`,`config_value`,`config_default`) VALUES '.
"('mijo_import_state',".$this->options->state.",".$this->options->state.")".
",('mijo_import_max_hk_cat',".$this->options->max_hk_cat.",".$this->options->max_hk_cat.")".
",('mijo_import_max_hk_prod',".$this->options->max_hk_prod.",".$this->options->max_hk_prod.")".
",('mijo_import_last_mijo_cat',".$this->options->last_mijo_cat.",".$this->options->last_mijo_cat.")".
",('mijo_import_last_mijo_prod',".$this->options->last_mijo_prod.",".$this->options->last_mijo_prod.")".
",('mijo_import_last_mijo_user',".$this->options->last_mijo_user.",".$this->options->last_mijo_user.")".
",('mijo_import_last_mijo_order',".$this->options->last_mijo_order.",".$this->options->last_mijo_order.")".
",('mijo_import_last_mijo_pfile',".$this->options->last_mijo_pfile.",".$this->options->last_mijo_pfile.")".
",('mijo_import_last_mijo_coupon',".$this->options->last_mijo_coupon.",".$this->options->last_mijo_coupon.")".
",('mijo_import_last_mijo_voucher',".$this->options->last_mijo_voucher.",".$this->options->last_mijo_voucher.")".
",('mijo_import_last_mijo_taxrate',".$this->options->last_mijo_taxrate.",".$this->options->last_mijo_taxrate.")".
",('mijo_import_last_mijo_taxclass',".$this->options->last_mijo_taxclass.",".$this->options->last_mijo_taxclass.")".
",('mijo_import_last_mijo_manufacturer',".$this->options->last_mijo_manufacturer.",".$this->options->last_mijo_manufacturer.")".
';';
$this->db->setQuery($query);
$this->db->query();
echo '<p'.$this->titlefont.'>Import finished
!</p>';
$class = hikashop_get('class.plugins');
$infos =
$class->getByName('system','mijo_redirect');
if($infos)
{
$pkey = reset($class->pkeys);
if(!empty($infos->$pkey))
{
if(version_compare(JVERSION,'1.6','<'))
$url =
JRoute::_('index.php?option=com_plugins&view=plugin&client=site&task=edit&cid[]='.$infos->$pkey);
else
$url =
JRoute::_('index.php?option=com_plugins&view=plugin&layout=edit&extension_id='.$infos->$pkey);
echo '<p>You can publish the
<a'.$this->linkstyle.'
href="'.$url.'">Mijoshop Fallback Redirect
Plugin</a> so that your old Mijoshop links are automatically
redirected to HikaShop pages and thus not loose the ranking of your content
on search engines.</p>';
}
}
}
}
importopenc.php000064400000207451151162557620007637 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopImportopencHelper extends hikashopImportHelper
{
var $hikaDatabaseName;
var $opencDatabase;
var $opencRootPath;
var $sessionParams;
var $importcurrencies;
function __construct()
{
parent::__construct();
$this->importName = 'openc';
$this->copyImgDir = '';
$this->copyCatImgDir = '';
$this->copyDownloadDir = '';
$this->copyManufDir = '';
$this->sessionParams = HIKASHOP_COMPONENT.'openc';
jimport('joomla.filesystem.file');
}
function importFromOpenc()
{
@ob_clean();
echo $this->getHtmlPage();
$this->token = hikashop_getFormToken();
flush();
if( isset($_GET['import']) && $_GET['import']
== '1' )
{
$app = JFactory::getApplication();
$this->opencDatabase =
$app->getUserState($this->sessionParams.'dbName');
$this->opencRootPath =
$app->getUserState($this->sessionParams.'rootPath');
$this->hikaDatabaseName = $config->getValue( 'db' );
$this->importcurrencies =
$app->getUserState($this->sessionParams.'importcurrencies');
(!empty($this->opencRootPath) &&
substr($this->opencRootPath, -1))=='/' ? $includestring =
'admin/config.php' : $includestring .=
'/admin/config.php';
if (!empty($this->opencRootPath))
include($this->opencRootPath . $includestring);
$time = microtime(true);
$processed = $this->doImport();
if( $processed )
{
$elasped = microtime(true) - $time;
if( !$this->refreshPage )
echo
'<p></br><a'.$this->linkstyle.'href="'.hikashop_completeLink('import&task=import&importfrom=openc&'.$this->token.'=1&import=1').'">'.JText::_('HIKA_NEXT').'</a></p>';
echo '<p style="font-size:0.85em;
color:#605F5D;">Elasped time: ' . round($elasped * 1000, 2) .
'ms</p>';
}
else
{
echo
'<a'.$this->linkstyle.'href="'.hikashop_completeLink('import&task=show').'">'.JText::_('HIKA_BACK').'</a>';
}
}
else
{
echo $this-> getStartPage();
}
if( $this->refreshPage )
{
echo "<script type=\"text/javascript\">\r\nr =
true;\r\n</script>";
}
echo '</body></html>';
exit;
}
function getStartPage()
{
$app = JFactory::getApplication();
$database = JFactory::getDBO();
$returnString = '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
0</span></p>';
$continue = true;
$this->opencDatabase =
$app->getUserStateFromRequest($this->sessionParams.'dbName',
'opencDbName', '', 'string' );
//getUserStateFromRequest( 'keyFromSession',
'keyFromRequest', '', 'typeKey' ) -
JRequest::getString()
$this->opencRootPath =
$app->getUserStateFromRequest($this->sessionParams.'rootPath',
'opencRootPath', '', 'string' );
$config =& JFactory::getConfig();
$this->hikaDatabaseName = $config->getValue( 'db' );
$this->importcurrencies =
$app->getUserStateFromRequest($this->sessionParams.'importcurrencies',
'import_currencies', '', 'string' );
if (empty($this->opencDatabase))
{
$returnString .= '<p style="color:red">Please
specify a name for your Opencart Database.</p>';
}
else
{
$query = 'SHOW TABLES FROM '.$this->opencDatabase.'
LIKE
'.$database->Quote(substr(hikashop_table('oc_product',false),3)).';';
try
{
$database->setQuery($query);
$table = $database->loadResult();
}
catch(Exception $e)
{
$returnString .= '<p style="color:red">Error with
the openning of the `'.$this->opencDatabase.'`
database.</br><span style="font-size:0.75em">Mysql
Error :'.$e.'</span></p>';
$continue = false;
}
if ($continue)
{
if (empty($table))
$returnString .= '<p style="color:red">Opencart
has not been found in the database you specified :
'.$this->opencDatabase.'</p>';
else
$returnString .= 'The import will now start from the database
`'.$this->opencDatabase.'`.</br>First, make a backup of
your databases.<br/>'.
'When ready, click on <a '.$this->linkstyle.'
href="'.hikashop_completeLink('import&task=import&importfrom=openc&'.$this->token.'=1&import=1').'">'.JText::_('HIKA_NEXT').'</a>,
otherwise ';
}
}
$returnString .= '<a'.$this->linkstyle.'
href="'.hikashop_completeLink('import&task=show').'">'.JText::_('HIKA_BACK').'</a>';
return $returnString;
}
function doImport()
{
if( $this->db == null )
return false;
$this->loadConfiguration();
$current = $this->options->current;
$ret = true;
$next = false;
switch($this->options->state)
{
case 0:
$next = $this->createTables();
break;
case 1:
$next = $this->importTaxes();
break;
case 2:
$next = $this->importManufacturers();
break;
case 3:
$next = $this->importCategories();
break;
case 4:
$next = $this->importProducts();
break;
case 5:
$next = $this->importProductPrices();
break;
case 6:
$next = $this->importProductCategory();
break;
case 7:
$next = $this->importUsers();
break;
case 8:
$next = $this->importDiscount();
break;
case 9:
$next = $this->importOrders();
break;
case 10:
$next = $this->importOrderItems();
break;
case 11:
$next = $this->importDownloads();
break;
case MAX_IMPORT_ID:
$next = $this->finishImport();
$ret = false;
break;
case MAX_IMPORT_ID+1:
$next = false;
$ret = $this->proposeReImport();
break;
default:
$ret = false;
break;
}
if( $ret && $next )
{
$sql = "UPDATE `#__hikashop_config` SET
config_value=(config_value+1) WHERE config_namekey =
'openc_import_state'; ";
$this->db->setQuery($sql);
$this->db->query();
$sql = "UPDATE `#__hikashop_config` SET config_value=0 WHERE
config_namekey = 'openc_import_current';";
$this->db->setQuery($sql);
$this->db->query();
}
else if( $current != $this->options->current )
{
$sql = "UPDATE `#__hikashop_config` SET
config_value=".$this->options->current." WHERE
config_namekey = 'openc_import_current';";
$this->db->setQuery($sql);
$this->db->query();
}
return $ret;
}
function loadConfiguration()
{
$this->options = null;
$firsttime = false;
$data = array(
'uploadfolder',
'uploadsecurefolder',
'main_currency',
'openc_import_state',
'openc_import_current',
'openc_import_tax_id',
'openc_import_main_cat_id',
'openc_import_max_hk_cat',
'openc_import_max_hk_prod',
'openc_import_last_openc_cat',
'openc_import_last_openc_prod',
'openc_import_last_openc_user',
'openc_import_last_openc_order',
'openc_import_last_openc_pfile',
'openc_import_last_openc_coupon',
'openc_import_last_openc_voucher',
'openc_import_last_openc_taxrate',
'openc_import_last_openc_taxclass',
'openc_import_last_openc_manufacturer',
'openc_import_max_joomla_user'
);
$this->db->setQuery('SELECT config_namekey, config_value FROM
`#__hikashop_config` WHERE config_namekey IN
('."'".implode("','",$data)."'".');');
$result = $this->db->loadObjectList();
if (!empty($result))
{
foreach($result as $o)
{
if( substr($o->config_namekey, 0, 13) == 'openc_import_'
)
$nk = substr($o->config_namekey, 13);
else
$nk = $o->config_namekey;
$this->options->$nk = $o->config_value;
}
}
else
{
$firsttime = true;
}
$this->options->uploadfolder =
rtrim(JPath::clean(html_entity_decode($this->options->uploadfolder)),DS.'
').DS;
if(!preg_match('#^([A-Z]:)?/.*#',$this->options->uploadfolder)){
if(!$this->options->uploadfolder[0]=='/' ||
!is_dir($this->options->uploadfolder)){
$this->options->uploadfolder =
JPath::clean(HIKASHOP_ROOT.DS.trim($this->options->uploadfolder,DS.'
').DS);
}
}
$this->options->uploadsecurefolder =
rtrim(JPath::clean(html_entity_decode($this->options->uploadsecurefolder)),DS.'
').DS;
if(!preg_match('#^([A-Z]:)?/.*#',$this->options->uploadsecurefolder)){
if(!$this->options->uploadsecurefolder[0]=='/' ||
!is_dir($this->options->uploadsecurefolder)){
$this->options->uploadsecurefolder =
JPath::clean(HIKASHOP_ROOT.DS.trim($this->options->uploadsecurefolder,DS.'
').DS);
}
}
if( $firsttime )
{
$this->options->state = 0;
$this->options->current = 0;
$this->options->tax_id = 0;
$this->options->last_openc_coupon = 0;
$this->options->last_openc_voucher = 0;
$this->options->last_openc_pfile = 0;
$this->options->last_openc_taxrate = 0;
$this->options->last_openc_taxclass = 0;
$this->options->last_openc_manufacturer = 0;
$element = 'product';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$this->options->main_cat_id = $element;
$this->db->setQuery("SELECT max(category_id) as
'max' FROM `#__hikashop_category`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(product_id) as
'max' FROM `#__hikashop_product`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_prod = (int)($data[0]->max);
$this->db->setQuery("SELECT max(id) as 'max' FROM
`#__users`;");
$data = $this->db->loadObjectList();
$this->options->max_joomla_user = (int)($data[0]->max);
$query='SHOW TABLES LIKE
'.$this->db->Quote($this->db->getPrefix().substr(hikashop_table('openc_cat'),3));
$this->db->setQuery($query);
$table = $this->db->loadResult();
if(!empty($table))
{
$this->db->setQuery("SELECT max(openc_id) as 'max'
FROM `#__hikashop_openc_cat`;");
$data = $this->db->loadObjectList();
if( $data )
$this->options->last_openc_cat = (int)($data[0]->max);
else
$this->options->last_openc_cat = 0;
$this->db->setQuery("SELECT max(openc_id) as 'max'
FROM `#__hikashop_openc_prod`;");
$data = $this->db->loadObjectList();
if( $data )
$this->options->last_openc_prod = (int)($data[0]->max);
else
$this->options->last_openc_prod = 0;
$this->db->setQuery("SELECT max(order_openc_id) as
'max' FROM `#__hikashop_order`;");
$data = $this->db->loadObjectList();
if( $data )
$this->options->last_openc_order = (int)($data[0]->max);
else
$this->options->last_openc_order = 0;
}
else
{
$this->options->last_openc_cat = 0;
$this->options->last_openc_prod = 0;
$this->options->last_openc_order = 0;
}
$this->options->last_openc_user = 0;
$sql = 'INSERT IGNORE INTO `#__hikashop_config`
(`config_namekey`,`config_value`,`config_default`) VALUES '.
"('openc_import_state',".$this->options->state.",".$this->options->state.")".
",('openc_import_current',".$this->options->current.",".$this->options->current.")".
",('openc_import_tax_id',".$this->options->tax_id.",".$this->options->tax_id.")".
",('openc_import_main_cat_id',".$this->options->main_cat_id.",".$this->options->main_cat_id.")".
",('openc_import_max_hk_cat',".$this->options->max_hk_cat.",".$this->options->max_hk_cat.")".
",('openc_import_max_joomla_user',".$this->options->max_joomla_user.",".$this->options->max_joomla_user.")".
",('openc_import_max_hk_prod',".$this->options->max_hk_prod.",".$this->options->max_hk_prod.")".
",('openc_import_last_openc_cat',".$this->options->last_openc_cat.",".$this->options->last_openc_cat.")".
",('openc_import_last_openc_prod',".$this->options->last_openc_prod.",".$this->options->last_openc_prod.")".
",('openc_import_last_openc_user',".$this->options->last_openc_user.",".$this->options->last_openc_user.")".
",('openc_import_last_openc_order',".$this->options->last_openc_order.",".$this->options->last_openc_order.")".
",('openc_import_last_openc_pfile',".$this->options->last_openc_pfile.",".$this->options->last_openc_pfile.")".
",('openc_import_last_openc_coupon',".$this->options->last_openc_coupon.",".$this->options->last_openc_coupon.")".
",('openc_import_last_openc_voucher',".$this->options->last_openc_voucher.",".$this->options->last_openc_voucher.")".
",('openc_import_last_openc_taxrate',".$this->options->last_openc_taxrate.",".$this->options->last_openc_taxrate.")".
",('openc_import_last_openc_taxclass',".$this->options->last_openc_taxclass.",".$this->options->last_openc_taxclass.")".
",('openc_import_last_openc_manufacturer',".$this->options->last_openc_manufacturer.",".$this->options->last_openc_manufacturer.")".
';';
$this->db->setQuery($sql);
$this->db->query();
}
}
function createTables()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
1 :</span>Â Initialization Tables</p>';
$create = true;
$query='SHOW TABLES LIKE
'.$this->db->Quote($this->db->getPrefix().substr(hikashop_table('openc_cat'),3));
$this->db->setQuery($query);
$table = $this->db->loadResult();
if (!empty($table))
$create = false;
if ($create)
{
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_openc_prod` (`openc_id` int(11) unsigned NOT NULL DEFAULT
'0', `hk_id` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`openc_id`)) ENGINE=MyISAM");
$this->db->query();
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_openc_cat` (`openc_cat_id` INT(11) unsigned NOT NULL
AUTO_INCREMENT, `openc_id` int(11) unsigned NOT NULL DEFAULT '0',
`hk_id` int(11) unsigned NOT NULL DEFAULT '0', `category_type`
varchar(255) NULL, PRIMARY KEY (`openc_cat_id`)) ENGINE=MyISAM");
$this->db->query();
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_openc_user` (`openc_user_id` int(11) unsigned NOT NULL DEFAULT
'0', `hk_user_cms_id` int(11) unsigned NOT NULL DEFAULT
'0', PRIMARY KEY (`openc_user_id`)) ENGINE=MyISAM");
$this->db->query();
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_openc_customer` (`openc_customer_id` int(11) unsigned NOT NULL
DEFAULT '0', `hk_customer_cms_id` int(11) unsigned NOT NULL
DEFAULT '0', PRIMARY KEY (`openc_customer_id`))
ENGINE=MyISAM");
$this->db->query();
$this->db->setQuery('ALTER IGNORE TABLE `#__hikashop_address`
ADD `address_openc_order_info_id` INT(11) NULL');
$this->db->query();
$this->db->setQuery('ALTER IGNORE TABLE `#__hikashop_order`
ADD `order_openc_id` INT(11) NULL');
$this->db->query();
$this->db->setQuery('ALTER IGNORE TABLE `#__hikashop_order`
ADD INDEX ( `order_openc_id` )');
$this->db->query();
$this->db->setQuery('ALTER IGNORE TABLE
`#__hikashop_taxation` ADD `tax_openc_id` INT(11) NULL');
$this->db->query();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
All table created</p>';
}
else
{
echo '<p>Tables have been already created.</p>';
}
return true;
}
function importTaxes()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
2 :</span>Â Import Taxes<p>';
$ret = false;
$data = array(
'tax_namekey' => "CONCAT('OPENC_TAX_',
octr.tax_rate_id)",
'tax_rate' => 'octr.rate'
);
$sql = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_tax`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`oc_tax_rate` AS octr '.
'WHERE octr.tax_rate_id > ' .
(int)$this->options->last_openc_taxrate;
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported taxes: ' . $total . '</p>';
$element = 'tax';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$data = array(
'category_type' => "'tax'",
'category_name' => "CONCAT('Tax imported
(', octc.title,')')",
'category_published' => '1',
'category_parent_id' => $element,
'category_namekey' => "
CONCAT('OPENC_TAX_CATEGORY_', octc.tax_class_id)"
);
$sql = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`oc_tax_class` AS octc ';
'WHERE octc.tax_class_id > ' .
(int)$this->options->last_openc_taxclass;
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Taxes Categories: ' . $total . '</p>';
if( $total > 0 ) {
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'openc_import_max_hk_cat'; ");
$this->db->query();
$this->importRebuildTree();
}
$data = array(
'zone_namekey' => "case when hkz.zone_namekey IS NULL
then '' else hkz.zone_namekey end",
'category_namekey' =>
"CONCAT('OPENC_TAX_CATEGORY_', octc.tax_class_id)",
//"case when hkz.zone_id IS NULL then CONCAT('openc_TAX_',
octr.tax_rate_id,'_0') else CONCAT('openc_TAX_',
octr.tax_rate_id,'_',hkz.zone_id) end",
'tax_namekey' => "CONCAT('OPENC_TAX_',
octra.tax_rate_id)",
'taxation_published' => '1',
'taxation_type' => "''",
'tax_openc_id' => 'octc.tax_class_id'
//'octra.tax_rate_id' See import product
);
$sql = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_taxation`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`oc_tax_class` AS octc '.
'INNER JOIN `'.$this->opencDatabase.'`.`oc_tax_rule`
AS octr ON octc.tax_class_id = octr.tax_class_id '.
'INNER JOIN `'.$this->opencDatabase.'`.`oc_tax_rate`
AS octra ON octr.tax_rate_id = octra.tax_rate_id '.
'LEFT JOIN
`'.$this->opencDatabase.'`.`oc_zone_to_geo_zone` AS ocz ON
octra.geo_zone_id = ocz.geo_zone_id '.
'LEFT JOIN `'.$this->opencDatabase.'`.`oc_country` AS
occ ON ocz.country_id = occ.country_id ' .
"LEFT JOIN
`".$this->hikaDatabaseName."`.`#__hikashop_zone` hkz ON
occ.iso_code_3 = hkz.zone_code_3 AND hkz.zone_type = 'country'
".
'WHERE octra.tax_rate_id > ' .
(int)$this->options->last_openc_taxrate;
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Taxations: ' . $total . '</p>';
$ret = true;
return $ret;
}
function importManufacturers()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
3 :</span>Â Import Manufacturers</p>';
$ret = false;
$count = 100;
$rebuild = false;
$sql1 = 'SELECT * FROM
`'.$this->opencDatabase.'`.`oc_manufacturer` ocm '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_cat` hkoc ON
ocm.manufacturer_id = hkoc.openc_id AND
category_type=\'manufacturer\' '.
'WHERE ocm.manufacturer_id > ' .
(int)$this->options->last_openc_manufacturer;
'ORDER BY ocm.manufacturer_id ASC;';
$this->db->setQuery($sql1);
$this->db->query();
$datas = $this->db->loadObjectList();
$sql2 = 'INSERT INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_published`,'.
'`category_namekey`,`category_description`,`category_menu`) VALUES
';
$sql3 = 'INSERT INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_cat`
(`openc_id`,`hk_id`,`category_type`) VALUES ';
$sql4 = 'INSERT INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_file`
(`file_name`,`file_description`,`file_path`,`file_type`,`file_ref_id`)
VALUES ';
$doSql3 = false;
$doSql4 = false;
$i = $this->options->max_hk_cat + 1;
$ids = array( 0 => $this->options->main_cat_id);
$sep = '';
$sep2 = '';
$cpt=0;
$echo=false;
if( empty($datas) )
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported manufacturers : 0</p>';
return true;
}
else
{
foreach($datas as $data)
{
if( !empty($data->openc_id) )
{
$ids[$data->manufacturer_id] = $data->hk_id;
}
else
{
$doSql3 = true;
$ids[$data->manufacturer_id] = $i;
$sql3 .=
$sep.'('.$data->manufacturer_id.','.$i.',\'manufacturer\')';
$i++;
$sep = ',';
}
$cpt++;
if( $cpt >= $count )
break;
}
$sql3 .= ';';
$cpt = 0;
$sep = '';
foreach($datas as $data)
{
if( !empty($data->openc_id) )
continue;
$id = $ids[$data->manufacturer_id];
$element = 'manufacturer';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$d = array(
$id,
$element,
"'manufacturer'",
$this->db->quote($data->name),
'1',
"CONCAT('OPENC_MANUFAC_',
".$data->manufacturer_id .")",
"'manufacturer imported from Opencart'",
'0'
);
$sql2 .= $sep.'('.implode(',',$d).')';
if( !empty($data->image) &&
!empty($this->opencRootPath))
{
$this->copyManufDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode(DIR_IMAGE)),DS.'
').DS);
if (!$echo)
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying manufacturers images... </p>';
$echo=true;
}
$doSql4 = true;
$sql4 .=
$sep2."(".$this->db->quote($data->name).",'',".$this->db->quote($data->image).",'category',".$id.')';
$sep2 = ',';
$file_name =
str_replace('\\','/',$data->image);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyManufDir,$data->image,
str_replace('//','/',str_replace('\\','/',$this->options->uploadfolder.$file_name)));
}
$sep = ',';
$cpt++;
if( $cpt >= $count )
break;
}
}
if($cpt > 0)
{
$sql2 .= ';';
$sql4 .= ';';
$this->db->setQuery($sql2);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Manufacturers : ' . $total . '</p>';
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Manufacturers : 0</p>';
}
if( isset($total) && $total > 0)
{
$rebuild = true;
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'openc_import_max_hk_cat'; ");
$this->db->query();
}
if ($doSql3)
{
$this->db->setQuery($sql3);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links : ' . $total . '</p>';
}
if($doSql4)
{
$this->db->setQuery($sql4);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Manufacturers files : ' . $total . '</p>';
}
if( $rebuild )
$this->importRebuildTree();
if( $cpt < $count )
$ret = true;
return $ret;
}
function importCategories()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
4 :</span>Â Import General Categories</p>';
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$rebuild = false;
$ret = false;
$offset = 0;
$count = 100;
$cpt = 0;
$sep = '';
$sep2 = '';
$echo = false;
$statuses = array(
'P' => 'created',
'C' => 'confirmed',
'X' => 'cancelled',
'R'=> 'refunded' ,
'S' => 'shipped'
);
$this->db->setQuery("SELECT category_keywords,
category_parent_id FROM `#__hikashop_category` WHERE category_type =
'status' AND category_name = 'confirmed'");
$data = $this->db->loadObject();
$status_category = $data->category_parent_id;
if( $data->category_keywords != 'C' ) {
foreach($statuses as $k => $v) {
$this->db->setQuery("UPDATE `#__hikashop_category` SET
category_keywords = '".$k."' WHERE category_type =
'status' AND category_name = '".$v."';
");
$this->db->query();
}
}
$this->db->setQuery("SELECT order_status_id, name FROM
`".$this->opencDatabase."`.`oc_order_status` WHERE name NOT IN
('".implode("','",$statuses)."','canceled');");
$data = $this->db->loadObjectList();
if( count($data) > 0 )
{
$sql0 = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_description`,`category_published`,'.
'`category_namekey`,`category_access`,`category_menu`,`category_keywords`)
VALUES ';
$id = $this->options->max_hk_cat + 1;
$sep = '';
foreach($data as $c) {
$d = array(
$id++,
$status_category,
"'status'",
$this->db->quote( strtolower($c->name) ),
"'Order status imported from Opencart'",
'1',
$this->db->quote('status_openc_import_'.strtolower(str_replace('
','_',$c->name))),
"'all'",
'0',
$this->db->quote( $c->order_status_id )
);
$sql0 .= $sep.'('.implode(',',$d).')';
$sep = ',';
}
$this->db->setQuery($sql0);
$this->db->query();
$total = $this->db->getAffectedRows();
if( $total > 0 ) {
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported order status categories : ' . $total .
'</p>';
$rebuild = true;
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'openc_import_max_hk_cat'; ");
$this->db->query();
$sql0 = '';
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported order status categories : 0</p>';
}
}
$sql1 = 'SELECT * FROM
`'.$this->opencDatabase.'`.`oc_category` occ '.
'INNER JOIN
`'.$this->opencDatabase.'`.`oc_category_description` occd ON
occ.category_id = occd.category_id '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_cat` hkoc ON
occ.category_id = hkoc.openc_id AND category_type=\'category\'
'.
'WHERE occ.category_id >
'.$this->options->last_openc_cat.' '.
'ORDER BY occ.parent_id ASC, occ.category_id ASC;';
$this->db->setQuery($sql1);
$this->db->query();
$datas = $this->db->loadObjectList();
$sql2 = 'INSERT INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_description`,`category_published`,'.
'`category_ordering`,`category_namekey`,`category_created`,`category_modified`,`category_access`,`category_menu`)
VALUES ';
$sql3 = 'INSERT INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_cat`
(`openc_id`,`hk_id`,`category_type`) VALUES ';
$sql4 = 'INSERT INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_file`
(`file_name`,`file_description`,`file_path`,`file_type`,`file_ref_id`)
VALUES ';
$doSql3 = false;
$doSql4 = false;
$i = $this->options->max_hk_cat + 1;
$ids = array( 0 => $this->options->main_cat_id);
$sep = '';
if( empty($datas) )
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported category : 0</p>';
if( $rebuild )
$this->importRebuildTree();
return true;
}
else
{
foreach($datas as $data)
{
if( !empty($data->openc_id) )
{
$ids[$data->category_id] = $data->hk_id;
}
else
{
$doSql3 = true;
$ids[$data->category_id] = $i;
$sql3 .=
$sep.'('.$data->category_id.','.$i.',\'category\')';
$i++;
$sep = ',';
}
$cpt++;
if( $cpt >= $count )
break;
}
$sql3 .= ';';
$cpt = 0;
$sep = '';
foreach($datas as $data)
{
if( !empty($data->openc_id) )
continue;
$id = $ids[$data->category_id];
if(!empty($ids[$data->parent_id]))
$pid = (int)$ids[$data->parent_id];
else
$pid = $ids[0];
$element = new stdClass();
$element->category_id = $id;
$element->category_parent_id = $pid;
$element->category_name = $data->name;
$nameKey = $categoryClass->getNameKey($element);
$d = array(
$id,
$pid,
"'product'",
$this->db->quote($data->name),
$this->db->quote($data->description),
'1',
$data->sort_order,
$this->db->quote($nameKey),
"'".$data->date_added."'",
"'".$data->date_modified."'",
"'all'",
'0'
);
$sql2 .= $sep.'('.implode(',',$d).')';
if( !empty($data->image) &&
!empty($this->opencRootPath))
{
$this->copyCatImgDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode(DIR_IMAGE)),DS.'
').DS);
if (!$echo)
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying categories images... </p>';
$echo=true;
}
$doSql4 = true;
$sql4 .=
$sep2."('','','".$data->image."','category',".$id.')';
$sep2 = ',';
$file_name =
str_replace('\\','/',$data->image);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyCatImgDir,$data->image,
str_replace('//','/',str_replace('\\','/',$this->options->uploadfolder.$file_name)));
}
$sep = ',';
$cpt++;
if( $cpt >= $count )
break;
}
}
if($cpt > 0)
{
$sql2 .= ';';
$sql4 .= ';';
$this->db->setQuery($sql2);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Categories : ' . $total . '</p>';
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported category : 0</p>';
}
if( isset($total) && $total > 0)
{
$rebuild = true;
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'openc_import_max_hk_cat'; ");
$this->db->query();
}
if ($doSql3)
{
$this->db->setQuery($sql3);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links : ' . $total . '</p>';
}
if($doSql4)
{
$this->db->setQuery($sql4);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Categories files : ' . $total . '</p>';
}
if( $rebuild )
$this->importRebuildTree();
if( $cpt < $count )
$ret = true;
return $ret;
}
function importProducts()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
5 :</span>Â Import Products</p>';
$ret = false;
$count = 100;
$offset = $this->options->current;
$max = 0;
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$this->db->setQuery('SELECT ocp.product_id, ocpi.image FROM
`'.$this->opencDatabase.'`.`oc_product` ocp '.
'LEFT JOIN
`'.$this->opencDatabase.'`.`oc_product_image` ocpi ON
ocp.product_id = ocpi.product_id '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_prod` hkprod
ON ocp.product_id = hkprod.openc_id '.
"WHERE ocp.product_id > ".(int)$offset." AND
hkprod.hk_id IS NULL AND (ocp.image IS NOT NULL) AND ocp.image <>
'' ".
'ORDER BY product_id ASC LIMIT '.$count.';'
);
$datas = $this->db->loadObjectList();
if (!empty($datas) && !empty($this->opencRootPath))
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying products images... </p>';
$this->copyImgDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode(DIR_IMAGE)),DS.'
').DS);
foreach($datas as $data) {
if( !empty($data->image) ) {
$file_name =
str_replace('\\','/',$data->image);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyImgDir,$data->image,
$this->options->uploadfolder.$file_name);
$max = $data->product_id;
}
}
}
if( $max > 0 )
{
echo '<p>Copying files...(last proccessed product id: '
. $max . ')</p>';
$this->options->current = $max;
$this->refreshPage = true;
return $ret;
}
$data = array(
'product_name' => 'ocpd.name',
'product_description' => 'ocpd.description',
'product_quantity' => 'case when ocp.quantity IS NULL
or ocp.quantity < 0 then 0 else ocp.quantity end',
'product_code' => 'ocp.hika_sku',
'product_published' => 'ocp.status',
'product_hit' => 'ocp.viewed',
'product_created' => 'ocp.date_added',
'product_modified' => 'ocp.date_modified',
'product_sale_start' => 'ocp.date_available',
'product_tax_id' => 'hkc.category_id',
'product_type' => "'main'",
'product_url' => "''",
'product_weight' => 'ocp.weight',
'product_weight_unit' => "LOWER(ocwcd.unit)",
'product_dimension_unit' => "LOWER(oclcd.unit)",
'product_min_per_order' => 'ocp.minimum',
'product_sales' => '0',
'product_width' => 'ocp.width',
'product_length' => 'ocp.length',
'product_height' => 'ocp.height',
'product_parent_id' => '0'
);
$sql1 = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_product`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`oc_product` AS ocp '.
'INNER JOIN
`'.$this->opencDatabase.'`.`oc_weight_class_description` ocwcd
ON ocp.weight_class_id = ocwcd.weight_class_id '.
'INNER JOIN
`'.$this->opencDatabase.'`.`oc_length_class_description` oclcd
ON ocp.length_class_id = oclcd.length_class_id '.
'INNER JOIN
`'.$this->opencDatabase.'`.`oc_product_description` ocpd ON
ocp.product_id = ocpd.product_id '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_taxation` hkt ON
hkt.tax_openc_id = ocp.tax_class_id '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_category` hkc ON
hkc.category_namekey = hkt.category_namekey '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_prod` AS hkp
ON ocp.product_id = hkp.openc_id '.
'WHERE hkp.hk_id IS NULL ORDER BY ocp.product_id ASC;';
$this->db->setQuery("SHOW COLUMNS FROM
`".$this->opencDatabase."`.`oc_product` LIKE
'hika_sku';");
$data = $this->db->loadObjectList();
if (empty($data))
{
$this->db->setQuery('ALTER TABLE
`'.$this->opencDatabase.'`.`oc_product` ADD COLUMN `hika_sku`
VARCHAR(255) NOT NULL;');
$this->db->query();
}
$this->db->setQuery('UPDATE
`'.$this->opencDatabase.'`.`oc_product` AS ocp SET
ocp.hika_sku = ocp.sku;');
$this->db->query();
$this->db->setQuery("UPDATE
`".$this->opencDatabase."`.`oc_product` AS ocp SET
ocp.hika_sku = CONCAT(ocp.model,'_',ocp.product_id) WHERE
ocp.hika_sku='';");
$this->db->query();
$this->db->setQuery('SELECT hika_sku FROM
`'.$this->opencDatabase.'`.`oc_product` GROUP BY hika_sku
HAVING COUNT(hika_sku)>1');
$data = $this->db->loadObjectList();
if (!empty($data))
{
foreach ($data as $d)
{
$this->db->setQuery("UPDATE `oc_product` AS ocp SET
ocp.hika_sku = CONCAT(ocp.hika_sku,'_',ocp.product_id) WHERE
ocp.hika_sku = '".$d->hika_sku."';");
$this->db->query();
}
}
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
SKU generated: '.count($data).'</p>';
$data = array(
'openc_id' => 'ocp.product_id',
'hk_id' => 'hkp.product_id'
);
$sql2 = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_prod`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`oc_product` AS ocp '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_product` AS hkp ON
CONVERT(ocp.hika_sku USING utf8) = CONVERT(hkp.product_code USING utf8)
'.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_prod` hkocp
ON hkocp.openc_id = ocp.product_id '.
'WHERE hkocp.hk_id IS NULL;';
$data = array(
'file_name' => "''",
'file_description' => "''",
'file_path' =>
"SUBSTRING_INDEX(ocpi.image,'/',-1)",
'file_type' => "'product'",
'file_ref_id' => 'hkocp.hk_id'
);
$sql4 = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_file`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`oc_product` AS ocp '.
'INNER JOIN
`'.$this->opencDatabase.'`.`oc_product_image` ocpi ON
ocp.product_id = ocpi.product_id '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_prod` AS
hkocp ON ocp.product_id = hkocp.openc_id '.
'WHERE ocp.product_id >
'.(int)$this->options->last_openc_prod. ' AND (ocpi.image
IS NOT NULL) AND (ocpi.image <>'." '');";
$sql5 = 'UPDATE
`'.$this->hikaDatabaseName.'`.`#__hikashop_product` AS hkp
'.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_prod` AS
hkocp ON hkp.product_id = hkocp.hk_id '.
'INNER JOIN `'.$this->opencDatabase.'`.`oc_product` AS
ocp ON hkocp.openc_id = ocp.product_id '.
"INNER JOIN
`".$this->hikaDatabaseName."`.`#__hikashop_category` AS hkc ON
hkc.category_type = 'manufacturer' AND ocp.manufacturer_id =
hkc.category_menu ".
'SET hkp.product_manufacturer_id = hkc.category_id '.
'WHERE ocp.manufacturer_id >
'.(int)$this->options->last_openc_manufacturer.' OR
ocp.product_id >
'.$this->options->last_openc_prod.';';
$this->db->setQuery($sql1);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products: ' . $total . '</p>';
$this->db->setQuery($sql2);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links: ' . $total . '</p>';
$this->db->setQuery($sql4);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products files: ' . $total . '</p>';
$this->db->setQuery($sql5);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating products manufacturers: ' . $total . '</p>';
$ret = true;
return $ret;
}
function importVariant()
{
}
function importProductPrices()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
6 :</span>Â Import Product Prices</p>';
$ret = false;
$cpt = 0;
$this->db->setQuery('SELECT hkcur.currency_id FROM
`'.$this->opencDatabase.'`.`oc_currency` occ '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_currency` hkcur ON
CONVERT(occ.code USING utf8) = CONVERT( hkcur.currency_code USING utf8)
'.
"WHERE occ.value = '1.0';");
$data = $this->db->loadObjectList();
if (!empty($data))
{
$this->db->setQuery('INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_price`
(`price_product_id`,`price_value`,`price_currency_id`,`price_min_quantity`,`price_access`)
'
."SELECT hkprod.hk_Id, ocp.price,
'".$data[0]->currency_id."', '0',
'all' "
.'FROM `'.$this->opencDatabase.'`.`oc_product` ocp
INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_prod` hkprod
ON ocp.product_id = hkprod.openc_id '
.'WHERE ocp.product_id > ' .
(int)$this->options->last_openc_prod
);
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Prices imported : 0</p>';
}
$ret = $this->db->query();
$cpt = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Prices imported : ' . $cpt .'</p>';
if ($this->importcurrencies)
$this->importCurrencies();
return $ret;
}
function importProductCategory()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
7 :</span>Â Import Product Category</p>';
$ret = false;
$data = array(
'category_id' => 'hocc.hk_id',
'product_id' => 'hocp.hk_id',
'ordering' => '0',
);
$sql = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_product_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`oc_product_to_category` ocpc
'.
'INNER JOIN #__hikashop_openc_cat hocc ON ocpc.category_id =
hocc.openc_id AND category_type=\'category\' '.
'INNER JOIN #__hikashop_openc_prod hocp ON ocpc.product_id =
hocp.openc_id '.
'WHERE hocp.openc_id > ' .
(int)$this->options->last_openc_prod . ' OR hocc.openc_id >
' . $this->options->last_openc_cat;
$this->db->setQuery($sql);
$ret = $this->db->query();
$total = $this->db->getAffectedRows();
$this->importRebuildTree();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products categories: ' . $total . '</p>';
return $ret;
}
function importUsers()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
8 :</span>Â Import Users</p>';
$ret = false;
$sqla = 'SELECT ocu.* FROM
`'.$this->opencDatabase.'`.`oc_user` ocu '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_user` hkocu
ON ocu.user_id = hkocu.openc_user_id '.
'WHERE hkocu.openc_user_id IS NULL '.
'ORDER BY ocu.user_id ASC;';
$this->db->setQuery($sqla);
$this->db->query();
$datas = $this->db->loadObjectList();
$i = $this->options->max_joomla_user + 1;
if( empty($datas) )
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported user to Joomla : 0</p>';
}
else
{
$total = $this->importUsersToJoomla($datas,$i,false);
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported users to Joomla : ' . $total . '</p>';
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links (users) : ' . $total . '</p>';
}
$sqla = 'SELECT occu.* FROM
`'.$this->opencDatabase.'`.`oc_customer` occu '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_customer`
hkoccu ON occu.customer_id = hkoccu.openc_customer_id '.
'WHERE hkoccu.openc_customer_id IS NULL '.
'ORDER BY occu.customer_id ASC;';
$this->db->setQuery($sqla);
$this->db->query();
$datas = $this->db->loadObjectList();
if( empty($datas) )
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported customer to Joomla : 0</p>';
}
else
{
$total = $this->importUsersToJoomla($datas,$i,true);
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported customers to Joomla : ' . $total . '</p>';
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links (customers) : ' . $total . '</p>';
}
$sql0 = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_user`
(`user_cms_id`,`user_email`) '.
'SELECT hkoccu.hk_customer_cms_id, occ.email FROM
`'.$this->opencDatabase.'`.`oc_customer` occ '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_customer`
hkoccu ON hkoccu.openc_customer_id = occ.customer_id '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_user` AS hkusr ON
hkoccu.hk_customer_cms_id = hkusr.user_cms_id '.
'WHERE hkusr.user_cms_id IS NULL;';
$data = array(
'address_user_id' => 'hku.user_id',
'address_title' => "'Mr'",
'address_firstname' => 'oca.firstname',
'address_lastname' => 'oca.lastname',
'address_company' => 'oca.company',
'address_street' => 'CONCAT(oca.address_1,\'
\',oca.address_2)',
'address_post_code' => 'oca.postcode',
'address_city' => 'oca.city',
'address_telephone' => 'occu.telephone',
'address_fax' => 'occu.fax',
'address_state' => 'hkzsta.zone_namekey',
'address_country' => 'hkzcou.zone_namekey',
'address_published' => 4
);
$sql1 = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_address`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`oc_customer` AS occu '.
'INNER JOIN `'.$this->opencDatabase.'`.`oc_address`
AS oca ON occu.customer_id = oca.customer_id '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_customer`
hkoccu ON oca.customer_id = hkoccu.openc_customer_id '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_user` AS hku ON
hkoccu.hk_customer_cms_id = hku.user_cms_id '.
'INNER JOIN `'.$this->opencDatabase.'`.`oc_country`
AS occ ON oca.country_id = occ.country_id '.
'INNER JOIN `'.$this->opencDatabase.'`.`oc_zone` AS
ocz ON oca.zone_id = ocz.zone_id '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_zone` AS hkzcou ON
occ.iso_code_3 = hkzcou.zone_code_3 AND
hkzcou.zone_type=\'country\' '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_zone_link` AS hkzl
ON hkzcou.zone_namekey = hkzl.zone_parent_namekey '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_zone` AS hkzsta ON
ocz.code = hkzsta.zone_code_3 AND hkzsta.zone_type=\'state\' AND
hkzsta.zone_namekey = hkzl.zone_child_namekey '.
'WHERE occu.customer_id >
'.(int)$this->options->last_openc_user.' ORDER BY
oca.customer_id ASC';
$this->db->setQuery($sql0);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported users to Hikashop : ' . $total . '</p>';
$this->db->setQuery($sql1);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses : ' . $total . '</p>';
$ret = true;
return $ret;
}
function importUsersToJoomla($datas,&$i,$customer)
{
$cpt = 0;
foreach($datas as $data)
{
if ($customer)
$data->username = $data->email;
$this->db->setQuery("SELECT * FROM `#__users` WHERE username
= ".$this->db->quote($data->username).";");
$this->db->query();
$result = $this->db->loadObjectList();
if (!empty($result))
{
echo
'<p><span'.$this->bullstyle.'>►</span>
The user <strong>'.$data->username.'</strong>
won\'t be imported because an user with the same name already exists
on Joomla.</p>';
}
else
{
$sqlb = 'INSERT IGNORE INTO `#__users` (id, name, username, email,
password, block, sendEmail, registerDate, params) VALUES ';
$sqlc = 'INSERT IGNORE INTO `#__user_usergroup_map` (user_id,
group_id) VALUES ';
if ($customer)
{
$sqld = 'INSERT IGNORE INTO `#__hikashop_openc_customer`
(openc_customer_id, hk_customer_cms_id) VALUES ';
$block = !$data->approved;
}
else
{
$sqld = 'INSERT IGNORE INTO `#__hikashop_openc_user`
(openc_user_id, hk_user_cms_id) VALUES ';
$block = 0;
}
$d = array(
$i,
$this->db->quote($data->lastname),
$this->db->quote($data->username),
$this->db->quote($data->email),
"CONCAT(".$this->db->quote(@$data->password).",':',".$this->db->quote(@$data->salt).")",
$this->db->quote($block),
'0',
$this->db->quote($data->date_added),
"'{}'",
);
$sqlb .= '('.implode(',',$d).');';
if (isset($data->password)) //Don't insert guest
{
$this->db->setQuery($sqlb);
$this->db->query();
}
if (!$customer)
$data->user_group_id == 1 ? $group = 8 : $group = 2;
else
$group = 2;
$sqlc .= '('.$i.','.$group.')';
if (isset($data->password)) //Don't insert guest
{
$this->db->setQuery($sqlc);
$this->db->query();
}
if ($customer)
$sqld .=
'('.$data->customer_id.','.$i.')';
else
$sqld .=
'('.$data->user_id.','.$i.')';
$this->db->setQuery($sqld);
$this->db->query();
$i++;
$cpt++;
}
}
return $cpt;
}
function importOrders()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
10 :</span>Â Import Orders</p>';
$ret = false;
$offset = $this->options->current;
$count = 100;
$total = 0;
$vat_cols = "''";
$data = array(
'order_number' => 'oco.order_id',
'order_openc_id' => 'oco.order_id',
'order_user_id' => 'hkusr.user_id',
'order_status' => 'hkc.category_name',
'order_created' => 'oco.date_added',
'order_ip' => 'oco.ip',
'order_currency_id' => 'hkcur.currency_id',
'order_shipping_price' => "''", //?
'order_shipping_method' =>
'oco.shipping_method',
'order_shipping_id' => '1',
'order_payment_id' => 0,
'order_payment_method' => 'oco.payment_method',
'order_full_price' => 'ocot.value',
'order_modified' => 'oco.date_modified',
'order_partner_id' => 0,
'order_partner_price' => 0,
'order_partner_paid' => 0,
'order_type' => "'sale'",
'order_partner_currency_id' => 0,
'order_shipping_tax' => "''", //?
'order_discount_tax' => 0
);
$sql1 = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_order`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`oc_order` AS oco '.
'INNER JOIN
`'.$this->opencDatabase.'`.`oc_order_product` ocop ON
ocop.order_id = oco.order_id '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_category` AS hkc ON
oco.order_status_id = hkc.category_keywords AND hkc.category_type =
\'status\' '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_currency` AS hkcur
ON CONVERT(oco.currency_code USING utf8) = CONVERT(hkcur.currency_code
USING utf8) '.
'INNER JOIN
`'.$this->opencDatabase.'`.`oc_order_total` ocot ON
oco.order_id = ocot.order_id AND code=\'total\' '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_customer`
hkoccu ON oco.customer_id = hkoccu.openc_customer_id '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_user` AS hkusr ON
hkoccu.hk_customer_cms_id = hkusr.user_cms_id '.
'WHERE oco.order_id > ' .
(int)$this->options->last_openc_order . ' '.
'GROUP BY oco.order_id '.
'ORDER BY oco.order_id ASC;';
$sql1_1 = 'UPDATE
`'.$this->hikaDatabaseName.'`.`#__hikashop_order` AS hko
'.
'INNER JOIN `'.$this->opencDatabase.'`.`oc_voucher`
AS ocv ON hko.order_openc_id = ocv.order_id '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_discount` AS hkd ON
hkd.discount_code = ocv.code '.
'SET hko.order_discount_code = hkd.discount_code AND
hko.order_discount_price = hkd.discount_flat_amount';
$data = array(
'address_user_id' => 'oco.customer_id',
'address_firstname' => 'oco.payment_firstname',
'address_lastname' => 'oco.payment_lastname',
'address_company' => 'oco.payment_company',
'address_street' =>
'CONCAT(oco.payment_address_1,\'
\',oco.payment_address_2)',
'address_post_code' => 'oco.payment_postcode',
'address_city' => 'oco.payment_city ',
'address_telephone' => 'oco.telephone',
'address_fax' => 'oco.fax',
'address_state' => 'hkzsta.zone_namekey',
'address_country' => 'hkzcou.zone_namekey',
'address_published' => '7',
'address_vat' => $vat_cols,
'address_openc_order_info_id' => 'oco.order_id'
//8
);
$sql2_1 = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_address`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`oc_order` AS oco '.
'INNER JOIN `'.$this->opencDatabase.'`.`oc_country`
AS occ ON oco.payment_country_id = occ.country_id '.
'INNER JOIN `'.$this->opencDatabase.'`.`oc_zone` AS
ocz ON oco.payment_zone_id = ocz.zone_id '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_zone` AS hkzcou ON
occ.iso_code_3 = hkzcou.zone_code_3 AND
hkzcou.zone_type=\'country\' '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_zone_link` AS hkzl
ON hkzcou.zone_namekey = hkzl.zone_parent_namekey '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_zone` AS hkzsta ON
ocz.code = hkzsta.zone_code_3 AND hkzsta.zone_type=\'state\' AND
hkzsta.zone_namekey = hkzl.zone_child_namekey '.
'WHERE oco.order_id > ' .
(int)$this->options->last_openc_order;
$sql2_2 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone` AS hkz ON (a.address_country =
hkz.zone_code_3 AND hkz.zone_type = "country") '.
'SET address_country = hkz.zone_namekey, address_published = 6
WHERE address_published >= 7;';
$sql2_3 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone_link` AS zl ON (a.address_country =
zl.zone_parent_namekey) '.
'JOIN `#__hikashop_zone` AS hks ON (hks.zone_namekey =
zl.zone_child_namekey AND hks.zone_type = "state" AND
hks.zone_code_3 = a.address_state) '.
'SET address_state = hks.zone_namekey, address_published = 5 WHERE
address_published = 6;';
$sql2_4 = 'UPDATE `#__hikashop_address` AS a '.
'SET address_published = 0 WHERE address_published > 4;';
$sql3 = 'UPDATE `#__hikashop_order` AS o '.
'INNER JOIN `#__hikashop_address` AS a ON
a.address_openc_order_info_id = o.order_openc_id '.
'SET o.order_billing_address_id = a.address_id,
o.order_shipping_address_id = a.address_id '.
"WHERE o.order_billing_address_id = 0 AND address_published >= 7
;";
$sql4 = 'UPDATE `#__hikashop_order` AS o '.
'INNER JOIN `#__hikashop_address` AS a ON
a.address_openc_order_info_id = o.order_openc_id '.
'SET o.order_shipping_address_id = a.address_id '.
"WHERE o.order_shipping_address_id = 0 AND address_published >=
8 ;";
$sql5 = 'UPDATE
`'.$this->hikaDatabaseName.'`.`#__hikashop_order` AS hko
'.
'JOIN `'.$this->opencDatabase.'`.`oc_order` AS oco ON
hko.order_openc_id = oco.order_id '.
"SET hko.order_payment_method = CONCAT('openc import: ',
oco.payment_method) ".
'WHERE hko.order_openc_id > ' .
(int)$this->options->last_openc_order;
$this->db->setQuery($sql1);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported orders: ' . $total . '</p>';
$this->db->setQuery($sql1_1);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating discount orders: ' . $total . '</p>';
$this->db->setQuery($sql2_1);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported orders addresses: ' . $total . '</p>';
$this->db->setQuery($sql3);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating billing addresses: ' . $total . '</p>';
$this->db->setQuery($sql4);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating shipping addresses: ' . $total . '</p>';
$this->db->setQuery($sql5);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating order payments: ' . $total . '</p>';
$this->db->setQuery($sql2_2);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating orders: ' . $total;
$this->db->setQuery($sql2_3);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '/' . $total;
$this->db->setQuery($sql2_4);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '/' . $total . '</p>';
$ret = true;
return $ret;
}
function importOrderItems()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
11 :</span>Â Import Order Items</p>';
$ret = false;
$offset = $this->options->current;
$count = 100;
$data = array(
'order_id' => 'hko.order_id',
'product_id' => 'hkp.hk_id',
'order_product_quantity' => 'ocop.quantity',
'order_product_name' => 'ocop.name',
'order_product_code' => 'ocp.hika_sku',
'order_product_price' => 'ocop.price',
'order_product_tax' => 'ocop.tax',
'order_product_options' => "''"
);
$sql = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_order_product`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`oc_order_product` AS ocop '.
'INNER JOIN `'.$this->opencDatabase.'`.`oc_product`
ocp ON ocop.product_id=ocp.product_id '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_order` AS hko ON
ocop.order_id = hko.order_openc_id '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_prod` AS hkp
ON hkp.openc_id = ocop.product_id '.
'WHERE ocop.order_id > ' .
(int)$this->options->last_openc_order . ';';
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Orders Items : '. $total .'</p>';
$ret = true;
return $ret;
}
function importDownloads()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
12 :</span>Â Import Downloads</p>';
$ret = false;
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$count = 100;
$offset = $this->options->current;
if( $offset == 0 )
$offset = $this->options->last_openc_pfile;
$sql = "SELECT `config_value` FROM `#__hikashop_config` WHERE
config_namekey = 'download_number_limit';";
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$dl_limit = $data[0]->config_value;
$sql = 'SELECT ocd.download_id, ocd.filename FROM
`'.$this->opencDatabase.'`.`oc_download` AS ocd WHERE
ocd.download_id > '.$offset.';'; //Why no Mask FFS
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$max = 0;
if (!empty($data) && !empty($this->opencRootPath))
{
$this->copyDownloadDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode(DIR_DOWNLOAD)),DS.'
').DS);
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying downloads files... </p>';
foreach($data as $c)
{
$file_name =
end(explode('/',str_replace('\\','/',$c->filename)));
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$dstFolder = $this->options->uploadfolder; //secure ?
$this->copyFile($this->copyDownloadDir, $c->filename,
$dstFolder.$file_name);
$max = $c->download_id;
}
if( $max > 0 )
{
echo '<p>Copying files...<br/>(Last processed file id:
' . $max . '</p>';
$this->options->current = $max;
$this->refreshPage = true;
return $ret;
}
}
$data = array(
'file_name' => 'ocdd.name',
'file_description' => "''",
'file_path' => "SUBSTRING_INDEX(ocd.filename
,'/',-1)", //Why no filename ?
'file_type' => "'file'",
'file_ref_id' => 'hkocp.hk_id'
);
$sql = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_file`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`oc_download` AS ocd '.
'INNER JOIN
`'.$this->opencDatabase.'`.`oc_download_description` ocdd ON
ocd.download_id = ocdd.download_id '.
'LEFT JOIN
`'.$this->opencDatabase.'`.`oc_product_to_download` ocpd ON
ocd.download_id = ocpd.download_id '.
'LEFT JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_openc_prod` AS
hkocp ON ocpd.product_id = hkocp.openc_id '.
'WHERE ocd.download_id >
'.(int)$this->options->last_openc_pfile;
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Downloable files imported : ' . $total . '</p>';
$data = array(
'file_id' => 'hkf.file_id',
'order_id' => 'hko.order_id',
'download_number' => '(' . $dl_limit . '-
ocd.remaining)' //$dl_limit ?
);
$sql = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_download`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`oc_download` AS ocd '.
'INNER JOIN
`'.$this->opencDatabase.'`.`oc_download_description` ocdd ON
ocd.download_id = ocdd.download_id '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_file` AS hkf ON (
CONVERT(hkf.file_name USING utf8) = CONVERT(ocdd.name USING utf8) )'.
'INNER JOIN
`'.$this->opencDatabase.'`.`oc_product_to_download` AS ocpd ON
ocd.download_id = ocpd.download_id '.
'INNER JOIN
`'.$this->opencDatabase.'`.`oc_order_product` AS ocop ON
ocpd.product_id = ocop.product_id '.
'INNER JOIN
`'.$this->hikaDatabaseName.'`.`#__hikashop_order` AS hko ON
hko.order_openc_id = ocop.order_id '.
'WHERE ocd.download_id >
'.(int)$this->options->last_openc_pfile;
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Downloable order files imported : ' . $total .
'</p>';
$ret = true;
return $ret;
}
function importDiscount()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
9 :</span>Â Import Discount</p>';
$ret = false;
$sql = "SELECT `config_value` FROM `#__hikashop_config` WHERE
config_namekey = 'main_currency';";
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$main_currency = $data[0]->config_value;
$data = array(
'discount_type' => "'coupon'",
'discount_start' => 'date_start',
'discount_end' => 'date_end',
'discount_quota' => 'uses_total',
'discount_quota_per_user' => 'uses_customer',
'discount_published' => 'status',
'discount_code' => 'code',
'discount_currency_id' => $main_currency,
'discount_flat_amount' => "case when type =
'F' then discount else 0 end",
'discount_percent_amount' => "case when type =
'P' then discount else 0 end",
'discount_quota' => '0'
);
$sql = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_discount`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`oc_coupon` WHERE coupon_id >
' . $this->options->last_openc_coupon;
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Discount codes/coupons imported : ' . $total .
'</p>';
$data = array(
'discount_type' => "'coupon'",
'discount_code' => 'code',
'discount_currency_id' => $main_currency,
'discount_flat_amount' => 'amount',
'discount_percent_amount' => '0',
'discount_published' => 'status',
);
$sql = 'INSERT IGNORE INTO
`'.$this->hikaDatabaseName.'`.`#__hikashop_discount`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`'.$this->opencDatabase.'`.`oc_voucher` WHERE voucher_id >
' . $this->options->last_openc_voucher;
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Vouchers imported : ' . $total . '</p>';
$ret = true;
return $ret;
}
function importCurrencies()
{
if( $this->db == null )
return false;
$this->db->setQuery('UPDATE
`'.$this->hikaDatabaseName.'`.`#__hikashop_currency` AS hkcur
'.
'INNER JOIN
`'.$this->opencDatabase.'`.`oc_currency` occ ON
CONVERT(occ.code USING utf8) = CONVERT( hkcur.currency_code USING utf8)
'.
'SET hkcur.currency_rate = occ.value'
);
$ret = $this->db->query();
$cpt = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Currencies values imported : ' . $cpt .'</p>';
return true;
}
function finishImport()
{
$this->db->setQuery("SELECT max(category_id) as
'max' FROM `#__hikashop_category`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(id) as 'max' FROM
`#__users`;");
$data = $this->db->loadObjectList();
$this->options->max_joomla_user = (int)($data[0]->max);
$this->db->setQuery("SELECT max(product_id) as 'max'
FROM `#__hikashop_product`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_prod = (int)($data[0]->max);
$this->db->setQuery("SELECT max(openc_id) as 'max'
FROM `#__hikashop_openc_cat`;");
$data = $this->db->loadObjectList();
$this->options->last_openc_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(openc_id) as 'max'
FROM `#__hikashop_openc_prod`;");
$data = $this->db->loadObjectList();
$this->options->last_openc_prod = (int)($data[0]->max);
$this->db->setQuery("SELECT max(customer_id) as
'max' FROM
`".$this->opencDatabase."`.`oc_customer`;");
$data = $this->db->loadObjectList();
$this->options->last_openc_user = (int)($data[0]->max);
$this->db->setQuery("SELECT max(order_openc_id) as
'max' FROM `#__hikashop_order`;");
$data = $this->db->loadObjectList();
$this->options->last_openc_order = (int)($data[0]->max);
$this->db->setQuery("SELECT max(ocpi.product_image_id) as
'max' FROM
`".$this->opencDatabase."`.`oc_product_image` ocpi INNER JOIN
`".$this->opencDatabase."`.`oc_product` ocp ON ocpi.product_id
= ocp.product_id");
$data = $this->db->loadObject();
$this->options->last_openc_pfile = (int)($data->max);
$this->db->setQuery("SELECT max(coupon_id) as 'max'
FROM `".$this->opencDatabase."`.`oc_coupon`;");
$data = $this->db->loadObject();
$this->options->last_openc_coupon = (int)($data->max);
$this->db->setQuery("SELECT max(voucher_id) as 'max'
FROM `".$this->opencDatabase."`.`oc_voucher`;");
$data = $this->db->loadObject();
$this->options->last_openc_voucher = (int)($data->max);
$this->db->setQuery("SELECT max(tax_rate_id) as
'max' FROM
`".$this->opencDatabase."`.`oc_tax_rate`;");
$data = $this->db->loadObject();
$this->options->last_openc_taxrate = (int)($data->max);
$this->db->setQuery("SELECT max(tax_class_id) as
'max' FROM
`".$this->opencDatabase."`.`oc_tax_class`;");
$data = $this->db->loadObject();
$this->options->last_openc_taxclass = (int)($data->max);
$this->db->setQuery("SELECT max(manufacturer_id) as
'max' FROM
`".$this->opencDatabase."`.`oc_manufacturer`;");
$data = $this->db->loadObjectList();
$this->options->last_openc_manufacturer = (int)($data[0]->max);
$this->options->state = (MAX_IMPORT_ID+1);
$query = 'REPLACE INTO `#__hikashop_config`
(`config_namekey`,`config_value`,`config_default`) VALUES '.
"('openc_import_state',".$this->options->state.",".$this->options->state.")".
",('openc_import_max_hk_cat',".$this->options->max_hk_cat.",".$this->options->max_hk_cat.")".
",('openc_import_max_joomla_user',".$this->options->max_joomla_user.",".$this->options->max_joomla_user.")".
",('openc_import_max_hk_prod',".$this->options->max_hk_prod.",".$this->options->max_hk_prod.")".
",('openc_import_last_openc_cat',".$this->options->last_openc_cat.",".$this->options->last_openc_cat.")".
",('openc_import_last_openc_prod',".$this->options->last_openc_prod.",".$this->options->last_openc_prod.")".
",('openc_import_last_openc_user',".$this->options->last_openc_user.",".$this->options->last_openc_user.")".
",('openc_import_last_openc_order',".$this->options->last_openc_order.",".$this->options->last_openc_order.")".
",('openc_import_last_openc_pfile',".$this->options->last_openc_pfile.",".$this->options->last_openc_pfile.")".
",('openc_import_last_openc_coupon',".$this->options->last_openc_coupon.",".$this->options->last_openc_coupon.")".
",('openc_import_last_openc_voucher',".$this->options->last_openc_voucher.",".$this->options->last_openc_voucher.")".
",('openc_import_last_openc_taxrate',".$this->options->last_openc_taxrate.",".$this->options->last_openc_taxrate.")".
",('openc_import_last_openc_taxclass',".$this->options->last_openc_taxclass.",".$this->options->last_openc_taxclass.")".
",('openc_import_last_openc_manufacturer',".$this->options->last_openc_manufacturer.",".$this->options->last_openc_manufacturer.")".
';';
$this->db->setQuery($query);
$this->db->query();
echo '<p'.$this->titlefont.'>Import finished
!</p>';
$class = hikashop_get('class.plugins');
}
}
importreds.php000064400000171377151162557640007501 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?> <?php
include(HIKASHOP_ROOT .
'administrator/components/com_redshop/helpers/redshop.cfg.php');
class hikashopImportredsHelper extends hikashopImportHelper
{
function __construct()
{
parent::__construct();
$this->importName = 'reds';
$this->copyImgDir = HIKASHOP_ROOT .
'components/com_redshop/assets/images/product';
$this->copyCatImgDir = HIKASHOP_ROOT .
'components/com_redshop/assets/images/category';
$this->copyDownloadDir = PRODUCT_DOWNLOAD_ROOT;
$this->copyManufDir = HIKASHOP_ROOT .
'components/com_redshop/assets/images/manufacturer';
jimport('joomla.filesystem.file');
}
function importFromRedshop()
{
@ob_clean();
echo $this->getHtmlPage();
$this->token = hikashop_getFormToken();
flush();
if( isset($_GET['import']) && $_GET['import']
== '1' )
{
$time = microtime(true);
$processed = $this->doImport();
if( $processed )
{
$elasped = microtime(true) - $time;
if( !$this->refreshPage )
echo
'<p></br><a'.$this->linkstyle.'href="'.hikashop_completeLink('import&task=import&importfrom=redshop&'.$this->token.'=1&import=1').'">'.JText::_('HIKA_NEXT').'</a></p>';
echo '<p style="font-size:0.85em;
color:#605F5D;">Elasped time: ' . round($elasped * 1000, 2) .
'ms</p>';
}
else
{
echo
'<a'.$this->linkstyle.'href="'.hikashop_completeLink('import&task=show').'">'.JText::_('HIKA_BACK').'</a>';
}
}
else
{
echo $this-> getStartPage();
}
if( $this->refreshPage )
{
echo "<script type=\"text/javascript\">\r\nr =
true;\r\n</script>";
}
echo '</body></html>';
exit;
}
function doImport()
{
if( $this->db == null )
return false;
$this->loadConfiguration();
$current = $this->options->current;
$ret = true;
$next = false;
$next = $this->importOrders();
if( $ret && $next )
{
$sql = "UPDATE `#__hikashop_config` SET
config_value=(config_value+1) WHERE config_namekey =
'reds_import_state'; ";
$this->db->setQuery($sql);
$this->db->query();
$sql = "UPDATE `#__hikashop_config` SET config_value=0 WHERE
config_namekey = 'reds_import_current';";
$this->db->setQuery($sql);
$this->db->query();
}
else if( $current != $this->options->current )
{
$sql = "UPDATE `#__hikashop_config` SET
config_value=".$this->options->current." WHERE
config_namekey = 'reds_import_current';";
$this->db->setQuery($sql);
$this->db->query();
}
return $ret;
}
function loadConfiguration()
{
$this->options = null;
$firsttime = false;
$data = array(
'uploadfolder',
'uploadsecurefolder',
'main_currency',
'reds_import_state',
'reds_import_current',
'reds_import_tax_id',
'reds_import_main_cat_id',
'reds_import_max_hk_cat',
'reds_import_max_hk_prod',
'reds_import_last_reds_cat',
'reds_import_last_reds_prod',
'reds_import_last_reds_user',
'reds_import_last_reds_order',
'reds_import_last_reds_pfile',
'reds_import_last_reds_coupon',
'reds_import_last_reds_discount',
'reds_import_last_reds_discount_prod',
'reds_import_last_reds_voucher',
'reds_import_last_reds_taxrate',
'reds_import_last_reds_taxclass',
'reds_import_last_reds_manufacturer'
);
$this->db->setQuery('SELECT config_namekey, config_value FROM
`#__hikashop_config` WHERE config_namekey IN
('."'".implode("','",$data)."'".');');
$result = $this->db->loadObjectList();
if (!empty($options))
{
foreach($result as $o)
{
if( substr($o->config_namekey, 0, 12) == 'reds_import_' )
$nk = substr($o->config_namekey, 12);
else
$nk = $o->config_namekey;
$this->options->$nk = $o->config_value;
}
}
else
{
$firsttime = true;
}
$this->options->uploadfolder =
rtrim(JPath::clean(html_entity_decode($this->options->uploadfolder)),DS.'
').DS;
if(!preg_match('#^([A-Z]:)?/.*#',$this->options->uploadfolder)){
if(!$this->options->uploadfolder[0]=='/' ||
!is_dir($this->options->uploadfolder)){
$this->options->uploadfolder =
JPath::clean(HIKASHOP_ROOT.DS.trim($this->options->uploadfolder,DS.'
').DS);
}
}
$this->options->uploadsecurefolder =
rtrim(JPath::clean(html_entity_decode($this->options->uploadsecurefolder)),DS.'
').DS;
if(!preg_match('#^([A-Z]:)?/.*#',$this->options->uploadsecurefolder)){
if(!$this->options->uploadsecurefolder[0]=='/' ||
!is_dir($this->options->uploadsecurefolder)){
$this->options->uploadsecurefolder =
JPath::clean(HIKASHOP_ROOT.DS.trim($this->options->uploadsecurefolder,DS.'
').DS);
}
}
if( $firsttime )
{
$this->options->state = 0;
$this->options->current = 0;
$this->options->tax_id = 0;
$this->options->last_reds_coupon = 0;
$this->options->last_reds_discount = 0;
$this->options->last_reds_discount_prod = 0;
$this->options->last_reds_voucher = 0;
$this->options->last_reds_pfile = 0;
$this->options->last_reds_taxrate = 0;
$this->options->last_reds_taxclass = 0;
$this->options->last_reds_manufacturer = 0;
$element = 'product';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$this->options->main_cat_id = $element;
$this->db->setQuery("SELECT max(category_id) as
'max' FROM `#__hikashop_category`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(product_id) as
'max' FROM `#__hikashop_product`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_prod = (int)($data[0]->max);
$query='SHOW TABLES LIKE
'.$this->db->Quote($this->db->getPrefix().substr(hikashop_table('reds_cat'),3));
$this->db->setQuery($query);
$table = $this->db->loadResult();
if(!empty($table))
{
$this->db->setQuery("SELECT max(reds_id) as 'max'
FROM `#__hikashop_reds_cat`;");
$data = $this->db->loadObjectList();
if( $data )
$this->options->last_reds_cat = (int)($data[0]->max);
else
$this->options->last_reds_cat = 0;
$this->db->setQuery("SELECT max(reds_id) as 'max'
FROM `#__hikashop_reds_prod`;");
$data = $this->db->loadObjectList();
if( $data )
$this->options->last_reds_prod = (int)($data[0]->max);
else
$this->options->last_reds_prod = 0;
$this->db->setQuery("SELECT max(order_reds_id) as
'max' FROM `#__hikashop_order`;");
$data = $this->db->loadObjectList();
if( $data )
$this->options->last_reds_order = (int)($data[0]->max);
else
$this->options->last_reds_order = 0;
}
else
{
$this->options->last_reds_cat = 0;
$this->options->last_reds_prod = 0;
$this->options->last_reds_order = 0;
}
$this->options->last_reds_user = 0;
$sql = 'INSERT IGNORE INTO `#__hikashop_config`
(`config_namekey`,`config_value`,`config_default`) VALUES '.
"('reds_import_state',".$this->options->state.",".$this->options->state.")".
",('reds_import_current',".$this->options->current.",".$this->options->current.")".
",('reds_import_tax_id',".$this->options->tax_id.",".$this->options->tax_id.")".
",('reds_import_main_cat_id',".$this->options->main_cat_id.",".$this->options->main_cat_id.")".
",('reds_import_max_hk_cat',".$this->options->max_hk_cat.",".$this->options->max_hk_cat.")".
",('reds_import_max_hk_prod',".$this->options->max_hk_prod.",".$this->options->max_hk_prod.")".
",('reds_import_last_reds_cat',".$this->options->last_reds_cat.",".$this->options->last_reds_cat.")".
",('reds_import_last_reds_prod',".$this->options->last_reds_prod.",".$this->options->last_reds_prod.")".
",('reds_import_last_reds_user',".$this->options->last_reds_user.",".$this->options->last_reds_user.")".
",('reds_import_last_reds_order',".$this->options->last_reds_order.",".$this->options->last_reds_order.")".
",('reds_import_last_reds_pfile',".$this->options->last_reds_pfile.",".$this->options->last_reds_pfile.")".
",('reds_import_last_reds_coupon',".$this->options->last_reds_coupon.",".$this->options->last_reds_coupon.")".
",('reds_import_last_reds_discount',".$this->options->last_reds_discount.",".$this->options->last_reds_discount.")".
",('reds_import_last_reds_discount_prod',".$this->options->last_reds_discount_prod.",".$this->options->last_reds_discount_prod.")".
",('reds_import_last_reds_voucher',".$this->options->last_reds_voucher.",".$this->options->last_reds_voucher.")".
",('reds_import_last_reds_taxrate',".$this->options->last_reds_taxrate.",".$this->options->last_reds_taxrate.")".
",('reds_import_last_reds_taxclass',".$this->options->last_reds_taxclass.",".$this->options->last_reds_taxclass.")".
",('reds_import_last_reds_manufacturer',".$this->options->last_reds_manufacturer.",".$this->options->last_reds_manufacturer.")".
';';
$this->db->setQuery($sql);
$this->db->query();
}
}
function createTables()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
1 :</span>Â Initialization Tables</p>';
$create = true;
$query='SHOW TABLES LIKE
'.$this->db->Quote($this->db->getPrefix().substr(hikashop_table('reds_cat'),3));
$this->db->setQuery($query);
$table = $this->db->loadResult();
if (!empty($table))
$create = false;
if ($create)
{
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_reds_prod` (`reds_id` int(11) unsigned NOT NULL DEFAULT
'0', `hk_id` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`reds_id`)) ENGINE=MyISAM");
$this->db->query();
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_reds_cat` (`reds_cat_id` INT(11) unsigned NOT NULL
AUTO_INCREMENT, `reds_id` int(11) unsigned NOT NULL DEFAULT '0',
`hk_id` int(11) unsigned NOT NULL DEFAULT '0', `category_type`
varchar(255) NULL, PRIMARY KEY (`reds_cat_id`)) ENGINE=MyISAM");
$this->db->query();
$this->db->setQuery('ALTER IGNORE TABLE `#__hikashop_address`
ADD `address_reds_order_info_id` INT(11) NULL');
$this->db->query();
$this->db->setQuery('ALTER IGNORE TABLE `#__hikashop_order`
ADD `order_reds_id` INT(11) NULL');
$this->db->query();
$this->db->setQuery('ALTER IGNORE TABLE `#__hikashop_order`
ADD INDEX ( `order_reds_id` )');
$this->db->query();
$this->db->setQuery('ALTER IGNORE TABLE
`#__hikashop_taxation` ADD `tax_reds_id` INT(11) NULL');
$this->db->query();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
All table created</p>';
}
else
{
echo '<p>Tables have been already created.</p>';
$this->refreshPage = true; //toComment ?
}
return true;
}
function importTaxes()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
2 :</span>Â Import Taxes<p>';
$ret = false;
$data = array(
'tax_namekey' => "CONCAT('REDS_TAX_',
rstr.tax_rate_id)",
'tax_rate' => 'rstr.tax_rate'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_tax`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__redshop_tax_rate` AS rstr '.
'WHERE rstr.tax_rate_id > ' .
(int)$this->options->last_reds_taxrate;
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported taxes: ' . $total . '</p>';
$element = 'tax';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$data = array(
'category_type' => "'tax'",
'category_name' => "CONCAT('Tax imported
(', rstg.tax_group_name,')')",
'category_published' => 'rstg.published',
'category_parent_id' => $element,
'category_namekey' => "
CONCAT('REDS_TAX_CATEGORY_', rstg.tax_group_id)"
);
$sql = 'INSERT IGNORE INTO `#__hikashop_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__redshop_tax_group` AS rstg ';
'WHERE rstg.tax_group_id > ' .
(int)$this->options->last_reds_taxclass;
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Taxes Categories: ' . $total . '</p>';
if( $total > 0 ) {
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'reds_import_max_hk_cat'; ");
$this->db->query();
$this->importRebuildTree();
}
$data = array(
'zone_namekey' => "case when hkz.zone_namekey IS NULL
then '' else hkz.zone_namekey end",
'category_namekey' =>
"CONCAT('REDS_TAX_CATEGORY_', rstg.tax_group_id)",
'tax_namekey' => "CONCAT('REDS_TAX_',
rstr.tax_rate_id)",
'taxation_published' => '1',
'taxation_type' => "''",
'tax_reds_id' => 'rstg.tax_group_id'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_taxation`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__redshop_tax_rate` AS rstr '.
'INNER JOIN `#__redshop_tax_group` AS rstg ON rstr.tax_group_id =
rstg.tax_group_id '.
'LEFT JOIN `#__redshop_country` AS rsc ON rstr.tax_country =
rsc.country_3_code ' . //Tocheck
"LEFT JOIN `#__hikashop_zone` hkz ON rsc.country_3_code =
hkz.zone_code_3 AND hkz.zone_type = 'country' ".
'WHERE rstr.tax_rate_id > ' .
(int)$this->options->last_reds_taxrate;
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Taxations: ' . $total . '</p>';
$ret = true;
return $ret;
}
function importManufacturers()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
3 :</span>Â Import Manufacturers</p>';
$ret = false;
$count = 100;
$rebuild = false;
$sql1 = 'SELECT * FROM `#__redshop_manufacturer` rsm '.
'LEFT JOIN `#__redshop_media` rsme ON rsme.section_id =
rsm.manufacturer_id AND rsme.media_section = \'manufacturer\'
'.
'LEFT JOIN `#__hikashop_reds_cat` hkmj ON rsm.manufacturer_id =
hkmj.reds_id AND category_type=\'manufacturer\' '.
'WHERE rsm.manufacturer_id > ' .
(int)$this->options->last_reds_manufacturer;
'ORDER BY rsm.manufacturer_id ASC;';
$this->db->setQuery($sql1);
$this->db->query();
$datas = $this->db->loadObjectList();
$sql2 = 'INSERT INTO `#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_published`,'.
'`category_namekey`,`category_description`,`category_menu`,`category_keywords`)
VALUES ';
$sql3 = 'INSERT INTO `#__hikashop_reds_cat`
(`reds_id`,`hk_id`,`category_type`) VALUES ';
$sql4 = 'INSERT INTO `#__hikashop_file`
(`file_name`,`file_description`,`file_path`,`file_type`,`file_ref_id`)
VALUES ';
$doSql3 = false;
$doSql4 = false;
$i = $this->options->max_hk_cat + 1;
$ids = array( 0 => $this->options->main_cat_id);
$sep = '';
$sep2 = '';
$cpt=0;
if( empty($datas) )
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported manufacturers : 0</p>';
return true;
}
else
{
foreach($datas as $data)
{
if( !empty($data->reds_id) )
{
$ids[$data->manufacturer_id] = $data->hk_id;
}
else
{
$doSql3 = true;
$ids[$data->manufacturer_id] = $i;
$sql3 .=
$sep.'('.$data->manufacturer_id.','.$i.',\'manufacturer\')';
$i++;
$sep = ',';
}
$cpt++;
if( $cpt >= $count )
break;
}
$sql3 .= ';';
$cpt = 0;
$sep = '';
foreach($datas as $data)
{
if( !empty($data->reds_id) )
continue;
$id = $ids[$data->manufacturer_id];
$element = 'manufacturer';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$d = array(
$id,
$element,
"'manufacturer'",
$this->db->quote($data->manufacturer_name),
'1',
"CONCAT('REDS_MANUFAC_',
".$data->manufacturer_id .")",
"'manufacturer imported from Redshop'",
'0',
$this->db->quote($data->metakey)
);
$sql2 .= $sep.'('.implode(',',$d).')';
if( !empty($data->media_name))
{
$this->copyManufDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode($this->copyManufDir)),DS.'
').DS);
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying categories images... </p>';
$doSql4 = true;
$sql4 .=
$sep2."('".$data->media_name."','','".$data->media_name."','category',".$id.')';
$sep2 = ',';
$file_name =
str_replace('\\','/',$data->media_name);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyManufDir,$data->media_name,
str_replace('//','/',str_replace('\\','/',$this->options->uploadfolder.$file_name)));
}
$sep = ',';
$cpt++;
if( $cpt >= $count )
break;
}
}
if($cpt > 0)
{
$sql2 .= ';';
$sql4 .= ';';
$this->db->setQuery($sql2);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Manufacturers : ' . $total . '</p>';
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Manufacturers : 0</p>';
}
if( isset($total) && $total > 0)
{
$rebuild = true;
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'reds_import_max_hk_cat'; ");
$this->db->query();
}
if ($doSql3)
{
$this->db->setQuery($sql3);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links : ' . $total . '</p>';
}
if($doSql4)
{
$this->db->setQuery($sql4);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Manufacturers files : ' . $total . '</p>';
}
if( $rebuild )
$this->importRebuildTree();
if( $cpt < $count )
$ret = true;
return $ret;
}
function importCategories()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
4 :</span>Â Import General Categories</p>';
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$rebuild = false;
$ret = false;
$offset = 0;
$count = 100;
$cpt = 0;
$sep = '';
$sep2 = '';
$statuses = array(
'P' => 'created',
'C' => 'confirmed',
'X' => 'cancelled',
'R'=> 'refunded' ,
'S' => 'shipped'
);
$this->db->setQuery("SELECT category_keywords,
category_parent_id FROM `#__hikashop_category` WHERE category_type =
'status' AND category_name = 'confirmed'");
$data = $this->db->loadObject();
$status_category = $data->category_parent_id;
if( $data->category_keywords != 'C' ) {
foreach($statuses as $k => $v) {
$this->db->setQuery("UPDATE `#__hikashop_category` SET
category_keywords = '".$k."' WHERE category_type =
'status' AND category_name = '".$v."';
");
$this->db->query();
}
}
$this->db->setQuery("SELECT order_status_code,
order_status_name FROM `#__redshop_order_status` WHERE order_status_name
NOT IN
('".implode("','",$statuses)."');");
$data = $this->db->loadObjectList();
if( count($data) > 0 )
{
$sql0 = 'INSERT IGNORE INTO `#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_description`,`category_published`,'.
'`category_namekey`,`category_access`,`category_menu`,`category_keywords`)
VALUES ';
$id = $this->options->max_hk_cat + 1;
$sep = '';
foreach($data as $c) {
$d = array(
$id++,
$status_category,
"'status'",
$this->db->quote( strtolower($c->order_status_name) ),
"'Order status imported from Redshop'",
'1',
$this->db->quote('status_reds_import_'.strtolower(str_replace('
','_',$c->order_status_name))),
"'all'",
'0',
$this->db->quote( $c->order_status_code )
);
$sql0 .= $sep.'('.implode(',',$d).')';
$sep = ',';
}
$this->db->setQuery($sql0);
$this->db->query();
$total = $this->db->getAffectedRows();
if( $total > 0 ) {
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported order status categories : ' . $total .
'</p>';
$rebuild = true;
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'reds_import_max_hk_cat'; ");
$this->db->query();
$sql0 = '';
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported order status categories : 0</p>';
}
}
$sql1 = 'SELECT * FROM `#__redshop_category` rsc '.
'LEFT JOIN `#__redshop_category_xref` rscx ON rsc.category_id =
rscx.category_child_id '.
'LEFT JOIN `#__hikashop_reds_cat` hkrs ON rsc.category_id =
hkrs.reds_id AND category_type=\'category\' '.
'WHERE rsc.category_id >
'.$this->options->last_reds_cat.' '.
'ORDER BY category_parent_id ASC, ordering ASC, category_id
ASC;';
$this->db->setQuery($sql1);
$this->db->query();
$datas = $this->db->loadObjectList();
$sql2 = 'INSERT INTO `#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_description`,`category_published`,'.
'`category_ordering`,`category_namekey`,`category_created`,`category_canonical`,`category_access`,`category_menu`,`category_keywords`)
VALUES ';
$sql3 = 'INSERT INTO `#__hikashop_reds_cat`
(`reds_id`,`hk_id`,`category_type`) VALUES ';
$sql4 = 'INSERT INTO `#__hikashop_file`
(`file_name`,`file_description`,`file_path`,`file_type`,`file_ref_id`)
VALUES ';
$doSql3 = false;
$doSql4 = false;
$i = $this->options->max_hk_cat + 1;
$ids = array( 0 => $this->options->main_cat_id);
$sep = '';
if( empty($datas) )
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported category : 0</p>';
if( $rebuild )
$this->importRebuildTree();
return true;
}
else
{
foreach($datas as $data)
{
if( !empty($data->reds_id) )
{
$ids[$data->category_id] = $data->hk_id;
}
else
{
$doSql3 = true;
$ids[$data->category_id] = $i;
$sql3 .=
$sep.'('.$data->category_id.','.$i.',\'category\')';
$i++;
$sep = ',';
}
$cpt++;
if( $cpt >= $count )
break;
}
$sql3 .= ';';
$cpt = 0;
$sep = '';
foreach($datas as $data)
{
if( !empty($data->reds_id) )
continue;
$id = $ids[$data->category_id];
if(!empty($ids[$data->category_parent_id]))
$pid = (int)$ids[$data->category_parent_id];
else
$pid = $ids[0];
$element = new stdClass();
$element->category_id = $id;
$element->category_parent_id = $pid;
$element->category_name = $data->category_name;
$nameKey = $categoryClass->getNameKey($element);
$d = array(
$id,
$pid,
"'product'",
$this->db->quote($data->category_name),
$this->db->quote($data->category_description),
$data->published,
$data->ordering,
$this->db->quote($nameKey),
"'".$data->category_pdate."'",
$this->db->quote($data->canonical_url),
"'all'",
'0',
$this->db->quote($data->metakey)
);
$sql2 .= $sep.'('.implode(',',$d).')';
if( !empty($data->category_full_image))
{
$this->copyCatImgDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode($this->copyCatImgDir)),DS.'
').DS);
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying categories images... </p>';
$doSql4 = true;
$sql4 .=
$sep2."('','','".$data->category_full_image."','category',".$id.')';
$sep2 = ',';
$file_name =
str_replace('\\','/',$data->category_full_image);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyCatImgDir,$data->category_full_image,
str_replace('//','/',str_replace('\\','/',$this->options->uploadfolder.$file_name)));
}
$sep = ',';
$cpt++;
if( $cpt >= $count )
break;
}
}
if($cpt > 0)
{
$sql2 .= ';';
$sql4 .= ';';
$this->db->setQuery($sql2);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Categories : ' . $total . '</p>';
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported category : 0</p>';
}
if( isset($total) && $total > 0)
{
$rebuild = true;
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'reds_import_max_hk_cat'; ");
$this->db->query();
}
if ($doSql3)
{
$this->db->setQuery($sql3);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links : ' . $total . '</p>';
}
if($doSql4)
{
$this->db->setQuery($sql4);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Categories files : ' . $total . '</p>';
}
if( $rebuild )
$this->importRebuildTree();
if( $cpt < $count )
$ret = true;
return $ret;
}
function importProducts()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
5 :</span>Â Import Products</p>';
$ret = false;
$count = 100;
$offset = $this->options->current;
$max = 0;
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$this->db->setQuery('SELECT rsp.product_id, rsm.media_name
FROM `#__redshop_product` rsp '.
'LEFT JOIN `#__redshop_media` rsm ON rsp.product_id =
rsm.section_id '.
'LEFT JOIN `#__hikashop_reds_prod` hkprod ON rsp.product_id =
hkprod.reds_id '.
"WHERE rsp.product_id > ".$offset." AND
hkprod.hk_id IS NULL AND (rsm.media_name IS NOT NULL) AND rsm.media_name
<> '' AND rsm.media_section = 'product' ".
'ORDER BY product_id ASC LIMIT '.$count.';'
);
$datas = $this->db->loadObjectList();
$this->copyImgDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode($this->copyImgDir)),DS.'
').DS);
if (!empty($datas))
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying products images... </p>';
foreach($datas as $data) {
if( !empty($data->media_name) ) {
$file_name =
str_replace('\\','/',$data->media_name);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyImgDir,$data->media_name,
$this->options->uploadfolder.$file_name);
$max = $data->product_id;
}
}
}
if( $max > 0 )
{
echo '<p>Copying files...(last proccessed product id: '
. $max . ')</p>';
$this->options->current = $max;
$this->refreshPage = true;
return $ret;
}
$data = array(
'product_name' => 'rsp.product_name',
'product_description' => 'rsp.product_desc',
'product_meta_description' => 'rsp.metadesc',
'product_quantity' => 'case when
quantity_selectbox_value IS NULL or quantity_selectbox_value < 0 then 0
else quantity_selectbox_value end',
'product_code' => 'rsp.hika_sku',
'product_published' => 'rsp.published',
'product_hit' => 'rsp.visited',
'product_created' => 'rsp.publish_date',
'product_modified' => 'rsp.update_date',
'product_sale_start' =>
'rsp.product_availability_date',
'product_tax_id' => 'hkc.category_id',
'product_type' => "'main'",
'product_url' => 'rsp.sef_url',
'product_canonical' => 'rsp.canonical_url',
'product_weight' => 'rsp.weight',
'product_weight_unit' =>
"LOWER('".DEFAULT_WEIGHT_UNIT."')",
'product_dimension_unit' =>
"LOWER('".DEFAULT_VOLUME_UNIT."')",
'product_min_per_order' =>
'rsp.min_order_product_quantity',
'product_max_per_order' =>
'rsp.max_order_product_quantity',
'product_sales' => '0',
'product_width' => 'rsp.product_width',
'product_length' => 'rsp.product_length',
'product_height' => 'rsp.product_height',
'product_parent_id' => '0'
//rsp.product_parent_id ?
);
$sql1 = 'INSERT IGNORE INTO `#__hikashop_product`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__redshop_product` AS rsp '.
'LEFT JOIN `#__hikashop_taxation` hkt ON hkt.tax_reds_id =
rsp.product_tax_id '.
'LEFT JOIN `#__hikashop_category` hkc ON hkc.category_namekey =
hkt.category_namekey '.
'LEFT JOIN `#__hikashop_reds_prod` AS hkp ON rsp.product_id =
hkp.reds_id '.
'WHERE hkp.hk_id IS NULL ORDER BY rsp.product_id ASC;';
$this->db->setQuery("SHOW COLUMNS FROM `#__redshop_product`
LIKE 'hika_sku';");
$data = $this->db->loadObjectList();
if (empty($data))
{
$this->db->setQuery('ALTER TABLE `#__redshop_product` ADD
COLUMN `hika_sku` VARCHAR(255) NOT NULL;');
$this->db->query();
}
$this->db->setQuery("UPDATE `#__redshop_product` AS rsp SET
rsp.hika_sku = CONCAT(rsp.product_name,'_',rsp.product_id) WHERE
rsp.hika_sku='';");
$this->db->query();
$this->db->setQuery('SELECT hika_sku FROM `#__redshop_product`
GROUP BY hika_sku HAVING COUNT(hika_sku)>1');
$data = $this->db->loadObjectList();
if (!empty($data))
{
foreach ($data as $d)
{
$this->db->setQuery("UPDATE `#__redshop_product` AS rsp SET
rsp.hika_sku = CONCAT(rsp.hika_sku,'_',rsp.product_id) WHERE
rsp.hika_sku = '".$d->hika_sku."';");
$this->db->query();
}
}
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
SKU generated: '.count($data).'</p>';
$data = array(
'reds_id' => 'rsp.product_id',
'hk_id' => 'hkp.product_id'
);
$sql2 = 'INSERT IGNORE INTO `#__hikashop_reds_prod`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__redshop_product` AS rsp '.
'INNER JOIN `#__hikashop_product` AS hkp ON CONVERT(rsp.hika_sku
USING utf8) = CONVERT(hkp.product_code USING utf8) '.
'LEFT JOIN `#__hikashop_reds_prod` hkrsp ON hkrsp.reds_id =
rsp.product_id '.
'WHERE hkrsp.hk_id IS NULL;';
$sql3 = 'UPDATE `#__hikashop_product` AS hkp '.
'INNER JOIN `#__redshop_product` AS rsp ON CONVERT(rsp.hika_sku
USING utf8) = CONVERT(hkp.product_code USING utf8) '.
'INNER JOIN `#__hikashop_reds_prod` hkrsp ON hkrsp.reds_id =
rsp.product_parent_id '.
'SET hkp.product_parent_id = hkrsp.hk_id;';
$data = array(
'file_name' => "''",
'file_description' => "''",
'file_path' =>
"SUBSTRING_INDEX(rsm.media_name,'/',-1)",
'file_type' => "'product'",
'file_ref_id' => 'hkprod.hk_id'
);
$sql4 = 'INSERT IGNORE INTO `#__hikashop_file`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__redshop_product` rsp '.
'INNER JOIN `#__redshop_media` rsm ON rsp.product_id =
rsm.section_id '.
'INNER JOIN `#__hikashop_reds_prod` hkprod ON rsp.product_id =
hkprod.reds_id '.
'WHERE rsp.product_id >
'.$this->options->last_reds_prod. ' AND (rsm.media_name IS
NOT NULL) AND (rsm.media_name <>'." '') AND
rsm.media_section = 'product' ;";
$sql5 = 'UPDATE `#__hikashop_product` AS hkp '.
'INNER JOIN `#__hikashop_reds_prod` AS hkrsp ON hkp.product_id =
hkrsp.hk_id '.
'INNER JOIN `#__redshop_product` AS rsp ON hkrsp.reds_id =
rsp.product_id '.
"INNER JOIN `#__hikashop_category` AS hkc ON hkc.category_type =
'manufacturer' AND rsp.manufacturer_id = hkc.category_menu
".
'SET hkp.product_manufacturer_id = hkc.category_id '.
'WHERE rsp.manufacturer_id >
'.$this->options->last_reds_manufacturer.' OR
rsp.product_id >
'.$this->options->last_reds_prod.';';
$this->db->setQuery($sql1);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products: ' . $total . '</p>';
$this->db->setQuery($sql2);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links: ' . $total . '</p>';
$this->db->setQuery($sql3);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating products for parent links: ' . $total .
'</p>';
$this->db->setQuery($sql4);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products files: ' . $total . '</p>';
$this->db->setQuery($sql5);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating products manufacturers: ' . $total . '</p>';
$ret = true;
return $ret;
}
function importProductPrices()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
6 :</span>Â Import Product Prices</p>';
$ret = false;
$cpt = 0;
$data = array(
'price_product_id' => 'hkprod.hk_Id',
'price_value' => 'rsp.product_price',
'price_currency_id' => "case when hkcur.currency_id IS
NULL then '0' else hkcur.currency_id end",
'price_min_quantity' => "case when
rspp.price_quantity_start IS NULL then '0' else
rspp.price_quantity_start end",
'price_access' => "'all'"
);
$this->db->setQuery('INSERT IGNORE INTO #__hikashop_price
(`'.implode('`,`',array_keys($data)).'`) '
.'SELECT '.implode(',',$data).'FROM
#__redshop_product rsp '
.'INNER JOIN #__hikashop_reds_prod hkprod ON rsp.product_id =
hkprod.reds_id '
.'LEFT JOIN #__redshop_product_price rspp ON rsp.product_id =
rspp.product_id '
.'LEFT JOIN #__redshop_currency rsc ON rspp.product_currency =
rsc.currency_id '
.'LEFT JOIN #__hikashop_currency hkcur ON
CONVERT(rsc.currency_code USING utf8) = CONVERT( hkcur.currency_code USING
utf8) '
.'WHERE rsp.product_id > ' .
(int)$this->options->last_reds_prod
);
$ret = $this->db->query();
$cpt = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Prices imported : ' . $cpt .'</p>';
return $ret;
}
function importProductCategory()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
7 :</span>Â Import Product Category</p>';
$ret = false;
$data = array(
'category_id' => 'hkrc.hk_id',
'product_id' => 'hkrp.hk_id',
'ordering' => 'rspcx.ordering',
);
$sql = 'INSERT IGNORE INTO `#__hikashop_product_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__redshop_product_category_xref` rspcx '.
'INNER JOIN `#__hikashop_reds_cat` hkrc ON rspcx.category_id =
hkrc.reds_id AND category_type=\'category\''.
'INNER JOIN `#__hikashop_reds_prod` hkrp ON rspcx.product_id =
hkrp.reds_id '.
'WHERE hkrp.reds_id > ' .
(int)$this->options->last_reds_prod . ' OR hkrc.reds_id >
' . (int)$this->options->last_reds_cat;
$this->db->setQuery($sql);
$ret = $this->db->query();
$total = $this->db->getAffectedRows();
$this->importRebuildTree();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products categories: ' . $total . '</p>';
return $ret;
}
function importUsers()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
8 :</span>Â Import Users</p>';
$ret = false;
$sql0 = 'INSERT IGNORE INTO `#__hikashop_user`
(`user_cms_id`,`user_email`) '.
'SELECT rsui.user_id, rsui.user_email FROM `#__redshop_users_info`
AS rsui '.
'LEFT JOIN `#__hikashop_user` AS hkusr ON rsui.user_id =
hkusr.user_cms_id '.
'WHERE hkusr.user_cms_id IS NULL;';
$data = array(
'address_user_id' => 'hku.user_id',
'address_firstname' => 'rsui.firstname',
'address_lastname' => 'rsui.lastname',
'address_company' => 'rsui.company_name',
'address_street' => 'rsui.address',
'address_post_code' => 'rsui.zipcode',
'address_city' => 'rsui.city',
'address_telephone' => 'rsui.phone',
'address_state' => 'hkzsta.zone_namekey',
'address_country' => 'hkzcou.zone_namekey',
'address_vat' => "case when
rsui.tax_exempt='0' then rsui.vat_number else ''
end",
'address_published' => '4'
);
$sql1 = 'INSERT IGNORE INTO `#__hikashop_address`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__redshop_users_info` AS rsui '.
'INNER JOIN `#__redshop_country` rsc ON rsui.country_code =
rsc.country_3_code '.
'INNER JOIN `#__redshop_state` rss ON rsc.country_id =
rss.country_id AND rsui.state_code = rss.state_2_code '.
'INNER JOIN `#__hikashop_user` AS hku ON rsui.user_id =
hku.user_cms_id '.
'INNER JOIN `#__hikashop_zone` AS hkzcou ON rsc.country_3_code =
hkzcou.zone_code_3 AND hkzcou.zone_type=\'country\' '.
'INNER JOIN `#__hikashop_zone_link` AS hkzl ON hkzcou.zone_namekey
= hkzl.zone_parent_namekey '.
'INNER JOIN `#__hikashop_zone` AS hkzsta ON rss.state_2_code =
hkzsta.zone_code_3 AND hkzsta.zone_type=\'state\' AND
hkzsta.zone_namekey = hkzl.zone_child_namekey '.
'WHERE rsui.user_id >
'.$this->options->last_reds_user.' ORDER BY rsui.user_id
ASC;';
$sql2 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone` AS hkz ON (a.address_country =
hkz.zone_code_3 AND hkz.zone_type = "country") '.
'SET address_country = hkz.zone_namekey, address_published = 3
WHERE address_published = 4;';
$sql3 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone_link` AS zl ON (a.address_country =
zl.zone_parent_namekey) '.
'JOIN `#__hikashop_zone` AS hks ON (hks.zone_namekey =
zl.zone_child_namekey AND hks.zone_type = "state" AND
hks.zone_code_3 = a.address_state) '.
'SET address_state = hks.zone_namekey, address_published = 2 WHERE
address_published = 3;';
$sql4 = "UPDATE `#__hikashop_address` AS a SET a.address_country =
'' WHERE address_published > 3;";
$sql5 = "UPDATE `#__hikashop_address` AS a SET a.address_state =
'' WHERE address_published > 2;";
$sql6 = 'UPDATE `#__hikashop_address` AS a SET a.address_published =
1 WHERE address_published > 1;';
$this->db->setQuery($sql0);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Users: ' . $total . '</p>';
$this->db->setQuery($sql1);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses: ' . $total . '</p>';
$this->db->setQuery($sql2);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses countries: ' . $total . '</p>';
$this->db->setQuery($sql3);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses states: ' . $total . '</p>';
$this->db->setQuery($sql4);
$this->db->query();
$this->db->setQuery($sql5);
$this->db->query();
$this->db->setQuery($sql6);
$this->db->query();
$ret = true;
return $ret;
}
function importDiscount()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
9 :</span>Â Import Discount</p>';
$ret = false;
$sql = "SELECT `config_value` FROM `#__hikashop_config` WHERE
config_namekey = 'main_currency';";
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$main_currency = $data[0]->config_value;
$data = array(
'discount_type' => "'discount'",
'discount_published' => 'published',
'discount_code' => "CONCAT('REDS_DISCOUNT_',
discount_id)", //Hum
'discount_currency_id' => $main_currency,
'discount_flat_amount' => "case when discount_type =
'0' then discount_amount else 0 end",
'discount_percent_amount' => "case when discount_type
= '1' then discount_amount else 0 end",
'discount_start' => 'start_date',
'discount_end' => 'end_date',
'discount_quota' => '0'
);
$sql1 = 'INSERT IGNORE INTO #__hikashop_discount
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
#__redshop_discount WHERE discount_id > ' .
(int)$this->options->last_reds_discount;
$data['discount_code'] =
"CONCAT('REDS_DISCOUNTPROD_', discount_product_id)";
$sql2 = 'INSERT IGNORE INTO #__hikashop_discount
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
#__redshop_discount_product WHERE discount_product_id > ' .
(int)$this->options->last_reds_discount_prod;
$data = array(
'discount_type' => "'coupon'",
'discount_published' => 'published',
'discount_code' => 'coupon_code',
'discount_currency_id' => $main_currency,
'discount_flat_amount' => "case when percent_or_total
= '0' then coupon_value else 0 end",
'discount_percent_amount' => "case when
percent_or_total = '1' then coupon_value else 0 end",
'discount_start' => 'start_date',
'discount_end' => 'end_date',
'discount_quota' => 'coupon_left'
);
$sql3 = 'INSERT IGNORE INTO #__hikashop_discount
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
#__redshop_coupons WHERE coupon_id > ' .
(int)$this->options->last_reds_coupon;
$data = array(
'discount_type' => "'coupon'",
'discount_published' => 'rsv.published',
'discount_code' => 'rsv.voucher_code',
'discount_currency_id' => $main_currency,
'discount_flat_amount' => "case when voucher_type =
'Percentage' then 0 else rsv.amount end",
'discount_percent_amount' => "case when voucher_type =
'Percentage' then rsv.amount else 0 end",
'discount_start' => 'rsv.start_date',
'discount_end' => 'rsv.end_date',
'discount_quota' => 'rsv.voucher_left',
'discount_product_id' => 'rspv.product_id'
);
$sql4 = 'INSERT IGNORE INTO #__hikashop_discount
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
#__redshop_product_voucher rsv '.
'LEFT JOIN #__redshop_product_voucher_xref AS rspv ON
rsv.voucher_id = rspv.voucher_id '.
'WHERE rsv.voucher_id > ' .
(int)$this->options->last_reds_voucher;
$this->db->setQuery($sql1);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Discount codes imported : ' . $total . '</p>';
$this->db->setQuery($sql2);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Discount codes product imported : ' . $total .
'</p>';
$this->db->setQuery($sql3);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Coupons imported : ' . $total . '</p>';
$this->db->setQuery($sql4);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Vouchers imported : ' . $total . '</p>';
$ret = true;
return $ret;
}
function importOrders()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
10 :</span>Â Import Orders</p>';
$ret = false;
$offset = $this->options->current;
$count = 100;
$total = 0;
$vat_cols = "''";
$data = array(
'order_number' => 'rso.order_number',
'order_reds_id' => 'rso.order_id',
'order_user_id' => 'hkusr.user_id',
'order_status' => 'hkc.category_name',
'order_discount_price' =>
'rso.coupon_discount',
'order_created' => 'rso.cdate',
'order_modified' => 'rso.mdate',
'order_ip' => 'rso.ip_address',
'order_currency_id' => 'hkcur.currency_id',
'order_shipping_price' => 'rso.order_shipping',
'order_shipping_method' => "'Redshop
import'",
'order_shipping_id' => '1',
'order_payment_id' => 0,
'order_payment_method' => "'Redshop
import'",
'order_full_price' => 'rso.order_total',
'order_partner_id' => 0,
'order_partner_price' => 0,
'order_partner_paid' => 0,
'order_type' => "'sale'",
'order_partner_currency_id' => 0,
'order_shipping_tax' =>
'rso.order_shipping_tax',
'order_discount_tax' => 0
);
$sql1 = 'INSERT IGNORE INTO `#__hikashop_order`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__redshop_orders` AS rso '.
'INNER JOIN `#__redshop_order_item` AS rsoi ON rso.order_id =
rsoi.order_id '.
'INNER JOIN `#__redshop_order_status` AS rsos ON rso.order_status =
rsos.order_status_code '.
'JOIN `#__hikashop_category` AS hkc ON rsos.order_status_name =
hkc.category_name AND hkc.category_type = \'status\' '.
'JOIN `#__hikashop_currency` AS hkcur ON
CONVERT(rsoi.order_item_currency USING utf8) = CONVERT(hkcur.currency_code
USING utf8) '.
'JOIN `#__hikashop_user` AS hkusr ON rso.user_id =
hkusr.user_cms_id '.
'WHERE rso.order_id > ' .
(int)$this->options->last_reds_order . ' '.
'GROUP BY rso.order_id '.
'ORDER BY rso.order_id ASC;';
$sql1_1 = 'UPDATE `#__hikashop_order` AS hko '.
'INNER JOIN `#__redshop_coupons` AS rsc ON hko.order_reds_id =
rsc.order_id '.
'INNER JOIN `#__hikashop_discount` AS hkd ON hkd.discount_code =
rsc.coupon_code '.
'SET hko.order_discount_code = hkd.discount_code AND
hko.order_discount_price = hkd.discount_flat_amount';
$data = array(
'address_user_id' => 'rsui.user_id',
'address_firstname' => 'rsui.firstname',
'address_lastname' => 'rsui.lastname',
'address_company' => 'rsui.company_name',
'address_street' => 'rsui.address',
'address_post_code' => 'rsui.zipcode',
'address_city' => 'rsui.city',
'address_telephone' => 'rsui.phone',
'address_state' => 'hkzsta.zone_namekey',
'address_country' => 'hkzcou.zone_namekey',
'address_published' => "case when rsui.address_type =
'BT' then 7 else 8 end",
'address_vat' => "case when
rsui.tax_exempt='0' then rsui.vat_number else ''
end",
'address_reds_order_info_id' => 'rsui.order_id'
);
$sql2_1 = 'INSERT IGNORE INTO `#__hikashop_address`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__redshop_order_users_info` AS rsui '.
'INNER JOIN `#__redshop_country` rsc ON rsui.country_code =
rsc.country_3_code '.
'INNER JOIN `#__redshop_state` rss ON rsc.country_id =
rss.country_id AND rsui.state_code = rss.state_2_code '.
'INNER JOIN `#__hikashop_user` AS hku ON rsui.user_id =
hku.user_cms_id '.
'INNER JOIN `#__hikashop_zone` AS hkzcou ON rsc.country_3_code =
hkzcou.zone_code_3 AND hkzcou.zone_type=\'country\' '.
'INNER JOIN `#__hikashop_zone_link` AS hkzl ON hkzcou.zone_namekey
= hkzl.zone_parent_namekey '.
'INNER JOIN `#__hikashop_zone` AS hkzsta ON rss.state_2_code =
hkzsta.zone_code_3 AND hkzsta.zone_type=\'state\' AND
hkzsta.zone_namekey = hkzl.zone_child_namekey '.
'WHERE rsui.order_id >
'.$this->options->last_reds_order.' ORDER BY
rsui.order_info_id ASC';
$sql2_2 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone` AS hkz ON (a.address_country =
hkz.zone_code_3 AND hkz.zone_type = "country") '.
'SET address_country = hkz.zone_namekey, address_published = 6
WHERE address_published >= 7;';
$sql2_3 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone_link` AS zl ON (a.address_country =
zl.zone_parent_namekey) '.
'JOIN `#__hikashop_zone` AS hks ON (hks.zone_namekey =
zl.zone_child_namekey AND hks.zone_type = "state" AND
hks.zone_code_3 = a.address_state) '.
'SET address_state = hks.zone_namekey, address_published = 5 WHERE
address_published = 6;';
$sql2_4 = 'UPDATE `#__hikashop_address` AS a '.
'SET address_published = 0 WHERE address_published > 4;';
$sql3 = 'UPDATE `#__hikashop_order` AS o '.
'INNER JOIN `#__hikashop_address` AS a ON
a.address_reds_order_info_id = o.order_reds_id '.
'SET o.order_billing_address_id = a.address_id,
o.order_shipping_address_id = a.address_id '.
"WHERE o.order_billing_address_id = 0 AND address_published >= 7
;";
$sql4 = 'UPDATE `#__hikashop_order` AS o '.
'INNER JOIN `#__hikashop_address` AS a ON
a.address_reds_order_info_id = o.order_reds_id '.
'SET o.order_shipping_address_id = a.address_id '.
"WHERE o.order_shipping_address_id = 0 AND address_published >=
8 ;";
$sql5 = 'UPDATE `#__hikashop_order` AS hko '.
'JOIN `#__redshop_orders` AS rso ON hko.order_reds_id =
rso.order_id '.
"SET hko.order_payment_method = CONCAT('Redshop import:
', rso.payment_oprand) ".
'WHERE hko.order_reds_id > ' .
(int)$this->options->last_reds_order;
$this->db->setQuery($sql1);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported orders: ' . $total . '</p>';
$this->db->setQuery($sql1_1);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating discount orders: ' . $total . '</p>';
$this->db->setQuery($sql2_1);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported orders addresses: ' . $total . '</p>';
$this->db->setQuery($sql3);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating billing addresses: ' . $total . '</p>';
$this->db->setQuery($sql4);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating shipping addresses: ' . $total . '</p>';
$this->db->setQuery($sql5);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating order payments: ' . $total . '</p>';
$this->db->setQuery($sql2_2);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating orders: ' . $total;
$this->db->setQuery($sql2_3);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '/' . $total;
$this->db->setQuery($sql2_4);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '/' . $total . '</p>';
$ret = true;
return $ret;
}
function importOrderItems()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
11 :</span>Â Import Order Items</p>';
$ret = false;
$offset = $this->options->current;
$count = 100;
$data = array(
'order_id' => 'hko.order_id',
'product_id' => 'hkp.hk_id',
'order_product_quantity' =>
'rsoi.product_quantity',
'order_product_name' => 'rsoi.order_item_name',
'order_product_code' => 'rsp.hika_sku',
'order_product_price' =>
'rsoi.product_item_price',
'order_product_tax' => "''",
'order_product_options' => "''"
);
$sql = 'INSERT IGNORE INTO `#__hikashop_order_product`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__redshop_order_item` AS rsoi '.
'INNER JOIN `#__redshop_product` rsp ON
rsoi.product_id=rsp.product_id '.
'INNER JOIN `#__hikashop_order` AS hko ON rsoi.order_id =
hko.order_reds_id '.
'INNER JOIN `#__hikashop_reds_prod` AS hkp ON rsoi.product_id =
hkp.reds_id '.
'WHERE rsoi.order_id > ' .
(int)$this->options->last_reds_order . ';';
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Orders Items : '. $total .'</p>';
$ret = true;
return $ret;
}
function importDownloads()
{
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
12 :</span>Â Import Downloads</p>';
$ret = false;
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$count = 100;
$offset = $this->options->current;
if( $offset == 0 )
$offset = $this->options->last_reds_pfile;
$sql = "SELECT `config_value` FROM `#__hikashop_config` WHERE
config_namekey = 'download_number_limit';";
$this->db->setQuery($sql);
$sql = 'SELECT download_id, file_name FROM
`#__redshop_product_download` WHERE download_id >
'.$offset.';';
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$max = 0;
if (!empty($data))
{
$this->copyDownloadDir =
str_replace('\\','/',rtrim(JPath::clean(html_entity_decode($this->copyDownloadDir)),DS.'
').DS);
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying downloads files... </p>';
foreach($data as $c)
{
$file_name =
end(explode('/',str_replace('\\','/',$c->filename)));
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$dstFolder = $this->options->uploadfolder; //secure ?
$this->copyFile($this->copyDownloadDir, $c->filename,
$dstFolder.$file_name);
$max = $c->download_id;
}
if( $max > 0 )
{
echo '<p>Copying files...<br/>(Last processed file id:
' . $max . '</p>';
$this->options->current = $max;
$this->refreshPage = true;
return $ret;
}
}
$data = array(
'file_name' => 'rspd.file_name',
'file_description' => "'File imported from
Redshop'",
'file_path' =>
"SUBSTRING_INDEX(SUBSTRING_INDEX(rspd.file_name, '/', -1),
'\\\\', -1)",
'file_type' => "'file'",
'file_ref_id' => 'hkrsp.hk_id'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_file`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__redshop_product_download` AS rspd '.
'LEFT JOIN `#__hikashop_reds_prod` AS hkrsp ON rspd.product_id =
hkrsp.reds_id '.
'WHERE rspd.download_id >
'.$this->options->last_reds_pfile;
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Downloable files imported : ' . $total . '</p>';
$data = array(
'file_id' => 'hkf.file_id',
'order_id' => 'hko.order_id',
'download_number' => 'rspd.download_max'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_download`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__redshop_product_download` AS rspd '.
'INNER JOIN `#__hikashop_order` AS hko ON hko.order_reds_id =
rspd.order_id '.
'INNER JOIN `#__hikashop_reds_prod` AS hkp ON hkp.reds_id =
rspd.product_id '.
'INNER JOIN `#__hikashop_file` AS hkf ON ( CONVERT(hkf.file_name
USING utf8) = CONVERT(rspd.file_name USING utf8) )'.
"WHERE hkf.file_type = 'file' AND (hkp.hk_id =
hkf.file_ref_id) AND (rspd.product_id >
".$this->options->last_reds_prod.' OR rspd.order_id >
' . (int)$this->options->last_reds_order . ');';
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Downloable order files imported : ' . $total .
'</p>';
$ret = true;
return $ret;
}
function finishImport()
{
$this->db->setQuery("SELECT max(category_id) as
'max' FROM `#__hikashop_category`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(product_id) as 'max'
FROM `#__hikashop_product`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_prod = (int)($data[0]->max);
$this->db->setQuery("SELECT max(reds_id) as 'max'
FROM `#__hikashop_reds_cat`;");
$data = $this->db->loadObjectList();
$this->options->last_reds_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(reds_id) as 'max'
FROM `#__hikashop_reds_prod`;");
$data = $this->db->loadObjectList();
$this->options->last_reds_prod = (int)($data[0]->max);
$this->db->setQuery("SELECT max(user_id) as 'max'
FROM `#__redshop_users_info`;");
$data = $this->db->loadObjectList();
$this->options->last_reds_user = (int)($data[0]->max);
$this->db->setQuery("SELECT max(order_reds_id) as
'max' FROM `#__hikashop_order`;");
$data = $this->db->loadObjectList();
$this->options->last_reds_order = (int)($data[0]->max);
$this->db->setQuery("SELECT max(rsm.media_id) as
'max' FROM `#__redshop_media` rsm INNER JOIN `#__redshop_product`
rsp ON rsp.product_id = rsm.section_id AND media_section =
'product';");
$data = $this->db->loadObject();
$this->options->last_reds_pfile = (int)($data->max);
$this->db->setQuery("SELECT max(coupon_id) as 'max'
FROM `#__redshop_coupons`;");
$data = $this->db->loadObject();
$this->options->last_reds_coupon = (int)($data->max);
$this->db->setQuery("SELECT max(discount_id) as
'max' FROM `#__redshop_discount`;");
$data = $this->db->loadObject();
$this->options->last_reds_discount = (int)($data->max);
$this->db->setQuery("SELECT max(discount_product_id) as
'max' FROM `#__redshop_discount_product`;");
$data = $this->db->loadObject();
$this->options->last_reds_discount_prod = (int)($data->max);
$this->db->setQuery("SELECT max(voucher_id) as 'max'
FROM `#__redshop_product_voucher`;");
$data = $this->db->loadObject();
$this->options->last_reds_voucher = (int)($data->max);
$this->db->setQuery("SELECT max(tax_rate_id) as
'max' FROM `#__redshop_tax_rate`;");
$data = $this->db->loadObject();
$this->options->last_reds_taxrate = (int)($data->max);
$this->db->setQuery("SELECT max(tax_group_id) as
'max' FROM `#__redshop_tax_group`;");
$data = $this->db->loadObject();
$this->options->last_reds_taxclass = (int)($data->max);
$this->db->setQuery("SELECT max(manufacturer_id) as
'max' FROM `#__redshop_manufacturer`;");
$data = $this->db->loadObjectList();
$this->options->last_reds_manufacturer = (int)($data[0]->max);
$this->options->state = (MAX_IMPORT_ID+1);
$query = 'REPLACE INTO `#__hikashop_config`
(`config_namekey`,`config_value`,`config_default`) VALUES '.
"('reds_import_state',".$this->options->state.",".$this->options->state.")".
",('reds_import_max_hk_cat',".$this->options->max_hk_cat.",".$this->options->max_hk_cat.")".
",('reds_import_max_hk_prod',".$this->options->max_hk_prod.",".$this->options->max_hk_prod.")".
",('reds_import_last_reds_cat',".$this->options->last_reds_cat.",".$this->options->last_reds_cat.")".
",('reds_import_last_reds_prod',".$this->options->last_reds_prod.",".$this->options->last_reds_prod.")".
",('reds_import_last_reds_user',".$this->options->last_reds_user.",".$this->options->last_reds_user.")".
",('reds_import_last_reds_order',".$this->options->last_reds_order.",".$this->options->last_reds_order.")".
",('reds_import_last_reds_pfile',".$this->options->last_reds_pfile.",".$this->options->last_reds_pfile.")".
",('reds_import_last_reds_coupon',".$this->options->last_reds_coupon.",".$this->options->last_reds_coupon.")".
",('reds_import_last_reds_discount',".$this->options->last_reds_discount.",".$this->options->last_reds_discount.")".
",('reds_import_last_reds_discount_prod',".$this->options->last_reds_discount_prod.",".$this->options->last_reds_discount_prod.")".
",('reds_import_last_reds_voucher',".$this->options->last_reds_voucher.",".$this->options->last_reds_voucher.")".
",('reds_import_last_reds_taxrate',".$this->options->last_reds_taxrate.",".$this->options->last_reds_taxrate.")".
",('reds_import_last_reds_taxclass',".$this->options->last_reds_taxclass.",".$this->options->last_reds_taxclass.")".
",('reds_import_last_reds_manufacturer',".$this->options->last_reds_manufacturer.",".$this->options->last_reds_manufacturer.")".
';';
$this->db->setQuery($query);
$this->db->query();
echo '<p'.$this->titlefont.'>Import finished
!</p>';
$class = hikashop_get('class.plugins');
$infos =
$class->getByName('system','reds_redirect');
if($infos)
{
$pkey = reset($class->pkeys);
if(!empty($infos->$pkey))
{
if(version_compare(JVERSION,'1.6','<'))
$url =
JRoute::_('index.php?option=com_plugins&view=plugin&client=site&task=edit&cid[]='.$infos->$pkey);
else
$url =
JRoute::_('index.php?option=com_plugins&view=plugin&layout=edit&extension_id='.$infos->$pkey);
echo '<p>You can publish the
<a'.$this->linkstyle.'
href="'.$url.'">Redshop Fallback Redirect
Plugin</a> so that your old Redshop links are automatically
redirected to HikaShop pages and thus not loose the ranking of your content
on search engines.</p>';
}
}
}
}
?>
importvm.php000064400000234062151162557640007155 0ustar00<?php
/**
* @package HikaShop for Joomla!
* @version 2.2.3
* @author hikashop.com
* @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
@include_once(HIKASHOP_ROOT .
'administrator/components/com_virtuemart/virtuemart.cfg.php');
class hikashopImportvmHelper extends hikashopImportHelper
{
var $vm_version = 0; //TODO : TOCHECK
var $vm_current_lng = '';
function __construct(&$parent)
{
parent::__construct();
$this->importName = 'vm';
jimport('joomla.filesystem.file');
}
function importFromVM()
{
@ob_clean();
echo $this->getHtmlPage();
$this->token = hikashop_getFormToken();
flush();
$lang = JFactory::getLanguage();
$this->vm_current_lng = str_replace('-', '_',
strtolower($lang->get('tag')));
if( isset($_GET['import']) && $_GET['import']
== '1' )
{
$time = microtime(true);
$processed = $this->doImport();
if($processed)
{
$elasped = microtime(true) - $time;
if( !$this->refreshPage )
echo '<p><a'.$this->linkstyle.'
href="'.hikashop_completeLink('import&task=import&importfrom=vm&'.$this->token.'=1&import=1').'">'.JText::_('HIKA_NEXT').'</a></p>';
echo '<p style="font-size:0.85em;
color:#605F5D;">Elasped time: ' . round($elasped * 1000, 2) .
'ms</p>';
}
else
{
echo '<a'.$this->linkstyle.'
href="'.hikashop_completeLink('import&task=show').'">'.JText::_('HIKA_BACK').'</a>';
}
}
else
{
echo $this->getStartPage();
}
if( $this->refreshPage == true )
{
echo "<script type=\"text/javascript\">\r\nr =
true;\r\n</script>";
}
echo '</body></html>';
exit;
}
function doImport() {
if( $this->db == null )
return false;
$this->loadConfiguration();
$current = $this->options->current;
$ret = true;
$next = false;
switch( $this->options->state ) {
case 0:
$next = $this->createTables();
break;
case 1:
$next = $this->importTaxes();
break;
case 2:
$next = $this->importManufacturers();
break;
case 3:
$next = $this->importCategories();
break;
case 4:
$next = $this->importProducts();
break;
case 5:
$next = $this->importProductPrices();
break;
case 6:
$next = $this->importProductCategory();
break;
case 7:
$next = $this->importUsers();
break;
case 8:
$next = $this->importDiscount();
break;
case 9:
$next = $this->importOrders();
break;
case 10:
$next = $this->importOrderItems();
break;
case 11:
$next = $this->importDownloads();
break;
case MAX_IMPORT_ID:
$next = $this->finishImport();
$ret = false;
break;
case MAX_IMPORT_ID+1:
$next = false;
$ret = $this->proposeReImport();
break;
default:
$ret = false;
break;
}
if( $ret && $next ) {
$sql = "UPDATE `#__hikashop_config` SET
config_value=(config_value+1) WHERE config_namekey =
'vm_import_state'; ";
$this->db->setQuery($sql);
$this->db->query();
$sql = "UPDATE `#__hikashop_config` SET config_value=0 WHERE
config_namekey = 'vm_import_current';";
$this->db->setQuery($sql);
$this->db->query();
} else if( $current != $this->options->current ) {
$sql = "UPDATE `#__hikashop_config` SET
config_value=".$this->options->current." WHERE
config_namekey = 'vm_import_current';";
$this->db->setQuery($sql);
$this->db->query();
}
return $ret;
}
function loadConfiguration() {
if( $this->db == null )
return false;
$this->loadVmConfigs();
$data = array(
'uploadfolder',
'uploadsecurefolder',
'main_currency',
'vm_import_state',
'vm_import_current',
'vm_import_tax_id',
'vm_import_main_cat_id',
'vm_import_max_hk_cat',
'vm_import_max_hk_prod',
'vm_import_last_vm_cat',
'vm_import_last_vm_prod',
'vm_import_last_vm_user',
'vm_import_last_vm_order',
'vm_import_last_vm_pfile',
'vm_import_last_vm_coupon',
'vm_import_last_vm_taxrate',
'vm_import_last_vm_manufacturer'
);
$this->db->setQuery('SELECT config_namekey, config_value FROM
`#__hikashop_config` WHERE config_namekey IN
('."'".implode("','",$data)."'".');');
$options = $this->db->loadObjectList();
$this->options = null;
if (!empty($options))
{
foreach($options as $o) {
if( substr($o->config_namekey, 0, 10) == 'vm_import_' ) {
$nk = substr($o->config_namekey, 10);
} else {
$nk = $o->config_namekey;
}
$this->options->$nk = $o->config_value;
}
}
$this->options->uploadfolder =
rtrim(JPath::clean(html_entity_decode($this->options->uploadfolder)),DS.'
').DS;
if(!preg_match('#^([A-Z]:)?/.*#',$this->options->uploadfolder)){
if(!$this->options->uploadfolder[0]=='/' ||
!is_dir($this->options->uploadfolder)){
$this->options->uploadfolder =
JPath::clean(HIKASHOP_ROOT.DS.trim($this->options->uploadfolder,DS.'
').DS);
}
}
$this->options->uploadsecurefolder =
rtrim(JPath::clean(html_entity_decode($this->options->uploadsecurefolder)),DS.'
').DS;
if(!preg_match('#^([A-Z]:)?/.*#',$this->options->uploadsecurefolder)){
if(!$this->options->uploadsecurefolder[0]=='/' ||
!is_dir($this->options->uploadsecurefolder)){
$this->options->uploadsecurefolder =
JPath::clean(HIKASHOP_ROOT.DS.trim($this->options->uploadsecurefolder,DS.'
').DS);
}
}
if( !isset($this->options->state) ) {
$this->options->state = 0;
$this->options->current = 0;
$this->options->tax_id = 0;
$this->options->last_vm_coupon = 0;
$this->options->last_vm_pfile = 0;
$this->options->last_vm_taxrate = 0;
$this->options->last_vm_manufacturer = 0;
$element = 'product';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
$this->options->main_cat_id = $element;
$this->db->setQuery("SELECT max(category_id) as
'max' FROM `#__hikashop_category`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(product_id) as
'max' FROM `#__hikashop_product`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_prod = (int)($data[0]->max);
$query='SHOW TABLES LIKE
'.$this->db->Quote($this->db->getPrefix().substr(hikashop_table('vm_cat'),3));
$this->db->setQuery($query);
$table = $this->db->loadResult();
if(!empty($table)){
$this->db->setQuery("SELECT max(vm_id) as 'max'
FROM `#__hikashop_vm_cat`;");
$data = $this->db->loadObjectList();
if( $data ) {
$this->options->last_vm_cat = (int)($data[0]->max);
} else {
$this->options->last_vm_cat = 0;
}
$this->db->setQuery("SELECT max(vm_id) as 'max'
FROM `#__hikashop_vm_prod`;");
$data = $this->db->loadObjectList();
if( $data ) {
$this->options->last_vm_prod = (int)($data[0]->max);
} else {
$this->options->last_vm_prod = 0;
}
$this->db->setQuery("SELECT max(order_vm_id) as
'max' FROM `#__hikashop_order`;");
$data = $this->db->loadObjectList();
$this->options->last_vm_order = (int)($data[0]->max);
}else{
$this->options->last_vm_cat = 0;
$this->options->last_vm_prod = 0;
$this->options->last_vm_order = 0;
}
$this->options->last_vm_user = 0;
$sql = 'INSERT IGNORE INTO `#__hikashop_config`
(`config_namekey`,`config_value`,`config_default`) VALUES '.
"('vm_import_state',".$this->options->state.",".$this->options->state.")".
",('vm_import_current',".$this->options->current.",".$this->options->current.")".
",('vm_import_tax_id',".$this->options->tax_id.",".$this->options->tax_id.")".
",('vm_import_main_cat_id',".$this->options->main_cat_id.",".$this->options->main_cat_id.")".
",('vm_import_max_hk_cat',".$this->options->max_hk_cat.",".$this->options->max_hk_cat.")".
",('vm_import_max_hk_prod',".$this->options->max_hk_prod.",".$this->options->max_hk_prod.")".
",('vm_import_last_vm_cat',".$this->options->last_vm_cat.",".$this->options->last_vm_cat.")".
",('vm_import_last_vm_prod',".$this->options->last_vm_prod.",".$this->options->last_vm_prod.")".
",('vm_import_last_vm_user',".$this->options->last_vm_user.",".$this->options->last_vm_user.")".
",('vm_import_last_vm_order',".$this->options->last_vm_order.",".$this->options->last_vm_order.")".
",('vm_import_last_vm_pfile',".$this->options->last_vm_pfile.",".$this->options->last_vm_pfile.")".
",('vm_import_last_vm_coupon',".$this->options->last_vm_coupon.",".$this->options->last_vm_coupon.")".
",('vm_import_last_vm_taxrate',".$this->options->last_vm_taxrate.",".$this->options->last_vm_taxrate.")".
",('vm_import_last_vm_manufacturer',".$this->options->last_vm_manufacturer.",".$this->options->last_vm_manufacturer.")".
';';
$this->db->setQuery($sql);
$this->db->query();
}
}
function loadVmConfigs()
{
$configstring = '';
if ($this->vm_version==2)
{
$this->db->setQuery('SELECT config FROM
`#__virtuemart_configs`;');
$data = $this->db->loadObjectList();
$configstring = $data[0]->config;
$paths = $this->parseConfig($configstring);
foreach ($paths as $key => $value)
{
switch ($key)
{
case 'media_category_path' :
$this->copyCatImgDir = $value;
break;
case 'media_product_path' :
$this->copyImgDir = $value;
break;
case 'media_manufacturer_path' :
$this->copyManufDir = $value;
break;
default :
break;
}
}
}
elseif ($this->vm_version==1)
{
$this->copyImgDir = IMAGEPATH. 'product/';
if ( substr($this->copyImgDir, 0, 1)=='/')
$this->copyImgDir = HIKASHOP_ROOT.substr($this->copyImgDir, 1,
strlen($this->copyImgDir)-1);
$this->copyCatImgDir = IMAGEPATH. 'category/';
if ( substr($this->copyCatImgDir, 0, 1)=='/')
$this->copyCatImgDir = HIKASHOP_ROOT.substr($this->copyCatImgDir, 1,
strlen($this->copyCatImgDir)-1);
$this->copyManufDir = IMAGEPATH. 'vendor/';
if ( substr($this->copyManufDir, 0, 1)=='/')
$this->copyManufDir = HIKASHOP_ROOT.substr($this->copyManufDir, 1,
strlen($this->copyManufDir)-1);
}
}
function parseConfig($string)
{
$arraypath = array(
'media_category_path',
'media_product_path',
'media_manufacturer_path'
);
$paths =array();
$firstparse = explode('|', $string);
foreach ($firstparse as $fp)
{
$secondparse = explode('=', $fp);
if (in_array($secondparse[0],$arraypath))
{
$thirdparse = explode('"', $secondparse[1]);
$paths[$secondparse[0]] = $thirdparse[1];
}
}
return $paths;
}
function finishImport() {
if( $this->db == null )
return false;
if ($this->vm_version!=1 && $this->vm_version!=2)
return false;
$this->db->setQuery("SELECT max(category_id) as
'max' FROM `#__hikashop_category`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(product_id) as 'max'
FROM `#__hikashop_product`;");
$data = $this->db->loadObjectList();
$this->options->max_hk_prod = (int)($data[0]->max);
$this->db->setQuery("SELECT max(vm_id) as 'max' FROM
`#__hikashop_vm_cat`;");
$data = $this->db->loadObjectList();
$this->options->last_vm_cat = (int)($data[0]->max);
$this->db->setQuery("SELECT max(vm_id) as 'max' FROM
`#__hikashop_vm_prod`;");
$data = $this->db->loadObjectList();
$this->options->last_vm_prod = (int)($data[0]->max);
if ($this->vm_version==1)
$this->db->setQuery("SELECT max(user_id) as 'max'
FROM `#__vm_user_info`;");
elseif ($this->vm_version==2)
$this->db->setQuery("SELECT max(virtuemart_user_id) as
'max' FROM `#__virtuemart_userinfos`;");
$data = $this->db->loadObjectList();
$this->options->last_vm_user = (int)($data[0]->max);
$this->db->setQuery("SELECT max(order_vm_id) as
'max' FROM `#__hikashop_order`;");
$data = $this->db->loadObjectList();
$this->options->last_vm_order = (int)($data[0]->max);
if ($this->vm_version==1)
$this->db->setQuery("SELECT max(file_id) as 'max'
FROM `#__vm_product_files`;");
elseif ($this->vm_version==2)
$this->db->setQuery("SELECT max(vmpm.virtuemart_media_id) as
'max' FROM `#__virtuemart_products` vmp INNER JOIN
`#__virtuemart_product_medias` vmpm ON vmp.virtuemart_product_id =
vmpm.virtuemart_product_id INNER JOIN `#__virtuemart_medias` vmm ON
vmpm.virtuemart_media_id = vmm.virtuemart_media_id;");
$data = $this->db->loadObject();
$this->options->last_vm_pfile = (int)($data->max);
if ($this->vm_version==1)
$this->db->setQuery("SELECT max(coupon_id) as 'max'
FROM `#__vm_coupons`;");
elseif ($this->vm_version==2)
$this->db->setQuery("SELECT max(virtuemart_coupon_id) as
'max' FROM `#__virtuemart_coupons`;");
$data = $this->db->loadObject();
$this->options->last_vm_coupon = (int)($data->max);
if ($this->vm_version==1)
$this->db->setQuery("SELECT max(tax_rate_id) as
'max' FROM `#__vm_tax_rate`;");
elseif ($this->vm_version==2)
$this->db->setQuery("SELECT max(virtuemart_calc_id) as
'max' FROM `#__virtuemart_calcs`;");
$data = $this->db->loadObject();
$this->options->last_vm_taxrate = (int)($data->max);
if ($this->vm_version==1)
$this->db->setQuery("SELECT max(manufacturer_id) as
'max' FROM `#__vm_manufacturer`;");
elseif ($this->vm_version==2)
$this->db->setQuery("SELECT max(virtuemart_manufacturer_id)
as 'max' FROM `#__virtuemart_manufacturers`;");
$data = $this->db->loadObjectList();
$this->options->last_vm_manufacturer = (int)($data[0]->max);
$this->options->state = (MAX_IMPORT_ID+1);
$query = 'REPLACE INTO `#__hikashop_config`
(`config_namekey`,`config_value`,`config_default`) VALUES '.
"('vm_import_state',".$this->options->state.",".$this->options->state.")".
",('vm_import_max_hk_cat',".$this->options->max_hk_cat.",".$this->options->max_hk_cat.")".
",('vm_import_max_hk_prod',".$this->options->max_hk_prod.",".$this->options->max_hk_prod.")".
",('vm_import_last_vm_cat',".$this->options->last_vm_cat.",".$this->options->last_vm_cat.")".
",('vm_import_last_vm_prod',".$this->options->last_vm_prod.",".$this->options->last_vm_prod.")".
",('vm_import_last_vm_user',".$this->options->last_vm_user.",".$this->options->last_vm_user.")".
",('vm_import_last_vm_order',".$this->options->last_vm_order.",".$this->options->last_vm_order.")".
",('vm_import_last_vm_pfile',".$this->options->last_vm_pfile.",".$this->options->last_vm_pfile.")".
",('vm_import_last_vm_coupon',".$this->options->last_vm_coupon.",".$this->options->last_vm_coupon.")".
",('vm_import_last_vm_taxrate',".$this->options->last_vm_taxrate.",".$this->options->last_vm_taxrate.")".
",('vm_import_last_vm_manufacturer',".$this->options->last_vm_manufacturer.",".$this->options->last_vm_manufacturer.")".
';';
$this->db->setQuery($query);
$this->db->query();
echo '<p'.$this->titlefont.'>Import finished
!</p>';
$class = hikashop_get('class.plugins');
$infos =
$class->getByName('system','vm_redirect');
if($infos){
$pkey = reset($class->pkeys);
if(!empty($infos->$pkey)){
if(version_compare(JVERSION,'1.6','<')){
$url =
JRoute::_('index.php?option=com_plugins&view=plugin&client=site&task=edit&cid[]='.$infos->$pkey);
}else{
$url =
JRoute::_('index.php?option=com_plugins&view=plugin&layout=edit&extension_id='.$infos->$pkey);
}
echo '<p>You can publish the
<a'.$this->linkstyle.'
href="'.$url.'">VirtueMart Fallback Redirect
Plugin</a> so that your old VirtueMart links are automatically
redirected to HikaShop pages and thus not loose the ranking of your content
on search engines.</p>';
}
}
}
function createTables() {
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
1 :</span>Â Initialization Tables</p>';
$create = true;
$query='SHOW TABLES LIKE
'.$this->db->Quote($this->db->getPrefix().substr(hikashop_table('vm_cat'),3));
$this->db->setQuery($query);
$table = $this->db->loadResult();
if(!empty($table) ) {
$create = false;
}
if( $create ) {
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_vm_prod` (`vm_id` int(10) unsigned NOT NULL DEFAULT
'0', `hk_id` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`vm_id`)) ENGINE=MyISAM");
$this->db->query();
$this->db->setQuery("CREATE TABLE IF NOT EXISTS
`#__hikashop_vm_cat` (`vm_id` int(10) unsigned NOT NULL DEFAULT
'0', `hk_id` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`vm_id`)) ENGINE=MyISAM");
$this->db->query();
$this->db->setQuery('ALTER IGNORE TABLE `#__hikashop_address`
ADD `address_vm_order_info_id` INT(11) NULL');
$this->db->query();
$this->db->setQuery('ALTER IGNORE TABLE `#__hikashop_order`
ADD `order_vm_id` INT(11) NULL');
$this->db->query();
$this->db->setQuery('ALTER IGNORE TABLE `#__hikashop_order`
ADD INDEX ( `order_vm_id` )');
$this->db->query();
$this->db->setQuery('ALTER IGNORE TABLE
`#__hikashop_taxation` ADD `tax_vm_id` INT(11) NULL');
$this->db->query();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
All table created</p>';
}
else
{
echo '<p>Tables have been already created.</p>';
}
return true;
}
function importTaxes() {
if( $this->db == null )
return false;
$ret = false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
2 :</span>Â Import Taxes<p>';
if ($this->vm_version==1)
{
$buffTable="#__vm_tax_rate";
$data = array(
'tax_namekey' => "CONCAT('VM_TAX_',
vmtr.tax_rate_id)",
'tax_rate' => 'vmtr.tax_rate'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_tax`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$buffTable.'` AS vmtr '.
'WHERE vmtr.tax_rate_id > ' .
(int)$this->options->last_vm_taxrate;
}
elseif ($this->vm_version==2)
{
$buffTable="#__virtuemart_calcs";
$data = array(
'tax_namekey' => "CONCAT('VM_TAX_',
vmtr.virtuemart_calc_id)",
'tax_rate' => 'vmtr.calc_value'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_tax`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$buffTable.'` AS vmtr '.
'WHERE vmtr.virtuemart_calc_id > ' .
(int)$this->options->last_vm_taxrate;
}
else
{
return false;
}
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported taxes: ' . $total . '</p>';
$element = 'tax';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
if ($this->vm_version==1)
{
$data = array(
'category_type' => "'tax'",
'category_name' => "CONCAT('Tax imported
(', vmtr.tax_country,')')",
'category_published' => '1',
'category_parent_id' => $element,
'category_namekey' => "CONCAT('VM_TAX_',
vmtr.tax_rate_id,'_',hkz.zone_id)",
);
$sql = 'INSERT IGNORE INTO `#__hikashop_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__vm_tax_rate` vmtr '.
"INNER JOIN `#__hikashop_zone` hkz ON vmtr.tax_country =
hkz.zone_code_3 AND hkz.zone_type = 'country' ".
'WHERE vmtr.tax_rate_id > ' .
(int)$this->options->last_vm_taxrate;
}
elseif ($this->vm_version==2)
{
$data = array(
'category_type' => "'tax'",
'category_name' => "case when vmcs.country_name IS
NULL then 'Tax imported (no country)' else CONCAT('Tax
imported (', vmcs.country_name,')') end",
'category_published' => '1',
'category_parent_id' => $element,
'category_namekey' => "case when hkz.zone_id IS NULL
then CONCAT('VM_TAX_', vmtr.virtuemart_calc_id,'_0')
else CONCAT('VM_TAX_',
vmtr.virtuemart_calc_id,'_',hkz.zone_id) end",
);
$sql = 'INSERT IGNORE INTO `#__hikashop_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__virtuemart_calcs` vmtr '.
"LEFT JOIN `#__virtuemart_calc_countries` vmcc ON
vmtr.virtuemart_calc_id = vmcc.virtuemart_calc_id " .
"LEFT JOIN `#__virtuemart_countries` vmcs ON
vmcc.virtuemart_country_id = vmcs.virtuemart_country_id ".
"LEFT JOIN `#__hikashop_zone` hkz ON vmcs.country_3_code =
hkz.zone_code_3 AND hkz.zone_type = 'country' ".
"WHERE vmtr.virtuemart_calc_id >" .
$this->options->last_vm_taxrate;
}
else
{
return false;
}
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Taxes Categories: ' . $total . '</p>';
if( $total > 0 ) {
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'vm_import_max_hk_cat'; ");
$this->db->query();
$this->importRebuildTree();
}
if ($this->vm_version==1)
{
$data = array(
'zone_namekey' => 'hkz.zone_namekey',
'category_namekey' => "CONCAT('VM_TAX_',
vmtr.tax_rate_id,'_',hkz.zone_id)",
'tax_namekey' => "CONCAT('VM_TAX_',
vmtr.tax_rate_id)",
'taxation_published' => '1',
'taxation_type' => "''",
'tax_vm_id' => 'vmtr.tax_rate_id'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_taxation`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__vm_tax_rate` vmtr '.
"INNER JOIN #__hikashop_zone hkz ON vmtr.tax_country =
hkz.zone_code_3 AND hkz.zone_type = 'country' ".
'WHERE vmtr.tax_rate_id > ' .
(int)$this->options->last_vm_taxrate;
}
elseif ($this->vm_version==2)
{
$data = array(
'zone_namekey' => "case when hkz.zone_namekey IS NULL
then '' else hkz.zone_namekey end",
'category_namekey' => "case when hkz.zone_id IS NULL
then CONCAT('VM_TAX_', vmtr.virtuemart_calc_id,'_0')
else CONCAT('VM_TAX_',
vmtr.virtuemart_calc_id,'_',hkz.zone_id) end",
'tax_namekey' => "CONCAT('VM_TAX_',
vmtr.virtuemart_calc_id)",
'taxation_published' => '1',
'taxation_type' => "''",
'tax_vm_id' => 'vmtr.virtuemart_calc_id'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_taxation`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__virtuemart_calcs` vmtr '.
"LEFT JOIN `#__virtuemart_calc_countries` vmcc ON
vmtr.virtuemart_calc_id = vmcc.virtuemart_calc_id " .
"LEFT JOIN `#__virtuemart_countries` vmcs ON
vmcc.virtuemart_country_id = vmcs.virtuemart_country_id ".
"LEFT JOIN `#__hikashop_zone` hkz ON vmcs.country_3_code =
hkz.zone_code_3 AND hkz.zone_type = 'country' ".
"WHERE vmtr.virtuemart_calc_id >" .
$this->options->last_vm_taxrate;
}
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Taxations: ' . $total . '</p>';
$ret = true;
return $ret;
}
function importManufacturers() {
if( $this->db == null )
return false;
$ret = false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
3 :</span>Â Import Manufacturers</p>';
$element = 'manufacturer';
$categoryClass = hikashop_get('class.category');
$categoryClass->getMainElement($element);
if ($this->vm_version==1)
{
$buffTable="#__vm_manufacturer";
$data = array(
'category_type' => "'manufacturer'",
'category_name' => "vmm.mf_name ",
'category_published' => '1',
'category_parent_id' => $element,
'category_namekey' =>
"CONCAT('VM_MANUFAC_', vmm.manufacturer_id )",
'category_description' => 'vmm.mf_desc',
'category_menu' => 'vmm.manufacturer_id'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$buffTable.'` vmm '.
'WHERE vmm.manufacturer_id > ' .
(int)$this->options->last_vm_manufacturer;
}
else if ($this->vm_version==2)
{
$buffTable="#__virtuemart_manufacturers_".$this->vm_current_lng;
if (!mysql_query('select 1 from `'.$buffTable.'`'))
$buffTable="#__virtuemart_manufacturers_en_gb";
$data = array(
'category_type' => "'manufacturer'",
'category_name' => "vmm.mf_name ",
'category_published' => '1',
'category_parent_id' => $element,
'category_namekey' =>
"CONCAT('VM_MANUFAC_', vmm.virtuemart_manufacturer_id
)",
'category_description' => 'vmm.mf_desc',
'category_menu' =>
'vmm.virtuemart_manufacturer_id'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`'.$buffTable.'` vmm '.
'WHERE vmm.virtuemart_manufacturer_id > ' .
(int)$this->options->last_vm_manufacturer;
}
else
{
return false;
}
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Manufacturers : ' . $total . '</p>';
if( $total > 0 )
{
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'vm_import_max_hk_cat'; ");
$this->db->query();
$this->importRebuildTree();
}
$ret = true;
return $ret;
}
function importCategories() {
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
4 :</span>Â Import General Categories</p>';
if( $this->db == null )
return false;
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$rebuild = false;
$ret = false;
$offset = 0;
$count = 100;
$statuses = array(
'P' => 'created',
'C' => 'confirmed',
'X' => 'cancelled',
'R'=> 'refunded' ,
'S' => 'shipped'
);
$this->db->setQuery("SELECT category_keywords,
category_parent_id FROM `#__hikashop_category` WHERE category_type =
'status' AND category_name = 'confirmed'");
$data = $this->db->loadObject();
$status_category = $data->category_parent_id;
if( $data->category_keywords != 'C' ) {
foreach($statuses as $k => $v) {
$this->db->setQuery("UPDATE `#__hikashop_category` SET
category_keywords = '".$k."' WHERE category_type =
'status' AND category_name = '".$v."';
");
$this->db->query();
}
}
if ($this->vm_version==1)
$this->db->setQuery("SELECT order_status_code,
order_status_name, order_status_description FROM `#__vm_order_status` WHERE
order_status_code NOT IN
('".implode("','",$statuses)."');");
elseif ($this->vm_version==2)
$this->db->setQuery("SELECT order_status_code,
order_status_name, order_status_description FROM
`#__virtuemart_orderstates` WHERE order_status_code NOT IN
('".implode("','",$statuses)."');");
else
return false;
$data = $this->db->loadObjectList();
if( count($data) > 0 )
{
$sql0 = 'INSERT IGNORE INTO `#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_description`,`category_published`,'.
'`category_namekey`,`category_access`,`category_menu`,`category_keywords`)
VALUES ';
$id = $this->options->max_hk_cat + 1;
$sep = '';
foreach($data as $c) {
$d = array(
$id++,
$status_category,
"'status'",
$this->db->quote( strtolower($c->order_status_name) ),
$this->db->quote( $c->order_status_description ),
'1',
$this->db->quote('status_vm_import_'.strtolower(str_replace('
','_',$c->order_status_name))),
"'all'",
'0',
$this->db->quote( $c->order_status_code )
);
if ($this->vm_version==2)
{
$d[3]=$this->db->quote(strtolower(JText::_($c->order_status_name)));
$d[6]=$this->db->quote('status_vm_import_'.strtolower(str_replace('
','_',JText::_($c->order_status_name))));
}
$sql0 .= $sep.'('.implode(',',$d).')';
$sep = ',';
}
$this->db->setQuery($sql0);
$this->db->query();
$total = $this->db->getAffectedRows();
if( $total > 0 )
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported order status categories : ' . $total .
'</p>';
$rebuild = true;
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'vm_import_max_hk_cat'; ");
$this->db->query();
$sql0 = '';
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported order status categories : 0</p>';
}
}
if ($this->vm_version==1)
{
$this->db->setQuery('SELECT * FROM `#__vm_category` vmc
'.
'LEFT JOIN `#__vm_category_xref` vmcx ON vmc.category_id =
vmcx.category_child_id '.
'LEFT JOIN `#__hikashop_vm_cat` hkvm ON vmc.category_id =
hkvm.vm_id '.
'ORDER BY category_parent_id ASC, list_order ASC, category_id
ASC;');
}
elseif ($this->vm_version==2)
{
$buffTable="#__virtuemart_categories_".$this->vm_current_lng;
if (!mysql_query('select 1 from `'.$buffTable.'`'))
$buffTable="#__virtuemart_categories_en_gb";
$this->db->setQuery('SELECT * FROM `#__virtuemart_categories`
vmc '.
"INNER JOIN `".$buffTable."` vmceg ON
vmc.virtuemart_category_id = vmceg.virtuemart_category_id ".
"INNER JOIN `#__virtuemart_category_medias` vmcm ON
vmceg.virtuemart_category_id = vmcm.virtuemart_category_id ".
"INNER JOIN `#__virtuemart_medias` vmm ON
vmcm.virtuemart_media_id = vmm.virtuemart_media_id ".
'LEFT JOIN `#__virtuemart_category_categories` vmcc ON
vmceg.virtuemart_category_id = vmcc.category_child_id '.
'LEFT JOIN `#__hikashop_vm_cat` hkvm ON
vmc.virtuemart_category_id = hkvm.vm_id '.
'ORDER BY category_parent_id ASC, vmc.ordering ASC,
vmc.virtuemart_category_id ASC;');
}
else
{
return false;
}
$data = $this->db->loadObjectList();
$total = count($data);
if( $total == 0 ) {
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported category : 0</p>';
if( $rebuild )
$this->importRebuildTree();
return true;
}
$sql0 = 'INSERT INTO `#__hikashop_category`
(`category_id`,`category_parent_id`,`category_type`,`category_name`,`category_description`,`category_published`,'.
'`category_ordering`,`category_namekey`,`category_created`,`category_modified`,`category_access`,`category_menu`)
VALUES ';
$sql1 = 'INSERT INTO `#__hikashop_vm_cat` (`vm_id`,`hk_id`) VALUES
';
$sql2 = 'INSERT INTO `#__hikashop_file`
(`file_name`,`file_description`,`file_path`,`file_type`,`file_ref_id`)
VALUES ';
$doSql2 = false;
$doSql1 = false;
$i = $this->options->max_hk_cat + 1;
$ids = array( 0 => $this->options->main_cat_id);
$cpt = 0;
$sep = '';
foreach($data as $c)
{
if( !empty($c->vm_id) )
{
if ($this->vm_version==1)
$ids[$c->category_id] = $c->hk_id;
elseif ($this->vm_version==2)
$ids[$c->virtuemart_category_id] = $c->hk_id;
}
else
{
$doSql1 = true;
if ($this->vm_version==1)
{
$ids[$c->category_id] = $i;
$sql1 .=
$sep.'('.$c->category_id.','.$i.')';
}
elseif ($this->vm_version==2)
{
$ids[$c->virtuemart_category_id] = $i;
$sql1 .=
$sep.'('.$c->virtuemart_category_id.','.$i.')';
}
$i++;
$sep = ',';
}
$cpt++;
if( $cpt >= $count )
break;
}
$sql1 .= ';';
if( $cpt == 0 ) {
if( $rebuild )
$this->importRebuildTree();
return true;
}
$cpt = 0;
$sep = '';
$sep2 = '';
foreach($data as $c)
{
if( !empty($c->vm_id) )
continue;
if ($this->vm_version==1)
$id = $ids[$c->category_id];
elseif ($this->vm_version==2)
$id = $ids[$c->virtuemart_category_id];
if(!empty($ids[$c->category_parent_id]))
$pid = (int)$ids[$c->category_parent_id];
else
$pid = $ids[0];
$element = new stdClass();
$element->category_id = $id;
$element->category_parent_id = $pid;
$element->category_name = $c->category_name;
$nameKey = $categoryClass->getNameKey($element);
if ($this->vm_version==1)
{
$d = array(
$id,
$pid,
"'product'",
$this->db->quote($c->category_name),
$this->db->quote($c->category_description),
'1',
$c->list_order,
$this->db->quote($nameKey),
$c->cdate,
$c->mdate,
"'all'",
'0'
);
}
elseif ($this->vm_version==2)
{
$d = array(
$id,
$pid,
"'product'",
$this->db->quote($c->category_name),
$this->db->quote($c->category_description),
'1',
$c->ordering,
$this->db->quote($nameKey),
$this->db->quote($c->created_on),
$this->db->quote($c->modified_on),
"'all'",
'0'
);
}
$sql0 .= $sep.'('.implode(',',$d).')';
if ($this->vm_version==1)
{
if( !empty($c->category_full_image)) {
$doSql2 = true;
$sql2 .=
$sep2."('','','".$c->category_full_image."','category',".$id.')';
$sep2 = ',';
$file_name =
str_replace('\\','/',$c->category_full_image);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyCatImgDir,$c->category_full_image,
$this->options->uploadfolder.$file_name);
}
}
elseif ($this->vm_version==2)
{
if( !empty($c->file_title)) {
$doSql2 = true;
$sql2 .=
$sep2."('','','".$c->file_title."','category',".$id.')';
$sep2 = ',';
$file_name =
str_replace('\\','/',$c->file_title);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyCatImgDir,$c->file_title,
$this->options->uploadfolder.$file_name);
}
}
$sep = ',';
$cpt++;
if( $cpt >= $count )
break;
}
if($cpt > 0)
{
$sql0 .= ';';
$this->db->setQuery($sql0);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Categories : ' . $total . '</p>';
}
else
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported category : 0</p>';
}
if( isset($total) && $total > 0)
{
$rebuild = true;
$this->options->max_hk_cat += $total;
$this->db->setQuery("UPDATE `#__hikashop_config` SET
config_value = ".$this->options->max_hk_cat." WHERE
config_namekey = 'vm_import_max_hk_cat'; ");
$this->db->query();
}
if ($doSql1)
{
$this->db->setQuery($sql1);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links : ' . $total . '</p>';
}
else
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links : 0</p>';
if( $doSql2 )
{
$sql2 .= ';';
$this->db->setQuery($sql2);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Categories files : ' . $total . '</p>';
}
else
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Categories files : 0</p>';
if( $rebuild )
$this->importRebuildTree();
if( $cpt < $count )
$ret = true;
return $ret;
}
function importRebuildTree() {
if( $this->db == null )
return false;
$categoryClass = hikashop_get('class.category');
$query = 'SELECT
category_namekey,category_left,category_right,category_depth,category_id,category_parent_id
FROM `#__hikashop_category` ORDER BY category_left ASC';
$this->db->setQuery($query);
$categories = $this->db->loadObjectList();
$root = null;
$categoryClass->categories = array();
foreach($categories as $cat){
$categoryClass->categories[$cat->category_parent_id][]=$cat;
if(empty($cat->category_parent_id)){
$root = $cat;
}
}
$categoryClass->rebuildTree($root,0,1);
}
function importProducts() {
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
5 :</span>Â Import Products</p>';
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$ret = false;
$count = 100;
$offset = $this->options->current;
$max = 0;
if ($this->vm_version==1)
{
$this->db->setQuery('SELECT vmp.product_id,
vmp.product_full_image '.
'FROM `#__vm_product` vmp '.
'LEFT JOIN `#__hikashop_vm_prod` hkprod ON vmp.product_id =
hkprod.vm_id '.
"WHERE vmp.product_id > ".$offset." AND
hkprod.hk_id IS NULL AND (vmp.product_full_image IS NOT NULL) AND
vmp.product_full_image <> '' ".
'ORDER BY product_id ASC LIMIT '.$count.';'
);
$data = $this->db->loadObjectList();
if (!empty($data))
{
foreach($data as $c) {
if( !empty($c->product_full_image) ) {
$file_name =
str_replace('\\','/',$c->product_full_image);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyImgDir,$c->product_full_image,
$this->options->uploadfolder.$file_name);
$max = $c->product_id;
}
}
}
}
elseif ($this->vm_version==2)
{
$this->db->setQuery('SELECT vmp.virtuemart_product_id,
vmm.file_title '.
'FROM `#__virtuemart_products` vmp '.
"INNER JOIN `#__virtuemart_product_medias` vmpm ON
vmp.virtuemart_product_id = vmpm.virtuemart_product_id ".
"INNER JOIN `#__virtuemart_medias` vmm ON
vmpm.virtuemart_media_id = vmm.virtuemart_media_id ".
'LEFT JOIN `#__hikashop_vm_prod` hkprod ON
vmp.virtuemart_product_id = hkprod.vm_id '.
"WHERE vmp.virtuemart_product_id > ".$offset." AND
hkprod.hk_id IS NULL AND (vmm.file_title IS NOT NULL) AND vmm.file_title
<> '' ".
'ORDER BY vmp.virtuemart_product_id ASC LIMIT
'.$count.';'
);
$data = $this->db->loadObjectList();
if (!empty($data))
{
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Copying products images... </p>';
foreach($data as $c) {
if( !empty($c->file_title) ) {
$file_name =
str_replace('\\','/',$c->file_title);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$this->copyFile($this->copyImgDir,$c->file_title,
$this->options->uploadfolder.$file_name); //???
$max = $c->virtuemart_product_id;
}
}
}
}
else
{
return false;
}
if( $max > 0 ) {
echo '<p>Copying files...(last proccessed product id: '
. $max . ')</p>';
$this->options->current = $max;
$this->refreshPage = true;
return $ret;
}
if ($this->vm_version==1)
{
$this->db->setQuery('SELECT weight_symbols FROM
`#__hikashop_config`');
$data = $this->db->loadObjectList();
$wghtunit = explode(',',$data);
$this->db->setQuery('SELECT volume_symbols FROM
`#__hikashop_config`');
$data = $this->db->loadObjectList();
$dimunit = explode(',',$data);
$data = array(
'product_name' => 'vmp.product_name',
'product_description' =>
"CONCAT(vmp.product_s_desc,'<hr
id=\"system-readmore\"/>',vmp.product_desc)",
'product_quantity' => 'case when vmp.product_in_stock
IS NULL or vmp.product_in_stock < 0 then 0 else vmp.product_in_stock
end',
'product_code' => 'vmp.product_sku',
'product_published' => "case when vmp.product_publish
= 'Y' then 1 else 0 end",
'product_hit' => '0',
'product_created' => 'vmp.cdate',
'product_modified' => 'vmp.mdate',
'product_sale_start' =>
'vmp.product_available_date',
'product_tax_id' => 'hkc.category_id',
'product_type' => "'main'",
'product_url' => 'vmp.product_url',
'product_weight' => 'vmp.product_weight',
'product_weight_unit' => "case when
LOWER(vmp.product_weight_uom) = 'pounds' then 'lb' else
".$wghtunit[0]." end",
'product_dimension_unit' => "case when
LOWER(vmp.product_lwh_uom) = 'inches' then 'in' else
".$dimunit[0]." end",
'product_sales' => 'vmp.product_sales',
'product_width' => 'vmp.product_width',
'product_length' => 'vmp.product_length',
'product_height' => 'vmp.product_height',
);
$sql1 = 'INSERT IGNORE INTO `#__hikashop_product`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__vm_product` AS vmp '.
'LEFT JOIN `#__hikashop_taxation` hkt ON hkt.tax_vm_id =
product_tax_id '.
'LEFT JOIN `#__hikashop_category` hkc ON hkc.category_namekey =
hkt.category_namekey '.
'LEFT JOIN `#__hikashop_vm_prod` AS hkp ON vmp.product_id =
hkp.vm_id '.
'WHERE hkp.hk_id IS NULL ORDER BY vmp.product_id ASC;';
$data = array(
'vm_id' => 'vmp.product_id',
'hk_id' => 'hkp.product_id'
);
$sql2 = 'INSERT IGNORE INTO `#__hikashop_vm_prod`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__vm_product` AS vmp INNER JOIN `#__hikashop_product` AS hkp ON
CONVERT(vmp.product_sku USING utf8) = CONVERT(hkp.product_code USING utf8)
'.
'LEFT JOIN `#__hikashop_vm_prod` hkvm ON hkvm.vm_id =
vmp.product_id '.
'WHERE hkvm.hk_id IS NULL;';
$sql3 = 'UPDATE `#__hikashop_product` AS hkp '.
'INNER JOIN `#__vm_product` AS vmp ON CONVERT(vmp.product_sku USING
utf8) = CONVERT(hkp.product_code USING utf8) '.
'INNER JOIN `#__hikashop_vm_prod` AS hkvm ON vmp.product_parent_id
= hkvm.vm_id '.
'SET hkp.product_parent_id = hkvm.hk_id;';
$data = array(
'file_name' => "''",
'file_description' => "''",
'file_path' =>
"SUBSTRING_INDEX(vmp.product_full_image,'/',-1)",
'file_type' => "'product'",
'file_ref_id' => 'hkvm.hk_id'
);
$sql4 = 'INSERT IGNORE INTO `#__hikashop_file`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__vm_product` AS vmp '.
'INNER JOIN `#__hikashop_vm_prod` AS hkvm ON vmp.product_id =
hkvm.vm_id '.
'WHERE vmp.product_id >
'.$this->options->last_vm_prod.' AND
(vmp.product_full_image IS NOT NULL) AND (vmp.product_full_image
<>'." '');";
$sql5 = 'UPDATE `#__hikashop_product` AS hkp '.
'INNER JOIN `#__hikashop_vm_prod` AS hkvm ON hkp.product_id =
hkvm.hk_id '.
'INNER JOIN `#__vm_product_mf_xref` AS vmm ON vmm.product_id =
hkvm.vm_id '.
"INNER JOIN `#__hikashop_category` AS hkc ON hkc.category_type =
'manufacturer' AND vmm.manufacturer_id = hkc.category_menu
".
'SET hkp.product_manufacturer_id = hkc.category_id '.
'WHERE vmm.manufacturer_id >
'.$this->options->last_vm_manufacturer.' OR vmm.product_id
> '.$this->options->last_vm_prod.';';
}
elseif ($this->vm_version==2) //OK
{
$buffTable="#__virtuemart_products_".$this->vm_current_lng;
if (!mysql_query('select 1 from `'.$buffTable.'`'))
$buffTable="#__virtuemart_products_en_gb";
$data = array(
'product_name' => 'vmpeg.product_name',
'product_description' =>
"CONCAT(vmpeg.product_s_desc,'<hr
id=\"system-readmore\"/>',vmpeg.product_desc)",
'product_quantity' => 'case when vmp.product_in_stock
IS NULL or vmp.product_in_stock < 0 then 0 else vmp.product_in_stock
end',
'product_code' => 'vmp.product_sku',
'product_published' => "vmp.published",
'product_hit' => '0',
'product_created' => "case when
vmp.created_on='0000-00-00 00:00:00' then 0 else 1 end",
'product_modified' => 'vmp.modified_on',
'product_sale_start' =>
'vmp.product_available_date',
'product_tax_id' => 'hkc.category_id',
'product_type' => "'main'",
'product_url' => 'vmp.product_url',
'product_weight' => 'vmp.product_weight',
'product_weight_unit' =>
"LOWER(vmp.product_weight_uom)",
'product_dimension_unit' =>
"LOWER(vmp.product_lwh_uom)",
'product_sales' => 'vmp.product_sales',
'product_width' => 'vmp.product_width',
'product_length' => 'vmp.product_length',
'product_height' => 'vmp.product_height',
);
$sql1 = 'INSERT IGNORE INTO `#__hikashop_product`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__virtuemart_products` AS vmp '.
"INNER JOIN `".$buffTable."` vmpeg ON
vmp.virtuemart_product_id = vmpeg.virtuemart_product_id ".
"INNER JOIN `#__virtuemart_product_prices` vmpp ON
vmpeg.virtuemart_product_id = vmpp.virtuemart_product_id ".
'LEFT JOIN `#__hikashop_taxation` hkt ON hkt.tax_vm_id =
vmpp.product_tax_id '.
'LEFT JOIN `#__hikashop_category` hkc ON hkc.category_namekey =
hkt.category_namekey '.
'LEFT JOIN `#__hikashop_vm_prod` AS hkp ON
vmp.virtuemart_product_id = hkp.vm_id '.
'WHERE hkp.hk_id IS NULL ORDER BY vmp.virtuemart_product_id
ASC;';
$data = array(
'vm_id' => 'vmp.virtuemart_product_id',
'hk_id' => 'hkp.product_id'
);
$sql2 = 'INSERT IGNORE INTO `#__hikashop_vm_prod`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__virtuemart_products` AS vmp '.
'INNER JOIN `#__hikashop_product` AS hkp ON CONVERT(vmp.product_sku
USING utf8) = CONVERT(hkp.product_code USING utf8) '.
'LEFT JOIN `#__hikashop_vm_prod` hkvm ON vmp.virtuemart_product_id
= hkvm.vm_id '.
'WHERE hkvm.hk_id IS NULL;';
$sql3 = 'UPDATE `#__hikashop_product` AS hkp '.
'INNER JOIN `#__virtuemart_products` AS vmp ON
CONVERT(vmp.product_sku USING utf8) = CONVERT(hkp.product_code USING utf8)
'.
'INNER JOIN `#__hikashop_vm_prod` AS hkvm ON vmp.product_parent_id
= hkvm.vm_id '.
'SET hkp.product_parent_id = hkvm.hk_id;';
$data = array(
'file_name' => "''",
'file_description' => "''",
'file_path' =>
"SUBSTRING_INDEX(vmm.file_title,'/',-1)",
'file_type' => "'product'",
'file_ref_id' => 'hkvm.hk_id'
);
$sql4 = 'INSERT IGNORE INTO `#__hikashop_file`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__virtuemart_products` AS vmp '.
"INNER JOIN `#__hikashop_vm_prod` AS hkvm ON
vmp.virtuemart_product_id = hkvm.vm_id ".
"INNER JOIN `#__virtuemart_product_medias` vmpm ON hkvm.vm_id =
vmpm.virtuemart_product_id ".
"INNER JOIN `#__virtuemart_medias` vmm ON vmpm.virtuemart_media_id
= vmm.virtuemart_media_id ".
'WHERE vmp.virtuemart_product_id >
'.$this->options->last_vm_prod.' AND (vmm.file_title
<>'." '');";
$sql5 = 'UPDATE `#__hikashop_product` AS hkp '.
'INNER JOIN `#__hikashop_vm_prod` AS hkvm ON hkp.product_id =
hkvm.hk_id '.
'INNER JOIN `#__virtuemart_product_manufacturers` AS vmpm ON
vmpm.virtuemart_product_id = hkvm.vm_id '.
"INNER JOIN `#__hikashop_category` AS hkc ON hkc.category_type =
'manufacturer' AND vmpm.virtuemart_manufacturer_id =
hkc.category_menu ".
'SET hkp.product_manufacturer_id = hkc.category_id '.
'WHERE vmpm.virtuemart_manufacturer_id >
'.$this->options->last_vm_manufacturer.' OR
vmpm.virtuemart_product_id >
'.$this->options->last_vm_prod.';';
}
else
{
return false;
}
$this->db->setQuery($sql1);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products: ' . $total . '</p>';
$this->db->setQuery($sql2);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Fallback links: ' . $total . '</p>';
$this->db->setQuery($sql3);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating products for parent links: ' . $total .
'</p>';
$this->db->setQuery($sql4);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products files: ' . $total . '</p>';
$this->db->setQuery($sql5);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating products manufacturers: ' . $total . '</p>';
$ret = true;
return $ret;
}
function importProductPrices() {
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
6 :</span>Â Import Product Prices</p>';
$ret = false;
$cpt = 0;
if ($this->vm_version==1)
{
$this->db->setQuery('INSERT IGNORE INTO #__hikashop_price
(`price_product_id`,`price_value`,`price_currency_id`,`price_min_quantity`,`price_access`)
'
.'SELECT hkprod.hk_Id, product_price, hkcur.currency_id,
price_quantity_start, \'all\' '
.'FROM #__vm_product_price vm INNER JOIN #__hikashop_vm_prod
hkprod ON vm.product_id = hkprod.vm_id '
.'INNER JOIN #__hikashop_currency hkcur ON
CONVERT(vm.product_currency USING utf8) = CONVERT( hkcur.currency_code
USING utf8) '
.'WHERE product_price_vdate < NOW() AND (product_price_edate =
0 OR product_price_edate > NOW() ) '
.'AND vm.product_id > ' .
(int)$this->options->last_vm_prod
);
}
else if ($this->vm_version==2)
{
$this->db->setQuery('INSERT IGNORE INTO #__hikashop_price
(`price_product_id`,`price_value`,`price_currency_id`,`price_min_quantity`,`price_access`)
'
.'SELECT hkprod.hk_Id, product_price, hkcur.currency_id,
price_quantity_start, \'all\' '
.'FROM #__virtuemart_product_prices vmpp '
.'INNER JOIN #__hikashop_vm_prod hkprod ON
vmpp.virtuemart_product_id = hkprod.vm_id '
.'INNER JOIN #__virtuemart_currencies vmc ON
vmpp.product_currency = vmc.virtuemart_currency_id '
.'INNER JOIN #__hikashop_currency hkcur ON
CONVERT(vmc.currency_code_3 USING utf8) = CONVERT( hkcur.currency_code
USING utf8) '
.'WHERE vmpp.virtuemart_product_id > ' .
(int)$this->options->last_vm_prod
);
}
else
{
return false;
}
$ret = $this->db->query();
$cpt = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Prices imported : ' . $cpt .'</p>';
return $ret;
}
function importProductCategory() {
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
7 :</span>Â Import Product Category</p>';
$data = array(
'category_id' => 'vmc.hk_id',
'product_id' => 'vmp.hk_id',
'ordering' => '`product_list`',
);
if ($this->vm_version==1)
{
$sql = 'INSERT IGNORE INTO `#__hikashop_product_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__vm_product_category_xref` vm '.
'INNER JOIN `#__hikashop_vm_cat` vmc ON vm.category_id = vmc.vm_id
'.
'INNER JOIN `#__hikashop_vm_prod` vmp ON vm.product_id = vmp.vm_id
'.
'WHERE vmp.vm_id > ' .
(int)$this->options->last_vm_prod . ' OR vmc.vm_id > ' .
(int)$this->options->last_vm_cat;
}
else if ($this->vm_version==2)
{
$data['ordering'] = '`ordering`';
$sql = 'INSERT IGNORE INTO `#__hikashop_product_category`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT ' . implode(',',$data).' FROM
`#__virtuemart_product_categories` vmpc '.
'INNER JOIN #__hikashop_vm_cat vmc ON vmpc.virtuemart_category_id =
vmc.vm_id '.
'INNER JOIN #__hikashop_vm_prod vmp ON vmpc.virtuemart_product_id =
vmp.vm_id '.
'WHERE vmp.vm_id > ' .
(int)$this->options->last_vm_prod . ' OR vmc.vm_id > ' .
(int)$this->options->last_vm_cat;
}
else
{
return false;
}
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Inserted products categories: ' . $total . '</p>';
return true;
}
function importUsers() {
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
8 :</span>Â Import Users</p>';
$ret = false;
if ($this->vm_version==1)
{
$sql0 = 'INSERT IGNORE INTO `#__hikashop_user`
(`user_cms_id`,`user_email`) '.
'SELECT vmui.user_id, vmui.user_email FROM `#__vm_user_info` AS
vmui '.
'LEFT JOIN `#__hikashop_user` AS hkusr ON vmui.user_id =
hkusr.user_cms_id '.
'WHERE hkusr.user_cms_id IS NULL;';
}
else if ($this->vm_version==2)
{
$sql0 = 'INSERT IGNORE INTO `#__hikashop_user`
(`user_cms_id`,`user_email`) '.
'SELECT u.id, u.email FROM `#__virtuemart_userinfos` vmui INNER
JOIN `#__users` u ON vmui.virtuemart_user_id = u.id '.
'LEFT JOIN `#__hikashop_user` AS hkusr ON vmui.virtuemart_user_id
= hkusr.user_cms_id '.
'WHERE hkusr.user_cms_id IS NULL;';
}
else
{
return false;
}
$data = array(
'address_user_id' => 'hku.user_id',
'address_firstname' => 'vmui.first_name',
'address_middle_name' => 'vmui.middle_name',
'address_lastname' => 'vmui.last_name',
'address_company' => 'vmui.company',
'address_street' => 'CONCAT(vmui.address_1,\'
\',vmui.address_2)',
'address_post_code' => 'vmui.zip',
'address_city' => 'vmui.city',
'address_telephone' => 'vmui.phone_1',
'address_telephone2' => 'vmui.phone_2',
'address_fax' => 'vmui.fax',
'address_state' => 'vmui.state',
'address_country' => 'vmui.country',
'address_published' => 4
);
if ($this->vm_version==1)
{
$sql1 = 'INSERT IGNORE INTO `#__hikashop_address`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__vm_user_info` AS vmui INNER JOIN `#__hikashop_user` AS hku ON
vmui.user_id = hku.user_cms_id WHERE vmui.user_id >
'.$this->options->last_vm_user.' ORDER BY vmui.user_id
ASC';
}
elseif ($this->vm_version==2)
{
$data['address_state'] = 'vms.state_3_code';
$data['address_country'] = 'vmc.country_3_code';
$sql1 = 'INSERT IGNORE INTO `#__hikashop_address`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__virtuemart_userinfos` AS vmui '.
"INNER JOIN `#__virtuemart_states` vms ON
vmui.virtuemart_state_id = vms.virtuemart_state_id ".
"INNER JOIN `#__virtuemart_countries` vmc ON
vmui.virtuemart_country_id = vmc.virtuemart_country_id ".
'INNER JOIN `#__hikashop_user` AS hku ON vmui.virtuemart_user_id
= hku.user_cms_id '.
'WHERE vmui.virtuemart_user_id >
'.$this->options->last_vm_user.' ORDER BY
vmui.virtuemart_user_id ASC;';
}
$sql2 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone` AS hkz ON (a.address_country =
hkz.zone_code_3 AND hkz.zone_type = "country") '.
'SET address_country = hkz.zone_namekey, address_published = 3
WHERE address_published = 4;';
$sql3 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone_link` AS zl ON (a.address_country =
zl.zone_parent_namekey) '.
'JOIN `#__hikashop_zone` AS hks ON (hks.zone_namekey =
zl.zone_child_namekey AND hks.zone_type = "state" AND
hks.zone_code_3 = a.address_state) '.
'SET address_state = hks.zone_namekey, address_published = 2 WHERE
address_published = 3;';
$sql4 = "UPDATE `#__hikashop_address` AS a SET a.address_country =
'' WHERE address_published > 3;";
$sql5 = "UPDATE `#__hikashop_address` AS a SET a.address_state =
'' WHERE address_published > 2;";
$sql6 = 'UPDATE `#__hikashop_address` AS a SET a.address_published =
1 WHERE address_published > 1;';
$this->db->setQuery($sql0);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported Users: ' . $total . '</p>';
$this->db->setQuery($sql1);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses: ' . $total . '</p>';
$this->db->setQuery($sql2);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses countries: ' . $total . '</p>';
$this->db->setQuery($sql3);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported addresses states: ' . $total . '</p>';
$this->db->setQuery($sql4);
$this->db->query();
$this->db->setQuery($sql5);
$this->db->query();
$this->db->setQuery($sql6);
$this->db->query();
$ret = true;
echo "\n<br/>\n";
return $ret;
}
function importOrders() {
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
10 :</span>Â Import Orders</p>';
$ret = false;
$offset = $this->options->current;
$count = 100;
$total = 0;
if ($this->vm_version==1)
$this->db->setQuery("SELECT name FROM `#__vm_userfield` WHERE
type = 'euvatid' AND published = 1");
elseif ($this->vm_version==2)
$this->db->setQuery("SELECT name FROM
`#__virtuemart_userfields` WHERE name = 'tax_exemption_number'
AND published = 1");
else
return false;
$vat_cols = $this->db->loadObjectList();
if( isset($vat_cols) && $vat_cols !== null &&
is_array($vat_cols) && count($vat_cols)>0)
$vat_cols = 'vmui.' . $vat_cols[0]->name;
else
$vat_cols = "''";
if ($this->vm_version==1)
{
$data = array(
'order_number' => 'vmo.order_number',
'order_vm_id' => 'vmo.order_id',
'order_user_id' => 'hkusr.user_id',
'order_status' => 'hkc.category_name',
'order_discount_code' => 'vmo.coupon_code',
'order_discount_price' =>
'vmo.coupon_discount',
'order_created' => 'vmo.cdate',
'order_ip' => 'vmo.ip_address',
'order_currency_id' => 'hkcur.currency_id',
'order_shipping_price' => 'vmo.order_shipping',
'order_shipping_method' => "'vm
import'",
'order_shipping_id' => '1',
'order_payment_id' => 0,
'order_payment_method' => '\'vm
import\'',
'order_full_price' => 'vmo.order_total',
'order_modified' => 'vmo.mdate',
'order_partner_id' => 0,
'order_partner_price' => 0,
'order_partner_paid' => 0,
'order_type' => "'sale'",
'order_partner_currency_id' => 0,
'order_shipping_tax' =>
'vmo.order_shipping_tax',
'order_discount_tax' => 0
);
$sql1 = 'INSERT IGNORE INTO `#__hikashop_order`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__vm_orders` AS vmo '.
'JOIN `#__vm_order_status` AS vmos ON vmo.order_status =
vmos.order_status_code '.
'JOIN `#__hikashop_category` AS hkc ON vmos.order_status_name =
hkc.category_name AND hkc.category_type = \'status\' '.
'JOIN `#__hikashop_currency` AS hkcur ON
CONVERT(vmo.order_currency USING utf8) = CONVERT(hkcur.currency_code USING
utf8) '.
'JOIN `#__hikashop_user` AS hkusr ON vmo.user_id =
hkusr.user_cms_id '.
'WHERE vmo.order_id > ' .
(int)$this->options->last_vm_order . ' '.
'GROUP BY vmo.order_id '.
'ORDER BY vmo.order_id ASC;';
$data = array(
'address_user_id' => 'vmui.user_id',
'address_firstname' => 'vmui.first_name',
'address_middle_name' => 'vmui.middle_name',
'address_lastname' => 'vmui.last_name',
'address_company' => 'vmui.company',
'address_street' => "CONCAT(vmui.address_1,'
',vmui.address_2)",
'address_post_code' => 'vmui.zip',
'address_city' => 'vmui.city',
'address_telephone' => 'vmui.phone_1',
'address_telephone2' => 'vmui.phone_2',
'address_fax' => 'vmui.fax',
'address_state' => 'vmui.state',
'address_country' => 'vmui.country',
'address_published' => "case when vmui.address_type =
'BT' then 7 else 8 end",
'address_vat' => $vat_cols,
'address_vm_order_info_id' => 'vmui.order_id'
);
$sql2_1 = 'INSERT IGNORE INTO `#__hikashop_address`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__vm_order_user_info` AS vmui WHERE vmui.order_id >
'.$this->options->last_vm_order.' ORDER BY
vmui.order_info_id ASC';
}
elseif ($this->vm_version==2)
{
$data = array(
'order_number' => 'vmo.order_number',
'order_vm_id' => 'vmo.virtuemart_order_id',
'order_user_id' => 'hkusr.user_id',
'order_status' => 'hkc.category_name',
'order_discount_code' => 'vmo.coupon_code',
'order_discount_price' =>
'vmo.coupon_discount',
'order_created' => 'vmo.created_on',
'order_ip' => 'vmo.ip_address',
'order_currency_id' => 'hkcur.currency_id',
'order_shipping_price' => 'vmo.order_shipment',
'order_shipping_method' => "'vm
import'",
'order_shipping_id' => '1',
'order_payment_id' => 0,
'order_payment_method' => "'vm
import'",
'order_full_price' => 'vmo.order_total',
'order_modified' => 'vmo.modified_on',
'order_partner_id' => 0,
'order_partner_price' => 0,
'order_partner_paid' => 0,
'order_type' => "'sale'",
'order_partner_currency_id' => 0,
'order_shipping_tax' =>
'vmo.order_shipment_tax',
'order_discount_tax' => 0
);
$sql1 = 'INSERT IGNORE INTO `#__hikashop_order`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__virtuemart_orders` AS vmo '.
'INNER JOIN `#__virtuemart_currencies` vmc ON vmo.order_currency =
vmc.virtuemart_currency_id '.
'INNER JOIN `#__hikashop_currency` hkcur ON
CONVERT(vmc.currency_code_3 USING utf8) = CONVERT( hkcur.currency_code
USING utf8) '. //needed ?
'JOIN `#__virtuemart_orderstates` AS vmos ON vmo.order_status =
vmos.order_status_code '.
'JOIN `#__hikashop_category` AS hkc ON vmos.order_status_name =
hkc.category_name AND hkc.category_type = \'status\' '. //No
U founded
'INNER JOIN `#__hikashop_user` AS hkusr ON vmo.virtuemart_user_id
= hkusr.user_cms_id '.
'WHERE vmo.virtuemart_order_id > ' .
(int)$this->options->last_vm_order . ' '.
'GROUP BY vmo.virtuemart_order_id '.
'ORDER BY vmo.virtuemart_order_id ASC;';
$data = array(
'address_user_id' => 'vmui.virtuemart_user_id',
'address_firstname' => 'vmui.first_name',
'address_middle_name' => 'vmui.middle_name',
'address_lastname' => 'vmui.last_name',
'address_company' => 'vmui.company',
'address_street' => "CONCAT(vmui.address_1,'
',vmui.address_2)",
'address_post_code' => 'vmui.zip',
'address_city' => 'vmui.city',
'address_telephone' => 'vmui.phone_1',
'address_telephone2' => 'vmui.phone_2',
'address_fax' => 'vmui.fax',
'address_state' => 'vms.state_3_code',
'address_country' => 'vmc.country_3_code',
'address_published' => "case when vmui.address_type =
'BT' then 7 else 8 end",
'address_vat' => $vat_cols,
'address_vm_order_info_id' =>
'vmui.virtuemart_order_id'
);
$sql2_1 = 'INSERT IGNORE INTO `#__hikashop_address`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__virtuemart_order_userinfos` AS vmui '.
"INNER JOIN `#__virtuemart_states` vms ON vmui.virtuemart_state_id
= vms.virtuemart_state_id ".
"INNER JOIN `#__virtuemart_countries` vmc ON
vmui.virtuemart_country_id = vmc.virtuemart_country_id ".
'WHERE vmui.virtuemart_order_id >
'.$this->options->last_vm_order.' ORDER BY
vmui.virtuemart_order_userinfo_id ASC';
}
else
{
return false;
}
$sql2_2 = 'UPDATE `#__hikashop_address` AS a '.
'JOIN `#__hikashop_zone` AS hkz ON (a.address_country =
hkz.zone_code_3 AND hkz.zone_type = "country") '.
'SET address_country = hkz.zone_namekey, address_published = 6
WHERE address_published >= 7;';
$sql2_3 = 'UPDATE `#__hikashop_address` AS a '. // todo
'JOIN `#__hikashop_zone_link` AS zl ON (a.address_country =
zl.zone_parent_namekey) '.
'JOIN `#__hikashop_zone` AS hks ON (hks.zone_namekey =
zl.zone_child_namekey AND hks.zone_type = "state" AND
hks.zone_code_3 = a.address_state) '.
'SET address_state = hks.zone_namekey, address_published = 5 WHERE
address_published = 6;';
$sql2_4 = 'UPDATE `#__hikashop_address` AS a '.
'SET address_published = 0 WHERE address_published > 4;';
$sql3 = 'UPDATE `#__hikashop_order` AS o '.
'INNER JOIN `#__hikashop_address` AS a ON
a.address_vm_order_info_id = o.order_vm_id '.
'SET o.order_billing_address_id = a.address_id,
o.order_shipping_address_id = a.address_id '.
"WHERE o.order_billing_address_id = 0 AND address_published >= 7
;";
$sql4 = 'UPDATE `#__hikashop_order` AS o '.
'INNER JOIN `#__hikashop_address` AS a ON
a.address_vm_order_info_id = o.order_vm_id '.
'SET o.order_shipping_address_id = a.address_id '.
"WHERE o.order_shipping_address_id = 0 AND address_published >=
8 ;";
if ($this->vm_version==1)
{
$sql5 = 'UPDATE `#__hikashop_order` AS a '.
'JOIN `#__vm_order_payment` AS o ON a.order_vm_id = o.order_id
'.
'JOIN `#__vm_payment_method` AS p ON o.payment_method_id =
p.payment_method_id '.
"SET a.order_payment_method = CONCAT('vm import: ',
p.payment_method_name) ".
'WHERE a.order_vm_id > ' .
(int)$this->options->last_vm_order;
}
elseif ($this->vm_version==2)
{
$buffTable="#__virtuemart_paymentmethods_".$this->vm_current_lng;
if (!mysql_query('select 1 from `'.$buffTable.'`'))
$buffTable="#__virtuemart_paymentmethods_en_gb";
$sql5 = 'UPDATE `#__hikashop_order` AS a '.
'JOIN `#__virtuemart_orders` AS vmo ON a.order_vm_id =
vmo.virtuemart_order_id '.
'JOIN `'.$buffTable.'` AS vmp ON
vmo.virtuemart_paymentmethod_id = vmp.virtuemart_paymentmethod_id '.
"SET a.order_payment_method = CONCAT('vm import: ',
vmp.payment_name) ".
'WHERE a.order_vm_id > ' .
(int)$this->options->last_vm_order;
}
$this->db->setQuery($sql1);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported orders: ' . $total . '</p>';
$this->db->setQuery($sql2_1);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Imported orders addresses: ' . $total . '</p>';
$this->db->setQuery($sql3);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating billing addresses: ' . $total . '</p>';
$this->db->setQuery($sql4);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating shipping addresses: ' . $total . '</p>';
$this->db->setQuery($sql5);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating order payments: ' . $total . '</p>';
$this->db->setQuery($sql2_2);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Updating orders: ' . $total;
$this->db->setQuery($sql2_3);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '/' . $total;
$this->db->setQuery($sql2_4);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '/' . $total . '</p>';
$ret = true;
return $ret;
}
function importOrderItems() {
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
11 :</span>Â Import Order Items</p>';
$ret = false;
$offset = $this->options->current;
$count = 100;
$data = array(
'order_id' => 'hko.order_id',
'product_id' => 'hkp.hk_id',
'order_product_quantity' =>
'vmoi.product_quantity',
'order_product_name' => 'vmoi.order_item_name',
'order_product_code' => 'vmoi.order_item_sku',
'order_product_price' =>
'vmoi.product_item_price',
'order_product_tax' => '(vmoi.product_final_price -
vmoi.product_item_price)',
'order_product_options' => "''"
);
if ($this->vm_version==1)
{
$sql = 'INSERT IGNORE INTO `#__hikashop_order_product`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__vm_order_item` AS vmoi '.
'INNER JOIN `#__hikashop_order` AS hko ON vmoi.order_id =
hko.order_vm_id '.
'INNER JOIN `#__hikashop_vm_prod` AS hkp ON hkp.vm_id =
vmoi.product_id '.
'WHERE vmoi.order_id > ' .
(int)$this->options->last_vm_order . ';';
}
elseif ($this->vm_version==2)
{
$sql = 'INSERT IGNORE INTO `#__hikashop_order_product`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__virtuemart_order_items` AS vmoi '.
'INNER JOIN `#__hikashop_order` AS hko ON vmoi.virtuemart_order_id
= hko.order_vm_id '.
'INNER JOIN `#__hikashop_vm_prod` AS hkp ON
vmoi.virtuemart_product_id = hkp.vm_id '.
'WHERE vmoi.virtuemart_order_id > ' .
(int)$this->options->last_vm_order . ';';
}
else
{
return false;
}
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Orders Items : '. $total .'</p>';
$ret = true;
return $ret;
}
function importDownloads() {
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
12 :</span>Â Import Downloads</p>';
jimport('joomla.filesystem.file');
$categoryClass = hikashop_get('class.category');
$ret = false;
$count = 100;
$offset = $this->options->current;
if( $offset == 0 ) {
$offset = $this->options->last_vm_pfile;
}
$sql = "SELECT `config_value` FROM `#__hikashop_config` WHERE
config_namekey = 'download_number_limit';";
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$dl_limit = $data[0]->config_value;
if ($this->vm_version==1)
{
$sql = 'SELECT vmf.file_id,vmf.file_name,vmf.file_is_image FROM
`#__vm_product_files` AS vmf WHERE vmf.file_id >
'.$offset.';';
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$max = 0;
foreach($data as $c) {
$file_name =
str_replace('\\','/',$c->file_name);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$dstFolder = $this->options->uploadsecurefolder;
if($c->file_is_image){
$dstFolder = $this->options->uploadfolder;
}
$this->copyFile($this->copyImgDir,$c->file_name,
$dstFolder.$file_name);
$max = $c->file_id;
}
}
elseif ($this->vm_version==2)
{
$sql = 'SELECT
vmm.virtuemart_media_id,vmm.file_title,vmm.file_is_product_image '.
'FROM `#__virtuemart_products` vmp ' .
"INNER JOIN `#__virtuemart_product_medias` AS vmpm ON
vmp.virtuemart_product_id = vmpm.virtuemart_product_id " .
"INNER JOIN `#__virtuemart_medias` vmm ON vmpm.virtuemart_media_id
= vmm.virtuemart_media_id " .
'WHERE vmm.virtuemart_media_id > '.$offset.';';
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$max = 0;
foreach($data as $c) {
$file_name =
str_replace('\\','/',$c->file_title);
if( strpos($file_name,'/') !== false ) {
$file_name = substr($file_name, strrpos($file_name,'/'));
}
$dstFolder = $this->options->uploadsecurefolder;
if($c->file_is_product_image){
$dstFolder = $this->options->uploadfolder;
}
$this->copyFile($this->copyImgDir,$c->file_title,
$dstFolder.$file_name);
$max = $c->virtuemart_media_id;
}
}
else
{
return false;
}
if( $max > 0 ) {
echo '<p>Copying files...<br/>(Last processed file id:
' . $max . '</p>';
$this->options->current = $max;
$this->refreshPage = true;
return $ret;
}
if ($this->vm_version==1)
{
$data = array(
'file_name' => 'vmf.file_title',
'file_description' => 'vmf.file_description',
'file_path' =>
"SUBSTRING_INDEX(SUBSTRING_INDEX(vmf.file_name, '/', -1),
'\\\\', -1)",
'file_type' => "case when vmf.file_is_image = 1 then
'product' else 'file' end",
'file_ref_id' => 'hkp.hk_id'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_file`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__vm_product_files` AS vmf '.
'INNER JOIN `#__hikashop_vm_prod` AS hkp ON hkp.vm_id =
vmf.file_product_id '.
'WHERE vmf.file_id >
'.$this->options->last_vm_pfile.';';
}
elseif ($this->vm_version==2)
{
$data = array(
'file_name' => 'vmm.file_title',
'file_description' => 'vmm.file_description',
'file_path' =>
"SUBSTRING_INDEX(SUBSTRING_INDEX(vmm.file_title, '/', -1),
'\\\\', -1)",
'file_type' => "case when vmm.file_is_product_image =
1 then 'product' else 'file' end",
'file_ref_id' => 'hkp.hk_id'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_file`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__virtuemart_products` vmp '.
"INNER JOIN `#__virtuemart_product_medias` AS vmpm ON
vmp.virtuemart_product_id = vmpm.virtuemart_product_id ".
"INNER JOIN `#__virtuemart_medias` vmm ON vmpm.virtuemart_media_id
= vmm.virtuemart_media_id " .
'INNER JOIN `#__hikashop_vm_prod` AS hkp ON
vmm.virtuemart_media_id = hkp.vm_id '.
'WHERE vmm.virtuemart_media_id >
'.$this->options->last_vm_pfile.';';
}
else
{
return false;
}
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Downloable files imported : ' . $total . '</p>';
if ($this->vm_version==1)
{
$data = array(
'file_id' => 'hkf.file_id',
'order_id' => 'hko.order_id',
'download_number' => '(' . $dl_limit . '-
vmd.download_max)'
);
$sql = 'INSERT IGNORE INTO `#__hikashop_download`
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
`#__vm_product_download` AS vmd '.
'INNER JOIN `#__hikashop_order` AS hko ON hko.order_vm_id =
vmd.order_id '.
'INNER JOIN `#__hikashop_vm_prod` AS hkp ON hkp.vm_id =
vmd.product_id '.
'INNER JOIN `#__hikashop_file` AS hkf ON ( CONVERT(hkf.file_name
USING utf8) = CONVERT(vmd.file_name USING utf8) )'.
"WHERE hkf.file_type = 'file' AND (hkp.hk_id =
hkf.file_ref_id) AND (vmd.product_id >
".$this->options->last_vm_prod.' OR vmd.order_id >
' . (int)$this->options->last_vm_order . ');';
}
elseif ($this->vm_version==2)
{
return true;
}
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Downloable order files imported : ' . $total .
'</p>';
$ret = true;
return $ret;
}
function importDiscount() {
if( $this->db == null )
return false;
echo '<p
'.$this->titlefont.'><span'.$this->titlestyle.'>Step
9 :</span>Â Import Discount</p>';
$sql = "SELECT `config_value` FROM `#__hikashop_config` WHERE
config_namekey = 'main_currency';";
$this->db->setQuery($sql);
$data = $this->db->loadObjectList();
$main_currency = $data[0]->config_value;
$data = array(
'discount_type' => "'coupon'", //coupon
or discount
'discount_published' => '1',
'discount_code' => '`coupon_code`',
'discount_currency_id' => $main_currency,
'discount_flat_amount' => "case when percent_or_total
= 'total' then coupon_value else 0 end",
'discount_percent_amount' => "case when
percent_or_total = 'percent' then coupon_value else 0 end",
'discount_quota' => "case when coupon_type =
'gift' then 1 else 0 end"
);
if ($this->vm_version==1)
{
$sql = 'INSERT IGNORE INTO #__hikashop_discount
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
#__vm_coupons WHERE coupon_id > ' .
(int)$this->options->last_vm_coupon;
}
elseif ($this->vm_version==2) //OK
{
$sql = 'INSERT IGNORE INTO #__hikashop_discount
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
#__virtuemart_coupons WHERE virtuemart_coupon_id > ' .
(int)$this->options->last_vm_coupon;
}
else
{
return false;
}
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Discount codes / coupons imported : ' . $total .
'</p>';
if ($this->vm_version==1)
{
$data = array(
'discount_type' => "'discount'",
//coupon or discount
'discount_published' => '1',
'discount_code' => "CONCAT('discount_',
vmp.product_sku)",
'discount_currency_id' => $main_currency,
'discount_flat_amount' => "case when vmd.is_percent =
0 then vmd.amount else 0 end",
'discount_percent_amount' => "case when
vmd.is_percent = 1 then vmd.amount else 0 end",
'discount_quota' => "''",
'discount_product_id' => 'hkp.hk_id',
'discount_category_id' => '0',
'discount_start' => "vmd.start_date",
'discount_end' => "vmd.end_date"
);
$sql = 'INSERT IGNORE INTO #__hikashop_discount
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
#__vm_product vmp '.
'INNER JOIN `#__vm_product_discount` vmd ON
vmp.product_discount_id = vmd.discount_id '.
'INNER JOIN `#__hikashop_vm_prod` AS hkp ON hkp.vm_id =
vmp.product_id '.
'WHERE vmp.product_id > ' .
(int)$this->options->last_vm_prod;
}
elseif ($this->vm_version==2)
{
$data = array(
'discount_type' => "'discount'",
'discount_published' => '1',
'discount_code' => "CONCAT('discount_',
vmp.product_sku)",
'discount_currency_id' => $main_currency,
'discount_flat_amount' => "case when
vmc.percent_or_total = 'total' then vmc.coupon_value else 0
end",
'discount_percent_amount' => "case when
vmc.percent_or_total = 'percent' then vmc.coupon_value else 0
end",
'discount_quota' => "''",
'discount_product_id' => 'hkp.hk_id',
'discount_category_id' => '0',
'discount_start' => "vmc.coupon_start_date",
'discount_end' => "vmc.coupon_expiry_date"
);
$sql = 'INSERT IGNORE INTO #__hikashop_discount
(`'.implode('`,`',array_keys($data)).'`) '.
'SELECT '.implode(',',$data).' FROM
#__virtuemart_products vmp '.
'INNER JOIN `#__virtuemart_product_prices` vmpp ON
vmp.virtuemart_product_id = vmpp.virtuemart_product_id '.
'INNER JOIN `#__virtuemart_coupons` vmc ON
vmpp.product_discount_id = vmc.virtuemart_coupon_id '.
'INNER JOIN `#__hikashop_vm_prod` AS hkp ON hkp.vm_id =
vmp.virtuemart_product_id '.
'WHERE vmp.virtuemart_product_id > ' .
(int)$this->options->last_vm_prod;
}
$this->db->setQuery($sql);
$this->db->query();
$total = $this->db->getAffectedRows();
echo '<p
'.$this->pmarginstyle.'><span'.$this->bullstyle.'>•</span>
Discount product imported : ' . $total . '</p>';
$ret = true;
return $ret;
}
}
?>
html/menus.php000064400000012713151164044020007351 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_menus
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
JLoader::register('MenusHelper', JPATH_ADMINISTRATOR .
'/components/com_menus/helpers/menus.php');
/**
* Menus HTML helper class.
*
* @package Joomla.Administrator
* @subpackage com_menus
* @since 1.7
*/
abstract class MenusHtmlMenus
{
/**
* Generate the markup to display the item associations
*
* @param int $itemid The menu item id
*
* @return string
*
* @since 3.0
*
* @throws Exception If there is an error on the query
*/
public static function association($itemid)
{
// Defaults
$html = '';
// Get the associations
if ($associations = MenusHelper::getAssociations($itemid))
{
// Get the associated menu items
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('m.id, m.title')
->select('l.sef as lang_sef, l.lang_code')
->select('mt.title as menu_title')
->from('#__menu as m')
->join('LEFT', '#__menu_types as mt ON
mt.menutype=m.menutype')
->where('m.id IN (' . implode(',',
array_values($associations)) . ')')
->where('m.id != ' . $itemid)
->join('LEFT', '#__languages as l ON
m.language=l.lang_code')
->select('l.image')
->select('l.title as language_title');
$db->setQuery($query);
try
{
$items = $db->loadObjectList('id');
}
catch (runtimeException $e)
{
throw new Exception($e->getMessage(), 500);
}
// Construct html
if ($items)
{
foreach ($items as &$item)
{
$text = strtoupper($item->lang_sef);
$url =
JRoute::_('index.php?option=com_menus&task=item.edit&id='
. (int) $item->id);
$tooltip = htmlspecialchars($item->title, ENT_QUOTES,
'UTF-8') . '<br />' .
JText::sprintf('COM_MENUS_MENU_SPRINTF', $item->menu_title);
$classes = 'hasPopover label label-association label-' .
$item->lang_sef;
$item->link = '<a href="' . $url . '"
title="' . $item->language_title . '"
class="' . $classes
. '" data-content="' . $tooltip . '"
data-placement="top">'
. $text . '</a>';
}
}
JHtml::_('bootstrap.popover');
$html = JLayoutHelper::render('joomla.content.associations',
$items);
}
return $html;
}
/**
* Returns a published state on a grid
*
* @param integer $value The state value.
* @param integer $i The row index
* @param boolean $enabled An optional setting for access control on
the action.
* @param string $checkbox An optional prefix for checkboxes.
*
* @return string The Html code
*
* @see JHtmlJGrid::state
*
* @since 1.7.1
*/
public static function state($value, $i, $enabled = true, $checkbox =
'cb')
{
$states = array(
9 => array(
'unpublish',
'',
'COM_MENUS_HTML_UNPUBLISH_HEADING',
'',
true,
'publish',
'publish',
),
8 => array(
'publish',
'',
'COM_MENUS_HTML_PUBLISH_HEADING',
'',
true,
'unpublish',
'unpublish',
),
7 => array(
'unpublish',
'',
'COM_MENUS_HTML_UNPUBLISH_SEPARATOR',
'',
true,
'publish',
'publish',
),
6 => array(
'publish',
'',
'COM_MENUS_HTML_PUBLISH_SEPARATOR',
'',
true,
'unpublish',
'unpublish',
),
5 => array(
'unpublish',
'',
'COM_MENUS_HTML_UNPUBLISH_ALIAS',
'',
true,
'publish',
'publish',
),
4 => array(
'publish',
'',
'COM_MENUS_HTML_PUBLISH_ALIAS',
'',
true,
'unpublish',
'unpublish',
),
3 => array(
'unpublish',
'',
'COM_MENUS_HTML_UNPUBLISH_URL',
'',
true,
'publish',
'publish',
),
2 => array(
'publish',
'',
'COM_MENUS_HTML_PUBLISH_URL',
'',
true,
'unpublish',
'unpublish',
),
1 => array(
'unpublish',
'COM_MENUS_EXTENSION_PUBLISHED_ENABLED',
'COM_MENUS_HTML_UNPUBLISH_ENABLED',
'COM_MENUS_EXTENSION_PUBLISHED_ENABLED',
true,
'publish',
'publish',
),
0 => array(
'publish',
'COM_MENUS_EXTENSION_UNPUBLISHED_ENABLED',
'COM_MENUS_HTML_PUBLISH_ENABLED',
'COM_MENUS_EXTENSION_UNPUBLISHED_ENABLED',
true,
'unpublish',
'unpublish',
),
-1 => array(
'unpublish',
'COM_MENUS_EXTENSION_PUBLISHED_DISABLED',
'COM_MENUS_HTML_UNPUBLISH_DISABLED',
'COM_MENUS_EXTENSION_PUBLISHED_DISABLED',
true,
'warning',
'warning',
),
-2 => array(
'publish',
'COM_MENUS_EXTENSION_UNPUBLISHED_DISABLED',
'COM_MENUS_HTML_PUBLISH_DISABLED',
'COM_MENUS_EXTENSION_UNPUBLISHED_DISABLED',
true,
'trash',
'trash',
),
-3 => array(
'publish',
'',
'COM_MENUS_HTML_PUBLISH',
'',
true,
'trash',
'trash',
),
);
return JHtml::_('jgrid.state', $states, $value, $i,
'items.', $enabled, true, $checkbox);
}
/**
* Returns a visibility state on a grid
*
* @param integer $params Params of item.
*
* @return string The Html code
*
* @since 3.7.0
*/
public static function visibility($params)
{
$registry = new Registry;
try
{
$registry->loadString($params);
}
catch (Exception $e)
{
// Invalid JSON
}
$show_menu = $registry->get('menu_show');
return ($show_menu === 0) ? '<span
class="label">' .
JText::_('COM_MENUS_LABEL_HIDDEN') . '</span>' :
'';
}
}
menus.php000064400000033167151164044020006413 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_menus
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
use Joomla\CMS\Menu\MenuHelper;
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;
defined('_JEXEC') or die;
/**
* Menus component helper.
*
* @since 1.6
*/
class MenusHelper
{
/**
* Defines the valid request variables for the reverse lookup.
*
* @since 1.6
*/
protected static $_filter = array('option', 'view',
'layout');
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since 1.6
*/
public static function addSubmenu($vName)
{
JHtmlSidebar::addEntry(
JText::_('COM_MENUS_SUBMENU_MENUS'),
'index.php?option=com_menus&view=menus',
$vName == 'menus'
);
JHtmlSidebar::addEntry(
JText::_('COM_MENUS_SUBMENU_ITEMS'),
'index.php?option=com_menus&view=items',
$vName == 'items'
);
}
/**
* Gets a list of the actions that can be performed.
*
* @param integer $parentId The menu ID.
*
* @return JObject
*
* @since 1.6
* @deprecated 3.2 Use JHelperContent::getActions() instead
*/
public static function getActions($parentId = 0)
{
// Log usage of deprecated function
try
{
JLog::add(
sprintf('%s() is deprecated. Use JHelperContent::getActions() with
new arguments order instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
// Get list of actions
return JHelperContent::getActions('com_menus');
}
/**
* Gets a standard form of a link for lookups.
*
* @param mixed $request A link string or array of request variables.
*
* @return mixed A link in standard option-view-layout form, or false if
the supplied response is invalid.
*
* @since 1.6
*/
public static function getLinkKey($request)
{
if (empty($request))
{
return false;
}
// Check if the link is in the form of index.php?...
if (is_string($request))
{
$args = array();
if (strpos($request, 'index.php') === 0)
{
parse_str(parse_url(htmlspecialchars_decode($request), PHP_URL_QUERY),
$args);
}
else
{
parse_str($request, $args);
}
$request = $args;
}
// Only take the option, view and layout parts.
foreach ($request as $name => $value)
{
if ((!in_array($name, self::$_filter)) && (!($name ==
'task' && !array_key_exists('view',
$request))))
{
// Remove the variables we want to ignore.
unset($request[$name]);
}
}
ksort($request);
return 'index.php?' . http_build_query($request, '',
'&');
}
/**
* Get the menu list for create a menu module
*
* @param int $clientId Optional client id - viz 0 = site, 1 =
administrator, can be NULL for all
*
* @return array The menu array list
*
* @since 1.6
*/
public static function getMenuTypes($clientId = 0)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.menutype')
->from('#__menu_types AS a');
if (isset($clientId))
{
$query->where('a.client_id = ' . (int) $clientId);
}
$db->setQuery($query);
return $db->loadColumn();
}
/**
* Get a list of menu links for one or all menus.
*
* @param string $menuType An option menu to filter the list on,
otherwise all menu with given client id links
* are returned as a grouped array.
* @param integer $parentId An optional parent ID to pivot results
around.
* @param integer $mode An optional mode. If parent ID is set and
mode=2, the parent and children are excluded from the list.
* @param array $published An optional array of states
* @param array $languages Optional array of specify which languages
we want to filter
* @param int $clientId Optional client id - viz 0 = site, 1 =
administrator, can be NULL for all (used only if menutype not givein)
*
* @return array
*
* @since 1.6
*/
public static function getMenuLinks($menuType = null, $parentId = 0, $mode
= 0, $published = array(), $languages = array(), $clientId = 0)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('DISTINCT(a.id) AS value,
a.title AS text,
a.alias,
a.level,
a.menutype,
a.client_id,
a.type,
a.published,
a.template_style_id,
a.checked_out,
a.language,
a.lft'
)
->from('#__menu AS a');
$query->select('e.name as componentname, e.element')
->join('left', '#__extensions e ON e.extension_id =
a.component_id');
if (JLanguageMultilang::isEnabled())
{
$query->select('l.title AS language_title, l.image AS
language_image, l.sef AS language_sef')
->join('LEFT', $db->quoteName('#__languages')
. ' AS l ON l.lang_code = a.language');
}
// Filter by the type if given, this is more specific than client id
if ($menuType)
{
$query->where('(a.menutype = ' . $db->quote($menuType) .
' OR a.parent_id = 0)');
}
elseif (isset($clientId))
{
$query->where('a.client_id = ' . (int) $clientId);
}
// Prevent the parent and children from showing if requested.
if ($parentId && $mode == 2)
{
$query->join('LEFT', '#__menu AS p ON p.id = ' .
(int) $parentId)
->where('(a.lft <= p.lft OR a.rgt >= p.rgt)');
}
if (!empty($languages))
{
if (is_array($languages))
{
$languages = '(' . implode(',',
array_map(array($db, 'quote'), $languages)) . ')';
}
$query->where('a.language IN ' . $languages);
}
if (!empty($published))
{
if (is_array($published))
{
$published = '(' . implode(',', $published) .
')';
}
$query->where('a.published IN ' . $published);
}
$query->where('a.published != -2');
$query->order('a.lft ASC');
// Get the options.
$db->setQuery($query);
try
{
$links = $db->loadObjectList();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
return false;
}
if (empty($menuType))
{
// If the menutype is empty, group the items by menutype.
$query->clear()
->select('*')
->from('#__menu_types')
->where('menutype <> ' .
$db->quote(''))
->order('title, menutype');
if (isset($clientId))
{
$query->where('client_id = ' . (int) $clientId);
}
$db->setQuery($query);
try
{
$menuTypes = $db->loadObjectList();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
return false;
}
// Create a reverse lookup and aggregate the links.
$rlu = array();
foreach ($menuTypes as &$type)
{
$rlu[$type->menutype] = & $type;
$type->links = array();
}
// Loop through the list of menu links.
foreach ($links as &$link)
{
if (isset($rlu[$link->menutype]))
{
$rlu[$link->menutype]->links[] = & $link;
// Cleanup garbage.
unset($link->menutype);
}
}
return $menuTypes;
}
else
{
return $links;
}
}
/**
* Get the associations
*
* @param integer $pk Menu item id
*
* @return array
*
* @since 3.0
*/
public static function getAssociations($pk)
{
$langAssociations =
JLanguageAssociations::getAssociations('com_menus',
'#__menu', 'com_menus.item', $pk, 'id',
'', '');
$associations = array();
foreach ($langAssociations as $langAssociation)
{
$associations[$langAssociation->language] = $langAssociation->id;
}
return $associations;
}
/**
* Load the menu items from database for the given menutype
*
* @param string $menutype The selected menu type
* @param boolean $enabledOnly Whether to load only enabled/published
menu items.
* @param int[] $exclude The menu items to exclude from the list
*
* @return array
*
* @since 3.8.0
*/
public static function getMenuItems($menutype, $enabledOnly = false,
$exclude = array())
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Prepare the query.
$query->select('m.*')
->from('#__menu AS m')
->where('m.menutype = ' . $db->q($menutype))
->where('m.client_id = 1')
->where('m.id > 1');
if ($enabledOnly)
{
$query->where('m.published = 1');
}
// Filter on the enabled states.
$query->select('e.element')
->join('LEFT', '#__extensions AS e ON m.component_id =
e.extension_id')
->where('(e.enabled = 1 OR e.enabled IS NULL)');
if (count($exclude))
{
$exId = array_filter($exclude, 'is_numeric');
$exEl = array_filter($exclude, 'is_string');
if ($exId)
{
$query->where('m.id NOT IN (' . implode(', ',
array_map('intval', $exId)) . ')');
$query->where('m.parent_id NOT IN (' . implode(',
', array_map('intval', $exId)) . ')');
}
if ($exEl)
{
$query->where('e.element NOT IN (' . implode(',
', $db->quote($exEl)) . ')');
}
}
// Order by lft.
$query->order('m.lft');
$db->setQuery($query);
try
{
$menuItems = $db->loadObjectList();
foreach ($menuItems as &$menuitem)
{
$menuitem->params = new Registry($menuitem->params);
}
}
catch (RuntimeException $e)
{
$menuItems = array();
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'),
'error');
}
return $menuItems;
}
/**
* Method to install a preset menu into database and link them to the
given menutype
*
* @param string $preset The preset name
* @param string $menutype The target menutype
*
* @return void
*
* @throws Exception
*
* @since 3.8.0
*/
public static function installPreset($preset, $menutype)
{
$items = MenuHelper::loadPreset($preset, false);
if (count($items) == 0)
{
throw new Exception(JText::_('COM_MENUS_PRESET_LOAD_FAILED'));
}
static::installPresetItems($items, $menutype, 1);
}
/**
* Method to install a preset menu item into database and link it to the
given menutype
*
* @param stdClass[] $items The single menuitem instance with a
list of its descendants
* @param string $menutype The target menutype
* @param int $parent The parent id or object
*
* @return void
*
* @throws Exception
*
* @since 3.8.0
*/
protected static function installPresetItems(&$items, $menutype,
$parent = 1)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
static $components = array();
if (!$components)
{
$query->select('extension_id,
element')->from('#__extensions')->where('type =
' . $db->q('component'));
$components = $db->setQuery($query)->loadObjectList();
$components = ArrayHelper::getColumn((array) $components,
'element', 'extension_id');
}
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onPreprocessMenuItems',
array('com_menus.administrator.import', &$items, null,
true));
foreach ($items as &$item)
{
/** @var JTableMenu $table */
$table = JTable::getInstance('Menu');
$item->alias = $menutype . '-' . $item->title;
if ($item->type == 'separator')
{
// Do not reuse a separator
$item->title = $item->title ?: '-';
$item->alias = microtime(true);
}
elseif ($item->type == 'heading' || $item->type ==
'container')
{
// Try to match an existing record to have minimum collision for a
heading
$keys = array(
'menutype' => $menutype,
'type' => $item->type,
'title' => $item->title,
'parent_id' => $parent,
'client_id' => 1,
);
$table->load($keys);
}
elseif ($item->type == 'url' || $item->type ==
'component')
{
if (substr($item->link, 0, 8) === 'special:')
{
$special = substr($item->link, 8);
if ($special === 'language-forum')
{
$item->link =
'index.php?option=com_admin&view=help&layout=langforum';
}
elseif ($special === 'custom-forum')
{
$item->link = '';
}
}
// Try to match an existing record to have minimum collision for a link
$keys = array(
'menutype' => $menutype,
'type' => $item->type,
'link' => $item->link,
'parent_id' => $parent,
'client_id' => 1,
);
$table->load($keys);
}
// Translate "hideitems" param value from "element"
into "menu-item-id"
if ($item->type == 'container' && count($hideitems
= (array) $item->params->get('hideitems')))
{
foreach ($hideitems as &$hel)
{
if (!is_numeric($hel))
{
$hel = array_search($hel, $components);
}
}
$query->clear()->select('id')->from('#__menu')->where('component_id
IN (' . implode(', ', $hideitems) . ')');
$hideitems = $db->setQuery($query)->loadColumn();
$item->params->set('hideitems', $hideitems);
}
$record = array(
'menutype' => $menutype,
'title' => $item->title,
'alias' => $item->alias,
'type' => $item->type,
'link' => $item->link,
'browserNav' => $item->browserNav ? 1 : 0,
'img' => $item->class,
'access' => $item->access,
'component_id' => array_search($item->element,
$components),
'parent_id' => $parent,
'client_id' => 1,
'published' => 1,
'language' => '*',
'home' => 0,
'params' => (string) $item->params,
);
if (!$table->bind($record))
{
throw new Exception('Bind failed: ' . $table->getError());
}
$table->setLocation($parent, 'last-child');
if (!$table->check())
{
throw new Exception('Check failed: ' .
$table->getError());
}
if (!$table->store())
{
throw new Exception('Saved failed: ' .
$table->getError());
}
$item->id = $table->get('id');
if (!empty($item->submenu))
{
static::installPresetItems($item->submenu, $menutype, $item->id);
}
}
}
}
blank.php000064400000107537151164126170006365 0ustar00<?php
/*----------------------------------------------------------------------------------|
www.vdm.io |----/
Lmskaran
/-------------------------------------------------------------------------------------------------------/
@version 1.0.0
@build 10th April, 2021
@created 10th April, 2021
@package Blank
@subpackage blank.php
@author Mojtaba Taheri <http://lmskaran.com/>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____
_____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \(
_ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/
)(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__)
(_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Language\Language;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* Blank component helper.
*/
abstract class BlankHelper
{
/**
* Composer Switch
*
* @var array
*/
protected static $composer = array();
/**
* The Main Active Language
*
* @var string
*/
public static $langTag;
/**
* Load the Composer Vendors
*/
public static function composerAutoload($target)
{
// insure we load the composer vendor only once
if (!isset(self::$composer[$target]))
{
// get the function name
$functionName = self::safeString('compose' . $target);
// check if method exist
if (method_exists(__CLASS__, $functionName))
{
return self::{$functionName}();
}
return false;
}
return self::$composer[$target];
}
/**
* Load the Component xml manifest.
*/
public static function manifest()
{
$manifestUrl =
JPATH_ADMINISTRATOR."/components/com_blank/blank.xml";
return simplexml_load_file($manifestUrl);
}
/**
* Joomla version object
*/
protected static $JVersion;
/**
* set/get Joomla version
*/
public static function jVersion()
{
// check if set
if (!self::checkObject(self::$JVersion))
{
self::$JVersion = new JVersion();
}
return self::$JVersion;
}
/**
* Load the Contributors details.
*/
public static function getContributors()
{
// get params
$params = JComponentHelper::getParams('com_blank');
// start contributors array
$contributors = array();
// get all Contributors (max 20)
$searchArray = range('0','20');
foreach($searchArray as $nr)
{
if ((NULL !== $params->get("showContributor".$nr))
&& ($params->get("showContributor".$nr) == 1 ||
$params->get("showContributor".$nr) == 3))
{
// set link based of selected option
if($params->get("useContributor".$nr) == 1)
{
$link_front = '<a
href="mailto:'.$params->get("emailContributor".$nr).'"
target="_blank">';
$link_back = '</a>';
}
elseif($params->get("useContributor".$nr) == 2)
{
$link_front = '<a
href="'.$params->get("linkContributor".$nr).'"
target="_blank">';
$link_back = '</a>';
}
else
{
$link_front = '';
$link_back = '';
}
$contributors[$nr]['title'] =
self::htmlEscape($params->get("titleContributor".$nr));
$contributors[$nr]['name'] =
$link_front.self::htmlEscape($params->get("nameContributor".$nr)).$link_back;
}
}
return $contributors;
}
/**
* Can be used to build help urls.
**/
public static function getHelpUrl($view)
{
return false;
}
/**
* Configure the Linkbar.
*/
public static function addSubmenu($submenu)
{
// load user for access menus
$user = JFactory::getUser();
// load the submenus to sidebar
JHtmlSidebar::addEntry(JText::_('COM_BLANK_SUBMENU_DASHBOARD'),
'index.php?option=com_blank&view=blank', $submenu ===
'blank');
JHtmlSidebar::addEntry(JText::_('COM_BLANK_SUBMENU_BLANKADMINS'),
'index.php?option=com_blank&view=blankadmins', $submenu ===
'blankadmins');
}
/**
* Get a Variable
*
* @param string $table The table from which to get the
variable
* @param string $where The value where
* @param string $whereString The target/field string where/name
* @param string $what The return field
* @param string $operator The operator between $whereString/field
and $where/value
* @param string $main The component in which the table is
found
*
* @return mix string/int/float
*
*/
public static function getVar($table, $where = null, $whereString =
'user', $what = 'id', $operator = '=', $main
= 'blank')
{
if(!$where)
{
$where = JFactory::getUser()->id;
}
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__'.$main));
}
else
{
$query->from($db->quoteName('#__'.$main.'_'.$table));
}
if (is_numeric($where))
{
$query->where($db->quoteName($whereString) . '
'.$operator.' '.(int) $where);
}
elseif (is_string($where))
{
$query->where($db->quoteName($whereString) . '
'.$operator.' '. $db->quote((string)$where));
}
else
{
return false;
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
return $db->loadResult();
}
return false;
}
/**
* Get array of variables
*
* @param string $table The table from which to get the
variables
* @param string $where The value where
* @param string $whereString The target/field string where/name
* @param string $what The return field
* @param string $operator The operator between $whereString/field
and $where/value
* @param string $main The component in which the table is
found
* @param bool $unique The switch to return a unique array
*
* @return array
*
*/
public static function getVars($table, $where = null, $whereString =
'user', $what = 'id', $operator = 'IN', $main
= 'blank', $unique = true)
{
if(!$where)
{
$where = JFactory::getUser()->id;
}
if (!self::checkArray($where) && $where > 0)
{
$where = array($where);
}
if (self::checkArray($where))
{
// prep main <-- why? well if $main='' is empty then $table
can be categories or users
if (self::checkString($main))
{
$main = '_'.ltrim($main, '_');
}
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__'.$main));
}
else
{
$query->from($db->quoteName('#_'.$main.'_'.$table));
}
// add strings to array search
if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS'
=== $operator)
{
$query->where($db->quoteName($whereString) . ' ' .
str_replace('_STRINGS', '', $operator) . '
("' . implode('","',$where) .
'")');
}
else
{
$query->where($db->quoteName($whereString) . ' ' .
$operator . ' (' . implode(',',$where) .
')');
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
if ($unique)
{
return array_unique($db->loadColumn());
}
return $db->loadColumn();
}
}
return false;
}
public static function jsonToString($value, $sperator = ", ",
$table = null, $id = 'id', $name = 'name')
{
// do some table foot work
$external = false;
if (strpos($table, '#__') !== false)
{
$external = true;
$table = str_replace('#__', '', $table);
}
// check if string is JSON
$result = json_decode($value, true);
if (json_last_error() === JSON_ERROR_NONE)
{
// is JSON
if (self::checkArray($result))
{
if (self::checkString($table))
{
$names = array();
foreach ($result as $val)
{
if ($external)
{
if ($_name = self::getVar(null, $val, $id, $name, '=',
$table))
{
$names[] = $_name;
}
}
else
{
if ($_name = self::getVar($table, $val, $id, $name))
{
$names[] = $_name;
}
}
}
if (self::checkArray($names))
{
return (string) implode($sperator,$names);
}
}
return (string) implode($sperator,$result);
}
return (string) json_decode($value);
}
return $value;
}
public static function isPublished($id,$type)
{
if ($type == 'raw')
{
$type = 'item';
}
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select(array('a.published'));
$query->from('#__blank_'.$type.' AS a');
$query->where('a.id = '. (int) $id);
$query->where('a.published = 1');
$db->setQuery($query);
$db->execute();
$found = $db->getNumRows();
if($found)
{
return true;
}
return false;
}
public static function getGroupName($id)
{
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select(array('a.title'));
$query->from('#__usergroups AS a');
$query->where('a.id = '. (int) $id);
$db->setQuery($query);
$db->execute();
$found = $db->getNumRows();
if($found)
{
return $db->loadResult();
}
return $id;
}
/**
* Get the action permissions
*
* @param string $view The related view name
* @param int $record The item to act upon
* @param string $views The related list view name
* @param mixed $target Only get this permission (like edit,
create, delete)
* @param string $component The target component
* @param object $user The user whose permissions we are loading
*
* @return object The JObject of permission/authorised actions
*
*/
public static function getActions($view, &$record = null, $views =
null, $target = null, $component = 'blank', $user =
'null')
{
// load the user if not given
if (!self::checkObject($user))
{
// get the user object
$user = JFactory::getUser();
}
// load the JObject
$result = new JObject;
// make view name safe (just incase)
$view = self::safeString($view);
if (self::checkString($views))
{
$views = self::safeString($views);
}
// get all actions from component
$actions = JAccess::getActionsFromFile(
JPATH_ADMINISTRATOR . '/components/com_' . $component .
'/access.xml',
"/access/section[@name='component']/"
);
// if non found then return empty JObject
if (empty($actions))
{
return $result;
}
// get created by if not found
if (self::checkObject($record) && !isset($record->created_by)
&& isset($record->id))
{
$record->created_by = self::getVar($view, $record->id,
'id', 'created_by', '=', $component);
}
// set actions only set in component settings
$componentActions = array('core.admin',
'core.manage', 'core.options',
'core.export');
// check if we have a target
$checkTarget = false;
if ($target)
{
// convert to an array
if (self::checkString($target))
{
$target = array($target);
}
// check if we are good to go
if (self::checkArray($target))
{
$checkTarget = true;
}
}
// loop the actions and set the permissions
foreach ($actions as $action)
{
// check target action filter
if ($checkTarget && self::filterActions($view, $action->name,
$target))
{
continue;
}
// set to use component default
$fallback = true;
// reset permission per/action
$permission = false;
$catpermission = false;
// set area
$area = 'comp';
// check if the record has an ID and the action is item related (not a
component action)
if (self::checkObject($record) && isset($record->id)
&& $record->id > 0 && !in_array($action->name,
$componentActions) &&
(strpos($action->name, 'core.') !== false ||
strpos($action->name, $view . '.') !== false))
{
// we are in item
$area = 'item';
// The record has been set. Check the record permissions.
$permission = $user->authorise($action->name, 'com_' .
$component . '.' . $view . '.' . (int) $record->id);
// if no permission found, check edit own
if (!$permission)
{
// With edit, if the created_by matches current user then dig deeper.
if (($action->name === 'core.edit' || $action->name
=== $view . '.edit') && $record->created_by > 0
&& ($record->created_by == $user->id))
{
// the correct target
$coreCheck = (array) explode('.', $action->name);
// check that we have both local and global access
if ($user->authorise($coreCheck[0] . '.edit.own',
'com_' . $component . '.' . $view . '.' .
(int) $record->id) &&
$user->authorise($coreCheck[0] . '.edit.own',
'com_' . $component))
{
// allow edit
$result->set($action->name, true);
// set not to use global default
// because we already validated it
$fallback = false;
}
else
{
// do not allow edit
$result->set($action->name, false);
$fallback = false;
}
}
}
elseif (self::checkString($views) && isset($record->catid)
&& $record->catid > 0)
{
// we are in item
$area = 'category';
// set the core check
$coreCheck = explode('.', $action->name);
$core = $coreCheck[0];
// make sure we use the core. action check for the categories
if (strpos($action->name, $view) !== false &&
strpos($action->name, 'core.') === false )
{
$coreCheck[0] = 'core';
$categoryCheck = implode('.', $coreCheck);
}
else
{
$categoryCheck = $action->name;
}
// The record has a category. Check the category permissions.
$catpermission = $user->authorise($categoryCheck, 'com_'
. $component . '.' . $views . '.category.' . (int)
$record->catid);
if (!$catpermission && !is_null($catpermission))
{
// With edit, if the created_by matches current user then dig deeper.
if (($action->name === 'core.edit' || $action->name
=== $view . '.edit') && $record->created_by > 0
&& ($record->created_by == $user->id))
{
// check that we have both local and global access
if ($user->authorise('core.edit.own', 'com_'
. $component . '.' . $views . '.category.' . (int)
$record->catid) &&
$user->authorise($core . '.edit.own', 'com_'
. $component))
{
// allow edit
$result->set($action->name, true);
// set not to use global default
// because we already validated it
$fallback = false;
}
else
{
// do not allow edit
$result->set($action->name, false);
$fallback = false;
}
}
}
}
}
// if allowed then fallback on component global settings
if ($fallback)
{
// if item/category blocks access then don't fall back on global
if ((($area === 'item') && !$permission) || (($area
=== 'category') && !$catpermission))
{
// do not allow
$result->set($action->name, false);
}
// Finally remember the global settings have the final say. (even if
item allow)
// The local item permissions can block, but it can't open and
override of global permissions.
// Since items are created by users and global permissions is set by
system admin.
else
{
$result->set($action->name,
$user->authorise($action->name, 'com_' . $component));
}
}
}
return $result;
}
/**
* Filter the action permissions
*
* @param string $action The action to check
* @param array $targets The array of target actions
*
* @return boolean true if action should be filtered out
*
*/
protected static function filterActions(&$view, &$action,
&$targets)
{
foreach ($targets as $target)
{
if (strpos($action, $view . '.' . $target) !== false ||
strpos($action, 'core.' . $target) !== false)
{
return false;
break;
}
}
return true;
}
/**
* Get any component's model
*/
public static function getModel($name, $path =
JPATH_COMPONENT_ADMINISTRATOR, $Component = 'Blank', $config =
array())
{
// fix the name
$name = self::safeString($name);
// full path to models
$fullPathModels = $path . '/models';
// load the model file
JModelLegacy::addIncludePath($fullPathModels, $Component .
'Model');
// make sure the table path is loaded
if (!isset($config['table_path']) ||
!self::checkString($config['table_path']))
{
// This is the JCB default path to tables in Joomla 3.x
$config['table_path'] = JPATH_ADMINISTRATOR .
'/components/com_' . strtolower($Component) .
'/tables';
}
// get instance
$model = JModelLegacy::getInstance($name, $Component . 'Model',
$config);
// if model not found (strange)
if ($model == false)
{
jimport('joomla.filesystem.file');
// get file path
$filePath = $path . '/' . $name . '.php';
$fullPathModel = $fullPathModels . '/' . $name .
'.php';
// check if it exists
if (File::exists($filePath))
{
// get the file
require_once $filePath;
}
elseif (File::exists($fullPathModel))
{
// get the file
require_once $fullPathModel;
}
// build class names
$modelClass = $Component . 'Model' . $name;
if (class_exists($modelClass))
{
// initialize the model
return new $modelClass($config);
}
}
return $model;
}
/**
* Add to asset Table
*/
public static function setAsset($id, $table, $inherit = true)
{
$parent = JTable::getInstance('Asset');
$parent->loadByName('com_blank');
$parentId = $parent->id;
$name = 'com_blank.'.$table.'.'.$id;
$title = '';
$asset = JTable::getInstance('Asset');
$asset->loadByName($name);
// Check for an error.
$error = $asset->getError();
if ($error)
{
return false;
}
else
{
// Specify how a new or moved node asset is inserted into the tree.
if ($asset->parent_id != $parentId)
{
$asset->setLocation($parentId, 'last-child');
}
// Prepare the asset to be stored.
$asset->parent_id = $parentId;
$asset->name = $name;
$asset->title = $title;
// get the default asset rules
$rules = self::getDefaultAssetRules('com_blank', $table,
$inherit);
if ($rules instanceof JAccessRules)
{
$asset->rules = (string) $rules;
}
if (!$asset->check() || !$asset->store())
{
JFactory::getApplication()->enqueueMessage($asset->getError(),
'warning');
return false;
}
else
{
// Create an asset_id or heal one that is corrupted.
$object = new stdClass();
// Must be a valid primary key value.
$object->id = $id;
$object->asset_id = (int) $asset->id;
// Update their asset_id to link to the asset table.
return
JFactory::getDbo()->updateObject('#__blank_'.$table, $object,
'id');
}
}
return false;
}
/**
* Gets the default asset Rules for a component/view.
*/
protected static function getDefaultAssetRules($component, $view, $inherit
= true)
{
// if new or inherited
$assetId = 0;
// Only get the actual item rules if not inheriting
if (!$inherit)
{
// Need to find the asset id by the name of the component.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__assets'))
->where($db->quoteName('name') . ' = ' .
$db->quote($component));
$db->setQuery($query);
$db->execute();
// check that there is a value
if ($db->getNumRows())
{
// asset already set so use saved rules
$assetId = (int) $db->loadResult();
}
}
// get asset rules
$result = JAccess::getAssetRules($assetId);
if ($result instanceof JAccessRules)
{
$_result = (string) $result;
$_result = json_decode($_result);
foreach ($_result as $name => &$rule)
{
$v = explode('.', $name);
if ($view !== $v[0])
{
// remove since it is not part of this view
unset($_result->$name);
}
elseif ($inherit)
{
// clear the value since we inherit
$rule = array();
}
}
// check if there are any view values remaining
if (count((array) $_result))
{
$_result = json_encode($_result);
$_result = array($_result);
// Instantiate and return the JAccessRules object for the asset rules.
$rules = new JAccessRules($_result);
// return filtered rules
return $rules;
}
}
return $result;
}
/**
* xmlAppend
*
* @param SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param mixed $node A SimpleXMLElement node to append
to the XML element reference, or a stdClass object containing a comment
attribute to be injected before the XML node and a fieldXML attribute
containing a SimpleXMLElement
*
* @return null
*
*/
public static function xmlAppend(&$xml, $node)
{
if (!$node)
{
// element was not returned
return;
}
switch (get_class($node))
{
case 'stdClass':
if (property_exists($node, 'comment'))
{
self::xmlComment($xml, $node->comment);
}
if (property_exists($node, 'fieldXML'))
{
self::xmlAppend($xml, $node->fieldXML);
}
break;
case 'SimpleXMLElement':
$domXML = dom_import_simplexml($xml);
$domNode = dom_import_simplexml($node);
$domXML->appendChild($domXML->ownerDocument->importNode($domNode,
true));
$xml = simplexml_import_dom($domXML);
break;
}
}
/**
* xmlComment
*
* @param SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param string $comment The comment to inject
*
* @return null
*
*/
public static function xmlComment(&$xml, $comment)
{
$domXML = dom_import_simplexml($xml);
$domComment = new DOMComment($comment);
$nodeTarget = $domXML->ownerDocument->importNode($domComment,
true);
$domXML->appendChild($nodeTarget);
$xml = simplexml_import_dom($domXML);
}
/**
* xmlAddAttributes
*
* @param SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param array $attributes The attributes to apply to
the XML element
*
* @return null
*
*/
public static function xmlAddAttributes(&$xml, $attributes = array())
{
foreach ($attributes as $key => $value)
{
$xml->addAttribute($key, $value);
}
}
/**
* xmlAddOptions
*
* @param SimpleXMLElement $xml The XML element reference in
which to inject a comment
* @param array $options The options to apply to the
XML element
*
* @return void
*
*/
public static function xmlAddOptions(&$xml, $options = array())
{
foreach ($options as $key => $value)
{
$addOption = $xml->addChild('option');
$addOption->addAttribute('value', $key);
$addOption[] = $value;
}
}
/**
* get the field object
*
* @param array $attributes The array of attributes
* @param string $default The default of the field
* @param array $options The options to apply to the XML
element
*
* @return object
*
*/
public static function getFieldObject(&$attributes, $default =
'', $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes) &&
isset($attributes['type']))
{
// make sure the form helper class is loaded
if (!method_exists('JFormHelper', 'loadFieldType'))
{
jimport('joomla.form.form');
}
// get field type
$field = JFormHelper::loadFieldType($attributes['type'],
true);
// get field xml
$XML = self::getFieldXML($attributes, $options);
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
}
return false;
}
/**
* get the field xml
*
* @param array $attributes The array of attributes
* @param array $options The options to apply to the XML
element
*
* @return object
*
*/
public static function getFieldXML(&$attributes, $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes))
{
// start field xml
$XML = new SimpleXMLElement('<field/>');
// load the attributes
self::xmlAddAttributes($XML, $attributes);
// check if we have options
if (self::checkArray($options))
{
// load the options
self::xmlAddOptions($XML, $options);
}
// return the field xml
return $XML;
}
return false;
}
/**
* Render Bool Button
*
* @param array $args All the args for the button
* 0) name
* 1) additional (options class) // not used
at this time
* 2) default
* 3) yes (name)
* 4) no (name)
*
* @return string The input html of the button
*
*/
public static function renderBoolButton()
{
$args = func_get_args();
// check if there is additional button class
$additional = isset($args[1]) ? (string) $args[1] : ''; // not
used at this time
// button attributes
$buttonAttributes = array(
'type' => 'radio',
'name' => isset($args[0]) ? self::htmlEscape($args[0]) :
'bool_button',
'label' => isset($args[0]) ?
self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool
Button', // not seen anyway
'class' => 'btn-group',
'filter' => 'INT',
'default' => isset($args[2]) ? (int) $args[2] : 0);
// set the button options
$buttonOptions = array(
'1' => isset($args[3]) ? self::htmlEscape($args[3]) :
'JYES',
'0' => isset($args[4]) ? self::htmlEscape($args[4]) :
'JNO');
// return the input
return self::getFieldObject($buttonAttributes,
$buttonAttributes['default'], $buttonOptions)->input;
}
/**
* Check if have an json string
*
* @input string The json string to check
*
* @returns bool true on success
*/
public static function checkJson($string)
{
if (self::checkString($string))
{
json_decode($string);
return (json_last_error() === JSON_ERROR_NONE);
}
return false;
}
/**
* Check if have an object with a length
*
* @input object The object to check
*
* @returns bool true on success
*/
public static function checkObject($object)
{
if (isset($object) && is_object($object))
{
return count((array)$object) > 0;
}
return false;
}
/**
* Check if have an array with a length
*
* @input array The array to check
*
* @returns bool/int number of items in array on success
*/
public static function checkArray($array, $removeEmptyString = false)
{
if (isset($array) && is_array($array) && ($nr =
count((array)$array)) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
{
foreach ($array as $key => $string)
{
if (empty($string))
{
unset($array[$key]);
}
}
return self::checkArray($array, false);
}
return $nr;
}
return false;
}
/**
* Check if have a string with a length
*
* @input string The string to check
*
* @returns bool true on success
*/
public static function checkString($string)
{
if (isset($string) && is_string($string) &&
strlen($string) > 0)
{
return true;
}
return false;
}
/**
* Check if we are connected
* Thanks https://stackoverflow.com/a/4860432/1429677
*
* @returns bool true on success
*/
public static function isConnected()
{
// If example.com is down, then probably the whole internet is down,
since IANA maintains the domain. Right?
$connected = @fsockopen("www.example.com", 80);
// website, port (try 80 or 443)
if ($connected)
{
//action when connected
$is_conn = true;
fclose($connected);
}
else
{
//action in connection failure
$is_conn = false;
}
return $is_conn;
}
/**
* Merge an array of array's
*
* @input array The arrays you would like to merge
*
* @returns array on success
*/
public static function mergeArrays($arrays)
{
if(self::checkArray($arrays))
{
$arrayBuket = array();
foreach ($arrays as $array)
{
if (self::checkArray($array))
{
$arrayBuket = array_merge($arrayBuket, $array);
}
}
return $arrayBuket;
}
return false;
}
// typo sorry!
public static function sorten($string, $length = 40, $addTip = true)
{
return self::shorten($string, $length, $addTip);
}
/**
* Shorten a string
*
* @input string The you would like to shorten
*
* @returns string on success
*/
public static function shorten($string, $length = 40, $addTip = true)
{
if (self::checkString($string))
{
$initial = strlen($string);
$words = preg_split('/([\s\n\r]+)/', $string, null,
PREG_SPLIT_DELIM_CAPTURE);
$words_count = count((array)$words);
$word_length = 0;
$last_word = 0;
for (; $last_word < $words_count; ++$last_word)
{
$word_length += strlen($words[$last_word]);
if ($word_length > $length)
{
break;
}
}
$newString = implode(array_slice($words, 0, $last_word));
$final = strlen($newString);
if ($initial != $final && $addTip)
{
$title = self::shorten($string, 400 , false);
return '<span class="hasTip"
title="'.$title.'"
style="cursor:help">'.trim($newString).'...</span>';
}
elseif ($initial != $final && !$addTip)
{
return trim($newString).'...';
}
}
return $string;
}
/**
* Making strings safe (various ways)
*
* @input string The you would like to make safe
*
* @returns string on success
*/
public static function safeString($string, $type = 'L', $spacer
= '_', $replaceNumbers = true, $keepOnlyCharacters = true)
{
if ($replaceNumbers === true)
{
// remove all numbers and replace with english text version (works well
only up to millions)
$string = self::replaceNumbers($string);
}
// 0nly continue if we have a string
if (self::checkString($string))
{
// create file name without the extention that is safe
if ($type === 'filename')
{
// make sure VDM is not in the string
$string = str_replace('VDM', 'vDm', $string);
// Remove anything which isn't a word, whitespace, number
// or any of the following caracters -_()
// If you don't need to handle multi-byte characters
// you can use preg_replace rather than mb_ereg_replace
// Thanks @Ćukasz Rysiak!
// $string = mb_ereg_replace("([^\w\s\d\-_\(\)])",
'', $string);
$string = preg_replace("([^\w\s\d\-_\(\)])", '',
$string);
// http://stackoverflow.com/a/2021729/1429677
return preg_replace('/\s+/', ' ', $string);
}
// remove all other characters
$string = trim($string);
$string = preg_replace('/'.$spacer.'+/', '
', $string);
$string = preg_replace('/\s+/', ' ', $string);
// Transliterate string
$string = self::transliterate($string);
// remove all and keep only characters
if ($keepOnlyCharacters)
{
$string = preg_replace("/[^A-Za-z ]/", '',
$string);
}
// keep both numbers and characters
else
{
$string = preg_replace("/[^A-Za-z0-9 ]/", '',
$string);
}
// select final adaptations
if ($type === 'L' || $type === 'strtolower')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// default is to return lower
return strtolower($string);
}
elseif ($type === 'W')
{
// return a string with all first letter of each word uppercase(no
undersocre)
return ucwords(strtolower($string));
}
elseif ($type === 'w' || $type === 'word')
{
// return a string with all lowercase(no undersocre)
return strtolower($string);
}
elseif ($type === 'Ww' || $type === 'Word')
{
// return a string with first letter of the first word uppercase and
all the rest lowercase(no undersocre)
return ucfirst(strtolower($string));
}
elseif ($type === 'WW' || $type === 'WORD')
{
// return a string with all the uppercase(no undersocre)
return strtoupper($string);
}
elseif ($type === 'U' || $type === 'strtoupper')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return all upper
return strtoupper($string);
}
elseif ($type === 'F' || $type === 'ucfirst')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return with first caracter to upper
return ucfirst(strtolower($string));
}
elseif ($type === 'cA' || $type === 'cAmel' || $type
=== 'camelcase')
{
// convert all words to first letter uppercase
$string = ucwords(strtolower($string));
// remove white space
$string = preg_replace('/\s+/', '', $string);
// now return first letter lowercase
return lcfirst($string);
}
// return string
return $string;
}
// not a string
return '';
}
public static function transliterate($string)
{
// set tag only once
if (!self::checkString(self::$langTag))
{
// get global value
self::$langTag =
JComponentHelper::getParams('com_blank')->get('language',
'en-GB');
}
// Transliterate on the language requested
$lang = Language::getInstance(self::$langTag);
return $lang->transliterate($string);
}
public static function htmlEscape($var, $charset = 'UTF-8',
$shorten = false, $length = 40)
{
if (self::checkString($var))
{
$filter = new JFilterInput();
$string = $filter->clean(html_entity_decode(htmlentities($var,
ENT_COMPAT, $charset)), 'HTML');
if ($shorten)
{
return self::shorten($string,$length);
}
return $string;
}
else
{
return '';
}
}
public static function replaceNumbers($string)
{
// set numbers array
$numbers = array();
// first get all numbers
preg_match_all('!\d+!', $string, $numbers);
// check if we have any numbers
if (isset($numbers[0]) && self::checkArray($numbers[0]))
{
foreach ($numbers[0] as $number)
{
$searchReplace[$number] = self::numberToString((int)$number);
}
// now replace numbers in string
$string = str_replace(array_keys($searchReplace),
array_values($searchReplace),$string);
// check if we missed any, strange if we did.
return self::replaceNumbers($string);
}
// return the string with no numbers remaining.
return $string;
}
/**
* Convert an integer into an English word string
* Thanks to Tom Nicholson
<http://php.net/manual/en/function.strval.php#41988>
*
* @input an int
* @returns a string
*/
public static function numberToString($x)
{
$nwords = array( "zero", "one", "two",
"three", "four", "five", "six",
"seven",
"eight", "nine", "ten",
"eleven", "twelve", "thirteen",
"fourteen", "fifteen", "sixteen",
"seventeen", "eighteen",
"nineteen", "twenty", 30 => "thirty",
40 => "forty",
50 => "fifty", 60 => "sixty", 70 =>
"seventy", 80 => "eighty",
90 => "ninety" );
if(!is_numeric($x))
{
$w = $x;
}
elseif(fmod($x, 1) != 0)
{
$w = $x;
}
else
{
if($x < 0)
{
$w = 'minus ';
$x = -$x;
}
else
{
$w = '';
// ... now $x is a non-negative integer.
}
if($x < 21) // 0 to 20
{
$w .= $nwords[$x];
}
elseif($x < 100) // 21 to 99
{
$w .= $nwords[10 * floor($x/10)];
$r = fmod($x, 10);
if($r > 0)
{
$w .= ' '. $nwords[$r];
}
}
elseif($x < 1000) // 100 to 999
{
$w .= $nwords[floor($x/100)] .' hundred';
$r = fmod($x, 100);
if($r > 0)
{
$w .= ' and '. self::numberToString($r);
}
}
elseif($x < 1000000) // 1000 to 999999
{
$w .= self::numberToString(floor($x/1000)) .' thousand';
$r = fmod($x, 1000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::numberToString($r);
}
}
else // millions
{
$w .= self::numberToString(floor($x/1000000)) .' million';
$r = fmod($x, 1000000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::numberToString($r);
}
}
}
return $w;
}
/**
* Random Key
*
* @returns a string
*/
public static function randomkey($size)
{
$bag =
"abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ";
$key = array();
$bagsize = strlen($bag) - 1;
for ($i = 0; $i < $size; $i++)
{
$get = rand(0, $bagsize);
$key[] = $bag[$get];
}
return implode($key);
}
}