Example #1
0
		public function checkLogin(){
			$document = new domDocument();
			$document->load("users/users.xml");
			$xpath = new domXpath($document);
			$nodelist = $xpath->query("/*/user[string(login) = '$this->login']");
			return ($nodelist->length == 0)?false:true; 
		}
Example #2
0
function viewInfo($node)
{
    if ($_POST["model1"] == "telefon") {
        $nameEl = "телефона";
    }
    if ($_POST["model2"] == "noutbuk") {
        $nameEl = "ноутбука";
    }
    if ($_POST["model3"] == "printer") {
        $nameEl = "принтера";
    }
    echo "<tr>\n\t\t<td><b>Марка " . $nameEl . "</b>\n\t\t</td><td><b>Год выпуска</b>\n\t</td></tr>";
    $document = new domDocument("1.0", "utf-8");
    $document->load("test3.xml");
    $nodelist = $document->getElementsByTagName("model");
    $model = $nodelist->item($i);
    for ($i = 0; $i < $nodelist->length; $i++) {
        $model = $nodelist->item($i);
        if ($model->parentNode->nodeName == $node || $model->parentNode->nodeName == "asort:" . $node) {
            $name = $model->childNodes->item(0);
            $year = $model->childNodes->item(1);
            echo "<tr>\n\t\t\t\t<td>" . $name->nodeValue . "</td>\n\t\t\t\t<td align='center'>" . $year->nodeValue . "</td>\n\t\t\t</tr>";
        }
    }
}
Example #3
0
 /**
  * Brief Description.
  * Complete Description.
  *
  * @param $file' (tipo) desc
  *
  * @returns (tipo) desc
  *
  */
 public function __construct($file = '', $options = 0)
 {
     $this->tree = null;
     $this->stack = array();
     // this keeps track of what tag level you're at
     $doc = new domDocument();
     $doc->preserveWhiteSpace = false;
     $doc->load($file, $options);
     $root = $doc->documentElement;
     $this->parse($doc);
 }
 public function execute($request)
 {
     $this->form = new sfForm();
     $this->timer = new QubitTimer();
     $this->terms = array();
     $this->termsPerPage = intval(sfConfig::get('app_hits_per_page'));
     $this->taxonomy = null;
     $this->parent = QubitTerm::getById(QubitTerm::ROOT_ID);
     if (isset($this->getRoute()->resource)) {
         $resource = $this->getRoute()->resource;
         if ('QubitTaxonomy' == $resource->className) {
             $this->taxonomy = QubitTaxonomy::getById($resource->id);
         } else {
             $this->parent = QubitTerm::getById($resource->id);
             $this->taxonomy = $this->parent->taxonomy;
         }
     }
     if (!isset($this->taxonomy)) {
         $this->forward404();
     }
     // Check user authorization
     if (!QubitAcl::check($this->parent, 'create')) {
         QubitAcl::forwardUnauthorized();
     }
     $this->form->setWidget('file', new sfWidgetFormInputFile());
     $this->form->setValidator('file', new sfValidatorFile());
     if ($request->isMethod('post')) {
         $this->form->bind($request->getPostParameters(), $request->getFiles());
         if ($this->form->isValid()) {
             if (null !== ($file = $this->form->getValue('file'))) {
                 $doc = new domDocument();
                 $doc->substituteEntities = true;
                 $doc->load($file->getTempName());
                 $this->skos = sfSkosPlugin::parse($doc, array('taxonomy' => $this->taxonomy, 'parent' => $this->parent));
             }
         }
     } else {
         $this->setTemplate('importSelect');
     }
 }
 public function generate()
 {
     $this->errors = array();
     $this->generatedMaps = array();
     $doc = new domDocument();
     $doc->load($this->fileXMI);
     $this->xpath = new DOMXpath($doc);
     $this->parse($doc);
     $this->handleAssociation();
     $this->handleAssociationClass();
     $this->handleClassPK();
     $this->handleClassModule();
     $this->handleClassComment();
     $this->handleClassGeneralization();
     $elements = $this->xpath->query("//ownedMember[@name='{$this->package}']/ownedMember[@xmi:type='uml:Class'] | " . " //ownedMember[@name='{$this->package}']/ownedMember[@xmi:type='uml:AssociationClass'] | " . " //ownedMember[@name='{$this->package}']/ownedMember[@xmi:type='uml:Enumeration'] ");
     if ($elements->length > 0) {
         $this->handleClass($elements);
         //$this->handleAssociativeClass();
     } else {
         throw new Exception("Não foi possível encontrar o Package {$this->package} no arquivo XMI.", 1);
     }
 }
