Exemplo n.º 1
0
 /**
  * Call this function to activate the xml handler
  *
  *
  * @param       string  the name of the xml file to process
  * @param       string - path of parent. default to root
  * @return      boolean success
  */
 public function process($src, $parent = false)
 {
     //load xml file
     $doc = new DOMDocument('1.0', 'UTF-8');
     $doc->load($src);
     $doc->xinclude();
     $flow = Nexista_Flow::singleton('Nexista_Flow');
     //import new doc into flow recursively
     $new = $flow->flowDocument->importNode($doc->documentElement, 1);
     //append to parent if called for
     if ($parent) {
         $res = Nexista_Flow::find($parent);
         if ($res->length > 0) {
             $parent = $res->item(0);
             $parent->appendChild($new);
         } else {
             return false;
         }
     } else {
         $flow->root->appendChild($new);
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $var = Nexista_Flow::find($this->params['var']);
     if (is_null($var) or is_array($var)) {
         return false;
     }
     $res = $var->item(0);
     $xmlString = $res->textContent;
     //load xml string
     $doc = new DOMDocument();
     $doc->loadXML($xmlString);
     $flow = Nexista_Flow::singleton('Nexista_Flow');
     //import new doc into flow recursively
     $new = $flow->flowDocument->importNode($doc->documentElement, 1);
     $replace = $this->params['replace'];
     if ($replace == "true") {
         $res->nodeValue = "";
     }
     //append back to node as parsed xml now
     $res->appendChild($new);
     //echo $flow->outputXml($flow->root);
     //exit;
     return true;
 }
Exemplo n.º 3
0
function nexista_view_flow()
{
    $flow = Nexista_Flow::singleton('Nexista_Flow');
    // Transform into HTML form
    $use_xslt_cache = 'yes';
    if ($use_xslt_cache != 'yes' || !class_exists('xsltCache')) {
        $debugXsl = new XsltProcessor();
    } else {
        $debugXsl = new XsltCache();
    }
    $xsl = new DomDocument();
    $xml_output = 1;
    if ($xml_output === 1) {
        $xsl->load(NX_PATH_BASE . 'extensions/dev_buffer/s/xsl/flow.ul.xml.xsl');
    }
    $debugXsl->importStyleSheet($xsl);
    if (isset($_GET['ignore'])) {
        $debugXsl->setParameter('', 'ignore', $_GET['ignore']);
    } else {
        $debugXsl->setParameter('', 'ignore', 'i18n');
    }
    $debugXsl->setParameter('', 'link_prefix', dirname($_SERVER['SCRIPT_NAME']) . '/index.php?nid=');
    return $debugXsl->transformToXML($flow->flowDocument);
}
Exemplo n.º 4
0
 /**
  * Init Flow
  *
  * This method creates an instance of Flow
  * which is the class responsible for all
  * data communication between sitemap modules (tags)
  *
  * @return null
  */
 private function _initFlow()
 {
     $flow = Nexista_Flow::singleton('Nexista_Flow');
     $flow->init();
 }
Exemplo n.º 5
0
 /**
  * Assigns query result to flow
  *
  * @return  boolean success
  */
 public function storeResult()
 {
     $debug = false;
     if ($this->result_set) {
         $result_set = $this->result_set;
         $cols = array_flip(array_keys($result_set[0]));
         $row = 0;
         $number_of_rows = count($result_set);
         $flow = Nexista_Flow::singleton('Nexista_Flow');
         $p = $flow->root->appendChild($flow->flowDocument->createElement($this->queryName));
         while ($row < $number_of_rows) {
             $q = $p->appendChild($flow->flowDocument->createElement($this->queryName));
             foreach ($cols as $key => $val) {
                 $myval = $result_set[$row][$key];
                 $myval = htmlspecialchars($myval);
                 $q->appendChild($flow->flowDocument->createElement($key, $myval));
             }
             $row++;
         }
         return true;
     }
     return false;
 }
Exemplo n.º 6
0
    $priority = 10;
}
if ($analytics_code) {
    $google_analytics_code = <<<EOS
<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>
<script type="text/javascript">
if (typeof jQuery != 'undefined') {
    \$(document).ready(function()
    {
        try {
        var pageTracker = _gat._getTracker("{$analytics_code}");
        pageTracker._setCookiePath("{$analytics_cpath}");
        pageTracker._trackPageview();
        } catch(err) {}
    });
} else {
    try {
    var pageTracker = _gat._getTracker("{$analytics_code}");
    pageTracker._setCookiePath("{$analytics_cpath}");
    pageTracker._trackPageview();
    } catch(err) {}
}
</script>
EOS;
    $flow = Nexista_Flow::singleton('Nexista_Flow');
    $f = new DOMDocument('1.0', 'UTF-8');
    $f->loadXML('<post_body_content><priority>11</priority><nodes>jhi' . $google_analytics_code . '</nodes></post_body_content>');
    $n = $f->getElementsByTagName('post_body_content')->item(0);
    $g = $flow->flowDocument->importNode($n, true);
    $flow->root->appendChild($g);
}
Exemplo n.º 7
0
 /**
  * Applies action
  *
  * @return  boolean     success
  */
 protected function main()
 {
     // For now, limit calls to the same domain and protocol.
     $mydomain = $_SERVER['SERVER_NAME'];
     if (isset($_SERVER['HTTPS'])) {
         $protocol = "https://";
     } else {
         $protocol = "http://";
     }
     $url = $this->params['url'];
     $the_params = $this->params['params'];
     $my_params = Nexista_Flow::getByPath($the_params, "ASSOC");
     $target_node = $this->params['target_node'];
     //print_r($my_params);
     if (is_array($my_params)) {
         foreach ($my_params as $key => $value) {
             if (is_array($value)) {
                 foreach ($value as $my_key => $my_value) {
                     //Only adds the query piece if its not already there.
                     //tried array_unique earlier but it didn't work with
                     //array of arrays.
                     $query_piece = "&" . urlencode($my_key) . "[]=" . urlencode($my_value);
                     if (strpos($query_string, $query_piece) === false) {
                         $query_string .= $query_piece;
                     }
                 }
             } else {
                 $query_string = "&" . urlencode($key) . "=" . urlencode($value);
             }
         }
     }
     //echo $query_string;
     $url .= $query_string;
     if (!strpos($url, "www.")) {
         $url = $protocol . $mydomain . $url;
     } else {
     }
     // Quick hack to allow overriding above logic with complete,
     // off-domain url
     if (strstr($this->params['url'], 'http://')) {
         $url = Nexista_Path::parseInlineFlow($this->params['url']);
     }
     if (strstr($_GET['myurl'], 'http://')) {
         $url = $_GET['myurl'];
     }
     if (function_exists(curl_init)) {
         session_write_close();
         $mysession = session_name() . '=' . session_id();
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
         curl_setopt($ch, CURLOPT_COOKIE, $mysession);
         curl_setopt($ch, CURLOPT_NOPROGRESS, 1);
         curl_setopt($ch, CURLOPT_VERBOSE, 1);
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
         curl_setopt($ch, CURLOPT_POST, 0);
         curl_setopt($ch, CURLOPT_TIMEOUT, 120);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $xml = curl_exec($ch);
         if (curl_errno($ch)) {
             print curl_error($ch);
             exit;
         } else {
             curl_close($ch);
         }
     } else {
         $xml = "<{$target_node}>Curl PHP extension is not available.</{$target_node}>";
     }
     $config = array('indent' => true, 'output-xml' => true, 'wrap' => 0);
     // Tidy
     if (class_exists('tidy')) {
         $tidy = new tidy();
         $tidy->parseString($xml, $config, 'utf8');
         $tidy->cleanRepair();
         $xml = $tidy;
     }
     if (1 == 2) {
         // Should result be added to flow as XML?
         $doc = new DOMDocument('1.0', 'UTF-8');
         $doc->loadXML($xml);
         $flow = Nexista_Flow::singleton('Nexista_Flow');
         //import new doc into flow recursively
         $new = $flow->flowDocument->importNode($doc->documentElement, 1);
         //append back to node as parsed xml now
         $flow->root->appendChild($new);
     } else {
         Nexista_Flow::add($target_node, $xml);
     }
 }
