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


PHP trusttext_strip函数代码示例

本文整理汇总了PHP中trusttext_strip函数的典型用法代码示例。如果您正苦于以下问题:PHP trusttext_strip函数的具体用法?PHP trusttext_strip怎么用?PHP trusttext_strip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: makeMailText

 /**
  * Builds and returns the body of the email notification in plain text.
  *
  * @param object $post
  * @param object $userto
  * @return string The email body in plain text format.
  */
 public function makeMailText($post, $userto)
 {
     global $CFG, $cm;
     $praxe = praxe_record::getData();
     if (!isset($userto->viewfullnames[$praxe->id])) {
         if (!($cm = get_coursemodule_from_instance('praxe', $praxe->id, $this->course->id))) {
             print_error('Course Module ID was incorrect');
         }
         $modcontext = context_module::instance($cm->id);
         $viewfullnames = has_capability('moodle/site:viewfullnames', $modcontext, $userto->id);
     } else {
         $viewfullnames = $userto->viewfullnames[$praxe->id];
     }
     //$by = New stdClass;
     //$by->name = fullname($userfrom, $viewfullnames);
     //$by->date = userdate($post->modified, "", $userto->timezone);
     //$strbynameondate = get_string('bynameondate', 'forum', $by);
     $strpraxes = get_string('modulenameplural', 'praxe');
     $posttext = '';
     $posttext = $this->course->shortname . " -> " . $strpraxes . " -> " . format_string($praxe->name, true);
     $posttext .= "\n---------------------------------------------------------------------\n";
     $posttext .= format_string($this->subject, true);
     //$posttext .= "\n".$strbynameondate."\n";
     $posttext .= "\n---------------------------------------------------------------------\n";
     $posttext .= format_text_email(trusttext_strip($post), FORMAT_PLAIN);
     $posttext .= "\n\n---------------------------------------------------------------------\n";
     $site = get_site();
     foreach ($this->linkstofoot as $link) {
         $posttext .= $link->text . ": " . $link->link . "\t";
         //$posttext .= get_string('confirmorrefusestudent','praxe').": ".$CFG->wwwroot.'/course/view.php?id='.$cm->id."\n\n";
     }
     $posttext .= "\n\n" . $site->shortname . ": " . $CFG->wwwroot . "\n";
     return $posttext;
 }
开发者ID:jerab,项目名称:moodle-mod-praxe,代码行数:41,代码来源:mailing.php

示例2: apply

 function apply($discussion, $all, $selected, $formdata)
 {
     global $COURSE, $USER, $CFG;
     // Begin with standard text
     $a = (object) array('name' => fullname($USER, true));
     // TODO Is this needed? It doesn't work; $CFG->stylesheets not there
     //         $allhtml = "<head>";
     //         foreach ($CFG->stylesheets as $stylesheet) {
     //             $allhtml .= '<link rel="stylesheet" type="text/css" href="' .
     //                 $stylesheet . '" />' . "\n";
     //         }
     //         $allhtml .= "</head>\n';
     $allhtml = "<body id='forumng-email'>\n";
     $preface = get_string('forward_preface', 'forumngfeature_forward', $a);
     $allhtml .= $preface;
     $alltext = format_text_email($preface, FORMAT_HTML);
     // Include intro if specified
     if (!preg_match('~^(<br[^>]*>|<p>|</p>|\\s)*$~', $formdata->message['text'])) {
         $alltext .= "\n" . mod_forumng_cron::EMAIL_DIVIDER . "\n";
         $allhtml .= '<hr size="1" noshade="noshade" />';
         // Add intro
         $message = trusttext_strip($formdata->message['text']);
         $allhtml .= format_text($message, $formdata->message['format']);
         $alltext .= format_text_email($message, $formdata->message['format']);
     }
     // Get list of all post ids in discussion order
     $alltext .= "\n" . mod_forumng_cron::EMAIL_DIVIDER . "\n";
     $allhtml .= '<hr size="1" noshade="noshade" />';
     $poststext = '';
     $postshtml = '';
     $discussion->build_selected_posts_email($selected, $poststext, $postshtml);
     $alltext .= $poststext;
     $allhtml .= $postshtml . '</body>';
     $emails = preg_split('~[; ]+~', $formdata->email);
     $subject = $formdata->subject;
     foreach ($emails as $email) {
         $fakeuser = (object) array('email' => $email, 'mailformat' => 1, 'id' => 0);
         $from = $USER;
         $from->maildisplay = 999;
         // Nasty hack required for OU moodle
         if (!email_to_user($fakeuser, $from, $subject, $alltext, $allhtml)) {
             print_error('error_forwardemail', 'forumng', $discussion->get_moodle_url(), $formdata->email);
         }
     }
     // Log that it was sent
     $discussion->log('forward discussion', $formdata->email);
     if (!empty($formdata->ccme)) {
         if (!email_to_user($USER, $from, $subject, $alltext, $allhtml)) {
             print_error('error_forwardemail', 'forumng', $discussion->get_moodle_url(), $USER->email);
         }
     }
     $out = $discussion->init_page($discussion->get_moodle_url(), $this->get_page_name());
     print $out->header();
     print $out->box(get_string('forward_done', 'forumngfeature_forward'));
     print $out->continue_button(new moodle_url('/mod/forumng/discuss.php', $discussion->get_link_params_array()));
     print $out->footer();
 }
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:57,代码来源:forward.php