Example #6
0
 public function generate()
 {
     $this->errors = array();
     $this->generatedMaps = array();
     $doc = new domDocument();
     $doc->load($this->fileXMI);
     $this->xpath = new DOMXpath($doc);
     // example 1: for everything with an id
     //$elements = $xpath->query("//*[@id]");
     // example 2: for node data in a selected id
     //$elements = $xpath->query("/html/body/div[@id='yourTagIdHere']");
     // example 3: same as above with wildcard
     $this->parse($doc);
     $this->handleAssociation();
     $this->handleClassPK();
     $this->handleClassModule();
     $this->handleClassComment();
     $this->handleClassGeneralization();
     $elements = $this->xpath->query("//ownedMember[@name='{$this->package}']/ownedMember[@xmi:type='uml:Class']");
     if ($elements->length > 0) {
         $this->handleClass($elements);
         $this->handleAssociativeClass();
     }
 }
Example #7
0
<?php

$dom = new domDocument();
$dom->load("book.xml");
if (!$dom) {
    echo "Error while parsing the document\n";
    exit;
}
print "As SimpleXML\n";
$s = simplexml_import_dom($dom);
$books = $s->book;
foreach ($books as $book) {
    echo "{$book->title} was written by {$book->author}\n";
}
print "As DOM \n";
$dom = dom_import_simplexml($s);
$books = $dom->getElementsByTagName("book");
foreach ($books as $book) {
    $title = $book->getElementsByTagName("title");
    $author = $book->getElementsByTagName("author");
    echo $title[0]->firstChild->data . " was written by " . $author[0]->firstChild->data . "\n";
}
Example #8
0
<?php

$dom = new domDocument();
$dom->load('note.xml');
if (!$dom->validate('note.dtd')) {
    print "Document note.dtd is not valid\n";
} else {
    print "Document note.dtd is valid\n";
}
$dom = new domDocument();
$dom->load('note-invalid.xml');
if (!$dom->validate('note.dtd')) {
    print "Document note-invalid.xml is not valid\n";
} else {
    print "Document note-invalid.xml is valid\n";
}
 public function getExtendedValue($extKey, $value, $config, $row)
 {
     if (isset($config) && is_array($config) && isset($row['cnum'])) {
         foreach ($config as $key => $lineConfig) {
             if (isset($lineConfig) && is_array($lineConfig) && isset($lineConfig['uid']) && isset($lineConfig['file'])) {
                 $dataFilename = $GLOBALS['TSFE']->tmpl->getFileName($lineConfig['file']);
                 $absFilename = t3lib_div::getFileAbsFileName($dataFilename);
                 $handle = fopen($absFilename, 'rt');
                 if ($handle === FALSE) {
                     throw new Exception($extKey . ': File not found ("' . $absFilename . '")');
                 } else {
                     // Dateityp bestimmen
                     $basename = basename($dataFilename);
                     $posFileExtension = strrpos($basename, '.');
                     $fileExtension = substr($basename, $posFileExtension + 1);
                     if ($fileExtension == 'xml') {
                         $objDom = new domDocument();
                         $objDom->encoding = 'utf-8';
                         $resultLoad = $objDom->load($absFilename, LIBXML_COMPACT);
                         if ($resultLoad) {
                             $bRowFits = FALSE;
                             $objRows = $objDom->getElementsByTagName('Row');
                             foreach ($objRows as $myRow) {
                                 $tag = $myRow->nodeName;
                                 if ($tag == 'Row') {
                                     $objRowDetails = $myRow->childNodes;
                                     $xmlRow = array();
                                     $count = 0;
                                     foreach ($objRowDetails as $rowDetail) {
                                         $count++;
                                         $detailValue = '';
                                         $detailTag = $rowDetail->nodeName;
                                         if ($detailTag != '#text') {
                                             $detailValue = trim($rowDetail->nodeValue);
                                             $xmlRow[$detailTag] = $detailValue;
                                         }
                                         if ($count > 30) {
                                             break;
                                         }
                                     }
                                     // strip off leading zeros
                                     $cnumInput = preg_replace('@^(0*)@', '', $row['cnum']);
                                     $cnumXml = preg_replace('@^(0*)@', '', $xmlRow['cnum']);
                                     if ($cnumInput != '' && $cnumInput == $cnumXml) {
                                         $textArray = array($row['last_name'], $xmlRow['last_name']);
                                         $nameArray = array();
                                         foreach ($textArray as $text) {
                                             $text = strtolower($text);
                                             $text = preg_replace('@\\x{00e4}@u', 'ae', $text);
                                             // umlaut ä => ae
                                             $text = preg_replace('@\\x{00f6}@u', 'oe', $text);
                                             // umlaut ö => oe
                                             $text = preg_replace('@\\x{00fc}@u', 'ue', $text);
                                             // umlaut ü => ue
                                             $nameArray[] = $text;
                                         }
                                         if ($row['email'] == $xmlRow['email']) {
                                             $bRowFits = TRUE;
                                         } else {
                                             if ($nameArray['0'] == $nameArray['1'] && $row['zip'] == $xmlRow['zip']) {
                                                 $bRowFits = TRUE;
                                             }
                                         }
                                     }
                                     if ($bRowFits) {
                                         break;
                                     }
                                 }
                             }
                             if ($bRowFits) {
                                 $value = intval($lineConfig['uid']);
                                 break;
                             }
                         } else {
                             throw new Exception($extKey . ': The file "' . $absFilename . '" is not XML valid.');
                         }
                     } else {
                         throw new Exception($extKey . ': The file "' . $absFilename . '" has an invalid extension.');
                     }
                 }
             }
         }
     }
     return $value;
 }
