Example #1
0
 function callProcessors(&$data, $pipe)
 {
     $pInput = $this->getInputs($data, $pipe->ordering);
     if (!class_exists($pipe->classn)) {
         $pipe->classn = $this->get_real_class($pipe->classn);
     }
     $pOutput = ogbLib::call_method($pipe->classn, 'process', array($pInput, $pipe->params));
     if (isset($pOutput->stop) && $pOutput->stop->state) {
         $data['stop'] = $pOutput->stop;
         return false;
     }
     $data['op'][$pipe->ordering] = $pOutput;
 }
Example #2
0
 public static function get_first_output_processor($current_data, $ordering, $proc_id)
 {
     global $wpdb;
     $sql = "SELECT * FROM `{$wpdb->prefix}wppipes_pipes` WHERE `id`={$proc_id}";
     $pipe = $wpdb->get_row($sql);
     $path = PIPES_PATH . DS . 'plugins' . DS . 'processors' . DS . $pipe->code . DS . $pipe->code . '.php';
     $path_plugin = OB_PATH_PLUGIN . $pipe->code . DS . $pipe->code . '.php';
     if (is_file($path)) {
         include_once $path;
         $class = 'WPPipesPro_' . $pipe->code;
     } elseif (!is_file($path_plugin)) {
         $res = new stdClass();
         $res->err = "File not found [processor {$pipe->code}]";
         return $res;
     } else {
         include_once $path_plugin;
         $real_name = explode('-', $pipe->code);
         $class = 'WPPipesPro_' . end($real_name);
     }
     $pInput = new stdClass();
     foreach ($current_data->pi[$ordering] as $key => $value) {
         $val_array = explode(',', $value);
         $type_input = $val_array[0];
         $name_input = $val_array[1];
         $data_value = $current_data->{$type_input};
         if (!isset($data_value)) {
             continue;
         }
         if (count($val_array) > 3 && $val_array[3] != '') {
             $pInput->{$key} = $data_value[$val_array[3]]->{$name_input};
         } else {
             $pInput->{$key} = $data_value->{$name_input};
         }
     }
     $pOutput = ogbLib::call_method($class, 'process', array($pInput, json_decode($pipe->params)));
     foreach ($pOutput as $out_key => $out_value) {
         if (is_string($out_value)) {
             $out_value = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $out_value);
             $out_value = str_replace('"', '', $out_value);
             $out_value = str_replace("'", "", $out_value);
             $pOutput->{$out_key} = strip_tags($out_value);
         }
     }
     if (!is_array($current_data->po[$ordering])) {
         $current_data->po[$ordering] = array();
     }
     if (isset($pOutput)) {
         $current_data->po[$ordering] = $pOutput;
     }
     return $current_data;
 }