static function load($config = array()) { self::$config = $config; self::$mode = $config['mode']; self::$appsDir = $config['appsDir']; self::$pluginsDir = $config['pluginsDir']; self::$helpersDir = $config['helpersDir']; self::$mainApp = $config['mainApp']; self::$disabledApps = $config['disabledApps']; self::$database = $config['database']; self::init(); }
public function __construct($template) { $this->template = $template; $config = new Config(); $this->data['app_title'] = App::name() . ' ' . App::version(); $this->data['app_version'] = App::version(); $this->data['mode'] = $config->mode(); $this->data['baseurl'] = $config->baseUrl(); $this->data['baseurl_full'] = $config->baseUrl(true); $this->data['site_title'] = $config->siteTitle(); $this->data['alerts'] = isset($_SESSION['alerts']) ? $_SESSION['alerts'] : array(); $_SESSION['alerts'] = array(); $user = new User(); if (isset($_SESSION['userid'])) { $user->load($_SESSION['userid']); } $this->data['user'] = $user; }
public function createFromJson($json) { // 1. Parse JSON $decoded = json_decode($json); if ($decoded !== null) { if ($this->validateJson($decoded)) { $this->packagenumber = $decoded->package->number; $tags = $this->getPreparedTags($decoded->tags_format, $decoded->tags); // Populate Config overwrite defaults Config::$glsbox_label_beginx = intval($decoded->pdf->beginx); // zero is the default anyway Config::$glsbox_label_beginy = intval($decoded->pdf->beginy); $format = resempty($decoded, array('pdf', 'format'), 'A4', Primitive::STR); if (in_array($format, array('A4', 'A5'))) { Config::$glsbox_label_papersize = $format; } Config::$filename_prefix = resempty($decoded, array('pdf', 'prefix'), "", Primitive::STR); $mode = resempty($decoded, 'mode', 'business', Primitive::STR); if (in_array($mode, array('business', 'express'))) { Config::$mode = $mode; } $glsService = null; if (Config::$mode == "express") { $glsService = new Gls_Unibox_Model_Label_Gls_Express(); } else { $glsService = new Gls_Unibox_Model_Label_Gls_Business(); } $glsService->importValues($tags); $ready_tags = $glsService->getData(); $gls_unibox_label_pdf = new Gls_Unibox_Model_Pdf_Label(); $pdf = $gls_unibox_label_pdf->createLabel($ready_tags); $this->content = $pdf->render(); return true; } else { array_push($this->errors, new GCError("Error: Validation of input parameters did not succeed.")); } } else { array_push($this->errors, new GCError("Error: Decoding of the JSON-Input failed - invalid JSON.")); } return false; }