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


PHP html_writer::random_id方法代码示例

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


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

示例1: output_select_html

 public function output_select_html($data, $current, $default, $extraname = '')
 {
     $warning = '';
     $output = '';
     if (empty($current)) {
         $current = $default;
     }
     foreach ($this->options as $value => $label) {
         $attributes = array();
         $attributes['id'] = html_writer::random_id('checkbox_');
         $attributes['type'] = 'radio';
         $attributes['value'] = $value;
         $attributes['name'] = $this->get_full_name();
         $attributes['class'] = 'form-checkbox';
         if ($current == $value) {
             $attributes['checked'] = 'checked';
         }
         $radiohtml = html_writer::empty_tag('input', $attributes);
         $labelhtml = html_writer::tag('label', ' ' . $label, array('for' => $attributes['id']));
         $output .= $radiohtml;
         $output .= $labelhtml;
         $output .= html_writer::empty_tag('br');
     }
     return array($output, $warning);
 }
开发者ID:CTANZ,项目名称:moodle-mod_equella,代码行数:25,代码来源:adminsettings.class.php

示例2: __toString

 /**
  * Init the random variable and return it as a string.
  *
  * @return string random id.
  */
 public function __toString()
 {
     if ($this->uniqid === null) {
         $this->uniqid = \html_writer::random_id(uniqid());
     }
     return $this->uniqid;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:12,代码来源:mustache_uniqid_helper.php

示例3: fetchSWFWidgetCode

function fetchSWFWidgetCode($widget, $params, $width, $height, $bgcolor = "#FFFFFF")
{
    global $CFG;
    $widgetid = html_writer::random_id('laszlobase');
    $widgetjson = \filter_poodll\poodlltools::fetchSWFWidgetJSON($widget, $params, $width, $height, $bgcolor = "#FFFFFF", $widgetid);
    $retcode = html_writer::div('', '', array('id' => $widgetid . 'Container'));
    $retcode .= '<script type="text/javascript" src="' . $CFG->httpswwwroot . '/filter/poodll/flash/embed-compressed.js"></script>
        <script type="text/javascript"> lz.embed.swf(' . $widgetjson . ')</script>';
    return $retcode;
}
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:10,代码来源:poodlliframe.php

示例4: display_options

    /**
     * Returns HTML to display choices of option
     * @param object $options
     * @param int  $coursemoduleid
     * @param bool $vertical
     * @return string
     */
    public function display_options($options, $coursemoduleid, $vertical = false) {
        $layoutclass = 'horizontal';
        if ($vertical) {
            $layoutclass = 'vertical';
        }
        $target = new moodle_url('/mod/choice/view.php');
        //changed below to post from target john
        $attributes = array('method'=>'POST', 'action'=>$target, 'class'=> $layoutclass);

        $html = html_writer::start_tag('form', $attributes);
        $html .= html_writer::start_tag('ul', array('class'=>'choices', 'data-role'=>'controlgroup' ));

        $availableoption = count($options['options']);
        foreach ($options['options'] as $option) {
            $html .= html_writer::start_tag('li', array('class'=>'option'));
            $option->attributes->name = 'answer';
            $option->attributes->type = 'radio';
            $option->attributes->id = 'answer'.html_writer::random_id();

            $labeltext = $option->text;
            if (!empty($option->attributes->disabled)) {
                $labeltext .= ' ' . get_string('full', 'choice');
                $availableoption--;
            }

            $html .= html_writer::empty_tag('input', (array)$option->attributes);
            $html .= html_writer::tag('label', $labeltext, array('for'=>$option->attributes->id));
            $html .= html_writer::end_tag('li');
        }
        $html .= html_writer::tag('li','', array('class'=>'clearfloat'));
        $html .= html_writer::end_tag('ul');
        $html .= html_writer::tag('div', '', array('class'=>'clearfloat'));
        $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey()));
        $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'id', 'value'=>$coursemoduleid));

        if (!empty($options['hascapability']) && ($options['hascapability'])) {
            if ($availableoption < 1) {
               $html .= html_writer::tag('label', get_string('choicefull', 'choice'));
            } else {
                $html .= html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('savemychoice','choice'), 'class'=>'button'));
            }

            if (!empty($options['allowupdate']) && ($options['allowupdate'])) {
                $url = new moodle_url('view.php', array('id'=>$coursemoduleid, 'action'=>'delchoice', 'sesskey'=>sesskey()));
                $html .= html_writer::link($url, get_string('removemychoice','choice'));
            }
        } else {
            $html .= html_writer::tag('label', get_string('havetologin', 'choice'));
        }

        $html .= html_writer::end_tag('ul');
        $html .= html_writer::end_tag('form');

        return $html;
    }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:62,代码来源:mod_choice_renderer.php

