public function testParse()
 {
     $file = __DIR__ . '/_files/xmlPhrasesForTest.xml';
     $this->xmlPhraseCollector->parse($file);
     $expectation = [['phrase' => 'Name only', 'file' => $file, 'line' => '', 'quote' => ''], ['phrase' => 'Name and title space delimiter', 'file' => $file, 'line' => '', 'quote' => ''], ['phrase' => 'title1', 'file' => $file, 'line' => '', 'quote' => ''], ['phrase' => 'title2', 'file' => $file, 'line' => '', 'quote' => ''], ['phrase' => 'Name only in sub node', 'file' => $file, 'line' => '', 'quote' => ''], ['phrase' => 'Text outside of attribute', 'file' => $file, 'line' => '', 'quote' => '']];
     $this->assertEquals($expectation, $this->xmlPhraseCollector->getPhrases());
 }
Exemplo n.º 2
0
function plugin_dst_xml_read()
{
    // Perform the repository lookup and xml creation --- start
    $localFile = 'plugins/dst/countries.xml';
    $result = array('body' => file_get_contents($localFile));
    unset($result['headers']);
    // we should take a look the header data and error messages before dropping them. Well, later maybe ;-)
    unset($result['error']);
    $result = array_shift($result);
    if (function_exists('simplexml_load_string')) {
        $xml = simplexml_load_string($result);
        unset($result);
        $dst_array = array();
        foreach ($xml as $file) {
            $dst_array[] = (array) $file;
        }
    } else {
        include_once 'include/lib.xml.php';
        $xml = new Xml();
        $dst_array = $xml->parse($result);
        $dst_array = array_shift($dst_array);
    }
    // Perform the repository lookup and xml creation --- end
    return $dst_array;
}
Exemplo n.º 3
0
 public static function xml_unserialize(&$xml, $isnormal = FALSE)
 {
     $xml_parser = new Xml($isnormal);
     $data = $xml_parser->parse($xml);
     $xml_parser->destruct();
     return $data;
 }
Exemplo n.º 4
0
 public function index()
 {
     $this->load->helper('directory');
     $map = directory_map(APPPATH . DS . 'modules', 1);
     // get all modules
     $module = array();
     if (count($map) > 0) {
         for ($i = 0; $i < count($map); $i++) {
             $file = APPPATH . DS . 'modules' . DS . $map[$i] . DS . $map[$i] . '.xml';
             if (file_exists($file)) {
                 $module[] = $map[$i];
             }
         }
     }
     // load modules info
     $this->load->library('xml');
     $xml = new Xml();
     $modules = array();
     $j = 0;
     for ($i = 0; $i < count($module); $i++) {
         $file = APPPATH . DS . 'modules' . DS . $module[$i] . DS . $module[$i] . '.xml';
         $data = $xml->parse($file);
         if (isset($data['name']) && $data['name'] != '' && isset($data['description']) && $data['description'] != '') {
             $modules[$j] = new stdclass();
             $modules[$j]->name = $module[$i];
             $modules[$j]->title = $data['name'];
             $modules[$j]->description = $data['description'];
             $modules[$j]->thumb = 'application/modules/' . $module[$i] . '/thumb.png';
             $j++;
         }
     }
     // get page layout
     $this->load->library('xml');
     $xml = new Xml();
     $file = APPPATH . DS . 'views' . DS . 'layouts' . DS . 'layouts.xml';
     $layouts = $xml->parse($file);
     $pages = array();
     if (count($layouts)) {
         $i = 0;
         //echo '<pre>'; print_r($layouts['group']); exit;
         foreach ($layouts['group'] as $group) {
             if (empty($group['@attributes']['description'])) {
                 continue;
             }
             $pages[$i] = new stdClass();
             $pages[$i]->name = $group['@attributes']['name'];
             $pages[$i]->description = $group['@attributes']['description'];
             if (empty($group['@attributes']['icon']) || $group['@attributes']['icon'] == '') {
                 $pages[$i]->icon = base_url('assets/images/system/home.png');
             } else {
                 $pages[$i]->icon = base_url('assets/images/system/' . $group['@attributes']['icon']);
             }
             $i++;
         }
     }
     $this->data['pages'] = $pages;
     $this->data['modules'] = $modules;
     $this->load->view('admin/module/index', $this->data);
 }
