当前位置: 首页>>代码示例>>PHP>>正文


PHP HTML_QuickForm::setRequiredNote方法代码示例

本文整理汇总了PHP中HTML_QuickForm::setRequiredNote方法的典型用法代码示例。如果您正苦于以下问题:PHP HTML_QuickForm::setRequiredNote方法的具体用法?PHP HTML_QuickForm::setRequiredNote怎么用?PHP HTML_QuickForm::setRequiredNote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTML_QuickForm的用法示例。


在下文中一共展示了HTML_QuickForm::setRequiredNote方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: factory

 /**
  * factory 
  * 
  * Factory method
  * 
  * @param mixed $name name of the form
  * @param mixed $url  action url
  * 
  * @static
  * @access public
  * @return Object HTML_QuickForm Object
  */
 static function factory($name, $url)
 {
     $form = new HTML_QuickForm($name, 'post', $url);
     $star = '<span style="color: #ff0000">*</span> ';
     $form->setRequiredNote($star . _('denotes required field'));
     return $form;
 }
开发者ID:shupp,项目名称:toasteradmin,代码行数:19,代码来源:Form.php

示例2: form

 static function form()
 {
     try {
         $anonymous = Variable::get('anonymous_setup');
     } catch (NoSuchVariableException $e) {
         $anonymous = true;
     }
     if (!Base_AclCommon::is_user() && Base_User_LoginCommon::is_banned()) {
         return self::t('You have exceeded the number of allowed login attempts.');
     }
     require_once 'modules/Libs/QuickForm/requires.php';
     if (!Base_AclCommon::is_user() && !$anonymous) {
         Base_User_LoginCommon::autologin();
     }
     if (!Base_AclCommon::is_user() && !$anonymous) {
         $get = count($_GET) ? '?' . http_build_query($_GET) : '';
         $form = new HTML_QuickForm('loginform', 'post', $_SERVER['PHP_SELF'] . $get);
         $form->setRequiredNote('<span style="font-size:80%; color:#ff0000;">*</span><span style="font-size:80%;">' . self::t('denotes required field') . '</span>');
         $form->addElement('text', 'username', self::t('Username'));
         $form->addRule('username', 'Field required', 'required');
         $form->addElement('password', 'password', self::t('Password'));
         $form->addRule('password', 'Field required', 'required');
         // register and add a rule to check if user is banned
         $form->registerRule('check_user_banned', 'callback', 'rule_login_banned', 'Base_User_LoginCommon');
         $form->addRule('username', self::t('You have exceeded the number of allowed login attempts.'), 'check_user_banned');
         // register and add a rule to check if user and password exists
         $form->registerRule('check_login', 'callback', 'submit_login', 'Base_User_LoginCommon');
         $form->addRule(array('username', 'password'), self::t('Login or password incorrect'), 'check_login', $form);
         $form->addElement('submit', null, self::t('Login'));
         if ($form->validate()) {
             $user = $form->exportValue('username');
             Base_AclCommon::set_user(Base_UserCommon::get_user_id($user), true);
             // redirect below is used to better browser refresh behavior.
             header('Location: ' . $_SERVER['REQUEST_URI']);
         } else {
             return "<center>" . $form->toHtml() . "</center>";
         }
     }
 }
开发者ID:cretzu89,项目名称:EPESI,代码行数:39,代码来源:simple_login.php

示例3: getModule


