Example #1
0
//  any later version.
//
//  WIRIS Plugin is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with WIRIS Plugin. If not, see <http://www.gnu.org/licenses/>.
//
require_once 'bootstrap.php';
include 'libwiris.php';
$currentPath = dirname($_SERVER['PHP_SELF']) . '/';
if (isset($_POST['image'])) {
    $fileName = md5($_POST['image']);
    $config = wrs_loadConfig(WRS_CONFIG_FILE);
    $formulaPath = wrs_getFormulaDirectory($config) . '/' . $fileName . '.xml';
    if (isset($_POST['mml']) && !is_file($formulaPath)) {
        file_put_contents($formulaPath, $_POST['mml']);
    }
    $url = $currentPath . 'showcasimage.php?formula=' . $fileName . '.png';
    $imagePath = wrs_getCacheDirectory($config) . '/' . $fileName . '.png';
    if (!is_file($imagePath)) {
        if (file_put_contents($imagePath, base64_decode($_POST['image'])) !== false) {
            echo $url;
        } else {
            echo $currentPath . '../core/cas.gif';
        }
    } else {
        echo $url;
    }
Example #2
0
 private function math_image($mathml)
 {
     global $CFG;
     $config = wrs_loadConfig(WRS_CONFIG_FILE);
     include $CFG->dirroot . '/lib/editor/tinymce/version.php';
     //Moodle older than 2.4
     $integration_folder = "/lib/editor/tinymce/tiny_mce/" . $plugin->release . "/plugins/tiny_mce_wiris/integration";
     if (!file_exists($CFG->dirroot . $integration_folder)) {
         $integration_folder = "/lib/editor/tinymce/plugins/tiny_mce_wiris/integration";
     }
     $integration_url = $CFG->wwwroot . $integration_folder;
     $src = $this->mathml2img($mathml, $integration_url);
     $lang = substr(current_language(), 0, 2);
     $data = array('mml' => $mathml, 'lang' => $lang, 'src' => $src);
     $output = '<img align="middle" ';
     $output .= 'src="' . $src . '" ';
     if (isset($config['wirisaccessibilityenabled']) && $config['wirisaccessibilityenabled']) {
         $accessible = $this->mathml2accessible($data, $config);
         $output .= 'alt="' . $accessible . '" ';
     }
     $output .= ' />';
     return $output;
 }