[*] BO : HelpAccess helper
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12179 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+14
-19
@@ -375,7 +375,10 @@ class AdminControllerCore extends Controller
|
||||
$version = Tools::getValue('version');
|
||||
|
||||
if (isset($item) && isset($iso_user) && isset($country))
|
||||
$this->content = HelpAccess::getHelp($item, $iso_user, $country, $version);
|
||||
{
|
||||
$helper = new HelperHelpAccess($item, $iso_user, $country, $version);
|
||||
$this->content = $helper->generate();
|
||||
}
|
||||
else
|
||||
$this->content = 'none';
|
||||
$this->display = 'content';
|
||||
@@ -1218,20 +1221,8 @@ class AdminControllerCore extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
// Multishop
|
||||
$is_multishop = Shop::isFeatureActive();// && Context::shop() != Shop::CONTEXT_ALL;
|
||||
/*if ($is_multishop)
|
||||
{
|
||||
if (Context::shop() == Shop::CONTEXT_GROUP)
|
||||
{
|
||||
$shop_context = 'group';
|
||||
$shop_name = $this->context->shop->getGroup()->name;
|
||||
}
|
||||
else if (Context::shop() == Shop::CONTEXT_SHOP)
|
||||
{
|
||||
$shop_context = 'shop';
|
||||
$shop_name = $this->context->shop->name;
|
||||
}*/
|
||||
// Multishop
|
||||
$is_multishop = Shop::isFeatureActive();
|
||||
|
||||
// Quick access
|
||||
$quick_access = QuickAccess::getQuickAccesses($this->context->language->id);
|
||||
@@ -1303,7 +1294,7 @@ class AdminControllerCore extends Controller
|
||||
'img_dir' => _PS_IMG_,
|
||||
'iso' => $this->context->language->iso_code,
|
||||
'class_name' => $this->className,
|
||||
'iso_user' => $this->context->language->id,
|
||||
'iso_user' => $this->context->language->iso_code,
|
||||
'country_iso_code' => $this->context->country->iso_code,
|
||||
'version' => _PS_VERSION_,
|
||||
'autorefresh_notifications' => Configuration::get('PS_ADMIN_REFRESH_NOTIFICATION'),
|
||||
@@ -1334,7 +1325,8 @@ class AdminControllerCore extends Controller
|
||||
'tabs' => $tabs,
|
||||
'install_dir_exists' => file_exists(_PS_ADMIN_DIR_.'/../install'),
|
||||
'is_multishop' => $is_multishop,
|
||||
'pic_dir' => _THEME_PROD_PIC_DIR_
|
||||
'pic_dir' => _THEME_PROD_PIC_DIR_,
|
||||
'controller_name' => Tools::getValue('controller'),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1438,7 +1430,9 @@ class AdminControllerCore extends Controller
|
||||
return false;
|
||||
|
||||
$helper = new HelperList();
|
||||
|
||||
$this->setHelperDisplay($helper);
|
||||
$this->tpl_list_vars['img_dir'] = 'toto';
|
||||
$helper->tpl_vars = $this->tpl_list_vars;
|
||||
$helper->tpl_delete_link_vars = $this->tpl_delete_link_vars;
|
||||
// Check if list templates have been overriden
|
||||
@@ -1542,7 +1536,6 @@ class AdminControllerCore extends Controller
|
||||
$helper->title = $this->toolbar_title;
|
||||
$helper->toolbar_btn = $this->toolbar_btn;
|
||||
|
||||
$helper->ps_help_context = !Configuration::get('PS_NO_HELP_CONTEXT');
|
||||
$helper->show_toolbar = $this->show_toolbar;
|
||||
$helper->toolbar_fix = $this->toolbar_fix;
|
||||
$helper->override_folder = $this->tpl_folder;
|
||||
@@ -1590,9 +1583,11 @@ class AdminControllerCore extends Controller
|
||||
_PS_JS_DIR_.'tools.js',
|
||||
_PS_JS_DIR_.'ajax.js',
|
||||
_PS_JS_DIR_.'notifications.js',
|
||||
_PS_JS_DIR_.'helpAccess.js',
|
||||
_PS_JS_DIR_.'toolbar.js'
|
||||
));
|
||||
|
||||
if (Configuration::get('PS_HELPBOX'))
|
||||
$this->addJS(_PS_JS_DIR_.'helpAccess.js');
|
||||
}
|
||||
/**
|
||||
* use translations files to replace english expression.
|
||||
|
||||
+32
-49
@@ -30,10 +30,13 @@ class HelpAccessCore
|
||||
{
|
||||
const URL = 'http://help.prestashop.com';
|
||||
|
||||
protected static $_images = array(0 => 'none',
|
||||
1 => 'help2.png',
|
||||
2 => 'help-new.png');
|
||||
|
||||
/**
|
||||
* Store in the local database that the user has seen a specific help page
|
||||
*
|
||||
* @static
|
||||
* @param $label
|
||||
* @param $version
|
||||
*/
|
||||
public static function trackClick($label, $version)
|
||||
{
|
||||
Db::getInstance()->execute('
|
||||
@@ -42,6 +45,13 @@ class HelpAccessCore
|
||||
');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last version seen of a help page seen by the user
|
||||
*
|
||||
* @static
|
||||
* @param $label
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getVersion($label)
|
||||
{
|
||||
return Db::getInstance()->getValue('
|
||||
@@ -50,14 +60,26 @@ class HelpAccessCore
|
||||
');
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch information from the help website in order to know:
|
||||
* - if the help page exists
|
||||
* - his version
|
||||
* - the associated tooltip
|
||||
*
|
||||
* @static
|
||||
* @param $label
|
||||
* @param $iso_lang
|
||||
* @param $country
|
||||
* @param $version
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function retrieveInfos($label, $iso_lang, $country, $version)
|
||||
{
|
||||
$image = self::$_images[0];
|
||||
$tooltip = '';
|
||||
$url = HelpAccess::URL.'/documentation/renderIcon?label='.$label.'&iso_lang='.$iso_lang.'&country='.$country.'&version='.$version;
|
||||
$tooltip = '';
|
||||
|
||||
$ctx = @stream_context_create(array('http' => array('timeout' => 10)));
|
||||
|
||||
$ctx = @stream_context_create(array('http' => array('timeout' => 10)));
|
||||
$res = @file_get_contents($url, 0, $ctx);
|
||||
|
||||
$infos = preg_split('/\|/', $res);
|
||||
@@ -66,51 +88,12 @@ class HelpAccessCore
|
||||
$version = trim($infos[0]);
|
||||
if (!empty($version))
|
||||
{
|
||||
$image = self::$_images[1];
|
||||
|
||||
if (sizeof($infos) > 1)
|
||||
$tooltip = trim('|'.$infos[1]);
|
||||
$tooltip = trim($infos[1]);
|
||||
}
|
||||
}
|
||||
|
||||
$last_version = HelpAccess::getVersion($label);
|
||||
|
||||
if (!empty($version) && $version != $last_version)
|
||||
$image = self::$_images[2];
|
||||
|
||||
return array('version' => $version, 'image' => $image, 'tooltip' => $tooltip);
|
||||
return array('version' => $version, 'tooltip' => $tooltip);
|
||||
}
|
||||
|
||||
public static function displayHelp($label, $iso_lang, $country, $ps_version)
|
||||
{
|
||||
echo HelpAccess::getHelp($label, $iso_lang, $country, $ps_version);
|
||||
return true;
|
||||
}
|
||||
public static function getHelp($label, $iso_lang, $country, $ps_version)
|
||||
{
|
||||
$content = '';
|
||||
$infos = HelpAccess::retrieveInfos($label, $iso_lang, $country, $ps_version);
|
||||
if (array_key_exists('image', $infos) && $infos['image'] != 'none')
|
||||
{
|
||||
$content .= '
|
||||
<a class="help-button" href="#" onclick="showHelp(\''.HelpAccess::URL.'\',\''.Tools::safeOutput($label).'\',\''.Tools::safeOutput($iso_lang).'\',\''.Tools::safeOutput($ps_version).'\',\''.Tools::safeOutput($infos['version']).'\',\''.Tools::safeOutput($country).'\');" title="'.Tools::htmlentitiesUTF8($infos['tooltip']).'">
|
||||
<img id="help-'.$label.'" src="../img/admin/'.Tools::htmlentitiesUTF8($infos['image']).'" alt="" class="middle" style="margin-top: -5px"/> '.Tools::displayError('HELP').'
|
||||
</a>';
|
||||
if (!empty($infos['tooltip']))
|
||||
$content .= ' <script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("a.help-button").cluetip({
|
||||
splitTitle: "|",
|
||||
cluetipClass: "help-button",
|
||||
showTitle: false,
|
||||
arrows: true,
|
||||
dropShadow: false,
|
||||
positionBy: "auto"
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -141,13 +141,6 @@ class HelperFormCore extends Helper
|
||||
$this->tpl->assign(array(
|
||||
'title' => $this->title,
|
||||
'toolbar_btn' => $this->toolbar_btn,
|
||||
|
||||
'ps_help_context' => $this->ps_help_context,
|
||||
'class_name' => get_class($this->context->controller),
|
||||
'iso_user' => $this->context->language->id,
|
||||
'country_iso_code' => $this->context->country->iso_code,
|
||||
'version' => _PS_VERSION_,
|
||||
|
||||
'show_toolbar' => $this->show_toolbar,
|
||||
'toolbar_fix' => $this->toolbar_fix,
|
||||
'submit_action' => $this->submit_action,
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 1.5
|
||||
*/
|
||||
class HelperHelpAccess extends Helper
|
||||
{
|
||||
public $label;
|
||||
public $iso_lang;
|
||||
public $country;
|
||||
public $ps_version;
|
||||
|
||||
|
||||
public function __construct($label, $iso_lang, $country, $ps_version)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->base_folder = 'helper/help_access/';
|
||||
|
||||
$this->tpl = $this->createTemplate('button.tpl');
|
||||
$this->label = $label;
|
||||
$this->iso_lang = $iso_lang;
|
||||
$this->country = $country;
|
||||
$this->ps_version = $ps_version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|void
|
||||
*/
|
||||
public function generate()
|
||||
{
|
||||
$info = HelpAccess::retrieveInfos($this->label, $this->iso_lang, $this->country, $this->ps_version);
|
||||
$content = '';
|
||||
|
||||
if (array_key_exists('version', $info) && $info['version'] != '')
|
||||
{
|
||||
$tpl_vars['label'] = $this->label;
|
||||
$tpl_vars['iso_lang'] = $this->iso_lang;
|
||||
$tpl_vars['country'] = $this->country;
|
||||
$tpl_vars['version'] = $this->ps_version;
|
||||
$tpl_vars['doc_version'] = $info['version'];
|
||||
$tpl_vars['help_base_url'] = HelpAccess::URL;
|
||||
$tpl_vars['tooltip'] = $info['tooltip'];
|
||||
|
||||
$this->tpl->assign($tpl_vars);
|
||||
|
||||
$content = parent::generate();
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
@@ -589,13 +589,6 @@ class HelperListCore extends Helper
|
||||
'show_toolbar' => $this->show_toolbar,
|
||||
'toolbar_fix' => $this->toolbar_fix,
|
||||
'toolbar_btn' => $this->toolbar_btn,
|
||||
|
||||
'ps_help_context' => $this->ps_help_context,
|
||||
'class_name' => get_class($this->context->controller),
|
||||
'iso_user' => $this->context->language->id,
|
||||
'country_iso_code' => $this->context->country->iso_code,
|
||||
'version' => _PS_VERSION_,
|
||||
|
||||
'table' => $this->table,
|
||||
'currentIndex' => $this->currentIndex,
|
||||
'action' => $action,
|
||||
|
||||
Reference in New Issue
Block a user