Exemplo n.º 1
0
 public static function get_default_item()
 {
     $id = filter_input(INPUT_POST, 'id');
     $value_default = filter_input(INPUT_POST, 'val_default');
     if ($value_default == '') {
         return 'Do nothing!';
     }
     $feed = new SimplePie();
     $path = OGRAB_EDATA . 'item-' . $id . DS . 'row-default.dat';
     $feed->set_feed_url($value_default);
     $feed->set_autodiscovery_level(SIMPLEPIE_LOCATOR_NONE);
     $feed->set_timeout(20);
     $feed->enable_cache(false);
     $feed->set_stupidly_fast(true);
     $feed->enable_order_by_date(false);
     // we don't want to do anything to the feed
     $feed->set_url_replacements(array());
     $result = $feed->init();
     if (isset($_GET['x'])) {
         echo "\n\n<br /><i><b>File:</b>" . __FILE__ . ' <b>Line:</b>' . __LINE__ . "</i><br />\n\n";
         echo "<p>URL: [{$value_default}]</p>";
         echo "<p>Error: [{$feed->error}]</p>";
     }
     $items = $feed->get_items();
     $c_items = count($items);
     if ($c_items == 0) {
         echo "<p>Error: [{$feed->error}]</p>";
         return array();
     }
     $row = new stdclass();
     $row->title = html_entity_decode($items[0]->get_title(), ENT_QUOTES, 'UTF-8');
     # the title for the post
     $row->link = $items[0]->get_link();
     # a single link for the post
     $row->description = $items[0]->get_description();
     # the content of the post (prefers summaries)
     $row->author = $items[0]->get_author();
     # a single author for the post
     $row->date = $items[0]->get_date('Y-m-d H:i:s');
     $row->enclosures = $items[0]->get_enclosures();
     if (!is_file($path)) {
         $source = new stdClass();
     } else {
         $source = ogb_common::get_default_data('', $id);
     }
     $source->so = $row;
     $cache = serialize($source);
     if (isset($_GET['x2'])) {
         //echo "\n\n<br /><i><b>File:</b>".__FILE__.' <b>Line:</b>'.__LINE__."</i><br />\n\n";
         echo '<br>Path: ' . $path;
     }
     ogbFile::write($path, $cache);
     exit;
 }
Exemplo n.º 2
0
 function write_down_input_processor()
 {
     $mod = $this->getModel('pipe');
     $id = filter_input(INPUT_GET, 'id');
     $processor_id = filter_input(INPUT_GET, 'process_id');
     $ordering = filter_input(INPUT_GET, 'ordering');
     $input_type = filter_input(INPUT_GET, 'input_type');
     $input_value = filter_input(INPUT_GET, 'input_value');
     $input_name = filter_input(INPUT_GET, 'input_name');
     $current_default = ogb_common::get_default_data('', $id);
     if ($input_type == 'e') {
         $input_type = 'so';
     } else {
         $stt = $input_type;
         $input_type = 'po';
     }
     if (!is_array($current_default->pi)) {
         $current_default->pi = array();
     }
     if (!is_object($current_default->pi[$ordering])) {
         $current_default->pi[$ordering] = new stdClass();
     }
     $current_default->pi[$ordering]->{$input_name} = $input_type . ',' . $input_value . ',' . $processor_id;
     if (isset($stt)) {
         $current_default->pi[$ordering]->{$input_name} .= ',' . $stt;
     }
     $current_default = $mod->get_first_output_processor($current_default, $ordering, $processor_id);
     $cache = serialize($current_default);
     $path = OGRAB_EDATA . 'item-' . $id . DS . 'row-default.dat';
     ogbFile::write($path, $cache);
     echo json_encode($current_default->po[$ordering]);
     exit;
     /*echo '<pre>';print_r( $current_default );die;
     		$pipe   = $mod->get_one_pipe( $processor_id );
     		$name   = $pipe->code;
     		$params = json_decode( $pipe->params );
     		$class  = 'WPPipesPro_' . $name;
     		$datas  = ogbLib::call_method( $class, 'process', array( $pipe->params ) );*/
 }