示例3: apply

 public function apply($discussion, $all, $selected, $formdata)
 {
     global $COURSE, $USER, $CFG;
     // Begin with standard text.
     $a = (object) array('name' => fullname($USER, true));
     $allhtml = "<body id='forumng-email'>\n";
     $preface = get_string('forward_preface', 'forumngfeature_forward', $a);
     $allhtml .= $preface;
     $alltext = format_text_email($preface, FORMAT_HTML);
     // Include intro if specified.
     if (!preg_match('~^(<br[^>]*>|<p>|</p>|\\s)*$~', $formdata->message['text'])) {
         $alltext .= "\n" . \mod_forumng_cron::EMAIL_DIVIDER . "\n";
         $allhtml .= '<hr size="1" noshade="noshade" />';
         // Add intro.
         $message = trusttext_strip($formdata->message['text']);
         $allhtml .= format_text($message, $formdata->message['format']);
         $alltext .= format_text_email($message, $formdata->message['format']);
     }
     // Get list of all post ids in discussion order.
     $alltext .= "\n" . \mod_forumng_cron::EMAIL_DIVIDER . "\n";
     $allhtml .= '<hr size="1" noshade="noshade" />';
     $poststext = '';
     $postshtml = '';
     $discussion->build_selected_posts_email($selected, $poststext, $postshtml);
     $alltext .= $poststext;
     $allhtml .= $postshtml . '</body>';
     $emails = preg_split('~[; ]+~', $formdata->email);
     $subject = $formdata->subject;
     foreach ($emails as $email) {
         $fakeuser = (object) array('email' => $email, 'mailformat' => 1, 'id' => -1);
         $from = $USER;
         $from->maildisplay = 999;
         // Nasty hack required for OU moodle.
         if (!email_to_user($fakeuser, $from, $subject, $alltext, $allhtml)) {
             print_error('error_forwardemail', 'forumng', $discussion->get_moodle_url(), $formdata->email);
         }
     }
     // Log that it was sent.
     $params = array('context' => $discussion->get_forum()->get_context(), 'objectid' => $discussion->get_id(), 'other' => array('logurl' => $discussion->get_log_url(), 'info' => $formdata->email));
     $event = \forumngfeature_forward\event\discussion_forwarded::create($params);
     $event->add_record_snapshot('course_modules', $discussion->get_course_module());
     $event->add_record_snapshot('course', $discussion->get_course());
     $event->trigger();
     if (!empty($formdata->ccme)) {
         if (!email_to_user($USER, $from, $subject, $alltext, $allhtml)) {
             print_error('error_forwardemail', 'forumng', $discussion->get_moodle_url(), $USER->email);
         }
     }
     if ($this->printout) {
         $out = $discussion->init_page($discussion->get_moodle_url(), $this->get_page_name());
         print $out->header();
         print $out->box(get_string('forward_done', 'forumngfeature_forward'));
         print $out->continue_button(new \moodle_url('/mod/forumng/discuss.php', $discussion->get_link_params_array()));
         print $out->footer();
     }
 }
开发者ID:ULCC-QMUL,项目名称:moodle-mod_forumng,代码行数:56,代码来源:post_selector.php

