title -> default
function asl_link( $attributes ) {
$app = asl_get_appdata(asl_extract_id($attributes));
$linkshare = asl_extract_linkshare($attributes);
$img = asl_extract_img($attributes);
$title = asl_extract_title($attributes);
$baseurl = $app->trackViewUrl;
if(!$linkshare) { $url = $baseurl; }
else { $url = "http://click.linksynergy.com/fs-bin/stat?id=".$linkshare."&offerid=146261&type=3&subid=0&tmpid=1826&RD_PARM1=" . urlencode(urlencode($baseurl)) . "%2526uo%253D4%2526partnerId%253D30"; }
$return = '';
if ($img) { $return .= ''; }
elseif ($title) { $return .= $title; }
else { $return .= 'Download'; }
$return .= '';
return $return;
}
//displays appname
function asl_name( $attributes ) {
$app = asl_get_appdata(asl_extract_id($attributes));
return $app->trackName;
}
//displays icon as img
function asl_icon ($attributes) {
$app = asl_get_appdata(asl_extract_id($attributes));
$url = $app->artworkUrl100;
$thumb = asl_extract_thumb($attributes);
$w = asl_extract_w($attributes);
$q = asl_extract_q($attributes);
if ($thumb) { $url = asl_timthumb_icon($url, $w, $q); }
return '
';
}
//displays genre
function asl_genre ($attributes) {
$app = asl_get_appdata(asl_extract_id($attributes));
return $app->primaryGenreName;
}
//displays price
function asl_price ($attributes) {
$app = asl_get_appdata(asl_extract_id($attributes));
return $app->formattedPrice;
}
//displays version
function asl_version ($attributes) {
$app = asl_get_appdata(asl_extract_id($attributes));
return $app->version;
}
//displays description
function asl_description ($attributes) {
$len = asl_extract_len($attributes);
$app = asl_get_appdata(asl_extract_id($attributes));
$return = nl2br($app->description);
if ($len) {
$i=0; $text='';
$arr = explode("\n", $return);
while ($i < $len) {
$text .= $arr[$i];
$i++;
}
$return=$text;
}
return $return;
}
//displays seller
//optional parameter link = true to display as a link
function asl_seller ($attributes) {
$app = asl_get_appdata(asl_extract_id($attributes));
$link = asl_extract_link($attributes);
if ($link) { $return = ''.$app->sellerName.''; }
else { $return = $app->sellerName; }
return $return;
}
//displays filesize parsed based on... file size
function asl_filesize ($attributes) {
$app = asl_get_appdata(asl_extract_id($attributes));
return formatBytes($app->fileSizeBytes, 2);
}
//displays release notes
function asl_release_notes ($attributes) {
$app = asl_get_appdata(asl_extract_id($attributes));
return nl2br($app->releaseNotes);
}
//displays average user rating
//optional parameter to display only current version
function asl_rating ($attributes) {
$app = asl_get_appdata(asl_extract_id($attributes));
$current = asl_extract_current($attributes);
if (!$current) { return $app->averageUserRating; }
else { return $app->averageUserRatingForCurrentVersion; }
}
//displays number of ratings
//optional parameter to display only current version
function asl_num_ratings ($attributes) {
$app = asl_get_appdata(asl_extract_id($attributes));
$current = asl_extract_current($attributes);
if (!$current) { return $app->userRatingCount; }
else { return $app->userRatingCountForCurrentVersion; }
}
//displays release date
//optional parameter dateformat
function asl_release_date ($attributes) {
$app = asl_get_appdata(asl_extract_id($attributes));
$dateformat = asl_extract_dateformat($attributes);
if (!$dateformat) { $dateformat = 'F j, Y'; }
return date($dateformat, strtotime(substr($app->releaseDate, 0, 10)));
}
//displays content rating
function asl_content_rating ($attributes) {
$app = asl_get_appdata(asl_extract_id($attributes));
return $app->contentAdvisoryRating;
}
//displays one or multiple screenshots as an unordered list
//Optional parameter first to show only first screenshot
//Optional parameter type to prefer ipad. Prefers iPhone/Mac AppStore by default.
//will verify ipad screenshots exist before displaying, and if not, will show iphone screenshots anyway
//Optional parameters thumb, w, h to use timthumb
function asl_screenshots ($attributes) {
$app = asl_get_appdata(asl_extract_id($attributes));
$first = asl_extract_first($attributes);
$type = asl_extract_type($attributes);
$thumb = asl_extract_thumb($attributes);
$w = asl_extract_w($attributes);
$q = asl_extract_q($attributes);
$i=0;
$return = '
That app ID was not found.'.$id.'
' ); } else { return $appdata->results[0]; } } //gets data via fopen function asl_fopen ($url) { return file_get_contents($url); } //gets data via curl (preferred) function asl_curl ($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $output = curl_exec($ch); curl_close($ch); return $output; } //chooses fopen or curl based on server function asl_fopen_or_curl($url) { if (function_exists('curl_exec')) return asl_curl($url); elseif(function_exists('file_get_contents') && ini_get('allow_url_fopen')) return asl_fopen($url); else wp_die('You must have either file_get_contents() or curl_exec() enabled on your web server.
'); } $asl_settings = array(); function asl_setting($name) { global $asl_settings; $asl_settings = get_option('asl_plugin'); if(!$asl_settings) { asl_add_defaults(); $asl_settings = get_option('asl_plugin'); } return $asl_settings[$name]; } function asl_set_setting($name, $value) { global $asl_settings; $asl_settings = get_option('asl_plugin'); if(!$asl_settings) { asl_add_defaults(); $asl_settings = get_option('asl_plugin'); } $asl_settings[$name] = $value; } //utility functions function is_iphone() { return (strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod')) ? true : false; } // adds smart app banner automatically if appId is set function asl_add_smart_app_banner() { if (is_single()) { $check = get_post_meta(get_the_ID(), 'appId', true); $show = true; //we do not want to show ipad app smart banners to iphone users //probably we should do this check either, but iphone apps do work on ipad, so we'll let that slide $iphone = is_iphone(); if ($iphone) { //if so if the user is on an iphone, get the app data so we can check $app = asl_get_appdata($check); if (!isset($app->screenshotUrls[0])) { $show=false; } //if we don't have them, then we're not on an iphone-friendly build } if ($show) { $linkshare = asl_setting('linkshareid'); if ($check) { $metaString = 'error("Could not create the file cache directory."); return false; } } } //vars $mins = asl_setting('json_cache'); $cache = dirname(__FILE__).'/cache/asl_'.md5($url).'.txt'; $current_time = time(); $expire_time = $mins * 60; $file_time = @filemtime($cache); //do we use the cache or the file? if(file_exists($cache) && ($current_time - $expire_time < $file_time)) { //echo 'returning from cached file'; return file_get_contents($cache); } else { $content = asl_fopen_or_curl($url); file_put_contents($cache, $content); return file_get_contents($cache); } } ?>