public static function getData($params) { if (isset($_GET['e'])) { echo "\n\n<br /><i><b>File:</b>" . __FILE__ . ' <b>Line:</b>' . __LINE__ . "</i><br />\n\n"; ogb_pr($params, 'Params: '); } $urls = explode("\nhttp", $params->feed_url); $limit = (int) $params->limit_items; $a = 0; $data = array(); for ($i = 0; $i < count($urls); $i++) { $url = trim($urls[$i]); if ($i > 0) { $url = 'http' . $url; } $items = self::getItemsFeed($url, $limit, $params); if (count($items) > 0) { $data = array_merge($items, $data); } } if (isset($_GET['e1'])) { echo "\n\n<br /><i><b>File:</b>" . __FILE__ . ' <b>Line:</b>' . __LINE__ . "</i><br />\n\n"; echo 'Total: ' . count($data); ogb_pr($data, 'Data: '); } return $data; }
public static function getData($params) { if (isset($_GET['e'])) { echo "\n\n<br /><i><b>File:</b>" . __FILE__ . ' <b>Line:</b>' . __LINE__ . "</i><br />\n\n"; ogb_pr($params, 'Params: '); } $limit = 0; $data = self::getItemsPost($params); $datas = array(); foreach ($data as $key => $value) { if ($limit >= (int) $params->limit_items) { break; } if (has_post_thumbnail($value->ID)) { $image = wp_get_attachment_image_src(get_post_thumbnail_id($value->ID), 'single-post-thumbnail'); } $data[$key]->featured_image = @$image[0]; $data[$key]->author_name = get_the_author_meta('display_name', $value->post_author); $data[$key]->link = $value->guid; $data[$key]->src_name = isset($value->post_title) ? $value->post_title : ''; $data[$key]->src_url = isset($value->ID) ? get_permalink($value->ID) : ''; $datas[] = $data[$key]; $limit++; } if (isset($_GET['e1'])) { echo "\n\n<br /><i><b>File:</b>" . __FILE__ . ' <b>Line:</b>' . __LINE__ . "</i><br />\n\n"; echo 'Total: ' . count($datas); ogb_pr($datas, 'Data: '); } //var_dump($data);die; return $datas; }
/** * Storing item * * @param $data * @param $params * * @return stdclass */ static function store($data, $params) { if (isset($_GET['a'])) { echo "\n\n<br /><i><b>File:</b>" . __FILE__ . ' <b>Line:</b>' . __LINE__ . "</i><br />\n\n"; ogb_show($data->excerpt, 'Excerpt: '); ogb_show($data->content, 'Content: '); } if (isset($_GET['a1'])) { echo "\n\n<br /><i><b>File:</b>" . __FILE__ . ' <b>Line:</b>' . __LINE__ . "</i><br />\n\n"; ogb_pr($params, 'Params: '); ogb_pr($data, 'Data: '); } if ('' == $data->slug) { $data->slug = sanitize_title($data->title); } $dup_id = self::checkDuplicate(array('title' => $data->slug)); $action = ''; $msg = ''; if ($dup_id > 0) { if (isset($_GET['u'])) { $action = 'Update'; $msg = 'Update - id:' . $dup_id; } else { $res = self::makeLog($dup_id, 'Ignore', 'Duplicate - id:' . $dup_id); return $res; } } $id = $dup_id > 0 ? $dup_id : 0; $save = self::storeContent($data, $params, $id); $id = $save->id; if (isset($_GET['a1'])) { echo "\n\n<br /><i><b>File:</b>" . __FILE__ . ' <b>Line:</b>' . __LINE__ . "</i><br />\n\n"; echo '<pre>'; echo 'Saved result: '; print_r($save); echo '</pre>'; } if ((int) $id > 0) { if ($dup_id < 1) { $action = 'Saved'; $msg = 'Saved - id:' . $id; } } else { $action = 'Saved Error'; $msg = $save->msg; } $res = self::makeLog($id, $action, $msg); return $res; }
public static function process($data, $params) { global $x; $params = self::check_params_df($params); // Some debug variables $x = isset($_GET['pim']); $x1 = isset($_GET['pim1']); // Debug if ($x1) { echo '<br /><br /><i><b>File</b> ' . __FILE__ . ' <b>Line</b> ' . __LINE__ . "</i><br />\n"; ogb_pr($params, 'Params: '); ogb_pr($data, 'Data: '); } $html = $data->html; $res = new stdClass(); $res->html = $html; $res->images = array(); // Debug if ($x) { echo '<br /><br /><i><b>File</b> ' . __FILE__ . ' <b>Line</b> ' . __LINE__ . "</i><br />\n"; //ogb_show($data->html,'data->html: '); } // if there is nothing set for the image path, store all images to /images/wppipes/ folder if ($params->get_image) { if ($params->image_local == '') { $params->image_local = 'images/wppipes'; } $html = self::copyImage($html, $data->url, $params); $res->html = $html; } else { return $res; } if ($params->makelist == 1) { $res = self::make_list($html, $params); // Debug if ($x) { echo '<br /><br /><i><b>File</b> ' . __FILE__ . ' <b>Line</b> ' . __LINE__ . "</i><br />\n"; ogb_pr($res, 'Imgs: '); } } return $res; }
public static function process($data, $params) { global $x; $params = self::check_params_df($params); // Some debug variables $x = isset($_GET['pim']); $x1 = isset($_GET['pim1']); // Debug if ($x1) { echo '<br /><br /><i><b>File</b> ' . __FILE__ . ' <b>Line</b> ' . __LINE__ . "</i><br />\n"; ogb_pr($params, 'Params: '); ogb_pr($data, 'Data: '); } if (isset($data->enclosure) && is_array($data->enclosure)) { $html = ''; foreach ($data->enclosure as $obj) { $enclosure = (array) $obj; if (isset($params->limit_width)) { $limit_period = explode(';', $params->limit_width); $width_img = isset($enclosure['width']) && $enclosure['width'] > 0 ? $enclosure['width'] : 0; if (count($limit_period) > 1 && ((int) $limit_period[0] > $width_img || $width_img > (int) $limit_period[1])) { continue; } } if (strpos($enclosure['type'], 'image') !== false) { $html .= '<img src="' . $enclosure['link'] . '" title="' . $enclosure['title'] . '">'; } } } else { $html = $data->html; } $res = new stdClass(); $res->html = $html; $res->images = array(); // Debug if ($x) { echo '<br /><br /><i><b>File</b> ' . __FILE__ . ' <b>Line</b> ' . __LINE__ . "</i><br />\n"; //ogb_show($data->html,'data->html: '); } // if there is nothing set for the image path, store all images to /images/wppipes/ folder if ($params->get_image) { if ($params->image_local == '') { $params->image_local = 'images/wppipes'; } $html = self::copyImage($html, $data->url, $params); $res->html = $html; } else { return $res; } if ($params->makelist == 1) { $res = self::make_list($html, $params); // Debug if ($x) { echo '<br /><br /><i><b>File</b> ' . __FILE__ . ' <b>Line</b> ' . __LINE__ . "</i><br />\n"; ogb_pr($res, 'Imgs: '); } } if (empty($res->images) && $params->stop_if_empty == 1) { $stop = new stdClass(); $stop->state = true; $stop->msg = 'no images found'; $res->stop = $stop; return $res; } if (isset($params->default_img) && $params->default_img != '') { $default_img = new stdClass(); $default_img->html = "<img src=\"{$params->default_img}\" alt=\"The default image\">"; $default_img->src = $params->default_img; if (empty($res->images)) { $res->images[] = $default_img; } } return $res; }