示例#1
0
 protected function GetAdminModulesList()
 {
     if ($this->_adminModulesList == null) {
         $this->_adminModulesList = array();
         // Nodes
         $rowNode = "group/module";
         $colNode = array();
         $colNode["group"] = "../@name";
         $colNode["name"] = "@name";
         $colNode["icon"] = "icon";
         $colNode["url"] = "url";
         $colNode["command"] = "@command";
         // Read from Generic XML
         $xmlProcessor = new AdminModulesXmlFilenameProcessor();
         for ($i = 0; $i < 2; $i++) {
             if ($i == 0) {
                 $xmlProcessor->setFilenameLocation(ForceFilenameLocation::SharedPath);
             } else {
                 $xmlProcessor->setFilenameLocation(ForceFilenameLocation::PrivatePath);
             }
             $configFile = $xmlProcessor->FullQualifiedNameAndPath();
             if (FileUtil::Exists($configFile)) {
                 $config = FileUtil::QuickFileRead($configFile);
                 $dataset = new XmlDataset($config, $rowNode, $colNode);
                 foreach ($dataset->getIterator() as $sr) {
                     if (array_key_exists($sr->getField("group"), $this->_adminModulesList) || $i == 0) {
                         if ($sr->getField("command") != "@hidegroup") {
                             $this->_adminModulesList[$sr->getField("group")][$sr->getField("name")] = array($sr->getField("icon"), $sr->getField("url"));
                         } else {
                             unset($this->_adminModulesList[$sr->getField("group")]);
                         }
                     } else {
                         $x = array();
                         $x[$sr->getField("group")][$sr->getField("name")] = array($sr->getField("icon"), $sr->getField("url"));
                         $this->_adminModulesList = $x + $this->_adminModulesList;
                     }
                 }
             }
         }
     }
     return $this->_adminModulesList;
 }
示例#2
0
    function test_atomXml()
    {
        $xml = '<feed xmlns="http://www.w3.org/2005/Atom" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:gContact="http://schemas.google.com/contact/2008" xmlns:gd="http://schemas.google.com/g/2005" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">
			<id>myId</id>
			<updated>2014-09-15T19:35:55.795Z</updated>
			<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact"/>
			<title type="text">Title</title>
			<link rel="alternate" type="text/html" href="https://www.google.com/"/>
			<link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/my%40gmail.com/full"/>
			<link rel="http://schemas.google.com/g/2005#post" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/my%40gmail.com/full"/>
			<link rel="http://schemas.google.com/g/2005#batch" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/my%40gmail.com/full/batch"/>
			<link rel="self" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/my%40gmail.com/full?max-results=20"/>
			<link rel="next" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/my%40gmail.com/full?max-results=20&amp;start-index=21"/>
			<author>
			 <name>My Name</name>
			 <email>My Email</email>
			</author>
			<generator version="1.0" uri="http://www.google.com/m8/feeds">Contacts</generator>
			<openSearch:totalResults>2107</openSearch:totalResults>
			<openSearch:startIndex>1</openSearch:startIndex>
			<openSearch:itemsPerPage>20</openSearch:itemsPerPage>
			<entry>
			 <id>http://www.google.com/m8/feeds/contacts/my%40gmail.com/base/0</id>
			 <updated>2013-10-05T22:16:03.564Z</updated>
			 <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact"/>
			 <title type="text">Person 1</title>
			 <link rel="http://schemas.google.com/contacts/2008/rel#edit-photo" type="image/*" href="https://www.google.com/m8/feeds/photos/media/my%40gmail.com/1/ABCDE"/>
			 <link rel="http://schemas.google.com/contacts/2008/rel#photo" type="image/*" href="https://www.google.com/m8/feeds/photos/media/my%40gmail.com/1"/>
			 <link rel="self" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/my%40gmail.com/full/0"/>
			 <link rel="edit" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/my%40gmail.com/full/0/1234"/>
			 <gd:email rel="http://schemas.google.com/g/2005#other" address="*****@*****.**" primary="true"/>
			</entry>
			<entry>
			 <id>http://www.google.com/m8/feeds/contacts/my%40gmail.com/base/1</id>
			 <updated>2012-07-12T17:19:17.546Z</updated>
			 <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact"/>
			 <title type="text">Person 2</title>
			 <link rel="http://schemas.google.com/contacts/2008/rel#edit-photo" type="image/*" href="https://www.google.com/m8/feeds/photos/media/my%40gmail.com/1/EDFGH"/>
			 <link rel="http://schemas.google.com/contacts/2008/rel#photo" type="image/*" href="https://www.google.com/m8/feeds/photos/media/my%40gmail.com/1"/>
			 <link rel="self" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/my%40gmail.com/full/1"/>
			 <link rel="edit" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/my%40gmail.com/full/1/5678"/>
			 <gd:email rel="http://schemas.google.com/g/2005#other" address="*****@*****.**" primary="true"/>
			</entry></feed>';
        $namespace = array("fake" => "http://www.w3.org/2005/Atom", "gd" => "http://schemas.google.com/g/2005");
        $rootNode = 'fake:entry';
        $colNode = array("id" => "fake:id", "updated" => "fake:updated", "name" => "fake:title", "email" => "gd:email/@address");
        $xmlDataset = new XmlDataset($xml, $rootNode, $colNode, $namespace);
        $xmlIterator = $xmlDataset->getIterator();
        $this->assertTrue($xmlIterator instanceof IteratorInterface);
        $this->assertTrue($xmlIterator->hasNext());
        $this->assertEquals(2, $xmlIterator->Count());
        $row = $xmlIterator->moveNext();
        $this->assertEquals("http://www.google.com/m8/feeds/contacts/my%40gmail.com/base/0", $row->getField("id"));
        $this->assertEquals("2013-10-05T22:16:03.564Z", $row->getField("updated"));
        $this->assertEquals("Person 1", $row->getField("name"));
        $this->assertEquals("*****@*****.**", $row->getField("email"));
        $row = $xmlIterator->moveNext();
        $this->assertEquals("http://www.google.com/m8/feeds/contacts/my%40gmail.com/base/1", $row->getField("id"));
        $this->assertEquals("2012-07-12T17:19:17.546Z", $row->getField("updated"));
        $this->assertEquals("Person 2", $row->getField("name"));
        $this->assertEquals("*****@*****.**", $row->getField("email"));
    }