<?php

$xslt = new XSLTProcessor();
// Chargement du fichier XML
$xmlDoc = new domDocument();
include 'get.inc';
$xmlDoc->loadXML('<?xml version="1.0" encoding="UTF-8" ?>' . getNodeAsXml($_GET['nodeId']));
// Chargement du fichier XSL
$xsl = new domDocument();
$xsl->load('xmlNodeToJson.xslt');
// Import de la feuille XSL
$xslt->importStylesheet($xsl);
// Transformation et affichage du résultat
echo $xslt->transformToXml($xmlDoc);
				</tr>
				<tr>
				<td align='center' colspan='2'><input type='checkbox' name='news' id='news'/><label for='news'> Хотите получать новости с сайта?</label></td>
				</tr>
				<tr>
				<td align='center' colspan='2'><input type='submit' value='Отправить'/></td>
				</tr>
			</table>
		</form>
		</div>";
	}
	?>
	<center >
		<?php
			$document = new domDocument();
			$document->load("content.xml");
			$xpath = new domXpath($document);
			if(isset($_REQUEST["view"])){
				$nodelist = $xpath->query("/*/*/".$_REQUEST["view"]."/*");
			}
			else{
				$nodelist = $xpath->query("/*/*/*/*");
			}
			for($i=0; $i<$nodelist->length; $i++){
				$node = $nodelist->item($i);
				$row["$node->nodeName"] = iconv("UTF-8", "CP1251",$node->nodeValue);
				if(($i+1)%4 == 0){
					echo "<a href='".$row["link"]."'><h1>".$row["title"]."</h1></a> 	<img src='".$row["image"]."'/><h3>Описание</h3>".$row["description"]."<br/>";
				
				}					
			}
Example #12
0
<?php

$document = new domDocument("1.0", "utf-8");
$document->load("test2.xml");
$nodelist = $document->getElementsByTagName("model");
echo "Количество моделей: <b>" . $nodelist->length . "<b><br/>";
Example #13
0
<?php

$dom = new domDocument();
$dom->load('relaxNG.xml');
if (!$dom->relaxNGValidate('relaxNG.rng')) {
    print "Document is not valid";
} else {
    print "Document is valid";
}
 static function get_elements_used($file = "")
 {
     @ini_set("zend.ze1_compatibility_mode", "0");
     //on récupère la partie intéressante du manifest...
     $dom = new domDocument();
     $dom->load($file);
     $use = $dom->getElementsbyTagName("use")->item(0);
     $elements_used = self::read_elements_used($use);
     @ini_set("zend.ze1_compatibility_mode", "1");
     return $elements_used;
 }
Example #15
0
<?php

