Ejemplo n.º 1
0
// Force the filesize and modification date to strings to be able to compare it with the DB
settype($lastEdit, 'string');
settype($fileSize, 'string');
$optionsUpdate = false;
// Update version based on the date and / or filesize. This will also work if the db is empty
if ($dbTimeStamp !== $lastEdit or $dbFileSize !== $fileSize) {
    $optionsUpdate = true;
    Options::groupAdd('Website Settings', 'basic website information');
    Options::groupAdd('META Data', 'control the Meta Data for the website');
    Options::groupAdd('Email Templates', 'variables used in Email Templates');
    Options::groupAdd('Miscellaneous', 'general settings page, not editible');
    Options::groupAdd('User Settings', "options visible in the user's settings page");
    // Set the timestamp and filesize
    Options::add('modified', $lastEdit, 'hidden', 'Miscellaneous');
    // Do not modify these, they need to be static
    Options::add('filesize', $fileSize, 'hidden', 'Miscellaneous');
    // Do not modify these, they need to be static
    // These would be the options you want to set, it will first
    // Site
    Options::addOnce('siteName', 'http://www.mysite.co.za', 'input', 'Website Settings');
    Options::addOnce('siteLogo', 'assets/img/logo.png', 'input', 'Website Settings');
    Options::addOnce('siteIcon', 'assets/img/icon.png', 'input', 'Website Settings');
    Options::addOnce('prettyName', '<small>www.</small>MySite<small>.co.za</small>', 'input', 'Website Settings');
    // Email Templates
    Options::addOnce('emailName', 'www.MySite.co.za', 'input', 'Email Templates');
    Options::addOnce('emailInfo', '*****@*****.**', 'input', 'Email Templates');
    Options::addOnce('emailAdmin', '*****@*****.**', 'input', 'Email Templates');
    // META Data
    Options::addOnce('metaAuthor', 'Rudi Strydom', 'input', 'META Data');
    Options::addOnce('metaDesc', 'Baseline is a PHP framework. Based on Simple PHP Framework and intgrates with Bootstrap from Twitter to create baseline website.', 'textarea', 'META Data');
    Options::addOnce('metaKeyWords', 'Baseline, Simple PHP Framework, Bootstrap from Twitter', 'textarea', 'META Data');
Ejemplo n.º 2
0
 public static function set($option, $value = '', $type = false, $group = false)
 {
     return Options::add($option, $value, $type, $group);
 }
Ejemplo n.º 3
0
// Force the filesize and modification date to strings to be able to compare it with the DB
settype($lastEdit, 'string');
settype($fileSize, 'string');
$optionsUpdate = false;
// Update version based on the date and / or filesize. This will also work if the db is empty
if ($dbTimeStamp !== $lastEdit or $dbFileSize !== $fileSize) {
    $optionsUpdate = true;
    Options::groupAdd('Website Settings', 'basic website information');
    Options::groupAdd('META Data', 'control the Meta Data for the website');
    Options::groupAdd('Email Templates', 'variables used in Email Templates');
    Options::groupAdd('Miscellaneous', 'general settings page');
    // Set the timestamp and filesize
    Options::add('modified', $lastEdit, 'hidden');
    // Do not modify these, they need to be static
    Options::add('filesize', $fileSize, 'hidden');
    // Do not modify these, they need to be static
    // These would be the options you want to set, it will first
    // Site
    Options::add('siteName', 'http://www.mysite.co.za', 'input', 'Website Settings');
    Options::add('siteLogo', 'assets/img/logo.png', 'input', 'Website Settings');
    Options::add('siteIcon', 'assets/img/icon.png', 'input', 'Website Settings');
    Options::add('prettyName', '<small>www.</small>MySite<small>.co.za</small>', 'input', 'Website Settings');
    // Email Templates
    Options::add('emailName', 'www.MySite.co.za', 'input', 'Email Templates');
    Options::add('emailInfo', '*****@*****.**', 'input', 'Email Templates');
    Options::add('emailAdmin', '*****@*****.**', 'input', 'Email Templates');
    // META Data
    Options::add('metaAuthor', 'Rudi Strydom', 'input', 'META Data');
    Options::add('metaDesc', 'Baseline is a PHP framework. Based on Simple PHP Framework and intgrates with Bootstrap from Twitter to create baseline website.', 'textarea', 'META Data');
    Options::add('metaKeyWords', 'Baseline, Simple PHP Framework, Bootstrap from Twitter', 'textarea', 'META Data');
}
 /**
  * Process posting data
  */
 public function postProcess()
 {
     $languages = Language::getLanguages(false);
     $current_theme = Theme::getThemeInfo($this->context->shop->id_theme);
     //$theme_arr['theme_id'] = $theme->id;
     //		$theme_arr['theme_name'] = $theme->name;
     //		$theme_arr['theme_directory'] = $theme->directory;
     if (Tools::isSubmit('submitnewOption')) {
         $id_option = Tools::getValue('id_option');
         if ($id_option && Validate::isUnsignedId($id_option)) {
             $option = new Options($id_option);
             $addaction = false;
         } else {
             $option = new Options();
             $addaction = true;
         }
         $option->column = Tools::getValue('colselected');
         $option->theme = strtolower($current_theme['theme_name']);
         $option->alias = Tools::getValue('alias');
         $option->active = (int) Tools::getValue('active');
         $name_set = false;
         $option_name = Tools::getValue('option_name');
         if (strlen($option_name) > 0) {
             $name_set = true;
             $option->name = $option_name;
         }
         if (!$name_set) {
             $lang_title = Language::getLanguage($this->context->language->id);
             $this->errors[] = Tools::displayError('This item title field is required');
         }
         if (strlen($option->alias) > 0) {
             if (OvicLayoutControl::isAvailablebyAlias($option->alias) > 0) {
                 $this->errors[] = Tools::displayError('Alias is avaiable in database');
             }
         } else {
             $this->errors[] = Tools::displayError('This item alias field is required');
         }
         if (isset($_FILES['option_img']) && strlen($_FILES['option_img']['name']) > 0) {
             $img_name = time() . $_FILES['option_img']['name'];
             $img_name = preg_replace('/[^A-Za-z0-9\\-.]/', '', $img_name);
             // Removes special chars.
             //_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $this->name .DIRECTORY_SEPARATOR
             $main_name = _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'oviclayoutcontrol' . DIRECTORY_SEPARATOR . 'thumbnails' . DIRECTORY_SEPARATOR . $img_name;
             if (!move_uploaded_file($_FILES['option_img']['tmp_name'], $main_name)) {
                 $this->errors[] = Tools::displayError('An error occurred during the image upload.');
             } else {
                 $option->image = $img_name;
                 if (Tools::getValue('old_img') != '') {
                     $filename = Tools::getValue('old_img');
                     if (file_exists(_PS_MODULE_DIR_ . 'oviclayoutcontrol/thumbnails/' . $filename)) {
                         @unlink(_PS_MODULE_DIR_ . 'oviclayoutcontrol/thumbnails/' . $filename);
                     }
                 }
             }
         } else {
             $option->image = Tools::getValue('old_img');
         }
         if (!count($this->errors)) {
             if ($addaction) {
                 if (!$option->add()) {
                     $this->errors[] = Tools::displayError('An error occurred while saving data.');
                 } else {
                     if (Tools::getIsset('id_copy_option')) {
                         $id_copy_option = (int) Tools::getValue('id_copy_option');
                         $source_option = new Options($id_copy_option);
                         OvicLayoutControl::copyHookModule($source_option, $option);
                         OvicLayoutControl::copyOptionStyle($source_option, $option);
                     } else {
                         OvicLayoutControl::registerDefaultHookModule($option->id);
                     }
                 }
             } else {
                 if (!$option->update()) {
                     $this->errors[] = Tools::displayError('An error occurred while update data.');
                 }
             }
             if (!count($this->errors)) {
                 Tools::redirectAdmin(self::$currentIndex . '&conf=3&token=' . Tools::getValue('token'));
             }
         }
     } elseif (Tools::isSubmit('changeactive')) {
         $id_option = Tools::getValue('id_option');
         if ($id_option && Validate::isUnsignedId($id_option)) {
             $option = new Options($id_option);
             $option->active = !$option->active;
             if (!$option->update()) {
                 $this->errors[] = Tools::displayError('Could not change');
             } else {
                 Tools::redirectAdmin(self::$currentIndex . '&conf=5&token=' . Tools::getValue('token'));
             }
         }
     } elseif (Tools::isSubmit('removeoption')) {
         $id_option = Tools::getValue('id_option');
         if ($id_option && Validate::isUnsignedId($id_option)) {
             $option = new Options($id_option);
             if (!$option->delete()) {
                 $this->errors[] = Tools::displayError('An error occurred during deletion');
             } else {
                 Tools::redirectAdmin(self::$currentIndex . '&conf=1&token=' . Tools::getValue('token'));
             }
         }
     } elseif (Tools::isSubmit('submitMultiSave')) {
         $id_option = (int) Tools::getValue('id_option');
         if ($id_option && Validate::isUnsignedId($id_option)) {
             $fonts = array();
             foreach (OvicLayoutControl::$OptionFonts as $font) {
                 $fonts[$font] = Tools::getValue($font);
             }
             $colors = array();
             foreach (OvicLayoutControl::$OptionColors as $color) {
                 $colors[$color] = Tools::getValue($color);
             }
             $option = new Options($id_option);
             $where = "`theme` = '" . $option->theme . "' AND `alias` = '" . $option->alias . "'";
             $sql = 'SELECT `alias`
     			FROM `' . _DB_PREFIX_ . 'ovic_options_style` 
     			 WHERE ' . $where;
             if (Db::getInstance()->getRow($sql)) {
                 $result = Db::getInstance()->update('ovic_options_style', array('color' => Tools::jsonEncode($colors), 'font' => Tools::jsonEncode($fonts)), $where);
             } else {
                 // Register module in hook
                 $result = Db::getInstance()->insert('ovic_options_style', array('theme' => $option->theme, 'alias' => $option->alias, 'color' => Tools::jsonEncode($colors), 'font' => Tools::jsonEncode($fonts)));
             }
             if ($result) {
                 Tools::redirectAdmin(self::$currentIndex . '&conf=4&token=' . Tools::getValue('token') . '&view=detail&id_option=' . $id_option);
             } else {
                 $this->errors[] = Tools::displayError('An error occurred while saving data.');
             }
         }
     }
     parent::postProcess();
 }
Ejemplo n.º 5
0
 /**
  * Process posting data
  */
 public function postProcess()
 {
     $errors = array();
     $languages = Language::getLanguages(false);
     if (Tools::isSubmit('submitnewOption')) {
         $id_option = Tools::getValue('id_option');
         if ($id_option && Validate::isUnsignedId($id_option)) {
             $option = new Options($id_option);
             $addaction = false;
         } else {
             $option = new Options();
             $addaction = true;
         }
         $option->column = Tools::getValue('colselected');
         $option->active = (int) Tools::getValue('active');
         $name_set = false;
         foreach ($languages as $language) {
             $option_name = Tools::getValue('option_name_' . $language['id_lang']);
             if (strlen($option_name) > 0) {
                 $name_set = true;
             }
             $option->name[$language['id_lang']] = $option_name;
         }
         if (!$name_set) {
             $lang_title = Language::getLanguage($this->context->language->id);
             $errors[] = Tools::displayError('This item title field is required at least in ' . $lang_title['name']);
         }
         if (isset($_FILES['option_img']) && strlen($_FILES['option_img']['name']) > 0) {
             $img_name = time() . $_FILES['option_img']['name'];
             $img_name = preg_replace('/[^A-Za-z0-9\\-.]/', '', $img_name);
             // Removes special chars.
             //_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $this->name .DIRECTORY_SEPARATOR
             $main_name = _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'oviclayoutcontrol' . DIRECTORY_SEPARATOR . 'thumbnails' . DIRECTORY_SEPARATOR . $img_name;
             if (!move_uploaded_file($_FILES['option_img']['tmp_name'], $main_name)) {
                 $errors[] = Tools::displayError('An error occurred during the image upload.');
             } else {
                 $option->image = $img_name;
                 if (Tools::getValue('old_img') != '') {
                     $filename = Tools::getValue('old_img');
                     if (file_exists(_PS_MODULE_DIR_ . 'oviclayoutcontrol/thumbnails/' . $filename)) {
                         @unlink(_PS_MODULE_DIR_ . 'oviclayoutcontrol/thumbnails/' . $filename);
                     }
                 }
             }
         } else {
             $option->image = Tools::getValue('old_img');
         }
         if (!count($errors)) {
             if ($addaction) {
                 if (!$option->add()) {
                     $errors[] = Tools::displayError('An error occurred while saving data.');
                 } else {
                     if (Tools::getIsset('id_copy_option')) {
                         $id_copy_option = Tools::getValue('id_copy_option');
                         OvicLayoutControl::copyHookModule($id_copy_option, $option->id);
                     } else {
                         OvicLayoutControl::registerDefaultHookModule($option->id);
                     }
                 }
             } else {
                 if (!$option->update()) {
                     $errors[] = Tools::displayError('An error occurred while update data.');
                 }
             }
             if (!count($errors)) {
                 Tools::redirectAdmin(self::$currentIndex . '&conf=3&token=' . Tools::getValue('token'));
             }
         }
     } elseif (Tools::isSubmit('changeactive')) {
         $id_option = Tools::getValue('id_option');
         if ($id_option && Validate::isUnsignedId($id_option)) {
             $option = new Options($id_option);
             $option->active = !$option->active;
             if (!$option->update()) {
                 $errors[] = Tools::displayError('Could not change');
             } else {
                 Tools::redirectAdmin(self::$currentIndex . '&conf=5&token=' . Tools::getValue('token'));
             }
         }
     } elseif (Tools::isSubmit('removeoption')) {
         $id_option = Tools::getValue('id_option');
         if ($id_option && Validate::isUnsignedId($id_option)) {
             $option = new Options($id_option);
             if (!$option->delete()) {
                 $errors[] = Tools::displayError('An error occurred during deletion');
             } else {
                 Tools::redirectAdmin(self::$currentIndex . '&conf=1&token=' . Tools::getValue('token'));
             }
         }
     } else {
         $this->context->controller->errors = array_merge($this->context->controller->errors, $errors);
     }
     parent::postProcess();
 }
Ejemplo n.º 6
0
    addColumn("options", '`type`', "ENUM('input', 'date', 'checkbox', 'hidden', 'textarea')", "default 'input'");
    addColumn("options", '`group`', "varchar(65)", "default 'Miscellaneous'");
    // This table will be where the settings are kept
    createTable("options_groups", "`group` varchar(65) NOT NULL", True, False);
    addColumn("options_groups", '`desc`', "varchar(65)", "default NULL");
    // This table will be where the settings are kept
    createTable("settings", "setting varchar(65) NOT NULL", True, False);
    addColumn("settings", '`desc`', "varchar(65)", "default NULL");
    addColumn("settings", 'type', "ENUM('input', 'date', 'checkbox', 'hidden', 'textarea')", "default 'input'");
    // This is where we will add the clien'ts ability to add values to the settings.
    createTable("repositry", "user_id int(11) NOT NULL", false, false);
    addColumn("repositry", '`key`', "varchar(65)", "default NULL");
    addColumn("repositry", 'value', "varchar(65)", "default NULL");
    // Create the default system user
    // Username: demo
    // Password: demo
    Auth::createNewUser('admin', 'password', '*****@*****.**');
    // Add a user, when the username does not exist
    Auth::changeGroup('admin', 'admin');
    // Promote the user to administrator by running the following snippet*/
    $getId = Auth::userId('admin');
    Activation::generate($getId, 20);
    Activation::activate($getId);
    // Set the timestamp and filesize
    Options::add('installModified', $lastEdit, 'input');
    // Do not modify these, they need to be static
    Options::add('installFilesize', $fileSize, 'input');
    // Do not modify these, they need to be static*/
    $installRan = true;
}
// End of installation action