Permalink
Browse files

v2.2.10

  • Loading branch information...
1 parent 6efed1e commit 2e124bd0b92f5332ae49bd9d23d5627e731ca7c9 @mtymek mtymek committed Feb 20, 2012
Showing with 79 additions and 28 deletions.
  1. +0 −4 js/CleengBEWidgetWP.js
  2. +3 −7 php/classes/Core.php
  3. +1 −1 php/classes/Editor.php
  4. +62 −12 php/classes/Frontend.php
  5. +3 −1 php/classes/Installer.php
  6. +4 −0 php/classes/PostList.php
  7. +6 −3 readme.txt
View
@@ -32,11 +32,7 @@ var CleengWidget = {
11.99, 12.99, 13.99, 14.99, 15.99, 16.99, 17.99, 18.99, 19.99,
24.95, 29.95, 34.95, 39.95, 44.95, 49.95, 54.95, 59.95, 64.95, 69.95, 74.95, 79.95, 84.95, 89.95, 94.95, 99.95
],
-<<<<<<< HEAD
-=======
->>>>>>> 31856ac7f95b3b47377ba841a4e4ce0e95764c54
-
teserInputWatcher: function() {
var desc = jQuery('#cleeng-ContentForm-Description');
if (desc.val().length > 110) {
View
@@ -3,9 +3,9 @@
class Cleeng_Core
{
- const DATABASE_VERSION = 2;
+ const DATABASE_VERSION = 3;
- const PLUGIN_VERSION = '2.2.8';
+ const PLUGIN_VERSION = '2.2.10';
/**
* Configuration injected to each created class
@@ -113,18 +113,14 @@ public static function deactivate()
* @return void
*/
public function setup()
- {
+ {
$options = get_option('cleeng_options');
if (!$options || !isset($options['db_version']) || $options['db_version'] < self::DATABASE_VERSION) {
self::load('Cleeng_Installer')->migrate_database($options);
$options = get_option('cleeng_options'); // reload options
}
self::$config = array_merge(self::$config, $options);
-<<<<<<< HEAD
-=======
-
->>>>>>> 31856ac7f95b3b47377ba841a4e4ce0e95764c54
if (!self::$config['appId']) { // no appId - register new application
$app = self::load('Cleeng_Installer')->register_client_app();
if ($app) {
View
@@ -265,7 +265,7 @@ function editor_meta_box() {
<div style="display:none;">
<?php _e('Thanks for using <strong class="cleeng-name">Cleeng</strong>.<br /><br />Please log in to protect your content.', 'cleeng') ?>
<br /> <br />
- <a style="margin-left:200px;" class="CleengWidget-auth-link button-primary" id="cleeng-login" href="#"><?php _e('Log in','cleeng') ?></a>
+ <a style="float:right" class="CleengWidget-auth-link button-primary" id="cleeng-login" href="#"><?php _e('Log in','cleeng') ?></a>
<br/><br/>
<div style="margin-left: 20px;"><?php _e( 'Or
<a href="#" id="cleeng-register-publisher">register</a>
View
@@ -23,6 +23,11 @@ class Cleeng_Frontend
*/
protected $cleeng_content;
+ /**
+ * @var bool
+ */
+ protected $cleeng_items_parsed = false;
+
/**
* Whether to call getContentInfo API when page is loaded or not.
* Right now it won't work if set to false.
@@ -47,7 +52,6 @@ public function setup()
$clientLang = 'en_US';
}
-
wp_enqueue_script( 'CleengClient', 'https://' . $options['platformUrl'] . '/js-api/client.' . $clientLang . '.js' );
wp_enqueue_script( 'CleengFEWidgetWP', CLEENG_PLUGIN_URL . 'js/CleengFEWidgetWP.js', array( 'jquery' ) );
@@ -159,13 +163,19 @@ public function action_wp_footer() {
/**
* Wordpress action.
- * Hook to Wordpress loop. It scans every post and searches for Cleeng
- * items. Then it fetches information about the content using WebAPI
*
- * @global array $posts
*/
public function action_loop_start() {
+ $this->cleeng_items_parsed = false;
+ }
+
+ /**
+ * Processes posts in a loop in search for Cleeng tags
+ *
+ */
+ public function parse_cleeng_items() {
global $posts;
+ global $wpdb;
$cleeng = Cleeng_Core::load('Cleeng_Client');
@@ -229,6 +239,9 @@ public function action_loop_start() {
}
}
+ // sync with cached content from database
+
+
if ( count( $this->cleeng_content ) ) {
$this->cleeng_has_content = true;
@@ -259,22 +272,53 @@ public function action_loop_start() {
$this->cleeng_preload_content = false;
return;
}
- $ids = array_keys( $this->cleeng_content );
+
+ if ($cleeng->isUserAuthenticated()) {
+ $auth = true;
+ } else {
+ $auth = false;
+ }
$contentInfoIds = array();
- foreach ($ids as $key => $value) {
- if (is_numeric($value)) {
- $contentInfoIds[] = $value;
+ $possiblyCached = array();
+ foreach ($this->cleeng_content as $key => $value) {
+ if (is_numeric($key)) {
+ if ($auth || $value['hasLayerDates']) {
+ $contentInfoIds[] = $key;
+ } else {
+ $possiblyCached[] = $key;
+ }
+ }
+ }
+
+
+ $table_name = $wpdb->prefix . "cleeng_content";
+ $rows = $wpdb->get_results(
+ "SELECT * FROM " . $table_name . ' WHERE content_id IN ("' . implode('","', $possiblyCached) . '")'
+ );
+ foreach ($rows as $cont) {
+ $cont = (array)$cont;
+ if (in_array($cont['content_id'], $possiblyCached)) {
+ unset($possiblyCached[array_search($cont['content_id'], $possiblyCached)]);
+ $this->cleeng_content[$cont['content_id']]['sync'] = true;
+ $this->cleeng_content[$cont['content_id']]['currency'] = $cont['currency'];
+ $this->cleeng_content[$cont['content_id']]['currencySymbol'] = $cont['currency_symbol'];
+ $this->cleeng_content[$cont['content_id']]['subscriptionOffer'] = $cont['subscription_offer'];
+ $this->cleeng_content[$cont['content_id']]['subscriptionPrompt'] = $cont['subscription_prompt'];
+ $this->cleeng_content[$cont['content_id']]['publisherId'] = $cont['publisher_id'];
}
}
- if (count($contentInfoIds)) {
+ if (count($possiblyCached)) {
+ $contentInfoIds = array_merge($contentInfoIds, $possiblyCached);
+ }
+
+ if (count($contentInfoIds)) {
try {
-// throw new Exception("test");
$contentInfo = $cleeng->getContentInfo( $contentInfoIds );
foreach ( $contentInfo as $key => $val ) {
-
+
if (!is_array($val)) {
continue;
}
@@ -299,6 +343,12 @@ public function action_loop_start() {
* @return string
*/
function cleeng_add_layers( $content ) {
+
+ if (!$this->cleeng_items_parsed) {
+ $this->parse_cleeng_items();
+ $this->cleeng_items_parsed = 1;
+ }
+
global $post;
$cleeng = Cleeng_Core::load('Cleeng_Client');
$expr = '/\[cleeng_content.*?id\s*=\s*(?:\"|&quot;)([\dt]+)(?:\"|&quot;).*?[^\\\]\](.*?[^\\\])\[\/cleeng_content\]/is';
@@ -453,7 +503,7 @@ function setDisplayNone($contentId){
* Helper function
* Outputs Cleeng Layer's HTML code
*/
-function get_layer_markup( $postId, $text, $content ) {
+ function get_layer_markup( $postId, $text, $content ) {
$cleeng = Cleeng_Core::load('Cleeng_Client');
@@ -98,7 +98,9 @@ public function migrate_database($options = null)
referral_rate float(18,4),
short_url varchar(200),
item_type varchar(50),
- referral_program_enabled tinyint(1)
+ referral_program_enabled tinyint(1),
+ subscription_offer tinyint(1),
+ subscription_prompt varchar(64)
);";
View
@@ -122,6 +122,8 @@ public function get_cleeng_contents()
'price' => $cont['price'],
'referralProgramEnabled' => $cont['referral_program_enabled'],
'referralRate' => $cont['referral_rate'],
+ 'subscriptionOffer' => $cont['subscription_offer'],
+ 'subscriptionPrompt' => $cont['subscription_prompt'],
);
}
@@ -141,6 +143,8 @@ public function get_cleeng_contents()
'price' => $cont['price'],
'referral_program_enabled' => $cont['referralProgramEnabled'],
'referral_rate' => $cont['referralRate'],
+ 'subscription_offer' => $cont['subscriptionOffer'],
+ 'subscription_prompt' => $cont['subscriptionPrompt'],
);
$wpdb->insert( $table_name, $insert);
View
@@ -111,9 +111,12 @@ You can find all FAQ on http://support.cleeng.com (or ask your question there if
6. User library, to access all his/her content
== Changelog ==
-= trunk =
-* verify data before calling Cleeng API
-* verify "default sale condition" before protecting content calling Cleeng API
+
+= 2.2.10 =
+* improved loading speed of pages with Cleeng items
+* removed redundant calls to Cleeng API, improved data validation before it is sent
+* verify if user has set default pricing conditions with AJAX request
+* small CSS improvements
= 2.2.9 =
* italian translations (by Davide Brioschi)

0 comments on commit 2e124bd

Please sign in to comment.