示例#3
0
文件: Sample.php 项目: byjg/xmlnuke
 protected function Opcao7()
 {
     $block = new XmlBlockCollection("Exemplo 7: XmlDataset", BlockPosition::Center);
     //XmlnukeBreakLine br = new XmlnukeBreakLine();
     $para1 = new XmlParagraphCollection();
     $xmlstr = $this->_context->get("xmlstr");
     $rowNode = $this->_context->get("rownode");
     $colNodeStr = preg_split("/\n/", $this->_context->get("cols"));
     if ($xmlstr != "") {
         $colNode = array();
         foreach ($colNodeStr as $key => $value) {
             $tmp = explode("=", $value);
             $colNode[$tmp[0]] = str_replace("\r", "", $tmp[1]);
         }
         $dataset = new XmlDataset($xmlstr, $rowNode, $colNode);
         //$para1->addXmlnukeObject(new XmlnukeText(""));
         $editlist = new XmlEditList($this->_context, "XML Flat", $this->_url . "?op=7");
         $editlist->setReadOnly(true);
         $editlist->setDataSource($dataset->getIterator());
         $para1->addXmlnukeObject($editlist);
     } else {
         $processor = new AnydatasetFilenameProcessor("sample");
         $xmlstr = FileUtil::QuickFileRead($processor->PathSuggested() . "sample.xml");
         $rowNode = "book";
         $colNodeStr = array();
         $colNodeStr[] = "category=@category";
         $colNodeStr[] = "title=title";
         $colNodeStr[] = "titlelang=title/@lang";
         $colNodeStr[] = "year=year";
         $colNodeStr[] = "price=price";
         $colNodeStr[] = "author=author";
     }
     // Cria um Formulário
     $form = new XmlFormCollection($this->_context, $this->_url, "Formulário de Edição");
     $form->addXmlnukeObject(new XmlInputHidden("op", "7"));
     $memo = new XmlInputMemo("XML", "xmlstr", $xmlstr);
     $form->addXmlnukeObject($memo);
     $text = new XmlInputTextBox("Row XPath", "rownode", $rowNode);
     $text->setRequired(true);
     $form->addXmlnukeObject($text);
     $colMemo = new XmlInputMemo("Col XPath", "cols", join("\n", $colNodeStr));
     $form->addXmlnukeObject($colMemo);
     $buttons = new XmlInputButtons();
     $buttons->addSubmit("Submit", "bs");
     $form->addXmlnukeObject($buttons);
     $block->addXmlnukeObject($para1);
     $block->addXmlnukeObject($form);
     $this->_document->addXmlnukeObject($block);
 }