• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP filter_phrases函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: data_filter

function data_filter($courseid, $text)
{
    global $CFG;
    static $nothingtodo;
    static $contentlist;
    if (!empty($nothingtodo)) {
        // We've been here in this page already
        return $text;
    }
    // if we don't have a courseid, we can't run the query, so
    if (empty($courseid)) {
        return $text;
    }
    // Create a list of all the resources to search for. It may be cached already.
    if (empty($contentlist)) {
        // We look for text field contents only, and only if the field has
        // autolink enabled (param1).
        $sql = 'SELECT dc.id AS contentid, ' . 'dr.id AS recordid, ' . 'dc.content AS content, ' . 'd.id AS dataid ' . 'FROM ' . $CFG->prefix . 'data d, ' . $CFG->prefix . 'data_fields df, ' . $CFG->prefix . 'data_records dr, ' . $CFG->prefix . 'data_content dc ' . "WHERE (d.course = '{$courseid}' or d.course = '" . SITEID . "')" . 'AND d.id = df.dataid ' . 'AND df.id = dc.fieldid ' . 'AND d.id = dr.dataid ' . 'AND dr.id = dc.recordid ' . "AND df.type = 'text' " . "AND " . sql_compare_text('df.param1', 1) . " = '1'";
        if (!($datacontents = get_records_sql($sql))) {
            return $text;
        }
        $contentlist = array();
        foreach ($datacontents as $datacontent) {
            $currentcontent = trim($datacontent->content);
            $strippedcontent = strip_tags($currentcontent);
            if (!empty($strippedcontent)) {
                $contentlist[] = new filterobject($currentcontent, '<a class="data autolink" title="' . $strippedcontent . '" href="' . $CFG->wwwroot . '/mod/data/view.php?d=' . $datacontent->dataid . '&amp;rid=' . $datacontent->recordid . '" ' . $CFG->frametarget . '>', '</a>', false, true);
            }
        }
        // End foreach
    }
    return filter_phrases($text, $contentlist);
    // Look for all these links in the text
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:34,代码来源:filter.php


示例2: filter

 function filter($text, array $options = array())
 {
     static $words;
     global $CFG;
     if (!isset($CFG->filter_censor_badwords)) {
         set_config('filter_censor_badwords', '');
     }
     if (empty($words)) {
         $words = array();
         if (empty($CFG->filter_censor_badwords)) {
             $badwords = explode(',', get_string('badwords', 'filter_censor'));
         } else {
             $badwords = explode(',', $CFG->filter_censor_badwords);
         }
         foreach ($badwords as $badword) {
             $badword = trim($badword);
             if ($this->_canseecensor()) {
                 $words[] = new filterobject($badword, '<span class="censoredtexthighlight" title="' . $badword . '">', '</span>', false, false, $badword);
             } else {
                 $words[] = new filterobject($badword, '<span class="censoredtext" title="' . $badword . '">', '</span>', false, false, str_pad('', strlen($badword), '*'));
             }
         }
     }
     return filter_phrases($text, $words);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:25,代码来源:filter.php


示例3: activitynames_filter

function activitynames_filter($courseid, $text)
{
    global $CFG, $COURSE;
    // Trivial-cache - keyed on $cachedcourseid
    static $activitylist = null;
    static $cachedcourseid;
    if (empty($courseid)) {
        $courseid = SITEID;
    }
    // Initialise/invalidate our trivial cache if dealing with a different course
    if (!isset($cachedcourseid) || $cachedcourseid !== (int) $courseid) {
        $activitylist = null;
    }
    $cachedcourseid = (int) $courseid;
    /// It may be cached
    if (is_null($activitylist)) {
        $activitylist = array();
        if ($COURSE->id == $courseid) {
            $course = $COURSE;
        } else {
            $course = get_record("course", "id", $courseid);
        }
        if (!isset($course->modinfo)) {
            return $text;
        }
        /// Casting $course->modinfo to string prevents one notice when the field is null
        $modinfo = unserialize((string) $course->modinfo);
        if (!empty($modinfo)) {
            $activitylist = array();
            /// We will store all the activities here
            //Sort modinfo by name length
            usort($modinfo, 'comparemodulenamesbylength');
            foreach ($modinfo as $activity) {
                //Exclude labels, hidden activities and activities for group members only
                if ($activity->mod != "label" and $activity->visible and empty($activity->groupmembersonly)) {
                    $title = s(trim(strip_tags(urldecode($activity->name))));
                    $currentname = trim(urldecode($activity->name));
                    $entitisedname = s($currentname);
                    /// Avoid empty or unlinkable activity names
                    if (!empty($title)) {
                        $href_tag_begin = "<a class=\"autolink\" title=\"{$title}\" href=\"{$CFG->wwwroot}/mod/{$activity->mod}/view.php?id={$activity->cm}\" {$CFG->frametarget}>";
                        $activitylist[] = new filterobject($currentname, $href_tag_begin, '</a>', false, true);
                        if ($currentname != $entitisedname) {
                            /// If name has some entity (&amp; &quot; &lt; &gt;) add that filter too. MDL-17545
                            $activitylist[] = new filterobject($entitisedname, $href_tag_begin, '</a>', false, true);
                        }
                    }
                }
            }
        }
    }
    if ($activitylist) {
        return $text = filter_phrases($text, $activitylist);
    } else {
        return $text;
    }
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:57,代码来源:filter.php


示例4: filter

 function filter($text, array $options = array())
 {
     if (!($courseid = get_courseid_from_context($this->context))) {
         return $text;
     }
     // Initialise/invalidate our trivial cache if dealing with a different course
     if (!isset(self::$cachedcourseid) || self::$cachedcourseid !== (int) $courseid) {
         self::$activitylist = null;
     }
     self::$cachedcourseid = (int) $courseid;
     /// It may be cached
     if (is_null(self::$activitylist)) {
         self::$activitylist = array();
         $modinfo = get_fast_modinfo($courseid);
         if (!empty($modinfo->cms)) {
             self::$activitylist = array();
             /// We will store all the activities here
             //Sort modinfo by name length
             $sortedactivities = fullclone($modinfo->cms);
             usort($sortedactivities, 'filter_activitynames_comparemodulenamesbylength');
             foreach ($sortedactivities as $cm) {
                 //Exclude labels, hidden activities and activities for group members only
                 if ($cm->visible and empty($cm->groupmembersonly) and $cm->has_view()) {
                     $title = s(trim(strip_tags($cm->name)));
                     $currentname = trim($cm->name);
                     $entitisedname = s($currentname);
                     /// Avoid empty or unlinkable activity names
                     if (!empty($title)) {
                         $href_tag_begin = html_writer::start_tag('a', array('class' => 'autolink', 'title' => $title, 'href' => $cm->get_url()));
                         self::$activitylist[$cm->id] = new filterobject($currentname, $href_tag_begin, '</a>', false, true);
                         if ($currentname != $entitisedname) {
                             /// If name has some entity (&amp; &quot; &lt; &gt;) add that filter too. MDL-17545
                             self::$activitylist[$cm->id . '-e'] = new filterobject($entitisedname, $href_tag_begin, '</a>', false, true);
                         }
                     }
                 }
             }
         }
     }
     $filterslist = array();
     if (self::$activitylist) {
         $cmid = $this->context->instanceid;
         if ($this->context->contextlevel == CONTEXT_MODULE && isset(self::$activitylist[$cmid])) {
             // remove filterobjects for the current module
             $filterslist = array_diff_key(self::$activitylist, array($cmid => 1, $cmid . '-e' => 1));
         } else {
             $filterslist = self::$activitylist;
         }
     }
     if ($filterslist) {
         return $text = filter_phrases($text, $filterslist);
     } else {
         return $text;
     }
 }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:55,代码来源:filter.php


示例5: wiki_filter

function wiki_filter($courseid, $text)
{
    global $CFG, $DB;
    // Trivial-cache - keyed on $cachedcourseid
    static $nothingtodo;
    static $wikipagelist;
    static $cachedcourseid;
    if (empty($courseid)) {
        $courseid = SITEID;
    }
    // Initialise/invalidate our trivial cache if dealing with a different course
    if (!isset($cachedcourseid) || $cachedcourseid !== (int) $courseid) {
        $wikipagelist = array();
        $nothingtodo = false;
    }
    $cachedcourseid = (int) $courseid;
    if (!empty($nothingtodo)) {
        // We've been here in this page already
        return $text;
    }
    /// Create a list of all the wikis to search for.  It may be cached already.
    if (empty($wikipagelist)) {
        /// Get all wikis for this course.
        if (!($wikis = wiki_get_course_wikis($courseid))) {
            $nothingtodo = true;
            return $text;
        }
        $wikipagelist = array();
        /// Walk through each wiki, and get entries.
        foreach ($wikis as $wiki) {
            if ($wiki_entries = wiki_get_entries($wiki)) {
                /// Walk through each entry and get the pages.
                foreach ($wiki_entries as $wiki_entry) {
                    if ($wiki_pages = $DB->get_records('wiki_pages', array('wiki' => $wiki_entry->id), 'pagename, version DESC')) {
                        /// Walk through each page and filter.
                        $wikientries = array();
                        foreach ($wiki_pages as $wiki_page) {
                            if (!in_array($wiki_page->pagename, $wikientries)) {
                                $startlink = '<a class="wiki autolink" title="Wiki" href="' . $CFG->wwwroot . '/mod/wiki/view.php?wid=' . $wiki->id . '&amp;userid=' . $wiki_entry->userid . '&amp;groupid=' . $wiki_entry->groupid . '&amp;page=' . $wiki_page->pagename . '">';
                                $wikipagelist[] = new filterobject($wiki_page->pagename, $startlink, '</a>', false, true);
                                $wikientries[] = $wiki_page->pagename;
                            }
                        }
                    }
                }
            }
        }
    }
    return filter_phrases($text, $wikipagelist);
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:50,代码来源:filter.php


示例6: resource_filter

function resource_filter($courseid, $text)
{
    global $CFG;
    // Trivial-cache - keyed on $cachedcourseid
    static $nothingtodo;
    static $resourcelist;
    static $cachedcourseid;
    // if we don't have a courseid, we can't run the query, so
    if (empty($courseid)) {
        return $text;
    }
    // Initialise/invalidate our trivial cache if dealing with a different course
    if (!isset($cachedcourseid) || $cachedcourseid !== (int) $courseid) {
        $resourcelist = array();
        $nothingtodo = false;
    }
    $cachedcourseid = (int) $courseid;
    if ($nothingtodo === true) {
        return $text;
    }
    /// Create a list of all the resources to search for.  It may be cached already.
    if (empty($resourcelist)) {
        /* get all non-hidden resources from this course
         * sorted from long to short so longer ones can be 
         * linked first. And order by section so we try to 
         * link to the top resource first.
         */
        $resource_sql = "SELECT r.id, r.name \n                FROM {$CFG->prefix}resource r, \n                     {$CFG->prefix}course_modules cm, \n                     {$CFG->prefix}modules m\n                WHERE m.name = 'resource' AND\n                        cm.module = m.id AND\n                        cm.visible =  1 AND\n                        r.id = cm.instance AND\n                        cm.course = {$courseid}\n                ORDER BY " . sql_length('r.name') . " DESC, cm.section ASC";
        if (!($resources = get_records_sql($resource_sql))) {
            $nothingtodo = true;
            return $text;
        }
        $resourcelist = array();
        foreach ($resources as $resource) {
            $currentname = trim($resource->name);
            $entitisedname = s($currentname);
            $strippedname = strip_tags($currentname);
            /// Avoid empty or unlinkable resource names
            if (!empty($strippedname)) {
                $resourcelist[] = new filterobject($currentname, '<a class="resource autolink" title="' . $strippedname . '" href="' . $CFG->wwwroot . '/mod/resource/view.php?r=' . $resource->id . '" ' . $CFG->frametarget . '>', '</a>', false, true);
                if ($currentname != $entitisedname) {
                    /// If name has some entity (&amp; &quot; &lt; &gt;) add that filter too. MDL-17518
                    $resourcelist[] = new filterobject($entitisedname, '<a class="resource autolink" title="' . $strippedname . '" href="' . $CFG->wwwroot . '/mod/resource/view.php?r=' . $resource->id . '" ' . $CFG->frametarget . '>', '</a>', false, true);
                }
            }
        }
    }
    return filter_phrases($text, $resourcelist);
    // Look for all these links in the text
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:50,代码来源:filter.php


示例7: resource_filter

function resource_filter($courseid, $text)
{
    global $CFG;
    // Trivial-cache - keyed on $cachedcourseid
    static $nothingtodo;
    static $resourcelist;
    static $cachedcourseid;
    // if we don't have a courseid, we can't run the query, so
    if (empty($courseid)) {
        return $text;
    }
    // Initialise/invalidate our trivial cache if dealing with a different course
    if (!isset($cachedcourseid) || $cachedcourseid !== (int) $courseid) {
        $resourcelist = array();
        $nothingtodo = false;
    }
    $cachedcourseid = (int) $courseid;
    if ($nothingtodo === true) {
        return $text;
    }
    /// Create a list of all the resources to search for.  It may be cached already.
    if (empty($resourcelist)) {
        /// The resources are sorted from long to short so longer ones can be linked first.
        if (!($resources = get_records('resource', 'course', $courseid, 'CHAR_LENGTH(name) DESC', 'id,name'))) {
            $nothingtodo = true;
            return $text;
        }
        $resourcelist = array();
        foreach ($resources as $resource) {
            $currentname = trim($resource->name);
            $entitisedname = s($currentname);
            $strippedname = strip_tags($currentname);
            /// Avoid empty or unlinkable resource names
            if (!empty($strippedname)) {
                $resourcelist[] = new filterobject($currentname, '<a class="resource autolink" title="' . $strippedname . '" href="' . $CFG->wwwroot . '/mod/resource/view.php?r=' . $resource->id . '" ' . $CFG->frametarget . '>', '</a>', false, true);
                if ($currentname != $entitisedname) {
                    /// If name has some entity (&amp; &quot; &lt; &gt;) add that filter too. MDL-17518
                    $resourcelist[] = new filterobject($entitisedname, '<a class="resource autolink" title="' . $strippedname . '" href="' . $CFG->wwwroot . '/mod/resource/view.php?r=' . $resource->id . '" ' . $CFG->frametarget . '>', '</a>', false, true);
                }
            }
        }
    }
    return filter_phrases($text, $resourcelist);
    // Look for all these links in the text
}
开发者ID:veritech,项目名称:pare-project,代码行数:45,代码来源:filter.php


示例8: activitynames_filter

function activitynames_filter($courseid, $text)
{
    global $CFG;
    // Trivial-cache - keyed on $cachedcourseid
    static $activitylist;
    static $cachedcourseid;
    if (empty($courseid)) {
        $courseid = SITEID;
    }
    // Initialise/invalidate our trivial cache if dealing with a different course
    if (!isset($cachedcourseid) || $cachedcourseid !== (int) $courseid) {
        $activitylist = array();
    }
    $cachedcourseid = (int) $courseid;
    /// It may be cached
    if (empty($activitylist)) {
        $course = get_record("course", "id", $courseid);
        /// Casting $course->modinfo to string prevents one notice when the field is null
        $modinfo = unserialize((string) $course->modinfo);
        if (!empty($modinfo)) {
            $activitylist = array();
            /// We will store all the activities here
            //Sort modinfo by name length
            usort($modinfo, 'comparemodulenamesbylength');
            foreach ($modinfo as $activity) {
                //Exclude labels and hidden items
                if ($activity->mod != "label" && $activity->visible) {
                    $title = trim(strip_tags(urldecode($activity->name)));
                    /// Avoid empty or unlinkable activity names
                    if (!empty($title)) {
                        $title = str_replace('"', "'", $title);
                        $href_tag_begin = "<a class=\"autolink\" title=\"{$title}\" href=\"{$CFG->wwwroot}/mod/{$activity->mod}/view.php?id={$activity->cm}\" {$CFG->frametarget}>";
                        $currentname = urldecode($activity->name);
                        if ($currentname = trim($currentname)) {
                            $activitylist[] = new filterobject($currentname, $href_tag_begin, '</a>', false, true);
                        }
                    }
                }
            }
        }
    }
    return $text = filter_phrases($text, $activitylist);
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:43,代码来源:filter.php


示例9: censor_filter

function censor_filter($courseid, $text)
{
    static $words;
    global $CFG;
    if (!isset($CFG->filter_censor_badwords)) {
        set_config('filter_censor_badwords', '');
    }
    if (empty($words)) {
        $words = array();
        // if no user-specified words, use default list from language pack
        if (empty($CFG->filter_censor_badwords)) {
            $badwords = explode(',', get_string('badwords', 'censor'));
        } else {
            $badwords = explode(',', $CFG->filter_censor_badwords);
        }
        foreach ($badwords as $badword) {
            $badword = trim($badword);
            $words[] = new filterobject($badword, '<span class="censoredtext" title="' . $badword . '">', '</span>', false, false, str_pad('', strlen($badword), '*'));
        }
    }
    return filter_phrases($text, $words);
    // Look for all these words in the text
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:23,代码来源:filter.php


示例10: filter


//.........这里部分代码省略.........
                   FROM {glossary_alias} ga,
                        {glossary_entries} ge
                   WHERE ga.entryid = ge.id
                     AND ge.glossaryid IN (' . $glossarylist . ')
                     AND ge.usedynalink != 0
                     AND ge.approved != 0', null);
         // Combine them into one big list
         $concepts = array();
         if ($entries and $categories) {
             $concepts = array_merge($entries, $categories);
         } else {
             if ($categories) {
                 $concepts = $categories;
             } else {
                 if ($entries) {
                     $concepts = $entries;
                 }
             }
         }
         if ($aliases) {
             $concepts = array_merge($concepts, $aliases);
         }
         if (!empty($concepts)) {
             foreach ($concepts as $key => $concept) {
                 // Trim empty or unlinkable concepts
                 $currentconcept = trim(strip_tags($concept->concept));
                 if (empty($currentconcept)) {
                     unset($concepts[$key]);
                     continue;
                 } else {
                     $concepts[$key]->concept = $currentconcept;
                 }
                 // Rule out any small integers.  See bug 1446
                 $currentint = intval($currentconcept);
                 if ($currentint && strval($currentint) == $currentconcept && $currentint < 1000) {
                     unset($concepts[$key]);
                 }
             }
         }
         if (empty($concepts)) {
             $nothingtodo = true;
             return $text;
         }
         usort($concepts, 'filter_glossary::sort_entries_by_length');
         $strcategory = get_string('category', 'glossary');
         // Loop through all the concepts, setting up our data structure for the filter
         $conceptlist = array();
         // We will store all the concepts here
         foreach ($concepts as $concept) {
             $glossaryname = str_replace(':', '-', $glossaries[$concept->glossaryid]);
             if ($concept->category) {
                 // Link to a category
                 // TODO: Fix this string usage
                 $title = strip_tags($glossaryname . ': ' . $strcategory . ' ' . $concept->concept);
                 $href_tag_begin = '<a class="glossary autolink category glossaryid' . $concept->glossaryid . '" title="' . $title . '" ' . 'href="' . $CFG->wwwroot . '/mod/glossary/view.php?g=' . $concept->glossaryid . '&amp;mode=cat&amp;hook=' . $concept->id . '">';
             } else {
                 // Link to entry or alias
                 if (!empty($concept->originalconcept)) {
                     // We are dealing with an alias (so show and point to original)
                     $title = str_replace('"', "'", strip_tags($glossaryname . ': ' . $concept->originalconcept));
                     $concept->id = $concept->entryid;
                 } else {
                     // This is an entry
                     $title = str_replace('"', "'", strip_tags($glossaryname . ': ' . $concept->concept));
                 }
                 // hardcoding dictionary format in the URL rather than defaulting
                 // to the current glossary format which may not work in a popup.
                 // for example "entry list" means the popup would only contain
                 // a link that opens another popup.
                 $link = new moodle_url('/mod/glossary/showentry.php', array('courseid' => $courseid, 'eid' => $concept->id, 'displayformat' => 'dictionary'));
                 $attributes = array('href' => $link, 'title' => $title, 'class' => 'glossary autolink concept glossaryid' . $concept->glossaryid);
                 // this flag is optionally set by resource_pluginfile()
                 // if processing an embedded file use target to prevent getting nested Moodles
                 if (isset($CFG->embeddedsoforcelinktarget) && $CFG->embeddedsoforcelinktarget) {
                     $attributes['target'] = '_top';
                 }
                 $href_tag_begin = html_writer::start_tag('a', $attributes);
             }
             $conceptlist[] = new filterobject($concept->concept, $href_tag_begin, '</a>', $concept->casesensitive, $concept->fullmatch);
         }
         $conceptlist = filter_remove_duplicates($conceptlist);
         if (empty($jsinitialised)) {
             // Add a JavaScript event to open popup's here. This only ever need to be
             // added once!
             $PAGE->requires->yui_module('moodle-filter_glossary-autolinker', 'M.filter_glossary.init_filter_autolinking', array(array('courseid' => $courseid)));
             $jsinitialised = true;
         }
     }
     if (!empty($GLOSSARY_EXCLUDECONCEPTS)) {
         $reducedconceptlist = array();
         foreach ($conceptlist as $concept) {
             if (!in_array($concept->phrase, $GLOSSARY_EXCLUDECONCEPTS)) {
                 $reducedconceptlist[] = $concept;
             }
         }
         return filter_phrases($text, $reducedconceptlist);
     }
     return filter_phrases($text, $conceptlist);
     // Actually search for concepts!
 }
开发者ID:numbas,项目名称:moodle,代码行数:101,代码来源:filter.php


示例11: filter

 public function filter($text, array $options = array())
 {
     global $CFG, $DB;
     // Trivial-cache - keyed on $cachedcontextid
     static $cachedcontextid;
     static $contentlist;
     static $nothingtodo;
     // Try to get current course
     if (!($courseid = get_courseid_from_context($this->context))) {
         $courseid = 0;
     }
     // Initialise/invalidate our trivial cache if dealing with a different context
     if (!isset($cachedcontextid) || $cachedcontextid !== $this->context->id) {
         $cachedcontextid = $this->context->id;
         $contentlist = array();
         $nothingtodo = false;
     }
     if ($nothingtodo === true) {
         return $text;
     }
     // Create a list of all the resources to search for. It may be cached already.
     if (empty($contentlist)) {
         $coursestosearch = $courseid ? array($courseid) : array();
         // Add courseid if found
         if (get_site()->id != $courseid) {
             // Add siteid if was not courseid
             $coursestosearch[] = get_site()->id;
         }
         // We look for text field contents only if have autolink enabled (param1)
         list($coursesql, $params) = $DB->get_in_or_equal($coursestosearch);
         $sql = 'SELECT dc.id AS contentid, dr.id AS recordid, dc.content AS content, d.id AS dataid
                   FROM {data} d
                   JOIN {data_fields} df ON df.dataid = d.id
                   JOIN {data_records} dr ON dr.dataid = d.id
                   JOIN {data_content} dc ON dc.fieldid = df.id AND dc.recordid = dr.id
                  WHERE d.course ' . $coursesql . '
                    AND df.type = \'text\'
                    AND ' . $DB->sql_compare_text('df.param1', 1) . " = '1'";
         if (!($contents = $DB->get_records_sql($sql, $params))) {
             $nothingtodo = true;
             return $text;
         }
         foreach ($contents as $key => $content) {
             // Trim empty or unlinkable concepts
             $currentcontent = trim(strip_tags($content->content));
             if (empty($currentcontent)) {
                 unset($contents[$key]);
                 continue;
             } else {
                 $contents[$key]->content = $currentcontent;
             }
             // Rule out any small integers.  See bug 1446
             $currentint = intval($currentcontent);
             if ($currentint && strval($currentint) == $currentcontent && $currentint < 1000) {
                 unset($contents[$key]);
             }
         }
         if (empty($contents)) {
             $nothingtodo = true;
             return $text;
         }
         usort($contents, 'filter_data::sort_entries_by_length');
         foreach ($contents as $content) {
             $href_tag_begin = '<a class="data autolink dataid' . $content->dataid . '" title="' . $content->content . '" ' . 'href="' . $CFG->wwwroot . '/mod/data/view.php?d=' . $content->dataid . '&amp;rid=' . $content->recordid . '">';
             $contentlist[] = new filterobject($content->content, $href_tag_begin, '</a>', false, true);
         }
         $contentlist = filter_remove_duplicates($contentlist);
         // Clean dupes
     }
     return filter_phrases($text, $contentlist);
     // Look for all these links in the text
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:72,代码来源:filter.php


示例12: filter

 public function filter($text, array $options = array())
 {
     global $CFG, $USER, $GLOSSARY_EXCLUDEENTRY;
     // Try to get current course.
     $coursectx = $this->context->get_course_context(false);
     if (!$coursectx) {
         // Only global glossaries will be linked.
         $courseid = 0;
     } else {
         $courseid = $coursectx->instanceid;
     }
     if ($this->cachecourseid != $courseid or $this->cacheuserid != $USER->id) {
         // Invalidate the page cache.
         $this->cacheconceptlist = null;
     }
     if (is_array($this->cacheconceptlist) and empty($GLOSSARY_EXCLUDEENTRY)) {
         if (empty($this->cacheconceptlist)) {
             return $text;
         }
         return filter_phrases($text, $this->cacheconceptlist);
     }
     list($glossaries, $allconcepts) = \mod_glossary\local\concept_cache::get_concepts($courseid);
     if (!$allconcepts) {
         $this->cacheuserid = $USER->id;
         $this->cachecourseid = $courseid;
         $this->cacheconcepts = array();
         return $text;
     }
     $strcategory = get_string('category', 'glossary');
     $conceptlist = array();
     $excluded = false;
     foreach ($allconcepts as $concepts) {
         foreach ($concepts as $concept) {
             if (!empty($GLOSSARY_EXCLUDEENTRY) and $concept->id == $GLOSSARY_EXCLUDEENTRY) {
                 $excluded = true;
                 continue;
             }
             if ($concept->category) {
                 // Link to a category.
                 // TODO: Fix this string usage.
                 $title = $glossaries[$concept->glossaryid] . ': ' . $strcategory . ' ' . $concept->concept;
                 $link = new moodle_url('/mod/glossary/view.php', array('g' => $concept->glossaryid, 'mode' => 'cat', 'hook' => $concept->id));
                 $attributes = array('href' => $link, 'title' => $title, 'class' => 'glossary autolink category glossaryid' . $concept->glossaryid);
             } else {
                 // Link to entry or alias
                 $title = $glossaries[$concept->glossaryid] . ': ' . $concept->concept;
                 // Hardcoding dictionary format in the URL rather than defaulting
                 // to the current glossary format which may not work in a popup.
                 // for example "entry list" means the popup would only contain
                 // a link that opens another popup.
                 $link = new moodle_url('/mod/glossary/showentry.php', array('eid' => $concept->id, 'displayformat' => 'dictionary'));
                 $attributes = array('href' => $link, 'title' => str_replace('&amp;', '&', $title), 'class' => 'glossary autolink concept glossaryid' . $concept->glossaryid);
             }
             // This flag is optionally set by resource_pluginfile()
             // if processing an embedded file use target to prevent getting nested Moodles.
             if (!empty($CFG->embeddedsoforcelinktarget)) {
                 $attributes['target'] = '_top';
             }
             $href_tag_begin = html_writer::start_tag('a', $attributes);
             $conceptlist[] = new filterobject($concept->concept, $href_tag_begin, '</a>', $concept->casesensitive, $concept->fullmatch);
         }
     }
     usort($conceptlist, 'filter_glossary::sort_entries_by_length');
     if (!$excluded) {
         // Do not cache the excluded list here, it is used once per page only.
         $this->cacheuserid = $USER->id;
         $this->cachecourseid = $courseid;
         $this->cacheconceptlist = $conceptlist;
     }
     if (empty($conceptlist)) {
         return $text;
     }
     return filter_phrases($text, $conceptlist);
     // Actually search for concepts!
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:75,代码来源:filter.php


示例13: filter

 function filter($text, array $options = array())
 {
     $coursectx = $this->context->get_course_context(false);
     if (!$coursectx) {
         return $text;
     }
     $courseid = $coursectx->instanceid;
     // Initialise/invalidate our trivial cache if dealing with a different course
     if (!isset(self::$cachedcourseid) || self::$cachedcourseid !== (int) $courseid) {
         self::$activitylist = null;
     }
     self::$cachedcourseid = (int) $courseid;
     /// It may be cached
     if (is_null(self::$activitylist)) {
         self::$activitylist = array();
         $modinfo = get_fast_modinfo($courseid);
         if (!empty($modinfo->cms)) {
             self::$activitylist = array();
             // We will store all the created filters here.
             // Create array of visible activities sorted by the name length (we are only interested in properties name and url).
             $sortedactivities = array();
             foreach ($modinfo->cms as $cm) {
                 // Exclude labels, hidden activities and activities for group members only.
                 if ($cm->visible and empty($cm->groupmembersonly) and $cm->has_view()) {
                     $sortedactivities[] = (object) array('name' => $cm->name, 'url' => $cm->url, 'id' => $cm->id, 'namelen' => strlen($cm->name));
                 }
             }
             core_collator::asort_objects_by_property($sortedactivities, 'namelen', SORT_NUMERIC);
             foreach ($sortedactivities as $cm) {
                 $title = s(trim(strip_tags($cm->name)));
                 $currentname = trim($cm->name);
                 $entitisedname = s($currentname);
                 // Avoid empty or unlinkable activity names.
                 if (!empty($title)) {
                     $href_tag_begin = html_writer::start_tag('a', array('class' => 'autolink', 'title' => $title, 'href' => $cm->url));
                     self::$activitylist[$cm->id] = new filterobject($currentname, $href_tag_begin, '</a>', false, true);
                     if ($currentname != $entitisedname) {
                         // If name has some entity (&amp; &quot; &lt; &gt;) add that filter too. MDL-17545.
                         self::$activitylist[$cm->id . '-e'] = new filterobject($entitisedname, $href_tag_begin, '</a>', false, true);
                     }
                 }
             }
         }
     }
     $filterslist = array();
     if (self::$activitylist) {
         $cmid = $this->context->instanceid;
         if ($this->context->contextlevel == CONTEXT_MODULE && isset(self::$activitylist[$cmid])) {
             // remove filterobjects for the current module
             $filterslist = array_values(array_diff_key(self::$activitylist, array($cmid => 1, $cmid . '-e' => 1)));
         } else {
             $filterslist = array_values(self::$activitylist);
         }
     }
     if ($filterslist) {
         return $text = filter_phrases($text, $filterslist);
     } else {
         return $text;
     }
 }
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:60,代码来源:filter.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP filter_preload_activities函数代码示例发布时间:2022-05-15
下一篇:
PHP filter_pflog_start函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap