Ejemplo n.º 1
0
 public function construct()
 {
     $installedVersion = $this->getClassInstalledVersion(__CLASS__);
     if ($installedVersion != self::CLASS_VERSION) {
         $this->linker->db->updateQueries(__CLASS__);
         if (version_compare($installedVersion, '1.1.11.03.29', '<')) {
             // The class datas are not in the same version as this file, or don't exist (installation)
             $this->helper->addClassesSharedMethods('sh_admin', sh_admin::ADMINMENUENTRIES, __CLASS__);
             $this->helper->addClassesSharedMethods('sh_facebook', '', __CLASS__);
             $this->helper->addClassesSharedMethods('sh_searcher', 'scopes', __CLASS__);
             $this->helper->addClassesSharedMethods('sh_sitemap', '', __CLASS__);
             $this->helper->addClassesSharedMethods('sh_path', '', $this->className);
             if (!is_dir(SH_IMAGES_FOLDER . 'small/')) {
                 mkdir(SH_IMAGES_FOLDER . 'small/');
             }
             sh_browser::setRights(SH_IMAGES_FOLDER . 'small/', sh_browser::ALL);
             sh_browser::setOwner(SH_IMAGES_FOLDER . 'small/');
             $this->linker->browser->addDimension(SH_IMAGES_FOLDER . 'small/', 100, 100);
             $this->db_execute('create_table', array());
         }
         if (version_compare($installedVersion, '1.1.11.07.13', '<')) {
             $this->db_execute('modify_table_1', array());
         }
         if (version_compare($installedVersion, '1.1.11.07.14', '<')) {
             $this->linker->renderer->add_render_tag('render_newsBox', __CLASS__, 'render_newsBox');
         }
         if (version_compare($installedVersion, '1.1.11.07.14.2', '<')) {
             sh_browser::setRights(SH_IMAGES_FOLDER . 'site/', sh_browser::ALL);
         }
         if (version_compare($installedVersion, '1.1.12.08.20', '<')) {
             $this->db_execute('modify_table_2', array());
             $params = $this->getParam('news>0', array());
             $this->setParam('news>1', $params);
             $this->removeParam('news>0');
             $this->writeParams();
         }
         if (version_compare($installedVersion, '1.1.12.08.21', '<')) {
             $this->helper->addClassesSharedMethods('sh_site', 'sharedSettings', __CLASS__);
         }
         $this->setClassInstalledVersion(self::CLASS_VERSION);
     }
     $this->news_is_active = $this->getParam('news_module_active', true);
 }
Ejemplo n.º 2
0
 public function addBankLogo_auto($bankLogoFile, $subFolder)
 {
     if (!is_dir(SH_IMAGES_FOLDER . 'banks/' . $subFolder . '/')) {
         mkdir(SH_IMAGES_FOLDER . 'banks/' . $subFolder);
         sh_browser::setRights(SH_IMAGES_FOLDER . 'banks/' . $subFolder, sh_browser::READ);
     }
     if (!file_exists(SH_IMAGES_FOLDER . 'banks/' . $subFolder . '/' . basename($bankLogoFile))) {
         copy($bankLogoFile, SH_IMAGES_FOLDER . 'banks/' . $subFolder . '/' . basename($bankLogoFile));
     }
 }
