예제 #1
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $mytext = Nexista_Flow::getByPath($this->params['text']);
     $name = $this->params['name'];
     Nexista_Flow::add($name, $new_text);
     return true;
 }
예제 #2
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $res = Nexista_Flow::find($this->params['var']);
     if (!empty($res)) {
         $chars = Nexista_Flow::getByPath($this->params['chars']);
         $res->item(0)->nodeValue = str_replace($chars, "", $res->item(0)->nodeValue);
         return true;
     } else {
         return false;
     }
 }
예제 #3
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     include 'HTML/BBCodeParser.php';
     $mytext = Nexista_Flow::getByPath($this->params['text']);
     $name = $this->params['name'];
     $parser = new HTML_BBCodeParser();
     $parser->addFilters('Basic,Extended,Links,Images,Lists');
     $new_text = $parser->qParse($mytext);
     Nexista_Flow::add($name, $new_text);
     return true;
 }
예제 #4
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     include 'HTML/Safe.php';
     $mytext = Nexista_Flow::getByPath($this->params['text']);
     $name = $this->params['name'];
     $parser =& new HTML_Safe();
     $new_text = $parser->parse($mytext);
     if (empty($name)) {
         $node = Nexista_Flow::find($this->params['text']);
         $node->item(0)->nodeValue = $new_text;
     } else {
         Nexista_Flow::add($name, $new_text);
     }
     return true;
 }
예제 #5
0
파일: path.php 프로젝트: savonix/nexista
 /**
  * Returns a string based on given protocol://path 
  *
  * @param string $path     path to resolve/render
  * @param string $protocol (optional) default protocol if none given
  *
  * @return string value of variable
  */
 public static function get($path, $protocol = 'string')
 {
     switch ($protocol) {
         case 'flow':
             $result = Nexista_Flow::getByPath($path);
             break;
         default:
             $result = Nexista_Path::parseInlineFlow($path);
     }
     if (!is_null($result)) {
         return $result;
     } else {
         return false;
     }
 }
예제 #6
0
 /**
  * Applies action
  *
  * @return  boolean success
  */
 protected function main()
 {
     $var = Nexista_Flow::getByPath($this->params['var']);
     if (is_null($var) or is_array($var)) {
         return false;
     }
     $trans_array = array();
     for ($i = 127; $i < 255; $i++) {
         if ($this->params['translate'] == 'true') {
             $trans_array[chr($i)] = "&#" . $i . ";";
         } else {
             $trans_array[chr($i)] = "";
         }
     }
     //also deal with xsl stuff
     $sterile = strtr($var->textContent, $trans_array);
     //strip tags with namespaces
     $sterile = preg_replace('~<([^>\\"=\']*):(.*)>~mU', '', $sterile);
     //write new data to Flow
     $var->textContent = $sterile;
     return true;
 }
예제 #7
0
 /**
  * Parses a prepared query for general query type (select,insert,etc...) and
  *
  * This method calls MDB2 prepareQuery(), sets the variable types
  * (see MDB2 docs) and parses a query to determine its type (select,insert.etc...)
  * and updates $this->queryType with this info. It also looks for
  * special keyword and replaces them with values accordingly.
  * This function returns a prepared query handler resource by reference
  *
  * @param   integer     returning prepared query handler
  * @param   integer     current loop count
  * @return  boolean     success
  */
 private function prepareQuery(&$sql, $loop)
 {
     //see if it is a select
     if (!isset($this->queryType)) {
         if (eregi("^[[:space:]]*[select|show]", $this->query['sql'])) {
             $this->queryType = 'select';
         }
     }
     $count = 1;
     if (isset($this->query['params'])) {
         foreach ($this->query['params'] as $val) {
             $found = true;
             $path = new Nexista_Flow();
             if (!empty($val['name'])) {
                 $value = $path->getByPath($val['name']);
                 if (is_null($value) && $val['type'] == 'integer') {
                     $found = false;
                 }
             } elseif (!empty($val['array'])) {
                 $array = $path->getByPath($val['array']);
                 if (!is_array($array)) {
                     $array = array($array);
                 }
                 $value = $array[$loop];
             } elseif (!empty($val['node-name-array'])) {
                 $array = $path->getByPath($val['node-name-array'], 'ASSOC');
                 if (!is_array($array)) {
                     $array = array($array);
                 }
                 $key = array_keys($array[$loop]);
                 $value = $key[0];
             } else {
                 $found = false;
             }
             if ((!$found || $value === 'NaN' || $value === '' || $value == '') && $value !== '0') {
                 $value = $val['default'];
             }
             if ($value !== 'NULL') {
                 $type = $val['type'];
             }
             if ($value == 'NULL') {
                 $value = NULL;
                 $type = NULL;
             }
             if ($value || $value == 0) {
                 $types[] = $type;
                 $data[] = $value;
             }
             $count++;
         }
         $prep = $this->db->prepare($this->query['sql'], $types);
         if (PEAR::isError($prep)) {
             Nexista_Error::init($result->getMessage() . "\n                    " . $this->queryName, NX_ERROR_FATAL);
         }
         $result = $prep->execute($data);
         $prep->free();
     } else {
         $prep = $this->db->prepare($this->query['sql'], $types);
         $result = $prep->execute();
         $prep->free();
     }
     if (PEAR::isError($result)) {
         $my_debug_result = '';
         //serialize($result);
         Nexista_Error::init($result->getMessage() . ' in query named ' . $this->queryName . $my_debug_result, NX_ERROR_FATAL);
     }
     if ($this->queryType == 'select') {
         return $result->fetchAll(MDB2_FETCHMODE_ASSOC);
     } else {
         return true;
     }
 }
예제 #8
0
/*
<google_analytics_code>
  <placement>predisplay</placement>
  <code>raw code</code>
  <!-- xpath trumps code -->
  <xpath>//o_google_analytics_code</xpath>
  <priority>100</priority>
  <cookie_path>100</cookie_path>
  <source>&includepath;extensions/google_analytics.php</source>
</google_analytics_code>
*/
$analytics_code = Nexista_Config::get('./extensions/google_analytics_code/code');
$analytics_xpath = Nexista_Config::get('./extensions/google_analytics_code/xpath');
$analytics_cpath = Nexista_Config::get('./extensions/google_analytics_code/cookie_path');
if ($analytics_xpath) {
    $analytics_code = Nexista_Flow::getByPath($analytics_xpath);
}
if (!($priority = Nexista_Config::get('./extensions/google_analytics_code/priority'))) {
    $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();
예제 #9
0
 /**
  * Checks item requirements
  *
  * @param string $required item requirements
  *
  * @return null
  */
 protected function setRequired($required)
 {
     if ($required === 'true') {
         $this->required = true;
     } elseif ($required === 'false') {
         $this->required = false;
     } else {
         $req = explode(',', $required);
         if (sizeof($req) == 2) {
             $var = Nexista_Flow::getByPath($req[0]);
             if (is_array($var)) {
                 $var = $var[0];
             }
             if (preg_match($req[1], $var, $match) == true) {
                 $this->required = true;
             } else {
                 $this->required = false;
             }
         } else {
             Nexista_Error::init("Validator 'required' field is not valid", NX_ERROR_WARNING);
             $this->required = true;
         }
     }
 }
예제 #10
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);
     }
 }