//.........这里部分代码省略.........
                $fields = array("name" => $values['title'], "lessons_ID" => $values['lessons_ID'] ? $values['lessons_ID'] : $_SESSION['s_lessons_ID'], "description" => $values['description'], "registered" => $values['registered']);
                if (isset($_GET['edit_blog'])) {
                    if (eF_updateTableData("module_blogs", $fields, "id=" . $_GET['edit_blog'])) {
                        $message = _BLOGS_BLOGUPDATEDSUCCESSFULLY;
                        $message_type = 'success';
                    } else {
                        $message = _BLOGS_BLOGNOTUPDATED;
                        $message_type = 'failure';
                    }
                    eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=" . $message_type);
                } else {
                    $fields['users_LOGIN'] = $_SESSION['s_login'];
                    $fields['timestamp'] = time();
                    //pr($fields);
                    $new_id = eF_insertTableData("module_blogs", $fields);
                    if ($new_id) {
                        $message = _BLOGS_BLOGADDEDSUCCESSFULLY;
                        $message_type = 'success';
                        eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=" . $message_type . "&edit_blog=" . $new_id . "&tab=blog_creators");
                    } else {
                        $message = _BLOGS_BLOGNOTADDED;
                        $message_type = 'failure';
                        eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=" . $message_type);
                    }
                }
            }
            $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
            //Create a smarty renderer
            $renderer->setRequiredTemplate('{$html}{if $required}
				&nbsp;<span class = "formRequired">*</span>
			{/if}');
            $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
            //Set javascript error messages
            $form->setRequiredNote(_REQUIREDNOTE);
            $form->accept($renderer);
            //Assign this form to the renderer, so that corresponding template code is created
            $smarty->assign('T_BLOG_ADD_FORM', $renderer->toArray());
            //Assign the form to the template
            try {
                $lessonUsers = $currentLesson->getUsers();
                //Get all users that have this lesson
                unset($lessonUsers[$currentUser->login]);
                //Remove the current user from the list, he can't set parameters for his self!
                $users = $lessonUsers;
                $blogsCreators = eF_getTableDataFlat("module_blogs_users", "*", "blogs_ID=" . $_GET['edit_blog']);
                $creatorsAssoc = array_combine(array_values($blogsCreators['users_LOGIN']), array_values($blogsCreators['users_LOGIN']));
                $nonBlogsCreators = array_diff_key($users, $creatorsAssoc);
                $blogsCreatorsTemp = array_diff_key($users, $nonBlogsCreators);
                foreach ($users as $key => $user) {
                    in_array($key, array_values($blogsCreators['users_LOGIN'])) ? $users[$key]['blog_creator'] = true : ($users[$key]['blog_creator'] = false);
                }
                //pr($users);
                $roles = eF_getTableDataFlat("user_types", "name", "active=1 AND basic_user_type!='administrator'");
                //Get available roles
                if (sizeof($roles) > 0) {
                    $roles = array_combine($roles['name'], $roles['name']);
                    //Match keys with values, it's more practical this way
                }
                $roles = array_merge(array('student' => _STUDENT, 'professor' => _PROFESSOR), $roles);
                //Append basic user types to the beginning of the array
                //pr($roles);
                if (isset($_GET['ajax']) && $_GET['ajax'] == 'usersTable') {
                    isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'uint') ? $limit = $_GET['limit'] : ($limit = G_DEFAULT_TABLE_SIZE);
                    if (isset($_GET['sort']) && eF_checkParameter($_GET['sort'], 'text')) {
                        $sort = $_GET['sort'];
                        isset($_GET['order']) && $_GET['order'] == 'desc' ? $order = 'desc' : ($order = 'asc');
开发者ID:kaseya-university,项目名称:efront,代码行数:67,代码来源:module_blogs.class.php

示例4: getModule


//.........这里部分代码省略.........
                 }
             }
             $branchCourses = array();
             foreach ($result as $value) {
                 $branchCourses[$value['courses_ID']] = $value['courses_ID'];
             }
             foreach ($events as $key => $value) {
                 if (!isset($branchCourses[$key]) && !isset($userCourses[$key])) {
                     unset($events[$key]);
                 }
             }
         } else {
             foreach ($events as $key => $value) {
                 if (!isset($userCourses[$key])) {
                     unset($events[$key]);
                 }
             }
         }
     }
     if (!isset($_GET['course'])) {
         $dataSource = $events;
         $tableName = 'outlookInvitationsTable';
         isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'uint') ? $limit = $_GET['limit'] : ($limit = G_DEFAULT_TABLE_SIZE);
         if (isset($_GET['sort']) && eF_checkParameter($_GET['sort'], 'text')) {
             $sort = $_GET['sort'];
             isset($_GET['order']) && $_GET['order'] == 'desc' ? $order = 'desc' : ($order = 'asc');
         } else {
             $sort = 'login';
         }
         $dataSource = eF_multiSort($dataSource, $sort, $order);
         $smarty->assign("T_TABLE_SIZE", sizeof($dataSource));
         if (isset($_GET['filter'])) {
             $dataSource = eF_filterData($dataSource, $_GET['filter']);
         }
         if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) {
             isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0);
             $dataSource = array_slice($dataSource, $offset, $limit);
         }
         $smarty->assign("T_DATA_SOURCE", $dataSource);
     } else {
         $course = new EfrontCourse($_GET['course']);
         $form = new HTML_QuickForm("import_outlook_invitation_form", "post", $this->moduleBaseUrl . "&course={$course->course['id']}&add_event=1" . (isset($_GET['popup']) ? '&popup=1' : ''), "", null, true);
         $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
         //Register this rule for checking user input with our function, eF_checkParameter
         $form->addElement('text', 'email', _SENDER, 'class = "inputText"');
         $form->addElement('text', 'location', _LOCATION, 'class = "inputText"');
         $form->addElement('text', 'subject', _SUBJECT, 'class = "inputText"');
         $form->addElement('textarea', 'description', _DESCRIPTION, 'class = "inputTestTextarea" style = "width:80%;height:6em;"');
         //$form -> addElement('checkbox', 'calendar', _MODULE_OUTLOOK_INVITATION_CREATE_CALENDAR);
         //$form -> addElement('static', 'static', _MODULE_OUTLOOK_INVITATION_INFO);
         $form->addElement('submit', 'submit_event_all', _MODULE_OUTLOOK_INVITATION_SENDALL, 'class=flatButton');
         $form->addElement('submit', 'submit_event_new', _MODULE_OUTLOOK_INVITATION_SENDNEW, 'class=flatButton');
         if (empty($events[$course->course['id']])) {
             //new invitation
             $currentEvent = null;
             $form->setDefaults(array('email' => $currentUser->user['email'], 'subject' => 'Invitation to attend training: ' . $course->course['name']));
         } else {
             //existing invitation
             $currentEvent = $events[$course->course['id']];
             $form->setDefaults(array('email' => $currentEvent['email'], 'description' => $currentEvent['description'], 'subject' => $currentEvent['subject'], 'location' => $currentEvent['location']));
         }
         if ($form->isSubmitted() && $form->validate()) {
             try {
                 $message = "";
                 // Set info to store into database
                 $permanent_info = array("courses_ID" => $course->course['id'], "email" => $form->exportValue('email') ? $form->exportValue('email') : $GLOBALS['configuration']['system_email'], "location" => $form->exportValue('location'), "subject" => $form->exportValue('subject'), "description" => $form->exportValue('description'));
                 if ($currentEvent) {
                     $permanent_info['sequence'] = $currentEvent['sequence'] + 1;
                     eF_updateTableData("module_outlook_invitation", $permanent_info, "courses_ID={$course->course['id']}");
                 } else {
                     eF_insertTableData("module_outlook_invitation", $permanent_info);
                 }
                 if ($form->exportValue('submit_event_all')) {
                     $users = $course->getCourseUsers(array('active' => true, archive => false, 'return_objects' => false));
                     $recipients = array();
                     foreach ($users as $value) {
                         $recipients[] = $value['email'];
                     }
                     $this->sendInvitation($course->course['id'], $recipients);
                 }
                 //					$smarty->assign('T_RELOAD', true);
                 if (isset($_GET['popup'])) {
                     $this->setMessageVar(_OPERATIONCOMPLETEDSUCCESSFULLY, 'success');
                 } else {
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_OPERATIONCOMPLETEDSUCCESSFULLY) . "&message_type=success");
                 }
             } catch (Exception $e) {
                 $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
                 $this->setMessageVar($e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>', 'failure');
             }
         }
         $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
         $form->setRequiredNote(_REQUIREDNOTE);
         $smarty->assign('T_MODULE_OUTLOOK_INVITATION_FORM', $form->toArray());
     }
     $smarty->assign("T_MODULE_BASEDIR", $this->moduleBaseDir);
     $smarty->assign("T_MODULE_BASELINK", $this->moduleBaseLink);
     $smarty->assign("T_MODULE_BASEURL", $this->moduleBaseUrl);
     return true;
 }
开发者ID:kaseya-university,项目名称:efront,代码行数:101,代码来源:module_outlook_invitation.class.php

示例5: array

</head>
<body>
<?php 
set_include_path(get_include_path() . ";c:\\php\\pear");
require_once "HTML/QuickForm.php";
$form = new HTML_QuickForm('frmTest', 'post');
$form->addElement('text', 'Pseudo', 'Votre pseudo : ');
$form->addElement('text', 'Nom', 'Votre nom : ');
$form->addElement('text', 'Email', 'Votre adresse email : ');
$options = array('language' => 'fr', 'format' => 'dMY', 'minYear' => 2001, 'maxYear' => 2005);
$form->addElement('date', 'date', 'votre date de naissance : ', $options);
$form->addRule('Pseudo', 'Vous devez saisir un pseudo', 'required', '', 'client');
$form->addRule('Nom', 'Vous devez saisir un nom', 'required', '', 'client');
$form->addRule('Email', 'Vous devez saisir une adresse Email', 'required', '', 'client');
$form->addRule('Pseudo', 'Votre pseudo doit avoir entre 6 caractères et 10 caractères', 'rangelength', array(6, 10), 'client');
$form->addRule('Email', 'Vous devez saisir une adresse email valide', 'email', '', 'client');
$form->applyFilter('Nom', 'trim');
$form->applyFilter('Pseudo', 'trim');
$form->setRequiredNote('<span style="color: #ff0000">*</span> = champs obligatoires');
$form->setJsWarnings('Erreur de saisie', 'Veuillez corriger');
$form->addElement('reset', 'bouton_clear', 'Effacer');
$form->addElement('submit', 'bouton_effacer', 'Envoyer');
if ($form->validate()) {
    echo "Toutes les règles sont respectées<br>";
} else {
    $form->display();
}
?>
</body>
</html>
开发者ID:BackupTheBerlios,项目名称:thinkedit-svn,代码行数:30,代码来源:quickform.php

