当前位置: 首页>>代码示例>>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;未经允许,请勿转载。