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


PHP Image::newFromName方法代码示例

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


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

示例1: WidgetWikiaPartners

function WidgetWikiaPartners($id, $params)
{
    global $wgWikiaPartners;
    if (!isset($wgWikiaPartners)) {
        return '';
    }
    wfProfileIn(__METHOD__);
    $output = "\n<table style='margin: 0 auto; border: 0; background: none'><tr>\n";
    for ($i = 0; $i < count($wgWikiaPartners); $i += 3) {
        $wgWikiaPartners[$i] = htmlspecialchars($wgWikiaPartners[$i]);
        $wgWikiaPartners[$i + 1] = htmlspecialchars($wgWikiaPartners[$i + 1]);
        if ($i != 0 && $i % 6 == 0) {
            $output .= "</tr>\n<tr>\n";
        }
        $output .= "<td><a href='" . $wgWikiaPartners[$i + 1] . "' title='" . $wgWikiaPartners[$i] . "'>\n";
        if ($wgWikiaPartners[$i + 2] != 'text') {
            $img = Image::newFromName($wgWikiaPartners[$i + 2]);
            if (is_object($img)) {
                $thumb = $img->createThumb(75, -1);
                $output .= "<img src='{$thumb}' alt='" . $wgWikiaPartners[$i] . "' />\n";
            } else {
                $output .= $wgWikiaPartners[$i];
            }
        } else {
            $output .= $wgWikiaPartners[$i];
        }
        $output .= "</a></td>\n";
    }
    $output .= "</tr></table>\n";
    wfProfileOut(__METHOD__);
    return $output;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:32,代码来源:WidgetWikiaPartners.php

示例2: renderMp3

function renderMp3($input)
{
    global $wgScriptPath, $wgUploadPath;
    //$input = "filename.mp3"
    $arr = explode('|', trim($input));
    $addDLlink = isset($arr[1]) && $arr[1] == 'download';
    $input = $arr[0];
    $img = Image::newFromName($input);
    $mp3 = '';
    $bgcolor = 'FFF8DC';
    //You can change it, of course :-)
    //The parameters for object and embed
    # File uploaded or external link ?
    if (!$img->exists()) {
        //Must be http://... URL
        if (substr($input, 0, 7) == 'http://') {
            $mp3 = $input;
        }
    } else {
        $mp3 = $img->getURL();
    }
    if ($mp3 == '') {
        return '<div class="noprint">Fichier manquant : ' . $input . '<br />' . 'Missing ressource: ' . $input . '</div>';
    }
    unset($img);
    $output = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ' . 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" ' . 'width="200" height="20" id="dewplayer" align="middle">' . '<param name="allowScriptAccess" value="sameDomain" />' . '<param name="movie" value="' . $wgScriptPath . '/extensions/dewplayer.swf?son=' . $mp3 . '&amp;bgcolor=' . $bgcolor . '" />' . '<param name="quality" value="high" />' . '<param name="bgcolor" value="FFF8DC" />' . '<embed src="' . $wgScriptPath . '/extensions/dewplayer.swf?son=' . $mp3 . '&amp;bgcolor=' . $bgcolor . '" quality="high" bgcolor="FFF8DC" width="200" height="20" ' . 'name="dewplayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" ' . 'pluginspage="http://www.macromedia.com/go/getflashplayer">' . '</embed>' . '</object>';
    if ($addDLlink) {
        $output .= '<a href="' . $mp3 . '" title="Download">' . '<img src="' . $wgUploadPath . '/download.gif" alt="Download" />' . '</a>';
    }
    return $output;
}
开发者ID:hoonio,项目名称:mediawiki,代码行数:31,代码来源:mp3.php

示例3: imageLink

 /**
  * Outputs the internal image wrapped in a link
  * @param Parser $parser Instance of running Parser.
  * @param String $image Name of image to display.
  * @param String $url External URL to which to link
  * @param String $alt Alternate text for image and link (optional)
  * @return String A parser strip flag which will be later replaced with raw html.
  */
 function imageLink($parser, $image = null, $url = null, $alt = '')
 {
     # Short-circuit if requried params are missing
     if ($image === null || $url === null) {
         return $this->error('missing-params');
     }
     # Prepare incomming params
     $image = trim($image);
     $url = trim($url);
     $alt = trim($alt);
     # Check for bad URLs
     if (!preg_match('/^(' . wfUrlProtocols() . ')/', $url) || preg_match('/\'"/', $url)) {
         $t = Title::newFromText($url);
         if (!$t) {
             return $this->error('bad-url', $url);
         }
         $url = $t->getFullURL();
     }
     # Check to see that the selected image exists
     $imageObj = Image::newFromName($image);
     if (!$imageObj->exists()) {
         return $this->error('no-such-image', $image);
     }
     # Finally, since all checks passed, display it!
     return $parser->insertStripItem($this->msg('embed-clause', htmlentities($url, ENT_COMPAT), $imageObj->getURL(), htmlentities($alt, ENT_COMPAT)), $parser->mStripState);
 }
开发者ID:mediawiki-extensions,项目名称:mahalo-parserfunctions,代码行数:34,代码来源:mhoImageLink.php

示例4: jsxgraph_filter

function jsxgraph_filter($courseid, $text)
{
    global $CFG;
    // to optimize speed, search for a jsxgraph-tag (avoiding to parse everything on every text)
    if (is_int(strpos($text, '<jsxgraph'))) {
        $jsxgraph_version = '0.1';
        // get every construction
        $count = substr_count($text, '<jsxgraph');
        for ($i = 0; $i < $count; $i++) {
            $start = strpos($text, '<jsxgraph');
            $end = is_int(strpos($text, '</jsxgraph>', $start)) ? strpos($text, '</jsxgraph>', $start) + 11 : strpos($text, '/>', $start) + 2;
            $jxg = substr($text, $start + 10, $end - $start - 21);
            // parse parameters of construction
            $input = split(">", $jxg);
            // fix for javascript construction input
            $input[0] = str_replace("'", '', $input[0]);
            $input[0] = str_replace('"', '', $input[0]);
            $input[0] = str_replace(' ', '&', $input[0]);
            parse_str($input[0], $params);
            $outputDivId = isset($params['box']) ? htmlspecialchars(strip_tags($params['box'])) : 'box' . $i;
            $outputBoardId = isset($params['board']) ? htmlspecialchars(strip_tags($params['board'])) : 'board' . $i;
            $width = isset($params['width']) ? htmlspecialchars(strip_tags($params['width'])) : 500;
            $height = isset($params['height']) ? htmlspecialchars(strip_tags($params['height'])) : 400;
            // Load necessary stylesheet und scripts
            echo $PAGE->requires->js('filter/jsxgraph/jsxgraphcore.js')->asap();
            echo $PAGE->requires->css('filter/jsxgraph/jsxgraph.css')->asap();
            // output div
            $output = "<div id='" . $outputDivId . "' class='jxgbox' style='width:" . $width . "px; height:" . $height . "px;'></div>";
            $output .= "<script type='text/javascript'>";
            // construction by filename
            if (isset($params['filename'])) {
                $gxtBinary = htmlspecialchars(strip_tags($params['filename']));
                $gxtFile = Image::newFromName($gxtBinary);
                if (!$gxtFile->exists()) {
                    $error_message = "File " . $gxtFile . " not found.";
                } else {
                    $gxtURL = $CFG->wwwroot . $gxtFile->getURL();
                }
                $output .= "  var " . $outputBoardId . " = JXG.JSXGraph.loadBoardFromFile('" . $outputDivId . "', '" . $gxtURL . "', 'Geonext');";
            } else {
                if (isset($params['filestring'])) {
                    $tmp = split("filestring=", $text);
                    $tmp[1] = str_replace("'", '"', $tmp[1]);
                    $tmp = split('"', $tmp[1]);
                    $filestring = htmlspecialchars(strip_tags($tmp[1]));
                    $output .= "  var " . $outputBoardId . " = JXG.JSXGraph.loadBoardFromString('" . $outputDivId . "', '" . $filestring . "', 'Geonext');";
                } else {
                    for ($i = 1; $i <= sizeof($input); $i++) {
                        $i == 1 || $i == sizeof($input) ? $output .= $input[$i] : ($output .= ">" . $input[$i]);
                    }
                }
            }
            $output .= "</script>";
            $text = substr_replace($text, $output, $start, $end - $start);
        }
    }
    return $text;
}
开发者ID:stepheneb,项目名称:jsxgraph,代码行数:58,代码来源:filter.php

示例5: imageURL

function imageURL(&$parser, $name = '')
{
    $imageObj = Image::newFromName($name);
    if (!$imageObj || !$imageObj->exists()) {
        return wfMsg('respawn:noexist', $name);
    } else {
        return $imageObj->getViewURL();
    }
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:9,代码来源:RespawnMap.php

示例6: wfMsLinksRender

function wfMsLinksRender(&$parser, $typ = '', $url = '', $beschreibung = '', $align = '')
{
    global $wgOut, $wgScriptPath, $wgFileTypes;
    if (empty($typ)) {
        return 'kein typ angegeben';
    }
    $base = "Media";
    $version = "";
    if ($typ != "dlink") {
        if ($typ != "vlink") {
            #wenn weder d noch v link, dann eins weiterschieben
            $align = $beschreibung;
            $beschreibung = $url;
            $url = $typ;
        }
        $img = Image::newFromName($url);
        if ($img && $img->exists()) {
            #datei existiert
            $base = ":Image";
        }
    }
    //if
    $img = Image::newFromName($url);
    if ($img && $img->exists()) {
        #datei existiert
        $base = ":Image";
    }
    $extension = strtolower(substr(strrchr($url, "."), 1));
    if ($beschreibung == "") {
        #$beschreibung = $file_info['filename'];
        $beschreibung = substr($url, 0, strlen($url) - (strlen($extension) + 1));
        // damit umlaute auch angezeigt werden
    }
    $html = "[[{$base}:{$url}|{$beschreibung}]]";
    $bild = "<img src='{$wgScriptPath}/extensions/MsLinks/images/" . $wgFileTypes['no'] . "'>";
    if (isset($wgFileTypes)) {
        foreach ($wgFileTypes as $key => $value) {
            if ($key == $extension) {
                $bild = "<img title='{$extension}' src='{$wgScriptPath}/extensions/MsLinks/images/{$value}'>";
            }
        }
    }
    //if
    $bild = $parser->insertStripItem($bild, $parser->mStripState);
    if ($typ != "vlink" && $typ != "dlink") {
        $base = "Media";
    }
    $bild = "[[{$base}:{$url}|" . $bild . "]]";
    if ($align == "right") {
        $html = $html . " " . $bild . " " . $version;
    } else {
        #standardausrichtung
        $html = $bild . " " . $html . " " . $version;
    }
    return $html;
}
开发者ID:Ratin,项目名称:Taken,代码行数:56,代码来源:mslinks_body.php

示例7: jsxgraph_filter

function jsxgraph_filter($text)
{
    if (is_int(strpos($text, '<jsxgraph'))) {
        // get every construction
        $count = substr_count($text, '<jsxgraph');
        for ($i = 0; $i < $count; $i++) {
            $start = strpos($text, '<jsxgraph');
            $end = is_int(strpos($text, '</jsxgraph>', $start)) ? strpos($text, '</jsxgraph>', $start) + 11 : strpos($text, '/>', $start) + 2;
            $jxg = substr($text, $start + 10, $end - $start - 21);
            // parse parameters of construction
            $input = split(">", $jxg);
            // fix for javascript construction input
            $input[0] = str_replace("'", '', $input[0]);
            $input[0] = str_replace('"', '', $input[0]);
            $input[0] = str_replace(' ', '&', $input[0]);
            parse_str($input[0], $params);
            $outputDivId = isset($params['box']) ? htmlspecialchars(strip_tags($params['box'])) : 'box' . $i;
            $outputBoardId = isset($params['board']) ? htmlspecialchars(strip_tags($params['board'])) : 'board' . $i;
            $width = isset($params['width']) ? htmlspecialchars(strip_tags($params['width'])) : 500;
            $height = isset($params['height']) ? htmlspecialchars(strip_tags($params['height'])) : 400;
            // output div
            $output = "<div id='" . $outputDivId . "' class='jxgbox' style='width:" . $width . "px; height:" . $height . "px;'></div>";
            $output .= "<script type='text/javascript'>";
            // construction by filename
            if (isset($params['filename'])) {
                $gxtBinary = htmlspecialchars(strip_tags($params['filename']));
                $gxtFile = Image::newFromName($gxtBinary);
                if (!$gxtFile->exists()) {
                    $error_message = "File " . $gxtFile . " not found.";
                } else {
                    $gxtURL = get_bloginfo('wpurl') . $gxtFile->getURL();
                }
                $output .= "  var " . $outputBoardId . " = JXG.JSXGraph.loadBoardFromFile('" . $outputDivId . "', '" . $gxtURL . "', 'Geonext');";
            } else {
                if (isset($params['filestring'])) {
                    $tmp = split("filestring=", $text);
                    $tmp[1] = str_replace("'", '"', $tmp[1]);
                    $tmp = split('"', $tmp[1]);
                    $filestring = htmlspecialchars(strip_tags($tmp[1]));
                    $output .= "  var " . $outputBoardId . " = JXG.JSXGraph.loadBoardFromString('" . $outputDivId . "', '" . $filestring . "', 'Geonext');";
                } else {
                    for ($j = 1; $j <= sizeof($input); $j++) {
                        $j == 1 || $j == sizeof($input) ? $output .= $input[$j] : ($output .= ">" . $input[$j]);
                    }
                }
            }
            $output .= "</script>";
            $text = substr_replace($text, $output, $start, $end - $start);
        }
    }
    return $text;
}
开发者ID:stepheneb,项目名称:jsxgraph,代码行数:52,代码来源:JSXGraph.php

示例8: execute

 function execute($par)
 {
     global $wgOut, $wgRequest;
     global $wgCopyimagesBaseURL, $wgServer;
     wfLoadExtensionMessages('Copyimages');
     $this->setHeaders();
     $target = isset($par) ? $par : $wgRequest->getVal('target');
     $t = Title::newFromText($target);
     if (!$t) {
         $wgOut->addHTML(wfMsg('copyimages_noarticle'));
         return;
     }
     $id = $t->getArticleID();
     if ($wgRequest->wasPosted()) {
         $dbr = wfGetDB(DB_MASTER);
         $res = $dbr->query("select il_to from imagelinks left join page on il_to = page_title where il_from={$id} and page_id is NULL;");
         $images = array();
         while ($row = $dbr->fetchObject($res)) {
             $images[] = $row->il_to;
         }
         foreach ($images as $image) {
             $up = new UploadForm($wgRequest);
             $up->mSourceType = 'web';
         }
         return;
     }
     $dbr = wfGetDB(DB_MASTER);
     $res = $dbr->query("select il_to from imagelinks left join page on il_to = page_title where il_from={$id} and page_id is NULL;");
     $images = array();
     while ($row = $dbr->fetchObject($res)) {
         $images[] = $row->il_to;
     }
     if (sizeof($images) == 0) {
         $wgOut->addHTML(wfMsg('copyimages_nobrokenimages'));
         return;
     }
     $wgOut->addHTML(wfMsg('copyimages_brokenimages'));
     $wgOut->addHTML("<p><form id='copyimages' method='POST'><ul>");
     foreach ($images as $image) {
         $i = Image::newFromName($image);
         $target_url = $wgCopyimagesBaseURL . Image::imageUrl($i->name, $i->fromSharedDirectory);
         $desc = file_get_contents($wgCopyimagesBaseURL . "/index.php?title=Image:{$image}&action=raw");
         $desc = str_replace("\n", " ", $desc);
         $up = Title::makeTitle(NS_SPECIAL, "Upload");
         $url = $up->getFullURL() . "?desturl=" . urlencode($target_url) . "&desc=" . urlencode($desc) . "&destname=" . urlencode($image);
         $wgOut->addHTML("<li><a onclick=\"javascript:window.open('{$url}', 'upload', 'scrollbars=1,status=0,toolbar=0,location=0,menubar=0, height=500,width=800');\">{$image}</a></li>\n");
     }
     $wgOut->addHTML("</ul><br/><br/></p>");
     $dbr->freeResult($res);
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:50,代码来源:Copyimages.body.php

示例9: launchExternal

function launchExternal($input, $params = array())
{
    global $wgServer;
    global $wgAddServerName_EXT;
    $arrInput = split("::", $input);
    // use a different display then the file reference...
    $reference = $input;
    $display = "";
    $server = "";
    if (count($arrInput) > 1) {
        $reference = $arrInput[0];
        $display = $arrInput[1];
    }
    $reference = str_replace('\\', '/', $reference);
    $reference = str_replace('////', '//', $reference);
    //fix just incase we have "file://\\server"
    if (strpos($reference, "://") !== false) {
        $section1 = explode("/", $reference);
        $section2 = explode(".", $section1[2]);
        //parse the dots (sub-domains)
        if ($wgAddServerName_EXT && strpos($reference, "file://") !== false) {
            $server = " <i>({$section2['0']})</i>";
        }
        if ($display == "") {
            $display = $section1[count($section1) - 1];
        }
        //default the file name
        return "<a href='" . $reference . "' target='new'>" . ($display == "" ? $reference : $display) . "{$server}</a>";
    }
    // wiki uploaded media or image reference
    $img = Image::newFromName($reference);
    if ($img->exists()) {
        return buildLink($wgServer . $img->getURL(), $display == "" ? $reference : $display);
    }
    return $input . " <i>(bad reference)</i>";
}
开发者ID:mediawiki-extensions,项目名称:mw-toolbox,代码行数:36,代码来源:launchExternal.php

示例10: loadFromFile

 /** 
  * Load metadata from the file itself
  */
 function loadFromFile()
 {
     global $wgUseSharedUploads, $wgSharedUploadDirectory, $wgLang, $wgShowEXIF;
     $fname = 'Image::loadFromFile';
     wfProfileIn($fname);
     $this->imagePath = $this->getFullPath();
     $this->fileExists = file_exists($this->imagePath);
     $this->fromSharedDirectory = false;
     $gis = array();
     if (!$this->fileExists) {
         wfDebug("{$fname}: " . $this->imagePath . " not found locally!\n");
     }
     # If the file is not found, and a shared upload directory is used, look for it there.
     if (!$this->fileExists && $wgUseSharedUploads && $wgSharedUploadDirectory) {
         # In case we're on a wgCapitalLinks=false wiki, we
         # capitalize the first letter of the filename before
         # looking it up in the shared repository.
         $sharedImage = Image::newFromName($wgLang->ucfirst($this->name));
         $this->fileExists = file_exists($sharedImage->getFullPath(true));
         if ($this->fileExists) {
             $this->name = $sharedImage->name;
             $this->imagePath = $this->getFullPath(true);
             $this->fromSharedDirectory = true;
         }
     }
     if ($this->fileExists) {
         $magic =& wfGetMimeMagic();
         $this->mime = $magic->guessMimeType($this->imagePath, true);
         $this->type = $magic->getMediaType($this->imagePath, $this->mime);
         # Get size in bytes
         $this->size = filesize($this->imagePath);
         $magic =& wfGetMimeMagic();
         # Height and width
         if ($this->mime == 'image/svg') {
             wfSuppressWarnings();
             $gis = wfGetSVGsize($this->imagePath);
             wfRestoreWarnings();
         } elseif (!$magic->isPHPImageType($this->mime)) {
             # Don't try to get the width and height of sound and video files, that's bad for performance
             $gis[0] = 0;
             //width
             $gis[1] = 0;
             //height
             $gis[2] = 0;
             //unknown
             $gis[3] = "";
             //width height string
         } else {
             wfSuppressWarnings();
             $gis = getimagesize($this->imagePath);
             wfRestoreWarnings();
         }
         wfDebug("{$fname}: " . $this->imagePath . " loaded, " . $this->size . " bytes, " . $this->mime . ".\n");
     } else {
         $gis[0] = 0;
         //width
         $gis[1] = 0;
         //height
         $gis[2] = 0;
         //unknown
         $gis[3] = "";
         //width height string
         $this->mime = NULL;
         $this->type = MEDIATYPE_UNKNOWN;
         wfDebug("{$fname}: " . $this->imagePath . " NOT FOUND!\n");
     }
     $this->width = $gis[0];
     $this->height = $gis[1];
     #NOTE: $gis[2] contains a code for the image type. This is no longer used.
     #NOTE: we have to set this flag early to avoid load() to be called
     # be some of the functions below. This may lead to recursion or other bad things!
     # as ther's only one thread of execution, this should be safe anyway.
     $this->dataLoaded = true;
     if ($this->fileExists && $wgShowEXIF) {
         $this->metadata = serialize($this->retrieveExifData());
     } else {
         $this->metadata = serialize(array());
     }
     if (isset($gis['bits'])) {
         $this->bits = $gis['bits'];
     } else {
         $this->bits = 0;
     }
     wfProfileOut($fname);
 }
开发者ID:BackupTheBerlios,项目名称:openzaurus-svn,代码行数:88,代码来源:Image.php

示例11: loadFromFile

 /**
  * Load metadata from the file itself
  */
 function loadFromFile()
 {
     global $wgUseSharedUploads, $wgSharedUploadDirectory, $wgContLang;
     wfProfileIn(__METHOD__);
     $this->imagePath = $this->getFullPath();
     $this->fileExists = file_exists($this->imagePath);
     $this->fromSharedDirectory = false;
     $gis = array();
     if (!$this->fileExists) {
         wfDebug(__METHOD__ . ': ' . $this->imagePath . " not found locally!\n");
     }
     # If the file is not found, and a shared upload directory is used, look for it there.
     if (!$this->fileExists && $wgUseSharedUploads && $wgSharedUploadDirectory) {
         # In case we're on a wgCapitalLinks=false wiki, we
         # capitalize the first letter of the filename before
         # looking it up in the shared repository.
         $sharedImage = Image::newFromName($wgContLang->ucfirst($this->name));
         $this->fileExists = $sharedImage && file_exists($sharedImage->getFullPath(true));
         if ($this->fileExists) {
             $this->name = $sharedImage->name;
             $this->imagePath = $this->getFullPath(true);
             $this->fromSharedDirectory = true;
         }
     }
     if ($this->fileExists) {
         $magic =& MimeMagic::singleton();
         $this->mime = $magic->guessMimeType($this->imagePath, true);
         $this->type = $magic->getMediaType($this->imagePath, $this->mime);
         $handler = MediaHandler::getHandler($this->mime);
         # Get size in bytes
         $this->size = filesize($this->imagePath);
         # Height, width and metadata
         if ($handler) {
             $gis = $handler->getImageSize($this, $this->imagePath);
             $this->metadata = $handler->getMetadata($this, $this->imagePath);
         } else {
             $gis = false;
             $this->metadata = '';
         }
         wfDebug(__METHOD__ . ': ' . $this->imagePath . " loaded, " . $this->size . " bytes, " . $this->mime . ".\n");
     } else {
         $this->mime = NULL;
         $this->type = MEDIATYPE_UNKNOWN;
         $this->metadata = '';
         wfDebug(__METHOD__ . ': ' . $this->imagePath . " NOT FOUND!\n");
     }
     if ($gis) {
         $this->width = $gis[0];
         $this->height = $gis[1];
     } else {
         $this->width = 0;
         $this->height = 0;
     }
     #NOTE: $gis[2] contains a code for the image type. This is no longer used.
     #NOTE: we have to set this flag early to avoid load() to be called
     # be some of the functions below. This may lead to recursion or other bad things!
     # as ther's only one thread of execution, this should be safe anyway.
     $this->dataLoaded = true;
     if (isset($gis['bits'])) {
         $this->bits = $gis['bits'];
     } else {
         $this->bits = 0;
     }
     wfProfileOut(__METHOD__);
 }
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:68,代码来源:Image.php

示例12: jsxgraphOutput

function jsxgraphOutput($input, $args, $parser)
{
    global $wgServer;
    // URL of the WIKI's server
    global $jsxgraph_version;
    // see line 9 of this file
    global $markerList;
    global $outputURI;
    $error_message = "no error";
    //will be overwritten, if error occurs
    $CRLF = "\r\n";
    // Look for required parameters
    if (!(isset($args['filename']) || isset($args['filestring']) || isset($input))) {
        $error_message = "Missing parameter (width or height, filename, string or input).";
    }
    $output = "<!-- JSXGraph MediaWiki extension " . $jsxgraph_version . " -->";
    $markercount = count($markerList);
    if ($markercount > 0) {
        $defaultBoard = "brd" . $markercount;
        $defaultBox = "jxgbox" . $markercount;
    } else {
        $defaultBoard = "brd";
        $defaultBox = "jxgbox";
    }
    $outputDivId = isset($args['box']) ? htmlspecialchars(strip_tags($args['box'])) : $defaultBox;
    $outputBoardId = isset($args['board']) ? htmlspecialchars(strip_tags($args['board'])) : $defaultBoard;
    $width = isset($args['width']) ? htmlspecialchars(strip_tags($args['width'])) : 500;
    $height = isset($args['height']) ? htmlspecialchars(strip_tags($args['height'])) : 400;
    // Load necessary stylesheet und scripts
    if ($markercount == 0) {
        $output .= "<link rel='stylesheet' type='text/css' href='" . $outputURI . "/jsxgraph.css' />";
        $output .= "<script src='" . $outputURI . "/jsxgraphcore.js' type='text/javascript'></script>";
    }
    // Output div
    $output .= "<div id='" . $outputDivId . "' class='jxgbox' style='width:" . $width . "px; height:" . $height . "px;'></div>";
    $output .= "<script type='text/javascript'>";
    // construction input method
    if (isset($args['filename'])) {
        // string of url to gxt-file
        // retrieve URL of .gxt file
        $gxtBinary = htmlspecialchars(strip_tags($args['filename']));
        $gxtFile = Image::newFromName($gxtBinary);
        if (!$gxtFile->exists()) {
            $error_message = "File " . $gxtFile . " not found.";
        } else {
            $gxtURL = $wgServer . $gxtFile->getURL();
        }
        $output .= "  var " . $outputBoardId . " = JXG.JSXGraph.loadBoardFromFile('" . $outputDivId . "', '" . $gxtURL . "', 'Geonext');";
    }
    if (isset($args['filestring'])) {
        // binary content of gxt-file
        $output .= "  var " . $outputBoardId . " = JXG.JSXGraph.loadBoardFromString('" . $outputDivId . "', '" . htmlspecialchars(strip_tags($args['filestring'])) . "', 'Geonext');";
    }
    if (isset($input)) {
        // content between <jsxgraph>-tags
        $output .= $input;
    }
    $output .= "</script>";
    // if error occured, discard and output error message
    if ($error_message != "no error") {
        $output = "<p>Error in MediaWiki extension (JSXGraph.php): <em>" . $error_message . "</em></p>" . $CRLF;
    }
    // Send the output to the browser
    $marker = "jsxgraph-marker" . $markercount . "-jsxgraph";
    $markerList[$markercount] = $output;
    return $marker;
}
开发者ID:stepheneb,项目名称:jsxgraph,代码行数:67,代码来源:JSXGraph.php

示例13: getImageURLreal

 /**
  * Really returns an URL for a given image page.
  */
 protected function getImageURLreal(&$img)
 {
     $ititle = Title::newFromText($img);
     // this really shouldn't happen... not much we can do here.
     if (!is_object($ititle)) {
         return self::codeInvalidTitleImage;
     }
     // check if we are dealing with an InterWiki link
     if ($ititle->isLocal()) {
         $image = Image::newFromName($img);
         if (!$image->exists()) {
             return self::codeImageNotExist;
         }
         $iURL = $image->getURL();
     } else {
         $iURL = $ititle->getFullURL();
     }
     return $iURL;
 }
开发者ID:clrh,项目名称:mediawiki,代码行数:22,代码来源:ImageLink.body.php

示例14: checkOverwrite

 /**
  * Check if there's an overwrite conflict and, if so, if restrictions
  * forbid this user from performing the upload.
  *
  * @return mixed true on success, WikiError on failure
  * @access private
  */
 function checkOverwrite($name)
 {
     $img = Image::newFromName($name);
     if (is_null($img)) {
         // Uh... this shouldn't happen ;)
         // But if it does, fall through to previous behavior
         return false;
     }
     $error = '';
     if ($img->exists()) {
         global $wgUser, $wgOut;
         if ($img->isLocal()) {
             if (!$wgUser->isAllowed('reupload')) {
                 $error = 'fileexists-forbidden';
             }
         } else {
             if (!$wgUser->isAllowed('reupload') || !$wgUser->isAllowed('reupload-shared')) {
                 $error = "fileexists-shared-forbidden";
             }
         }
     }
     if ($error) {
         $errorText = wfMsg($error, wfEscapeWikiText($img->getName()));
         return new WikiError($wgOut->parse($errorText));
     }
     // Rockin', go ahead and upload
     return true;
 }
开发者ID:k-hasan-19,项目名称:wiki,代码行数:35,代码来源:SpecialUpload.php

示例15: userCanOverwrite

 /** I BORROWED THIS FUNCTION FROM SpecialUpload.php!! CHECK FOR EACH VERSION OF MEDIAWIKI, IF
  *  THIS FUNCTION STILL MAKES SENSE!
  *
  * Check if there's an overwrite conflict and, if so, if restrictions
  * forbid this user from performing the upload.
  *
  * @return true on success, false on failure
  * @access private
  */
 function userCanOverwrite($name)
 {
     $img = Image::newFromName($name);
     if (is_null($img)) {
         // Uh... this shouldn't happen ;)
         // But if it does, fall through to previous behavior
         return false;
     }
     if ($img->exists()) {
         global $wgUser, $wgOut;
         if ($img->isLocal()) {
             if (!$wgUser->isAllowed('reupload')) {
                 return false;
             }
         } else {
             if (!$wgUser->isAllowed('reupload') || !$wgUser->isAllowed('reupload-shared')) {
                 return false;
             }
         }
     }
     // Rockin', go ahead and upload
     return true;
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:32,代码来源:AnyWikiDraw_body.php


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