Skip to content

Commit

Permalink
Merge branch 'Dev' of https://github.com/pagelines/framework into Dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Powers committed Mar 7, 2013
2 parents 41557d5 + e309cf7 commit 9f21096
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 27 deletions.
46 changes: 36 additions & 10 deletions editor/editor.api.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,26 @@ function __construct(){
$this->data_url = $this->base_url . '/v4/all';
$this->username = get_pagelines_credentials( 'user' );
$this->password = get_pagelines_credentials( 'pass' );
$this->bootstrap();
}
// bootstrap, make sure store data is ready before page loads.
function bootstrap(){
global $pldraft;
$this->draft = $pldraft->mode;
$this->get_latest();
if( is_object( $pldraft ) && 'draft' == $pldraft->mode )
$this->get_latest();
}

function get_latest(){

if( 'draft' == $this->draft ) {
$data = $this->json_get( $this->data_url );

// Add the decoded data to the global for store to use.
global $mixed_array;
$mixed_array = $this->make_array( json_decode( $data ) );
}
$data = $this->get( 'store_mixed', array( $this, 'json_get' ), array( $this->data_url ) );
return $this->sort( $this->make_array( json_decode( $data ) ) );
}

// sort store data
function sort( $data ){

return $data;
}
}

/*
Expand All @@ -37,6 +41,29 @@ class PageLinesAPI {
var $prot = array( 'https://', 'http://' );
var $base_url = 'api.pagelines.com';

// default timeout for transients.
var $timeout = 300;

// write data to a transient.
function put( $data, $id, $timeout = false ) {
if( ! $timeout )
$timeout = $this->timeout;
set_transient( $id, $data, $timeout );
}

// fetch from transient, if not found use callback.
function get( $id, $callback = false, $args = array() ){

$data = '';

if( false === ( $data = get_transient( $id ) ) && $callback ) {

$data = call_user_func_array( $callback, $args );
if( '' != $data )
$this->put( $data, $id );
}
return $data;
}
/*
* Turn something into an array.
*/
Expand All @@ -57,7 +84,6 @@ function make_array( $data ) {
function json_get( $url ) {

$options = array(
'sslverify' => false,
'timeout' => 15,
'body' => array(
'username' => ( $this->username != '' ) ? $this->username : false,
Expand Down
9 changes: 5 additions & 4 deletions editor/editor.extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,18 @@ function get_sections(){
}

function get_store(){
global $mixed_array;
foreach( $mixed_array as $key => $s ) {

global $storeapi;
foreach( $storeapi->get_latest() as $key => $s ) {
if( ! isset( $s['name'] ) )
continue;
$this->ext[ $key ] = array(
'name' => $s['name'],
'desc' => '',
'desc' => $s['description'],
'thumb' => $s['thumb'],
'splash' => $s['splash'],
'purchase' => '',
'overview' => '',
'overview' => $s['overview'],
);
}
}
Expand Down
17 changes: 4 additions & 13 deletions editor/editor.interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -691,26 +691,17 @@ function themes_dashboard(){
function the_store_callback(){

$list = '';
global $mixed_array;
foreach( $mixed_array as $key => $item){

if( ! isset( $item['type'] ) )
continue;
global $storeapi;
$mixed_array = $storeapi->get_latest();

$class = array();
$class[] = $item['type'];
$class[] = $item['slug'];
foreach( $mixed_array as $key => $item){

if ( 'true' == $item['featured'] )
$class[] = 'featured';
if ( 'true' == $item['plus_product'] )
$class[] = 'plus';
$class = $item['class_array'];

$class[] = 'x-storefront';

$img = sprintf('<img src="%s" style=""/>', $item['thumb']);


$args = array(
'id' => $item['slug'],
'class_array' => $class,
Expand Down

0 comments on commit 9f21096

Please sign in to comment.