$dom = new domDocument();
$dom->load(dirname(__FILE__) . "/area_name.xml");
if (!$dom) {
    echo "Error while parsing the document\n";
    exit;
}
$xsl = new domDocument();
$xsl->load(dirname(__FILE__) . "/area_list.xsl");
if (!$xsl) {
    echo "Error while parsing the document\n";
    exit;
}
$proc = new xsltprocessor();
if (!$proc) {
    echo "Error while making xsltprocessor object\n";
    exit;
}
$proc->importStylesheet($xsl);
print $proc->transformToXml($dom);
//this segfaulted before
print $dom->documentElement->firstChild->nextSibling->nodeName;
Example #16
0
<?php

$dom = new domDocument('1.0');
$dom->load(dirname(__FILE__) . "/thedata.xml");
$new_item = $dom->createElement('item');
$new_item->setAttribute("id", 1234);
// set attribute id for new item
foreach (array('title', 'link', 'description') as $v) {
    $node = $dom->createElement($v);
    $node->appendChild($dom->createTextNode($v));
    $new_item->appendChild($node);
}
// append entry to existing forum entries
$dom->documentElement->appendChild($new_item);
$xml = $dom->saveXML();
echo nl2br(htmlspecialchars(str_replace('><', ">\n<", $xml)));
Example #17
0
function formatjson($dom)
{
    $proc = new XSLTProcessor();
    $proc->importStyleSheet(domDocument::load("xml2json.xslt"));
    $json = $proc->transformToDoc($dom);
    echo "<pre>";
    echo $json->saveHTML();
    echo "</pre>";
}
Example #18
0
[expect php]
[file]
<?php 
require 'Phalanger.inc';
echo "Test 12: Using Associative Array of Parameters";
$dom = new domDocument();
$dom->load(dirname(__FILE__) . "/xslt.xml");
if (!$dom) {
    echo "Error while parsing the document\n";
    exit;
}
$xsl = new domDocument();
$xsl->load(dirname(__FILE__) . "/xslt012.xsl");
if (!$xsl) {
    echo "Error while parsing the document\n";
    exit;
}
$proc = new xsltprocessor();
if ($proc === false) {
    echo "Error while making xsltprocessor object\n";
    exit;
}
$proc->importStylesheet($xsl);
$parameters = array('foo' => 'barbar', 'foo1' => 'test');
$proc->setParameter("", $parameters);
print "\n";
print __xml_norm($proc->transformToXml($dom));
print "\n";
Example #19
0
//$z->imag=3;
$z->show();
// Création fichier XML
$z->xmlSave('complexe.xml');
// Validation fichier XML via DTD
/*
$document = new domDocument();
$document->load('complexe.xml');
//'complexe.dtd' // ToDo
$document->validate() or die("Le fichier XML n'est pas conforme.");
// création d'une DTD avec Cooktop
// http://www.xmlcooktop.com
*/
// Lecture fichier XML
$tree = new domDocument();
$tree->load('complexe.xml');
echo <<<EOF
L'élément racine est : {$tree->documentElement->nodeName},
il comporte {$tree->documentElement->childNodes->length} 
élément(s) fils.<br/>
EOF;
/*
function domExplore($node, $root=true) {
  if ($root) print "<ol>\n";
  print "<li> {$node->nodeName}<br/>\n";
  if ($node->childNodes->length) print "<ol>\n";
  for ($i=0;$i<$node->childNodes->length;$i++)
    domExplore($node->childNodes->item($i), false);
  if ($node->childNodes->length) print "</ol>\n";
  if ($root) print "</ol>\n";
}
Example #20
0
<?php

//header("Content-type:text/xml");
$dom = domDocument::loadHTMLFile($_GET["file"]);
$xslt = domDocument::load("style.xslt");
$proc = new XSLTProcessor();
$proc->importStylesheet($xslt);
$html = $proc->transformToDoc($dom);
echo $html->saveXML();
 public function get_datasources_list()
 {
     global $include_path;
     $list = array();
     $file = $include_path . "/editions/" . $this->filename . "_subst.xml";
     if (!file_exists($file)) {
         $file = $include_path . "/editions/" . $this->filename . ".xml";
     }
     $dom = new domDocument();
     $dom->load($file);
     $datasources = $dom->getElementsByTagName("datasource");
     for ($i = 0; $i < $datasources->length; $i++) {
         $list[$datasources->item($i)->getAttribute('id')] = $this->get_label($datasources->item($i)->getAttribute('name'));
     }
     return $list;
 }
 private function importTemplates($fileNameAndPath)
 {
     $allAccounts = array();
     $dom = new domDocument();
     if (!$dom->load($fileNameAndPath)) {
         throw new CException(Yii::t('lazy8', 'input file could not be xml parsed'));
     }
     $root = $dom->documentElement;
     if ($root->nodeName != "lazy8webtemplates") {
         $this->hasErrors = true;
         $this->errors = array(array(Yii::t('lazy8', 'Upload failed.  This is not a valid file.'), Yii::t('lazy8', 'Select a file and try again')));
         $this->render('showimport');
         return 0;
     }
     if ($root->getAttribute('version') > 1.0) {
         $this->errors = array(array(Yii::t('lazy8', 'There maybe problems because this is a file version greater then this programs version'), Yii::t('lazy8', 'Select a file and try again')));
     }
     Template::importTemplates($root, Yii::app()->user->getState('selectedCompanyId'), $this->errors);
 }
<?php

print "Test 11: php:function Support\n";
class foo
{
    function __construct()
    {
    }
    function __toString()
    {
        return "not a DomNode object";
    }
}
$dom = new domDocument();
$dom->load(dirname(__FILE__) . "/xslt011.xsl");
$proc = new xsltprocessor();
$xsl = $proc->importStylesheet($dom);
$xml = new DomDocument();
$xml->load(dirname(__FILE__) . "/xslt011.xml");
$proc->registerPHPFunctions();
print $proc->transformToXml($xml);
function foobar($id, $secondArg = "")
{
    if (is_array($id)) {
        return $id[0]->value . " - " . $secondArg;
    } else {
        return $id . " - " . $secondArg;
    }
}
function nodeSet($id = null)
{
<?php

include dirname(__FILE__) . '/prepare.inc';
$phpfuncxsl = new domDocument();
$phpfuncxsl->load(dirname(__FILE__) . "/phpfunc.xsl");
if (!$phpfuncxsl) {
    echo "Error while parsing the xsl document\n";
    exit;
}
$proc->importStylesheet($phpfuncxsl);
var_dump($proc->registerPHPFunctions('ucwords'));
var_dump($proc->registerPHPFunctions(null));
var_dump($proc->transformToXml($dom));
 /**
  * Import a language
  * 
  */
 public static function importLanguage($filename, $showMessage = true, $fastImport = false)
 {
     $localErrors = array();
     $allAccounts = array();
     $dom = new domDocument();
     if (!$dom->load($filename)) {
         if ($showMessage) {
             throw new CException(Yii::t('lazy8', 'input file could not be xml parsed'));
         } else {
             throw new CException('input file could not be xml parsed');
         }
     }
     $root = $dom->documentElement;
     if ($root->nodeName != "lazy8webportlang") {
         if ($showMessage) {
             $localErrors = array(array(Yii::t('lazy8', 'Upload failed.  This is not a valid file.'), Yii::t('lazy8', 'Select a file and try again')));
         }
         $this->render('importlang');
         return $localErrors;
     }
     if ($root->getAttribute('version') > 1.0) {
         if ($showMessage) {
             $localErrors = array(array(Yii::t('lazy8', 'There maybe problems because this is a file version greater then this programs version'), Yii::t('lazy8', 'Select a file and try again')));
         }
     }
     $nodeLanguages = $root->getElementsByTagName('language');
     unset($root);
     unset($dom);
     foreach ($nodeLanguages as $nodeLanguage) {
         //make sure the company code is unique
         //Message::model()->dbConnection->createCommand("DELETE FROM Message WHERE language='".$nodeLanguage->getAttribute('langcode')."'")->execute();
         //make sure that all the source messages exist for this language
         if (!$fastImport) {
             $sources = SourceMessage::model()->findAll();
             foreach ($sources as $source) {
                 $foundMessage = Message::model()->find(array('condition' => "language='" . $nodeLanguage->getAttribute('langcode') . "' AND id=" . $source->id));
                 if ($foundMessage == null) {
                     $trans = new Message();
                     $trans->id = $source->id;
                     $trans->translation = $source->message;
                     $trans->language = $nodeLanguage->getAttribute('langcode');
                     $trans->save();
                 }
             }
         } else {
             //quickly delete all occurances of this language
             SourceMessage::model()->dbConnection->createCommand("DELETE FROM Message WHERE language='{$nodeLanguage->getAttribute('langcode')}'")->execute();
         }
         //update the version information
         if ($nodeLanguage->getAttribute('version') != null) {
             $foundOption = Options::model()->find('name=:name AND userId=:id AND companyId=:compid', array(':name' => "Language.Version." . $nodeLanguage->getAttribute('langcode'), ':id' => 0, ':compid' => 0));
             if ($foundOption !== null) {
                 $foundOption->delete();
             }
             $createOption = new Options();
             $createOption->name = "Language.Version." . $nodeLanguage->getAttribute('langcode');
             $createOption->userId = 0;
             $createOption->companyId = 0;
             $createOption->datavalue = $nodeLanguage->getAttribute('version');
             $createOption->save();
         }
         //get all the messages
         $nodeMessages = $nodeLanguage->getElementsByTagName('message');
         foreach ($nodeMessages as $nodeMessage) {
             $sources = SourceMessage::model()->find(array('condition' => "category='" . $nodeMessage->getAttribute('category') . "' AND message='" . SourceMessageController::sqlCleanString(CHtml::encode($nodeMessage->getAttribute('key'))) . "'"));
             if ($sources == null) {
                 $newSource = new SourceMessage();
                 $newSource->message = CHtml::encode($nodeMessage->getAttribute('key'));
                 $newSource->category = $nodeMessage->getAttribute('category');
                 $maxId = 0;
                 $command = SourceMessage::model()->dbConnection->createCommand("SELECT MAX(id) as maxid FROM SourceMessage");
                 try {
                     $reader = $command->query();
                 } catch (Exception $e) {
                     echo '<h2>Died on Sql Maxid</h2>';
                     throw $e;
                 }
                 if ($reader !== null && count($reader) > 0) {
                     foreach ($reader as $row) {
                         $maxId = $row['maxid'] + 1;
                         break;
                         //there is only one row here anyway.
                     }
                 }
                 $newSource->id = $maxId;
                 if ($newSource->save()) {
                     $modelMessage = new Message();
                     $modelMessage->language = $nodeLanguage->getAttribute('langcode');
                     $modelMessage->id = $newSource->id;
                     $modelMessage->translation = SourceMessageController::getNodeText($nodeMessage, "translation");
                     $modelMessage->save();
                     if (!$fastImport) {
                         //now we must add to all of the other languages.
                         $langs = Message::model()->findAll(array('select' => 'distinct language'));
                         if (isset($langs) && count($langs) > 0) {
                             foreach ($langs as $lang) {
                                 if ($nodeLanguage->getAttribute('langcode') != $lang->language) {
                                     $newLangItem = new Message();
                                     $newLangItem->id = $newSource->id;
                                     $newLangItem->language = $lang->language;
                                     $newLangItem->translation = CHtml::encode($nodeMessage->getAttribute('key'));
                                     $newLangItem->save();
                                 }
                             }
                         }
                     }
                 }
             } else {
                 //make sure the key is unique
                 if (!$fastImport) {
                     Message::model()->dbConnection->createCommand("DELETE FROM Message WHERE language='" . $nodeLanguage->getAttribute('langcode') . "' AND id=" . $sources->id)->execute();
                 }
                 $modelMessage = new Message();
                 $modelMessage->language = $nodeLanguage->getAttribute('langcode');
                 $modelMessage->id = $sources->id;
                 $modelMessage->translation = SourceMessageController::getNodeText($nodeMessage, "translation");
                 //try{
                 if (!$modelMessage->save()) {
                     if ($showMessage) {
                         $localErrors[] = array(Yii::t('lazy8', 'Failed import of translation.') . ' = ' . $nodeLanguage->getAttribute('langcode') . ' ; ' . $nodeMessage->getAttribute('key'), Yii::t('lazy8', 'Select a file and try again'));
                     }
                 }
                 //}catch(Exception $e){
                 //	echo "error on langcode=" . $nodeLanguage->getAttribute('langcode') . " key=" . $nodeMessage->getAttribute('key');
                 //	die();
                 //}
             }
         }
     }
     return $localErrors;
 }
