/**
 * Checks if the provided filter path is installed and enabled (check "Site Administration -> Plugins -> Filters" or 
 * "Site Administration -> Modules -> Filters" area to see if a filter is enabled) in the moodle platform. Uses the built-in
 * function filter_is_enabled() for Moodle 2.x and raw checkups for Moodle 1.9.
 * 
 * @param String $filterpath
 * 		The filter path in the format "folder/plugin_name" to check for files
 * @return boolean
 * 		true if the filter is installed and enabled, false otherwise
 */
function filter_plugin_enabled($filterpath)
{
    global $CFG;
    // filter_is_enabled() function belongs to Moodle 2.x
    if (function_exists('filter_is_enabled')) {
        return filter_is_enabled($filterpath);
    } else {
        // get all the currently selected filters
        if (!empty($CFG->textfilters)) {
            $activefilters = explode(',', $CFG->textfilters);
        } else {
            $activefilters = array();
        }
        // check if filter plugin location is readable
        $pluginpath = "{$CFG->dirroot}/{$filterpath}/filter.php";
        return is_readable($pluginpath) && in_array($filterpath, $activefilters);
    }
}
예제 #2
0
 public function process_config($data)
 {
     $data = (object) $data;
     if (strpos($data->filter, 'filter/') === 0) {
         $data->filter = substr($data->filter, 7);
     } else {
         if (strpos($data->filter, '/') !== false) {
             // Unsupported old filter.
             return;
         }
     }
     if (!filter_is_enabled($data->filter)) {
         // Not installed or not enabled, nothing to do
         return;
     }
     filter_set_local_config($data->filter, $this->task->get_contextid(), $data->name, $data->value);
 }
예제 #3
0
    public function process_config($data) {

        $data = (object)$data;

        if (!filter_is_enabled($data->filter)) { // Not installed or not enabled, nothing to do
            return;
        }
        filter_set_local_config($data->filter, $this->task->get_contextid(), $data->name, $data->value);
    }
예제 #4
0
파일: filelib.php 프로젝트: hatone/moodle
/**
 * add includes (js and css) into uploaded files
 * before returning them, useful for themes and utf.js includes
 *
 * @global object
 * @param string $text text to search and replace
 * @return string text with added head includes
 */
function file_modify_html_header($text)
{
    // first look for <head> tag
    global $CFG;
    $stylesheetshtml = '';
    /*    foreach ($CFG->stylesheets as $stylesheet) {
            //TODO: MDL-21120
            $stylesheetshtml .= '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'" />'."\n";
        }*/
    $ufo = '';
    if (filter_is_enabled('filter/mediaplugin')) {
        // this script is needed by most media filter plugins.
        $attributes = array('type' => 'text/javascript', 'src' => $CFG->httpswwwroot . '/lib/ufo.js');
        $ufo = html_writer::tag('script', '', $attributes) . "\n";
    }
    preg_match('/\\<head\\>|\\<HEAD\\>/', $text, $matches);
    if ($matches) {
        $replacement = '<head>' . $ufo . $stylesheetshtml;
        $text = preg_replace('/\\<head\\>|\\<HEAD\\>/', $replacement, $text, 1);
        return $text;
    }
    // if not, look for <html> tag, and stick <head> right after
    preg_match('/\\<html\\>|\\<HTML\\>/', $text, $matches);
    if ($matches) {
        // replace <html> tag with <html><head>includes</head>
        $replacement = '<html>' . "\n" . '<head>' . $ufo . $stylesheetshtml . '</head>';
        $text = preg_replace('/\\<html\\>|\\<HTML\\>/', $replacement, $text, 1);
        return $text;
    }
    // if not, look for <body> tag, and stick <head> before body
    preg_match('/\\<body\\>|\\<BODY\\>/', $text, $matches);
    if ($matches) {
        $replacement = '<head>' . $ufo . $stylesheetshtml . '</head>' . "\n" . '<body>';
        $text = preg_replace('/\\<body\\>|\\<BODY\\>/', $replacement, $text, 1);
        return $text;
    }
    // if not, just stick a <head> tag at the beginning
    $text = '<head>' . $ufo . $stylesheetshtml . '</head>' . "\n" . $text;
    return $text;
}
예제 #5
0
<?php

