'bgtrans', 'f_l' => 'f_htmllinks', 'f_fscr' => 'f_fullscreen', 'f_tb' => 'f_topbar', 'f_bb' => 'f_bbar', 'f_bbl' => 'f_bbarbig', 'f_fss' => 'fsvis', 'f_2up' => 'twoup', 'f_crp' => 'crop', 'f_wm' => 'f_show_watermark', 'f_s2f' => 'f_send_to_friend_btn', 'f_emb' => 'f_enable_embed_btn', 'f_cap' => 'f_show_caption', 'f_sln' => 'f_show_slidenum', 'ldest' => 'linkdest', 'imgT' => 'img_title', 'cred' => 'pho_credit', 'trans' => 'trans', 'target' => 'target', 'f_link' => 'f_link', 'f_smooth' => 'f_smooth', 'f_mtrx' => 'f_mtrx', 'tbs' => 'tbs', 'f_ap' => 'f_ap', 'f_up' => 'f_up', 'btype' => 'btype', 'bcolor' => 'bcolor' ); $flsv = ''; foreach($map as $k => $v) { $flsv .= '&'.$k.'='; if (isset($atts[$v])) { $flsv .= urlencode($atts[$v]); } } if (isset($atts['wmds'])) { $flsv .= '&wmds=' . urlencode($atts['wmds']); } $fullscreen = $atts['f_fullscreen'] == 't' ? 'true' : 'false'; $movie = PSIframe::BASE_URL . '/swf/CSlideShow.swf?feedSRC=' . urlencode(PSIframe::BASE_URL . '/gallery/' . $atts['g_id'] . '?feed=json&ppg=1000'); $keyImg = PSIframe::BASE_URL . '/gal-kimg-get/'.$atts['g_id'].'/s/' . $atts['width']; $galleryURL = PSIframe::BASE_URL . '/gallery/'.$atts['g_name'].'/' . $atts['g_id']; $embed_code = PSIframe::EMBED_CODE; $embed_code = preg_replace('/{{fv}}/', $flsv, $embed_code); $embed_code = preg_replace('/{{width}}/', $atts['width'], $embed_code); $embed_code = preg_replace('/{{height}}/', $atts['height'], $embed_code); $embed_code = preg_replace('/{{bgcolor}}/', $atts['bgcolor'], $embed_code); $embed_code = preg_replace('/{{wmode}}/', ($atts['bgtrans'] == 't') ? 'transparent' : 'opaque' , $embed_code); $embed_code = preg_replace('/{{fullscreen}}/', $fullscreen, $embed_code); $embed_code = preg_replace('/{{movie}}/', $movie, $embed_code); $embed_code = preg_replace('/{{imgsrc}}/', $keyImg, $embed_code); $embed_code = preg_replace('/{{galleryurl}}/', $galleryURL, $embed_code); $embed_code = preg_replace('/{{galleryname}}/', $atts['g_name'], $embed_code); return $embed_code; } function photoshelter_img_handler($atts, $content=null, $code="") { $embed_code = PSIframe::IMG_CODE; $embed_code = preg_replace('/{{url}}/', PSIframe::BASE_URL, $embed_code); $embed_code = preg_replace('/{{i_id}}/', $atts['i_id'], $embed_code); $embed_code = preg_replace('/{{width}}/', $atts['width'], $embed_code); $embed_code = preg_replace('/{{height}}/', $atts['height'], $embed_code); $embed_code = preg_replace('/{{buy}}/', $atts['buy'], $embed_code); return $embed_code; } function photoshelter_activate() { if (version_compare(phpversion(), '5.0', '<')) { trigger_error('', E_USER_ERROR); } } if ($_GET['action'] == 'error_scrape') { die("

This PhotoShelter plugin requires PHP 5.0 or higher, cURL and WordPress 2.9 or above. Please contact your web host and ask them enable PHP 5.0 or above and cURL. Please deactivate the PhotoShelter plugin.

"); } function system_requirement_dialog() { $wp_req = $this->verify_wp(); if( is_wp_error( $wp_req ) ) return $wp_req->get_error_message(); $php_req = $this->verify_php(); if( is_wp_error( $php_req ) ) return $php_req->get_error_message(); $curl_req = $this->verify_http(); if( is_wp_error( $curl_req ) ) return $curl_req->get_error_message(); $simplexml_req = $this->verify_simplexml(); if( is_wp_error( $simplexml_req ) ) return $simplexml_req->get_error_message(); return true; } function verify_wp() { global $wp_version, $wpmu_version; $wpver = ( defined('IS_WPMU') ) ? $wpmu_version : $wp_version; if( version_compare( $wpver, $this->wp_min_req, '<' ) ) return new WP_Error( 'ps_wp_version_err', sprintf(__('You must be running at least WordPress or WordPress MU %s', 'photoshelter'), $this->wp_min_req ) ); return true; } function verify_php() { if( version_compare( PHP_VERSION, '5.0', '<' ) ) return new WP_Error( 'ps_php_version_err', sprintf(__('Your system must meet the following requirements to use the PhotoShelter Official Plugin: WordPress 2.9 or higher, PHP 5.0 or higher, and cURL. Please upgrade accordingly or contact your web host for help. We recommend deactivating the plugin in the meantime.', 'photoshelter'), $this->php_min_req ) ); return true; } function verify_http() { if( !function_exists('curl_exec') ) return new WP_Error( 'ps_curl_exists', __('Your PHP build does not support cURL. This plugin requires cURL to use the Photoshelter API. Please contact your host and ask them to add cURL support.', 'photoshelter') ); return true; } function verify_simplexml() { if( !function_exists('simplexml_load_file') ) return new WP_Error( 'ps_simplexml_err', __('Your PHP build does not support simplexml. This plugin requires simplexml to use the Photoshelter API. Please contact your host and ask them to add simplexml support.', 'photoshelter') ); return true; } function add_menu() { add_menu_page('PS Option page', 'PhotoShelter', 'administrator', 'photoshelter-admin', 'ps_option_page', WP_PLUGIN_URL . '/photoshelter-official-plugin/img/ps_menu_icon.png'); } function ps_admin_css() { ?>

Which account would you like to use?

' . __('Not Logged In','photoshelter') . '

'; } if (!$psc->logged_in && get_option('photoshelter_logged_in') != '1') { echo '

' . get_option('photoshelter_logged_in') . '

'; } ?>
auth(); wp_safe_redirect( 'admin.php?page=photoshelter-admin' ); } function process_photoshelter_org() { global $psc; if(!isset($_POST['ps_org_auth'])) { return false; } check_admin_referer('photoshelter_admin_pick_org'); $result = $psc->org_auth($_POST['O_ID']); wp_safe_redirect( 'admin.php?page=photoshelter-admin' ); } function media_upload_shelter() { wp_iframe( 'media_upload_type_shelter'); } function media_upload_type_shelter() { // wp_iframe content //global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types; //global $foldername, $pshttp; global $psc; $cookie = get_option('ps_cookies'); $offset = count( $cookie ) - 1; $last_cookie = $cookie['ch_' . $offset]; if( $last_cookie ) { include( plugin_basename('photoshelter-iframe.php') ); } else { $admin_url = admin_url(); echo '

Oops! Looks like you haven\'t entered your PhotoShelter account details yet.

'; } } function logout() { if( isset($_POST['photoshelter_logout']) && $_POST['photoshelter_logout'] == 'logout' ) { check_admin_referer('photoshelter_admin_logout'); delete_option('ps_cookies'); delete_option('photoshelter'); wp_safe_redirect( 'admin.php?page=photoshelter-admin' ); } } function add_photoshelter_button() { global $post_ID, $temp_ID; //location of wordpress plugin folder $pluginURI = WP_PLUGIN_URL . '/photoshelter-official-plugin'; // the id of the post or whatever for media uploading $uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID); $iframe_src = "media-upload.php?post_id=$uploading_iframe_ID"; $iframe_src = apply_filters('iframe_src', "$iframe_src&type=shelter"); $title = __('Add PhotoShelter photo'); echo "\"$title\""; } include_once( WP_PLUGIN_DIR . '/photoshelter-official-plugin/photoshelter_client.php'); $GLOBALS['psc'] = new Photoshelter_Client(); //$GLOBALS['ps_errors'] = new WP_Error; add_action( 'init', 'process_photoshelter_login' ); add_action( 'init', 'process_photoshelter_org' ); add_action( 'init', 'logout', 1 ); // add media button add_action( 'admin_menu','add_menu'); add_action( 'admin_head', 'ps_admin_css'); add_action( 'media_buttons', 'add_photoshelter_button', 20); add_action('media_upload_shelter', 'media_upload_shelter'); ?>