Example #26
0
<?php

echo "Test 8: Stream Wrapper Includes ";
include "prepare.inc";
$xsl = new domDocument();
$xsl->load(dirname(__FILE__) . "/streamsinclude.xsl");
if (!$xsl) {
    echo "Error while parsing the document\n";
    exit;
}
chdir(dirname(__FILE__));
$proc->importStylesheet($xsl);
print "\n";
print $proc->transformToXML($dom);
Example #27
0
 public static function get_module_default_language($xml)
 {
     @ini_set("zend.ze1_compatibility_mode", "0");
     if (!is_object($xml)) {
         $dom = new domDocument();
         $dom->load($xml);
         $xml = $dom;
     }
     $default_language = $xml->getElementsByTagName("default_language")->item(0)->nodeValue;
     @ini_set("zend.ze1_compatibility_mode", "1");
     return $default_language;
 }
Example #28
0
        gpx url:
<!--
        <input type="text" name="url" value="http://www.openstreetmap.org/trace/653814/data" style="width:400px"/>
-->
        <input type="text" name="url" value="http://www.openstreetmap.org/trace/1066385/data" style="width:400px"/>
        <input type="submit"/>
        </form>
        <?php 
    //echo "syntax: http://.....?url=http://myhost.com/file.gpx";
    die;
}
if (substr($_GET["url"], 0, 4) != "http") {
    echo "please insert http address only";
    die;
}
$dom = domDocument::load($_GET["url"]);
if (!$dom) {
    echo "invalid gpx at <a href='{$_GET["url"]}'>{$_GET["url"]}</a>";
    die;
}
/*
$dom=domDocument::load($_GET["url"]);
if(!$dom){
    echo "invalid gpx";
    die();
}
*/
$xmlstring = makeString($dom->documentElement);
function makeString($el)
{
    $string = "";
Example #29
0
<?php

echo "Test 10: EXSLT Support";
$dom = new domDocument();
$dom->load(dirname(__FILE__) . "/exslt.xsl");
$proc = new xsltprocessor();
$xsl = $proc->importStylesheet($dom);
$xml = new DomDocument();
$xml->load(dirname(__FILE__) . "/exslt.xml");
print $proc->transformToXml($xml);
 /**
  * Import a report
  * 
  */
 public static function importFile($filename, $showMessage = true, $removeExistingReport = false)
 {
     $localErrors = array();
     $allAccounts = array();
     $dom = new domDocument();
     if (!$dom->load($filename)) {
         if ($showMessage) {
             throw new CException(Yii::t('lazy8', 'input file could not be xml parsed'));
         } else {
             throw new CException('input file could not be xml parsed');
         }
     }
     $root = $dom->documentElement;
     if ($root->nodeName != "lazy8webportreport") {
         if ($showMessage) {
             $localErrors = array(array(Yii::t('lazy8', 'Upload failed.  This is not a valid file.'), Yii::t('lazy8', 'Select a file and try again')));
         }
         return $localErrors;
     }
     if ($root->getAttribute('version') > 1.0) {
         if ($showMessage) {
             $localErrors = array(array(Yii::t('lazy8', 'There maybe problems because this is a file version greater then this programs version'), Yii::t('lazy8', 'Select a file and try again')));
         }
     }
     $nodeReports = $root->getElementsByTagName('report');
     unset($root);
     unset($dom);
     foreach ($nodeReports as $nodeReport) {
         if ($removeExistingReport) {
             $deleteReports = Report::model()->findAll(array('condition' => 'name=\'' . $nodeReport->getAttribute('name') . '\''));
             if ($deleteReports != null) {
                 foreach ($deleteReports as $deleteReport) {
                     $deleteReport->delete();
                 }
             }
         }
         $report = new Report();
         $report->name = $nodeReport->getAttribute('name');
         $report->desc = ReportController::getNodeText($nodeReport, "desc");
         $report->selectSql = ReportController::getNodeText($nodeReport, "selectsql");
         $report->sortOrder = ReportController::getNodeText($nodeReport, "sortOrder");
         $report->cssColorFileName = ReportController::getNodeText($nodeReport, "csscolorfilename");
         $report->cssBwFileName = ReportController::getNodeText($nodeReport, "cssbwfilename");
         $nodeParams = $nodeReport->getElementsByTagName('parameter');
         if (!$report->save()) {
             if ($showMessage) {
                 $localErrors = $report->getErrors();
             }
             return $localErrors;
         }
         foreach ($nodeParams as $nodeParam) {
             $reportParam = new ReportParameters();
             $reportParam->reportId = $report->id;
             $reportParam->sortOrder = $nodeParam->getAttribute('sortorder');
             $reportParam->name = $nodeParam->getAttribute('name');
             $reportParam->alias = $nodeParam->getAttribute('alias');
             $reportParam->dataType = $nodeParam->getAttribute('datatype');
             $reportParam->isDefaultPhp = $nodeParam->getAttribute('isdefaultphp') == 'true' ? 1 : 0;
             $reportParam->isDate = $nodeParam->getAttribute('isdate') == 'true' ? 1 : 0;
             $reportParam->isDecimal = $nodeParam->getAttribute('isdecimal') == 'true' ? 1 : 0;
             $reportParam->desc = ReportController::getNodeText($nodeParam, "desc");
             $reportParam->phpSecondaryInfo = ReportController::getNodeText($nodeParam, "phpsecondaryinfo");
             $reportParam->defaultValue = ReportController::getNodeText($nodeParam, "defaultvalue");
             if (!$reportParam->save()) {
                 if ($showMessage) {
                     $localErrors = $reportParam->getErrors();
                 }
             }
         }
         unset($nodeParams);
         $nodeGroups = $nodeReport->getElementsByTagName('group');
         foreach ($nodeGroups as $nodeGroup) {
             $reportGroup = new ReportGroups();
             $reportGroup->reportId = $report->id;
             $reportGroup->sortOrder = $nodeGroup->getAttribute('sortorder');
             $reportGroup->breakingField = $nodeGroup->getAttribute('breakingfield');
             $reportGroup->pageBreak = $nodeGroup->getAttribute('pagebreak') == 'true' ? 1 : 0;
             $reportGroup->showGrid = $nodeGroup->getAttribute('showgrid') == 'true' ? 1 : 0;
             $reportGroup->showHeader = $nodeGroup->getAttribute('showheader') == 'true' ? 1 : 0;
             $reportGroup->continueSumsOverGroup = $nodeGroup->getAttribute('continuesumsovergroup') == 'true' ? 1 : 0;
             if (!$reportGroup->save()) {
                 if ($showMessage) {
                     $localErrors = $reportGroup->getErrors();
                 }
             }
             $nodeGroupFields = $nodeGroup->getElementsByTagName('field');
             foreach ($nodeGroupFields as $nodeGroupField) {
                 $reportGroupField = new ReportGroupFields();
                 $reportGroupField->reportGroupId = $reportGroup->id;
                 $reportGroupField->sortOrder = $nodeGroupField->getAttribute('sortorder');
                 $reportGroupField->fieldName = $nodeGroupField->getAttribute('fieldname');
                 $reportGroupField->fieldWidth = $nodeGroupField->getAttribute('fieldwidth');
                 $reportGroupField->row = $nodeGroupField->getAttribute('row');
                 $reportGroupField->isDate = $nodeGroupField->getAttribute('isdate') == 'true' ? 1 : 0;
                 $reportGroupField->isDecimal = $nodeGroupField->getAttribute('isdecimal') == 'true' ? 1 : 0;
                 $reportGroupField->fieldCalc = ReportController::getNodeText($nodeGroupField, "fieldcalc");
                 if (!$reportGroupField->save()) {
                     if ($showMessage) {
                         $localErrors = $reportGroupField->getErrors();
                     }
                 }
             }
             unset($nodeGroupFields);
         }
         unset($nodeGroups);
         $nodeReportRows = $nodeReport->getElementsByTagName('rows');
         foreach ($nodeReportRows as $nodeReportRow) {
             $reportRow = new ReportRows();
             $reportRow->reportId = $report->id;
             $reportRow->sortOrder = $nodeReportRow->getAttribute('sortorder');
             $reportRow->fieldName = $nodeReportRow->getAttribute('fieldname');
             $reportRow->fieldWidth = $nodeReportRow->getAttribute('fieldwidth');
             $reportRow->row = $nodeReportRow->getAttribute('row');
             $reportRow->isSummed = $nodeReportRow->getAttribute('issummed') == 'true' ? 1 : 0;
             $reportRow->isAlignRight = $nodeReportRow->getAttribute('isalignright') == 'true' ? 1 : 0;
             $reportRow->isDate = $nodeReportRow->getAttribute('isdate') == 'true' ? 1 : 0;
             $reportRow->isDecimal = $nodeReportRow->getAttribute('isdecimal') == 'true' ? 1 : 0;
             $reportRow->fieldCalc = ReportController::getNodeText($nodeReportRow, "fieldcalc");
             if (!$reportRow->save()) {
                 if ($showMessage) {
                     $localErrors = $reportRow->getErrors();
                 }
             }
         }
     }
     return $localErrors;
 }