示例5: render_assign_files

 /**
  * Rendering assignment files
  *
  * @param assign_files $tree
  * @return string
  */
 public function render_assign_files(assign_files $tree)
 {
     $this->htmlid = html_writer::random_id('assign_files_tree');
     $this->page->requires->js_init_call('M.mod_assign.init_tree', array(true, $this->htmlid));
     $html = '<div id="' . $this->htmlid . '">';
     $html .= $this->htmllize_tree($tree, $tree->dir);
     $html .= '</div>';
     if ($tree->portfolioform) {
         $html .= $tree->portfolioform;
     }
     return $html;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:18,代码来源:renderer.php

示例6: course_category_tree

 /**
  * Renderers a structured array of courses and categories into a nice
  * XHTML tree structure.
  *
  * This method was designed initially to display the front page course/category
  * combo view. The structure can be retrieved by get_course_category_tree()
  *
  * @param array $structure
  * @return string
  */
 public function course_category_tree(array $structure)
 {
     $this->strings->summary = get_string('summary');
     // Generate an id and the required JS call to make this a nice widget
     $id = html_writer::random_id('course_category_tree');
     $this->page->requires->js_init_call('M.util.init_toggle_class_on_click', array($id, '.category.with_children .category_label', 'collapsed', '.category.with_children'));
     // Start content generation
     $content = html_writer::start_tag('div', array('class' => 'course_category_tree', 'id' => $id));
     foreach ($structure as $category) {
         $content .= $this->course_category_tree_category($category);
     }
     $content .= html_writer::start_tag('div', array('class' => 'controls'));
     $content .= html_writer::tag('div', get_string('collapseall'), array('class' => 'addtoall expandall'));
     $content .= html_writer::tag('div', get_string('expandall'), array('class' => 'removefromall collapseall'));
     $content .= html_writer::end_tag('div');
     $content .= html_writer::end_tag('div');
     // Return the course category tree HTML
     return $content;
 }
开发者ID:nmicha,项目名称:moodle,代码行数:29,代码来源:renderer.php

示例7: render_user_button

 /**
  * Render for the select user button.
  *
  * @param user_button $button instance of  gradereport_history_user_button to render
  *
  * @return string HTML to display
  */
 protected function render_user_button(user_button $button)
 {
     $attributes = array('type' => 'button', 'class' => 'selectortrigger', 'value' => $button->label, 'disabled' => $button->disabled ? 'disabled' : null, 'title' => $button->tooltip);
     if ($button->actions) {
         $id = \html_writer::random_id('single_button');
         $attributes['id'] = $id;
         foreach ($button->actions as $action) {
             $this->add_action_handler($action, $id);
         }
     }
     // First the input element.
     $output = \html_writer::empty_tag('input', $attributes);
     // Then hidden fields.
     $params = $button->url->params();
     if ($button->method === 'post') {
         $params['sesskey'] = sesskey();
     }
     foreach ($params as $var => $val) {
         $output .= \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $var, 'value' => $val));
     }
     // Then div wrapper for xhtml strictness.
     $output = \html_writer::tag('div', $output);
     // Now the form itself around it.
     if ($button->method === 'get') {
         $url = $button->url->out_omit_querystring(true);
         // Url without params, the anchor part allowed.
     } else {
         $url = $button->url->out_omit_querystring();
         // Url without params, the anchor part not allowed.
     }
     if ($url === '') {
         $url = '#';
         // There has to be always some action.
     }
     $attributes = array('method' => $button->method, 'action' => $url, 'id' => $button->formid);
     $output = \html_writer::tag('div', $output, $attributes);
     // Finally one more wrapper with class.
     return \html_writer::tag('div', $output, array('class' => $button->class));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:46,代码来源:renderer.php