Exemplo n.º 5
0
 /**
  * parse() should return true if output if well-formed xml
  */
 public function test_parse_returnsTrue_ifOutputIsValidXml()
 {
     $xml = '<?xml version="1.0" encoding="UTF-8"?>' . '<foo>' . '<bar>' . 'baz' . '</bar>' . '<bar>' . 'qux' . '</bar>' . '</foo>';
     $data = ['bar' => ['baz', 'qux']];
     $response = new Xml();
     $this->assertTrue($response->parse($xml));
     $this->assertEquals($data, $response->getData());
     return;
 }
Exemplo n.º 6
0
 public function add($id = null)
 {
     $this->data['breadcrumb'] = lang('layout_add');
     $this->data['meta_title'] = lang('layout_add');
     $this->data['sub_title'] = 'Drag and drop to add element after click "save"';
     // get all layouts
     $this->load->library('xml');
     $xml = new Xml();
     $file = APPPATH . DS . 'views' . DS . 'layouts' . DS . 'layouts.xml';
     $layouts = $xml->parse($file);
     if (count($layouts)) {
         $arr = array();
         foreach ($layouts['group'] as $key => $group) {
             $arr[$group['@attributes']['name']] = array();
             if ($group['layout']) {
                 if (isset($group['layout'][0]) == true) {
                     foreach ($group['layout'] as $layout) {
                         $arr[$group['@attributes']['name']][$layout['name']] = array();
                         $arr[$group['@attributes']['name']][$layout['name']]['title'] = $layout['title'];
                         $arr[$group['@attributes']['name']][$layout['name']]['description'] = $layout['description'];
                     }
                 } else {
                     $arr[$group['@attributes']['name']][$group['layout']['name']] = array();
                     $arr[$group['@attributes']['name']][$group['layout']['name']]['title'] = $group['layout']['title'];
                     $arr[$group['@attributes']['name']][$group['layout']['name']]['description'] = $group['layout']['description'];
                 }
             }
         }
     }
     //echo '<pre>'; print_r($arr); exit;
     $this->data['layouts'] = $arr;
     // load data
     if ($id == null) {
         $layout = $this->layout_m->getNew();
     } else {
         $layout = $this->layout_m->get($id);
     }
     $this->data['page'] = $layout;
     $this->data['subview'] = 'admin/layout/add';
     $this->load->view('admin/_layout_main', $this->data);
 }
Exemplo n.º 7
0
function cpgVersioncheckConnectRepository()
{
    global $displayOption_array, $majorVersion;
    // Perform the repository lookup and xml creation --- start
    //$displayOption_array['do_not_connect_to_online_repository'] = 1;
    $remoteURL = 'http://coppermine-gallery.net/' . str_replace('.', '', $majorVersion) . '.files.xml';
    $localFile = 'include/' . str_replace('.', '', $majorVersion) . '.files.xml';
    $remoteConnectionFailed = '';
    if ($displayOption_array['do_not_connect_to_online_repository'] == 0) {
        // connect to the online repository --- start
        $result = cpgGetRemoteFileByURL($remoteURL, 'GET', '', '200');
        if (strlen($result['body']) < 2000) {
            $remoteConnectionFailed = 1;
            $error = $result['error'];
        }
    }
    // connect to the online repository --- end
    if ($displayOption_array['do_not_connect_to_online_repository'] == 1 || $remoteConnectionFailed == 1) {
        $result = array('body' => file_get_contents($localFile));
    }
    unset($result['headers']);
    // we should take a look the header data and error messages before dropping them. Well, later maybe ;-)
    unset($result['error']);
    $result = array_shift($result);
    if (function_exists('simplexml_load_string')) {
        $xml = simplexml_load_string($result);
        unset($result);
        $file_data_array = array();
        foreach ($xml as $file) {
            $file_data_array[] = (array) $file;
        }
    } else {
        include_once 'include/lib.xml.php';
        $xml = new Xml();
        $file_data_array = $xml->parse($result);
        $file_data_array = array_shift($file_data_array);
    }
    // Perform the repository lookup and xml creation --- end
    return $file_data_array;
}
Exemplo n.º 8
0
 /**
  * testNumericDataHandling method
  *
  * @access public
  * @return void
  */
 function testNumericDataHandling()
 {
     $data = '<xml><data>012345</data></xml>';
     $node = new Xml();
     $node->load($data);
     $node->parse();
     $result = $node->first();
     $result = $result->children("data");
     $result = $result[0]->first();
     $this->assertEqual($result->value, '012345');
 }
