public function load($templateName, $generalSettingsInstance = false) { //set default template as messy if (!$templateName) { foreach ($this->getAllTemplates() as $tpl) { list($template_all) = explode('-', $tpl); if ($template_all == 'messy') { $templateName = $tpl; break; } else { $templateName = 'default'; } } //save in settings $settings = new Settings(false); $settings->update('template', 'template', array('value' => $templateName)); $settings->save(); } $this->name = $templateName; $tPath = self::$options['TEMPLATES_FULL_SERVER_PATH'] . $this->name; if (!file_exists($tPath)) { $template = explode('-', $this->name); $template = $template[0]; //try to get same template with different version if not exists foreach ($this->getAllTemplates() as $tpl) { list($template_all) = explode('-', $tpl); if ($template_all == $template) { $this->name = $tpl; break; //default template = messy } else { $this->name = 'default'; } } $tPath = self::$options['TEMPLATES_FULL_SERVER_PATH'] . $this->name; } if (file_exists($tPath) && file_exists($tPath . '/template.conf.php')) { $this->smarty->template_dir = $tPath; $this->smarty->plugins_dir = array('plugins', self::$options['TEMPLATES_FULL_SERVER_PATH'] . '_plugins', $tPath . '/plugins'); list($this->sectionTypes, $this->settingsDefinition) = (include $tPath . '/template.conf.php'); $this->templateHTML = @file_get_contents($tPath . '/template.tpl'); $this->templateFile = $tPath . '/template.tpl'; $this->settings = new Settings($this->settingsDefinition, $generalSettingsInstance, $this->name); // instantiate settings for each section type definition (extend $this->settings) reset($this->sectionTypes); while (list($tName, $t) = each($this->sectionTypes)) { $this->sectionTypes[$tName]['settings'] = new Settings(false, $this->settings, false, isset($t['settings']) ? $t['settings'] : false); } return true; } return false; }
function update() { $params = $this->input->post(); $obj = new Settings(); $obj->update($params); }
<?php // KioCMS - Kiofol Content Managment System // modules/guestbook/admin/settings.php $note = new Notifier(); $err = new Errors(); $save = $_POST['save'] ? true : false; $form = $save ? $_POST['form'] : $guestbook; $form['bbcode'] = $save ? $_POST['bbcode'] : $guestbook['bbcode'] ? 1 : 0; $form['allow_signatures'] = $save ? $_POST['allow_signatures'] : $guestbook['allow_signatures'] ? 1 : 0; $form['blocks'] = $save ? array_diff($blocks, $_POST['blocks']) : ($guestbook['blocks'] ? explode(',', trim($guestbook['blocks'])) : ''); if ($save) { // Errors $err->message_max_empty(t('ERROR_MESSAGE_MAX_EMPTY'), !$form['message_max'])->limit_empty(t('ERROR_ERROR_LIMIT_EMPTY'), !$form['limit'])->order_by_empty(t('ERROR_ORDER_BY_EMPTY'), $form['order_by']); if (!$err->count()) { Settings::update('guestbook'); Cache::clear('contact.txt'); $note->success(t('SAVED_SUCCESSFUL')); redirect(HREF . 'admin/modules/guestbook/settings'); } else { $note->error($err); } } else { $note->error(array(t('MODULE_SETTINGS'), t('REQUIRED_FIELDS'))); } $tpl = new PHPTAL('modules/guestbook/admin/settings.html'); $tpl->form = $form; $tpl->note = $note; $tpl->columns = Settings::formColumns(); $tpl->blocks = Settings::formBlocks(); echo $tpl->execute();
<?php // KioCMS - Kiofol Content Managment System // modules/contact/admin/index.php $kio->path['admin/modules/contact'] = t('Contact'); $note = new Notifier(); $err = new Error(); $save = $_POST['save'] ? true : false; $blocks = Settings::getBlocks(); if ($save) { $form = $_POST['form']; $form['blocks'] = array_diff(array_keys($blocks), (array) $_POST['blocks']); $err->receivers_empty($lang2['ERROR_RECEIVERS_EMPTY'], !$form['receivers']); $err->receivers_invalid($lang2['ERROR_RECEIVERS_INVALID'], $form['receivers'] && !preg_match('#^\\d+(, *\\d)*$#', $form['receivers'])); if (!$err->count()) { Settings::update('contact'); Cache::clear('contact.txt'); $info->positive(t('SAVED_SUCCESSFUL')); redirect(HREF . 'admin/modules/contact'); } else { $note->error($err); } } else { $form = $cfg->contact; $form['blocks'] = explode(', ', $cfg->contact['blocks']); $note->info(array($lang_admin['MODULE_SETTINGS'], $lang_system['REQUIRED'])); } $tpl = new PHPTAL('modules/contact/admin/settings.html'); $tpl->note = $note; $tpl->form = $form; $tpl->err = $err;
public function remove() { // Take the data we received and store it. Settings::update(['SettingsEvAccessToken' => '', 'SettingsEvUserId' => '', 'SettingsEvTokenExpires' => ''], Settings::get_settings_id()); return Redirect::to('/?evernote=removed'); }