Exemplo n.º 8
0
 /**
  * Assigns query result to flow
  *
  * @return boolean success
  */
 public function storeResult()
 {
     foreach ($this->result_set as $dn => $entry) {
         $flow = Nexista_Flow::singleton('Nexista_Flow');
         $q = $flow->root->appendChild($flow->flowDocument->createElement($this->queryName));
         $cn = $entry->getValue('cn', 'single');
         $key = 'ipHostNumber';
         $ip = $entry->getValue($key, 'single');
         $myval = htmlspecialchars($ip);
         $q->appendChild($flow->flowDocument->createElement($key, $myval));
         //echo "$ip    $cn\n";
     }
     return false;
 }
Exemplo n.º 9
0
 /**
  * Creates and appends one or more children elements
  *
  * This method is a shortcut to the createElement, appendChild
  * sequence and can also accept associative arrays of any depth
  *
  * There are a few ways to call this method:
  * - Flow::add('name', 'value'); would result in a new child at the root
  * called 'name' with a value of 'value'.
  * - Flow::add(array('name1'=>'value1', 'name2'=>'value2')); would result 2
  * new children at root level (name1 and name2) with respective values
  * - Flow:add('name', array('blue','red')); would result in 2 nodes at root
  * level of name 'name' with values of 'blue' and 'red' respectively.
  * - Flow::add('name', array('sub1'=> 'blue','sub2'=>'red')); results in a
  * new node of name 'name' at rool level, which contains 2 children
  * each with the values of blue and red respectively.
  * 
  * Note that multi level arrays can be used.
  * 
  * @param mixed  $node  a string for a child or associative array of values
  * @param mixed  $value (optional) if a string is passed $node
  * If an array is passed, it represents the multiple children of $node.
  * @param object $root  (optional) reference to a DOMElement child
  * if none is passed, root is assumed
  *
  * @return boolean success. Usual fail reason is non valid XML names
  */
 public static function add($node, $value = null, $root = false)
 {
     $flow = Nexista_Flow::singleton('Nexista_Flow');
     //where do we place this?
     if (!$root) {
         $root = $flow->root;
     }
     if (is_array($node)) {
         foreach ($node as $n => $v) {
             if (IS_NUMERIC) {
                 return false;
             }
             $flow->add($n, $v, $root);
         }
     } else {
         if (is_array($value)) {
             //numeric array? we replicate the node
             if (IS_NUMERIC(key($value))) {
                 foreach ($value as $n => $v) {
                     $flow->add($node, $v, $root);
                 }
             } else {
                 //associative array
                 $e = $root->appendChild($flow->flowDocument->createElement($node));
                 foreach ($value as $n => $v) {
                     if ($n == 'GLOBALS' || $n == '') {
                         continue;
                     }
                     $flow->add($n, $v, $e);
                 }
             }
         } elseif (!is_null($value)) {
             $e = $root->appendChild($flow->flowDocument->createElement($node));
             $e->appendChild($flow->flowDocument->createTextNode($value));
         }
     }
     return true;
 }