Commit dbf32eb4 authored by Cédric Houbart's avatar Cédric Houbart
Browse files

Migrated global constants to a dedicated class to fix wordpress modules

parent 11780b1f
......@@ -21,15 +21,16 @@
// API is the entry point for all API calls.
namespace Pasteque;
const ABSPATH = __DIR__; // Base path. Also to check if a call
require_once(__DIR__ . "/inc/constants.php");
PT::$ABSPATH = __DIR__; // Base path. Also to check if a call
// originates from api.php
// Load
require_once(ABSPATH . "/inc/load.php");
require_once(ABSPATH . "/inc/load_api.php");
require_once(PT::$ABSPATH . "/inc/load.php");
require_once(PT::$ABSPATH . "/inc/load_api.php");
if (isset($_GET[URL_ACTION_PARAM])) {
$api = $_GET[URL_ACTION_PARAM];
if (isset($_GET[PT::URL_ACTION_PARAM])) {
$api = $_GET[PT::URL_ACTION_PARAM];
$params = $_GET;
if (isset($_GET['action'])) {
$action = $_GET['action'];
......@@ -37,8 +38,8 @@ if (isset($_GET[URL_ACTION_PARAM])) {
$action = null;
}
} else {
if (isset($_POST[URL_ACTION_PARAM])) {
$api = $_POST[URL_ACTION_PARAM];
if (isset($_POST[PT::URL_ACTION_PARAM])) {
$api = $_POST[PT::URL_ACTION_PARAM];
$params = $_POST;
if (isset($_POST['action'])) {
$action = $_POST['action'];
......
......@@ -19,7 +19,7 @@
// along with Pastèque. If not, see <http://www.gnu.org/licenses/>.
namespace WordPressDB {
require_once(COREPATH . "/tools/wp_preprocessing.php");
require_once(\Pasteque\PT::$ABSPATH . "/core_modules/tools/wp_preprocessing.php");
require_once(dirname(__FILE__) . "/config.php");
\WordPress\loadWP($config['wordpress_base_path']);
$data = NULL;
......
......@@ -19,7 +19,8 @@
// along with Pastèque. If not, see <http://www.gnu.org/licenses/>.
namespace WordPressID {
require_once(COREPATH . "/tools/wp_preprocessing.php");
require_once(\Pasteque\PT::$ABSPATH . "/core_modules/tools/wp_preprocessing.php");
require_once(dirname(__FILE__) . "/config.php");
\WordPress\loadWP($config['wordpress_base_path']);
$api_user = NULL;
......
......@@ -21,7 +21,7 @@
namespace Pasteque;
function generate_barcode($type, $data) {
require_once(ABSPATH . "/lib/barcode-master/php-barcode.php");
require_once(PT::$ABSPATH . "/lib/barcode-master/php-barcode.php");
$font = "./lib/barcode-master/NOTTB___.TTF";
$fontSize = 10; // GD1 in px ; GD2 in point
$marge = 2; // between barcode and hri in pixel
......@@ -60,7 +60,7 @@ case 'product':
if ($prd->hasImage !== false) {
echo ProductsService::getImage($prd->id);
} else {
echo file_get_contents(ABSPATH . "/templates/" . $config['template'] . "/img/default_product.png");
echo file_get_contents(PT::$ABSPATH . "/templates/" . $config['template'] . "/img/default_product.png");
}
break;
case 'category':
......@@ -68,7 +68,7 @@ case 'category':
if ($cat->hasImage !== false) {
echo CategoriesService::getImage($cat->id);
} else {
echo file_get_contents(ABSPATH . "/templates/" . $config['template'] . "/img/default_category.png");
echo file_get_contents(PT::$ABSPATH . "/templates/" . $config['template'] . "/img/default_category.png");
}
break;
case 'resource':
......@@ -86,7 +86,7 @@ case 'custcard':
case 'js':
$file = $_GET['id'];
$file = str_replace("..", ".", $file);
require_once(ABSPATH . "/templates/" . $config['template'] . "/" . $file);
require_once(PT::$ABSPATH . "/templates/" . $config['template'] . "/" . $file);
break;
}
?>
......@@ -54,7 +54,7 @@ class Installer {
$uid = get_user_id();
$type = get_db_type($uid);
$pdo = PDOBuilder::getPDO();
$file = ABSPATH . "/install/database/" . $type . "/create.sql";
$file = PT::$ABSPATH . "/install/database/" . $type . "/create.sql";
if (!\file_exists($file)) {
return false;
}
......@@ -64,7 +64,7 @@ class Installer {
}
// Load country data
if ($country !== null) {
$cfile = ABSPATH . "/install/database/" . $type
$cfile = PT::$ABSPATH . "/install/database/" . $type
. "/data_" . $country . ".sql";
$fileContent = \file_get_contents($cfile);
Installer::loadFile($pdo, $fileContent, $type);
......@@ -77,16 +77,16 @@ class Installer {
if ($version === null) {
$version = Installer::getVersion();
}
while ($version != DB_VERSION) {
while ($version != PT::DB_LEVEL) {
$uid = get_user_id();
$type = get_db_type($uid);
$pdo = PDOBuilder::getPDO();
// Load generic sql update for current version
$file = ABSPATH . "/install/database/" . $type
$file = PT::$ABSPATH . "/install/database/" . $type
. "/upgrade-" . $version . ".sql";
$pdo->query(\file_get_contents($file));
// Check for localized update data for current version
$file = ABSPATH . "/install/database/" . $type
$file = PT::$ABSPATH . "/install/database/" . $type
. "upgrade-" . $version . "_" . $country . ".sql";
if (\file_exists($file)) {
$pdo->query(\file_get_contents($file));
......@@ -114,9 +114,9 @@ class Installer {
$dbVer = Installer::getVersion();
}
if ($dbVer !== null) {
if (intval($dbVer) < intval(DB_VERSION)) {
if (intval($dbVer) < intval(PT::DB_LEVEL)) {
return Installer::NEED_DB_UPGRADE;
} else if (intval($dbVer) > intval(DB_VERSION)) {
} else if (intval($dbVer) > intval(PT::DB_LEVEL)) {
return Installer::NEED_DB_DOWNGRADE;
} else {
return Installer::OK;
......
......@@ -39,12 +39,12 @@ class APIBroker {
if ($this->api === null || $this->api == ""
|| strpos("..", $this->api) !== false
|| strpos("/", $this->api) !== false
|| !file_exists(ABSPATH . "/inc/data/api/"
|| !file_exists(PT::$ABSPATH . "/inc/data/api/"
. $this->api . ".php")) {
return APIResult::reject(APIError::$REJ_WRONG_API);
}
// Run the api
require_once(ABSPATH . "/inc/data/api/" . $this->api . ".php");
require_once(PT::$ABSPATH . "/inc/data/api/" . $this->api . ".php");
$apiClass = new \ReflectionClass("\\Pasteque\\" . $this->api);
$api = $apiClass->newInstance($action, $input);
$api->run();
......
......@@ -51,7 +51,7 @@ function init_catalog($jsName, $containerId, $selectCallback,
$prd = '{' . jsonify("id", $product->id) . ', '
. jsonify("label", $product->label) . ', '
. jsonify("reference", $product->reference) . ', '
. jsonify("img", "?" . URL_ACTION_PARAM . "=img&w=product&id=" . $product->id) . ', '
. jsonify("img", "?" . PT::URL_ACTION_PARAM . "=img&w=product&id=" . $product->id) . ', '
. jsonify("buy", $product->priceBuy) . ', '
. jsonify("sell", $product->priceSell) . ', '
. jsonify("vatSell", $vatPrice)
......
......@@ -20,8 +20,11 @@
namespace Pasteque;
const DB_VERSION = "4";
const VERSION = "1.0 beta 1";
class PT {
public static $ABSPATH;
const DB_LEVEL = "4";
const VERSION = "1.0 beta 1";
const URL_ACTION_PARAM = "p";
const URL_REPORT_PARAM = "r";
\ No newline at end of file
const URL_ACTION_PARAM = "p";
const URL_REPORT_PARAM = "r";
}
\ No newline at end of file
......@@ -27,8 +27,8 @@ class VersionAPI extends APIService {
}
protected function proceed() {
$ret = new \StdClass();
$ret->version = VERSION;
$ret->level = DB_VERSION;
$ret->version = PT::VERSION;
$ret->level = PT::DB_LEVEL;
$this->succeed($ret);
}
}
......
......@@ -141,15 +141,15 @@ $i18n_modules = array();
/** Load generic i18n files */
function load_base_i18n($language = NULL) {
global $I18N;
$I18N->loadFile(ABSPATH . "/languages/default.locale");
$I18N->loadFile(PT::$ABSPATH . "/languages/default.locale");
if ($language !== NULL) {
$base_i18n = ABSPATH . "/languages/" . $language . ".locale";
$base_i18n = PT::$ABSPATH . "/languages/" . $language . ".locale";
if (file_exists($base_i18n) && is_readable($base_i18n)) {
$I18N->loadFile($base_i18n);
} else if (strpos($language, "-") !== FALSE) {
// Check parent language
$parent = substr($language, 0, 2);
$file = ABSPATH . "/languages/" . $parent . ".locale";
$file = PT::$ABSPATH . "/languages/" . $parent . ".locale";
if (file_exists($file) && is_readable($file)) {
$I18N->loadFile($file);
}
......@@ -163,7 +163,7 @@ function load_modules_i18n($language = NULL) {
global $i18n_modules;
global $I18N;
foreach ($i18n_modules as $module) {
$file = ABSPATH . "/modules/" . $module . "/languages/default.locale";
$file = PT::$ABSPATH . "/modules/" . $module . "/languages/default.locale";
if (file_exists($file) && is_readable($file)) {
$I18N->loadModuleFile($module, $file);
}
......@@ -171,14 +171,14 @@ function load_modules_i18n($language = NULL) {
// Override with requested language
if ($language !== NULL) {
foreach ($i18n_modules as $module) {
$file = ABSPATH . "/modules/" . $module . "/languages/"
$file = PT::$ABSPATH . "/modules/" . $module . "/languages/"
. $language . ".locale";
if (file_exists($file) && is_readable($file)) {
$I18N->loadModuleFile($module, $file);
} else if (strpos($language, "-") !== FALSE) {
// Check parent language
$parent = substr($language, 0, 2);
$file = ABSPATH . "/modules/" . $module . "/languages/"
$file = PT::$ABSPATH . "/modules/" . $module . "/languages/"
. $parent . ".locale";
if (file_exists($file) && is_readable($file)) {
$I18N->loadModuleFile($module, $file);
......
......@@ -19,7 +19,6 @@
// along with Pastèque. If not, see <http://www.gnu.org/licenses/>.
namespace Pasteque;
define('COREPATH', ABSPATH . "/core_modules");
/** Check a core module readability. Returns the module file to import if
* success. Die on error.
......@@ -31,7 +30,7 @@ function _check_core_module($type) {
die();
}
$name = $config["core_$type"];
$file = ABSPATH . "/core_modules/$type/" . $name . "/module.php";
$file = PT::$ABSPATH . "/core_modules/$type/" . $name . "/module.php";
if (!file_exists($file)) {
echo("$name module not found");
die();
......@@ -39,13 +38,11 @@ function _check_core_module($type) {
return $file;
}
// Load constants
require_once(ABSPATH . "/inc/constants.php");
// Load configuration file
if (isset($altConfigFile)) {
define("CFG_FILE", ABSPATH . "/" . $altConfigFile);
define("CFG_FILE", PT::$ABSPATH . "/" . $altConfigFile);
} else {
define ("CFG_FILE", ABSPATH . "/config.php");
define ("CFG_FILE", PT::$ABSPATH . "/config.php");
}
if (!file_exists(CFG_FILE) || !is_readable(CFG_FILE)) {
echo("No config file");
......@@ -54,17 +51,17 @@ if (!file_exists(CFG_FILE) || !is_readable(CFG_FILE)) {
require_once(CFG_FILE);
// Load static tools
require_once(ABSPATH . "/inc/date_utils.php");
require_once(ABSPATH . "/inc/url_broker.php");
require_once(ABSPATH . "/inc/i18n.php");
require_once(ABSPATH . "/inc/i18n_aliases.php");
require_once(ABSPATH . "/inc/Menu.php");
require_once(ABSPATH . "/inc/Report.php");
require_once(ABSPATH . "/inc/hooks.php");
require_once(ABSPATH . "/inc/forms.php");
require_once(ABSPATH . "/inc/PDOBuilder.php");
require_once(ABSPATH . "/inc/DB.php");
require_once(ABSPATH . "/inc/Installer.php");
require_once(PT::$ABSPATH . "/inc/date_utils.php");
require_once(PT::$ABSPATH . "/inc/url_broker.php");
require_once(PT::$ABSPATH . "/inc/i18n.php");
require_once(PT::$ABSPATH . "/inc/i18n_aliases.php");
require_once(PT::$ABSPATH . "/inc/Menu.php");
require_once(PT::$ABSPATH . "/inc/Report.php");
require_once(PT::$ABSPATH . "/inc/hooks.php");
require_once(PT::$ABSPATH . "/inc/forms.php");
require_once(PT::$ABSPATH . "/inc/PDOBuilder.php");
require_once(PT::$ABSPATH . "/inc/DB.php");
require_once(PT::$ABSPATH . "/inc/Installer.php");
// Load core modules
require_once(_check_core_module('ident'));
......@@ -72,49 +69,49 @@ require_once(_check_core_module('database'));
require_once(_check_core_module('modules'));
// Load data
require_once(ABSPATH . "/inc/data/models/Attribute.php");
require_once(ABSPATH . "/inc/data/models/Cash.php");
require_once(ABSPATH . "/inc/data/models/ZTicket.php");
require_once(ABSPATH . "/inc/data/models/Category.php");
require_once(ABSPATH . "/inc/data/models/Floor.php");
require_once(ABSPATH . "/inc/data/models/Payment.php");
require_once(ABSPATH . "/inc/data/models/Place.php");
require_once(ABSPATH . "/inc/data/models/Product.php");
require_once(ABSPATH . "/inc/data/models/Composition.php");
require_once(ABSPATH . "/inc/data/models/TariffArea.php");
require_once(ABSPATH . "/inc/data/models/Tax.php");
require_once(ABSPATH . "/inc/data/models/TaxAmount.php");
require_once(ABSPATH . "/inc/data/models/TaxCat.php");
require_once(ABSPATH . "/inc/data/models/Ticket.php");
require_once(ABSPATH . "/inc/data/models/TicketLine.php");
require_once(ABSPATH . "/inc/data/models/Customer.php");
require_once(ABSPATH . "/inc/data/models/CustTaxCat.php");
require_once(ABSPATH . "/inc/data/models/User.php");
require_once(ABSPATH . "/inc/data/models/Role.php");
require_once(ABSPATH . "/inc/data/models/Location.php");
require_once(ABSPATH . "/inc/data/models/Stock.php");
require_once(ABSPATH . "/inc/data/models/Resource.php");
require_once(ABSPATH . "/inc/data/models/Currency.php");
require_once(ABSPATH . "/inc/data/services/AbstractService.php");
require_once(ABSPATH . "/inc/data/services/AttributesService.php");
require_once(ABSPATH . "/inc/data/services/CashesService.php");
require_once(ABSPATH . "/inc/data/services/CategoriesService.php");
require_once(ABSPATH . "/inc/data/services/PlacesService.php");
require_once(ABSPATH . "/inc/data/services/ProductsService.php");
require_once(ABSPATH . "/inc/data/services/CompositionsService.php");
require_once(ABSPATH . "/inc/data/services/TariffAreasService.php");
require_once(ABSPATH . "/inc/data/services/TaxesService.php");
require_once(ABSPATH . "/inc/data/services/TicketsService.php");
require_once(ABSPATH . "/inc/data/services/CustomersService.php");
require_once(ABSPATH . "/inc/data/services/CustTaxCatsService.php");
require_once(ABSPATH . "/inc/data/services/UsersService.php");
require_once(ABSPATH . "/inc/data/services/RolesService.php");
require_once(ABSPATH . "/inc/data/services/LocationsService.php");
require_once(ABSPATH . "/inc/data/services/StocksService.php");
require_once(ABSPATH . "/inc/data/services/ResourcesService.php");
require_once(ABSPATH . "/inc/data/services/CurrenciesService.php");
require_once(ABSPATH . "/inc/Csv.php");
require_once(ABSPATH . "/inc/catalog.php");
require_once(PT::$ABSPATH . "/inc/data/models/Attribute.php");
require_once(PT::$ABSPATH . "/inc/data/models/Cash.php");
require_once(PT::$ABSPATH . "/inc/data/models/ZTicket.php");
require_once(PT::$ABSPATH . "/inc/data/models/Category.php");
require_once(PT::$ABSPATH . "/inc/data/models/Floor.php");
require_once(PT::$ABSPATH . "/inc/data/models/Payment.php");
require_once(PT::$ABSPATH . "/inc/data/models/Place.php");
require_once(PT::$ABSPATH . "/inc/data/models/Product.php");
require_once(PT::$ABSPATH . "/inc/data/models/Composition.php");
require_once(PT::$ABSPATH . "/inc/data/models/TariffArea.php");
require_once(PT::$ABSPATH . "/inc/data/models/Tax.php");
require_once(PT::$ABSPATH . "/inc/data/models/TaxAmount.php");
require_once(PT::$ABSPATH . "/inc/data/models/TaxCat.php");
require_once(PT::$ABSPATH . "/inc/data/models/Ticket.php");
require_once(PT::$ABSPATH . "/inc/data/models/TicketLine.php");
require_once(PT::$ABSPATH . "/inc/data/models/Customer.php");
require_once(PT::$ABSPATH . "/inc/data/models/CustTaxCat.php");
require_once(PT::$ABSPATH . "/inc/data/models/User.php");
require_once(PT::$ABSPATH . "/inc/data/models/Role.php");
require_once(PT::$ABSPATH . "/inc/data/models/Location.php");
require_once(PT::$ABSPATH . "/inc/data/models/Stock.php");
require_once(PT::$ABSPATH . "/inc/data/models/Resource.php");
require_once(PT::$ABSPATH . "/inc/data/models/Currency.php");
require_once(PT::$ABSPATH . "/inc/data/services/AbstractService.php");
require_once(PT::$ABSPATH . "/inc/data/services/AttributesService.php");
require_once(PT::$ABSPATH . "/inc/data/services/CashesService.php");
require_once(PT::$ABSPATH . "/inc/data/services/CategoriesService.php");
require_once(PT::$ABSPATH . "/inc/data/services/PlacesService.php");
require_once(PT::$ABSPATH . "/inc/data/services/ProductsService.php");
require_once(PT::$ABSPATH . "/inc/data/services/CompositionsService.php");
require_once(PT::$ABSPATH . "/inc/data/services/TariffAreasService.php");
require_once(PT::$ABSPATH . "/inc/data/services/TaxesService.php");
require_once(PT::$ABSPATH . "/inc/data/services/TicketsService.php");
require_once(PT::$ABSPATH . "/inc/data/services/CustomersService.php");
require_once(PT::$ABSPATH . "/inc/data/services/CustTaxCatsService.php");
require_once(PT::$ABSPATH . "/inc/data/services/UsersService.php");
require_once(PT::$ABSPATH . "/inc/data/services/RolesService.php");
require_once(PT::$ABSPATH . "/inc/data/services/LocationsService.php");
require_once(PT::$ABSPATH . "/inc/data/services/StocksService.php");
require_once(PT::$ABSPATH . "/inc/data/services/ResourcesService.php");
require_once(PT::$ABSPATH . "/inc/data/services/CurrenciesService.php");
require_once(PT::$ABSPATH . "/inc/Csv.php");
require_once(PT::$ABSPATH . "/inc/catalog.php");
load_base_i18n(detect_preferred_language());
......
......@@ -20,8 +20,8 @@
namespace Pasteque;
require_once(ABSPATH . "/inc/api/APIResult.php");
require_once(ABSPATH . "/inc/api/APIService.php");
require_once(ABSPATH . "/inc/api/APIBroker.php");
require_once(PT::$ABSPATH . "/inc/api/APIResult.php");
require_once(PT::$ABSPATH . "/inc/api/APIService.php");
require_once(PT::$ABSPATH . "/inc/api/APIBroker.php");
?>
......@@ -24,7 +24,7 @@ namespace Pasteque;
if(!isset($config['template'])) {
die("No template given");
}
$tmpl_file = ABSPATH . "/templates/" . $config['template'] . "/module.php";
$tmpl_file = PT::$ABSPATH . "/templates/" . $config['template'] . "/module.php";
if (!file_exists($tmpl_file) || !is_readable($tmpl_file)) {
die("Template not found");
}
......@@ -32,7 +32,7 @@ require_once($tmpl_file);
// Load modules
$modules = get_loaded_modules(get_user_id());
foreach ($modules as $module) {
$module_file = ABSPATH . "/modules/" . $module . "/module.php";
$module_file = PT::$ABSPATH . "/modules/" . $module . "/module.php";
if (file_exists($module_file)) {
require_once($module_file);
}
......
......@@ -22,32 +22,32 @@ namespace Pasteque;
/** Redirect page content to an action */
function redirectAction($path) {
if (!file_exists(ABSPATH . "/" . $path . ".php")) {
if (!file_exists(PT::$ABSPATH . "/" . $path . ".php")) {
tpl_404();
return;
}
require_once(ABSPATH . "/" . $path . ".php");
require_once(PT::$ABSPATH . "/" . $path . ".php");
}
function redirect_report($module, $name) {
if (!file_exists(ABSPATH . "/modules/" . $module . "/reports/" . $name . ".php")) {
if (!file_exists(PT::$ABSPATH . "/modules/" . $module . "/reports/" . $name . ".php")) {
$ret = array("error" => "No such seport");
echo json_encode($ret);
return;
}
require_once(ABSPATH . "/modules/" . $module . "/reports/" . $name . ".php");
require_once(PT::$ABSPATH . "/modules/" . $module . "/reports/" . $name . ".php");
}
/** Redirect page to the given one in url */
function url_content() {
if (!isset($_GET[URL_ACTION_PARAM]) && !isset($_GET[URL_REPORT_PARAM])) {
if (!isset($_GET[PT::URL_ACTION_PARAM]) && !isset($_GET[PT::URL_REPORT_PARAM])) {
$action = "home";
} else if (isset($_GET[URL_ACTION_PARAM])) {
$action = $_GET[URL_ACTION_PARAM];
} else if (isset($_GET[PT::URL_ACTION_PARAM])) {
$action = $_GET[PT::URL_ACTION_PARAM];
$action = str_replace("..", "", $action);
redirectAction($action);
} else if (isset($_GET[URL_REPORT_PARAM])) {
$report = $_GET[URL_REPORT_PARAM];
} else if (isset($_GET[PT::URL_REPORT_PARAM])) {
$report = $_GET[PT::URL_REPORT_PARAM];
$report = str_replace("..", "", $report);
redirectReport($report);
}
......@@ -57,23 +57,23 @@ function report_content($module, $name) {
redirect_report($module, $name);
}
function print_content($module, $name) {
if (!file_exists(ABSPATH . "/modules/" . $module . "/print/" . $name . ".php")) {
if (!file_exists(PT::$ABSPATH . "/modules/" . $module . "/print/" . $name . ".php")) {
$ret = array("error" => "No such print");
echo json_encode($ret);
return;
}
require_once(ABSPATH . "/modules/" . $module . "/print/" . $name . ".php");
require_once(PT::$ABSPATH . "/modules/" . $module . "/print/" . $name . ".php");
}
function get_url_action($action) {
return "./?" . URL_ACTION_PARAM . "=" . $action;
return "./?" . PT::URL_ACTION_PARAM . "=" . $action;
}
function get_url_report($report) {
return "./?" . URL_REPORT_PARAM . "=" . $report;
return "./?" . PT::URL_REPORT_PARAM . "=" . $report;
}
function get_module_url_action($module, $action, $params = array()) {
$url = "./?" . URL_ACTION_PARAM . "=" . get_module_action($module, $action);
$url = "./?" . PT::URL_ACTION_PARAM . "=" . get_module_action($module, $action);
foreach ($params as $key => $value) {
$url .= "&" . $key . "=" . $value;
}
......@@ -97,7 +97,7 @@ function get_module_report($module, $report) {
}
function get_report_url($module, $report_name, $type = "csv") {
return "./?" . URL_ACTION_PARAM . "=report&w=" . $type . "&m=" . $module
return "./?" . PT::URL_ACTION_PARAM . "=report&w=" . $type . "&m=" . $module
. "&n=" . $report_name;
}
......
......@@ -21,10 +21,11 @@
// Index is the entry point for everything.
namespace Pasteque;
define("ABSPATH", __DIR__); // Base path. Also to check if a call
require_once(__DIR__ . "/inc/constants.php");
PT::$ABSPATH = __DIR__; // Base path. Also to check if a call
// originates from index.php
// Load
require_once(ABSPATH . "/inc/load.php");
require_once(PT::$ABSPATH . "/inc/load.php");
function index_run() {
tpl_open();
......@@ -36,19 +37,19 @@ function index_run() {
if (!is_user_logged_in()) {
show_login_page();
} else {
require_once(ABSPATH . "/inc/load_logged.php");
require_once(PT::$ABSPATH . "/inc/load_logged.php");
// Check install
require_once(ABSPATH . "/install.php");
if (isset($_GET[URL_ACTION_PARAM])) {
switch($_GET[URL_ACTION_PARAM]) {
require_once(PT::$ABSPATH . "/install.php");
if (isset($_GET[PT::URL_ACTION_PARAM])) {
switch($_GET[PT::URL_ACTION_PARAM]) {
case "img":
require_once(ABSPATH . "/dbimg.php");
require_once(PT::$ABSPATH . "/dbimg.php");
break;
case "report":
require_once(ABSPATH . "/report.php");
require_once(PT::$ABSPATH . "/report.php");
break;
case "print":
require_once(ABSPATH . "/print.php");
require_once(PT::$ABSPATH . "/print.php");
break;
default:
index_run();
......
......@@ -7,7 +7,7 @@
* Author: Olivier PLATHEY *
*******************************************************************************/
define('FPDF_VERSION','1.7');
define('FPDF_PT::VERSION','1.7');
class FPDF
{
......@@ -1711,7 +1711,7 @@ function _putresources()
function _putinfo()
{
$this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION));
$this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_PT::VERSION));
if(!empty($this->title))
$this->_out('/Title '.$this->_textstring($this->title));
if(!empty($this->subject))
......
......@@ -157,7 +157,7 @@ if (isset($_GET['id'])) {
<script type="text/javascript">
updateBarcode = function() {
var barcode = jQuery("#barcode").val();
var src = "?<?php echo \Pasteque\URL_ACTION_PARAM; ?>=img&w=custcard&code=" + barcode;
var src = "?<?php echo \Pasteque\PT::URL_ACTION_PARAM; ?>=img&w=custcard&code=" + barcode;
jQuery("#barcodeImg").attr("src", src);
}
updateBarcode();
......
......@@ -62,7 +62,7 @@ foreach ($categories as $category) {
$par = !$par;
?>
<tr class="row-<?php echo $par ? 'par' : 'odd'; ?>">
<td><img class="thumbnail" src="?<?php echo \Pasteque\URL_ACTION_PARAM; ?>=img&w=category&id=<?php echo $category->id; ?>" />
<td><img class="thumbnail" src="?<?php echo \Pasteque\PT::URL_ACTION_PARAM; ?>=img&w=category&id=<?php echo $category->id; ?>" />
<td><?php echo $category->label; ?></td>
<td class="edition">
<?php \Pasteque\tpl_btn("edition", \Pasteque\get_module_url_action(PLUGIN_NAME,
......
......@@ -82,7 +82,7 @@ if (isset($_GET['id'])) {
<div style="display:inline-block">
<input type="hidden" id="clearImage" name="clearImage" value="0" />
<?php if ($category !== null && $category->hasImage) { ?>
<img id="img" class="image-preview" src="?<?php echo \Pasteque\URL_ACTION_PARAM; ?>=img&w=category&id=<?php echo $category->id; ?>" />
<img id="img" class="image-preview" src="?<?php echo \Pasteque\PT::URL_ACTION_PARAM; ?>=img&w=category&id=<?php echo $category->id; ?>" />
<a class="btn" id="clear" href="" onClick="javascript:clearImage(); return false;"><?php \pi18n("Delete"); ?></a>
<a class="btn" style="display:none" id="restore" href="" onClick="javascript:restoreImage(); return false;"><?php \pi18n("Restore"); ?></a><br />
<?php } ?>
......
......@@ -144,7 +144,7 @@ if ($stocks === TRUE && $product != NULL) {
<div style="display:inline-block">