Fix Issue #1833 by upgrading ShareYourCart SDK to v1.10

This commit is contained in:
Andrei Barabas 2012-12-12 17:58:54 +02:00
parent 8622f7bdc6
commit b8b5471f4d
8 changed files with 193 additions and 188 deletions

View File

@ -17,22 +17,22 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
//this array is used to hold function calls between different instances of this class
private static $_SINGLE_FUNCTIONS_CALLS = array();
private static $_SDK_VERSION = '1.9'; //the first one is the SDK main version, while the second one is it's revision
private static $_SDK_VERSION = '1.10'; //the first one is the SDK main version, while the second one is it's revision
protected static $_DB_VERSION = '1.1';
protected $SDK_ANALYTICS = true;
/**
* Constructor
* @param null
*/
function __construct() {
//set exception handler
if(set_exception_handler(array(&$this,'UncaughtExceptionHandler')) !== null)
restore_exception_handler(); //if there allready was an exception handler, revert back to it
parent::__construct();
//now, add the api version to the button_js, in order to force users to download the latest
//JS file
if(!$this->isDebugMode()){
@ -41,12 +41,12 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
$this->SHAREYOURCART_BUTTON_JS = $this->SHAREYOURCART_API.'/js/button.dev.js';
}
$this->SHAREYOURCART_BUTTON_URL .= '?client_id='. $this->getClientId();
//set the language & it's loader
SyC::setLanguageLoader(array(&$this,'loadLanguage'));
SyC::setLanguage($this->getConfigValue('lang'));
}
/**
* Execute NonQuery SQL
* @param string action
@ -96,10 +96,10 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
* @return boolean / array
*/
protected function getCurrentProductDetails(){
return FALSE;
}
/**
*
* Return TRUE if this page describes a single product, otherwise FALSE
@ -115,7 +115,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
public function isOutOfStock(){
return FALSE;
}
/**
*
* Return the URL to be called when the button is pressed
@ -159,7 +159,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
*
*/
protected abstract function applyCoupon($coupon_code);
/**
*
* Return the jQuery sibling selector for the product button
@ -168,7 +168,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
protected function getProductButtonPosition(){
return $this->getConfigValue('product_button_position');
}
/**
*
* Return the jQuery sibling selector for the cart button
@ -177,7 +177,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
protected function getCartButtonPosition(){
return $this->getConfigValue('cart_button_position');
}
/**
*
* Get the plugin version.
@ -196,10 +196,10 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
//make sure a developer enters only a number as a version
if(!is_int($minor_version = $this->getPluginVersion()))
throw new Exception(SyC::t('sdk','The Plugin Version must be an integer'));
return self::$_SDK_VERSION.'.'.$minor_version;
}
/**
*
* Returns TRUE if the account is in debug mode
@ -208,10 +208,10 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
public function isDebugMode()
{
$val =$this->getConfigValue('debug');
return !empty($val);
}
/**
*
* Return TRUE if there is a newer version of the plugin
@ -221,7 +221,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
{
return version_compare($this->getVersion(),$this->getConfigValue('latest_version'),'<');
}
/**
*
* Check if this instance can load, or not!
@ -230,14 +230,14 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
*/
protected function canLoad()
{
$v = version_compare($this->getVersion(),$this->getConfigValue('plugin_current_version'));
$v = version_compare($this->getVersion(),$this->getConfigValue('plugin_current_version'));
//first, check if this instance is the latest one, or not
if($v < 0) return false;
//save the latest version, for later reference
if($v > 0 )
$this->setConfigValue('plugin_current_version',$this->getVersion());
return true;
}
@ -275,10 +275,10 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
$appKey = $this->getAppKey();
$clientId = $this->getClientId();
if(!empty($appKey) && !empty($clientId)){
$activated = $this->activate($message);
}
//set some default value, like the button skin
$skin = $this->getConfigValue('button_skin');
if(empty($skin)){
@ -400,11 +400,11 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
//reset the Location, as the following code might give an error
//and the developer needs to be aware of it
$headers = headers_list();
header('Location:');
header('Location:');
//save session details
$this->insertRow($this->getTableName('shareyourcart_tokens'), $data);
//we can't rely on the fact that the row has been inserted, so check!
if($this->getSessionId($data['token']) === null)
throw new Exception(SyC::t('sdk','Token cannot be saved. Check your "{table_name}" table permissions.', array('{table_name}' => $this->getTableName('shareyourcart_tokens'))));
@ -473,25 +473,26 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
* @param null
* @return boolean
*/
protected function renderButton($callback_url,$position = null) {
protected function renderButton($callback_url,$position = null,$languageISO = null) {
$data = array(
'current_button_type' => $this->getConfigValue("button_type"),
'button_html' => $this->getConfigValue("button_html"),
'button_img' => $this->getUrl($this->getConfigValue("btn-img")),
'button_img_width' => $this->getConfigValue("btn-img-width"),
'button_img_height' => $this->getConfigValue("btn-img-height"),
'button_img_hover' => $this->getUrl($this->getConfigValue("btn-img-h")),
'button_img_hover_width' => $this->getConfigValue("btn-img-h-width"),
'button_img_hover_height' => $this->getConfigValue("btn-img-h-height"),
'is_product_page' => $this->isSingleProduct(),
'position_'.(SyC::startsWith($position,"/*before*/") ? 'before' : 'after') => $position,
'language' => $languageISO,
);
$output = null;
switch ($data['current_button_type'])
{
@ -545,7 +546,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
*
*/
public function showCartButton() {
echo $this->getCartButton();
}
@ -607,11 +608,11 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
* @return boolean
*/
public function getAdminHeader() {
//this is a single call function
if (!$this->isFirstCall(__FUNCTION__))
return;
//check the SDK status
$this->checkSDKStatus(true); //force a check, as the admin might have changed the language in the configure page, so we need to sync with it
@ -642,7 +643,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
$status_message = ''; //this is to be used for good messages
$error_message = ''; //this is to be used for bad messages
$refresh = false;
//check if this is a post for this particular page
if ($_SERVER['REQUEST_METHOD'] == 'POST' &&
!empty($_POST['syc-account-form'])) {
@ -661,42 +662,42 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
//the account did not activate, so show the error
$error_message = $message;
}
//since we might have changed the status, REFRESH
$refresh = true;
}
//the user decided to disable the API
else if ($_SERVER['REQUEST_METHOD'] == 'POST' &&
!empty($_POST['disable-API'])){
$message = '';
if($this->deactivate($message) == true) {
$status_message = $message;
} else {
$error_message = $message;
}
//since we might have changed the status, REFRESH
$refresh = true;
}
//the user decided to activate the API
else if ($_SERVER['REQUEST_METHOD'] == 'POST' &&
!empty($_POST['enable-API'])){
$message = '';
if($this->activate($message) == true) {
$status_message = $message;
} else {
$error_message = $message;
}
//since we might have changed the status, REFRESH
$refresh = true;
}
}
//check if the user want's to recover his account
else if (@$_REQUEST['syc-account'] === 'recover'){
@ -708,22 +709,24 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
//try to recover if the user posted the form
$show_form = !$this->recover($this->getSecretKey(), @$_REQUEST['domain'], @$_REQUEST['email'], $status_message);
}
//if we need to show the form, the recovery failed
if($show_form)
{
//if there is a message, put the form on a new line
$error_message = $status_message;
$status_message = $this->renderView('account-recover-partial');
}
else
$status_message = $this->renderView('account-recover-partial', array(
'html' => $html,
));
}
else
{
//Refresh in order to get rid of the GET parameter
$refresh = true;
}
}
else if (@$_REQUEST['syc-account'] === 'create'){
//by default, show the form if we are here
$show_form = true;
if($_SERVER['REQUEST_METHOD'] == 'POST' &&
@ -733,14 +736,14 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
if(isset($_POST['syc-terms-agreement']))
{
//try to create the account if the user posted the form
if (!(($register = $this->register($this->getSecretKey(), @$_REQUEST['domain'], @$_REQUEST['email'], $status_message)) === false))
if (!(($register = $this->register($this->getSecretKey(), @$_REQUEST['domain'], @$_REQUEST['email'], $status_message)) === false))
{
$this->setConfigValue('appKey', @$register['app_key']);
$this->setConfigValue('clientId', @$register['client_id']);
$this->setConfigValue("account_status", "active");
$show_form = false; //no need to show the register form anymore
//since we might have changed the status, REFRESH
$refresh = true;
}
@ -751,19 +754,21 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
$status_message = SyC::t('sdk',"Error. You must agree with the terms and conditions bellow");
}
}
//if we need to show the form
if($show_form)
{
//move any message to errors
$error_message = $status_message;
$status_message = $this->renderView('account-create-partial');
$status_message = $this->renderView('account-create-partial', array(
'html' => $html,
));
}
}
//make sure there is a session variable setup
@session_start();
//since switching the API status has a great impact on how the UI looks, refresh the page
//just to make sure the UI is using the latest value
if($refresh)
@ -775,14 +780,14 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
else
{
//load the variables, if any
//if there is a status message
if(!empty($_SESSION['_syc_status_message']))
{
$status_message = $_SESSION['_syc_status_message'];
unset($_SESSION['_syc_status_message']);
}
//if there is an error message
if(!empty($_SESSION['_syc_error_message']))
{
@ -790,7 +795,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
unset($_SESSION['_syc_error_message']);
}
}
// Display the view
return $this->renderView('admin-page',array(
'html' => $html,
@ -830,7 +835,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
//set the button position
$this->setConfigValue("button_position", $_POST['button_position']);
//set the button height
$this->setConfigValue("dont_set_height", empty($_POST['show_on_single_row']));
@ -842,7 +847,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
//set the show'
$this->setConfigValue("hide_on_checkout", empty($_POST['show_on_checkout']));
//set button position
$this->setConfigValue("product_button_position",$_POST['product_button_position']);
$this->setConfigValue("cart_button_position",$_POST['cart_button_position']);
@ -851,13 +856,13 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
$target_path = $this->getUploadDir();
if(!SyC::endsWith($target_path,'/')) $target_path .= '/'; //make sure that the path has a / in it's end
$target_path = $target_path . 'button-img.png';
if(file_exists($target_path)) unlink($target_path);
list($width, $height, $type, $attr) = getimagesize($_FILES['button-img']['tmp_name']);
if (move_uploaded_file($_FILES['button-img']['tmp_name'], $target_path))
{
//set the button img
@ -879,7 +884,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
$target_path = $target_path . 'btn-img-hover.png';
if(file_exists($target_path)) unlink($target_path);
list($width, $height, $type, $attr) = getimagesize($_FILES['button-img-hover']['tmp_name']);
if(move_uploaded_file($_FILES['button-img-hover']['tmp_name'], $target_path))
@ -911,7 +916,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
'button_html' => $this->getConfigValue("button_html"),
'button_img' => $this->getUrl($this->getConfigValue("btn-img")),
'button_img_hover' => $this->getUrl($this->getConfigValue("btn-img-h")),
'html' => $html,
'show_header' => $show_header,
'show_footer' => $show_footer,
@ -928,7 +933,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
public function getUploadDir(){
return dirname(_FILE_). "/img/";
}
/**
* showDocumentation
* @param null
@ -953,13 +958,13 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
//render the view
return $this->renderView('documentation',array(
'action_url' => $this->getButtonCallbackURL(),
'html' => $html,
'show_header' => $show_header,
'show_footer' => $show_footer,
));
}
/**
* show the update notification
* @param null
@ -967,7 +972,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
public function showUpdateNotification(){
echo $this->getUpdateNotification();
}
/**
* get the update notification
* @param null
@ -1005,7 +1010,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
header("HTTP/1.0 403");
echo $e->getMessage();
if($this->isDebugMode()){
echo $e->getTraceAsString();
}
@ -1065,21 +1070,21 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
$sql .= "PRIMARY KEY ($primaryKey));";
$this->executeNonQuery($sql);
//we can't relly on the fact that the table has been properly created, so check it!
if(!$this->existsTable($tableName))
throw new Exception(SyC::t('sdk','Cannot create table "{table_name}". Check your database permissions or manually run the following SQL command and try again:<br /><strong>{sql}</strong>', array('{table_name}' => $tableName,'{sql}' => nl2br($sql))));
}
/**
*
* existsTable
* @return TRUE if the table exists, otherwise false
*/
protected function existsTable($tableName){
$table_details = $this->getRow("show tables like '$tableName'");
//if there are table details, it means the table exists
return !empty($table_details);
}
@ -1093,26 +1098,26 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
$sql = "DROP TABLE $tableName";
$this->executeNonQuery($sql);
//we can't relly on the fact that the table has been properly droped, so check it!
if($this->existsTable($tableName))
throw new Exception(SyC::t('sdk','Cannot drop table "{table_name}". Check your database permissions or manually run the following SQL command and try again:<br /><strong>{sql}</strong>', array('{table_name}' => $tableName, '{sql}' => nl2br($sql))));
}
/**
*
* Render the specified views. we use special variable names here to avoid conflict when extracting data
*
*/
protected function renderView($_viewName_, $_data_=NULL, $_return_=true){
//get information about the Top Parent class
$_reflection_ = new ReflectionClass(get_class($this));
$_viewFile_ = dirname($_reflection_->getFileName())."/views/$_viewName_.php";
//check if there is a file in the specified location
if(!file_exists($_viewFile_)){
//the view has not been overrided, so use the SDK one
$_viewFile_ = dirname(__FILE__) . "/views/$_viewName_.php";
}
@ -1122,7 +1127,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
extract($_data_,EXTR_PREFIX_SAME,'data');
else
$data=$_data_;
//render the view
if($_return_)
{
@ -1134,21 +1139,21 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
else
require($_viewFile_);
}
/**
*
* This function is used to make sure that the created url returns a proper scheme
*
*/
protected function getUrl($file){
//if there is no file, return an empty string
if(empty($file)) return $file;
//test if the files is a url, as one migt send it that way
$parts = parse_url($file);
$is_url = is_array($parts) && isset($parts['scheme']);
$is_url = is_array($parts) && isset($parts['scheme']) && SyC::startsWith($parts['scheme'],'http');
//if this is not a url, create one for it
if(!$is_url)
{
@ -1160,19 +1165,19 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
{
$url = $file;
}
//do it here. the problem is loading an insecure object over a secure page, so check for this situation
if( (isset($_SERVER['HTTPS']) && !strcasecmp($_SERVER['HTTPS'],'on')) && //the page is a secure one
SyC::startsWith($url,'http://') //the created url is an insecure one, adjust it
)
{
$url = "https://".substr($url, 7);
}
return $url;
}
/**
*
@ -1181,39 +1186,39 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
*
*/
public function checkSDKStatus($force = false) {
//call the API at most only once every 5 minutes, not sooner
if(!$force && (time()-$this->getConfigValue('api_last_check')) < 5*60)
if(!$force && (time()-$this->getConfigValue('api_last_check')) < 5*60)
return;
//set the latest check time
$this->setConfigValue('api_last_check',time());
//get an update from the API
$message = '';
if(is_array($result = $this->getSDKStatus($this->getSecretKey(), $this->getClientId(), $this->getAppKey(), $message)))
{
//save the data
$this->setConfigValue('api_version', @$result['api_version']);
$this->setConfigValue('latest_version', @$result['plugin_latest_version']);
$this->setConfigValue('download_url', @$result['plugin_download_url']);
$this->setConfigValue('debug', @$result['debug']);
//set the current language the SDK should be displayed in
if(isset($result['lang'])){
$this->setConfigValue('lang', $result['lang']);
SyC::setLanguage($result['lang']);
//check if there is a new translation available for this language
if(!empty($result['lang_checksum']) && $result['lang_checksum'] != SyC::getLanguageChecksum()){
//download the translation
$messages = $this->getSDKTranslation(SyC::getLanguage());
//save the translation
$this->setConfigValue('messages', $messages);
//reset the loaded messages so that the new ones are being used
SyC::reloadLanguage();
}
@ -1221,9 +1226,9 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
}else{
//simply log the error, for now!
error_log(print_r($message,true));
}
}
}
/**
*
* Language loader ( from the DB )
@ -1233,18 +1238,18 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
{
//see if we have the language saved in the db
$messages = $this->getConfigValue('messages');
if(empty($messages)) //no language is saved, so revert to the file one
{
$messages = SyC::loadFileLanguage($lang,$category);
}
//make sure we have an array for this variable
if(!is_array($messages)) $messages=array();
return $messages;
}
/*
*
* Call to see if the function was called once, or not
@ -1258,7 +1263,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
self::$_SINGLE_FUNCTIONS_CALLS[$functionName] = true;
return true;
}
/**
*
* User to catch any unhandled exceptions and print them nicelly
@ -1267,7 +1272,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
public function UncaughtExceptionHandler(Exception $e) {
//@header("HTTP/1.0 403");
echo $e->getMessage();
if($this->isDebugMode()){
echo $e->getTraceAsString();
}

View File

@ -1,4 +1,4 @@
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied');
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied');
$admin_base_url = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
@ -8,7 +8,7 @@ if($refresh)
//recreate the url ( but before that make sure there is no syc-account parameter in it )
unset($_GET['syc-account']);
$url = $admin_base_url.'?'.http_build_query($_GET,'','&');
@header("HTTP/1.1 302 Found");
@header("Location: $url");
echo "<meta http-equiv=\"refresh\" content=\"0; url=$url\">"; //it can happen that the headers have allready been sent, so use the html version as well
@ -20,15 +20,15 @@ if($refresh)
</script>
<div class="wrap">
<?php if($show_header):?>
<?php echo $this->getUpdateNotification(); ?>
<h2>
<a href="http://www.shareyourcart.com" target="_blank" title="Shareyourcart" class="shareyourcart-logo" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin-view/logo-click']);">
<img src="<?php echo $this->getUrl(dirname(__FILE__).'/../img/shareyourcart-logo.png'); ?>"/>
</a>
<div class="syc-slogan"><?php echo SyC::t('sdk','Increase your social media exposure by 10%!'); ?></div>
<?php
if(isset($this->adminFix)) echo "<br /><br /><br /><br /><br />";
else echo "<br class=\"clr\" /> ";
@ -38,29 +38,29 @@ if($refresh)
<?php if(!empty($status_message) || !empty($error_message)): ?>
<div class="updated settings-error"><p><strong>
<?php
$message = @$error_message;
<?php
$message = @$error_message;
//is there a status message?
if(!empty($status_message))
{
//put the status message on a new line
if(!empty($message)) $message .= "<br /><br />";
$message .= $status_message;
}
echo $message;
echo $message;
?>
</strong></p></div>
<?php endif; ?>
<p><?php echo SyC::t('sdk','{brand} helps you get more customers by motivating satisfied customers to talk with their friends about your products. Each customer that promotes your products, via social media, will receive a coupon that they can apply to their shopping cart in order to get a small discount.',array('{brand}' => '<a href="http://www.shareyourcart.com" target="_blank" title="Shareyourcart&trade;" onclick=" if(_gaq) _gaq.push([\'_trackPageview\', \'/admin-view/logo-click\']);">ShareYourCart&trade;</a>')); ?></p>
<br />
<div id="acount-options">
<form method="POST" name="account-form">
<fieldset>
<div id="acount-options">
<form method="POST" name="account-form">
<fieldset>
<div class="api-status" align="right">
<?php echo SyC::t('sdk','API Status:'); ?>
<?php if($this->isActive()) : ?>
@ -74,7 +74,7 @@ if($refresh)
<?php else :?>
<input type="submit" value="<?php echo SyC::t('sdk','Enable'); ?>" name="enable-API" class="api-button" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin-view/enable-click']);" />
<?php endif;?>
</div>
</div>
<table class="form-table-api" name="shareyourcart_settings">
<tr>
<th scope="row"><?php echo SyC::t('sdk','Client ID'); ?></th>
@ -90,34 +90,34 @@ if($refresh)
</tr>
</table>
<?php echo $html;?>
<div class="submit"><input type="submit" name="syc-account-form" class="button" value="<?php echo SyC::t('sdk','Save'); ?>" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin-view/save-click']);"></div>
</fieldset>
</form>
<div class="submit"><input type="submit" name="syc-account-form" class="button" value="<?php echo SyC::t('sdk','Save'); ?>" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin-view/save-click']);"></div>
</fieldset>
</form>
</div>
<?php if($this->isActive()): //show the configure part only if it is active ?>
<br/>
<fieldset>
<p><?php echo SyC::t('sdk','You can choose how much of a discount to give (in fixed amount, percentage, or free shipping) and to which social media channels it should it be applied. You can also define what the advertisement should say, so that it fully benefits your sales.'); ?></p>
<br />
<form action="<?php echo $this->SHAREYOURCART_CONFIGURE; ?>" method="POST" id="configure-form" target="_blank">
<div class="configure-button-container" align="center">
<input type="submit" value="<?php echo SyC::t('sdk','Configure'); ?>" id="configure-button" class="shareyourcart-button-orange" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin-view/configure-click']);" />
<input type="hidden" name="app_key" value="<?php echo $this->getAppKey(); ?>" />
<input type="hidden" name="client_id" value="<?php echo $this->getClientId(); ?>" />
<input type="hidden" name="email" value="<?php echo $this->getAdminEmail(); ?>" />
</div>
</div>
</form>
</fieldset>
<?php if($show_footer):?>
<?php if($show_footer):?>
<br />
<h2><?php echo SyC::t('sdk','Contact'); ?></h2>
<p><?php echo SyC::t('sdk',"If you've got 30 seconds, we'd {link-1} love to know what ideal outcome you'd like ShareYourCart to help bring to your business</a>, or if you have a private question, you can {link-2} contact us directly</a>", array('{link-1}' => '<a href="http://shareyourcart.uservoice.com" target="_blank" title="forum" class="api-link" onclick=" if(_gaq) _gaq.push([\'_trackPageview\', \'/admin/documentation/forum-click\']);">', '{link-2}' => '<a href="http://www.shareyourcart.com/contact" target="_blank" class="api-link" onclick=" if(_gaq) _gaq.push([\'_trackPageview\', \'/admin/documentation/contact-click\']);">')); ?></p>
<br />
<?php endif; ?>
<?php endif; //show only if the cart is active ?>
</div>

View File

@ -1,5 +1,5 @@
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
<a href="<?php echo $this->SHAREYOURCART_BUTTON_URL ?>" class="shareyourcart-button <?php if (isset($is_product_page) && $is_product_page) echo "product_button"; ?>" <?php echo (isset($callback_url) && !empty($callback_url)) ? "data-syc-callback_url=$callback_url" : ''; ?> data-syc-layout="custom" <?php if(!empty($position_after)): echo "data-syc-position-after=\"$position_after\""; elseif(!empty($position_before)): echo "data-syc-position-before=\"$position_before\""; endif; ?>>
<a href="<?php echo $this->SHAREYOURCART_BUTTON_URL ?>" class="shareyourcart-button <?php if (isset($is_product_page) && $is_product_page) echo "product_button"; ?>" <?php echo (isset($callback_url) && !empty($callback_url)) ? "data-syc-callback_url=$callback_url" : ''; ?> data-syc-layout="custom" <?php if(!empty($position_after)): echo "data-syc-position-after=\"$position_after\""; elseif(!empty($position_before)): echo "data-syc-position-before=\"$position_before\""; endif; ?> <?php if(!empty($language)): echo "data-syc-language=\"$language\""; endif; ?>>
<?php echo $button_html;?>
</a>

View File

@ -1,6 +1,6 @@
<?php
<?php
if(!class_exists('ShareYourCartBase',false)) die('Access Denied');
// If only the hover is uploaded
if((!$button_img or !$button_img_width or !$button_img_height) and ($button_img_hover and $button_img_hover_width and $button_img_hover_height)) {
$button_img = $button_img_hover;
@ -10,15 +10,15 @@
$button_img_hover_width = null;
$button_img_hover_height = null;
}
$callbackDataAttr = '';
if(isset($callback_url) && !empty($callback_url)) {
$callbackDataAttr = 'data-syc-callback_url="' . $callback_url .'"';
}
?>
<a href="<?php echo $this->SHAREYOURCART_BUTTON_URL ?>" class="shareyourcart-button <?php if (isset($is_product_page) && $is_product_page) echo "product_button"; ?>" <?php echo $callbackDataAttr; ?> data-syc-layout="custom" <?php if(!empty($position_after)): echo "data-syc-position-after=\"$position_after\""; elseif(!empty($position_before)): echo "data-syc-position-before=\"$position_before\""; endif; ?>>
<a href="<?php echo $this->SHAREYOURCART_BUTTON_URL ?>" class="shareyourcart-button <?php if (isset($is_product_page) && $is_product_page) echo "product_button"; ?>" <?php echo $callbackDataAttr; ?> data-syc-layout="custom" <?php if(!empty($position_after)): echo "data-syc-position-after=\"$position_after\""; elseif(!empty($position_before)): echo "data-syc-position-before=\"$position_before\""; endif; ?> <?php if(!empty($language)): echo "data-syc-language=\"$language\""; endif; ?>>
&nbsp;
</a>
@ -30,7 +30,7 @@
height: <?php echo $button_img_height; ?>px;
text-indent: -9999px;
}
<?php
if($button_img_hover and $button_img_hover_width and $button_img_hover_height) {
?>

View File

@ -5,15 +5,15 @@
</script>
<div class="wrap">
<?php if($show_header):?>
<?php echo $this->getUpdateNotification(); ?>
<h2>
<a href="http://www.shareyourcart.com" target="_blank" title="Shareyourcart" class="shareyourcart-logo" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/logo-click']);">
<img src="<?php echo $this->getUrl(dirname(__FILE__).'/../img/shareyourcart-logo.png'); ?>"/>
</a>
<div class="syc-slogan"><?php echo SyC::t('sdk','Increase your social media exposure by 10%!'); ?></div>
<br clear="all" />
<br clear="all" />
</h2>
<?php endif; ?>
@ -23,14 +23,14 @@
</strong></p></div>
<?php endif; ?>
<div id="visual-options">
<form method="POST" enctype="multipart/form-data" id="syc-form">
<div id="visual-options">
<form method="POST" enctype="multipart/form-data" id="syc-form">
<fieldset>
<div class="buttonOption">
<input class="buttonOptionRadio" type="radio" value="1" id="button_type_1" <?php if ($current_button_type == '1'||$current_button_type == '') echo 'checked' ?> name="button_type" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/default-click']);" />
<label class="buttonOptionLabel" for="button_type_1"><?php echo SyC::t('sdk','Use Standard Button'); ?></label>
<label class="buttonOptionLabel" for="button_type_1"><?php echo SyC::t('sdk','Use Standard Button'); ?></label>
<br /><br />
<table class="form-table shareyourcart_button_standard" name="shareyourcart_button_standard">
<tr align="center">
@ -43,7 +43,7 @@
<option name="blue" <?php echo $current_skin == 'blue' ? 'selected="selected"' : ''; ?> value="blue"><?php echo SyC::t('sdk','Blue'); ?></option>
<option name="light" <?php echo $current_skin == 'light' ? 'selected="selected"' : ''; ?> value="light"><?php echo SyC::t('sdk','Light'); ?></option>
<option name="dark" <?php echo $current_skin == 'dark' ? 'selected="selected"' : ''; ?> value="dark"><?php echo SyC::t('sdk','Dark'); ?></option>
</select>
</select>
</td>
</tr>
<tr align="center">
@ -54,14 +54,14 @@
<select name="button_position" id="button_position" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/button-position-click']);">
<option name="normal" <?php echo $current_position == 'normal' ? 'selected="selected"' : ''; ?> value="normal"><?php echo SyC::t('sdk','Normal'); ?></option>
<option name="floating" <?php echo $current_position == 'floating' ? 'selected="selected"' : ''; ?> value="floating"><?php echo SyC::t('sdk','Floating'); ?></option>
</select>
</select>
</td>
</tr>
</tr>
<!-- <tr align="center"> since we switched to <a> on the button, this does not seem to be needed anymore
<td>
<input class="buttonCheckbox" name="show_on_single_row" <?php echo $show_on_single_row ? 'checked="checked"' : ''; ?> type='checkbox' onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/toggle-show-on-single-row-click']);"><?php echo SyC::t('sdk','Check this if you want the button to be shown on it\'s own row'); ?></input>
</td>
</tr> -->
</tr> -->
</table>
</div>
@ -82,7 +82,7 @@
<input type="hidden" name="MAX_FILE_SIZE" value="100000000000" />
<input type="file" accept="image/gif, image/jpeg, image/jpg, image/png" name="button-img" id="button-img" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/upload-normal-img-click']);" />
</td>
</tr>
</tr>
<tr align="center">
<th><label><?php echo SyC::t('sdk','Hover image:'); ?></label></th>
@ -96,27 +96,27 @@
<input type="hidden" name="MAX_FILE_SIZE" value="100000000000" />
<input type="file" accept="image/gif, image/jpeg, image/jpg, image/png" name="button-img-hover" id="button-img-hover" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/upload-hover-img-click']);" />
</td>
</tr>
</tr>
</table>
</div>
<div class="buttonOption last">
<input class="buttonOptionRadio" type="radio" value="3" id="button_type_3" name="button_type" <?php if ($current_button_type == '3') echo 'checked' ?> onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/custom-button-click']);"/>
<label class="buttonOptionLabel" for="button_type_3"><?php echo SyC::t('sdk','Build your own HTML button'); ?></label>
<label class="buttonOptionLabel" for="button_type_3"><?php echo SyC::t('sdk','Build your own HTML button'); ?></label>
<table class="form-table shareyourcart_button_html" name="shareyourcart_button_html">
<tr>
<tr>
<td>
<textarea id="syc_button_textarea" class="buttonTextarea" rows="7" cols="56" name="button_html"><?php echo ($button_html!=''?$button_html:'<button>'.SyC::t('sdk','Get a {value} discount',array('{value}' => '<div class="shareyourcart-discount"></div>')).'</button>'); ?></textarea>
<textarea id="syc_button_textarea" class="buttonTextarea" rows="7" cols="56" name="button_html"><?php echo ($button_html!=''?$button_html:'<button>'.SyC::t('sdk','Get a {value} discount',array('{value}' => '<div class="shareyourcart-discount"></div>')).'</button>'); ?></textarea>
</td>
</tr>
</tr>
</table>
<?php echo $html; ?>
</div>
<br clear="all" />
<hr />
<br />
<table class="form-table table-small" name="shareyourcart_settings">
@ -125,7 +125,7 @@
<td>
<input class="buttonCheckbox" name="show_on_product" <?php echo $show_on_product ? 'checked="checked"' : ''; ?> type='checkbox' onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/toggle-show-on-product-click']);"><?php echo SyC::t('sdk','Product page'); ?></input>
<br />
<input class="buttonCheckbox" name="show_on_checkout" <?php echo $show_on_checkout ? 'checked="checked"' : ''; ?> type='checkbox' onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/toggle-show-on-checkout-click']);"><?php echo SyC::t('sdk','Checkout page'); ?></input>
<input class="buttonCheckbox" name="show_on_checkout" <?php echo $show_on_checkout ? 'checked="checked"' : ''; ?> type='checkbox' onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/toggle-show-on-checkout-click']);"><?php echo SyC::t('sdk','Checkout page'); ?></input>
</td>
</tr>
<tr>
@ -141,13 +141,13 @@
</td>
</tr>
</table>
<div class="submit"><input type="submit" class="button" name="syc-visual-form" id="syc-visual-form" value="<?php echo SyC::t('sdk','Save'); ?>" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/save-click']);"></div>
</fieldset>
<div class="submit"><input type="submit" class="button" name="syc-visual-form" id="syc-visual-form" value="<?php echo SyC::t('sdk','Save'); ?>" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/save-click']);"></div>
</fieldset>
<br />
</form>
</form>
</div>
<?php if($show_footer):?>

View File

@ -1,5 +1,5 @@
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
<a href="<?php echo $this->SHAREYOURCART_BUTTON_URL ?>" class="shareyourcart-button <?php if (isset($is_product_page) && $is_product_page) echo "product_button"; ?> <?php echo ( $this->getConfigValue('button_position') == 'floating' ? 'button_iframe' : 'button_iframe-normal');?> <?php echo ( !$this->getConfigValue('dont_set_height') ? 'button_height' : ''); ?>" <?php echo (isset($callback_url) && !empty($callback_url)) ? "data-syc-callback_url=$callback_url" : ''; ?> data-syc-skin="<?php echo $this->getConfigValue('button_skin');?>" data-syc-orientation="<?php echo $this->getConfigValue('button_position'); ?>" <?php if(!empty($position_after)): echo "data-syc-position-after=\"$position_after\""; elseif(!empty($position_before)): echo "data-syc-position-before=\"$position_before\""; endif; ?> >
<a href="<?php echo $this->SHAREYOURCART_BUTTON_URL ?>" class="shareyourcart-button <?php if (isset($is_product_page) && $is_product_page) echo "product_button"; ?> <?php echo ( $this->getConfigValue('button_position') == 'floating' ? 'button_iframe' : 'button_iframe-normal');?> <?php echo ( !$this->getConfigValue('dont_set_height') ? 'button_height' : ''); ?>" <?php echo (isset($callback_url) && !empty($callback_url)) ? "data-syc-callback_url=$callback_url" : ''; ?> data-syc-skin="<?php echo $this->getConfigValue('button_skin');?>" data-syc-orientation="<?php echo $this->getConfigValue('button_position'); ?>" <?php if(!empty($position_after)): echo "data-syc-position-after=\"$position_after\""; elseif(!empty($position_before)): echo "data-syc-position-before=\"$position_before\""; endif; ?> <?php if(!empty($language)): echo "data-syc-language=\"$language\""; endif; ?> >
ShareYourCart Discount
</a>

View File

@ -5,28 +5,28 @@
</script>
<div class="wrap">
<?php if($show_header):?>
<?php echo $this->getUpdateNotification(); ?>
<h2>
<a href="http://www.shareyourcart.com" target="_blank" title="Shareyourcart" class="shareyourcart-logo" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/documentation/logo-click']);">
<img src="<?php echo $this->getUrl(dirname(__FILE__).'/../img/shareyourcart-logo.png'); ?>"/>
</a>
<div class="syc-slogan"><?php echo SyC::t('sdk','Increase your social media exposure by 10%!'); ?></div>
<br clear="all" />
<br clear="all" />
</h2>
<?php endif; ?>
<div id="doc-content">
<h2><?php echo SyC::t('sdk','Standard Button'); ?></h2>
<p><?php echo SyC::t('sdk','In order to see the {brand} button on a <strong>post</strong> or <strong>page</strong> you can use the following shortcode:', array( '{brand}' => '<a href="http://www.shareyourcart.com" target="_blank" title="Shareyourcart&trade;" onclick=" if(_gaq) _gaq.push([\'_trackPageview\', \'/admin/documentation/logo-click\']);">ShareYourCart&trade;</a>')); ?></p>
<pre><code>[shareyourcart]</code></pre>
<p><?php echo SyC::t('sdk','If you want to use the {brand} button directly in a <strong>theme</strong> or <strong>page template</strong> you have to use the following function call:', array('{brand}' => '<a href="http://www.shareyourcart.com" target="_blank" title="Shareyourcart&trade;" onclick=" if(_gaq) _gaq.push([\'_trackPageview\', \'/admin/documentation/logo-click\']);">ShareYourCart&trade;</a>')); ?></p>
<pre><code>echo do_shortcode('[shareyourcart]');</code></pre>
<h3><?php echo SyC::t('sdk','Remarks'); ?></h3>
<ol>
<?php if (!(isset($action_url) && !empty($action_url))): //if no shopping cart is active ?>
<li><p><?php echo SyC::t('sdk','For the button to work, you need to specify the following properties in the meta description area'); ?></p>
<pre><code><?php echo SyC::htmlIndent(nl2br(htmlspecialchars('<html xmlns="http://www.w3.org/1999/xhtml"
@ -37,8 +37,8 @@
<meta property="syc:price" content="$10" />
<meta property="og:description"
content="
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Proin feugiat nunc quis nibh congue luctus.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Proin feugiat nunc quis nibh congue luctus.
Maecenas ac est nec turpis fermentum imperdiet.
"/>
...
@ -55,23 +55,23 @@
</ul>
</li>
</ol>
<h2><?php echo SyC::t('sdk','Custom Button'); ?></h2>
<p><?php echo SyC::t('sdk','If you want to fully style the {brand} button, use instead the following HTML code', array('{brand}' => '<a href="http://www.shareyourcart.com" target="_blank" title="Shareyourcart&trade;" onclick=" if(_gaq) _gaq.push([\'_trackPageview\', \'/admin/documentation/logo-click\']);">ShareYourCart&trade;</a>')); ?></p>
<?php $custom_button = '<button class="shareyourcart-button" data-syc-layout="custom"';
if (isset($action_url) && !empty($action_url)){
if (isset($action_url) && !empty($action_url)){
//if there is no action url, it means none of the supported shopping carts are active,
//so there would be no need for the callback attribute
$custom_button .= ' data-syc-callback_url="'.$action_url.'" ';
}
$custom_button .= '>
Get a <div class="shareyourcart-discount" ></div> discount
</button>'; ?>
<pre><code><?php echo SyC::htmlIndent(nl2br(htmlspecialchars($custom_button))); ?></code></pre>
<?php if (isset($action_url) && !empty($action_url)): //only show if a known shopping cart is active ?>
<h3><?php echo SyC::t('sdk','Remarks'); ?></h3>
<p><?php echo SyC::t('sdk','If you want to use the {brand} button on a product\'s page, you need to <strong>append</strong> {product-property} to the {callback-url} value, where {product-property} is the product\'s id', array('{brand}' => '<a href="http://www.shareyourcart.com" target="_blank" title="Shareyourcart&trade;" onclick=" if(_gaq) _gaq.push([\'_trackPageview\', \'/admin/documentation/logo-click\']);">ShareYourCart&trade;</a>', '{product-property}' => '<code>&p=&lt;product_id&gt;</code>', '{callback-url}' => '<strong>data-syc-callback_url</strong>')); ?></p>

View File

@ -4,14 +4,14 @@
<link rel="stylesheet" href="<?php echo $this->getUrl(dirname(__FILE__).'/../css/ie.css'); ?>" type="text/css"/>
<![endif]-->
<?php //check if there is a style outside of the SDK, and include that one as well
<?php //check if there is a style outside of the SDK, and include that one as well
$_reflection_ = new ReflectionClass(get_class($this));
$_file_ = dirname($_reflection_->getFileName())."/css/style.css";
//check if there is a file in the specified location
if(file_exists($_file_)):?>
<link rel="stylesheet" type="text/css" href="<?php echo $this->getUrl($_file_); ?>" />
<?php endif; ?>