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


PHP FormValidator::toHtml方法代码示例

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


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

示例1: getSearchForm

 /**
  * Returns the search form
  * @return string
  */
 public static function getSearchForm()
 {
     $url = api_get_path(WEB_CODE_PATH) . 'group/group_overview.php?' . api_get_cidreq();
     $form = new FormValidator('search_groups', 'get', $url, null, array('class' => 'form-search'));
     $form->addElement('text', 'keyword');
     $form->addElement('button', 'submit', get_lang('Search'));
     return $form->toHtml();
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:12,代码来源:groupmanager.lib.php

示例2: build_directory_selector

 /**
  * Builds the form that enables the user to
  * select a directory to browse/upload in
  *
  * @param array 	An array containing the folders we want to be able to select
  * @param string	The current folder (path inside of the "document" directory, including the prefix "/")
  * @param string	Group directory, if empty, prevents documents to be uploaded (because group documents cannot be uploaded in root)
  * @param	boolean	Whether to change the renderer (this will add a template <span> to the QuickForm object displaying the form)
  * @todo this funcionality is really bad : jmontoya
  * @return string html form
  */
 public static function build_directory_selector($folders, $document_id, $group_dir = '', $change_renderer = false)
 {
     $doc_table = Database::get_course_table(TABLE_DOCUMENT);
     $course_id = api_get_course_int_id();
     $folder_titles = array();
     if (is_array($folders)) {
         $escaped_folders = array();
         foreach ($folders as $key => &$val) {
             $escaped_folders[$key] = Database::escape_string($val);
         }
         $folder_sql = implode("','", $escaped_folders);
         $sql = "SELECT * FROM {$doc_table}\n                WHERE filetype = 'folder' AND c_id = {$course_id} AND path IN ('" . $folder_sql . "')";
         $res = Database::query($sql);
         $folder_titles = array();
         while ($obj = Database::fetch_object($res)) {
             $folder_titles[$obj->path] = $obj->title;
         }
     }
     $form = new FormValidator('selector', 'GET', api_get_self() . '?' . api_get_cidreq());
     $form->addElement('hidden', 'cidReq', api_get_course_id());
     $parent_select = $form->addSelect('id', get_lang('CurrentDirectory'), '', array('onchange' => 'javascript: document.selector.submit();'));
     if ($change_renderer) {
         $renderer = $form->defaultRenderer();
         $renderer->setElementTemplate('<span>{label} : {element}</span> ', 'curdirpath');
     }
     // Group documents cannot be uploaded in the root
     if (empty($group_dir)) {
         $parent_select->addOption(get_lang('Documents'), '/');
         if (is_array($folders)) {
             foreach ($folders as $folder_id => &$folder) {
                 $selected = $document_id == $folder_id ? ' selected="selected"' : '';
                 $path_parts = explode('/', $folder);
                 $folder_titles[$folder] = cut($folder_titles[$folder], 80);
                 $counter = count($path_parts) - 2;
                 if ($counter > 0) {
                     $label = str_repeat('&nbsp;&nbsp;&nbsp;', $counter) . ' &mdash; ' . $folder_titles[$folder];
                 } else {
                     $label = ' &mdash; ' . $folder_titles[$folder];
                 }
                 $parent_select->addOption($label, $folder_id);
                 if ($selected != '') {
                     $parent_select->setSelected($folder_id);
                 }
             }
         }
     } else {
         if (!empty($folders)) {
             foreach ($folders as $folder_id => &$folder) {
                 $selected = $document_id == $folder_id ? ' selected="selected"' : '';
                 $label = $folder_titles[$folder];
                 if ($folder == $group_dir) {
                     $label = get_lang('Documents');
                 } else {
                     $path_parts = explode('/', str_replace($group_dir, '', $folder));
                     $label = cut($label, 80);
                     $label = str_repeat('&nbsp;&nbsp;&nbsp;', count($path_parts) - 2) . ' &mdash; ' . $label;
                 }
                 $parent_select->addOption($label, $folder_id);
                 if ($selected != '') {
                     $parent_select->setSelected($folder_id);
                 }
             }
         }
     }
     $html = $form->toHtml();
     return $html;
 }
开发者ID:daffef,项目名称:chamilo-lms,代码行数:78,代码来源:document.lib.php

示例3: getSearchForm

 /**
  * Returns the search form
  * @return string
  */
 public static function getSearchForm()
 {
     $url = api_get_path(WEB_CODE_PATH) . 'group/group_overview.php?' . api_get_cidreq();
     $form = new FormValidator('search_groups', 'get', $url, null, array('class' => 'form-search'), FormValidator::LAYOUT_INLINE);
     $form->addHidden('cidReq', api_get_course_id());
     $form->addHidden('id_session', api_get_session_id());
     $form->addElement('text', 'keyword');
     $form->addButtonSearch();
     return $form->toHtml();
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:14,代码来源:groupmanager.lib.php

示例4: display_item_small_form

 /**
  * Displays a basic form on the overview page for changing the item title and the item description.
  * @param string $item_type
  * @param string $title
  * @param array $data
  * @return string
  */
 public function display_item_small_form($item_type, $title = '', $data = array())
 {
     $url = api_get_self() . '?' . api_get_cidreq() . '&action=edit_item&lp_id=' . $this->lp_id;
     $form = new FormValidator('small_form', 'post', $url);
     $form->addElement('header', $title);
     $form->addElement('text', 'title', get_lang('Title'));
     $form->addElement('button', 'submit_button', get_lang('Save'));
     $form->addElement('hidden', 'id', $data['id']);
     $form->addElement('hidden', 'parent', $data['parent_item_id']);
     $form->addElement('hidden', 'previous', $data['previous_item_id']);
     $form->setDefaults(array('title' => $data['title']));
     return $form->toHtml();
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:20,代码来源:learnpath.class.php

示例5: header

if ($form->validate()) {
    $em = Database::getManager();
    $values = $form->exportValues();
    $password = $values['pass1'];
    $token = $values['token'];
    /** @var \Chamilo\UserBundle\Entity\User $user */
    $user = UserManager::getManager()->findUserByConfirmationToken($token);
    if ($user) {
        if (!$user->isPasswordRequestNonExpired($ttl)) {
            Display::addFlash(Display::return_message(get_lang('LinkExpired')), 'warning');
            header('Location: ' . api_get_path(WEB_CODE_PATH) . 'auth/lostPassword.php');
            exit;
        }
        $user->setPlainPassword($password);
        $userManager = UserManager::getManager();
        $userManager->updateUser($user, true);
        $user->setConfirmationToken(null);
        $user->setPasswordRequestedAt(null);
        Database::getManager()->persist($user);
        Database::getManager()->flush();
        Display::addFlash(Display::return_message(get_lang('Updated')));
        header('Location: ' . api_get_path(WEB_PATH));
        exit;
    } else {
        Display::addFlash(Display::return_message(get_lang('LinkExpired')));
    }
}
$tpl->assign('form', $form->toHtml());
$content = $tpl->get_template('auth/set_temp_password.tpl');
$tpl->assign('content', $tpl->fetch($content));
$tpl->display_one_col_template();
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:reset.php

示例6: Template

if (!empty($selectedGroupChoices)) {
    $defaults['groups'] = $selectedGroupChoices;
}
$form->setDefaults($defaults);
$tpl = new Template();
$currentUser = $em->getRepository('ChamiloUserBundle:User')->find(api_get_user_id());
if ($form->validate()) {
    $values = $form->getSubmitValues();
    // Subscribing users
    $users = isset($values['users']) ? $values['users'] : [];
    $userForm = isset($values['user_form']) ? $values['user_form'] : [];
    if (!empty($userForm)) {
        $em->getRepository('ChamiloCourseBundle:CItemProperty')->subscribeUsersToItem($currentUser, 'learnpath', $course, $session, $lpId, $users);
        Display::addFlash(Display::return_message(get_lang('Updated')));
    }
    // Subscribing groups
    $groups = isset($values['groups']) ? $values['groups'] : [];
    $groupForm = isset($values['group_form']) ? $values['group_form'] : [];
    if (!empty($groupForm)) {
        $em->getRepository('ChamiloCourseBundle:CItemProperty')->subscribeGroupsToItem($currentUser, 'learnpath', $course, $session, $lpId, $groups);
        Display::addFlash(Display::return_message(get_lang('Updated')));
    }
    header("Location: {$url}");
    exit;
} else {
    $headers = [get_lang('SubscribeUsersToLp'), get_lang('SubscribeGroupsToLp')];
    $tabs = Display::tabs($headers, [$formUsers->toHtml(), $form->toHtml()]);
    $tpl->assign('tabs', $tabs);
}
$layout = $tpl->get_template('learnpath/subscribe_users.tpl');
$tpl->display($layout);
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:31,代码来源:lp_subscribe_users.php

示例7: indexAction


//.........这里部分代码省略.........
     $choices = array();
     foreach ($subscribedUsers as $user) {
         $choices[$user->getUserId()] = $user->getCompleteNameWithClasses();
     }
     // Getting subscribed users to a LP.
     $subscribedUsersInLp = $app['orm.em']->getRepository('Chamilo\\CoreBundle\\Entity\\CItemProperty')->getUsersSubscribedToItem('learnpath', $lpId, $course, $session);
     $selectedChoices = array();
     foreach ($subscribedUsersInLp as $itemProperty) {
         $selectedChoices[] = $itemProperty->getToUserId();
     }
     //Building the form for Users
     $formUsers = new \FormValidator('lp_edit', 'post', $url);
     $formUsers->addElement('hidden', 'user_form', 1);
     $formUsers->addElement('header', get_lang('SubscribeUsersToLp'));
     $userMultiSelect = $formUsers->addElement('advmultiselect', 'users', get_lang('Users'), $choices);
     $userMultiSelect->setButtonAttributes('add');
     $userMultiSelect->setButtonAttributes('remove');
     $formUsers->addElement('style_submit_button', 'submit', get_lang('Save'), 'class="save"');
     $defaults = array();
     if (!empty($selectedChoices)) {
         $defaults['users'] = $selectedChoices;
     }
     $formUsers->setDefaults($defaults);
     //Building the form for Groups
     $form = new \FormValidator('lp_edit', 'post', $url);
     $form->addElement('header', get_lang('SubscribeGroupsToLp'));
     $form->addElement('hidden', 'group_form', 1);
     //Group list
     $groupList = \CourseManager::get_group_list_of_course(api_get_course_id(), api_get_session_id(), 1);
     $groupChoices = array();
     if (!empty($groupList)) {
         foreach ($groupList as $group) {
             $groupChoices[$group['id']] = $group['name'];
         }
     }
     //Subscribed groups to a LP
     $subscribedGroupsInLp = $app['orm.em']->getRepository('Chamilo\\CoreBundle\\Entity\\CItemProperty')->getGroupsSubscribedToItem('learnpath', $lpId, $course, $session);
     $selectedGroupChoices = array();
     foreach ($subscribedGroupsInLp as $itemProperty) {
         $selectedGroupChoices[] = $itemProperty->getToGroupId();
     }
     $groupMultiSelect = $form->addElement('advmultiselect', 'groups', get_lang('Groups'), $groupChoices);
     $groupMultiSelect->setButtonAttributes('add');
     $groupMultiSelect->setButtonAttributes('remove');
     // submit button
     $form->addElement('style_submit_button', 'submit', get_lang('Save'), 'class="save"');
     /*$form = $app['form.factory']->createBuilder('form')
            ->add('origin', 'choice', array(
               'label' => get_lang('Origin'),
               'multiple' => true,
               'required' => false,
               'expanded' => false,
               //'class' => 'Entity\Course',
               //'property' => 'complete_name',
               //'query_builder' => function(Chamilo\CoreBundle\Entity\Repository\CourseRepository $repo) use ($course) {
                   $repo =  $repo->getSubscribedStudents($course);
                   return $repo;
               },
               'choices' => $choices
           ))
           ->add('destination', 'choice', array(
               'label' => get_lang('Destination'),
               'multiple' => true,
               'expanded' => false,
               'required' => false,
               //'class' => 'Entity\Course',
               //'property' => 'complete_name',
               //'query_builder' => function(Chamilo\CoreBundle\Entity\Repository\CourseRepository $repo) use ($course) {
                 //  return $repo->getSubscribedStudents($course);
               //},
               'choices' => $selectedChoices
           ))
           ->getForm();
       */
     $defaults = array();
     if (!empty($selectedGroupChoices)) {
         $defaults['groups'] = $selectedGroupChoices;
     }
     $form->setDefaults($defaults);
     if ($request->getMethod() == 'POST') {
         //Subscribing users
         $users = $request->get('users');
         $userForm = $request->get('user_form');
         if (!empty($userForm)) {
             $app['orm.em']->getRepository('Chamilo\\CoreBundle\\Entity\\CItemProperty')->subscribeUsersToItem('learnpath', $course, $session, $lpId, $users);
         }
         //Subscribing groups
         $groups = $request->get('groups');
         $groupForm = $request->get('group_form');
         if (!empty($groupForm)) {
             $app['orm.em']->getRepository('Chamilo\\CoreBundle\\Entity\\CItemProperty')->subscribeGroupsToItem('learnpath', $course, $session, $lpId, $groups);
         }
         return $app->redirect($url);
     } else {
         $app['template']->assign('formUsers', $formUsers->toHtml());
         $app['template']->assign('formGroups', $form->toHtml());
     }
     $response = $app['template']->render_template('learnpath/subscribe_users.tpl');
     return new Response($response, 200, array());
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:101,代码来源:LearningPathController.php

示例8: isset

    $users = isset($values['users']) ? $values['users'] : [];
    if (!empty($users)) {
        $deleteUsers = [];
        if ($subscribedUsersInCategory) {
            /** @var CLpCategoryUser $user */
            foreach ($subscribedUsersInCategory as $user) {
                $userId = $user->getUser()->getId();
                if (!in_array($userId, $users)) {
                    $category->removeUsers($user);
                }
            }
        }
        foreach ($users as $userId) {
            $categoryUser = new CLpCategoryUser();
            $user = UserManager::getRepository()->find($userId);
            $categoryUser->setUser($user);
            $category->addUser($categoryUser);
        }
        $em->merge($category);
        $em->flush();
        Display::addFlash(Display::return_message(get_lang('Updated')));
    }
    header("Location: {$url}");
    exit;
} else {
    $headers = [get_lang('SubscribeUsersToLp'), get_lang('SubscribeGroupsToLp')];
    $tabs = $formUsers->toHtml();
    $tpl->assign('tabs', $tabs);
}
$layout = $tpl->get_template('learnpath/subscribe_users.tpl');
$tpl->display($layout);
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:31,代码来源:lp_subscribe_users_to_category.php


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