Exemplo n.º 3
0
 function getEditData($id = null)
 {
     global $wpdb;
     //$id = filter_input( INPUT_GET, 'id', FILTER_VALIDATE_INT );
     if (!$id) {
         $id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
     }
     //		$id	= (int) $cid[0];
     //		var_dump($id);exit();
     //$data	= JTable::getInstance('Items','wppipesTable');
     if (!$id) {
         $id = 0;
     }
     $sql = 'SELECT * FROM ' . $wpdb->prefix . 'wppipes_items WHERE `id`=' . $id;
     $data = $wpdb->get_row($sql);
     //		echo $sql;
     //		var_dump($data);
     //		exit();
     //		$data->load( $id );
     if ($data) {
         $data->inputs = json_decode($data->inputs);
         $data->outputs = json_decode($data->outputs);
         $data->pipes = $this->getPipes($id);
     } else {
         $data = new stdClass();
         $data->id = 0;
         $data->name = '';
         $data->published = 0;
         $data->engine = '';
         $data->engine_params = '';
         $data->adapter = '';
         $data->adapter_params = '';
         $data->inherit = '';
         $data->inputs = '';
         $data->outputs = '';
     }
     $disabled = false;
     if ($data->inherit > 0) {
         $data->processors = '';
         $disabled = true;
     } else {
         $data->processors = $this->getListProcessors();
     }
     $data->engines = $this->getListEngine($data->engine, $disabled);
     $data->adapters = $this->getListAdapter($data->adapter, $disabled);
     if ($data->engine != '') {
         $data->eParams = $this->addonRender('engine', $data->engine, $data->engine_params, $data->id);
     } else {
         $data->eParams = '';
     }
     $data->eParams = str_replace('data-toggle=', 'rel=', $data->eParams);
     if ($data->adapter != '') {
         $data->aParams = $this->addonRender('adapter', $data->adapter, $data->adapter_params, $data->id);
     } else {
         $data->aParams = '';
     }
     $data->aParams = str_replace('data-toggle=', 'rel=', $data->aParams);
     $default_oe = ogb_common::get_default_data('so', $id);
     if (!$default_oe || !isset($data->outputs->oe)) {
         return $data;
     }
     foreach ($data->outputs->oe as $key => $value) {
         if (is_array($default_oe->{$value}) || !is_string($default_oe->{$value})) {
             $data->outputs->oe[$key] = $value . '<br /><p class="text-muted small">Array</p>';
         } else {
             $default_oe->{$value} = str_replace("'", "", $default_oe->{$value});
             $default_oe->{$value} = str_replace('"', '', $default_oe->{$value});
             $data->outputs->oe[$key] = $value . '<br /><p title="' . ($default_oe->{$value} != '' ? strip_tags($default_oe->{$value}) : 'null') . '" class="text-muted small">' . ($default_oe->{$value} != '' ? strip_tags($default_oe->{$value}) . '</p>' : 'null</p>');
         }
     }
     $default_op = ogb_common::get_default_data('po', $id);
     if (!$default_op) {
         return $data;
     }
     foreach ($data->outputs->op as $key => $values) {
         foreach ($values as $index => $value) {
             if (!isset($default_op[$key]->{$value})) {
                 continue;
             }
             if (is_array($default_op[$key]->{$value}) || !is_string($default_op[$key]->{$value})) {
                 $values[$index] = $value . '<br /><p class="text-muted small">Array</p>';
             } else {
                 $default_op[$key]->{$value} = str_replace("'", "", $default_op[$key]->{$value});
                 $default_op[$key]->{$value} = str_replace('"', '', $default_op[$key]->{$value});
                 $stripped = preg_replace(array('/\\s{2,}/', '/[\\t\\n]/'), ' ', $default_op[$key]->{$value});
                 $stripped = strlen($stripped) > 200 ? mb_substr(strip_tags($stripped), 0, 200, 'UTF-8') . '...' : strip_tags($stripped);
                 $values[$index] = $value . '<br /><p data-placement="bottom" title="' . $stripped . '" class="text-muted small">' . $stripped . '</p>';
             }
         }
         $data->outputs->op[$key] = $values;
     }
     return $data;
 }