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


PHP portfolio_add_button::set_formats方法代码示例

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


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

示例1: array

 function test_set_formats()
 {
     $button = new portfolio_add_button();
     $button->set_callback_options('assignment_portfolio_caller', array('id' => 6), '/mod/assignment/lib.php');
     $formats = array(PORTFOLIO_FORMAT_FILE, PORTFOLIO_FORMAT_IMAGE);
     $button->set_formats($formats);
     $this->assertEqual(2, count($button->get_formats()));
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:8,代码来源:testportfolioaddbutton.php

示例2: apply

 public function apply($discussion, $all, $selected, $formdata)
 {
     global $COURSE, $USER, $CFG;
     if (!$CFG->enableportfolios) {
         return '';
     }
     /*
      * It is necessary to encode the array of selected discussion posts as text in order to
      * pass the data in the button callback options because it gets filtered as PARAM_ALPHA
      */
     if (is_array($selected) && !empty($selected)) {
         $seltext = implode('x', $selected);
         $letters = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j');
         $posts = '';
         $selarray = str_split($seltext);
         foreach ($selarray as $char) {
             $posts .= $char == 'x' ? $char : $letters[$char];
         }
     } else {
         $posts = '';
     }
     // get the id of the forum
     $forumobj = $discussion->get_forum();
     $forumngid = $forumobj->get_id();
     require_once $CFG->libdir . '/portfoliolib.php';
     // check if the forum is shared and pass the cloneid in the callback options
     $linkparams = $discussion->get_link_params_array();
     if (array_key_exists('clone', $linkparams)) {
         $cloneid = $linkparams['clone'];
     } else {
         $cloneid = 0;
     }
     $button = new portfolio_add_button();
     $button->set_callback_options('forumng_all_portfolio_caller', array('forumngid' => $forumngid, 'cloneid' => $cloneid, 'posts' => $posts, 'discussionid' => $discussion->get_id()), 'mod_forumng');
     $button->set_formats(PORTFOLIO_FORMAT_PLAINHTML);
     // redirect to the export page
     redirect($button->to_html(PORTFOLIO_ADD_FAKE_URL));
 }
开发者ID:ULCC-QMUL,项目名称:moodle-mod_forumng,代码行数:38,代码来源:export.php

示例3: forum_print_post


//.........这里部分代码省略.........
    $age = time() - $post->created;
    if (!$post->parent && $forum->type == 'news' && $discussion->timestart > time()) {
        $age = 0;
    }
    if ($forum->type == 'single' and $discussion->firstpost == $post->id) {
        if (has_capability('moodle/course:manageactivities', $modcontext)) {
            // The first post in single simple is the forum description.
            $commands[] = array('url' => new moodle_url('/course/modedit.php', array('update' => $cm->id, 'sesskey' => sesskey(), 'return' => 1)), 'text' => $str->edit);
        }
    } else {
        if ($ownpost && $age < $CFG->maxeditingtime || $cm->cache->caps['mod/forum:editanypost']) {
            $commands[] = array('url' => new moodle_url('/mod/forum/post.php', array('edit' => $post->id)), 'text' => $str->edit);
        }
    }
    if ($cm->cache->caps['mod/forum:splitdiscussions'] && $post->parent && $forum->type != 'single') {
        $commands[] = array('url' => new moodle_url('/mod/forum/post.php', array('prune' => $post->id)), 'text' => $str->prune, 'title' => $str->pruneheading);
    }
    if ($forum->type == 'single' and $discussion->firstpost == $post->id) {
        // Do not allow deleting of first post in single simple type.
    } else {
        if ($ownpost && $age < $CFG->maxeditingtime && $cm->cache->caps['mod/forum:deleteownpost'] || $cm->cache->caps['mod/forum:deleteanypost']) {
            $commands[] = array('url' => new moodle_url('/mod/forum/post.php', array('delete' => $post->id)), 'text' => $str->delete);
        }
    }
    if ($reply) {
        $commands[] = array('url' => new moodle_url('/mod/forum/post.php#mformforum', array('reply' => $post->id)), 'text' => $str->reply);
    }
    if ($CFG->enableportfolios && ($cm->cache->caps['mod/forum:exportpost'] || $ownpost && $cm->cache->caps['mod/forum:exportownpost'])) {
        $p = array('postid' => $post->id);
        require_once $CFG->libdir . '/portfoliolib.php';
        $button = new portfolio_add_button();
        $button->set_callback_options('forum_portfolio_caller', array('postid' => $post->id), 'mod_forum');
        if (empty($attachments)) {
            $button->set_formats(PORTFOLIO_FORMAT_PLAINHTML);
        } else {
            $button->set_formats(PORTFOLIO_FORMAT_RICHHTML);
        }
        $porfoliohtml = $button->to_html(PORTFOLIO_ADD_TEXT_LINK);
        if (!empty($porfoliohtml)) {
            $commands[] = $porfoliohtml;
        }
    }
    // Finished building commands
    // Begin output
    $output = '';
    if ($istracked) {
        if ($postisread) {
            $forumpostclass = ' read';
        } else {
            $forumpostclass = ' unread';
            // If this is the first unread post printed then give it an anchor and id of unread.
            if (!$firstunreadanchorprinted) {
                $output .= html_writer::tag('a', '', array('id' => 'unread'));
                $firstunreadanchorprinted = true;
            }
        }
    } else {
        // ignore trackign status if not tracked or tracked param missing
        $forumpostclass = '';
    }
    $topicclass = '';
    if (empty($post->parent)) {
        $topicclass = ' firstpost starter';
    }
    if (!empty($post->lastpost)) {
        $forumpostclass .= ' lastpost';
开发者ID:rezaies,项目名称:moodle,代码行数:67,代码来源:lib.php

示例4: data_print_template

/**
 * takes a list of records, the current data, a search string,
 * and mode to display prints the translated template
 *
 * @global object
 * @global object
 * @param string $template
 * @param array $records
 * @param object $data
 * @param string $search
 * @param int $page
 * @param bool $return
 * @return mixed
 */
function data_print_template($template, $records, $data, $search='', $page=0, $return=false) {
    global $CFG, $DB, $OUTPUT;
    $cm = get_coursemodule_from_instance('data', $data->id);
    $context = get_context_instance(CONTEXT_MODULE, $cm->id);

    static $fields = NULL;
    static $isteacher;
    static $dataid = NULL;

    if (empty($dataid)) {
        $dataid = $data->id;
    } else if ($dataid != $data->id) {
        $fields = NULL;
    }

    if (empty($fields)) {
        $fieldrecords = $DB->get_records('data_fields', array('dataid'=>$data->id));
        foreach ($fieldrecords as $fieldrecord) {
            $fields[]= data_get_field($fieldrecord, $data);
        }
        $isteacher = has_capability('mod/data:managetemplates', $context);
    }

    if (empty($records)) {
        return;
    }

    foreach ($records as $record) {   // Might be just one for the single template

    // Replacing tags
        $patterns = array();
        $replacement = array();

    // Then we generate strings to replace for normal tags
        foreach ($fields as $field) {
            $patterns[]='[['.$field->field->name.']]';
            $replacement[] = highlight($search, $field->display_browse_field($record->id, $template));
        }

    // Replacing special tags (##Edit##, ##Delete##, ##More##)
        $patterns[]='##edit##';
        $patterns[]='##delete##';
        if (has_capability('mod/data:manageentries', $context) or data_isowner($record->id)) {
            $replacement[] = '<a href="'.$CFG->wwwroot.'/mod/data/edit.php?d='
                             .$data->id.'&amp;rid='.$record->id.'&amp;sesskey='.sesskey().'"><img src="'.$OUTPUT->pix_url('t/edit') . '" class="iconsmall" alt="'.get_string('edit').'" title="'.get_string('edit').'" /></a>';
            $replacement[] = '<a href="'.$CFG->wwwroot.'/mod/data/view.php?d='
                             .$data->id.'&amp;delete='.$record->id.'&amp;sesskey='.sesskey().'"><img src="'.$OUTPUT->pix_url('t/delete') . '" class="iconsmall" alt="'.get_string('delete').'" title="'.get_string('delete').'" /></a>';
        } else {
            $replacement[] = '';
            $replacement[] = '';
        }

        $moreurl = $CFG->wwwroot . '/mod/data/view.php?d=' . $data->id . '&amp;rid=' . $record->id;
        if ($search) {
            $moreurl .= '&amp;filter=1';
        }
        $patterns[]='##more##';
        $replacement[] = '<a href="' . $moreurl . '"><img src="' . $OUTPUT->pix_url('i/search') . '" class="iconsmall" alt="' . get_string('more', 'data') . '" title="' . get_string('more', 'data') . '" /></a>';

        $patterns[]='##moreurl##';
        $replacement[] = $moreurl;

        $patterns[]='##user##';
        $replacement[] = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$record->userid.
                               '&amp;course='.$data->course.'">'.fullname($record).'</a>';

        $patterns[]='##export##';

        if (!empty($CFG->enableportfolios) && ($template == 'singletemplate' || $template == 'listtemplate')
            && ((has_capability('mod/data:exportentry', $context)
                || (data_isowner($record->id) && has_capability('mod/data:exportownentry', $context))))) {
            require_once($CFG->libdir . '/portfoliolib.php');
            $button = new portfolio_add_button();
            $button->set_callback_options('data_portfolio_caller', array('id' => $cm->id, 'recordid' => $record->id), '/mod/data/locallib.php');
            list($formats, $files) = data_portfolio_caller::formats($fields, $record);
            $button->set_formats($formats);
            $replacement[] = $button->to_html(PORTFOLIO_ADD_ICON_LINK);
        } else {
            $replacement[] = '';
        }

        $patterns[] = '##timeadded##';
        $replacement[] = userdate($record->timecreated);

        $patterns[] = '##timemodified##';
        $replacement [] = userdate($record->timemodified);
//.........这里部分代码省略.........
开发者ID:nottmoo,项目名称:moodle,代码行数:101,代码来源:lib.php

示例5: data_print_template

/**
 * takes a list of records, the current data, a search string,
 * and mode to display prints the translated template
 *
 * @global object
 * @global object
 * @param string $template
 * @param array $records
 * @param object $data
 * @param string $search
 * @param int $page
 * @param bool $return
 * @param object $jumpurl a moodle_url by which to jump back to the record list (can be null)
 * @return mixed
 */
function data_print_template($template, $records, $data, $search = '', $page = 0, $return = false, moodle_url $jumpurl = null)
{
    global $CFG, $DB, $OUTPUT;
    $cm = get_coursemodule_from_instance('data', $data->id);
    $context = context_module::instance($cm->id);
    static $fields = NULL;
    static $isteacher;
    static $dataid = NULL;
    if (empty($dataid)) {
        $dataid = $data->id;
    } else {
        if ($dataid != $data->id) {
            $fields = NULL;
        }
    }
    if (empty($fields)) {
        $fieldrecords = $DB->get_records('data_fields', array('dataid' => $data->id));
        foreach ($fieldrecords as $fieldrecord) {
            $fields[] = data_get_field($fieldrecord, $data);
        }
        $isteacher = has_capability('mod/data:managetemplates', $context);
    }
    if (empty($records)) {
        return;
    }
    if (!$jumpurl) {
        $jumpurl = new moodle_url('/mod/data/view.php', array('d' => $data->id));
    }
    $jumpurl = new moodle_url($jumpurl, array('page' => $page, 'sesskey' => sesskey()));
    // Check whether this activity is read-only at present
    $readonly = data_in_readonly_period($data);
    foreach ($records as $record) {
        // Might be just one for the single template
        // Replacing tags
        $patterns = array();
        $replacement = array();
        // Then we generate strings to replace for normal tags
        foreach ($fields as $field) {
            $patterns[] = '[[' . $field->field->name . ']]';
            $replacement[] = highlight($search, $field->display_browse_field($record->id, $template));
        }
        $canmanageentries = has_capability('mod/data:manageentries', $context);
        // Replacing special tags (##Edit##, ##Delete##, ##More##)
        $patterns[] = '##edit##';
        $patterns[] = '##delete##';
        if ($canmanageentries || !$readonly && data_isowner($record->id)) {
            $replacement[] = '<a href="' . $CFG->wwwroot . '/mod/data/edit.php?d=' . $data->id . '&amp;rid=' . $record->id . '&amp;sesskey=' . sesskey() . '"><img src="' . $OUTPUT->pix_url('t/edit') . '" class="iconsmall" alt="' . get_string('edit') . '" title="' . get_string('edit') . '" /></a>';
            $replacement[] = '<a href="' . $CFG->wwwroot . '/mod/data/view.php?d=' . $data->id . '&amp;delete=' . $record->id . '&amp;sesskey=' . sesskey() . '"><img src="' . $OUTPUT->pix_url('t/delete') . '" class="iconsmall" alt="' . get_string('delete') . '" title="' . get_string('delete') . '" /></a>';
        } else {
            $replacement[] = '';
            $replacement[] = '';
        }
        $moreurl = $CFG->wwwroot . '/mod/data/view.php?d=' . $data->id . '&amp;rid=' . $record->id;
        if ($search) {
            $moreurl .= '&amp;filter=1';
        }
        $patterns[] = '##more##';
        $replacement[] = '<a href="' . $moreurl . '"><img src="' . $OUTPUT->pix_url('t/preview') . '" class="iconsmall" alt="' . get_string('more', 'data') . '" title="' . get_string('more', 'data') . '" /></a>';
        $patterns[] = '##moreurl##';
        $replacement[] = $moreurl;
        $patterns[] = '##delcheck##';
        if ($canmanageentries) {
            $replacement[] = html_writer::checkbox('delcheck[]', $record->id, false, '', array('class' => 'recordcheckbox'));
        } else {
            $replacement[] = '';
        }
        $patterns[] = '##user##';
        $replacement[] = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $record->userid . '&amp;course=' . $data->course . '">' . fullname($record) . '</a>';
        $patterns[] = '##userpicture##';
        $ruser = user_picture::unalias($record, null, 'userid');
        $replacement[] = $OUTPUT->user_picture($ruser, array('courseid' => $data->course));
        $patterns[] = '##export##';
        if (!empty($CFG->enableportfolios) && ($template == 'singletemplate' || $template == 'listtemplate') && (has_capability('mod/data:exportentry', $context) || data_isowner($record->id) && has_capability('mod/data:exportownentry', $context))) {
            require_once $CFG->libdir . '/portfoliolib.php';
            $button = new portfolio_add_button();
            $button->set_callback_options('data_portfolio_caller', array('id' => $cm->id, 'recordid' => $record->id), 'mod_data');
            list($formats, $files) = data_portfolio_caller::formats($fields, $record);
            $button->set_formats($formats);
            $replacement[] = $button->to_html(PORTFOLIO_ADD_ICON_LINK);
        } else {
            $replacement[] = '';
        }
        $patterns[] = '##timeadded##';
        $replacement[] = userdate($record->timecreated);
        $patterns[] = '##timemodified##';
//.........这里部分代码省略.........
开发者ID:Keneth1212,项目名称:moodle,代码行数:101,代码来源:lib.php

示例6: referentiel_menu_certificat

function referentiel_menu_certificat($context, $certificat_id, $referentiel_instance_id, $verrou, $userid = 0, $select_acc = 0, $rang = 0, $dossier_ferme)
{
    global $CFG;
    global $OUTPUT;
    global $USER;
    $s = "";
    $s .= '<tr valign="top">';
    $s .= '<td align="center" colspan="6">' . "\n";
    $s .= '&nbsp; <a href="' . $CFG->wwwroot . '/mod/referentiel/certificat.php?d=' . $referentiel_instance_id . '&amp;select_acc=' . $select_acc . '&amp;certificat_id=' . $certificat_id . '&amp;userid=' . $userid . '&amp;mode=listcertifsingle&amp;sesskey=' . sesskey() . '#certificat_' . $certificat_id . '"><img src="' . $OUTPUT->pix_url('search', 'referentiel') . '" alt="' . get_string('plus', 'referentiel') . '" title="' . get_string('plus', 'referentiel') . '" /></a>' . "\n";
    if (!$dossier_ferme) {
        $s .= '&nbsp; <a href="' . $CFG->wwwroot . '/mod/referentiel/certificat.php?d=' . $referentiel_instance_id . '&amp;select_acc=' . $select_acc . '&amp;certificat_id=' . $certificat_id . '&amp;userid=' . $userid . '&amp;mode=updatecertif&amp;sesskey=' . sesskey() . '"><img src="' . $OUTPUT->pix_url('/t/edit') . '" alt="' . get_string('edit') . '" title="' . get_string('edit') . '" /></a>' . "\n";
    }
    if (has_capability('mod/referentiel:comment', $context) && !$dossier_ferme) {
        //		or referentiel_certificat_isowner($certificat_id)) {
        $s .= '&nbsp; <a href="' . $CFG->wwwroot . '/mod/referentiel/certificat.php?d=' . $referentiel_instance_id . '&amp;select_acc=' . $select_acc . '&amp;certificat_id=' . $certificat_id . '&amp;userid=' . $userid . '&amp;mode=commentcertif&amp;sesskey=' . sesskey() . '"><img src="' . $OUTPUT->pix_url('feedback', 'referentiel') . '" alt="' . get_string('comment', 'referentiel') . '" title="' . get_string('comment', 'referentiel') . '" /></a>' . "\n";
    }
    if (has_capability('mod/referentiel:managecertif', $context)) {
        $s .= '&nbsp; <a href="' . $CFG->wwwroot . '/mod/referentiel/certificat.php?d=' . $referentiel_instance_id . '&amp;select_acc=' . $select_acc . '&amp;certificat_id=' . $certificat_id . '&amp;userid=' . $userid . '&amp;mode=deletecertif&amp;sesskey=' . sesskey() . '"><img src="' . $OUTPUT->pix_url('/t/delete') . '" alt="' . get_string('certificat_initialiser', 'referentiel') . '" title="' . get_string('certificat_initialiser', 'referentiel') . '" /></a>' . "\n";
        if (!$dossier_ferme) {
            if ($verrou) {
                $s .= '&nbsp; <a href="' . $CFG->wwwroot . '/mod/referentiel/certificat.php?d=' . $referentiel_instance_id . '&amp;select_acc=' . $select_acc . '&amp;certificat_id=' . $certificat_id . '&amp;userid=' . $userid . '&amp;mode=deverrouiller&amp;sesskey=' . sesskey() . '"><img src="' . $OUTPUT->pix_url('/t/go') . '" alt="' . get_string('deverrouiller', 'referentiel') . '" title="' . get_string('deverrouiller', 'referentiel') . '" /></a>' . "\n";
            } else {
                $s .= '&nbsp; <a href="' . $CFG->wwwroot . '/mod/referentiel/certificat.php?d=' . $referentiel_instance_id . '&amp;select_acc=' . $select_acc . '&amp;certificat_id=' . $certificat_id . '&amp;userid=' . $userid . '&amp;mode=verrouiller&amp;sesskey=' . sesskey() . '"><img src="' . $OUTPUT->pix_url('/t/stop') . '" alt="' . get_string('verrouiller', 'referentiel') . '" title="' . get_string('verrouiller', 'referentiel') . '" /></a>' . "\n";
            }
            $s .= '&nbsp; <a href="' . $CFG->wwwroot . '/mod/referentiel/certificat.php?d=' . $referentiel_instance_id . '&amp;select_acc=' . $select_acc . '&amp;certificat_id=' . $certificat_id . '&amp;userid=' . $userid . '&amp;mode=clorecertificat&amp;sesskey=' . sesskey() . '"><img src="' . $OUTPUT->pix_url('cadenas_f', 'referentiel') . '" alt="' . get_string('c_clore', 'referentiel') . '" title="' . get_string('c_clore', 'referentiel') . '" /></a>' . "\n";
        } else {
            $s .= '&nbsp; <a href="' . $CFG->wwwroot . '/mod/referentiel/certificat.php?d=' . $referentiel_instance_id . '&amp;select_acc=' . $select_acc . '&amp;certificat_id=' . $certificat_id . '&amp;userid=' . $userid . '&amp;mode=ouvrircertificat&amp;sesskey=' . sesskey() . '"><img src="' . $OUTPUT->pix_url('cadenas_o', 'referentiel') . '" alt="' . get_string('c_ouvrir', 'referentiel') . '" title="' . get_string('c_ouvrir', 'referentiel') . '" /></a>' . "\n";
        }
        if (referentiel_site_can_print_referentiel($referentiel_instance_id)) {
            $s .= '&nbsp; <a href="' . $CFG->wwwroot . '/mod/referentiel/print_certificat.php?d=' . $referentiel_instance_id . '&amp;select_acc=' . $select_acc . '&amp;certificat_id=' . $certificat_id . '&amp;userid=' . $userid . '&amp;mode=printcertif&amp;sesskey=' . sesskey() . '"><img src="' . $OUTPUT->pix_url('printer', 'referentiel') . '" alt="' . get_string('print', 'referentiel') . '" title="' . get_string('print', 'referentiel') . '" /></a>' . "\n";
        }
    }
    // Portofolio
    if (!empty($CFG->enableportfolios)) {
        require_once $CFG->libdir . '/portfoliolib.php';
        // Mahara export stuff
        $button = new portfolio_add_button();
        // Version anterieure à Moodle 2.4
        // $button->set_callback_options('referentiel_portfolio_caller',
        //            array('instanceid' => $referentiel_instance_id, 'certificatid' => $certificat_id, 'report' => 0, 'export_format' => ''), '/mod/referentiel/portfolio/mahara/locallib_portfolio.php');
        // Version Moodle 2.4
        $button->set_callback_options('referentiel_portfolio_caller', array('instanceid' => $referentiel_instance_id, 'certificatid' => $certificat_id, 'report' => 0, 'export_format' => ''), 'mod_referentiel');
        $button->set_formats(array(PORTFOLIO_FORMAT_PLAINHTML, PORTFOLIO_FORMAT_LEAP2A));
        $s .= $button->to_html(PORTFOLIO_ADD_ICON_LINK);
        // Mahara ATranscript stuff
        // Ne pas activer pour le moment (juin 2012) car le developpement n'est pas achevé
        if (MAHARA_ARTEFACT_ATRANSCRIPT) {
            $button = new portfolio_add_button();
            // Version antérieure à Moodle 2.4
            //            $button->set_callback_options('atranscript_portfolio_caller',
            //                array('instanceid' => $referentiel_instance_id, 'userid' => $USER->id, 'certificatid' => $certificat_id, 'export_format' => PORTFOLIO_FORMAT_LEAP2A), '/mod/referentiel/portfolio/mahara/atranscript_artefact/locallib_portfolio.php');
            // Version  Moodle 2.4
            $button->set_callback_options('atranscript_portfolio_caller', array('instanceid' => $referentiel_instance_id, 'userid' => $USER->id, 'certificatid' => $certificat_id, 'export_format' => PORTFOLIO_FORMAT_LEAP2A), 'mod_referentiel');
            $button->set_formats(array(PORTFOLIO_FORMAT_LEAP2A));
            $s .= $button->to_html(PORTFOLIO_ADD_ICON_LINK, get_string('atranscript', 'referentiel'));
            // $s.=$button->to_html(PORTFOLIO_ADD_TEXT_LINK);
        }
    }
    $s .= '</td></tr>' . "\n";
    if ($rang % 2 == 0) {
        $s .= '<td class="couleur_paire" heigth="4" colspan="6"></td>' . "\n";
    } else {
        $s .= '<td class="couleur_impaire" heigth="4" colspan="6"></td>' . "\n";
    }
    return $s;
}
开发者ID:jfruitet,项目名称:moodle_referentiel,代码行数:66,代码来源:print_lib_certificat.php

示例7: glossary_print_entry_icons

/**
 *
 * @global object
 * @global object
 * @global object
 * @param object $course
 * @param object $cm
 * @param object $glossary
 * @param object $entry
 * @param string $mode
 * @param string $hook
 * @param string $type
 * @return string|void
 */
function glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode='',$hook='', $type = 'print') {
    global $USER, $CFG, $DB, $OUTPUT;

    $context = get_context_instance(CONTEXT_MODULE, $cm->id);

    $output = false;   //To decide if we must really return text in "return". Activate when needed only!
    $importedentry = ($entry->sourceglossaryid == $glossary->id);
    $ismainglossary = $glossary->mainglossary;


    $return = '<span class="commands">';
    // Differentiate links for each entry.
    $altsuffix = ': '.strip_tags(format_text($entry->concept));

    if (!$entry->approved) {
        $output = true;
        $return .= get_string('entryishidden','glossary');
    }

    $iscurrentuser = ($entry->userid == $USER->id);

    if (has_capability('mod/glossary:manageentries', $context) or (isloggedin() and has_capability('mod/glossary:write', $context) and $iscurrentuser)) {
        // only teachers can export entries so check it out
        if (has_capability('mod/glossary:export', $context) and !$ismainglossary and !$importedentry) {
            $mainglossary = $DB->get_record('glossary', array('mainglossary'=>1,'course'=>$course->id));
            if ( $mainglossary ) {  // if there is a main glossary defined, allow to export the current entry
                $output = true;
                $return .= ' <a title="'.get_string('exporttomainglossary','glossary') . '" href="exportentry.php?id='.$entry->id.'&amp;prevmode='.$mode.'&amp;hook='.urlencode($hook).'"><img src="'.$OUTPUT->pix_url('export', 'glossary').'" class="iconsmall" alt="'.get_string('exporttomainglossary','glossary').$altsuffix.'" /></a>';
            }
        }

        if ( $entry->sourceglossaryid ) {
            $icon = $OUTPUT->pix_url('minus', 'glossary');   // graphical metaphor (minus) for deleting an imported entry
        } else {
            $icon = $OUTPUT->pix_url('t/delete');
        }

        //Decide if an entry is editable:
        // -It isn't a imported entry (so nobody can edit a imported (from secondary to main) entry)) and
        // -The user is teacher or he is a student with time permissions (edit period or editalways defined).
        $ineditperiod = ((time() - $entry->timecreated <  $CFG->maxeditingtime) || $glossary->editalways);
        if ( !$importedentry and (has_capability('mod/glossary:manageentries', $context) or ($entry->userid == $USER->id and ($ineditperiod and has_capability('mod/glossary:write', $context))))) {
            $output = true;
            $return .= " <a title=\"" . get_string("delete") . "\" href=\"deleteentry.php?id=$cm->id&amp;mode=delete&amp;entry=$entry->id&amp;prevmode=$mode&amp;hook=".urlencode($hook)."\"><img src=\"";
            $return .= $icon;
            $return .= "\" class=\"iconsmall\" alt=\"" . get_string("delete") .$altsuffix."\" /></a> ";

            $return .= " <a title=\"" . get_string("edit") . "\" href=\"edit.php?cmid=$cm->id&amp;id=$entry->id&amp;mode=$mode&amp;hook=".urlencode($hook)."\"><img src=\"" . $OUTPUT->pix_url('t/edit') . "\" class=\"iconsmall\" alt=\"" . get_string("edit") .$altsuffix. "\" /></a>";
        } elseif ( $importedentry ) {
            $return .= " <font size=\"-1\">" . get_string("exportedentry","glossary") . "</font>";
        }
    }
    if (!empty($CFG->enableportfolios) && (has_capability('mod/glossary:exportentry', $context) || ($iscurrentuser && has_capability('mod/glossary:exportownentry', $context)))) {
        require_once($CFG->libdir . '/portfoliolib.php');
        $button = new portfolio_add_button();
        $button->set_callback_options('glossary_entry_portfolio_caller',  array('id' => $cm->id, 'entryid' => $entry->id), '/mod/glossary/locallib.php');

        $filecontext = $context;
        if ($entry->sourceglossaryid == $cm->instance) {
            if ($maincm = get_coursemodule_from_instance('glossary', $entry->glossaryid)) {
                $filecontext = get_context_instance(CONTEXT_MODULE, $maincm->id);
            }
        }
        $fs = get_file_storage();
        if ($files = $fs->get_area_files($filecontext->id, 'mod_glossary', 'attachment', $entry->id, "timemodified", false)) {
            $button->set_formats(PORTFOLIO_FORMAT_RICHHTML);
        } else {
            $button->set_formats(PORTFOLIO_FORMAT_PLAINHTML);
        }

        $return .= $button->to_html(PORTFOLIO_ADD_ICON_LINK);
    }
    $return .= "&nbsp;&nbsp;"; // just to make up a little the output in Mozilla ;)

    $return .= '</span>';

    if (!empty($CFG->usecomments) && has_capability('mod/glossary:comment', $context) and $glossary->allowcomments) {
        require_once($CFG->dirroot . '/comment/lib.php');
        $cmt = new stdClass();
        $cmt->component = 'mod_glossary';
        $cmt->context  = $context;
        $cmt->course   = $course;
        $cmt->cm       = $cm;
        $cmt->area     = 'glossary_entry';
        $cmt->itemid   = $entry->id;
        $cmt->showcount = true;
//.........这里部分代码省略.........
开发者ID:rolandovanegas,项目名称:moodle,代码行数:101,代码来源:lib.php

示例8: view

 function view()
 {
     global $OUTPUT, $CFG, $USER, $PAGE;
     $edit = optional_param('edit', 0, PARAM_BOOL);
     $saved = optional_param('saved', 0, PARAM_BOOL);
     $context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
     require_capability('mod/assignment:view', $context);
     $submission = $this->get_submission($USER->id, false);
     //Guest can not submit nor edit an assignment (bug: 4604)
     if (!is_enrolled($this->context, $USER, 'mod/assignment:submit')) {
         $editable = false;
     } else {
         $editable = $this->isopen() && (!$submission || $this->assignment->resubmit || !$submission->timemarked);
     }
     $editmode = ($editable and $edit);
     if ($editmode) {
         // prepare form and process submitted data
         $editoroptions = array('noclean' => false, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $this->course->maxbytes);
         $data = new stdClass();
         $data->id = $this->cm->id;
         $data->edit = 1;
         if ($submission) {
             $data->sid = $submission->id;
             $data->text = $submission->data1;
             $data->textformat = $submission->data2;
         } else {
             $data->sid = NULL;
             $data->text = '';
             $data->textformat = NULL;
         }
         $data = file_prepare_standard_editor($data, 'text', $editoroptions, $this->context, 'mod_assignment', $this->filearea, $data->sid);
         $mform = new mod_assignment_online_edit_form(null, array($data, $editoroptions));
         if ($mform->is_cancelled()) {
             redirect($PAGE->url);
         }
         if ($data = $mform->get_data()) {
             $submission = $this->get_submission($USER->id, true);
             //create the submission if needed & its id
             $data = file_postupdate_standard_editor($data, 'text', $editoroptions, $this->context, 'mod_assignment', $this->filearea, $submission->id);
             $submission = $this->update_submission($data);
             //TODO fix log actions - needs db upgrade
             add_to_log($this->course->id, 'assignment', 'upload', 'view.php?a=' . $this->assignment->id, $this->assignment->id, $this->cm->id);
             $this->email_teachers($submission);
             //redirect to get updated submission date and word count
             redirect(new moodle_url($PAGE->url, array('saved' => 1)));
         }
     }
     add_to_log($this->course->id, "assignment", "view", "view.php?id={$this->cm->id}", $this->assignment->id, $this->cm->id);
     /// print header, etc. and display form if needed
     if ($editmode) {
         $this->view_header(get_string('editmysubmission', 'assignment'));
     } else {
         $this->view_header();
     }
     $this->view_intro();
     $this->view_dates();
     if ($saved) {
         echo $OUTPUT->notification(get_string('submissionsaved', 'assignment'), 'notifysuccess');
     }
     if (is_enrolled($this->context, $USER)) {
         if ($editmode) {
             echo $OUTPUT->box_start('generalbox', 'onlineenter');
             $mform->display();
         } else {
             echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter', 'online');
             if ($submission && has_capability('mod/assignment:exportownsubmission', $this->context)) {
                 $text = file_rewrite_pluginfile_urls($submission->data1, 'pluginfile.php', $this->context->id, 'mod_assignment', $this->filearea, $submission->id);
                 echo format_text($text, $submission->data2, array('overflowdiv' => true));
                 if ($CFG->enableportfolios) {
                     require_once $CFG->libdir . '/portfoliolib.php';
                     $button = new portfolio_add_button();
                     $button->set_callback_options('assignment_portfolio_caller', array('id' => $this->cm->id), '/mod/assignment/locallib.php');
                     $fs = get_file_storage();
                     if ($files = $fs->get_area_files($this->context->id, 'mod_assignment', $this->filearea, $submission->id, "timemodified", false)) {
                         $button->set_formats(PORTFOLIO_FORMAT_RICHHTML);
                     } else {
                         $button->set_formats(PORTFOLIO_FORMAT_PLAINHTML);
                     }
                     $button->render();
                 }
             } else {
                 if ($this->isopen()) {
                     //fix for #4206
                     echo '<div style="text-align:center">' . get_string('emptysubmission', 'assignment') . '</div>';
                 }
             }
         }
         echo $OUTPUT->box_end();
         if (!$editmode && $editable) {
             if (!empty($submission)) {
                 $submitbutton = "editmysubmission";
             } else {
                 $submitbutton = "addsubmission";
             }
             echo "<div style='text-align:center'>";
             echo $OUTPUT->single_button(new moodle_url('view.php', array('id' => $this->cm->id, 'edit' => '1')), get_string($submitbutton, 'assignment'));
             echo "</div>";
         }
     }
     $this->view_feedback();
//.........这里部分代码省略.........
开发者ID:vuchannguyen,项目名称:web,代码行数:101,代码来源:assignment.class.php

示例9: trim

                if (empty($data->listtemplate)) {
                    echo $OUTPUT->notification(get_string('nolisttemplate', 'data'));
                    data_generate_default_template($data, 'listtemplate', 0, false, false);
                }
                echo $data->listtemplateheader;
                data_print_template('listtemplate', $records, $data, $search, $page);
                echo $data->listtemplatefooter;
                echo $OUTPUT->paging_bar($totalcount, $page, $nowperpage, $baseurl);
            }
        }
    }
    $search = trim($search);
    if (empty($records)) {
        $records = array();
    }
    if ($mode == '' && !empty($CFG->enableportfolios)) {
        require_once $CFG->libdir . '/portfoliolib.php';
        $button = new portfolio_add_button();
        $button->set_callback_options('data_portfolio_caller', array('id' => $cm->id), '/mod/data/locallib.php');
        if (data_portfolio_caller::has_files($data)) {
            $button->set_formats(array(PORTFOLIO_FORMAT_RICHHTML, PORTFOLIO_FORMAT_LEAP2A));
            // no plain html for us
        }
        echo $button->to_html(PORTFOLIO_ADD_FULL_FORM);
    }
    //Advanced search form doesn't make sense for single (redirects list view)
    if (($maxcount || $mode == 'asearch') && $mode != 'single') {
        data_print_preference_form($data, $perpage, $search, $sort, $order, $search_array, $advanced, $mode);
    }
}
echo $OUTPUT->footer();
开发者ID:hatone,项目名称:moodle,代码行数:31,代码来源:view.php

示例10: foreach

 /**
  * Produces a list of links to the files uploaded by a user
  *
  * @param $userid int optional id of the user. If 0 then $USER->id is used.
  * @param $return boolean optional defaults to false. If true the list is returned rather than printed
  * @return string optional
  */
 function print_user_files($userid = 0, $return = false)
 {
     global $CFG, $USER;
     $mode = optional_param('mode', '', PARAM_ALPHA);
     $offset = optional_param('offset', 0, PARAM_INT);
     if (!$userid) {
         if (!isloggedin()) {
             return '';
         }
         $userid = $USER->id;
     }
     $output = '';
     $submission = $this->get_submission($userid);
     $candelete = $this->can_delete_files($submission);
     $strdelete = get_string('delete');
     if ($this->drafts_tracked() and $this->isopen() and !$this->is_finalized($submission) and !empty($mode)) {
         // only during grading
         $output .= '<strong>' . get_string('draft', 'assignment') . ':</strong><br />';
     }
     if ($this->notes_allowed() and !empty($submission->data1) and !empty($mode)) {
         // only during grading
         $npurl = $CFG->wwwroot . "/mod/assignment/type/upload/notes.php?id={$this->cm->id}&amp;userid={$userid}&amp;offset={$offset}&amp;mode=single";
         $output .= '<a href="' . $npurl . '">' . get_string('notes', 'assignment') . '</a><br />';
     }
     $fs = get_file_storage();
     $browser = get_file_browser();
     if ($files = $fs->get_area_files($this->context->id, 'assignment_submission', $userid, "timemodified", false)) {
         $button = new portfolio_add_button();
         foreach ($files as $file) {
             $filename = $file->get_filename();
             $mimetype = $file->get_mimetype();
             $icon = mimeinfo_from_type('icon', $mimetype);
             $path = $browser->encodepath($CFG->wwwroot . '/pluginfile.php', '/' . $this->context->id . '/assignment_submission/' . $userid . '/' . $filename);
             $output .= '<a href="' . $path . '" ><img src="' . $CFG->pixpath . '/f/' . $icon . '" class="icon" alt="' . $icon . '" />' . s($filename) . '</a>';
             if ($candelete) {
                 $delurl = "{$CFG->wwwroot}/mod/assignment/delete.php?id={$this->cm->id}&amp;file=" . rawurlencode($filename) . "&amp;userid={$submission->userid}&amp;mode={$mode}&amp;offset={$offset}";
                 $output .= '<a href="' . $delurl . '">&nbsp;' . '<img title="' . $strdelete . '" src="' . $CFG->pixpath . '/t/delete.gif" class="iconsmall" alt="" /></a> ';
             }
             if (has_capability('mod/assignment:exportownsubmission', $this->context)) {
                 $button->set_callback_options('assignment_portfolio_caller', array('id' => $this->cm->id, 'fileid' => $file->get_id()), '/mod/assignment/lib.php');
                 $button->set_formats(portfolio_format_from_file($file));
                 $output .= $button->to_html(PORTFOLIO_ADD_ICON_LINK);
             }
             $output .= '<br />';
         }
         if (count($files) > 1 && has_capability('mod/assignment:exportownsubmission', $this->context)) {
             $button->set_callback_options('assignment_portfolio_caller', array('id' => $this->cm->id), '/mod/assignment/lib.php');
             $button->set_formats(PORTFOLIO_FORMAT_FILE);
             $output .= $button->to_html();
         }
     }
     if ($this->drafts_tracked() and $this->isopen() and has_capability('mod/assignment:grade', $this->context) and $mode != '') {
         // we do not want it on view.php page
         if ($this->can_unfinalize($submission)) {
             $options = array('id' => $this->cm->id, 'userid' => $userid, 'action' => 'unfinalize', 'mode' => $mode, 'offset' => $offset);
             $output .= print_single_button('upload.php', $options, get_string('unfinalize', 'assignment'), 'post', '_self', true);
         } else {
             if ($this->can_finalize($submission)) {
                 $options = array('id' => $this->cm->id, 'userid' => $userid, 'action' => 'finalizeclose', 'mode' => $mode, 'offset' => $offset);
                 $output .= print_single_button('upload.php', $options, get_string('finalize', 'assignment'), 'post', '_self', true);
             }
         }
     }
     $output = '<div class="files">' . $output . '</div>';
     if ($return) {
         return $output;
     }
     echo $output;
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:76,代码来源:assignment.class.php

示例11: render_export_all_li

 /**
  * Renders the 'export entire wiki' link.
  * @param object $subwiki Subwiki data object
  * @param bool $anyfiles True if any page of subwiki contains files
  * @return string HTML content of list item with link, or nothing if none
  */
 public function render_export_all_li($subwiki, $anyfiles)
 {
     global $CFG;
     if (!$CFG->enableportfolios) {
         return '';
     }
     require_once $CFG->libdir . '/portfoliolib.php';
     $button = new portfolio_add_button();
     $button->set_callback_options('ouwiki_all_portfolio_caller', array('subwikiid' => $subwiki->id), '/mod/ouwiki/portfoliolib.php');
     if ($anyfiles) {
         $button->set_formats(PORTFOLIO_FORMAT_PLAINHTML);
     } else {
         $button->set_formats(PORTFOLIO_FORMAT_RICHHTML);
     }
     return html_writer::tag('li', $button->to_html(PORTFOLIO_ADD_TEXT_LINK));
 }
开发者ID:ndunand,项目名称:moodle-mod_ouwiki,代码行数:22,代码来源:renderer.php

示例12: foreach

 /**
  * Produces a list of links to the files uploaded by a user
  *
  * @param $userid int optional id of the user. If 0 then $USER->id is used.
  * @param $return boolean optional defaults to false. If true the list is returned rather than printed
  * @return string optional
  */
 function print_user_files($userid = 0, $return = false)
 {
     global $CFG, $USER, $OUTPUT;
     if (!$userid) {
         if (!isloggedin()) {
             return '';
         }
         $userid = $USER->id;
     }
     $output = '';
     $fs = get_file_storage();
     $browser = get_file_browser();
     $found = false;
     if ($files = $fs->get_area_files($this->context->id, 'assignment_submission', $userid, "timemodified", false)) {
         $button = new portfolio_add_button();
         foreach ($files as $file) {
             $filename = $file->get_filename();
             $found = true;
             $mimetype = $file->get_mimetype();
             $path = file_encode_url($CFG->wwwroot . '/pluginfile.php', '/' . $this->context->id . '/assignment_submission/' . $userid . '/' . $filename);
             $output .= '<a href="' . $path . '" ><img src="' . $OUTPUT->old_icon_url(file_mimetype_icon($mimetype)) . '" class="icon" alt="' . $mimetype . '" />' . s($filename) . '</a>';
             if ($this->portfolio_exportable() && has_capability('mod/assignment:exportownsubmission', $this->context)) {
                 $button->set_callback_options('assignment_portfolio_caller', array('id' => $this->cm->id, 'fileid' => $file->get_id()));
                 $button->set_formats(portfolio_format_from_file($file));
                 $output .= $button->to_html(PORTFOLIO_ADD_ICON_LINK);
             }
             $output .= '<br />';
         }
         if (count($files) > 1 && $this->portfolio_exportable() && has_capability('mod/assignment:exportownsubmission', $this->context)) {
             $button->set_callback_options('assignment_portfolio_caller', array('id' => $this->cm->id));
             $button->set_formats(PORTFOLIO_PORMAT_FILE);
             $output .= '<br />' . $button->to_html();
         }
     }
     $output = '<div class="files">' . $output . '</div>';
     if ($return) {
         return $output;
     }
     echo $output;
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:47,代码来源:lib.php

示例13: array

        if ($canoverride) {
            $displayassessment->add_action($workshop->assess_url($assessment->id), get_string('assessmentsettings', 'workshop'));
        }
        echo $output->render($displayassessment);
        if ($workshop->phase == workshop::PHASE_CLOSED and has_capability('mod/workshop:viewallassessments', $workshop->context)) {
            if (strlen(trim($assessment->feedbackreviewer)) > 0) {
                echo $output->render(new workshop_feedback_reviewer($assessment));
            }
        }
    }
}
if (!$edit and $canoverride) {
    // display a form to override the submission grade
    $feedbackform->display();
}
// If portfolios are enabled and we are not on the edit/removal confirmation screen, display a button to export this page.
// The export is not offered if the submission is seen as a published one (it has no relation to the current user.
if (!empty($CFG->enableportfolios)) {
    if (!$delete and !$edit and !$seenaspublished and $submission->id and ($ownsubmission or $canviewall or $isreviewer)) {
        if (has_capability('mod/workshop:exportsubmissions', $workshop->context)) {
            require_once $CFG->libdir . '/portfoliolib.php';
            $button = new portfolio_add_button();
            $button->set_callback_options('mod_workshop_portfolio_caller', array('id' => $workshop->cm->id, 'submissionid' => $submission->id), 'mod_workshop');
            $button->set_formats(PORTFOLIO_FORMAT_RICHHTML);
            echo html_writer::start_tag('div', array('class' => 'singlebutton'));
            echo $button->to_html(PORTFOLIO_ADD_FULL_FORM, get_string('exportsubmission', 'workshop'));
            echo html_writer::end_tag('div');
        }
    }
}
echo $output->footer();
开发者ID:dg711,项目名称:moodle,代码行数:31,代码来源:submission.php

示例14: add_button

 public static function add_button($resource, $format = null, $return = false)
 {
     if (!has_capability('mod/resource:exportresource', get_context_instance(CONTEXT_MODULE, $resource->cm->id))) {
         return;
     }
     if (!is_callable(array($resource, 'portfolio_prepare_package')) || !is_callable(array($resource, 'portfolio_get_sha1'))) {
         debugging(get_string('portfolionotimplemented', 'resource'));
         return false;
     }
     $callersupports = array(self::type_to_format($resource->resource->type));
     if ($resource->resource->type == 'file') {
         // $callersupports = array(portfolio_format_from_file($file);
     }
     $button = new portfolio_add_button();
     $button->set_callback_options('resource_portfolio_caller', array('id' => $resource->cm->instance), '/mod/resource/lib.php');
     $button->set_formats($callersupports);
     if ($return) {
         return $button->to_html($format);
     }
     $button->render($format);
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:21,代码来源:lib.php

示例15: render_post


//.........这里部分代码省略.........
             }
             if (!$forexport && !$email) {
                 $output .= html_writer::tag('a', $taglinktext, array('href' => $baseurl . '&tag=' . urlencode($taglink))) . ' ';
             } else {
                 $output .= $taglinktext . ' ';
             }
             $tagcounter++;
         }
         $output .= html_writer::end_tag('div');
     }
     $output .= html_writer::start_tag('div', array('class' => 'oublog-post-links'));
     if (!$forexport && !$email) {
         $output .= html_writer::tag('a', $strpermalink, array('href' => $CFG->wwwroot . '/mod/oublog/viewpost.php?post=' . $post->id)) . ' ';
     }
     if (!$post->deletedby) {
         if ($post->userid == $USER->id || $canmanageposts) {
             if (!$forexport && !$email) {
                 $output .= html_writer::tag('a', $stredit, array('href' => $CFG->wwwroot . '/mod/oublog/editpost.php?blog=' . $post->oublogid . '&post=' . $post->id)) . ' ';
                 if ($post->userid !== $USER->id) {
                     // Add email and 'oublog_deleteandemail' to delete link.
                     $output .= html_writer::tag('a', $strdelete, array('href' => $CFG->wwwroot . '/mod/oublog/deletepost.php?blog=' . $post->oublogid . '&post=' . $post->id . '&delete=1', 'class' => 'oublog_deleteandemail_' . $post->id));
                     self::render_oublog_print_delete_dialog($cm->id, $post->id);
                 } else {
                     $output .= html_writer::tag('a', $strdelete, array('href' => $CFG->wwwroot . '/mod/oublog/deletepost.php?blog=' . $post->oublogid . '&post=' . $post->id . '&delete=1'));
                 }
             }
         }
         // Show portfolio export link.
         if (!empty($CFG->enableportfolios) && (has_capability('mod/oublog:exportpost', $modcontext) || $post->userid == $USER->id && has_capability('mod/oublog:exportownpost', $modcontext))) {
             if (!$forexport && !$email) {
                 require_once $CFG->libdir . '/portfoliolib.php';
                 $button = new portfolio_add_button();
                 $button->set_callback_options('oublog_portfolio_caller', array('postid' => $post->id), 'mod_oublog');
                 if (empty($files)) {
                     $button->set_formats(PORTFOLIO_FORMAT_PLAINHTML);
                 } else {
                     $button->set_formats(PORTFOLIO_FORMAT_RICHHTML);
                 }
                 $output .= $button->to_html(PORTFOLIO_ADD_TEXT_LINK) . ' ';
             }
         }
         // Show OU Alerts reporting link.
         if (isloggedin() && oublog_oualerts_enabled() && oublog_get_reportingemail($oublog) && !($post->userid == $USER->id) && !$post->deletedby) {
             $itemnurl = new moodle_url('/mod/oublog/viewpost.php', array('post' => $post->id));
             $reportlink = oualerts_generate_alert_form_url('oublog', $modcontext->id, 'post', $post->id, $itemnurl, $itemnurl, '', false, true);
             if ($reportlink != '' && !$forexport && !$email) {
                 $output .= html_writer::tag('a', get_string('postalert', 'oublog'), array('href' => $reportlink));
             }
         }
         // Show comments.
         if ($post->allowcomments) {
             // If this is the current user's post, show pending comments too.
             $showpendingcomments = $post->userid == $USER->id && !empty($post->pendingcomments);
             if ((isset($post->comments) || $showpendingcomments) && $commentcount) {
                 // Show number of comments.
                 if (isset($post->comments)) {
                     $linktext = get_string(count($post->comments) == 1 ? 'onecomment' : 'ncomments', 'oublog', count($post->comments));
                 }
                 // Show number of pending comments.
                 if (isset($post->pendingcomments)) {
                     // Use different string if we already have normal comments too.
                     if (isset($post->comments)) {
                         $linktext .= get_string($post->pendingcomments == 1 ? 'onependingafter' : 'npendingafter', 'oublog', $post->pendingcomments);
                     } else {
                         $linktext = get_string($post->pendingcomments == 1 ? 'onepending' : 'npending', 'oublog', $post->pendingcomments);
                     }
                 }
                 if (!$forexport) {
                     // Display link.
                     $output .= html_writer::tag('a', $linktext, array('href' => $CFG->wwwroot . '/mod/oublog/viewpost.php?post=' . $post->id . '#oublogcomments'));
                 } else {
                     $output .= $linktext;
                 }
                 // Display information about most recent comment.
                 if (isset($post->comments)) {
                     $last = array_pop($post->comments);
                     array_push($post->comments, $last);
                     $a = new stdClass();
                     if ($last->userid) {
                         $a->fullname = fullname($last);
                     } else {
                         $a->fullname = s($last->authorname);
                     }
                     $a->timeposted = oublog_date($last->timeposted, true);
                     $output .= ' ' . get_string('lastcomment', 'oublog', $a);
                 }
             } else {
                 if (oublog_can_comment($cm, $oublog, $post)) {
                     if (!$forexport && !$email) {
                         $output .= html_writer::tag('a', $strcomment, array('href' => $CFG->wwwroot . '/mod/oublog/editcomment.php?blog=' . $post->oublogid . '&post=' . $post->id));
                     }
                 }
             }
         }
     }
     $output .= html_writer::end_tag('div');
     $output .= html_writer::end_tag('div');
     $output .= html_writer::end_tag('div');
     return $output;
 }
开发者ID:nadavkav,项目名称:moodle-mod_oublog,代码行数:101,代码来源:renderer.php


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