Exemplo n.º 9
0
 static function parseXML($xml)
 {
     $xml = com_wiris_util_xml_WXmlUtils::filterMathMLEntities($xml);
     $x = Xml::parse($xml);
     return $x;
 }
Exemplo n.º 10
0
 public function testParse()
 {
     $expected = ['Magento\\Module1', 'Magento\\Module2'];
     $actual = $this->parser->parse(['files_for_parse' => [$this->fixtureDir . 'module1.xml', $this->fixtureDir . 'module2.xml']]);
     $this->assertEquals($expected, $actual);
 }
Exemplo n.º 11
0
function cpgVersioncheckConnectRepository($displayOption_array = '')
{
    if ($displayOption_array = '') {
        global $displayOption_array;
    }
    // Perform the repository lookup and xml creation --- start
    //$displayOption_array['do_not_connect_to_online_repository'] = 1;
    $majorVersion = 'cpg' . str_replace('.' . ltrim(substr(COPPERMINE_VERSION, strrpos(COPPERMINE_VERSION, '.')), '.'), '', COPPERMINE_VERSION) . '.x';
    $remoteURL = 'http://coppermine-gallery.net/' . str_replace('.', '', $majorVersion) . '.files.xml';
    $localFile = 'include/' . str_replace('.', '', $majorVersion) . '.files.xml';
    $remoteConnectionFailed = '';
    if ($displayOption_array['do_not_connect_to_online_repository'] == 0) {
        // connect to the online repository --- start
        $result = cpgGetRemoteFileByURL($remoteURL, 'GET', '', '200');
        if (strlen($result['body']) < 200) {
            $remoteConnectionFailed = 1;
            $error = $result['error'];
            //print_r($error);
            //print '<hr />';
        }
    }
    // connect to the online repository --- end
    if ($displayOption_array['do_not_connect_to_online_repository'] == 1 || $remoteConnectionFailed == 1) {
        $result = cpgGetRemoteFileByURL($localFile, 'GET', '', '200');
    }
    unset($result['headers']);
    // we should take a look the header data and error messages before dropping them. Well, later maybe ;-)
    unset($result['error']);
    $result = array_shift($result);
    include_once 'include/lib.xml.php';
    $xml = new Xml();
    $file_data_array = $xml->parse($result);
    $file_data_array = array_shift($file_data_array);
    // Perform the repository lookup and xml creation --- end
    return $file_data_array;
}
Exemplo n.º 12
0
Arquivo: Xml.php Projeto: dapepe/xily
 /**
  * Initialize the parser by loading a file or an XML string
  *
  * @param string $strXML Name of the XML file or XML string
  * @param Xml|Bean $xmlMom Parent node
  * @param  bool $bolLoadFile Load from file or parse locally
  * @return Xml|Bean
  */
 public static function returnNode($strXML, $xmlMom, $bolLoadFile)
 {
     try {
         if ($bolLoadFile) {
             $strXML = file_get_contents($strXML);
         }
     } catch (Exception $e) {
         throw new Exception("Could not read file: " . $strXML);
     }
     if ($xmlResult = $xmlMom->parse($strXML)) {
         return $xmlResult;
     }
     throw new Exception('Could not create XML node due to an parsing error.');
 }
