當前位置: 首頁>>代碼示例>>PHP>>正文


PHP XMLParser::CreateInputArray方法代碼示例

本文整理匯總了PHP中XMLParser::CreateInputArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP XMLParser::CreateInputArray方法的具體用法?PHP XMLParser::CreateInputArray怎麽用?PHP XMLParser::CreateInputArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在XMLParser的用法示例。


在下文中一共展示了XMLParser::CreateInputArray方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: RenderWikiPlot

/**
*RenderWikiPlot CallBack function
*
*This is the function that handles MediaWiki callbacks, and renders the actual plot.
*
*@access private
*@param string $input The content of the wikiplot tag
*@param array $argv Hash-array of the parameters of the wikiplot tag, with parameter-name as key and parameter-value as value.
*@param Parser $parser The parser of MediaWiki, if null parser is obtained from global variable
*@uses WikiPlotDeserializeBoolean()
*@uses WikiPlotDeserializeString()
*@uses WikiPlotDeserializeMixed()
*@uses WikiPlotDeserializeInteger()
*@uses WikiPlotDeserializeColor()
*@uses XMLParser
*@uses Plot
*@uses Graph
*@uses Cache
*@return string HTML that can be directly inserted into any website.
*/
function RenderWikiPlot($input, $argv, $parser = null)
{
    //Get parser if not given as parameter
    if (!$parser) {
        $parser =& $GLOBALS['wgParser'];
    }
    /*Currently the parser*/
    //Creating instance of plot
    $Plot = new Plot();
    //Getting and deserializing parameters
    WikiPlotDeserializeBoolean($argv["grid"], $Plot->EnableGrid);
    WikiPlotDeserializeBoolean($argv["axis"], $Plot->EnableAxis);
    WikiPlotDeserializeString($argv["caption"], $Plot->Caption);
    WikiPlotDeserializeMixed($argv["xspan"], $Plot->MinX, $Plot->MaxX);
    WikiPlotDeserializeMixed($argv["yspan"], $Plot->MinY, $Plot->MaxY);
    WikiPlotDeserializeMixed($argv["gridspace"], $Plot->XGridSpace, $Plot->YGridSpace);
    WikiPlotDeserializeInteger($argv["height"], $Plot->Height);
    WikiPlotDeserializeInteger($argv["width"], $Plot->Width);
    WikiPlotDeserializeInteger($argv["captionfont"], $Plot->CaptionFont);
    WikiPlotDeserializeInteger($argv["gridfont"], $Plot->GridFont);
    WikiPlotDeserializeColor($argv["gridcolor"], $Plot->GridColor);
    //Parsing Xml
    $XmlParser = new XMLParser($input);
    $Graphs = $XmlParser->CreateInputArray();
    foreach ($Graphs as $Graph) {
        $G = new Graph();
        if (!is_array($Graph[1])) {
            $G->Exp = $Graph[1];
            WikiPlotDeserializeString($Graph[0]["label"], $G->Label);
            WikiPlotDeserializeColor($Graph[0]["color"], $G->Color);
        } else {
            $G->Exp = $Graph[0];
        }
        array_push($Plot->Graphs, $G);
    }
    //Render the plot
    //Get instance of cache
    $cache = new cache();
    //Url of the current plot
    $PlotURL = "";
    $PlotFileName = $Plot->GetHash() . ".png";
    if (!$cache->FileExist($PlotFileName)) {
        $Plot->SaveAs($cache->CachePath($PlotFileName));
    } else {
        $PlotURL = $cache->FileURL($PlotFileName);
    }
    $output = "<a href='{$PlotURL}' class='image' title='See the plot'><img src='{$PlotURL}'></a>";
    return $output;
}
開發者ID:mediawiki-extensions,項目名稱:wikiplot,代碼行數:69,代碼來源:WikiPlot.php


注:本文中的XMLParser::CreateInputArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。