示例8: coursecat_tree

 /**
  * Returns HTML to display a tree of subcategories and courses in the given category
  *
  * @param coursecat_helper $chelper various display options
  * @param coursecat $coursecat top category (this category's name and description will NOT be added to the tree)
  * @return string
  */
 protected function coursecat_tree(coursecat_helper $chelper, $coursecat)
 {
     $categorycontent = $this->coursecat_category_content($chelper, $coursecat, 0);
     if (empty($categorycontent)) {
         return '';
     }
     // Generate an id and the required JS call to make this a nice widget
     $id = html_writer::random_id('course_category_tree');
     $this->page->requires->js_init_call('M.util.init_toggle_class_on_click', array($id, '.category.with_children.loaded > .info .name', 'collapsed', '.category.with_children.loaded'));
     // Start content generation
     $content = '';
     $attributes = $chelper->get_and_erase_attributes('course_category_tree clearfix');
     $content .= html_writer::start_tag('div', array('id' => $id, 'data-showcourses' => $chelper->get_show_courses()) + $attributes);
     $content .= html_writer::tag('div', $categorycontent, array('class' => 'content'));
     if ($coursecat->get_children_count() && $chelper->get_subcat_depth() != 1) {
         // We don't need to display "Expand all"/"Collapse all" buttons if there are no
         // subcategories or there is only one level of subcategories loaded
         // TODO if subcategories are loaded by AJAX this might still be needed!
         $content .= html_writer::start_tag('div', array('class' => 'controls'));
         $content .= html_writer::tag('div', get_string('collapseall'), array('class' => 'addtoall expandall'));
         $content .= html_writer::tag('div', get_string('expandall'), array('class' => 'removefromall collapseall'));
         $content .= html_writer::end_tag('div');
     }
     $content .= html_writer::end_tag('div');
     // .course_category_tree
     return $content;
 }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:34,代码来源:renderer.php