Exemplo n.º 13
0
 public function __construct($dbtype = null, $host = null, $port = null, $socket = null, $user = null, $pass = null, $database = null, $trase = null)
 {
     if (!php_Boot::$skip_constructor) {
         $timer = null;
         $stoptime = null;
         $profiler = system_base_Profiler::get_instance();
         $db_config = "";
         $config_path = _hx_string_or_null(system_base_Wet_base::$conf_path) . "database.xml";
         try {
             $db_config = sys_io_File::getContent($config_path);
         } catch (Exception $__hx__e) {
             $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
             $e = $_ex_;
             throw new HException(new system_base_NoFileError(_hx_string_or_null($config_path) . " does not exist or cannot be opened for reading"));
         }
         $xml = Xml::parse($db_config);
         $config = new haxe_xml_Fast($xml->firstElement());
         if ($dbtype === null) {
             $dbtype = $config->node->resolve("type")->get_innerHTML();
         } else {
             $dbtype = $dbtype;
         }
         if ($user === null) {
             $user = $config->node->resolve("user")->get_innerHTML();
         } else {
             $user = $user;
         }
         if ($pass === null) {
             $pass = $config->node->resolve("pass")->get_innerHTML();
         } else {
             $pass = $pass;
         }
         if ($port === null) {
             $port = Std::parseInt($config->node->resolve("port")->get_innerHTML());
         } else {
             $port = $port;
         }
         if ($socket === null) {
             $socket = $config->node->resolve("socket")->get_innerHTML();
         } else {
             $socket = $socket;
         }
         if ($database === null) {
             $database = $config->node->resolve("schema")->get_innerHTML();
         } else {
             $database = $database;
         }
         $timer = new system_base_Timers(null);
         switch ($dbtype) {
             case "mysql":
                 if ($host === null) {
                     $host = $config->node->resolve("host")->get_innerHTML();
                 } else {
                     $host = $host;
                 }
                 if ($trase) {
                     haxe_Log::trace("Attempting connection to " . "MySQL " . _hx_string_or_null($user) . "@" . _hx_string_or_null($host), _hx_anonymous(array("fileName" => "Database.hx", "lineNumber" => 115, "className" => "system.base.Database", "methodName" => "new")));
                 }
                 try {
                     if (system_base_Database::$cnx === null) {
                         system_base_Database::$cnx = sys_db_Mysql::connect(_hx_anonymous(array("host" => $host, "port" => $port, "user" => $user, "pass" => $pass, "socket" => $socket, "database" => $database)));
                     }
                 } catch (Exception $__hx__e) {
                     $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
                     $e1 = $_ex_;
                     throw new HException(new system_base_NoConnectionError($e1));
                     return;
                 }
                 $stoptime = $timer->stop();
                 break;
             case "sqlite":
                 if ($host === null) {
                     $host = $config->node->resolve("host")->get_innerHTML();
                 } else {
                     $host = $host;
                 }
                 if (_hx_index_of($host, "/", null) === -1) {
                     $host = _hx_string_or_null(system_base_Wet_base::$datastore_path) . _hx_string_or_null($host);
                 } else {
                     $host = $host;
                 }
                 if ($trase) {
                     haxe_Log::trace("Attempting connection to " . "SQLite@" . _hx_string_or_null($host), _hx_anonymous(array("fileName" => "Database.hx", "lineNumber" => 150, "className" => "system.base.Database", "methodName" => "new")));
                 }
                 system_base_Database::$cnx = sys_db_Sqlite::open($host);
                 $stoptime = $timer->stop();
                 break;
             default:
                 throw new HException(new system_base_NoSuchDbexception($dbtype));
                 break;
         }
         $profiler->increment("CON", $stoptime, null);
     }
 }
Exemplo n.º 14
0
    unlink($tmpFile);
    header('Content-Disposition: attachment; filename=sacc-export.xml');
    echo $theData;
    exit;
} elseif ($type == "xml2db") {
    show_head();
    echo "<form enctype=\"multipart/form-data\" action=\"index.php?type=xmlimp\" method=\"post\">\r\n <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"3000000\" />\r\n select xml file for import: <input name=\"userfile\" type=\"file\" />\r\n <input type=\"submit\" value=\"Send File\" />\r\n</form>";
    show_tail();
    exit;
} elseif ($type == "xmlimp") {
    $uploaddir = '/tmp/';
    $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
    if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
        echo "File {$uploadfile} successfully uploaded. ";
        $xmlr = new Xml();
        $arro = $xmlr->parse($uploadfile, 'FILE');
        unlink($uploadfile);
        $arr1 = array_pop($arro);
        $arr = array_pop($arr1);
        $arrsize = count($arr1);
        echo "<br>erase all users ";
        $req = "truncate table users";
        $result = mysql_query($req);
        echo mysql_error($link);
        echo "<br>";
        for ($i = 0; $i < $arrsize; $i++) {
            $arr = array_pop($arr1);
            echo "importing ";
            $login = addslashes($arr['login']);
            $used = $arr['used'];
            $limit = $arr['lim'];