示例4: apply

 function apply($discussion, $all, $selected, $formdata)
 {
     global $COURSE, $USER, $CFG;
     // Begin with standard text
     $a = (object) array('name' => fullname($USER, true));
     $allhtml = "<head>";
     foreach ($CFG->stylesheets as $stylesheet) {
         $allhtml .= '<link rel="stylesheet" type="text/css" href="' . $stylesheet . '" />' . "\n";
     }
     $allhtml .= "</head>\n<body id='forumng-email'>\n";
     $preface = get_string('forward_preface', 'forumng', $a);
     $allhtml .= $preface;
     $alltext = format_text_email($preface, FORMAT_HTML);
     // Include intro if specified
     if (!preg_match('~^(<br[^>]*>|<p>|</p>|\\s)*$~', $formdata->message)) {
         $alltext .= "\n" . forum_cron::EMAIL_DIVIDER . "\n";
         $allhtml .= '<hr size="1" noshade="noshade" />';
         // Add intro
         $message = trusttext_strip(stripslashes($formdata->message));
         $allhtml .= format_text($message, $formdata->format);
         $alltext .= format_text_email($message, $formdata->format);
     }
     // Get list of all post ids in discussion order
     $alltext .= "\n" . forum_cron::EMAIL_DIVIDER . "\n";
     $allhtml .= '<hr size="1" noshade="noshade" />';
     $poststext = '';
     $postshtml = '';
     $discussion->build_selected_posts_email($selected, $poststext, $postshtml);
     $alltext .= $poststext;
     $allhtml .= $postshtml . '</body>';
     $emails = preg_split('~[; ]+~', $formdata->email);
     $subject = stripslashes($formdata->subject);
     foreach ($emails as $email) {
         $fakeuser = (object) array('email' => $email, 'mailformat' => 1, 'id' => 0);
         $from = $USER;
         $from->maildisplay = 999;
         // Nasty hack required for OU moodle
         if (!email_to_user($fakeuser, $from, $subject, $alltext, $allhtml)) {
             print_error('error_forwardemail', 'forumng', $formdata->email);
         }
     }
     // Log that it was sent
     $discussion->log('forward discussion', $formdata->email);
     if (!empty($formdata->ccme)) {
         if (!email_to_user($USER, $from, $subject, $alltext, $allhtml)) {
             print_error('error_forwardemail', 'forumng', $USER->email);
         }
     }
     $discussion->print_subpage_header($this->get_page_name());
     print_box(get_string('forward_done', 'forumng'));
     print_continue('../../discuss.php?' . $discussion->get_link_params(forum::PARAM_PLAIN));
     print_footer($COURSE);
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:53,代码来源:forward.php

示例5: sizeof

            }
        } else {
            echo $OUTPUT->notification("Error while trying to create the new glossary.");
            echo $OUTPUT->footer();
            exit;
        }
    }

    $xmlentries = $xml['GLOSSARY']['#']['INFO'][0]['#']['ENTRIES'][0]['#']['ENTRY'];
    $sizeofxmlentries = sizeof($xmlentries);
    for($i = 0; $i < $sizeofxmlentries; $i++) {
        // Inserting the entries
        $xmlentry = $xmlentries[$i];
        $newentry = new stdClass();
        $newentry->concept = trim($xmlentry['#']['CONCEPT'][0]['#']);
        $newentry->definition = trusttext_strip($xmlentry['#']['DEFINITION'][0]['#']);
        if ( isset($xmlentry['#']['CASESENSITIVE'][0]['#']) ) {
            $newentry->casesensitive = $xmlentry['#']['CASESENSITIVE'][0]['#'];
        } else {
            $newentry->casesensitive = $CFG->glossary_casesensitive;
        }

        $permissiongranted = 1;
        if ( $newentry->concept and $newentry->definition ) {
            if ( !$glossary->allowduplicatedentries ) {
                // checking if the entry is valid (checking if it is duplicated when should not be)
                if ( $newentry->casesensitive ) {
                    $dupentry = $DB->record_exists_select('glossary_entries',
                                    'glossaryid = :glossaryid AND concept = :concept', array(
                                        'glossaryid' => $glossary->id,
                                        'concept'    => $newentry->concept));
开发者ID:verbazend,项目名称:AWFA,代码行数:31,代码来源:import.php

示例6: trusttext_prepare_edit

function trusttext_prepare_edit(&$text, &$format, $usehtmleditor, $context)
{
    global $CFG;
    $options = new object();
    $options->smiley = false;
    $options->filter = false;
    if (!empty($CFG->enabletrusttext) and has_capability('moodle/site:trustcontent', $context) and trusttext_present($text)) {
        $options->noclean = true;
    } else {
        $options->noclean = false;
    }
    $text = trusttext_strip($text);
    if ($usehtmleditor) {
        $text = format_text($text, $format, $options);
        $format = FORMAT_HTML;
    } else {
        if (!$options->noclean) {
            $text = clean_text($text, $format);
        }
    }
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:21,代码来源:weblib.php

示例7: forum_make_mail_post

/**
* Given the data about a posting, builds up the HTML to display it and
* returns the HTML in a string.  This is designed for sending via HTML email.
*/
function forum_make_mail_post($course, $forum, $discussion, $post, $userfrom, $userto, $ownpost = false, $reply = false, $link = false, $rate = false, $footer = "")
{
    global $CFG;
    if (!isset($userto->viewfullnames[$forum->id])) {
        if (!($cm = get_coursemodule_from_instance('forum', $forum->id, $course->id))) {
            error('Course Module ID was incorrect');
        }
        $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
        $viewfullnames = has_capability('moodle/site:viewfullnames', $modcontext, $userto->id);
    } else {
        $viewfullnames = $userto->viewfullnames[$forum->id];
    }
    // format the post body
    $options = new object();
    $options->para = true;
    $formattedtext = format_text(trusttext_strip($post->message), $post->format, $options, $course->id);
    $output = '<table border="0" cellpadding="3" cellspacing="0" class="forumpost">';
    $output .= '<tr class="header"><td width="35" valign="top" class="picture left">';
    $output .= print_user_picture($userfrom, $course->id, $userfrom->picture, false, true);
    $output .= '</td>';
    if ($post->parent) {
        $output .= '<td class="topic">';
    } else {
        $output .= '<td class="topic starter">';
    }
    $output .= '<div class="subject">' . format_string($post->subject) . '</div>';
    $fullname = fullname($userfrom, $viewfullnames);
    $by = new object();
    $by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $userfrom->id . '&amp;course=' . $course->id . '">' . $fullname . '</a>';
    $by->date = userdate($post->modified, '', $userto->timezone);
    $output .= '<div class="author">' . get_string('bynameondate', 'forum', $by) . '</div>';
    $output .= '</td></tr>';
    $output .= '<tr><td class="left side" valign="top">';
    if (isset($userfrom->groups)) {
        $groups = $userfrom->groups[$forum->id];
    } else {
        if (!($cm = get_coursemodule_from_instance('forum', $forum->id, $course->id))) {
            error('Course Module ID was incorrect');
        }
        $group = groups_get_all_groups($course->id, $userfrom->id, $cm->groupingid);
    }
    if ($groups) {
        $output .= print_group_picture($groups, $course->id, false, true, true);
    } else {
        $output .= '&nbsp;';
    }
    $output .= '</td><td class="content">';
    if ($post->attachment) {
        $post->course = $course->id;
        $output .= '<div class="attachments">';
        $output .= forum_print_attachments($post, 'html');
        $output .= "</div>";
    }
    $output .= $formattedtext;
    // Commands
    $commands = array();
    if ($post->parent) {
        $commands[] = '<a target="_blank" href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '&amp;parent=' . $post->parent . '">' . get_string('parent', 'forum') . '</a>';
    }
    if ($reply) {
        $commands[] = '<a target="_blank" href="' . $CFG->wwwroot . '/mod/forum/post.php?reply=' . $post->id . '">' . get_string('reply', 'forum') . '</a>';
    }
    $output .= '<div class="commands">';
    $output .= implode(' | ', $commands);
    $output .= '</div>';
    // Context link to post if required
    if ($link) {
        $output .= '<div class="link">';
        $output .= '<a target="_blank" href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '#p' . $post->id . '">' . get_string('postincontext', 'forum') . '</a>';
        $output .= '</div>';
    }
    if ($footer) {
        $output .= '<div class="footer">' . $footer . '</div>';
    }
    $output .= '</td></tr></table>' . "\n\n";
    return $output;
}
开发者ID:r007,项目名称:PMoodle,代码行数:81,代码来源:lib.php

示例8: glossary_generate_export_file

function glossary_generate_export_file($glossary, $hook = "", $hook = 0)
{
    global $CFG;
    $co = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    $co .= glossary_start_tag("GLOSSARY", 0, true);
    $co .= glossary_start_tag("INFO", 1, true);
    $co .= glossary_full_tag("NAME", 2, false, $glossary->name);
    $co .= glossary_full_tag("INTRO", 2, false, $glossary->intro);
    $co .= glossary_full_tag("ALLOWDUPLICATEDENTRIES", 2, false, $glossary->allowduplicatedentries);
    $co .= glossary_full_tag("DISPLAYFORMAT", 2, false, $glossary->displayformat);
    $co .= glossary_full_tag("SHOWSPECIAL", 2, false, $glossary->showspecial);
    $co .= glossary_full_tag("SHOWALPHABET", 2, false, $glossary->showalphabet);
    $co .= glossary_full_tag("SHOWALL", 2, false, $glossary->showall);
    $co .= glossary_full_tag("ALLOWCOMMENTS", 2, false, $glossary->allowcomments);
    $co .= glossary_full_tag("USEDYNALINK", 2, false, $glossary->usedynalink);
    $co .= glossary_full_tag("DEFAULTAPPROVAL", 2, false, $glossary->defaultapproval);
    $co .= glossary_full_tag("GLOBALGLOSSARY", 2, false, $glossary->globalglossary);
    $co .= glossary_full_tag("ENTBYPAGE", 2, false, $glossary->entbypage);
    if ($entries = get_records("glossary_entries", "glossaryid", $glossary->id)) {
        $co .= glossary_start_tag("ENTRIES", 2, true);
        foreach ($entries as $entry) {
            $permissiongranted = 1;
            if ($hook) {
                switch ($hook) {
                    case "ALL":
                    case "SPECIAL":
                        break;
                    default:
                        $permissiongranted = $entry->concept[strlen($hook) - 1] == $hook;
                        break;
                }
            }
            if ($hook) {
                switch ($hook) {
                    case GLOSSARY_SHOW_ALL_CATEGORIES:
                        break;
                    case GLOSSARY_SHOW_NOT_CATEGORISED:
                        $permissiongranted = !record_exists("glossary_entries_categories", "entryid", $entry->id);
                        break;
                    default:
                        $permissiongranted = record_exists("glossary_entries_categories", "entryid", $entry->id, "categoryid", $hook);
                        break;
                }
            }
            if ($entry->approved and $permissiongranted) {
                $co .= glossary_start_tag("ENTRY", 3, true);
                $co .= glossary_full_tag("CONCEPT", 4, false, trim($entry->concept));
                $co .= glossary_full_tag("DEFINITION", 4, false, trusttext_strip($entry->definition));
                $co .= glossary_full_tag("FORMAT", 4, false, $entry->format);
                $co .= glossary_full_tag("USEDYNALINK", 4, false, $entry->usedynalink);
                $co .= glossary_full_tag("CASESENSITIVE", 4, false, $entry->casesensitive);
                $co .= glossary_full_tag("FULLMATCH", 4, false, $entry->fullmatch);
                $co .= glossary_full_tag("TEACHERENTRY", 4, false, $entry->teacherentry);
                if ($aliases = get_records("glossary_alias", "entryid", $entry->id)) {
                    $co .= glossary_start_tag("ALIASES", 4, true);
                    foreach ($aliases as $alias) {
                        $co .= glossary_start_tag("ALIAS", 5, true);
                        $co .= glossary_full_tag("NAME", 6, false, trim($alias->alias));
                        $co .= glossary_end_tag("ALIAS", 5, true);
                    }
                    $co .= glossary_end_tag("ALIASES", 4, true);
                }
                if ($catentries = get_records("glossary_entries_categories", "entryid", $entry->id)) {
                    $co .= glossary_start_tag("CATEGORIES", 4, true);
                    foreach ($catentries as $catentry) {
                        $category = get_record("glossary_categories", "id", $catentry->categoryid);
                        $co .= glossary_start_tag("CATEGORY", 5, true);
                        $co .= glossary_full_tag("NAME", 6, false, $category->name);
                        $co .= glossary_full_tag("USEDYNALINK", 6, false, $category->usedynalink);
                        $co .= glossary_end_tag("CATEGORY", 5, true);
                    }
                    $co .= glossary_end_tag("CATEGORIES", 4, true);
                }
                $co .= glossary_end_tag("ENTRY", 3, true);
            }
        }
        $co .= glossary_end_tag("ENTRIES", 2, true);
    }
    $co .= glossary_end_tag("INFO", 1, true);
    $co .= glossary_end_tag("GLOSSARY", 0, true);
    return $co;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:82,代码来源:lib.php

示例9: display_post


//.........这里部分代码省略.........
                 $attachmentlabel = get_string('attachments', 'forumng');
             }
             $out .= '<span class="accesshide">' . $attachmentlabel . '</span>';
             foreach ($attachments as $attachment) {
                 if ($html) {
                     require_once $CFG->libdir . '/filelib.php';
                     $iconsrc = $CFG->pixpath . '/f/' . mimeinfo('icon', $attachment);
                     $alt = get_mimetype_description(mimeinfo('type', $attachment));
                     $out .= '<li><a href="' . $linkprefix . 'attachment.php?' . $post->get_link_params(forum::PARAM_HTML) . '&amp;file=' . $attachment . '">' . '<img src="' . $iconsrc . '" alt="' . $alt . '" /> <span>' . htmlspecialchars($attachment) . '</span></a></li>';
                 } else {
                     // Right-align the entry to 70 characters
                     $padding = 70 - strlen($attachment);
                     if ($padding > 0) {
                         $out .= str_repeat(' ', $padding);
                     }
                     // Add filename
                     $out .= $attachment . $lf;
                 }
             }
             if ($html) {
                 $out .= '</ul>' . $lf;
             } else {
                 $out .= $lf;
                 // Extra line break after attachments
             }
         }
         // Display actual content
         if ($html) {
             if ($options[forum_post::OPTION_PRINTABLE_VERSION]) {
                 $message = preg_replace('~<a[^>]*\\shref\\s*=\\s*[\'"](http:.*?)[\'"][^>]*>' . '(?!(http:|www\\.)).*?</a>~', "\$0 [\$1]", $message);
             }
             $out .= $lf . '<div class="forumng-message">' . $message . '</div>';
         } else {
             $out .= format_text_email(trusttext_strip($post->get_message()), $post->get_format());
             $out .= "\n\n";
         }
         if ($html) {
             $out .= $lf . '<div class="forumng-postfooter">';
         }
         // Ratings
         $ratings = '';
         $ratingclasses = '';
         if ($options[forum_post::OPTION_RATINGS_VIEW]) {
             $ratingclasses .= ' forumng-canview';
             if ($post->get_num_ratings() >= $post->get_forum()->get_rating_threshold()) {
                 if ($html) {
                     $ratings .= '<div class="forumng-rating">';
                     $a = new stdClass();
                     $a->avg = '<strong id="rating_for_' . $post->get_id() . '">' . $post->get_average_rating(true) . '</strong>';
                     $a->num = '<span class="forumng-count">' . $post->get_num_ratings() . '</span>';
                     $ratings .= get_string('averagerating', 'forumng', $a);
                     $ratings .= '</div>';
                 } else {
                     $ratings .= strip_tags($post->get_average_rating(true));
                 }
             }
         }
         if ($options[forum_post::OPTION_RATINGS_EDIT] && $html) {
             $ratingclasses .= ' forumng-canedit';
             $ratings .= '<div class="forumng-editrating">' . get_string('yourrating', 'forumng') . ' ';
             $ratings .= choose_from_menu($post->get_forum()->get_rating_options(), 'rating' . $post->get_id(), $post->get_own_rating(), '-', '', forum_post::NO_RATING, true);
             $ratings .= '</div>';
         }
         if ($ratings) {
             $out .= '<div class="forumng-ratings' . $ratingclasses . '">' . $ratings . '</div>';
         }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:67,代码来源:forum_type.php

示例10: forum_make_mail_post

/**
* Given the data about a posting, builds up the HTML to display it and
* returns the HTML in a string.  This is designed for sending via HTML email.
*/
function forum_make_mail_post(&$post, $user, $touser, $course, $ownpost = false, $reply = false, $link = false, $rate = false, $footer = "")
{
    global $CFG, $USER;
    // the old caching was removed for now, because it did not work due to recent changes in cron
    $post->forum = get_field('forum_discussions', 'forum', 'id', $post->discussion);
    if (!($cm = get_coursemodule_from_instance('forum', $post->forum))) {
        mtrace('Course Module ID was incorrect');
    }
    $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
    // format the post body
    $options = new object();
    $options->para = true;
    $formattedtext = format_text(trusttext_strip($post->message), $post->format, $options, $course->id);
    $output = '<table border="0" cellpadding="3" cellspacing="0" class="forumpost">';
    $output .= '<tr class="header"><td width="35" valign="top" class="picture left">';
    $output .= print_user_picture($user->id, $course->id, $user->picture, false, true);
    $output .= '</td>';
    if ($post->parent) {
        $output .= '<td class="topic" colspan="3">';
    } else {
        $output .= '<td class="topic starter" colspan="3">';
    }
    $output .= '<div class="subject ' . PM_TITLE_CLASS . '">' . format_string($post->subject) . '</div>';
    // #GEOF# Annotations must use a unique value for the user ID
    // This should be a string, and it should be human-readable and suitable for
    // outside consumption.  I'm therefore using username rather than ID.
    // If Moodle displayed these values, the fields wouldn'n need to be hidden.
    $rootpath = $CFG->wwwroot;
    //parse_url( $CFG->wwwroot );
    //$rootpath = $rootpath[ 'path' ];
    $refUrl = "{$rootpath}/mod/forum/permalink.php?p={$post->id}";
    $discussUrl = "{$rootpath}/mod/forum/discuss.php?d={$post->discussion}";
    // used for summary link
    // This class author, used by Marginalia, must preceed the one below, used by Moodle (well, not in Moodle 1.8).
    // Unfortunately I can't use that one - it's marked author but it is not, in fact, the author
    // - it also includes "by", the date, etc.  (grrr) #geof#
    echo "<span style='display:none' class='" . PM_AUTHOR_CLASS . "' title='" . htmlspecialchars($post->username) . "'>" . htmlspecialchars($post->firstname . ' ' . $post->lastname) . "</span>\n";
    echo "<abbr style='display:none' class='" . PM_DATE_CLASS . "' title='" . date('Ymd', $post->modified) . 'T' . date('HiO', $post->modified) . "'></abbr>\n";
    echo "<a style='display:none' rel='" . PM_URL_REL . "' href='{$refurl}'></a>\n";
    $fullname = fullname($user, has_capability('moodle/site:viewfullnames', $modcontext));
    $by = new object();
    $by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&amp;course=' . $course->id . '">' . $fullname . '</a>';
    $by->date = userdate($post->modified, '', $touser->timezone);
    // This, I presume, is to localize string display.  Unfortunately it's
    // unstructured text, so I can't insert the necessary <abbr> element with the date.
    // Instead that's done in a hidden tag above.
    $output .= '<div class="author">' . get_string('bynameondate', 'forum', $by) . '</div>';
    $output .= '</td></tr>';
    $output .= '<tr><td class="left side" valign="top">';
    if ($group = user_group($course->id, $user->id)) {
        $output .= print_group_picture($group, $course->id, false, true, true);
    } else {
        $output .= '&nbsp;';
    }
    $output .= '</td><td class="content">';
    if ($post->attachment) {
        $post->course = $course->id;
        $output .= '<div class="attachments">';
        $output .= forum_print_attachments($post, 'html');
        $output .= "</div>";
    }
    $output .= $formattedtext;
    // Commands
    $commands = array();
    if ($post->parent) {
        $commands[] = '<a target="_blank" href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '&amp;parent=' . $post->parent . '">' . get_string('parent', 'forum') . '</a>';
    }
    // The span below is to allow text-decoration:underline, which doesn't seem
    // to work otherwise (Firefox bug?)
    $commands[] = "<button class='smartquote'><span>Quote</span></button>";
    if ($reply) {
        $commands[] = '<a target="_blank" href="' . $CFG->wwwroot . '/mod/forum/post.php?reply=' . $post->id . '">' . get_string('reply', 'forum') . '</a>';
    }
    $output .= '<div class="commands">';
    $output .= implode(' | ', $commands);
    $output .= '</div>';
    // Context link to post if required
    if ($link) {
        $output .= '<div class="link">';
        $output .= '<a target="_blank" href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '#p' . $post->id . '">' . get_string('postincontext', 'forum') . '</a>';
        $output .= '</div>';
    }
    if ($footer) {
        $output .= '<div class="footer">' . $footer . '</div>';
    }
    $output .= '</td></tr></table>' . "\n\n";
    return $output;
}
开发者ID:njorth,项目名称:marginalia,代码行数:92,代码来源:lib.php

示例11: str_replace

    $message = str_replace('</fgw9sdpq4>', '</span>', $message);
    if ($missing_terms) {
        $strmissingsearchterms = get_string('missingsearchterms', 'forum');
        $post->message = '<p class="highlight2">' . $strmissingsearchterms . ' ' . $missing_terms . '</p>' . $message;
        $ttpresent = false;
    } else {
        $post->message = $message;
    }
    $fulllink = "<a href=\"discuss.php?d={$post->discussion}#p{$post->id}\">" . get_string("postincontext", "forum") . "</a>";
    //search terms already highlighted - fiedorow - 9/2/2005
    $SESSION->forum_search = true;
    // reconstruct the TRUSTTEXT properly after processing
    if ($ttpresent) {
        $post->message = trusttext_mark($post->message);
    } else {
        $post->message = trusttext_strip($post->message);
        //make 100% sure TRUSTTEXT marker was not created during processing
    }
    forum_print_post($post, $course->id, false, false, false, false, $fulllink);
    unset($SESSION->forum_search);
    echo "<br />";
}
print_paging_bar($totalcount, $page, $perpage, "search.php?search=" . urlencode(stripslashes($search)) . "&amp;id={$course->id}&amp;perpage={$perpage}&amp;");
print_footer($course);
/**
 * @todo Document this function
 */
function forum_print_big_search_form($course)
{
    global $CFG, $words, $subject, $phrase, $user, $userid, $fullwords, $notwords, $datefrom, $dateto;
    print_simple_box(get_string('searchforumintro', 'forum'), 'center', '', '', 'searchbox', 'intro');
开发者ID:veritech,项目名称:pare-project,代码行数:31,代码来源:search.php

示例12: sizeof

         echo $OUTPUT->footer();
         exit;
     }
 }
 $xmlentries = $xml['GLOSSARY']['#']['INFO'][0]['#']['ENTRIES'][0]['#']['ENTRY'];
 $sizeofxmlentries = sizeof($xmlentries);
 for ($i = 0; $i < $sizeofxmlentries; $i++) {
     // Inserting the entries
     $xmlentry = $xmlentries[$i];
     $newentry = new stdClass();
     $newentry->concept = trim($xmlentry['#']['CONCEPT'][0]['#']);
     $definition = $xmlentry['#']['DEFINITION'][0]['#'];
     if (!is_string($definition)) {
         print_error('errorparsingxml', 'glossary');
     }
     $newentry->definition = trusttext_strip($definition);
     if (isset($xmlentry['#']['CASESENSITIVE'][0]['#'])) {
         $newentry->casesensitive = $xmlentry['#']['CASESENSITIVE'][0]['#'];
     } else {
         $newentry->casesensitive = $CFG->glossary_casesensitive;
     }
     $permissiongranted = 1;
     if ($newentry->concept and $newentry->definition) {
         if (!$glossary->allowduplicatedentries) {
             // checking if the entry is valid (checking if it is duplicated when should not be)
             if ($newentry->casesensitive) {
                 $dupentry = $DB->record_exists_select('glossary_entries', 'glossaryid = :glossaryid AND concept = :concept', array('glossaryid' => $glossary->id, 'concept' => $newentry->concept));
             } else {
                 $dupentry = $DB->record_exists_select('glossary_entries', 'glossaryid = :glossaryid AND LOWER(concept) = :concept', array('glossaryid' => $glossary->id, 'concept' => core_text::strtolower($newentry->concept)));
             }
             if ($dupentry) {
开发者ID:gabrielrosset,项目名称:moodle,代码行数:31,代码来源:import.php

示例13: array

 $questiontype = $questiontypeparams[0];
 if ($questiontype == 'multichoice') {
     $answernumbering = $questiontypeparams[1];
     $concepts = array();
     foreach ($entries as $entry) {
         $concepts[] = $entry->concept;
     }
 } else {
     $usecase = $questiontypeparams[1];
 }
 foreach ($entries as $entry) {
     $counter++;
     $definition = trusttext_strip($entry->definition);
     $fs = get_file_storage();
     $entryfiles = $fs->get_area_files($context->id, 'mod_glossary', 'entry', $entry->id);
     $concept = trusttext_strip($entry->concept);
     $expout .= "\n\n<!-- question: {$counter}  -->\n";
     $nametext = writetext($concept);
     $qtformat = "html";
     $expout .= "  <question type=\"{$questiontype}\">\n";
     $expout .= "    <name>{$nametext}</name>\n";
     $expout .= "    <questiontext format=\"{$qtformat}\">\n";
     $expout .= writetext($definition);
     $expout .= writefiles($entryfiles);
     $expout .= "    </questiontext>\n";
     if ($questiontype == 'multichoice') {
         $expout .= "    <shuffleanswers>true</shuffleanswers>\n";
         $expout .= "    <answernumbering>" . $answernumbering . "</answernumbering>\n";
         $concepts2 = $concepts;
         foreach ($concepts2 as $key => $value) {
             if ($value == $concept) {
开发者ID:marcusgreen,项目名称:moodle-block_advaced_grading_export,代码行数:31,代码来源:exportfile_to_quiz.php

示例14: xmldb_forum_upgrade


//.........这里部分代码省略.........
                    $post->attachment = '';
                    $DB->update_record('forum_posts', $post);
                    continue;
                }
                if (!$fs->file_exists($context->id, $filearea, $post->id, '/', $filename)) {
                    $file_record = array('contextid' => $context->id, 'filearea' => $filearea, 'itemid' => $post->id, 'filepath' => '/', 'filename' => $filename, 'userid' => $post->userid);
                    if ($fs->create_file_from_pathname($file_record, $filepath)) {
                        $post->attachment = '1';
                        if ($DB->update_record('forum_posts', $post)) {
                            unlink($filepath);
                        }
                    }
                }
                // remove dirs if empty
                @rmdir("{$CFG->dataroot}/{$post->course}/{$CFG->moddata}/forum/{$post->forum}/{$post->id}");
                @rmdir("{$CFG->dataroot}/{$post->course}/{$CFG->moddata}/forum/{$post->forum}");
                @rmdir("{$CFG->dataroot}/{$post->course}/{$CFG->moddata}/forum");
            }
            $rs->close();
        }
        upgrade_mod_savepoint($result, 2008081900, 'forum');
    }
    if ($result && $oldversion < 2008090800) {
        /// Define field maxattachments to be added to forum
        $table = new xmldb_table('forum');
        $field = new xmldb_field('maxattachments', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', 'maxbytes');
        /// Conditionally launch add field maxattachments
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        /// forum savepoint reached
        upgrade_mod_savepoint($result, 2008090800, 'forum');
    }
    if ($result && $oldversion < 2009042000) {
        /// Rename field format on table forum_posts to messageformat
        $table = new xmldb_table('forum_posts');
        $field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'message');
        /// Launch rename field format
        $dbman->rename_field($table, $field, 'messageformat');
        /// forum savepoint reached
        upgrade_mod_savepoint($result, 2009042000, 'forum');
    }
    if ($result && $oldversion < 2009042001) {
        /// Define field messagetrust to be added to forum_posts
        $table = new xmldb_table('forum_posts');
        $field = new xmldb_field('messagetrust', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'messageformat');
        /// Launch add field messagetrust
        $dbman->add_field($table, $field);
        /// forum savepoint reached
        upgrade_mod_savepoint($result, 2009042001, 'forum');
    }
    if ($result && $oldversion < 2009042002) {
        $trustmark = '#####TRUSTTEXT#####';
        $rs = $DB->get_recordset_sql("SELECT * FROM {forum_posts} WHERE message LIKE '{$trustmark}%'");
        foreach ($rs as $post) {
            if (strpos($post->entrycomment, $trustmark) !== 0) {
                // probably lowercase in some DBs
                continue;
            }
            $post->message = trusttext_strip($post->message);
            $post->messagetrust = 1;
            $DB->update_record('forum_posts', $post);
        }
        $rs->close();
        /// forum savepoint reached
        upgrade_mod_savepoint($result, 2009042002, 'forum');
    }
    if ($result && $oldversion < 2009042003) {
        /// Define field introformat to be added to forum
        $table = new xmldb_table('forum');
        $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
        /// Launch add field introformat
        $dbman->add_field($table, $field);
        /// forum savepoint reached
        upgrade_mod_savepoint($result, 2009042003, 'forum');
    }
    if ($result && $oldversion < 2009042004) {
        /// set format to current
        $DB->set_field('forum', 'introformat', FORMAT_MOODLE, array());
        /// quiz savepoint reached
        upgrade_mod_savepoint($result, 2009042004, 'forum');
    }
    /// Dropping all enums/check contraints from core. MDL-18577
    if ($result && $oldversion < 2009042700) {
        /// Changing list of values (enum) of field type on table forum to none
        $table = new xmldb_table('forum');
        $field = new xmldb_field('type', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, 'general', 'course');
        /// Launch change of list of values for field type
        $dbman->drop_enum_from_field($table, $field);
        /// forum savepoint reached
        upgrade_mod_savepoint($result, 2009042700, 'forum');
    }
    if ($result && $oldversion < 2009050400) {
        /// Clean existing wrong rates. MDL-18227
        $DB->delete_records('forum_ratings', array('post' => 0));
        /// forum savepoint reached
        upgrade_mod_savepoint($result, 2009050400, 'forum');
    }
    return $result;
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:101,代码来源:upgrade.php

示例15: xmldb_glossary_upgrade


//.........这里部分代码省略.........
                    $file_record = array('contextid' => $context->id, 'filearea' => $filearea, 'itemid' => $entry->id, 'filepath' => '/', 'filename' => $filename, 'userid' => $entry->userid);
                    if ($fs->create_file_from_pathname($file_record, $filepath)) {
                        $entry->attachment = '1';
                        if ($DB->update_record('glossary_entries', $entry)) {
                            unlink($filepath);
                        }
                    }
                }
                // remove dirs if empty
                @rmdir("{$CFG->dataroot}/{$entry->course}/{$CFG->moddata}/glossary/{$entry->glossaryid}/{$entry->id}");
                @rmdir("{$CFG->dataroot}/{$entry->course}/{$CFG->moddata}/glossary/{$entry->glossaryid}");
                @rmdir("{$CFG->dataroot}/{$entry->course}/{$CFG->moddata}/glossary");
            }
            $rs->close();
        }
        upgrade_mod_savepoint($result, 2008081900, 'glossary');
    }
    if ($result && $oldversion < 2009042000) {
        /// Rename field definitionformat on table glossary_entries to definitionformat
        $table = new xmldb_table('glossary_entries');
        $field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'definition');
        /// Launch rename field definitionformat
        $dbman->rename_field($table, $field, 'definitionformat');
        /// glossary savepoint reached
        upgrade_mod_savepoint($result, 2009042000, 'glossary');
    }
    if ($result && $oldversion < 2009042001) {
        /// Define field definitiontrust to be added to glossary_entries
        $table = new xmldb_table('glossary_entries');
        $field = new xmldb_field('definitiontrust', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'definitionformat');
        /// Launch add field definitiontrust
        $dbman->add_field($table, $field);
        /// glossary savepoint reached
        upgrade_mod_savepoint($result, 2009042001, 'glossary');
    }
    if ($result && $oldversion < 2009042002) {
        /// Rename field format on table glossary_comments to NEWNAMEGOESHERE
        $table = new xmldb_table('glossary_comments');
        $field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'entrycomment');
        /// Launch rename field format
        $dbman->rename_field($table, $field, 'entrycommentformat');
        /// glossary savepoint reached
        upgrade_mod_savepoint($result, 2009042002, 'glossary');
    }
    if ($result && $oldversion < 2009042003) {
        /// Define field entrycommenttrust to be added to glossary_comments
        $table = new xmldb_table('glossary_comments');
        $field = new xmldb_field('entrycommenttrust', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'entrycommentformat');
        /// Conditionally launch add field entrycommenttrust
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        /// glossary savepoint reached
        upgrade_mod_savepoint($result, 2009042003, 'glossary');
    }
    if ($result && $oldversion < 2009042004) {
        $trustmark = '#####TRUSTTEXT#####';
        $rs = $DB->get_recordset_sql("SELECT * FROM {glossary_entries} WHERE definition LIKE '{$trustmark}%'");
        foreach ($rs as $entry) {
            if (strpos($entry->definition, $trustmark) !== 0) {
                // probably lowercase in some DBs
                continue;
            }
            $entry->definition = trusttext_strip($entry->definition);
            $entry->definitiontrust = 1;
            $DB->update_record('glossary_entries', $entry);
        }
        $rs->close();
        /// glossary savepoint reached
        upgrade_mod_savepoint($result, 2009042004, 'glossary');
    }
    if ($result && $oldversion < 2009042005) {
        $trustmark = '#####TRUSTTEXT#####';
        $rs = $DB->get_recordset_sql("SELECT * FROM {glossary_comments} WHERE entrycomment LIKE '{$trustmark}%'");
        foreach ($rs as $comment) {
            if (strpos($comment->entrycomment, $trustmark) !== 0) {
                // probably lowercase in some DBs
                continue;
            }
            $comment->entrycomment = trusttext_strip($comment->entrycomment);
            $comment->entrycommenttrust = 1;
            $DB->update_record('glossary_comments', $comment);
        }
        $rs->close();
        /// glossary savepoint reached
        upgrade_mod_savepoint($result, 2009042005, 'glossary');
    }
    if ($result && $oldversion < 2009042006) {
        /// Define field introformat to be added to glossary
        $table = new xmldb_table('glossary');
        $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
        /// Conditionally launch add field introformat
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }
        /// glossary savepoint reached
        upgrade_mod_savepoint($result, 2009042006, 'glossary');
    }
    return $result;
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:101,代码来源:upgrade.php


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