private function expected_link($text, $number = null)
 {
     if ($number === null) {
         $number = $text;
     }
     $var = $number - 1;
     $attributes['href'] = "example.com?one=fish&two=fish&page={$var}";
     return html::li('', html::a($attributes, $text));
 }
 public static function sign_up_sign_in($url)
 {
     // TODO: add sign in as guest.
     $dropdown_content = array('class' => 'dropdown-menu', 'style' => 'padding: 15px; padding-bottom: 0px;');
     $form = array('method' => 'post', 'action' => $url, 'accept-charset' => 'UTF-8');
     $username = array('type' => 'text', 'placeholder' => 'Username', 'id' => 'username', 'name' => 'username');
     $password = array('type' => 'password', 'placeholder' => 'Password', 'id' => 'password', 'name' => 'password');
     $submit = array('value' => 'Sign In', 'class' => 'btn btn-primary btn-block', 'id' => 'sign-in');
     return html::ul('nav pull-right', html::li(html::a(new moodle_url('/login/signup.php'), 'Sign Up')) . bootstrap::list_divider() . bootstrap::dropdown('Sign In', html::div($dropdown_content, html::form($form, html::input($username) . html::input($password) . html::checkbox('rememberusername', 'Remember username') . html::submit($submit)))));
 }
 public function test_li_with_attributes_and_empty_string_args()
 {
     $attributes = array('class' => 'test', 'data' => '0101');
     $actual = html::li($attributes, '');
     $expected = '<li class=test data=0101></li>';
     $this->assertSame($expected, $actual);
 }
 protected function render_custom_menu_item(custom_menu_item $menunode, $submenu = null)
 {
     if ('list_divider' === $menunode->get_text()) {
         return bootstrap::list_divider();
     }
     if (!$menunode->has_children()) {
         return $this->render_custom_menu_leaf($menunode);
     }
     foreach ($menunode->get_children() as $child) {
         $items[] = $this->render_custom_menu_item($child, true);
     }
     if ($submenu === true) {
         return html::li(bootstrap::dropdown_submenu($menunode->get_text(), $items));
     } else {
         return html::li(bootstrap::dropdown_menu($menunode->get_text(), $items));
     }
 }
 public static function li_icon_link($href, $icon, $text)
 {
     return html::li(self::icon_link($href, $icon, $text));
 }
 private function skipped()
 {
     return html::li('disabled', html::span('...'));
 }
 /**
  * Formats the information that needs to go in the 'Requires' column.
  * @param plugininfo_base $plugin the plugin we are rendering the row for.
  * @param plugin_manager $pluginman provides data on all the plugins.
  * @param string $version
  * @return string HTML code
  */
 protected function required_column(plugininfo_base $plugin, plugin_manager $pluginman, $version)
 {
     $requires = array();
     if (!empty($plugin->versionrequires)) {
         $required = get_string('moodleversion', 'core_plugin', $plugin->versionrequires);
         if ($plugin->versionrequires > $version) {
             $required = label::important($required);
         }
         $requires[] = html::li($required);
     }
     foreach ($plugin->get_other_required_plugins() as $component => $requiredversion) {
         $ok = true;
         $otherplugin = $pluginman->get_plugin_info($component);
         if (is_null($otherplugin)) {
             $ok = false;
         } else {
             if ($requiredversion != ANY_VERSION and $otherplugin->versiondisk < $requiredversion) {
                 $ok = false;
             }
         }
         if ($requiredversion != ANY_VERSION) {
             $required = get_string('otherpluginversion', 'core_plugin', array('component' => $component, 'version' => $requiredversion));
         } else {
             $required = get_string('otherplugin', 'core_plugin', array('component' => $component, 'version' => $requiredversion));
         }
         if (!$ok) {
             $required = label::important($required);
         }
         $requires[] = html::li($required);
     }
     if (!$requires) {
         return '';
     }
     return html::ul('unstyled', $requires);
 }
 protected function disabled_navigation_node(navigation_node $node, $wrap = true)
 {
     $items = $node->children;
     if ($items->count() == 0) {
         return '';
     }
     foreach ($items as $item) {
         if (!$item->display) {
             continue;
         }
         $isbranch = $item->children->count() > 0 || $item->nodetype == navigation_node::NODETYPE_BRANCH;
         if ($isbranch) {
             $item->hideicon = true;
         }
         $content = $this->output->render($item);
         $classes = 'tree_item';
         $expanded = 'true';
         if (!$item->forceopen || !$item->forceopen && $item->collapse || $item->children->count() == 0 && $item->nodetype == navigation_node::NODETYPE_BRANCH) {
             $classes = classes::add_to($classes, 'collapsed');
             if ($isbranch) {
                 $expanded = "false";
                 $classes = classes::add_to($classes, 'branch');
             }
         }
         if ($item->isactive === true) {
             $classes = classes::add_to($classes, 'active');
         }
         $attributes = array('class' => $classes, 'aria-expanded' => $expanded);
         $content .= $this->navigation_node($item);
         $lis[] = html::li($attributes, $content);
     }
     $output = implode($lis);
     if ($wrap) {
         return html::ul('nav nav-list block_tree', $output);
     }
     return $output;
 }
 public function navigation_tree(global_navigation $navigation, $expansionlimit, array $options = array())
 {
     $navigation->add_class('navigation_node');
     $content = $this->navigation_node(array($navigation), array('class' => 'block_tree list nav nav-list'), $expansionlimit, $options);
     if (!isset($navigation->id) && !is_numeric($navigation->id) && !empty($content)) {
         $attributes = array('class' => 'block_tree_box', 'id' => $navigation->id);
         $content = html::li($attributes, $content);
     }
     return $content;
 }
Beispiel #10
0
 static function tolist($list, $type, $style = null)
 {
     $html_list = '';
     foreach ($list as $url => $value) {
         if (is_array($value)) {
             $row = html::tolist($value, $type, $style);
         } else {
             $row = $value;
         }
         $html_list .= html::a(html::li($row), "href='{$url}'");
     }
     switch ($type) {
         case 'ol':
             $html_list = html::ol($html_list, "type='{$style}'");
             break;
         case 'ul':
             $html_list = html::ul($html_list, "style='list-style-type:{$style}'");
             break;
         default:
             $html_list = html::ul($html_list, "style='list-style-type:none'");
             break;
     }
     return $html_list;
 }