diff --git a/admin-dev/header.inc.php b/admin-dev/header.inc.php index 4fffaff5b..2fb4d5c7a 100644 --- a/admin-dev/header.inc.php +++ b/admin-dev/header.inc.php @@ -1,6 +1,6 @@ @@ -72,13 +70,13 @@ echo ' if (data) { json = jQuery.parseJSON(data); - + // Add orders notifications to the list html = ""; nb_notifs = 0; $.each(json.order, function(property, value) { html += "
  • '.translate('A new order has been made on your shop.').'
    '.translate('Order number : ').'#" + parseInt(value.id_order) + "
    '.translate('Total : ').'" + value.total_paid_real + "
    '.translate('From : ').'" + value.customer_name + "
    '.translate('Click here to see that order').'
  • "; - }); + }); if (html != "") { $("#list_orders_notif").prev("p").hide(); @@ -90,17 +88,17 @@ echo ' else { $("#orders_notif_number_wrapper").hide(); - } - + } + // Add customers notifications to the list html = ""; nb_notifs = 0; $.each(json.customer, function(property, value) { html += "
  • '.translate('A new customer registered on your shop.').'
    '.translate('Customer name : ').'" + value.customer_name + "
    '.translate('Click here to see that customer').'
  • "; - }); + }); if (html != "") { - $("#list_customers_notif").prev("p").hide(); + $("#list_customers_notif").prev("p").hide(); $("#list_customers_notif").empty().append(html); nb_notifs = $("#list_customers_notif li").length; $("#customers_notif_value").text(nb_notifs); @@ -110,7 +108,7 @@ echo ' { $("#customers_notif_number_wrapper").hide(); } - + // Add messages notifications to the list html = ""; nb_notifs = 0; @@ -119,7 +117,7 @@ echo ' }); if (html != "") { - $("#list_messages_notif").prev("p").hide(); + $("#list_messages_notif").prev("p").hide(); $("#list_messages_notif").empty().append(html); nb_notifs = $("#list_messages_notif li").length; $("#messages_notif_value").text(nb_notifs); @@ -129,12 +127,12 @@ echo ' { $("#messages_notif_number_wrapper").hide(); } - + } setTimeout("getPush()",60000); }); } - + $().ready(function() { var hints = $(\'.translatable span.hint\'); @@ -149,12 +147,12 @@ echo ' $youEditFieldFor = sprintf(translate('A modification of this field will be applied for the shop %s'), ''.Context::getContext()->shop->name.''); echo 'hints.html(hints.html()+\'
    '.addslashes($youEditFieldFor).'\');'; } - -echo ' var html = ""; + +echo ' var html = ""; var nb_notifs = 0; var wrapper_id = ""; var type = new Array(); - + $(".notifs").live("click", function(){ wrapper_id = $(this).attr("id"); type = wrapper_id.split("s_notif") @@ -164,16 +162,16 @@ echo ' var html = ""; if(!$("#" + wrapper_id + "_wrapper").is(":visible")) { $(".notifs_wrapper").hide(); - $("#" + wrapper_id + "_number_wrapper").hide(); - $("#" + wrapper_id + "_wrapper").show(); + $("#" + wrapper_id + "_number_wrapper").hide(); + $("#" + wrapper_id + "_wrapper").show(); }else { - $("#" + wrapper_id + "_wrapper").hide(); + $("#" + wrapper_id + "_wrapper").hide(); } - } + } }); }); - + $("#main").click(function(){ $(".notifs_wrapper").hide(); }); @@ -209,7 +207,7 @@ echo ' var html = ""; '; } - if (Configuration::get('PS_SHOW_NEW_MESSAGES') == 1) + if (Configuration::get('PS_SHOW_NEW_MESSAGES') == 1) { echo '
    0
    @@ -324,7 +322,7 @@ if (Context::getContext()->employee->bo_uimode == 'hover') echo '
    ' - .(file_exists(PS_ADMIN_DIR.'/../install') ? '
    ' + .(file_exists(_PS_ADMIN_DIR_.'/../install') ? '
    ' .translate('For security reasons, you must also:').' '. translate('delete the /install folder'). '
    ' : '').' diff --git a/admin-dev/index.php b/admin-dev/index.php index 9af8d30a1..7a5d0bcf5 100644 --- a/admin-dev/index.php +++ b/admin-dev/index.php @@ -26,11 +26,10 @@ */ define('_PS_ADMIN_DIR_', getcwd()); -define('PS_ADMIN_DIR', _PS_ADMIN_DIR_); // Retro-compatibility -include(PS_ADMIN_DIR.'/../config/config.inc.php'); -include(PS_ADMIN_DIR.'/functions.php'); -include(PS_ADMIN_DIR.'/header.inc.php'); +include(_PS_ADMIN_DIR_.'/../config/config.inc.php'); +include(_PS_ADMIN_DIR_.'/functions.php'); +include(_PS_ADMIN_DIR_.'/init.php'); if (empty($tab) and !sizeof($_POST)) { $tab = 'AdminHome'; @@ -38,14 +37,22 @@ if (empty($tab) and !sizeof($_POST)) $_POST['token'] = Tools::getAdminTokenLite($tab); } - if ($adminObj = checkingTab($tab)) +if ($adminObj = checkingTab($tab)) +{ + // init is different for new tabs (AdminController) and old tabs (AdminTab) + if ($adminObj instanceof AdminController) { + $adminObj->path = dirname($_SERVER["PHP_SELF"]); + $adminObj->run(); + } + else + { + include(_PS_ADMIN_DIR_.'/header.inc.php'); $isoUser = Context::getContext()->language->id; $tabs = array(); $tabs = recursiveTab($adminObj->id, $tabs); $tabs = array_reverse($tabs); $bread = ''; - foreach ($tabs AS $key => $item) $bread .= ' > '.((sizeof($tabs) - 1 > $key) @@ -75,8 +82,8 @@ if (empty($tab) and !sizeof($_POST)) '.$bread; echo '
    '; - - + + if (Shop::isMultiShopActivated() && Context::shop() != Shop::CONTEXT_ALL) { echo '
    '; @@ -144,7 +151,8 @@ if (empty($tab) and !sizeof($_POST)) die; } } + include(_PS_ADMIN_DIR_.'/footer.inc.php'); } +} -include(PS_ADMIN_DIR.'/footer.inc.php'); diff --git a/admin-dev/tabs/AdminTools.php b/admin-dev/tabs/AdminTools.php index 2bcc86a33..2f01cabda 100644 --- a/admin-dev/tabs/AdminTools.php +++ b/admin-dev/tabs/AdminTools.php @@ -1,6 +1,6 @@ className = 'AdminTools'; + parent::__construct(); } - + public function display() { - echo '
    '.$this->l('Shop Tools').''; - echo '

    '.$this->l('Several tools are available to manage your shop.').'

    '; - echo '
    '; - echo '

    '.$this->l('Please choose a tool by selecting a Tools sub-tab above.').'

    '; - echo '
    '; + parent::display(); + $this->context->smarty->display('adminTools.tpl'); } } diff --git a/admin-dev/themes/default/admin.css b/admin-dev/themes/default/admin.css new file mode 100644 index 000000000..5f3da0854 --- /dev/null +++ b/admin-dev/themes/default/admin.css @@ -0,0 +1,82 @@ +body{background:#EFEFEF} +#top_container{margin:0;padding:0} +#header_infos{float:left;font-size:10px;margin:10px 20px 4px 0;width:380px;height:40px} +#header_infos #header_shopname span{display:block;font-size:24px;height:28px;overflow:hidden;margin-bottom:-8px} +#header_infos #header_logout{text-decoration:underline} +#header_infos #header_foaccess{text-decoration:none} +#header_search{float:right;height:39px;width:356px} +#header_search #bo_query{float:left;height:16px;line-height:16px;margin:8px 2px 0 30px;vertical-align:middle;width:140px} +#header_search #bo_search_type{float:left;height:21px;line-height:21px;margin:8px 2px 0 0;vertical-align:middle;width:90px} +#header_search #bo_search_submit{cursor:pointer;float:left;font-weight:700;margin:7px 0 0 2px;width:79px} +#header_quick{float:right;height:39px;margin-right:1px;width:175px} +#header_quick #quick_select{margin:8px 0 0 20px;vertical-align:middle;width:140px} +#header_shoplist{float: right;} +#header_myaccount{background:url(bg-lang.png) no-repeat;display:block;float:right;height:16px;margin:8px 1px 0 0;width:16px} +.button{background-color:#FFF6D3;border:1px solid #DFD5AF;border-left:1px solid #FFF6D3;border-top:1px solid #FFF6D3;color:#268CCD;padding:3px} +.button[disabled=disabled]{color:#8C8C8C} +input.button[disabled=disabled]:hover{background-color:#FFF6D3} +.button:hover{background-color:#F0EBD6} +.table{border:1px solid #DFD5C3;padding:0} +.table th a{text-decoration:underline} +.table a:hover{text-decoration:none} +.table tr th{background:#F4E6C9 url(news-bg.gif) repeat-x top left;padding:4px 6px} +.table tr td{border-bottom:1px solid #DEDEDE;color:#963;font-size:.9em;height:23px;padding:0 4px 0 6px} +.table tr.last td{border-bottom:none} +.alt_row{background-color:#EFEFEF} +.path_bar{background-color:#E2EBEE;border:1px solid #999999;font-family:Trebuchet,Arial,Helvetica,sans-serif;font-size:13px;margin-bottom:20px;padding:5px} +.path_bar a{font-weight:700} +.cat_bar{background-color:#F4E8CD;border:1px solid #999999;font-family:Trebuchet,Arial,Helvetica,sans-serif;font-size:12px;font-weight:700;margin-bottom:20px;padding:5px} +.cat_bar a{font-weight:700} +fieldset{background:#FFFFF0;border:1px solid #DFD5C3;font-size:1.1em;margin:0;padding:1em} +legend{background:#FFF6D3;border:1px solid #DFD5C3;font-weight:700;margin:0;padding:.2em .5em;text-align:left} +#menu{float:left;height:30px;line-height:normal;margin:10px 0 0;*margin:7px 0 0;padding:0;width:100%;padding:0 1px} +#menu li{background:url(bg-tab.png) repeat-x 0 -2px;float:left;height:29px;list-style:none;margin:0 1px 0 0;list-style:none;display:block;border:1px solid #999999;-moz-border-radius-topright:6px;-moz-border-radius-topleft:6px;-webkit-border-top-right-radius:6px;-webkit-border-top-left-radius:6px} +#menu li a{color:#000;display:block;height:20px;padding:8px 8px 4px 0;font-weight:bold;font-size:0.95em;} +#menu img{display:inline;padding:0 3px 0 6px;vertical-align:top;width:16px;height:16px} +#menu li.active,#menu li:hover{background-position:0 -38px;white-space:nowrap;} +#menu li.active a{color:#000} +#submenu{background:#ECEADE;clear:both;color:#666;margin:0;padding:0;border:1px solid #999999} +.withLeftBorder{background:transparent url(separator_subnav.png) no-repeat 0 5px} +#submenu li{display:inline;list-style:none;margin:0;background:transparent url(separator_subnav.png) no-repeat right 0;padding-left:7px;padding-right:7px;margin-top:8px;float:left;height:29px} +#submenu li a{text-decoration:underline} +#menu li{_height:32px;_padding-top:3px} +#menu li a{_display:inline;_padding:6px 5px 4px 0} +.tab-page {border:1px solid #ccc;background:#FFFFF0} +.tab-row .tab.selected {border:1px solid #ccc;background:#FFF6D3;margin:1px -3px -3px 0px;top:-2px} +.tab-row .tab {background:#EFEFEF} +hr {height: 1px;color:#E0D0B1;background-color:#E0D0B1} +#footer {height:40px;background:#ECEADE url(footer-bg.png) repeat-x scroll left bottom;border:1px solid #999999;font-size:12px;clear:both;font-size:0.9em;color:#666666} +#content {background-color:#FFF;border-left:1px solid #999999;border-right:1px solid #999999} +input[type="text"],input[type="password"],input[type="file"],textarea {border:1px solid #E0D0B1} +select {border: 1px solid #E0D0B1} +select[disabled="disabled"], input[disabled="disabled"],textarea[disabled="disabled"] {border: 1px solid #CCCCCC;color: #AAAAAA} +.header_module{background:url(header_module.png);padding-left: 0.5em;padding-top: 0.8em;height:20px;color: #812143;border:solid 1px #CCC;} +a.action_module{color: #268CCD;text-decoration: underline;} +a.header_module_toggle{font-weight: bold;color: #268CCD;display:block;} +a.module_toggle_all{color: #268CCD;} +.nbr_module{float:right;margin-right:10px;font-style:italic;font-size:12px;color: #268CCD;} + +.autoupgradeSteps div { line-height: 30px; } +.upgradestep { margin-right: 5px;padding-left: 10px; padding-right: 5px;} +#upgradeNow.stepok, .autoupgradeSteps a.stepok { background-image: url("../img/admin/enabled.gif");background-position: left center;background-repeat: no-repeat;padding-left: 15px;} +#upgradeNow {-moz-border-bottom-colors: none;-moz-border-image: none;-moz-border-left-colors: none;-moz-border-right-colors: none;-moz-border-top-colors: none;border-color: #FFF6D3 #DFD5AF #DFD5AF #FFF6D3;border-right: 1px solid #DFD5AF;border-style: solid;border-width: 1px;color: #268CCD;font-size: medium;padding: 5px;} +.button-autoupgrade {-moz-border-bottom-colors: none;-moz-border-image: none;-moz-border-left-colors: none;-moz-border-right-colors: none;-moz-border-top-colors: none;border-color: #FFF6D3 #DFD5AF #DFD5AF #FFF6D3;border-right: 1px solid #DFD5AF;border-style: solid;border-width: 1px;color: #268CCD;font-size: medium;padding: 5px;} +.processing {overflow: auto;} + +#header_infos {width: 445px;} +#header_shopname {float: left;width: 300px;} +#employee_links {float: left;clear: both;margin-top: 10px;} +#notifs_icon_wrapper {float: left;position: relative;margin-top: 8px;} +.notifs {float: left;position: relative; cursor: pointer;margin: 0px 5px;width: 18px;height: 15px;} +#orders_notif {background: url("notif_order.png") no-repeat left top;} +#customers_notif {background: url("notif_customer.png") no-repeat left top;} +#messages_notif {background: url("notif_message.png") no-repeat left top;} +.number_wrapper {color: white;display: none;font-size: 13px;font-weight: bold;position: absolute;right: -8px;top: -10px;z-index: 101;padding: 2px 5px;} +.number_wrapper span {background-color: #F03D25;display: block;padding: 0 2px;border-color: -moz-use-text-color #DD3822 #DD3822;border-radius: 2px 2px 2px 2px;border-right: 1px solid #DD3822;border-style: none solid solid;border-width: 0 0px;} +.notifs_wrapper {display: none;cursor:auto; position: absolute;top: 20px;left: 0;width:300px;background-color: white;border:2px solid #E0E0E0;padding: 10px;color: black;} +.notifs_wrapper h3 {font-size: 14px;padding-bottom:8px;margin:0;border-bottom: 2px solid #E0E0E0;} +.notifs_wrapper ul {padding:6px 0;margin:0;} +.notifs_wrapper ul li {text-decoration: none;list-style: none;font-size:12px;padding:5px 0;} +#header_infos .notifs_wrapper a {font-weight: bold;color: black;} +.notifs_wrapper p {font-size: 12px;padding-top:8px;margin:0;border-top: 2px solid #E0E0E0;} +.notifs_wrapper p.no_notifs {border: none;} \ No newline at end of file diff --git a/admin-dev/themes/default/bg-lang.png b/admin-dev/themes/default/bg-lang.png new file mode 100644 index 000000000..a1f547194 Binary files /dev/null and b/admin-dev/themes/default/bg-lang.png differ diff --git a/admin-dev/themes/default/bg-quick.png b/admin-dev/themes/default/bg-quick.png new file mode 100644 index 000000000..4acbb75b4 Binary files /dev/null and b/admin-dev/themes/default/bg-quick.png differ diff --git a/admin-dev/themes/default/bg-submenu.png b/admin-dev/themes/default/bg-submenu.png new file mode 100644 index 000000000..ba30c6b36 Binary files /dev/null and b/admin-dev/themes/default/bg-submenu.png differ diff --git a/admin-dev/themes/default/bg-subtab.png b/admin-dev/themes/default/bg-subtab.png new file mode 100644 index 000000000..fdc1b1180 Binary files /dev/null and b/admin-dev/themes/default/bg-subtab.png differ diff --git a/admin-dev/themes/default/bg-tab.png b/admin-dev/themes/default/bg-tab.png new file mode 100644 index 000000000..f2dcf116f Binary files /dev/null and b/admin-dev/themes/default/bg-tab.png differ diff --git a/admin-dev/themes/default/bg-top.png b/admin-dev/themes/default/bg-top.png new file mode 100644 index 000000000..a07fbec98 Binary files /dev/null and b/admin-dev/themes/default/bg-top.png differ diff --git a/admin-dev/themes/default/button-bg.png b/admin-dev/themes/default/button-bg.png new file mode 100644 index 000000000..bbde5ed57 Binary files /dev/null and b/admin-dev/themes/default/button-bg.png differ diff --git a/admin-dev/themes/default/footer-bg.png b/admin-dev/themes/default/footer-bg.png new file mode 100644 index 000000000..a72c8ba8d Binary files /dev/null and b/admin-dev/themes/default/footer-bg.png differ diff --git a/admin-dev/themes/default/header_module.png b/admin-dev/themes/default/header_module.png new file mode 100644 index 000000000..afaaae61d Binary files /dev/null and b/admin-dev/themes/default/header_module.png differ diff --git a/admin-dev/themes/default/index.php b/admin-dev/themes/default/index.php new file mode 100644 index 000000000..4e2611d37 --- /dev/null +++ b/admin-dev/themes/default/index.php @@ -0,0 +1,36 @@ + +* @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 +*/ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; \ No newline at end of file diff --git a/admin-dev/themes/default/news-bg.gif b/admin-dev/themes/default/news-bg.gif new file mode 100644 index 000000000..9adbd05e5 Binary files /dev/null and b/admin-dev/themes/default/news-bg.gif differ diff --git a/admin-dev/themes/default/notif_customer.png b/admin-dev/themes/default/notif_customer.png new file mode 100644 index 000000000..8a48039e7 Binary files /dev/null and b/admin-dev/themes/default/notif_customer.png differ diff --git a/admin-dev/themes/default/notif_message.png b/admin-dev/themes/default/notif_message.png new file mode 100644 index 000000000..517a5a474 Binary files /dev/null and b/admin-dev/themes/default/notif_message.png differ diff --git a/admin-dev/themes/default/notif_order.png b/admin-dev/themes/default/notif_order.png new file mode 100644 index 000000000..e72645c99 Binary files /dev/null and b/admin-dev/themes/default/notif_order.png differ diff --git a/admin-dev/themes/default/searchbar.png b/admin-dev/themes/default/searchbar.png new file mode 100644 index 000000000..26b93aeef Binary files /dev/null and b/admin-dev/themes/default/searchbar.png differ diff --git a/admin-dev/themes/default/searchbutton.png b/admin-dev/themes/default/searchbutton.png new file mode 100644 index 000000000..31327bf89 Binary files /dev/null and b/admin-dev/themes/default/searchbutton.png differ diff --git a/admin-dev/themes/default/separator_subnav.png b/admin-dev/themes/default/separator_subnav.png new file mode 100644 index 000000000..0d2a18ad0 Binary files /dev/null and b/admin-dev/themes/default/separator_subnav.png differ diff --git a/admin-dev/themes/default/tab_right.gif b/admin-dev/themes/default/tab_right.gif new file mode 100644 index 000000000..82740efa4 Binary files /dev/null and b/admin-dev/themes/default/tab_right.gif differ diff --git a/admin-dev/themes/default/thead.png b/admin-dev/themes/default/thead.png new file mode 100644 index 000000000..afaaae61d Binary files /dev/null and b/admin-dev/themes/default/thead.png differ diff --git a/admin-dev/themes/template/adminTools.tpl b/admin-dev/themes/template/adminTools.tpl new file mode 100644 index 000000000..43a1d0987 --- /dev/null +++ b/admin-dev/themes/template/adminTools.tpl @@ -0,0 +1,34 @@ +{* +* 2007-2011 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 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/afl-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 +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision$ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + +{include file='header.tpl'} +
    + {l s='Shop Tools'} +

    {l s='Several tools are available to manage your shop.'}

    +
    +

    {l s='Please choose a tool by selecting a Tools sub-tab above.'}

    +
    +{include file='footer.tpl'} \ No newline at end of file diff --git a/admin-dev/themes/template/footer.tpl b/admin-dev/themes/template/footer.tpl new file mode 100644 index 000000000..3e7579ff9 --- /dev/null +++ b/admin-dev/themes/template/footer.tpl @@ -0,0 +1,47 @@ +{* +* 2007-2011 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 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/afl-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 +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision$ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + +
    +
    + {$HOOK_FOOTER} + +
    +
    + + diff --git a/admin-dev/themes/template/header.tpl b/admin-dev/themes/template/header.tpl new file mode 100644 index 000000000..eccf341d9 --- /dev/null +++ b/admin-dev/themes/template/header.tpl @@ -0,0 +1,263 @@ +{* +* 2007-2011 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 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/afl-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 +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision$ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + + + + + + + PrestaShop™ - {l s='Administration panel'|escape:'htmlall':'UTF-8'} + + + {if isset($css_files)} + {foreach from=$css_files key=css_uri item=media} + + {/foreach} + {/if} + {if isset($js_files)} + {foreach from=$js_files item=js_uri} + + {/foreach} + {/if} + + + + {$HOOK_HEADER} + + + + + {if $is_multishop} + + {/if} +
    +
    +
    + {$shop_name}
    + {if {$show_new_orders} == 1} +
    + + 0 + +
    +

    {l s='Last orders'}

    +

    {l s='No new orders has been made on your shop'}

    +
      +

      {l s='Show all orders'}

      +
      +
      + {/if} + {if ($show_new_customers == 1)} +
      + + 0 + +
      +

      {l s='Last customers'}

      +

      {l s='No new customers registered on your shop'}

      +
        +

        {l s='Show all customers'}

        +
        +
        + {/if} + {if {$show_new_messages} == 1} +
        + + 0 + +
        +

        {l s='Last messages'}

        +

        {l s='No new messages posted on your shop'}

        +
          +

          {l s='Show all messages'}

          +
          +
          + {/if} +
          + + {$first_name} {$last_name} + [ + {l s='logout'} + ] + {if {$base_url}} + - {l s='View my shop'} + {/if} + - {l s='My preferences'} +
          + +
          + + +
          + + {if $multi_shop} +
          {l s='Select your shop:'}{$shop_list}
          + {/if} +
           
          + {$HOOK_TOP} + + {foreach $tabs AS $t} + + {/foreach} + {if $employee->bo_uimode == 'hover'} + + {/if} + +
          +
          + {if $install_dir_exists} +
          + {l s='For security reasons, you must also:'} {l s='delete the /install folder'} +
          + {/if} + +
          + + {l s='Back Office'} + {foreach $tabs_breadcrumb AS $item} + > + {if isset($item.token)}{/if} + {$item.name} + {if isset($item.token)}{/if} + {/foreach} +
          + {if $is_multishop} +
          + {if $shop_context == 'group'} + {l s='You are configuring your store for group shop '}{$shop_name} + {elseif $shop_context == 'shop'} + {l s='You are configuring your store for shop '}{$shop_name} + {/if} +
          + {/if} diff --git a/admin-dev/themes/template/index.php b/admin-dev/themes/template/index.php new file mode 100644 index 000000000..dce6b30f5 --- /dev/null +++ b/admin-dev/themes/template/index.php @@ -0,0 +1,36 @@ + +* @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 +*/ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; \ No newline at end of file diff --git a/admin-dev/themes/template/invalid_token.tpl b/admin-dev/themes/template/invalid_token.tpl new file mode 100644 index 000000000..b4fdb930e --- /dev/null +++ b/admin-dev/themes/template/invalid_token.tpl @@ -0,0 +1,43 @@ +{* +* 2007-2011 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 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/afl-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 +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision$ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + + + + {l s='Invalid security token'} + + +
          + + {l s='Invalid security token'} +
          + + + + + + + + \ No newline at end of file diff --git a/classes/AdminController.php b/classes/AdminController.php new file mode 100644 index 000000000..d67694c51 --- /dev/null +++ b/classes/AdminController.php @@ -0,0 +1,453 @@ +id = Tab::getIdFromClassName($this->className); + $this->_conf = array( + 1 => $this->l('Deletion successful'), 2 => $this->l('Selection successfully deleted'), + 3 => $this->l('Creation successful'), 4 => $this->l('Update successful'), + 5 => $this->l('Status update successful'), 6 => $this->l('Settings update successful'), + 7 => $this->l('Image successfully deleted'), 8 => $this->l('Module downloaded successfully'), + 9 => $this->l('Thumbnails successfully regenerated'), 10 => $this->l('Message sent to the customer'), + 11 => $this->l('Comment added'), 12 => $this->l('Module installed successfully'), + 13 => $this->l('Module uninstalled successfully'), 14 => $this->l('Language successfully copied'), + 15 => $this->l('Translations successfully added'), 16 => $this->l('Module transplanted successfully to hook'), + 17 => $this->l('Module removed successfully from hook'), 18 => $this->l('Upload successful'), + 19 => $this->l('Duplication completed successfully'), 20 => $this->l('Translation added successfully but the language has not been created'), + 21 => $this->l('Module reset successfully'), 22 => $this->l('Module deleted successfully'), + 23 => $this->l('Localization pack imported successfully'), 24 => $this->l('Refund Successful'), + 25 => $this->l('Images successfully moved'), + ); + if (!$this->identifier) $this->identifier = 'id_'.$this->table; + if (!$this->_defaultOrderBy) $this->_defaultOrderBy = $this->identifier; + $className = get_class($this); + if ($className == 'AdminCategories' OR $className == 'AdminProducts') + $className = 'AdminCatalog'; + $this->token = Tools::getAdminToken($className.(int)$this->id.(int)$this->context->employee->id); + + if (!Shop::isMultiShopActivated()) + $this->shopLinkType = ''; + } + + /** + * Check rights to view the current tab + * + * @return boolean + */ + public function viewAccess($disable = false) + { + if ($disable) + return true; + $this->tabAccess = Profile::getProfileAccess($this->context->employee->id_profile, $this->id); + + if ($this->tabAccess['view'] === '1') + return true; + return false; + } + + /** + * Check for security token + */ + public function checkToken() + { + $token = Tools::getValue('token'); + return (!empty($token) AND $token === $this->token); + } + + public function run() + { + $this->checkAccess(); + $this->init(); + $this->postProcess(); + $this->setMedia(); + $this->initHeader(); + $this->initFooter(); + //$adminObj->displayConf(); + //$adminObj->displayErrors(); + $this->display(); + } + + /** + * Check if the token is valid, else display a warning page + */ + public function checkAccess() + { + if (!$this->checkToken()) + { + // If this is an XSS attempt, then we should only display a simple, secure page + // ${1} in the replacement string of the regexp is required, because the token may begin with a number and mix up with it (e.g. $17) + $url = preg_replace('/([&?]token=)[^&]*(&.*)?$/', '${1}'.$this->token.'$2', $_SERVER['REQUEST_URI']); + if (false === strpos($url, '?token=') AND false === strpos($url, '&token=')) + $url .= '&token='.$this->token; + + $this->context->smarty->assign('url', htmlentities($url)); + $this->context->smarty->display(_PS_ADMIN_DIR_.'/themes/invalid_token.tpl'); + die; + } + } + + public function display() + { + + } + + /** + * Assign smarty variables for the header + */ + public function initHeader() + { + // Shop context + if (Shop::isMultiShopActivated()) + { + if (Context::shop() == Shop::CONTEXT_ALL) + $shop_context = 'all'; + elseif (Context::shop() == Shop::CONTEXT_GROUP) + { + $shop_context = 'group'; + $shop_name = $this->context->shop->getGroup()->name; + } + else + { + $shop_context = 'shop'; + $shop_name = $this->context->shop->name; + } + $this->context->smarty->assign(array( + 'shop_name' => $shop_name, + 'shop_context' => $shop_context, + )); + $youEditFieldFor = sprintf($this->l('A modification of this field will be applied for the shop %s'), ''.Context::getContext()->shop->name.''); + } + + // Multishop + $is_multishop = Shop::isMultiShopActivated();// && Context::shop() != Shop::CONTEXT_ALL; + /*if ($is_multishop) + { + if (Context::shop() == Shop::CONTEXT_GROUP) + { + $shop_context = 'group'; + $shop_name = $this->context->shop->getGroup()->name; + } + elseif (Context::shop() == Shop::CONTEXT_SHOP) + { + $shop_context = 'shop'; + $shop_name = $this->context->shop->name; + }*/ + + + + // Quick access + $quick_access = QuickAccess::getQuickAccesses($this->context->language->id); + foreach ($quick_access AS $index => $quick) + { + preg_match('/tab=(.+)(&.+)?$/', $quick['link'], $adminTab); + if (isset($adminTab[1])) + { + if (strpos($adminTab[1], '&')) + $adminTab[1] = substr($adminTab[1], 0, strpos($adminTab[1], '&')); + $quick_access[$index]['link'] .= '&token='.Tools::getAdminToken($adminTab[1].(int)(Tab::getIdFromClassName($adminTab[1])).(int)($this->context->employee->id)); + } + } + + // Tab list + $tabs = Tab::getTabs($this->context->language->id, 0); + foreach ($tabs AS $index => $tab) + { + if (Tab::checkTabRights($tab['id_tab']) === true) + { + $img_exists_cache = Tools::file_exists_cache(_PS_ADMIN_DIR_.'/themes/'.$this->context->employee->bo_theme.'/img/t/'.$tab['class_name'].'.gif'); + $img = ($img_exists_cache ? 'themes/'.Context::getContext()->employee->bo_theme.'/img/' : _PS_IMG_).'t/'.$tab['class_name'].'.gif'; + + if (trim($tab['module']) != '') + $img = _MODULE_DIR_.$tab['module'].'/'.$tab['class_name'].'.gif'; + + $tabs[$index]['current'] = ($tab['class_name'] == $this->className) || (Tab::getCurrentParentId() == $tab['id_tab']); + $tabs[$index]['img'] = $img; + $tabs[$index]['token'] = Tools::getAdminToken($tab['class_name'].(int)($tab['id_tab']).(int)$this->context->employee->id); + + $sub_tabs = Tab::getTabs($this->context->language->id, $tab['id_tab']); + foreach ($sub_tabs AS $index2 => $sub_tab) + { + if (Tab::checkTabRights($sub_tab) === true) + { + $sub_tabs[$index2]['token'] = Tools::getAdminTokenLite($sub_tab['class_name']); + } + else + unset($sub_tabs[$index2]); + } + $tabs[$index]['sub_tabs'] = $sub_tabs; + } + else + unset($tabs[$index]); + } + // Breadcrumbs + $home_token = Tools::getAdminToken('AdminHome'.intval(Tab::getIdFromClassName('AdminHome')).(int)$this->context->employee->id); + + $tabs_breadcrumb = array(); + $tabs_breadcrumb = recursiveTab($this->id, $tabs_breadcrumb); + $tabs_breadcrumb = array_reverse($tabs_breadcrumb); + + foreach ($tabs_breadcrumb AS $key => $item) + for ($i = 0; $i < (count($tabs_breadcrumb) - 1); $i++) + $tabs_breadcrumb[$key]['token'] = Tools::getAdminToken($item['class_name'].intval($item['id_tab']).(int)$this->context->employee->id); + + /* Hooks are volontary out the initialize array (need those variables already assigned) */ + $this->context->smarty->assign(array( + 'img_dir' => _PS_IMG_, + 'iso' => $this->context->language->iso_code, + 'class_name' => $this->className, + 'iso_user' => $this->context->language->id, + 'country_iso_code' => $this->context->country->iso_code, + 'version' => _PS_VERSION_, + 'help_box' => Configuration::get('PS_HELPBOX'), + 'round_mode' => Configuration::get('PS_PRICE_ROUND_MODE'), + 'brightness' => Tools::getBrightness(empty($this->context->employee->bo_color) ? '#FFFFFF' : $this->context->employee->bo_color) < 128 ? 'white' : '#383838', + 'edit_field' => isset($youEditFieldFor) ? $youEditFieldFor : '\'\'', + 'lang_iso' => $this->context->language->iso_code, + 'link' => $this->context->link, + 'bo_color' => isset($this->context->employee->bo_color) ? Tools::htmlentitiesUTF8($this->context->employee->bo_color) : null, + 'shop_name' => Configuration::get('PS_SHOP_NAME'), + 'show_new_orders' => Configuration::get('PS_SHOW_NEW_ORDERS'), + 'show_new_customers' => Configuration::get('PS_SHOW_NEW_CUSTOMERS'), + 'show_new_messages' => Configuration::get('PS_SHOW_NEW_MESSAGES'), + 'token_admin_orders' => Tools::getAdminTokenLite('AdminOrders'), + 'token_admin_customers' => Tools::getAdminTokenLite('AdminCustomers'), + 'token_admin_employees' => Tools::getAdminTokenLite('AdminEmployees'), + 'token_admin_search' => Tools::getAdminTokenLite('AdminSearch'), + 'first_name' => Tools::substr($this->context->employee->firstname, 0, 1), + 'last_name' => htmlentities($this->context->employee->lastname, ENT_COMPAT, 'UTF-8'), + 'base_url' => $this->context->shop->getBaseURL(), + 'employee' => $this->context->employee, + 'search_type' => Tools::getValue('bo_search_type'), + 'bo_query' => Tools::safeOutput(Tools::stripslashes(Tools::getValue('bo_query'))), + 'quick_access' => $quick_access, + 'multi_shop' => Shop::isMultiShopActivated(), + 'shop_list' => (Shop::isMultiShopActivated() ? generateShopList() : null), //@TODO refacto + 'tab' => $tab, + 'current_parent_id' => (int)Tab::getCurrentParentId(), + 'tabs' => $tabs, + 'install_dir_exists' => file_exists(_PS_ADMIN_DIR_.'/../install'), + 'home_token' => $home_token, + 'tabs_breadcrumb' => $tabs_breadcrumb, + 'is_multishop' => $is_multishop, + + )); + $this->context->smarty->assign(array( + 'HOOK_HEADER' => Module::hookExec('backOfficeHeader'), + 'HOOK_TOP' => Module::hookExec('backOfficeTop'), + )); + + $this->context->smarty->assign('css_files', $this->css_files); + $this->context->smarty->assign('js_files', array_unique($this->js_files)); + //$this->context->smarty->display(_PS_ADMIN_DIR_.'/themes/header.tpl'); + } + + /** + * Assign smarty variables for the page main content + */ + public function initContent() + { + } + + /** + * Assign smarty variables for the footer + */ + public function initFooter() + { + $this->context->smarty->assign(array( + 'ps_version' => _PS_VERSION_, + 'end_time' => number_format(microtime(true) - $this->timerStart, 3, '.', ''), + 'iso_is_fr' => strtoupper($this->context->language->iso_code) == 'FR', + )); + + $this->context->smarty->assign(array( + 'HOOK_FOOTER' => Module::hookExec('backOfficeFooter'), + )); + } + + public function setMedia() + { + $this->addCSS(_PS_JS_DIR_.'jquery/datepicker/datepicker.css', 'all'); + $this->addCSS(_PS_CSS_DIR_.'admin.css', 'all'); + $this->addCSS(_PS_CSS_DIR_.'jquery.cluetip.css', 'all'); + + $this->addCSS($this->path.'/themes/'.'default/admin.css', 'all'); + if ($this->context->language->is_rtl) + $this->addCSS(_THEME_CSS_DIR_.'rtl.css'); + + $this->addJS(_PS_JS_DIR_.'jquery/jquery-1.4.4.min.js'); + $this->addJS(_PS_JS_DIR_.'jquery/jquery.hoverIntent.minified.js'); + $this->addJS(_PS_JS_DIR_.'jquery/jquery.cluetip.js'); + $this->addJS(_PS_JS_DIR_.'admin.js'); + $this->addJS(_PS_JS_DIR_.'toggle.js'); + $this->addJS(_PS_JS_DIR_.'tools.js'); + $this->addJS(_PS_JS_DIR_.'ajax.js'); + $this->addJS(_PS_JS_DIR_.'notifications.js'); + } + + public static function translate($string, $class, $addslashes = FALSE, $htmlentities = TRUE) + { + $class = strtolower($class); + // if the class is extended by a module, use modules/[module_name]/xx.php lang file + //$currentClass = get_class($this); + if(false AND Module::getModuleNameFromClass($class)) + { + $string = str_replace('\'', '\\\'', $string); + return Module::findTranslation(Module::$classInModule[$class], $string, $class); + } + global $_LANGADM; + $_LANGADM = array_change_key_case($_LANGADM); + + //if ($class == __CLASS__) + // $class = 'AdminTab'; + + $key = md5(str_replace('\'', '\\\'', $string)); + + $str = (key_exists($class.$key, $_LANGADM)) ? $_LANGADM[$class.$key] : ((key_exists($class.$key, $_LANGADM)) ? $_LANGADM[$class.$key] : $string); + $str = $htmlentities ? htmlentities($str, ENT_QUOTES, 'utf-8') : $str; + return str_replace('"', '"', ($addslashes ? addslashes($str) : stripslashes($str))); + } + /** + * use translations files to replace english expression. + * + * @param mixed $string term or expression in english + * @param string $class + * @param boolan $addslashes if set to true, the return value will pass through addslashes(). Otherwise, stripslashes(). + * @param boolean $htmlentities if set to true(default), the return value will pass through htmlentities($string, ENT_QUOTES, 'utf-8') + * @return string the translation if available, or the english default text. + */ + protected function l($string, $class = 'AdminTab', $addslashes = FALSE, $htmlentities = TRUE) + { + $class = get_class($this); + return self::translate($string, $class, $addslashes, $htmlentities); + } + + public function init() + { + ob_start(); + $this->timerStart = microtime(true); + + if (isset($_GET['logout'])) + $this->context->employee->logout(); + + if (!isset($this->context->employee) || !$this->context->employee->isLoggedBack()) + Tools::redirectAdmin('login.php?redirect='.$_SERVER['REQUEST_URI']); + + // Set current index + $currentIndex = $_SERVER['SCRIPT_NAME'].(($tab = Tools::getValue('tab')) ? '?tab='.$tab : ''); + if ($back = Tools::getValue('back')) + $currentIndex .= '&back='.urlencode($back); + AdminTab::$currentIndex = $currentIndex; + + $iso = $this->context->language->iso_code; + include(_PS_TRANSLATIONS_DIR_.$iso.'/errors.php'); + include(_PS_TRANSLATIONS_DIR_.$iso.'/fields.php'); + include(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php'); + + /* Server Params */ + $protocol_link = (Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://'; + $protocol_content = (isset($useSSL) AND $useSSL AND Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://'; + $link = new Link($protocol_link, $protocol_content); + $this->context->link = $link; + //define('_PS_BASE_URL_', Tools::getShopDomain(true)); + //define('_PS_BASE_URL_SSL_', Tools::getShopDomainSsl(true)); + + /*$path = _PS_ADMIN_DIR_.'/themes/'; + if (empty($this->context->employee->bo_theme) OR !file_exists($path.$this->context->employee->bo_theme.'/admin.css')) + { + if (file_exists($path.'oldschool/admin.css')) + $this->context->employee->bo_theme = 'oldschool'; + elseif (file_exists($path.'origins/admin.css')) + $this->context->employee->bo_theme = 'origins'; + else + foreach (scandir($path) as $theme) + if ($theme[0] != '.' AND file_exists($path.$theme.'/admin.css')) + { + $employee->bo_theme = $theme; + break; + } + $this->context->employee->update(); + }*/ + + // Change shop context ? + if (Shop::isMultiShopActivated() && Tools::getValue('setShopContext') !== false) + { + $this->context->cookie->shopContext = Tools::getValue('setShopContext'); + $url = parse_url($_SERVER['REQUEST_URI']); + $query = (isset($url['query'])) ? $url['query'] : ''; + parse_str($query, $parseQuery); + unset($parseQuery['setShopContext']); + Tools::redirectAdmin($url['path'] . '?' . http_build_query($parseQuery)); + } + + $shopID = ''; + if ($this->context->cookie->shopContext) + { + $split = explode('-', $this->context->cookie->shopContext); + if (count($split) == 2 && $split[0] == 's') + $shopID = (int)$split[1]; + } + $this->context->shop = new Shop($shopID); + + /* Filter memorization */ + if (isset($_POST) AND !empty($_POST) AND isset($this->table)) + foreach ($_POST AS $key => $value) + if (is_array($this->table)) + { + foreach ($this->table AS $table) + if (strncmp($key, $table.'Filter_', 7) === 0 OR strncmp($key, 'submitFilter', 12) === 0) + $this->context->cookie->$key = !is_array($value) ? $value : serialize($value); + } + elseif (strncmp($key, $this->table.'Filter_', 7) === 0 OR strncmp($key, 'submitFilter', 12) === 0) + $this->context->cookie->$key = !is_array($value) ? $value : serialize($value); + + if (isset($_GET) AND !empty($_GET) AND isset($this->table)) + foreach ($_GET AS $key => $value) + if (is_array($this->table)) + { + foreach ($this->table AS $table) + if (strncmp($key, $table.'OrderBy', 7) === 0 OR strncmp($key, $table.'Orderway', 8) === 0) + $this->context->cookie->$key = $value; + } + elseif (strncmp($key, $this->table.'OrderBy', 7) === 0 OR strncmp($key, $this->table.'Orderway', 12) === 0) + $this->context->cookie->$key = $value; + } + + public function displayErrors() + { + p($this->_errors); + } + + public function postProcess() + { + + } + +} \ No newline at end of file diff --git a/classes/Tab.php b/classes/Tab.php index 754f8cc2e..54099a978 100644 --- a/classes/Tab.php +++ b/classes/Tab.php @@ -240,4 +240,16 @@ class TabCore extends ObjectModel WHERE `id_tab` = '.(int)$result[$i]['id_tab']); return true; } + + public static function checkTabRights($id_tab) + { + static $tabAccesses = NULL; + + if ($tabAccesses === NULL) + $tabAccesses = Profile::getProfileAccesses(Context::getContext()->employee->id_profile); + + if (isset($tabAccesses[(int)($id_tab)]['view'])) + return ($tabAccesses[(int)($id_tab)]['view'] === '1'); + return false; +} } diff --git a/config/config.inc.php b/config/config.inc.php index 0cd4baf8d..aa89d9d38 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -102,14 +102,14 @@ Context::getContext()->country = $defaultCountry; /* Instantiate cookie */ $cookieLifetime = (time() + (((int)Configuration::get('PS_COOKIE_LIFETIME_BO') > 0 ? (int)Configuration::get('PS_COOKIE_LIFETIME_BO') : 1)* 3600)); -if (defined('PS_ADMIN_DIR')) +if (defined('_PS_ADMIN_DIR_')) $cookie = new Cookie('psAdmin', '', $cookieLifetime); else $cookie = new Cookie('ps', '', $cookieLifetime); Context::getContext()->cookie = $cookie; /* Create employee if in BO, customer else */ -if (defined('PS_ADMIN_DIR')) +if (defined('_PS_ADMIN_DIR_')) { $employee = new Employee($cookie->id_employee); Context::getContext()->employee = $employee; @@ -123,9 +123,9 @@ else $customer = new Customer($cookie->id_customer); $customer->logged = $cookie->logged; } - else + else $customer = new Customer(); - + $customer->id_guest = $cookie->id_guest; Context::getContext()->customer = $customer; } @@ -158,7 +158,11 @@ if (function_exists('date_default_timezone_set')) @date_default_timezone_set(Configuration::get('PS_TIMEZONE')); /* Smarty */ -require_once(dirname(__FILE__).'/smarty.config.inc.php'); +if (!defined('_PS_ADMIN_DIR_')) + require_once(dirname(__FILE__).'/smarty.config.inc.php'); +else + require_once(dirname(__FILE__).'/smartyadmin.config.inc.php'); + Context::getContext()->smarty = $smarty; /* Possible value are true, false, 'URL' (for 'URL' append SMARTY_DEBUG as a parameter to the url) diff --git a/config/smartyadmin.config.inc.php b/config/smartyadmin.config.inc.php new file mode 100644 index 000000000..c7ede54b5 --- /dev/null +++ b/config/smartyadmin.config.inc.php @@ -0,0 +1,150 @@ + +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 6844 $ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ +define('_PS_SMARTY_DIR_', _PS_TOOL_DIR_.'smarty/'); + +require_once(_PS_SMARTY_DIR_.'Smarty.class.php'); + +global $smarty; +$smarty = new Smarty(); +$smarty->template_dir = _PS_ADMIN_DIR_.'/themes/template'; +$smarty->compile_dir = _PS_SMARTY_DIR_.'admincompile'; +$smarty->cache_dir = _PS_SMARTY_DIR_.'admincache'; +$smarty->caching = false; +$smarty->force_compile = (Configuration::get('PS_SMARTY_FORCE_COMPILE') == _PS_SMARTY_FORCE_COMPILE_) ? true : false; +$smarty->compile_check = (Configuration::get('PS_SMARTY_FORCE_COMPILE') == _PS_SMARTY_CHECK_COMPILE_) ? true : false; +$smarty->debugging = false; +$smarty->debugging_ctrl = 'URL'; // 'NONE' on production +$smarty->deprecation_notices = false; // so many depreciated yet not migrated smarty calls + +if (Configuration::get('PS_HTML_THEME_COMPRESSION')) + $smarty->registerFilter('output', 'smartyMinifyHTML'); +if (Configuration::get('PS_JS_HTML_THEME_COMPRESSION')) + $smarty->registerFilter('output', 'smartyPackJSinHTML'); + +smartyRegisterFunction($smarty, 'modifier', 'truncate', 'smarty_modifier_truncate'); +smartyRegisterFunction($smarty, 'modifier', 'secureReferrer', array('Tools', 'secureReferrer')); + +smartyRegisterFunction($smarty, 'function', 't', 'smartyTruncate'); // unused +smartyRegisterFunction($smarty, 'function', 'm', 'smartyMaxWords'); // unused +smartyRegisterFunction($smarty, 'function', 'p', 'smartyShowObject'); // Debug only +smartyRegisterFunction($smarty, 'function', 'd', 'smartyDieObject'); // Debug only +smartyRegisterFunction($smarty, 'function', 'l', 'smartyTranslate'); + +smartyRegisterFunction($smarty, 'function', 'dateFormat', array('Tools', 'dateFormat')); +smartyRegisterFunction($smarty, 'function', 'convertPrice', array('Product', 'convertPrice')); +smartyRegisterFunction($smarty, 'function', 'convertPriceWithCurrency', array('Product', 'convertPriceWithCurrency')); +smartyRegisterFunction($smarty, 'function', 'displayWtPrice', array('Product', 'displayWtPrice')); +smartyRegisterFunction($smarty, 'function', 'displayWtPriceWithCurrency', array('Product', 'displayWtPriceWithCurrency')); +smartyRegisterFunction($smarty, 'function', 'displayPrice', array('Tools', 'displayPriceSmarty')); +smartyRegisterFunction($smarty, 'modifier', 'convertAndFormatPrice', array('Product', 'convertAndFormatPrice')); // used twice + +function smartyTranslate($params, &$smarty) +{ + global $_LANGADM; + $htmlentities = !isset($params['js']); + $addslashes = !isset($params['slashes']); + + $string = str_replace('\'', '\\\'', $params['s']); + $filename = ((!isset($smarty->compiler_object) OR !is_object($smarty->compiler_object->template)) ? $smarty->template_filepath : $smarty->compiler_object->template->getTemplateFilepath()); + $class = Tools::substr(basename($filename), 0, -4);//.'_'.md5($string); + + if(in_array($class, array('header','footer','password','login'))) + $class = 'index'; + + return AdminController::translate($string, $class, $addslashes, $htmlentities); +} + +function smartyDieObject($params, &$smarty) +{ + return Tools::d($params['var']); +} + +function smartyShowObject($params, &$smarty) +{ + return Tools::p($params['var']); +} + +function smartyMaxWords($params, &$smarty) +{ + Tools::displayAsDeprecated(); + $params['s'] = str_replace('...', ' ...', html_entity_decode($params['s'], ENT_QUOTES, 'UTF-8')); + $words = explode(' ', $params['s']); + + foreach($words AS &$word) + if(Tools::strlen($word) > $params['n']) + $word = Tools::substr(trim(chunk_split($word, $params['n']-1, '- ')), 0, -1); + + return implode(' ', Tools::htmlentitiesUTF8($words)); +} + +function smartyTruncate($params, &$smarty) +{ + Tools::displayAsDeprecated(); + $text = isset($params['strip']) ? strip_tags($params['text']) : $params['text']; + $length = $params['length']; + $sep = isset($params['sep']) ? $params['sep'] : '...'; + + if (Tools::strlen($text) > $length + Tools::strlen($sep)) + $text = Tools::substr($text, 0, $length).$sep; + + return (isset($params['encode']) ? Tools::htmlentitiesUTF8($text, ENT_NOQUOTES) : $text); +} + +function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false, $charset = 'UTF-8') +{ + if (!$length) + return ''; + + if (Tools::strlen($string) > $length) + { + $length -= min($length, Tools::strlen($etc)); + if (!$break_words && !$middle) + $string = preg_replace('/\s+?(\S+)?$/u', '', Tools::substr($string, 0, $length+1, $charset)); + return !$middle ? Tools::substr($string, 0, $length, $charset).$etc : Tools::substr($string, 0, $length/2, $charset).$etc.Tools::substr($string, -$length/2, $charset); + } + else + return $string; +} + +function smartyMinifyHTML($tpl_output, &$smarty) +{ + $tpl_output = Tools::minifyHTML($tpl_output); + return $tpl_output; +} + +function smartyPackJSinHTML($tpl_output, &$smarty) +{ + $tpl_output = Tools::packJSinHTML($tpl_output); + return $tpl_output; +} + +function smartyRegisterFunction($smarty, $type, $function, $params) +{ + if (!in_array($type, array('function', 'modifier'))) + return false; + $smarty->registerPlugin($type, $function, $params); +} diff --git a/js/notifications.js b/js/notifications.js new file mode 100644 index 000000000..304d1c232 --- /dev/null +++ b/js/notifications.js @@ -0,0 +1,105 @@ +function getPush() +{ + $.post("ajax.php",{"getNotifications" : "1"}, function(data) { + if (data) + { + json = jQuery.parseJSON(data); + + // Add orders notifications to the list + html = ""; + nb_notifs = 0; + $.each(json.order, function(property, value) { + html += "
        • " + new_order_msg + "
          " + order_number_msg + "#" + parseInt(value.id_order) + "
          " + total_msg + "" + value.total_paid_real + "
          " + from_msg + "" + value.customer_name + "
          " + see_order_msg + "
        • "; + }); + if (html != "") + { + $("#list_orders_notif").prev("p").hide(); + $("#list_orders_notif").empty().append(html); + nb_notifs = $("#list_orders_notif li").length; + $("#orders_notif_value").text(nb_notifs); + $("#orders_notif_number_wrapper").show(); + } + else + { + $("#orders_notif_number_wrapper").hide(); + } + + // Add customers notifications to the list + html = ""; + nb_notifs = 0; + $.each(json.customer, function(property, value) { + html += "
        • " + new_customer_msg + "
          " + customer_name_msg + "" + value.customer_name + "
          " + see_customer_msg + "
        • "; + }); + if (html != "") + { + $("#list_customers_notif").prev("p").hide(); + $("#list_customers_notif").empty().append(html); + nb_notifs = $("#list_customers_notif li").length; + $("#customers_notif_value").text(nb_notifs); + $("#customers_notif_number_wrapper").show(); + } + else + { + $("#customers_notif_number_wrapper").hide(); + } + + // Add messages notifications to the list + html = ""; + nb_notifs = 0; + $.each(json.message, function(property, value) { + html += "
        • " + new_msg + "
          " + from_msg + "" + value.customer_name + "
          " + excerpt_msg + "" + value.message_customer + "
          " + see_msg + "
        • "; + }); + if (html != "") + { + $("#list_messages_notif").prev("p").hide(); + $("#list_messages_notif").empty().append(html); + nb_notifs = $("#list_messages_notif li").length; + $("#messages_notif_value").text(nb_notifs); + $("#messages_notif_number_wrapper").show(); + } + else + { + $("#messages_notif_number_wrapper").hide(); + } + } + setTimeout("getPush()",60000); + }); +} + +$().ready(function() +{ + var hints = $('.translatable span.hint'); + if (youEditFieldFor) + { + hints.html(hints.html() + '
          ' + youEditFieldFor + ''); + } + var html = ""; + var nb_notifs = 0; + var wrapper_id = ""; + var type = new Array(); + + $(".notifs").live("click", function(){ + wrapper_id = $(this).attr("id"); + type = wrapper_id.split("s_notif") + $.post("ajax.php",{"updateElementEmployee" : "1", "updateElementEmployeeType" : type[0]}, function(data) { + if(data) + { + if(!$("#" + wrapper_id + "_wrapper").is(":visible")) + { + $(".notifs_wrapper").hide(); + $("#" + wrapper_id + "_number_wrapper").hide(); + $("#" + wrapper_id + "_wrapper").show(); + }else + { + $("#" + wrapper_id + "_wrapper").hide(); + } + } + }); + }); + + $("#main").click(function(){ + $(".notifs_wrapper").hide(); + }); + + getPush(); +}); \ No newline at end of file