Ejemplo n.º 3
0
 /**
  * public function edit
  *
  */
 public function editParams()
 {
     $this->onlyAdmin(true);
     if ($this->formSubmitted('shopParamsEditor')) {
         //Saves the datas
         // Bills bottom text
         $this->setParam('billBottomText', stripslashes($_POST['billBottomText']));
         if ($this->getParam('activateShop', true) != isset($_POST['activateShop'])) {
             $renewSitemap = true;
         } else {
             $renewSitemap = false;
         }
         // Enables tthe only shop
         $this->setParam('activateShop', isset($_POST['activateShop']));
         if (isset($_POST['activateShop'])) {
             $this->helper->addClassesSharedMethods('sh_html', 'construct', __CLASS__);
         } else {
             $this->helper->removeClassesSharedMethods('sh_html', 'construct', __CLASS__);
         }
         sh_browser::setHidden(SH_SHOPIMAGES_FOLDER, !isset($_POST['activateShop']));
         // Format of the prices and currency
         $this->setParam('monney_format', $_POST['monney_format']);
         $this->setParam('currency', $_POST['currency']);
         // Taxes
         $this->setParam('taxes', $_POST['taxes']);
         $this->setParam('taxRate', str_replace(array(',', '%'), array('.', ''), $_POST['taxRate']));
         $this->setParam('showTaxSymbol', isset($_POST['showTaxSymbol']));
         $this->setParam('paymentRequiresConnexion', isset($_POST['paymentRequiresConnexion']));
         $this->setParam('forceUserToCheckConditions', isset($_POST['forceUserToCheckConditions']));
         $this->setParam('conditions', $_POST['conditions']);
         // State of the cart
         if ($this->linker->payment->getActivePaymentModesCount() > 0) {
             $this->setParam('selling>activated', isset($_POST['sellingActivated']));
         }
         $command_mail = str_replace(array(',', ';', '/', '\\', '"'), "\n", stripslashes($_POST['command_mail']));
         $command_mail = explode("\n", $command_mail);
         $mailer = $this->linker->mailer->get();
         if (is_array($command_mail)) {
             foreach ($command_mail as $oneMail) {
                 if ($mailer->checkAddress($oneMail)) {
                     $checkedMails .= $separator . $oneMail;
                     $separator = "\n";
                 }
             }
         }
         if ($checkedMails == '') {
             $datas = $this->linker->user->getData();
             $checkedMails = $datas['mail'];
         }
         $this->setParam('command_mail', $checkedMails);
         // Manages the quantity
         $this->setParam('showQuantity', isset($_POST['showQuantity']));
         $this->setParam('hideNullQuantityProducts', isset($_POST['hideNullQuantityProducts']));
         // Saves the commands parts
         if (trim($_POST['command_logo']) != self::$default_logo) {
             $logo = trim($_POST['command_logo']);
         } else {
             $logo = '';
         }
         $this->setI18n(self::I18N_BILLFOOTER, $_POST['command_footer']);
         $this->setI18n(self::I18N_BILLHEADLINE, $_POST['command_headLine']);
         $this->setI18n(self::I18N_BILLHEADLINE, $_POST['command_headLine']);
         $this->setI18n(self::I18N_BILLCUSTOMERSERVICE, $_POST['command_customerService']);
         $this->setParam('command>logo', $logo);
         $this->setParam('command>companyName', stripslashes($_POST['command_companyName']));
         $this->setParam('command>companyAddress', stripslashes($_POST['command_companyAddress']));
         $this->setParam('billColor', $_POST['billColor']);
         $this->setParam('bill_number_format', $_POST['bill_number_format']);
         // Finaly writes the params
         $this->writeParams();
         if ($renewSitemap) {
             $this->linker->sitemap->renew();
         }
     }
     if ($this->getParam('activateShop', true) === true) {
         $values['activateShop']['checked'] = 'checked';
     }
     if ($this->linker->payment->getActivePaymentModesCount() > 0) {
         if ($this->getParam('selling>activated') === true) {
             $values['sellingActivated']['checked'] = 'checked';
         }
     } else {
         $values['sellingActivated']['checked'] = 'disabled';
     }
     if ($this->getParam('forceUserToCheckConditions', true)) {
         $values['forceUserToCheckConditions']['checked'] = 'checked';
     }
     $values['conditions']['file'] = $this->getParam('conditions', '');
     $values['command_mail']['value'] = $this->getParam('command_mail');
     if ($this->getParam('showQuantity') === true) {
         $values['showQuantity']['checked'] = 'checked';
     }
     if ($this->getParam('hideNullQuantityProducts') === true) {
         $values['hideNullQuantityProducts']['checked'] = 'checked';
     }
     $values['command']['bill_number_format'] = $this->getParam('bill_number_format', '[YEAR4][MONTH2][DAYOFMONTH2]-[INCREMENT3]');
     // Monney format
     $monneyFormats = $this->getParam('monney_formats_listing');
     $monneyFormat = $this->getParam('monney_format', array());
     foreach (array_keys($monneyFormats) as $name) {
         if ($name == $monneyFormat) {
             $state = 'selected';
         } else {
             $state = '';
         }
         $values['monneyFormats'][] = array('name' => $name, 'state' => $state);
     }
     // Currency
     $currency = $this->getParam('currency');
     $currencies = $this->getParam('currencies', array());
     foreach ($currencies as $cName => $cValue) {
         if ($cName == $currency) {
             $state = 'selected';
         } else {
             $state = '';
         }
         $values['currencies'][] = array('id' => $cName, 'name' => $cValue['name'], 'value' => $cValue['name'] . ' (' . $cValue['symbol'] . ')', 'state' => $state);
     }
     // Taxes
     $values['taxes'][0]['value'] = 'TTC';
     $values['taxes'][0]['text'] = $this->getI18n('prices_showTTC');
     $values['taxes'][1]['value'] = 'HT';
     $values['taxes'][1]['text'] = $this->getI18n('prices_showHT');
     if ($this->getParam('taxes', 'TTC') === 'HT') {
         $values['taxes'][1]['selected'] = 'selected';
         $ht = true;
     } else {
         $values['taxes'][0]['selected'] = 'selected';
     }
     $values['tax']['rate'] = $this->getParam('taxRate', 19.6);
     if ($this->getParam('showTaxSymbol', false)) {
         $values['showTaxSymbol']['state'] = 'checked';
     }
     if ($this->getParam('paymentRequiresConnexion', true)) {
         $values['paymentRequiresConnexion']['state'] = 'checked';
     }
     $values['activateMail']['checked'] = 'disabled';
     $values['activateCom']['checked'] = 'disabled';
     $billColors = $this->getParam('billColors');
     foreach ($billColors as $id => $billColor) {
         $values['billColors'][] = array('id' => $id, 'color' => dechex($billColor[0]) . dechex($billColor[1]) . dechex($billColor[2]));
     }
     $values['bill']['color'] = $this->getParam('billColor', 0);
     // Saves the commands parts
     $logo = $this->getParam('command>logo', '');
     $values['command']['logo'] = $logo;
     $values['command']['companyName'] = $this->getParam('command>companyName');
     $values['command']['companyAddress'] = $this->getParam('command>companyAddress');
     $values['billForm']['bottomText'] = $this->getParam('billBottomText');
     $this->render('edit_params', $values);
 }
