";
const IMG_CODE = " ";
const BASE_URL = 'http://www.photoshelter.com';
var $psc;
function __construct(&$client) {
$this->psc = $client;
}
function render_session_error(){
echo 'Oops! Looks like your session has expired. Click here to log back in.
';
}
function render_tabs($current = 'browse') {
echo '';
}
function render_header($term = '') {
echo "";
echo "";
echo "
";
}
function iframeURL($opts) {
$iframe_src = "media-upload.php?post_id=$uploading_iframe_ID";
$iframe_src = apply_filters('iframe_src', "$iframe_src&type=shelter");
return $iframe_src . '&TB_iframe=true&height=500&width=640' . $opts;
}
function listGalleries() {
try {
$dat = $this->psc->gal_qry($_GET['_bqO'], $_GET['_bqH']);
} catch(Exception $e) {
$this->render_session_error();
return;
}
$this->render_tabs();
echo '';
echo '
';
$this->render_header();
echo '
';
$this->render_pag($dat['pag']);
echo '
';
}
function render_pag($pag, $opts = '') {
$totalPages = count($pag->s);
$currentOff = (int) $pag->o;
$blockSize = (int) $pag->b;
$hash = (string) $pag->h;
if ($totalPages > 1) {
echo "";
}
}
function listImages($G_ID, $G_NAME) {
try {
$dat = $this->psc->img_qry($G_ID, $_GET['_bqO'], $_GET['_bqH']);
} catch(Exception $e) {
$this->render_session_error();
return;
}
$this->render_tabs();
echo '';
echo '
« back to galleries ';
echo '
';
echo '
Click an image to view options or embed a slideshow .';
$this->render_images($dat['images'], $G_ID, $G_NAME);
$this->render_pag($dat['pag'], '&G_ID=' . $G_ID);
echo '
';
}
function searchImages($term) {
try {
$dat = $this->psc->img_search($term, $_GET['_bqO'], $_GET['_bqH']);
} catch(Exception $e) {
$this->render_session_error();
return;
}
$this->render_tabs();
echo '';
$this->render_header($term);
echo '
« back to galleries ';
if (count($dat['images']) == 0) {
echo '
No results found. Please note that images are only returned if they are publicly searchable. ';
} else {
echo '
';
$this->render_images($dat['images']);
$this->render_pag($dat['pag'], '&I_DSC=' . urlencode($term));
}
echo "
";
}
function render_images($images, $G_ID = null, $G_NAME = null) {
echo '';
}
function embedImg($I_ID, $G_ID, $G_NAME) {
try {
$image = $this->psc->img_get($I_ID);
} catch(Exception $e) {
$this->render_session_error();
return;
}
if (stripos($_SERVER['HTTP_REFERER'], 'recent') != false) {
$this->render_tabs('recent');
} else {
$this->render_tabs();
}
echo '';
$default_width = get_option('photoshelter_default_width', '600');
if ($G_ID) {
echo '
« back to gallery ';
}
echo '
';
}
function insertImg($I_ID, $G_ID, $width, $f_html, $f_bar = false, $g_name, $f_cap = false) {
update_option('photoshelter_default_width', $width);
$image = $this->psc->img_widget_get($I_ID);
$pattern = '/^http:\/\/([^.]*).photoshelter.com/';
preg_match($pattern, (string) $image['channel']->item->link, $label);
$img_width = (int) $image['channel']->item->children('ps', true)->width;
$img_height = (int) $image['channel']->item->children('ps', true)->height;
$caption = (string) $image['channel']->item->children('media', true)->description;
$credit = (string) $image['channel']->item->children('media', true)->credit;
$ttl = trim($image['channel']->item->children('ps', true)->iptc_title);
$hdln = trim($image['channel']->item->children('media', true)->title);
// get file name
$url_with_filename = (string) $image['channel']->item->enclosure['url'];
$file_name = preg_split('/\//', $url_with_filename);
$file_name = $file_name[count($file_name)-1];
//remove extension and replace with .jpg
$file_name = preg_split('/\./', $file_name);
if (count($file_name > 1)) {
array_pop($file_name);
}
$file_name = implode('.', $file_name);
$file_name .= '.jpg';
if($G_ID) {
$photoshelter_link = $label[0] . '/gallery-image/' .$this->dashify($g_name) . '/' . $G_ID . '/' . $I_ID;
} else {
$photoshelter_link = $label[0] . '/img-show/' . $I_ID;
}
//casecase title / headline / credit as image title
$img_title_alt = (!empty($hdln)) ? $hdln : 'Photo By: ' . $credit;
$img_title = (!empty($ttl)) ? $ttl : $img_title_alt;
$img_title = htmlentities($img_title, ENT_QUOTES);
//caption and credit as ALT
$alt = trim($caption) . ' (' . trim($credit) . ')';
$alt = htmlentities($alt, ENT_QUOTES);
if (isset($f_bar) && $f_bar == true) {
$b = 0;
} else {
$b = 1;
}
$height = floor($img_height * ($width / $img_width));
if ($f_html == 'true') {
$insert_string = ' ';
} else {
$height += 20;
$insert_string = "[photoshelter-img width='".$width."' height='".$height."' i_id='".$I_ID."' buy='".$b."']";
}
if($f_cap == 'on') {
$insert_string = '[caption align=\"alignnone\" width=\"'.$width.'\" caption=\"'.$caption.'\"]'.$insert_string.'[/caption]';
}
//make sure not to break the JS sring
$insert_string = preg_replace('/(?:(?:\r\n|\r|\n)\s*){2}/s', " ", $insert_string);
$this->output($insert_string);
}
function output($string) {
echo '';
}
function embedGallery($G_ID, $G_NAME) {
try {
$presets = $this->psc->ss_preset_qry();
} catch (Exception $e) {
$this->render_session_error();
return;
}
$this->render_tabs();
echo '';
$default_width = get_option('photoshelter_default_width', '600');
echo '
« back to galleries ';
echo '
';
echo '
';
}
function insertGallery($G_ID, $D_ID, $G_NAME) {
if ($D_ID == '-1') {
//DEFAULTS
$pset['width'] = 600;
$pset['f_fullscreen'] = 't';
$pset['bgtrans'] = 't';
$pset['pho_credit'] = "iptc";
$pset['twoup'] = "f";
$pset['f_bbar'] = "t";
$pset['f_bbarbig'] = "f";
$pset['fsvis'] = "f";
$pset['f_show_caption'] = "t";
$pset['crop'] = "f";
$pset['f_enable_embed_btn'] = "t";
$pset['f_htmllinks'] = "t";
$pset['f_l'] = "t";
$pset['f_send_to_friend_btn'] = "f";
$pset['f_show_slidenum'] = "t";
$pset['f_topbar'] = "f";
$pset['f_show_watermark'] = "t";
$pset['img_title'] = "casc";
$pset['linkdest'] = "c";
$pset['trans'] = "xfade";
$pset['target'] = "_self";
$pset['tbs'] = 5000;
$pset['f_link'] = 't';
$pset['f_smooth'] = 'f';
$pset['f_mtrx'] = 't';
$pset['f_ap'] = 't';
$pset['f_up'] = 'f';
$pset['height'] = floor($pset['width']*2/3);
$pset['btype'] = 'old';
$pset['bcolor'] = '#CCCCCC';
} else {
try {
$preset = $this->psc->ss_preset_get($D_ID, $G_ID);
$galleries = $this->psc->gal_qry();
$pset = (array) $preset->D_DAT;
} catch (Exception $e) {
$this->render_session_error();
return;
}
}
$output = "";
foreach($pset as $key => $value) {
$output .= $key . '=\''.$value.'\' ';
}
$embed_code = '[photoshelter-gallery g_id=\''.$G_ID.'\' g_name=\''.$this->dashify($G_NAME).'\' '.$output.']';
$this->output($embed_code);
}
function insertGalleryImage($G_ID, $G_NAME, $WIDTH = 600) {
update_option('photoshelter_default_width', $WIDTH);
$galleryURL = PSIframe::BASE_URL . '/gallery/'.$this->dashify($G_NAME).'/' . $G_ID;
$keyImg = PSIframe::BASE_URL . '/gal-kimg-get/'.$G_ID.'/s/' . $WIDTH;
$return = " ";
$this->output($return);
}
function recent_images() {
try {
$dat = $this->psc->img_search(null, $_GET['_bqO'], $_GET['_bqH']);
} catch(Exception $e) {
$this->render_session_error();
return;
}
$this->render_tabs('recent');
echo '';
echo '';
$this->render_images($dat['images']);
$this->render_pag($dat['pag'], '&recent=t');
echo "
";
}
/*!\brief replaces non-alphas with -'s for SEO friendliness
*/
function dashify($string)
{
$trA = array('\'' => '');
//downconvert inflected chars from unicode
//oof, slows conversion by 4x - remove if draining
$trA["\xE1"] = "a"; $trA["\xC1"] = "A";
$trA["\xE2"] = "a"; $trA["\xC2"] = "A";
$trA["\xE0"] = "a"; $trA["\xC0"] = "A";
$trA["\xE5"] = "a"; $trA["\xC5"] = "A";
$trA["\xE3"] = "a"; $trA["\xC3"] = "A";
$trA["\xC4"] = "A"; $trA["\xE4"] = "a";
$trA["\xE7"] = "c"; $trA["\xC7"] = "C";
$trA["\xD0"] = "E"; $trA["\xF0"] = "e";
$trA["\xC9"] = "E"; $trA["\xE9"] = "e";
$trA["\xCA"] = "E"; $trA["\xC8"] = "E";
$trA["\xCB"] = "E"; $trA["\xEB"] = "e";
$trA["\xCD"] = "I"; $trA["\xED"] = "i";
$trA["\xCE"] = "I"; $trA["\xEE"] = "i";
$trA["\xCC"] = "I"; $trA["\xEC"] = "i";
$trA["\xCF"] = "I"; $trA["\xEF"] = "i";
$trA["\xD1"] = "N"; $trA["\xF1"] = "n";
$trA["\xD3"] = "O"; $trA["\xE8"] = "e";
$trA["\xF3"] = "o"; $trA["\xE6"] = "ae";
$trA["\xD4"] = "O"; $trA["\xF4"] = "o";
$trA["\xF2"] = "o"; $trA["\xD2"] = "O";
$trA["\xD8"] = "O"; $trA["\xF5"] = "o";
$trA["\xF8"] = "o"; $trA["\xD5"] = "O";
$trA["\xD6"] = "O"; $trA["\xF6"] = "o";
$trA["\xFE"] = "t"; $trA["\xDE"] = "T";
$trA["\xDA"] = "U"; $trA["\xFA"] = "u";
$trA["\xDB"] = "U"; $trA["\xFB"] = "u";
$trA["\xD9"] = "U"; $trA["\xF9"] = "u";
$trA["\xDC"] = "U"; $trA["\xFC"] = "u";
$trA["\xDD"] = "Y"; $trA["\xFD"] = "y";
$trA["\xFF"] = "y";
$string = strtr($string, $trA);
$string = preg_replace('/[^[:alnum:]]+/', '-', $string);
$string = trim($string, '-');
if (!$string) $string = '-'; //in case entire str is dashed
return rawurlencode($string);
}
}
?>