コード例 #1
0
 /**
  * Parse the xml into its components according to spec. 
  * This first version is a little primitive. 
  *
  * @param string $xml
  */
 private function parse($xml)
 {
     $xml = xml_2_object($xml);
     // sanity check
     if (isset($xml->name) && strcasecmp($xml->name, "methodCall") != 0) {
         throw new CallException(elgg_echo('CallException:NotRPCCall'));
     }
     // method name
     $this->methodname = $xml->children[0]->content;
     // parameters
     $this->params = $xml->children[1]->children;
 }
コード例 #2
0
/**
 * Import an ODD document.
 * 
 * @param string $xml The XML ODD.
 * @return ODDDocument
 */
function ODD_Import($xml)
{
    // Parse XML to an array
    $elements = xml_2_object($xml);
    // Sanity check 1, was this actually XML?
    if (!$elements || !$elements->children) {
        return false;
    }
    // Create ODDDocument
    $document = new ODDDocument();
    // Itterate through array of elements and construct ODD document
    $cnt = 0;
    foreach ($elements->children as $child) {
        $odd = ODD_factory($child);
        if ($odd) {
            $document->addElement($odd);
            $cnt++;
        }
    }
    // Check that we actually found something
    if ($cnt == 0) {
        return false;
    }
    return $document;
}
コード例 #3
0
ファイル: plugins.php プロジェクト: eokyere/elgg
/**
 * Load and parse a plugin manifest from a plugin XML file.
 * 
 * Example file:
 * 
 * <plugin_manifest>
 * 	<field key="author" value="Curverider Ltd" />
 *  <field key="version" value="1.0" />
 * 	<field key="description" value="My plugin description, keep it short" />
 *  <field key="website" value="http://www.elgg.org/" />
 *  <field key="copyright" value="(C) Curverider 2008-2009" />
 *  <field key="licence" value="GNU Public License version 2" />
 * </plugin_manifest>
 *
 * @param string $plugin Plugin name.
 * @return array of values
 */
function load_plugin_manifest($plugin)
{
    global $CONFIG;
    $xml = xml_2_object(file_get_contents($CONFIG->pluginspath . $plugin . "/manifest.xml"));
    if ($xml) {
        $elements = array();
        foreach ($xml->children as $element) {
            $key = $element->attributes['key'];
            $value = $element->attributes['value'];
            $elements[$key] = $value;
        }
        return $elements;
    }
    return false;
}