function execute($options = array()) { $form_name = $this->udm->name; $form_method = isset($options['frmMethod']) ? $options['frmMethod'] : 'post'; $form_action = isset($options['frmAction']) ? $options['frmAction'] : null; $this->form = new HTML_QuickForm($form_name, $form_method, $form_action); $this->form->addElement('hidden', 'modin', 'Module Instance'); $this->form->addElement('submit', 'btnUdmSubmit', 'Submit'); $this->form->registerElementType('multiselect', 'HTML/QuickForm/select.php', 'HTML_QuickForm_select'); $this->form->registerElementType('radiogroup', 'HTML/QuickForm/group.php', 'HTML_QuickForm_group'); $this->form->registerElementType('checkgroup', 'HTML/QuickForm/group.php', 'HTML_QuickForm_group'); $this->form->registerElementType('wysiwyg', 'HTML/QuickForm/textarea.php', 'HTML_QuickForm_textarea'); $this->form->registerElementType('captcha', 'HTML/QuickForm/text.php', 'HTML_QuickForm_text'); $this->form->registerElementType('imagepicker', 'HTML/QuickForm/select.php', 'HTML_QuickForm_select'); $this->_build_core_fields(); $this->_build_fields(); $this->_build_plugins(); $this->_build_preview(); $opener =& $this->form->addElement('button', 'open_up', 'Expand All Fields'); $opener->updateAttributes(array('onclick' => 'change_all_udm_blocks( );')); $this->form->setDefaults($this->udm->_module_def); $this->form->setConstants(array('modin' => $this->udm->instance)); $tpl = new Savant2(); $tpl->addPath('template', $_SERVER['DOCUMENT_ROOT'] . '/include/templates/UserData'); $renderer = new HTML_QuickForm_Renderer_Savant(false, false, $tpl); $renderer->setTemplate('admin.php.tpl'); $this->form->accept($renderer); $this->udm->form = $this->form; }
* */ function preprint($val) { echo "<pre>\n"; print_r($val); echo "</pre>\n"; } error_reporting(E_ALL); require_once 'Savant2.php'; $conf = array('template_path' => 'templates', 'resource_path' => 'resources'); $savant = new Savant2($conf); echo "<h1>Paths to begin with</h1>\n"; preprint($savant->getPath('resource')); preprint($savant->getPath('template')); echo "<h1>Add a path</h1>\n"; $savant->addPath('resource', 'no/such/path'); preprint($savant->getPath('resource')); echo "<h1>Find an existing resource (non-default)</h1>\n"; $file = $savant->findFile('resource', 'Savant2_Plugin_cycle.php'); preprint($file); echo "<h1>Find an existing resource (default)</h1>\n"; $file = $savant->findFile('resource', 'Savant2_Plugin_input.php'); preprint($file); echo "<h1>Find a non-existent template</h1>\n"; $file = $savant->findFile('template', 'no_such_template.tpl.php'); if ($file) { preprint($file); } else { preprint("false or null"); }
} /***** end language block ****/ /* 7. load common libraries */ require AT_INCLUDE_PATH . 'classes/ContentManager.class.php'; /* content management class */ require_once AT_INCLUDE_PATH . 'lib/output.inc.php'; /* output functions */ if (!defined('AT_REDIRECT_LOADED')) { require_once AT_INCLUDE_PATH . 'classes/UrlRewrite/UrlParser.class.php'; /* pretty url tool */ } require AT_INCLUDE_PATH . 'classes/Savant2/Savant2.php'; /* for the theme and template management */ // set default template paths: $savant = new Savant2(); $savant->addPath('template', AT_INCLUDE_PATH . '../themes/default/'); /**************************************************/ /* load in message handler */ /**************************************************/ require AT_INCLUDE_PATH . 'classes/Message/Message.class.php'; $msg = new Message($savant); //if user has requested theme change, make the change here if ((isset($_POST['theme']) || isset($_POST['mobile_theme'])) && isset($_POST['submit'])) { //http://atutor.ca/atutor/mantis/view.php?id=4781 //Themes should be in the same folder, disallow '../' $newTheme = str_replace("../", "", $_POST['theme']); $newMobileTheme = str_replace("../", "", $_POST['mobile_theme']); if ($newTheme != $_POST['theme'] || $newMobileTheme != $_POST['mobile_theme']) { header('Location:' . AT_BASE_HREF . 'users/preferences.php'); exit; }
<?php error_reporting(E_ALL); require_once 'Savant2.php'; $Savant2 = new Savant2(); $Savant2->addPath('template', 'templates/'); $Savant2->addPath('resource', 'resources/'); $defaults = array('hideme' => null, 'mytext' => null, 'xbox' => null, 'picker' => null, 'picker2' => null, 'chooser' => null, 'myarea' => null); $values = array_merge($defaults, $_POST); $tmp = array(); if ($values['mytext'] == '') { // required $tmp[] = 'required'; } if (strlen($values['mytext']) > 5) { // max 5 chars $tmp[] = 'maxlen'; } if (preg_match('/[0-9]+/', $values['mytext'])) { // no digits $tmp[] = 'no_digits'; } if (count($tmp) == 0) { $valid = array('mytext' => true); } else { $valid = array('mytext' => $tmp); } $Savant2->assign('opts', array('one', 'two', 'three', 'four', 'five')); $Savant2->assign($values); $Savant2->assign('valid', $valid); $Savant2->display('form.tpl.php');
if (isset($_SESSION['prefs']['PREF_THEME']) && file_exists(TR_INCLUDE_PATH . '../themes/' . $_SESSION['prefs']['PREF_THEME']) && $_SESSION['user_id'] > 0) { if (!is_dir(TR_INCLUDE_PATH . '../themes/' . $_SESSION['prefs']['PREF_THEME'])) { $_SESSION['prefs']['PREF_THEME'] = 'default'; } else { //check if enabled $themesDAO = new ThemesDAO(); $row = $themesDAO->getByID($_SESSION['prefs']['PREF_THEME']); if ($row['status'] == 0) { // get default $_SESSION['prefs']['PREF_THEME'] = get_default_theme(); } } } else { $_SESSION['prefs']['PREF_THEME'] = get_default_theme(); } $savant->addPath('template', TR_INCLUDE_PATH . '../themes/' . $_SESSION['prefs']['PREF_THEME'] . '/'); require TR_INCLUDE_PATH . '../themes/' . $_SESSION['prefs']['PREF_THEME'] . '/theme.cfg.php'; require TR_INCLUDE_PATH . 'classes/Message/Message.class.php'; $msg = new Message($savant); /***** end of initialize theme and template management *****/ /***** 8. initialize user instance *****/ // used as global var if (isset($_SESSION['user_id']) && $_SESSION['user_id'] > 0) { // check if $_SESSION['user_id'] is valid include_once TR_INCLUDE_PATH . 'classes/DAO/UsersDAO.class.php'; $usersDAO = new UsersDAO(); $user = $usersDAO->getUserByID($_SESSION['user_id']); if (!$user) { // invalid user unset($_SESSION['user_id']); } else {