Ejemplo n.º 4
0
 /**
  * Method that creates the images list file in a gallery directory.<br />
  * If there is already one, it is replaced.
  * @param str $name Name of the gallery.
  * @return array An array containing the images list.
  */
 protected function buildListFile($name)
 {
     $this->debug(__METHOD__, 2, __LINE__);
     $folder = $this->galleryFolder . sh_browser::modifyName($name);
     // We remove the old list file
     $file = $folder . '/' . self::LIST_FILENAME;
     if (file_exists($file)) {
         unlink($file);
     }
     list($width, $height) = explode('x', file_get_contents($folder . '/.images_dimensions'));
     $elements = scandir($folder);
     foreach ($elements as $element) {
         if (substr($element, 0, 1) != '.') {
             // The file is neither ".", nor "..", nor any hidden file or folder
             $ext = array_pop(explode('.', $element));
             if (in_array(strtolower($ext), $this->acceptedTypes)) {
                 // We don't take resized images neither
                 if (!preg_match('`.*\\.resized\\.[0-9]+\\.[0-9]+\\.png`', $element)) {
                     $imagePath = $this->linker->path->changeToShortFolder($folder) . '/' . $element;
                     $values['images'][]['src'] = $imagePath . '.resized.' . $width . '.' . $height . '.png';
                 }
             }
         }
     }
     $this->helper->writeArrayInFile($file, 'values', $values);
     return $values;
 }
Ejemplo n.º 5
0
 /**
  * Method called by the sh_render class to render the tag RENDER_DIAPORAMA.
  * @param array $attributes An associative array containing all the tag's attributes.
  * @return str The rendered html for the diaporama.
  */
 public function render_diaporama($attributes = array())
 {
     $name = $attributes['name'];
     $folder = $this->diapoFolder . sh_browser::modifyName($name);
     if (!is_dir($folder)) {
         return false;
     }
     if (isset($attributes['id'])) {
         $id = $attributes['id'];
         unset($attributes['id']);
     } else {
         $id = 'd_' . substr(md5(microtime()), 0, 10);
     }
     if (isset($attributes['first'])) {
         $first = $attributes['first'];
     } else {
         $first = 1;
     }
     $file = $folder . '/' . self::LIST_FILENAME;
     if (!file_exists($file)) {
         $this->buildListFile($name);
     }
     include $file;
     if (isset($attributes['manual'])) {
         $values['diapo']['manual'] = true;
         $attributes['commands'] = true;
     }
     if (isset($attributes['commands'])) {
         if (strtolower($attributes['commands']) == 'commands') {
             $values['diapo']['commands'] = true;
         }
     } elseif (file_exists($folder . '/.commands')) {
         $values['diapo']['commands'] = true;
     }
     if (isset($attributes['shuffle']) && is_array($values['images'])) {
         // 2 shuffles to really shuffle the array
         shuffle($values['images']);
         shuffle($values['images']);
     }
     $values['diapo']['id'] = $id;
     if (!empty($attributes['class'])) {
         $values['diapo']['class'] = $attributes['class'];
     } elseif (file_exists($folder . '/.classes')) {
         $values['diapo']['class'] = file_get_contents($folder . '/.classes');
     }
     if (isset($values['images'][$first]['src'])) {
         $values['defaultImage']['src'] = $values['images'][$first]['src'];
     } else {
         $values['defaultImage']['src'] = $values['images'][0]['src'];
     }
     $values['js']['dir'] = $this->getSinglePath(false);
     $values['diapo']['style'] = '';
     if (isset($attributes['width'])) {
         $values['diapo']['style'] .= 'width:' . $attributes['width'] . 'px;';
     }
     if (isset($attributes['height'])) {
         $values['diapo']['style'] .= 'height:' . $attributes['height'] . 'px;';
     }
     if (isset($attributes['float']) && $attributes['float'] != 'none') {
         $values['diapo']['style'] .= 'float:' . $attributes['float'] . ';';
     }
     if ($this->jsAdded) {
         $values['js']['added'] = true;
     } elseif (sh_html::$willRender) {
         $values['js']['added'] = true;
         $this->linker->javascript->get(sh_javascript::SCRIPTACULOUS);
         $this->linker->html->addScript($this->getSinglePath() . 'fastinit.js');
         $this->linker->html->addScript($this->getSinglePath() . 'crossfade.js');
         $this->linker->html->addScript($this->getSinglePath() . 'actions.js');
         $this->jsAdded = true;
     } else {
         $this->jsAdded = true;
     }
     return $this->render('diaporama', $values, false, false);
 }