/** * get information about album from cincopa in json format * @param string $albumId - album id * @return json */ function wiziapp_cincopaJson($albumId) { $url = wiziapp_cincopaUrl('json') . urlencode($albumId); $GLOBALS['WiziappLog']->write('info', "About to request a cincopa album with the url: {$url}", "wiziapp_get_cincopa_albums"); $content = wiziapp_general_http_request('', $url, 'GET'); $content = $content['body']; $content = str_replace(array("'"), array("\""), substr($content, 6, -1)); $content = preg_replace('/([a-z_]*):"/', '"$1":"', $content); $content = preg_replace('/([a-z_]*):\\[/', '"$1":[', $content); $content = preg_replace('/id:/', '"id":', $content); $json = json_decode($content); return $json; }
/** * check witch rating plugin exist in wp and return rating of post * @param int $postId - the post id * @return floatval - rating of post */ function wiziapp_get_rating($postId) { $postId = intval($postId); //polldaddy rating $id = get_option('pd-rating-posts-id'); if (function_exists('polldaddy_show_rating_comments') && $id > 0) { $url = 'http://polldaddy.com/ratings/rate.php?'; $url_query = array(); $url_query['cmd'] = 'get'; $url_query['id'] = get_option('pd-rating-posts-id'); $url_query['uid'] = 'wp-post-' . $postId; $url_query['item_id'] = '_post_' . $postId; $link = $url . http_build_query($url_query); $matches = array(); $get_content = wiziapp_general_http_request('', $link, 'GET'); $get_content = $get_content['body']; preg_match("/\\.avg_rating = ([a-z0-9]*)/", $get_content, $matches); return wiziapp_convert_rating($matches[1], 5); } //GD Star rating global $gdsr; if (is_object($gdsr) && get_class($gdsr) == 'GDStarRating' && $postId > 0) { $rating = $gdsr->get_article_rating($postId); return wiziapp_convert_rating($rating[1] / $rating[0], $gdsr->o['stars']); } //WP-PostRatings if (function_exists('process_ratings') && function_exists('get_post_custom') && $postId > 0) { $post_ratings_data = get_post_custom($postId); return wiziapp_convert_rating($post_ratings_data['ratings_average'][0], intval(get_option('postratings_max'))); } }
function _handleYouTubeVideo($src) { $obj = array(); // Cut the parameters if (strpos($src, '&') !== FALSE) { $tmp = substr($src, 0, strpos($src, '&')); $youTubeId = str_replace('http://www.youtube.com/v/', '', $tmp); } else { // can be: http://www.youtube.com/v/SKdyMjsZjj8?fs=1 //http://www.youtube.com/watch?v=FCXlCkY4Y5g if (strpos($src, '/watch?') !== FALSE) { $qs = array(); parse_str(substr($src, strpos($src, "?") + 1), $qs); $youTubeId = $qs['v']; } else { $tmp = substr($src, strrpos($src, '/') + 1); if (strpos($tmp, '?') !== FALSE) { $youTubeId = substr($tmp, 0, strpos($tmp, '?')); } else { $youTubeId = $tmp; } } } /** * Get the information about the video from the formal API */ $apiUrl = "http://gdata.youtube.com/feeds/api/videos/"; if (strpos($youTubeId, '?') === FALSE) { $apiUrl .= $youTubeId . "?alt=json"; } else { $apiUrl .= $youTubeId . "&alt=json"; } $response = wiziapp_general_http_request(array(), $apiUrl, 'GET', array()); if (!is_wp_error($response)) { $json = $response['body']; $youTubeResponse = json_decode($json, TRUE); if (is_array($youTubeResponse)) { $movie = $youTubeResponse['entry']; // $GLOBALS['WiziappLog']->write('info', ">>> Got YouTube response: " . print_r($youTubeResponse, TRUE), "_handleYouTubeVideo"); //$thumbsCount = count($movie['media$group']['media$thumbnail']); // $bigThumbElement = $movie['media$group']['media$thumbnail'][$thumbsCount - 1]; $bigThumbElement = $movie['media$group']['media$thumbnail'][0]; $youTubeShortId = $youTubeId; if (strpos($youTubeShortId, '?') !== FALSE) { $youTubeShortId = substr($youTubeShortId, 0, strpos($youTubeShortId, '?')); } if (isset($movie['media$group']['yt$duration']['seconds'])) { $obj = array('title' => str_replace('&', '&', $movie['title']['$t']), 'date' => $movie['published']['$t'], 'thumb' => $movie['media$group']['media$thumbnail'][0]['url'], 'bigThumb' => array('url' => $bigThumbElement['url'], 'width' => $bigThumbElement['width'], 'height' => $bigThumbElement['height']), 'description' => str_replace('&', '&', $movie['content']['$t']), 'duration' => $movie['media$group']['yt$duration']['seconds'], 'actionURL' => wiziapp_buildVideoLink('youtube', $youTubeShortId, 'http://www.youtube.com/watch?v=' . $youTubeShortId . '&fmt=18')); } } } return $obj; }