示例6: getSmartyTpl

 public function getSmartyTpl()
 {
     $smarty = $this->getSmartyVar();
     $currentUser = $this->getCurrentUser();
     $currentLesson = $this->getCurrentLesson();
     $currentLessonID = $currentLesson->lesson['id'];
     if ($currentUser->getRole($this->getCurrentLesson()) == 'professor' || $currentUser->getRole($this->getCurrentLesson()) == 'student') {
         // XXX
         $workbookLessonName = _WORKBOOK_NAME . ' [' . $this->getWorkbookLessonName($currentLessonID) . ']';
         $smarty->assign("T_WORKBOOK_LESSON_NAME", $workbookLessonName);
         $lessonQuestions = $this->getLessonQuestions($currentLessonID);
         $workbookLessons = $this->isWorkbookInstalledByUser($currentUser, $currentUser->getRole($this->getCurrentLesson()), $currentLessonID);
         $workbookItems = $this->getWorkbookItems($currentLessonID);
         $nonOptionalQuestionsNr = $this->getNonOptionalQuestionsNr($workbookItems);
         if ($nonOptionalQuestionsNr != 0) {
             $questionPercentage = (double) (100 / $nonOptionalQuestionsNr);
             $questionPercentage = round($questionPercentage, 2);
         }
         $isWorkbookPublished = $this->isWorkbookPublished($currentLessonID);
     }
     if ($currentUser->getRole($this->getCurrentLesson()) == 'student') {
         $workbookSettings = $this->getWorkbookSettings($currentLessonID);
         $smarty->assign("T_WORKBOOK_SETTINGS", $workbookSettings);
     }
     $smarty->assign("T_WORKBOOK_BASEURL", $this->moduleBaseUrl);
     $smarty->assign("T_WORKBOOK_BASELINK", $this->moduleBaseLink);
     global $popup;
     isset($popup) && $popup == 1 ? $popup_ = '&popup=1' : ($popup_ = '');
     if (isset($_REQUEST['question_preview']) && $_REQUEST['question_preview'] == '1' && isset($_REQUEST['question_id']) && eF_checkParameter($_REQUEST['question_id'], 'id')) {
         $id = $_REQUEST['question_id'];
         if (!in_array($id, array_keys($lessonQuestions))) {
             // reused item
             $reusedQuestion = $this->getReusedQuestionDetails($id);
             $type = $reusedQuestion['type'];
         } else {
             $type = $lessonQuestions[$id]['type'];
         }
         echo $this->questionToHtml($id, $type);
         exit;
     }
     if (isset($_REQUEST['get_progress']) && $_REQUEST['get_progress'] == '1') {
         $isWorkbookCompleted = $this->isWorkbookCompleted($currentUser->user['login'], $currentLessonID, array_keys($workbookItems), $nonOptionalQuestionsNr);
         $studentProgress = $this->getStudentProgress($currentUser->user['login'], $currentLessonID);
         if ($isWorkbookCompleted['is_completed'] == 1) {
             $unitToComplete = $workbookSettings['unit_to_complete'];
             $result = eF_updateTableData('module_workbook_progress', array('completion_date' => time()), "lessons_ID='" . $currentLessonID . "' AND users_LOGIN='" . $currentUser->user['login'] . "'");
             if ($unitToComplete != -1) {
                 $currentUser->setSeenUnit($unitToComplete, $currentLessonID, true);
             }
         }
         echo $studentProgress . '-' . $isWorkbookCompleted['id'];
         exit;
     }
     if (isset($_GET['edit_settings']) && $_GET['edit_settings'] == '1') {
         if ($_SESSION['s_type'] != 'professor') {
             $message = _WORKBOOK_NOACCESS;
             $message_type = 'failure';
             $this->setMessageVar(urlencode($message), $message_type);
         }
         $content = new EfrontContentTree($currentLessonID);
         $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($content->tree), RecursiveIteratorIterator::SELF_FIRST), array('ctg_type' => 'theory'));
         $contentOptions = $content->toHTMLSelectOptions($iterator);
         $contentOptions = array(-1 => '-------------') + $contentOptions;
         $workbookSettings = $this->getWorkbookSettings($currentLessonID);
         if ($isWorkbookPublished == 1) {
             $contentOptions[$workbookSettings['unit_to_complete']] = str_replace('&nbsp;', '', $contentOptions[$workbookSettings['unit_to_complete']]);
             $contentOptions[$workbookSettings['unit_to_complete']] = str_replace('&raquo;', '', $contentOptions[$workbookSettings['unit_to_complete']]);
         }
         $form = new HTML_QuickForm("edit_settings_form", "post", $this->moduleBaseUrl . "&edit_settings=1", "", null, true);
         $form->addElement('text', 'lesson_name', _WORKBOOK_LESSON_NAME, 'class="inputText"');
         $form->addRule('lesson_name', _THEFIELD . ' "' . _WORKBOOK_LESSON_NAME . '" ' . _ISMANDATORY, 'required', null, 'client');
         $form->addElement('advcheckbox', 'allow_print', _WORKBOOK_ALLOW_PRINT, null, 'class="inputCheckBox"', array(0, 1));
         $form->addElement('advcheckbox', 'allow_export', _WORKBOOK_ALLOW_EXPORT, null, 'class="inputCheckBox"', array(0, 1));
         $form->addElement('advcheckbox', 'edit_answers', _WORKBOOK_EDIT_ANSWERS, null, 'class="inputCheckBox"', array(0, 1));
         $form->addElement('select', 'unit_to_complete', _WORKBOOK_UNIT_TO_COMPLETE, $contentOptions);
         $form->addElement('submit', 'submit', _UPDATE, 'class="flatButton"');
         if ($isWorkbookPublished == 1) {
             $form->freeze('unit_to_complete');
         }
         $form->setDefaults($workbookSettings);
         if ($form->isSubmitted() && $form->validate()) {
             $values = $form->exportValues();
             $fields = array("lesson_name" => $values['lesson_name'], "allow_print" => $values['allow_print'], "allow_export" => $values['allow_export'], "edit_answers" => $values['edit_answers'], "unit_to_complete" => $values['unit_to_complete']);
             if (eF_updateTableData("module_workbook_settings", $fields, "id=" . $workbookSettings['id'])) {
                 $smarty->assign("T_WORKBOOK_MESSAGE", _WORKBOOK_SETTINGS_SUCCESSFULLY_EDITED);
                 $smarty->assign("T_WORKBOOK_MESSAGE_TYPE", 'success');
             } else {
                 $smarty->assign("T_WORKBOOK_MESSAGE", _WORKBOOK_SETTINGS_EDIT_PROBLEM);
                 $smarty->assign("T_WORKBOOK_MESSAGE_TYPE", 'failure');
             }
         }
         $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
         $renderer->setRequiredTemplate('{$html}{if $required}&nbsp;<span class="formRequired">*</span>{/if}');
         $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
         $form->setRequiredNote(_REQUIREDNOTE);
         $form->accept($renderer);
         $smarty->assign('T_WORKBOOK_EDIT_SETTINGS_FORM', $renderer->toArray());
     }
     if (isset($_GET['reuse_item']) && $_GET['reuse_item'] == '1') {
         if ($_SESSION['s_type'] != 'professor') {
//.........这里部分代码省略.........
开发者ID:kaseya-university,项目名称:efront,代码行数:101,代码来源:module_workbook.class.php

示例7: array

 $form->addElement('select', 'engine', __('Database engine'), array('postgres' => 'PostgreSQL', 'mysqlt' => 'MySQL'));
 $form->addRule('engine', __('Field required'), 'required');
 $form->addElement('text', 'user', __('Database server user'));
 $form->addRule('user', __('Field required'), 'required');
 $form->addElement('password', 'password', __('Database server password'));
 $form->addRule('password', __('Field required'), 'required');
 $form->addElement('text', 'db', __('Database name'));
 $form->addRule('db', __('Field required'), 'required');
 $create_db_warn_msg = __('WARNING: Make sure you have CREATE access level to do this!');
 $form->addElement('select', 'newdb', __('Create new database'), array(0 => __('No'), 1 => __('Yes')), array('onChange' => 'if(this.value==1) alert("' . $create_db_warn_msg . '","warning");'));
 $form->addRule('newdb', __('Field required'), 'required');
 $form->addElement('header', null, __('Other settings'));
 $form->addElement('select', 'direction', __('Text direction'), array(0 => __('Left to Right'), 1 => __('Right to Left')));
 $form->addElement('submit', 'submit', __('Next'));
 $form->setDefaults(array('engine' => 'mysqlt', 'db' => 'epesi', 'host' => 'localhost'));
 $form->setRequiredNote('<span class="required_note_star">*</span> <span class="required_note">' . __('denotes required field') . '</span>');
 if (file_exists($fast_install_filename)) {
     include $fast_install_filename;
     if (isset($CONFIG) && is_array($CONFIG)) {
         $txt = __('Some fields were filled to make installation easier.');
         print '<div style="text-align:center"><p style="width: 250px;margin-left: auto;margin-right: auto;">' . $txt . '</p></div>';
         foreach ($CONFIG as $key => $value) {
             $form->setDefaults(array($key => $value));
             $form->getElement($key)->freeze();
         }
     }
 }
 $required_note_text = __('denotes required field');
 $form->setRequiredNote('<span class="required_note_star">*</span> <span class="required_note">' . $required_note_text . '</span>');
 $form->addElement('html', '<tr><td colspan=2><br /><b>' . __('Any existing tables will be dropped!') . '</b><br />' . __('The database will be populated with data.') . '<br />' . __('This operation can take several minutes.') . '</td></tr>');
 if ($form->validate()) {
开发者ID:cretzu89,项目名称:EPESI,代码行数:31,代码来源:setup.php

示例8: array

$attrsTextLong = array("size" => "50");
$form = new HTML_QuickForm('Form', 'post', '?p=' . $p);
$form->addElement('header', 'title', _('Centreon Nagvis configuration'));
$form->addElement('header', 'information', _('Nagvis information'));
$form->addElement('header', 'information2', _('Nagvis authentication'));
$form->addElement('text', 'centreon_nagvis_uri', _('Nagvis URI'), $attrsTextLong);
$form->addElement('text', 'centreon_nagvis_path', _('Nagvis Path'), $attrsTextLong);
$form->addElement('select', 'centreon_nagvis_auth', _("Single NagVis user auth or Centreon user auth ? "), array("single" => "Single User", "centreon" => "Centreon User"));
$form->addElement('text', 'centreon_nagvis_single_user', _('Nagvis user name'), $attrsTextLong);
$form->addRule('centreon_nagvis_uri', _('Compulsory field'), 'required');
$form->addRule('centreon_nagvis_path', _('Compulsory field'), 'required');
$form->addRule('centreon_nagvis_auth', _('Compulsory field'), 'required');
$form->addRule('centreon_nagvis_single_user', _('Compulsory field'), 'required');
$form->registerRule('exist', 'callback', 'nagvisInstall');
$form->addRule('centreon_nagvis_path', _('Directory does not exist'), 'exist');
$form->setRequiredNote("<font style='color: red;'>*</font>" . _(" Required fields"));
$form->addElement('submit', 'submitC', _("Save"));
$form->addElement('reset', 'reset', _("Reset"));
if ($form->validate()) {
    $values = $form->getSubmitValues();
    $queryInsert = 'UPDATE `options` SET `value` = "%s" WHERE `key` = "%s"';
    $pearDB->query(sprintf($queryInsert, $pearDB->escape($values['centreon_nagvis_uri']), 'centreon_nagvis_uri'));
    $pearDB->query(sprintf($queryInsert, $pearDB->escape($values['centreon_nagvis_path']), 'centreon_nagvis_path'));
    $pearDB->query(sprintf($queryInsert, $pearDB->escape($values['centreon_nagvis_auth']), 'centreon_nagvis_auth'));
    $pearDB->query(sprintf($queryInsert, $pearDB->escape($values['centreon_nagvis_single_user']), 'centreon_nagvis_single_user'));
}
/*
 * Get options
 */
if (!isset($values)) {
    $values = array();
开发者ID:chinaares,项目名称:centreon-nagvis,代码行数:31,代码来源:nagvis-config.php

示例9: __construct

    public function __construct()
    {
        parent::__construct('batch_add_authors');
        if ($this->loginError) {
            return;
        }
        $this->use_mootools = true;
        $form = new HTML_QuickForm('batch_add', 'post', null, '_self', 'multipart/form-data');
        $tooltip = <<<TOOLTIP_END
New Authors::A semi-colon separated list of author names. Names can be in the following
formats:
&lt;ul&gt;
  &lt;li&gt;fist last&lt;/li&gt;
  &lt;li&gt;fist initials last&lt;/li&gt;
  &lt;li&gt;last, first&lt;/li&gt;
  &lt;li&gt;last, first initials&lt;/li&gt;
&lt;/ul&gt;
TOOLTIP_END;
        $form->addGroup(array(HTML_QuickForm::createElement('textarea', 'new_authors', null, array('cols' => 60, 'rows' => 10)), HTML_QuickForm::createElement('static', 'kwgroup_help', null, '<span class="small">Name format is: GIVEN_NAME1 [GIVEN_NAME2 .. etc.] LAST_NAME. Separate using semi-colons (;)</span>')), 'new_auth_group', "<span class=\"Tips1\" title=\"{$tooltip}\">New Authors:</span>", '<br/>', false);
        $form->addGroup(array(HTML_QuickForm::createElement('submit', 'submit', 'Add New Authors'), HTML_QuickForm::createElement('button', 'cancel', 'Cancel', array('onclick' => 'history.back()'))), null, null, '&nbsp;', false);
        if ($form->validate()) {
            $values = $form->exportValues();
            $values['new_authors'] = preg_replace("/;\\s*;/", ';', $values['new_authors']);
            $new_authors = preg_split('/;\\s*/', $values['new_authors']);
            $fl_auth_list = pdAuthorList::create($this->db, null, null, true);
            $in_db_auths = array_intersect($fl_auth_list, $new_authors);
            $new_auths = array_diff($new_authors, $fl_auth_list);
            foreach ($new_auths as $auth_name) {
                $auth = new pdAuthor();
                $auth->nameSet($auth_name);
                $auth->dbSave($this->db);
                unset($auth);
            }
            if (count($in_db_auths) > 0) {
                echo 'These authors were already in the database:<ul>';
                foreach ($in_db_auths as $auth_name) {
                    echo '<li>', $auth_name, '</li>';
                }
            }
            if (count($new_auths) > 0) {
                if (count($in_db_auths) > 0) {
                    echo '</ul>', 'Only these authors were added to the database:', '<ul>';
                } else {
                    echo 'These authors were added to the database:<ul>';
                }
                foreach ($new_auths as $auth_name) {
                    echo '<li>', $auth_name, '</li>';
                }
                echo '</ul>';
            } else {
                echo '</ul>No authors were added to the database.';
            }
        } else {
            echo '<h2>Batch Add Authors</h2>';
            $renderer =& $form->defaultRenderer();
            $form->setRequiredNote('<font color="#FF0000">*</font> shows the required fields.');
            $form->accept($renderer);
            $this->form =& $form;
            $this->renderer =& $renderer;
            $this->js = <<<JS_END
window.addEvent('domready', function() {
                    var Tips1 = new Tips(\$\$('.Tips1'));
                });
JS_END;
        }
    }
开发者ID:papersdb,项目名称:papersdb,代码行数:66,代码来源:batch_add_authors.php

示例10: getModule

 public function getModule()
 {
     $smarty = $this->getSmartyVar();
     $currentLesson = $this->getCurrentLesson();
     $currentUser = $this->getCurrentUser();
     try {
         $currentContent = new EfrontContentTree($_SESSION['s_lessons_ID']);
         //Initialize content
     } catch (Exception $e) {
         $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
         $message = _ERRORLOADINGCONTENT . ": " . $_SESSION['s_lessons_ID'] . ": " . $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
     }
     //pr($currentUser);exit;
     $roles = EfrontUser::getRoles();
     //pr($roles);
     if ($roles[$currentUser->lessons[$_SESSION['s_lessons_ID']]] == "professor") {
         if (isset($_GET['view_deck']) && eF_checkParameter($_GET['view_deck'], 'id')) {
             $deck = $currentContent->seekNode($_GET['view_deck']);
             $questions = $deck->getQuestions(true);
             $cards = array();
             $possibleCardsIds = array();
             foreach ($questions as $key => $value) {
                 if ($value->question['type'] == 'empty_spaces') {
                     $cards[] = $value;
                     $possibleCardsIds[] = $value->question['id'];
                 }
             }
             $questions = $cards;
             //pr($questions);
             foreach ($questions as $qid => $question) {
                 $questions[$qid]->question['text'] = strip_tags($question->question['text']);
                 //If we ommit this line, then the questions list is html formatted, images are displayed etc, which is *not* the intended behaviour
                 //$questions[$qid]->question['answer']           = unserialize($question->question['answer']);
             }
             $res = eF_getTableData("module_flashcards_decks", "cards,options", "content_ID=" . $_GET['view_deck']);
             $resCards = unserialize($res[0]['cards']);
             $smarty->assign("T_FLASHCARDS_DECK_CARDS", $resCards);
             $post_target = $this->moduleBaseUrl . '&view_deck=' . $_GET['view_deck'] . "&tab=options";
             //Create form elements
             $form = new HTML_QuickForm("deck_options", "post", $post_target, "", null, true);
             $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
             $form->addElement('advcheckbox', 'active', _FLASHCARDS_ACTIVE, null, 'class = "inputCheckbox"', array(0, 1));
             $form->addElement("text", "low", _LOW, 'size = "5"');
             $form->addElement("text", "medium", _MEDIUM, 'size = "5"');
             $form->addElement("text", "hard", _HIGH, 'size = "5"');
             $form->addElement("text", "very_hard", _VERYHIGH, 'size = "5"');
             $form->addRule('low', _INVALIDFIELDDATA . ":" . _LOW, 'checkParameter', 'id');
             $form->addRule('medium', _INVALIDFIELDDATA . ":" . _MEDIUM, 'checkParameter', 'id');
             $form->addRule('hard', _INVALIDFIELDDATA . ":" . _HIGH, 'checkParameter', 'id');
             $form->addRule('very_hard', _INVALIDFIELDDATA . ":" . _VERYHIGH, 'checkParameter', 'id');
             $form->addElement('advcheckbox', 'answer_first', _FLASHCARDS_SHOWANSWERFIRST, null, 'class = "inputCheckbox"', array(0, 1));
             $form->addElement('advcheckbox', 'shuffle', _FLASHCARDS_SHUFFLECARDS, null, 'class = "inputCheckbox"', array(0, 1));
             $form->addElement('advcheckbox', 'display_mastery', _FLASHCARDS_DISPLAYMASTERY, null, 'class = "inputCheckbox"', array(0, 1));
             $form->addElement('advcheckbox', 'wrong', _FLASHCARDS_WRONGREDUCES, null, 'class = "inputCheckbox"', array(0, 1));
             $form->addElement('advcheckbox', 'show_count', _FLASHCARDS_SHOWSUCCESSCOUNT, null, 'class = "inputCheckbox"', array(0, 1));
             $form->addElement('advcheckbox', 'show_explanation', _FLASHCARDS_SHOWEXPLANATION, null, 'class = "inputCheckbox"', array(0, 1));
             $form->addElement('submit', 'submit_options', _SAVECHANGES, 'class = "flatButton"');
             //The submit content button
             $options = unserialize($res[0]['options']);
             $form->setDefaults(array('active' => $options['active'], 'answer_first' => $options['answer_first'], 'shuffle' => $options['shuffle'], 'display_mastery' => $options['display_mastery'], 'wrong' => $options['wrong'], 'show_count' => $options['show_count'], 'show_explanation' => $options['show_explanation'], 'low' => $options['low'] == "" ? 1 : $options['low'], 'medium' => $options['medium'] == "" ? 2 : $options['medium'], 'hard' => $options['hard'] == "" ? 4 : $options['hard'], 'very_hard' => $options['very_hard'] == "" ? 6 : $options['very_hard']));
             if ($form->isSubmitted() && $form->validate()) {
                 //If the form is submitted and validated
                 $values = $form->exportValues();
                 unset($values['submit_options']);
                 $options = serialize($values);
                 if (sizeof($res) != 0) {
                     $ok = eF_updateTableData("module_flashcards_decks", array('options' => $options), "content_ID=" . $_GET['view_deck']);
                 } else {
                     $fields = array('content_ID' => $_GET['view_deck'], 'options' => $options);
                     $ok = eF_insertTableData("module_flashcards_decks", $fields);
                 }
                 if ($ok !== false) {
                     $message = _FLASHCARDS_SUCCESSFULLY;
                     $message_type = 'success';
                 } else {
                     $message = _FLASHCARDS_PROBLEMOCCURED;
                     $message_type = 'failure';
                 }
                 eF_redirect("" . $this->moduleBaseUrl . "&view_deck=" . $_GET['view_deck'] . "&tab=options&message=" . $message . "&message_type=" . $message_type);
             }
             $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
             //Create a smarty renderer
             $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
             //Set javascript error messages
             $form->setRequiredNote(_REQUIREDNOTE);
             $form->accept($renderer);
             //Assign this form to the renderer, so that corresponding template code is created
             $smarty->assign('T_FLASHCARDS_OPTIONS', $renderer->toArray());
             //Assign the form to the template
             if (isset($_GET['postAjaxRequest'])) {
                 try {
                     $result = eF_getTableData("module_flashcards_decks", "cards", "content_ID=" . $_GET['view_deck']);
                     //pr($result);exit;
                     $cardsArray = unserialize($result[0]['cards']);
                     if (isset($_GET['id']) && eF_checkParameter($_GET['id'], 'id')) {
                         if (!in_array($_GET['id'], array_values($cardsArray))) {
                             $cardsArray[] = $_GET['id'];
                             $cards = serialize($cardsArray);
                             if (sizeof($result) != 0) {
                                 $fields = array('cards' => $cards);
//.........这里部分代码省略.........
开发者ID:bqq1986,项目名称:efront,代码行数:101,代码来源:module_flashcards.class.php

示例11: elseif

             }
             echo $res;
         } elseif ($type == 'form') {
             // template d'un formulaire bazar
             $url = $this->href('json', $this->GetPageTag(), 'demand=save_entry');
             //contruction du squelette du formulaire
             $formtemplate = new HTML_QuickForm('formulaire', 'post', preg_replace('/&amp;/', '&', $url));
             $squelette =& $formtemplate->defaultRenderer();
             $squelette->setFormTemplate('<form {attributes} class="form-horizontal content-padded list-spacer" ' . 'novalidate="novalidate">' . "\n" . '{content}' . "\n" . '</form>');
             $squelette->setElementTemplate('<div class="control-group form-group">' . "\n" . '<div class="control-label col-xs-3">' . "\n" . '<!-- BEGIN required --><span class="symbole_obligatoire">*</span> <!-- END required -->' . "\n" . '{label} :</div>' . "\n" . '<div class="controls col-xs-8"> ' . "\n" . '{element}' . "\n" . '<!-- BEGIN error -->' . '<span class="alert alert-error alert-danger">{error}</span>' . '<!-- END error -->' . "\n" . '</div>' . "\n" . '</div>' . "\n");
             $squelette->setElementTemplate('<div class="control-group form-group">' . "\n" . '<div class="liste_a_cocher"><strong>{label}&nbsp;{element}</strong>' . "\n" . '<!-- BEGIN required -->' . '<span class="symbole_obligatoire">&nbsp;*</span>' . '<!-- END required -->' . "\n" . '</div>' . "\n" . '</div>' . "\n", 'accept_condition');
             $squelette->setElementTemplate('<div class="form-actions">{label}{element}</div>' . "\n", 'groupe_boutons');
             $squelette->setElementTemplate('<div class="control-group form-group">' . "\n" . '<div class="control-label col-xs-3">' . "\n" . '{label} :</div>' . "\n" . '<div class="controls col-xs-8"> ' . "\n" . '{element}' . "\n" . '</div>' . "\n" . '</div>', 'select');
             $squelette->setRequiredNoteTemplate("<div class=\"symbole_obligatoire\">* {requiredNote}</div>\n");
             //Traduction de champs requis
             $formtemplate->setRequiredNote(_t('BAZ_CHAMPS_REQUIS'));
             $formtemplate->setJsWarnings(_t('BAZ_ERREUR_SAISIE'), _t('BAZ_VEUILLEZ_CORRIGER'));
             //antispam
             $formtemplate->addElement('hidden', 'antispam', 1);
             // generation du formulaire
             $form = baz_afficher_formulaire_fiche('saisie', $formtemplate, $url, '', true);
             $form = preg_replace('~<div class="form-actions">.*</div>~Ui', "\n" . '<a href="#" class="btn btn-block btn-positive btn-save">' . _t('BAZ_SAVE') . '</a>', $form);
             $form = preg_replace('~<div id="map".*>~Ui', "\n" . '<div id="map">', $form);
             echo json_encode(array('html' => $form));
         }
     }
     break;
 case "forms":
     // les formulaires bazar
     $formval = baz_valeurs_formulaire($form);
     // si un seul formulaire, on cree un tableau à une entrée
开发者ID:YesWiki,项目名称:yeswiki-sandstorm,代码行数:31,代码来源:json.php

示例12: __construct


//.........这里部分代码省略.........
        $this->registerElementType('date_time_picker', $dir . 'Element/DateTimePicker.php', 'DateTimePicker');
        $this->registerElementType('date_picker', $dir . 'Element/DatePicker.php', 'DatePicker');
        $this->registerElementType('datepicker', $dir . 'Element/datepicker_old.php', 'HTML_QuickForm_datepicker');
        $this->registerElementType('datepickerdate', $dir . 'Element/datepickerdate.php', 'HTML_QuickForm_datepickerdate');
        $this->registerElementType('receivers', $dir . 'Element/receivers.php', 'HTML_QuickForm_receivers');
        $this->registerElementType('select_language', $dir . 'Element/select_language.php', 'HTML_QuickForm_Select_Language');
        $this->registerElementType('select_ajax', $dir . 'Element/select_ajax.php', 'HTML_QuickForm_Select_Ajax');
        $this->registerElementType('select_theme', $dir . 'Element/select_theme.php', 'HTML_QuickForm_Select_Theme');
        $this->registerElementType('style_submit_button', $dir . 'Element/style_submit_button.php', 'HTML_QuickForm_stylesubmitbutton');
        $this->registerElementType('style_reset_button', $dir . 'Element/style_reset_button.php', 'HTML_QuickForm_styleresetbutton');
        $this->registerElementType('button', $dir . 'Element/style_submit_button.php', 'HTML_QuickForm_stylesubmitbutton');
        $this->registerElementType('captcha', 'HTML/QuickForm/CAPTCHA.php', 'HTML_QuickForm_CAPTCHA');
        $this->registerElementType('CAPTCHA_Image', 'HTML/QuickForm/CAPTCHA/Image.php', 'HTML_QuickForm_CAPTCHA_Image');
        $this->registerRule('date', null, 'HTML_QuickForm_Rule_Date', $dir . 'Rule/Date.php');
        $this->registerRule('datetime', null, 'DateTimeRule', $dir . 'Rule/DateTimeRule.php');
        $this->registerRule('date_compare', null, 'HTML_QuickForm_Rule_DateCompare', $dir . 'Rule/DateCompare.php');
        $this->registerRule('html', null, 'HTML_QuickForm_Rule_HTML', $dir . 'Rule/HTML.php');
        $this->registerRule('username_available', null, 'HTML_QuickForm_Rule_UsernameAvailable', $dir . 'Rule/UsernameAvailable.php');
        $this->registerRule('username', null, 'HTML_QuickForm_Rule_Username', $dir . 'Rule/Username.php');
        $this->registerRule('filetype', null, 'HTML_QuickForm_Rule_Filetype', $dir . 'Rule/Filetype.php');
        $this->registerRule('multiple_required', 'required', 'HTML_QuickForm_Rule_MultipleRequired', $dir . 'Rule/MultipleRequired.php');
        $this->registerRule('url', null, 'HTML_QuickForm_Rule_Url', $dir . 'Rule/Url.php');
        $this->registerRule('mobile_phone_number', null, 'HTML_QuickForm_Rule_Mobile_Phone_Number', $dir . 'Rule/MobilePhoneNumber.php');
        $this->registerRule('compare_fields', null, 'HTML_QuickForm_Compare_Fields', $dir . 'Rule/CompareFields.php');
        $this->registerRule('CAPTCHA', 'rule', 'HTML_QuickForm_Rule_CAPTCHA', 'HTML/QuickForm/Rule/CAPTCHA.php');
        // Modify the default templates
        $renderer =& $this->defaultRenderer();
        //Form template
        $form_template = '<form{attributes}>
<fieldset>
	{content}
	<div class="clear"></div>
</fieldset>
{hidden}
</form>';
        $renderer->setFormTemplate($form_template);
        //Element template
        if (isset($attributes['class']) && $attributes['class'] == 'well form-inline') {
            $element_template = ' {label}  {element} ';
            $renderer->setElementTemplate($element_template);
        } elseif (isset($attributes['class']) && $attributes['class'] == 'form-search') {
            $element_template = ' {label}  {element} ';
            $renderer->setElementTemplate($element_template);
        } else {
            $element_template = '
            <div class="control-group {error_class}">
                <label class="control-label" {label-for}>
                    <!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
                    {label}
                </label>
                <div class="controls">
                    {element}

                    <!-- BEGIN label_3 -->
                        {label_3}
                    <!-- END label_3 -->

                    <!-- BEGIN label_2 -->
                        <p class="help-block">{label_2}</p>
                    <!-- END label_2 -->

                    <!-- BEGIN error -->
                        <span class="help-inline">{error}</span>
                    <!-- END error -->
                </div>
            </div>';
            $renderer->setElementTemplate($element_template);
            //Display a gray div in the buttons
            $button_element_template_simple = '<div class="form-actions">{label} {element}</div>';
            $renderer->setElementTemplate($button_element_template_simple, 'submit_in_actions');
            //Display a gray div in the buttons + makes the button available when scrolling
            $button_element_template_in_bottom = '<div class="form-actions bottom_actions bg-form">{label} {element}</div>';
            $renderer->setElementTemplate($button_element_template_in_bottom, 'submit_fixed_in_bottom');
            //When you want to group buttons use something like this
            /* $group = array();
                $group[] = $form->createElement('button', 'mark_all', get_lang('MarkAll'));
                $group[] = $form->createElement('button', 'unmark_all', get_lang('UnmarkAll'));
                $form->addGroup($group, 'buttons_in_action');
               */
            $renderer->setElementTemplate($button_element_template_simple, 'buttons_in_action');
            $button_element_template_simple_right = '<div class="form-actions"> <div class="pull-right">{label} {element}</div></div>';
            $renderer->setElementTemplate($button_element_template_simple_right, 'buttons_in_action_right');
            /*
             $renderer->setElementTemplate($button_element_template, 'submit_button');
             $renderer->setElementTemplate($button_element_template, 'submit');
             $renderer->setElementTemplate($button_element_template, 'button');
            *
            */
        }
        //Set Header template
        $renderer->setHeaderTemplate('<legend>{header}</legend>');
        //Set required field template
        HTML_QuickForm::setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>');
        $required_note_template = <<<EOT
\t<div class="control-group">
\t\t<div class="controls">{requiredNote}</div>
\t</div>
EOT;
        $renderer->setRequiredNoteTemplate($required_note_template);
    }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:101,代码来源:FormValidator.class.php

示例13: header

                EfrontStats::createViews();
                if (!isset($_GET['unattended'])) {
                    header("location:" . $_SERVER['PHP_SELF'] . "?finish=1");
                    exit;
                }
            }
        } catch (Exception $e) {
            Installation::handleInstallationExceptions($e);
        }
    }
    $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
    $renderer->setRequiredTemplate('{$html}{if $required}
            &nbsp;<span class = "formRequired">*</span>
        {/if}');
    $form->setJsWarnings('The following errors occured:', 'Please correct the above errors');
    $form->setRequiredNote('* Denotes mandatory fields');
    $form->accept($renderer);
    $smarty->assign('T_DATABASE_FORM', $renderer->toArray());
}
if (isset($_GET['finish']) || isset($_GET['unattended'])) {
    if (isset($_GET['unattended'])) {
        if ($_GET['ajax']) {
            echo json_encode(array('status' => 1, 'message' => 'Successfully completed Unattended upgrade'));
            EfrontSystem::unlockSystem();
        } else {
            header("location:" . G_SERVERNAME . "index.php?delete_install=1");
        }
    } else {
        session_destroy();
        unset($_SESSION);
    }
开发者ID:jiangjunt,项目名称:efront_open_source,代码行数:31,代码来源:install.php

示例14: getModule

 public function getModule()
 {
     $smarty = $this->getSmartyVar();
     global $load_editor;
     $load_editor = true;
     $current_user = $this->getCurrentUser();
     $smarty->assign("T_MODULE_CURRENT_USER", $current_user->getType());
     $form = new HTML_QuickForm("module_mail_form", "post", $this->moduleBaseUrl, "", "id = 'module_mail_form'");
     $form->addElement('hidden', 'recipients', $_GET['rec']);
     $form->addElement('text', 'subject', _SUBJECT, 'class = "inputText" style = "width:400px"');
     $form->addElement('textarea', 'body', _BODY, 'class = "simpleEditor" style = "width:100%;height:200px"');
     $form->addElement('checkbox', 'email', _SENDASEMAILALSO, null, 'id = "send_as_email" class = "inputCheckBox"');
     $form->addRule('subject', _THEFIELD . ' "' . _SUBJECT . '" ' . _ISMANDATORY, 'required', null, 'client');
     $form->addRule('recipients', _THEFIELD . ' "' . _RECIPIENTS . '" ' . _ISMANDATORY, 'required', null, 'client');
     $form->addElement('file', 'attachment[0]', _ATTACHMENT, null, 'class = "inputText"');
     $form->addElement('submit', 'submit_mail', _SEND, 'class = "flatButton"');
     if ($form->isSubmitted() && $form->validate()) {
         $values = $form->exportValues();
         switch ($values['recipients']) {
             case "lesson_students":
                 $lesson = new EfrontLesson($_SESSION['s_lessons_ID']);
                 $lessonUsers = $lesson->getUsers("student");
                 foreach ($lessonUsers as $value) {
                     $mail_recipients[] = $value['login'];
                 }
                 //pr($mail_recipients);return;
                 break;
             case "lesson_professors":
                 $lesson = new EfrontLesson($_SESSION['s_lessons_ID']);
                 $lessonUsers = $lesson->getUsers("professor");
                 if (isset($_SESSION['s_courses_ID'])) {
                     $course = new EfrontCourse($_SESSION['s_courses_ID']);
                     $course_users = $course->getCourseUsers();
                     foreach ($lessonUsers as $key => $value) {
                         if (!isset($course_users[$key])) {
                             unset($lessonUsers[$key]);
                         }
                     }
                 }
                 foreach ($lessonUsers as $value) {
                     $mail_recipients[] = $value['login'];
                 }
                 break;
             case "admin":
                 $result = eF_getTableData("users", "*", "user_type='administrator' and user_types_ID=0 and archive = 0");
                 //not
                 foreach ($result as $value) {
                     $mail_recipients[] = $value['login'];
                 }
                 break;
         }
         //$list = implode(",",$mail_recipients);
         $pm = new eF_PersonalMessage($_SESSION['s_login'], $mail_recipients, $values['subject'], $values['body']);
         if ($_FILES['attachment']['name'][0] != "") {
             $maxFileSize = FileSystemTree::getUploadMaxSize();
             if ($_FILES['attachment']['size'][0] == 0 || $_FILES['attachment']['size'][0] > $maxFileSize * 1024) {
                 //	G_MAXFILESIZE is deprecated
                 $message = _EACHFILESIZEMUSTBESMALLERTHAN . " " . G_MAXFILESIZE . " Bytes";
                 $message_type = 'failure';
             }
             //Upload user avatar file
             $pm->sender_attachment_timestamp = time();
             $user_dir = G_UPLOADPATH . $_SESSION['s_login'] . '/message_attachments/Sent/' . $pm->sender_attachment_timestamp . '/';
             mkdir($user_dir, 0755);
             $filesystem = new FileSystemTree($user_dir);
             $uploadedFile = $filesystem->uploadFile('attachment', $user_dir, 0);
             $pm->sender_attachment_fileId = $uploadedFile['id'];
             $pm->setAttachment($uploadedFile['path']);
         }
         if ($pm->send($values['email'], $values)) {
             $message = _MESSAGEWASSENT;
             $message_type = 'success';
         } else {
             $message = $pm->errorMessage;
             $message_type = 'failure';
         }
     }
     $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
     //Create a smarty renderer
     $renderer->setRequiredTemplate('{$html}{if $required}
     	&nbsp;<span class = "formRequired">*</span>
 		{/if}');
     $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
     //Set javascript error messages
     $form->setRequiredNote(_REQUIREDNOTE);
     $form->accept($renderer);
     //Assign this form to the renderer, so that corresponding template code is created
     $smarty->assign('T_MODULE_MAIL_FORM', $renderer->toArray());
     $smarty->assign("T_MESSAGE_MAIL", $message);
     $smarty->assign("T_MESSAGE_MAIL_TYPE", $message_type);
     //pr($renderer -> toArray());
     return true;
 }
开发者ID:kaseya-university,项目名称:efront,代码行数:93,代码来源:module_quick_mails.class.php

示例15: __construct

    /**
     * Constructor
     * @param string $form_name					Name of the form
     * @param string $method (optional			Method ('post' (default) or 'get')
     * @param string $action (optional			Action (default is $PHP_SELF)
     * @param string $target (optional			Form's target defaults to '_self'
     * @param mixed $attributes (optional)		Extra attributes for <form> tag
     * @param bool $track_submit (optional)		Whether to track if the form was
     * submitted by adding a special hidden field (default = true)
     */
    public function __construct($form_name = null, $method = 'post', $action = '', $target = '', $attributes = null, $track_submit = true)
    {
        // Default form class
        if (is_array($attributes) && !isset($attributes['class']) || empty($attributes)) {
            $attributes['class'] = 'form-horizontal';
        }
        // Fixing form search
        if (is_array($attributes) && isset($attributes['class'])) {
            //if (strpos($attributes['class'], 'form-search')) {
            if ($attributes['class'] == 'form-search') {
                //    $attributes['class'] = str_replace('form-search', 'form-inline', $attributes['class']);
                $attributes['class'] = 'form-inline';
            }
        }
        // Allow form with no names
        if (empty($form_name)) {
            $form_name = uniqid();
        }
        parent::__construct($form_name, $method, $action, $target, $attributes, $track_submit);
        // Load some custom elements and rules
        $dir = api_get_path(LIBRARY_PATH) . 'formvalidator/';
        $this->registerElementType('html_editor', $dir . 'Element/html_editor.php', 'HTML_QuickForm_html_editor');
        $this->registerElementType('datepicker', $dir . 'Element/datepicker.php', 'HTML_QuickForm_datepicker');
        $this->registerElementType('datepickerdate', $dir . 'Element/datepickerdate.php', 'HTML_QuickForm_datepickerdate');
        $this->registerElementType('receivers', $dir . 'Element/receivers.php', 'HTML_QuickForm_receivers');
        $this->registerElementType('select_language', $dir . 'Element/select_language.php', 'HTML_QuickForm_Select_Language');
        $this->registerElementType('select_theme', $dir . 'Element/select_theme.php', 'HTML_QuickForm_Select_Theme');
        $this->registerElementType('style_submit_button', $dir . 'Element/style_submit_button.php', 'HTML_QuickForm_stylesubmitbutton');
        $this->registerElementType('button', $dir . 'Element/style_submit_button.php', 'HTML_QuickForm_stylesubmitbutton');
        $this->registerElementType('captcha', 'HTML/QuickForm/CAPTCHA.php', 'HTML_QuickForm_CAPTCHA');
        $this->registerElementType('CAPTCHA_Image', 'HTML/QuickForm/CAPTCHA/Image.php', 'HTML_QuickForm_CAPTCHA_Image');
        $this->registerRule('date', null, 'HTML_QuickForm_Rule_Date', $dir . 'Rule/Date.php');
        $this->registerRule('date_compare', null, 'HTML_QuickForm_Rule_DateCompare', $dir . 'Rule/DateCompare.php');
        $this->registerRule('html', null, 'HTML_QuickForm_Rule_HTML', $dir . 'Rule/HTML.php');
        $this->registerRule('username_available', null, 'HTML_QuickForm_Rule_UsernameAvailable', $dir . 'Rule/UsernameAvailable.php');
        $this->registerRule('username', null, 'HTML_QuickForm_Rule_Username', $dir . 'Rule/Username.php');
        $this->registerRule('filetype', null, 'HTML_QuickForm_Rule_Filetype', $dir . 'Rule/Filetype.php');
        $this->registerRule('multiple_required', 'required', 'HTML_QuickForm_Rule_MultipleRequired', $dir . 'Rule/MultipleRequired.php');
        $this->registerRule('url', null, 'HTML_QuickForm_Rule_Url', $dir . 'Rule/Url.php');
        $this->registerRule('compare_fields', null, 'HTML_QuickForm_Compare_Fields', $dir . 'Rule/CompareFields.php');
        $this->registerRule('compare_datetime_text', null, 'HTML_QuickForm_Rule_CompareDateTimeText', $dir . 'Rule/CompareDateTimeText.php');
        $this->registerRule('CAPTCHA', 'rule', 'HTML_QuickForm_Rule_CAPTCHA', 'HTML/QuickForm/Rule/CAPTCHA.php');
        // Modify the default templates
        /** @var  HTML_QuickForm_Renderer_Default $renderer */
        $renderer =& $this->defaultRenderer();
        // Form template
        $renderer->setFormTemplate($this->getFormTemplate());
        // Element template
        if (isset($attributes['class']) && $attributes['class'] == 'well form-inline') {
            $element_template = ' {label}  {element} ';
            $renderer->setElementTemplate($element_template);
        } elseif (isset($attributes['class']) && $attributes['class'] == 'form-search') {
            $element_template = ' {label}  {element} ';
            $renderer->setElementTemplate($element_template);
        } else {
            if (is_array($attributes) && isset($attributes['class']) && $attributes['class'] == 'form-inline') {
                $element_template = $this->getDefaultInlineElementTemplate();
            } else {
                $element_template = $this->getDefaultElementTemplate();
            }
            $renderer->setElementTemplate($element_template);
            // Display a gray div in the buttons
            $button_element_template_simple = '<div class="form-actions">{label} {element}</div>';
            $renderer->setElementTemplate($button_element_template_simple, 'submit_in_actions');
            //Display a gray div in the buttons + makes the button available when scrolling
            $button_element_template_in_bottom = '<div class="form-actions bottom_actions">{label} {element}</div>';
            $renderer->setElementTemplate($button_element_template_in_bottom, 'submit_fixed_in_bottom');
            $renderer->setElementTemplate($button_element_template_simple, 'buttons_in_action');
            $button_element_template_simple_right = '<div class="form-actions"> <div class="pull-right">{label} {element}</div></div>';
            $renderer->setElementTemplate($button_element_template_simple_right, 'buttons_in_action_right');
        }
        // Set Header template
        $renderer->setHeaderTemplate('<h2>{header}</h2>');
        //Set required field template
        HTML_QuickForm::setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>');
        $required_note_template = <<<EOT
\t<div class="form-group">
\t\t<div class="col-sm-2">{requiredNote}</div>
\t</div>
EOT;
        $renderer->setRequiredNoteTemplate($required_note_template);
    }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:92,代码来源:FormValidator.class.php


注:本文中的HTML_QuickForm::setRequiredNote方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。