// This function fetches math. images from the data directory
// If not, it obtains the corresponding TeX expression from the cache_tex db table
// and uses mimeTeX to create the image file
define('NO_MOODLE_COOKIES', true);
// Because it interferes with caching
require_once "../../config.php";
if (!filter_is_enabled('algebra')) {
    print_error('filternotenabled');
}
require_once $CFG->libdir . '/filelib.php';
require_once $CFG->dirroot . '/filter/tex/lib.php';
require_login();
require_capability('moodle/site:config', context_system::instance());
$query = urldecode($_SERVER['QUERY_STRING']);
if ($query) {
    $output = $query;
    $splitpos = strpos($query, '&') - 8;
    $algebra = substr($query, 8, $splitpos);
    $md5 = md5($algebra);
    if (strpos($query, 'ShowDB') || strpos($query, 'DeleteDB')) {
        $texcache = $DB->get_record("cache_filters", array("filter" => "algebra", "md5key" => $md5));
    }
    if (strpos($query, 'ShowDB')) {
        if ($texcache) {
            $output = "DB cache_filters entry for {$algebra}\n";
            $output .= "id = {$texcache->id}\n";
            $output .= "filter = {$texcache->filter}\n";
            $output .= "version = {$texcache->version}\n";
            $output .= "md5key = {$texcache->md5key}\n";
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * This function fetches math. images from the data directory
 * If not, it obtains the corresponding TeX expression from the cache_tex db table
 * and uses mimeTeX to create the image file
 *
 * @package    filter
 * @subpackage tex
 * @copyright  2004 Zbigniew Fiedorowicz fiedorow@math.ohio-state.edu
 *             Originally based on code provided by Bruno Vernier bruno@vsbeducation.ca
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once "../../config.php";
if (!filter_is_enabled('filter/tex')) {
    print_error('filternotenabled');
}
require_once $CFG->libdir . '/filelib.php';
require_once $CFG->dirroot . '/filter/tex/lib.php';
require_once $CFG->dirroot . '/filter/tex/latex.php';
$action = optional_param('action', '', PARAM_ALPHA);
$texexp = optional_param('tex', '', PARAM_RAW);
require_login();
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM), $USER->id);
/// Required cap to run this. MDL-18552
$output = '';
// look up in cache if required
if ($action == 'ShowDB' or $action == 'DeleteDB') {
    $md5 = md5($texexp);
    $texcache = $DB->get_record("cache_filters", array("filter" => "tex", "md5key" => $md5));
예제 #7
0
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * This script displays tex source code, it is used also from the algebra filter.
 *
 * @package    filter
 * @subpackage tex
 * @copyright  2004 Zbigniew Fiedorowicz fiedorow@math.ohio-state.edu
 *             Originally based on code provided by Bruno Vernier bruno@vsbeducation.ca
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
define('NO_MOODLE_COOKIES', true);
// Because it interferes with caching
require '../../config.php';
if (!filter_is_enabled('tex') and !filter_is_enabled('algebra')) {
    print_error('filternotenabled');
}
$texexp = optional_param('texexp', '', PARAM_RAW);
$title = get_string('source', 'filter_tex');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title><?php 
echo $title;
?>
</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  </head>
  <body>
예제 #8
0
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * This function fetches math. images from the data directory
 * If not, it obtains the corresponding TeX expression from the cache_tex db table
 * and uses mimeTeX to create the image file
 *
 * @package    filter
 * @subpackage tex
 * @copyright  2004 Zbigniew Fiedorowicz fiedorow@math.ohio-state.edu
 *             Originally based on code provided by Bruno Vernier bruno@vsbeducation.ca
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once "../../config.php";
if (!filter_is_enabled('tex')) {
    print_error('filternotenabled');
}
require_once $CFG->libdir . '/filelib.php';
require_once $CFG->dirroot . '/filter/tex/lib.php';
require_once $CFG->dirroot . '/filter/tex/latex.php';
$action = optional_param('action', '', PARAM_ALPHA);
$texexp = optional_param('tex', '', PARAM_RAW);
require_login();
require_capability('moodle/site:config', context_system::instance(), $USER->id);
/// Required cap to run this. MDL-18552
$output = '';
// look up in cache if required
if ($action == 'ShowDB' or $action == 'DeleteDB') {
    $md5 = md5($texexp);
    $texcache = $DB->get_record("cache_filters", array("filter" => "tex", "md5key" => $md5));
 public function updateConfiguration(&$configuration)
 {
     global $CFG;
     // Cache folder.
     $configuration['wiriscachedirectory'] = $CFG->dataroot . '/filter/wiris/cache';
     if (!file_exists($configuration['wiriscachedirectory'])) {
         @mkdir($configuration['wiriscachedirectory'], 0755, true);
     }
     // Formulas folder.
     $configuration['wirisformuladirectory'] = $CFG->dataroot . '/filter/wiris/formulas';
     if (!file_exists($configuration['wirisformuladirectory'])) {
         @mkdir($configuration['wirisformuladirectory'], 0755, true);
     }
     $scriptName = explode('/', $_SERVER["SCRIPT_FILENAME"]);
     $scriptName = array_pop($scriptName);
     if ($scriptName == 'showimage.php') {
         // Minimal conf showing images.
         if (isset($_GET['refererquery'])) {
             $refererquery = implode('&', explode('/', $_GET['refererquery']));
             $configuration['wirisreferer'] = $CFG->wwwroot . $refererquery;
         }
         return;
     }
     // Enable LaTeX.
     if ($this->getLatexStatus()) {
         $configuration['wiriseditorparselatex'] = false;
     }
     // WIRIS editor.
     $filter_enabled = filter_is_enabled('filter/wiris');
     $this->was_editor_enabled = $this->evalParameter($configuration['wiriseditorenabled']);
     if (isset($CFG->filter_wiris_editor_enable)) {
         $configuration['wiriseditorenabled'] = $this->was_editor_enabled && $this->evalParameter($CFG->filter_wiris_editor_enable) && $filter_enabled;
     } else {
         $configuration['wiriseditorenabled'] = false;
     }
     // WIRIS cas.
     $this->was_cas_enabled = $this->evalParameter($configuration['wiriscasenabled']);
     if (isset($CFG->filter_wiris_cas_enable)) {
         $configuration['wiriscasenabled'] = $this->was_cas_enabled && $this->evalParameter($CFG->filter_wiris_cas_enable) && $filter_enabled;
     } else {
         $configuration['wiriscasenabled'] = false;
     }
     // Where is the plugin.
     $configuration['wiriscontextpath'] = $this->editor_plugin->url;
     // Encoded XML
     $configuration['wiriseditorsavemode'] = 'safeXml';
     // Moodle version.
     // if ($CFG->version >= 2012120300) { // Moodle 2.4 or superior
     //     $configuration['wirishostplatform'] = 'moodle2_4';
     // } else {
     //     $configuration['wirishostplatform'] = 'moodle2';
     // }
     $configuration['wirishostplatform'] = isset($CFG->release) ? $CFG->release : $CFG->version;
     // Referer.
     global $COURSE;
     $query = '';
     if (isset($COURSE->id)) {
         $query .= '?course=' . $COURSE->id;
     }
     if (isset($COURSE->category)) {
         $query .= empty($query) ? '?' : '&';
         $query .= 'category=' . $COURSE->category;
     }
     $configuration['wirisreferer'] = $CFG->wwwroot . $query;
     $moodleproxyenabled = !empty($CFG->proxyhost);
     $proxyportenabled = !empty($CFG->proxyport);
     $proxyuserenabled = !empty($CFG->proxyuser);
     $proxypassenabled = !empty($CFG->proxypassword);
     if ($moodleproxyenabled) {
         $configuration['wirisproxy'] = "true";
         $configuration['wirisproxy_host'] = $CFG->proxyhost;
         $configuration['wirisproxy_port'] = $proxyportenabled ? $CFG->proxyport : null;
         $configuration['wirisproxy_user'] = $proxyuserenabled ? $CFG->proxyuser : null;
         $configuration['wirisproxy_password'] = $proxypassenabled ? $CFG->proxypassword : null;
     }
 }
예제 #10
0
    $report_text = '<span>' . $plugin->release . '</span>';
    $condition = true;
} else {
    $report_text = 'Impossible to find WIRIS plugin filter version file.';
    $condition = false;
}
$solution_link = 'http://www.wiris.com/plugins/moodle/download';
echo wrs_createTableRow($test_name, $report_text, $solution_link, $condition);
?>
				
			</tr>
			<tr>			
				<?php 
$test_name = 'WIRIS plugin filter';
$solution_link = 'http://www.wiris.com/plugins/docs/moodle/moodle-2.0';
$filter_enabled = filter_is_enabled('filter/wiris');
if ($filter_enabled) {
    $report_text = 'ENABLED';
} else {
    $report_text = 'DISABLED';
}
echo wrs_createTableRow($test_name, $report_text, $solution_link, $filter_enabled);
?>
			
			</tr>			
			<tr>			
				<?php 
$test_name = 'Looking for WIRIS plugin for ' . $wiris_plugin_base_string;
$report_text = 'WIRIS plugin for ' . $wiris_plugin_base_string . ' must be installed.';
$solution_link = 'http://www.wiris.com/plugins/moodle/download';
$wiris_plugin = $wiris_plugin_base . '/integration';
예제 #11
0
/**
 * add includes (js and css) into uploaded files
 * before returning them, useful for themes and utf.js includes
 * @param string text - text to search and replace
 * @return string - text with added head includes
 */
function file_modify_html_header($text)
{
    // first look for <head> tag
    global $CFG;
    $stylesheetshtml = '';
    foreach ($CFG->stylesheets as $stylesheet) {
        $stylesheetshtml .= '<link rel="stylesheet" type="text/css" href="' . $stylesheet . '" />' . "\n";
    }
    $ufo = '';
    if (filter_is_enabled('filter/mediaplugin')) {
        // this script is needed by most media filter plugins.
        $ufo = get_require_js_code(array($CFG->wwwroot . '/lib/ufo.js'));
    }
    preg_match('/\\<head\\>|\\<HEAD\\>/', $text, $matches);
    if ($matches) {
        $replacement = '<head>' . $ufo . $stylesheetshtml;
        $text = preg_replace('/\\<head\\>|\\<HEAD\\>/', $replacement, $text, 1);
        return $text;
    }
    // if not, look for <html> tag, and stick <head> right after
    preg_match('/\\<html\\>|\\<HTML\\>/', $text, $matches);
    if ($matches) {
        // replace <html> tag with <html><head>includes</head>
        $replacement = '<html>' . "\n" . '<head>' . $ufo . $stylesheetshtml . '</head>';
        $text = preg_replace('/\\<html\\>|\\<HTML\\>/', $replacement, $text, 1);
        return $text;
    }
    // if not, look for <body> tag, and stick <head> before body
    preg_match('/\\<body\\>|\\<BODY\\>/', $text, $matches);
    if ($matches) {
        $replacement = '<head>' . $ufo . $stylesheetshtml . '</head>' . "\n" . '<body>';
        $text = preg_replace('/\\<body\\>|\\<BODY\\>/', $replacement, $text, 1);
        return $text;
    }
    // if not, just stick a <head> tag at the beginning
    $text = '<head>' . $ufo . $stylesheetshtml . '</head>' . "\n" . $text;
    return $text;
}
예제 #12
0
 function is_enabled()
 {
     return filter_is_enabled($this->plugin);
 }
예제 #13
0
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * This script displays tex source code, it is used also from the algebra filter.
 *
 * @package    filter
 * @subpackage tex
 * @copyright  2004 Zbigniew Fiedorowicz fiedorow@math.ohio-state.edu
 *             Originally based on code provided by Bruno Vernier bruno@vsbeducation.ca
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
define('NO_MOODLE_COOKIES', true);
// Because it interferes with caching
require '../../config.php';
if (!filter_is_enabled('filter/tex') and !filter_is_enabled('filter/algebra')) {
    print_error('filternotenabled');
}
$texexp = optional_param('texexp', '', PARAM_RAW);
$title = get_string('source', 'filter_tex');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title><?php 
echo $title;
?>
</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  </head>
  <body>