示例9: embed

 /**
  * Generates code required to embed the player.
  *
  * @param array $urls Moodle URLs of media files
  * @param string $name Display name; '' to use default
  * @param int $width Optional width; 0 to use default
  * @param int $height Optional height; 0 to use default
  * @param array $options Options array
  *                       image
  *                           use 'image' key with a moodle_url to an image as poster image
  *                           displayed before playback starts.
  *                       subtitles
  *                           use 'subtitles' key with an array of subtitle track files
  *                           in vtt or srt format indexed by label name.
  *                           Example: $options['subtitles']['English'] = http://example.com/english.vtt
  * @return string HTML code for embed
  */
 public function embed($urls, $name, $width, $height, $options)
 {
     global $PAGE, $CFG;
     // We do embedding only here. JW player setup is done in the filter.
     $output = '';
     $sources = array();
     $playersetupdata = array();
     $isstream = false;
     foreach ($urls as $url) {
         // Add the details for this source.
         $source = array('file' => urldecode($url->out(false)));
         // Help to determine the type of mov.
         $ext = strtolower(pathinfo($url, PATHINFO_EXTENSION));
         if ($ext === 'mov') {
             $source['type'] = 'mp4';
         }
         if ($url->get_scheme() === 'rtmp' || $ext === 'm3u8' || $ext === 'smil') {
             // For RTMP, HLS and Dynamic RTMP we set rendering mode to Flash to
             // ensure streams play is possible even when mp4 fallbacks are given.
             // Also make sure that URL is the first in the list.
             $playersetupdata['primary'] = 'flash';
             array_unshift($sources, $source);
             $isstream = true;
         } else {
             $sources[] = $source;
         }
     }
     if (count($sources) > 0) {
         $playerid = 'filter_jwplayer_media_' . html_writer::random_id();
         $playersetupdata['title'] = $this->get_name('', $urls);
         $playlistitem = array('sources' => $sources);
         // Setup poster image.
         if (isset($options['image'])) {
             $playlistitem['image'] = urldecode($options['image']->out(false));
         } else {
             if ($poster = get_config('filter_jwplayer', 'defaultposter')) {
                 $syscontext = context_system::instance();
                 $playlistitem['image'] = moodle_url::make_pluginfile_url($syscontext->id, 'filter_jwplayer', 'defaultposter', null, null, $poster)->out(true);
             }
         }
         // Setup subtitle tracks.
         if (isset($options['subtitles'])) {
             $tracks = array();
             foreach ($options['subtitles'] as $label => $subtitlefileurl) {
                 $tracks[] = array('file' => urldecode($subtitlefileurl->out(false)), 'label' => $label);
             }
             $playlistitem['tracks'] = $tracks;
         }
         $playersetupdata['playlist'] = array($playlistitem);
         // If we are dealing with audio, show just the control bar.
         if (mimeinfo('string', $sources[0]['file']) === 'audio') {
             $width = FILTER_JWPLAYER_AUDIO_WIDTH;
             $height = FILTER_JWPLAYER_AUDIO_HEIGHT;
         }
         // If width is not provided, use default.
         if (!$width) {
             // Use responsive width if choosen in settings otherwise default to fixed width.
             if (get_config('filter_jwplayer', 'displaystyle') === 'responsive') {
                 $width = FILTER_JWPLAYER_VIDEO_WIDTH_RESPONSIVE;
             } else {
                 $width = FILTER_JWPLAYER_VIDEO_WIDTH;
             }
         }
         if (is_numeric($width)) {
             $width = round($width);
         }
         $playersetupdata['width'] = $width;
         // If width is a percentage surrounding span needs to have its width set so it does not default to 0px.
         $outerspanargs = array('class' => 'filter_jwplayer_playerblock');
         if (!is_numeric($width)) {
             $outerspanargs['style'] = 'width: ' . $width . ';';
             $width = '100%';
             // As the outer span in now at the required width, we set the width of the player to 100%.
         }
         // Automatically set the height unless it is specified.
         if ($height) {
             if (is_numeric($height)) {
                 $playersetupdata['height'] = $height;
             } else {
                 if (is_numeric($width)) {
                     // If width is numeric and height is percentage, calculate height from width.
                     $playersetupdata['height'] = round($width * floatval($height) / 100);
                 } else {
//.........这里部分代码省略.........
开发者ID:rlowry,项目名称:moodle-filter_jwplayer,代码行数:101,代码来源:lib.php

示例10: render_assignfeedback_editpdf_widget

 /**
  * Render the editpdf widget in the grading form.
  *
  * @param assignfeedback_editpdf_widget $widget - Renderable widget containing assignment, user and attempt number.
  * @return string
  */
 public function render_assignfeedback_editpdf_widget(assignfeedback_editpdf_widget $widget)
 {
     global $CFG;
     $html = '';
     $html .= html_writer::div(get_string('jsrequired', 'assignfeedback_editpdf'), 'hiddenifjs');
     $linkid = html_writer::random_id();
     if ($widget->readonly) {
         $launcheditorlink = html_writer::tag('a', get_string('viewfeedbackonline', 'assignfeedback_editpdf'), array('id' => $linkid, 'class' => 'btn', 'href' => '#'));
     } else {
         $launcheditorlink = html_writer::tag('a', get_string('launcheditor', 'assignfeedback_editpdf'), array('id' => $linkid, 'class' => 'btn', 'href' => '#'));
     }
     $links = $launcheditorlink;
     $links .= html_writer::tag('div', get_string('unsavedchanges', 'assignfeedback_editpdf'), array('class' => 'assignfeedback_editpdf_unsavedchanges warning'));
     $html .= html_writer::div($links, 'visibleifjs');
     $header = get_string('pluginname', 'assignfeedback_editpdf');
     $body = '';
     // Create the page navigation.
     $navigation1 = '';
     $navigation2 = '';
     // Pick the correct arrow icons for right to left mode.
     if (right_to_left()) {
         $nav_prev = 'nav_next';
         $nav_next = 'nav_prev';
     } else {
         $nav_prev = 'nav_prev';
         $nav_next = 'nav_next';
     }
     $iconalt = get_string('navigateprevious', 'assignfeedback_editpdf');
     $iconhtml = $this->pix_icon($nav_prev, $iconalt, 'assignfeedback_editpdf');
     $navigation1 .= html_writer::tag('button', $iconhtml, array('disabled' => 'true', 'class' => 'navigate-previous-button', 'accesskey' => $this->get_shortcut('navigate-previous-button')));
     $navigation1 .= html_writer::tag('select', null, array('disabled' => 'true', 'aria-label' => get_string('gotopage', 'assignfeedback_editpdf'), 'class' => 'navigate-page-select', 'accesskey' => $this->get_shortcut('navigate-page-select')));
     $iconalt = get_string('navigatenext', 'assignfeedback_editpdf');
     $iconhtml = $this->pix_icon($nav_next, $iconalt, 'assignfeedback_editpdf');
     $navigation1 .= html_writer::tag('button', $iconhtml, array('disabled' => 'true', 'class' => 'navigate-next-button', 'accesskey' => $this->get_shortcut('navigate-next-button')));
     $navigation1 = html_writer::div($navigation1, 'navigation', array('role' => 'navigation'));
     $navigation2 .= $this->render_toolbar_button('comment_search', 'searchcomments', $this->get_shortcut('searchcomments'));
     $navigation2 = html_writer::div($navigation2, 'navigation-search', array('role' => 'navigation'));
     $toolbar1 = '';
     $toolbar2 = '';
     $toolbar3 = '';
     $toolbar4 = '';
     $clearfix = html_writer::div('', 'clearfix');
     if (!$widget->readonly) {
         // Comments.
         $toolbar1 .= $this->render_toolbar_button('comment', 'comment', $this->get_shortcut('comment'));
         $toolbar1 .= $this->render_toolbar_button('background_colour_clear', 'commentcolour', $this->get_shortcut('commentcolour'));
         $toolbar1 = html_writer::div($toolbar1, 'toolbar', array('role' => 'toolbar'));
         // Select Tool.
         $toolbar2 .= $this->render_toolbar_button('select', 'select', $this->get_shortcut('select'));
         $toolbar2 = html_writer::div($toolbar2, 'toolbar', array('role' => 'toolbar'));
         // Other Tools.
         $toolbar3 = $this->render_toolbar_button('pen', 'pen', $this->get_shortcut('pen'));
         $toolbar3 .= $this->render_toolbar_button('line', 'line', $this->get_shortcut('line'));
         $toolbar3 .= $this->render_toolbar_button('rectangle', 'rectangle', $this->get_shortcut('rectangle'));
         $toolbar3 .= $this->render_toolbar_button('oval', 'oval', $this->get_shortcut('oval'));
         $toolbar3 .= $this->render_toolbar_button('highlight', 'highlight', $this->get_shortcut('highlight'));
         $toolbar3 .= $this->render_toolbar_button('background_colour_clear', 'annotationcolour', $this->get_shortcut('annotationcolour'));
         $toolbar3 = html_writer::div($toolbar3, 'toolbar', array('role' => 'toolbar'));
         // Stamps.
         $toolbar4 .= $this->render_toolbar_button('stamp', 'stamp', 'n');
         $toolbar4 .= $this->render_toolbar_button('background_colour_clear', 'currentstamp', $this->get_shortcut('currentstamp'));
         $toolbar4 = html_writer::div($toolbar4, 'toolbar', array('role' => 'toolbar'));
     }
     // Toobars written in reverse order because they are floated right.
     $pageheader = html_writer::div($navigation1 . $navigation2 . $toolbar4 . $toolbar3 . $toolbar2 . $toolbar1 . $clearfix, 'pageheader');
     $body = $pageheader;
     // Loading progress bar.
     $progressbar = html_writer::div('', 'bar', array('style' => 'width: 0%'));
     $progressbar = html_writer::div($progressbar, 'progress progress-info progress-striped active', array('title' => get_string('loadingeditor', 'assignfeedback_editpdf'), 'role' => 'progressbar', 'aria-valuenow' => 0, 'aria-valuemin' => 0, 'aria-valuemax' => 100));
     $progressbarlabel = html_writer::div(get_string('generatingpdf', 'assignfeedback_editpdf'), 'progressbarlabel');
     $loading = html_writer::div($progressbar . $progressbarlabel, 'loading');
     $canvas = html_writer::div($loading, 'drawingcanvas');
     $body .= html_writer::div($canvas, 'drawingregion');
     $body .= '<hr/>';
     $footer = '';
     $editorparams = array(array('header' => $header, 'body' => $body, 'footer' => $footer, 'linkid' => $linkid, 'assignmentid' => $widget->assignment, 'userid' => $widget->userid, 'attemptnumber' => $widget->attemptnumber, 'stampfiles' => $widget->stampfiles, 'readonly' => $widget->readonly, 'pagetotal' => $widget->pagetotal));
     $this->page->requires->yui_module('moodle-assignfeedback_editpdf-editor', 'M.assignfeedback_editpdf.editor.init', $editorparams);
     $this->page->requires->strings_for_js(array('yellow', 'white', 'red', 'blue', 'green', 'black', 'clear', 'colourpicker', 'loadingeditor', 'pagexofy', 'deletecomment', 'addtoquicklist', 'filter', 'searchcomments', 'commentcontextmenu', 'deleteannotation', 'stamp', 'stamppicker', 'cannotopenpdf', 'pagenumber'), 'assignfeedback_editpdf');
     return $html;
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:86,代码来源:renderer.php

示例11: render_help_icon

 protected function render_help_icon(help_icon $helpicon)
 {
     global $CFG;
     $output = bootstrap::icon_help();
     if (!empty($helpicon->linktext)) {
         $output .= ' ' . $helpicon->linktext;
     }
     $url = new moodle_url($CFG->httpswwwroot . '/help.php', array('component' => $helpicon->component, 'identifier' => $helpicon->identifier, 'lang' => current_language()));
     $title = get_string($helpicon->identifier, $helpicon->component);
     $title = get_string('helpprefix2', '', trim($title, ". \t"));
     $id = html_writer::random_id('helpicon');
     $attributes = array('href' => $url, 'title' => $title, 'id' => $id);
     $output = html::a($attributes, $output);
     $this->page->requires->js_init_call('M.util.help_icon.add', array(array('id' => $id, 'url' => $url->out(false))));
     return $output;
 }
开发者ID:rbclark,项目名称:moodle-theme_bootstrap_renderers,代码行数:16,代码来源:core_renderer.php

示例12: render_scheduler_student_list

 /**
  * Rendering a list of student, to be displayed within a larger table
  *
  * @param scheduler_slot_table $slottable the table to rended
  * @return string the HTML output
  */
 public function render_scheduler_student_list(scheduler_student_list $studentlist)
 {
     $o = '';
     $toggleid = html_writer::random_id('toggle');
     if ($studentlist->expandable && count($studentlist->students) > 0) {
         $this->page->requires->yui_module('moodle-mod_scheduler-studentlist', 'M.mod_scheduler.studentlist.init', array($toggleid, (bool) $studentlist->expanded));
         $imgclass = 'studentlist-togglebutton';
         $alttext = get_string('showparticipants', 'scheduler');
         $o .= $this->output->pix_icon('t/switch', $alttext, 'moodle', array('id' => $toggleid, 'class' => $imgclass));
     }
     $divprops = array('id' => 'list' . $toggleid);
     $o .= html_writer::start_div('studentlist', $divprops);
     if (count($studentlist->students) > 0) {
         $editable = $studentlist->actionurl && $studentlist->editable;
         if ($editable) {
             $o .= html_writer::start_tag('form', array('action' => $studentlist->actionurl, 'method' => 'post', 'class' => 'studentselectform'));
         }
         foreach ($studentlist->students as $student) {
             $class = 'otherstudent';
             $checkbox = '';
             if ($studentlist->checkboxname) {
                 if ($editable) {
                     $checkbox = html_writer::checkbox($studentlist->checkboxname, $student->entryid, $student->checked, '', array('class' => 'studentselect'));
                 } else {
                     $img = $student->checked ? 'ticked' : 'unticked';
                     $checkbox = $this->render(new pix_icon($img, '', 'scheduler', array('class' => 'statictickbox')));
                 }
             }
             if ($studentlist->linkappointment) {
                 $name = $this->appointment_link($studentlist->scheduler, $student->user, $student->entryid);
             } else {
                 $name = fullname($student->user);
             }
             if ($student->highlight) {
                 $class .= ' highlight';
             }
             $picture = $this->user_picture($student->user, array('courseid' => $studentlist->scheduler->courseid));
             $grade = '';
             if ($studentlist->showgrades && $student->grade) {
                 $grade = $this->format_grade($studentlist->scheduler, $student->grade, true);
             }
             $o .= html_writer::div($checkbox . $picture . ' ' . $name . ' ' . $grade, $class);
         }
         if ($editable) {
             $o .= html_writer::empty_tag('input', array('type' => 'submit', 'class' => 'studentselectsubmit', 'value' => $studentlist->buttontext));
             $o .= html_writer::end_tag('form');
         }
     }
     $o .= html_writer::end_div();
     return $o;
 }
开发者ID:ninelanterns,项目名称:moodle-mod_scheduler,代码行数:57,代码来源:renderer.php

示例13: render_user_picture

 /**
  * Internal implementation of user image rendering.
  * @param user_picture $userpicture
  * @return string
  */
 protected function render_user_picture(user_picture $userpicture)
 {
     global $CFG, $DB;
     $user = $userpicture->user;
     if ($userpicture->alttext) {
         if (!empty($user->imagealt)) {
             $alt = $user->imagealt;
         } else {
             $alt = get_string('pictureof', '', fullname($user));
         }
     } else {
         $alt = '';
     }
     if (empty($userpicture->size)) {
         $file = 'f2';
         $size = 35;
     } else {
         if ($userpicture->size === true or $userpicture->size == 1) {
             $file = 'f1';
             $size = 100;
         } else {
             if ($userpicture->size >= 50) {
                 $file = 'f1';
                 $size = $userpicture->size;
             } else {
                 $file = 'f2';
                 $size = $userpicture->size;
             }
         }
     }
     $class = $userpicture->class;
     if ($user->picture == 1) {
         $usercontext = get_context_instance(CONTEXT_USER, $user->id);
         $src = moodle_url::make_pluginfile_url($usercontext->id, 'user', 'icon', NULL, '/', $file);
     } else {
         if ($user->picture == 2) {
             //TODO: gravatar user icon support
         } else {
             // Print default user pictures (use theme version if available)
             $class .= ' defaultuserpic';
             $src = $this->pix_url('u/' . $file);
         }
     }
     $attributes = array('src' => $src, 'alt' => $alt, 'title' => $alt, 'class' => $class, 'width' => $size, 'height' => $size);
     // get the image html output fisrt
     $output = html_writer::empty_tag('img', $attributes);
     // then wrap it in link if needed
     if (!$userpicture->link) {
         return $output;
     }
     if (empty($userpicture->courseid)) {
         $courseid = $this->page->course->id;
     } else {
         $courseid = $userpicture->courseid;
     }
     if ($courseid == SITEID) {
         $url = new moodle_url('/user/profile.php', array('id' => $user->id));
     } else {
         $url = new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $courseid));
     }
     $attributes = array('href' => $url);
     if ($userpicture->popup) {
         $id = html_writer::random_id('userpicture');
         $attributes['id'] = $id;
         $this->add_action_handler(new popup_action('click', $url), $id);
     }
     return html_writer::tag('a', $output, $attributes);
 }
开发者ID:nfreear,项目名称:moodle,代码行数:73,代码来源:outputrenderers.php

示例14: js_init_code

 /**
  * Add short static javascript code fragment to page footer.
  * This is intended primarily for loading of js modules and initialising page layout.
  * Ideally the JS code fragment should be stored in plugin renderer so that themes
  * may override it.
  *
  * @param string $jscode
  * @param bool $ondomready wait for dom ready (helps with some IE problems when modifying DOM)
  * @param array $module JS module specification array
  */
 public function js_init_code($jscode, $ondomready = false, array $module = null)
 {
     $jscode = trim($jscode, " ;\n") . ';';
     $uniqid = html_writer::random_id();
     $startjs = " M.util.js_pending('" . $uniqid . "');";
     $endjs = " M.util.js_complete('" . $uniqid . "');";
     if ($module) {
         $this->js_module($module);
         $modulename = $module['name'];
         $jscode = "{$startjs} Y.use('{$modulename}', function(Y) { {$jscode} {$endjs} });";
     }
     if ($ondomready) {
         $jscode = "{$startjs} Y.on('domready', function() { {$jscode} {$endjs} });";
     }
     $this->jsinitcode[] = $jscode;
 }
开发者ID:rsturley,项目名称:moodle,代码行数:26,代码来源:outputrequirementslib.php

示例15: embed

 /**
  * Generates code required to embed the player.
  *
  * @param array $urls Moodle URLs of media files
  * @param string $name Display name; '' to use default
  * @param int $width Optional width; 0 to use default
  * @param int $height Optional height; 0 to use default
  * @param array $options Options array
  *                       image
  *                           use 'image' key with a moodle_url to an image as poster image
  *                           displayed before playback starts.
  *                       subtitles
  *                           use 'subtitles' key with an array of subtitle track files
  *                           in vtt or srt format indexed by label name.
  *                           Example: $options['subtitles']['English'] = http://example.com/english.vtt
  * @return string HTML code for embed
  */
 public function embed($urls, $name, $width, $height, $options)
 {
     global $PAGE, $CFG;
     // We do embedding only here. JW player setup is done in the filter.
     $output = '';
     $sources = array();
     $streams = array();
     $playersetupdata = array();
     foreach ($urls as $url) {
         // Add the details for this source.
         $source = array('file' => urldecode($url->out(false)));
         // Help to determine the type of mov.
         $ext = core_media::get_extension($url);
         if ($ext === 'mov') {
             $source['type'] = 'mp4';
         }
         if ($ext === 'mpd') {
             // Dash variable needs to be set if we have a dash stream_bucket_append
             $playersetupdata['dash'] = true;
             $streams[] = $source;
         } else {
             if ($url->get_scheme() === 'rtmp' || $ext === 'm3u8' || $ext === 'smil') {
                 // For RTMP, HLS and Dynamic RTMP we set rendering mode to Flash to
                 // ensure streams play is possible even when mp4 fallbacks are given.
                 $playersetupdata['primary'] = 'flash';
                 $streams[] = $source;
             } else {
                 $sources[] = $source;
             }
         }
     }
     // Make sure that stream URLs are at the start of the list.
     $sources = array_merge($streams, $sources);
     if (count($sources) > 0) {
         $playerid = 'filter_jwplayer_media_' . html_writer::random_id();
         // Process data-jwplayer attributes.
         if (!empty($options['htmlattributes'])) {
             foreach ($options['htmlattributes'] as $attrib => $atval) {
                 if (strpos($attrib, 'data-jwplayer-') === 0) {
                     // Treat attributes starting data-jwplayer as options.
                     $opt = preg_replace('~^data-jwplayer-~', '', $attrib);
                     $atval = trim((string) $atval);
                     if (strpos($atval, ': ') || strpos($atval, '; ') || strpos($atval, ', ')) {
                         // If attribute contains any of :;, it needs to be split to an array.
                         $atvalarray = preg_split('~[,;] ~', $atval);
                         $newatval = array();
                         foreach ($atvalarray as $dataval) {
                             $newdata = explode(': ', $dataval, 2);
                             if (count($newdata) > 1) {
                                 $newdata[1] = trim($newdata[1]);
                                 if (filter_var($newdata[1], FILTER_VALIDATE_URL)) {
                                     // If value is a URL convert to moodle_url.
                                     $newdata[1] = new moodle_url($newdata[1]);
                                 }
                                 $newatval[trim($newdata[0])] = $newdata[1];
                             } else {
                                 $newdata[0] = trim($newdata[0]);
                                 if (filter_var($newdata[0], FILTER_VALIDATE_URL)) {
                                     // If value is a URL convert to moodle_url.
                                     $newdata[0] = new moodle_url($newdata[0]);
                                 }
                                 $newatval[] = $newdata[0];
                             }
                         }
                         $atval = $newatval;
                     } else {
                         if (filter_var($atval, FILTER_VALIDATE_URL)) {
                             // If value is a URL convert to moodle_url.
                             $atval = new moodle_url($atval);
                         }
                     }
                     $options[$opt] = $atval;
                 } else {
                     // Pass any other global HTML attributes to the player span tag.
                     $globalhtmlattributes = array('accesskey', 'class', 'contenteditable', 'contextmenu', 'dir', 'draggable', 'dropzone', 'hidden', 'id', 'lang', 'spellcheck', 'style', 'tabindex', 'title', 'translate');
                     if (in_array($attrib, $globalhtmlattributes) || strpos($attrib, 'data-' === 0)) {
                         $newattributes[$attrib] = $atval;
                     }
                 }
             }
         }
         // Set up playlist.
         $playlistitem = array('sources' => $sources);
//.........这里部分代码省略.........
开发者ID:parksandwildlife,项目名称:learning,代码行数:101,代码来源:lib.php


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