mirror of
https://github.com/e107inc/e107.git
synced 2025-07-12 10:36:20 +02:00
Theme manager - online list using new communication protocol.
Added more control over array elements to the new XML parser.
This commit is contained in:
@ -315,7 +315,7 @@ class pluginManager{
|
|||||||
// it'll be moved to e107::getMarketplace() soon
|
// it'll be moved to e107::getMarketplace() soon
|
||||||
if($this->action == 'online')
|
if($this->action == 'online')
|
||||||
{
|
{
|
||||||
// force xmlrpc temporary
|
// XXX force xmlrpc temporary
|
||||||
require_once(e_HANDLER.'e_marketplace.php');
|
require_once(e_HANDLER.'e_marketplace.php');
|
||||||
$this->mp = new e_marketplace('xmlrpc');
|
$this->mp = new e_marketplace('xmlrpc');
|
||||||
}
|
}
|
||||||
|
@ -423,6 +423,7 @@ class e_marketplace_adapter_xmlrpc extends e_marketplace_adapter_abstract
|
|||||||
protected $url = 'http://e107.org/xservice';
|
protected $url = 'http://e107.org/xservice';
|
||||||
|
|
||||||
protected $_forceArray = array();
|
protected $_forceArray = array();
|
||||||
|
protected $_forceNumericalArray = array();
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
@ -541,11 +542,15 @@ class e_marketplace_adapter_xmlrpc extends e_marketplace_adapter_abstract
|
|||||||
if(in_array($name, $this->_forceArray))
|
if(in_array($name, $this->_forceArray))
|
||||||
{
|
{
|
||||||
$_res = $this->parse($node, $name);
|
$_res = $this->parse($node, $name);
|
||||||
if(is_string($_res)) $_res = trim($res);
|
if(is_string($_res)) $_res = trim($_res);
|
||||||
|
|
||||||
if(empty($_res)) $ret[$name] = array(); // empty
|
if(empty($_res)) $ret[$name] = array(); // empty
|
||||||
elseif(is_string($_res)) $ret[$name][] = $_res; // string
|
elseif(is_string($_res)) $ret[$name][] = $_res; // string
|
||||||
else $ret[$name][] = $_res; //array - test case, we wanna always force numerical array for now
|
else
|
||||||
|
{
|
||||||
|
if(in_array($name, $this->_forceNumericalArray)) $ret[$name][] = $_res; //array - controlled force numerical array
|
||||||
|
else $ret[$name] = $_res; //array, no force
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else $ret[$name] = $this->parse($node, $name);
|
else $ret[$name] = $this->parse($node, $name);
|
||||||
}
|
}
|
||||||
@ -605,6 +610,7 @@ class e_marketplace_adapter_xmlrpc extends e_marketplace_adapter_abstract
|
|||||||
{
|
{
|
||||||
case 'getList':
|
case 'getList':
|
||||||
$this->_forceArray = array('item', 'screenshots', 'image');
|
$this->_forceArray = array('item', 'screenshots', 'image');
|
||||||
|
$this->_forceNumericalArray = array('item', 'image');
|
||||||
//$client->setOptArrayTags('item,screenshots,image')
|
//$client->setOptArrayTags('item,screenshots,image')
|
||||||
// ->setOptStringTags('icon,folder,version,author,authorURL,date,compatibility,url,thumbnail,featured,livedemo,price,name,description,category,image');
|
// ->setOptStringTags('icon,folder,version,author,authorURL,date,compatibility,url,thumbnail,featured,livedemo,price,name,description,category,image');
|
||||||
break;
|
break;
|
||||||
|
@ -55,9 +55,15 @@ class themeHandler
|
|||||||
'video',
|
'video',
|
||||||
'multimedia');
|
'multimedia');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marketplace handler instance
|
||||||
|
* @var e_marketplace
|
||||||
|
*/
|
||||||
|
protected $mp;
|
||||||
|
|
||||||
/* constructor */
|
/* constructor */
|
||||||
|
|
||||||
function themeHandler()
|
function __construct()
|
||||||
{
|
{
|
||||||
|
|
||||||
global $e107cache,$pref;
|
global $e107cache,$pref;
|
||||||
@ -442,17 +448,31 @@ class themeHandler
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Temporary, e107::getMarketplace() coming soon
|
||||||
|
* @return e_marketplace
|
||||||
|
*/
|
||||||
|
public function getMarketplace()
|
||||||
|
{
|
||||||
|
if(null === $this->mp)
|
||||||
|
{
|
||||||
|
require_once(e_HANDLER.'e_marketplace.php');
|
||||||
|
$this->mp = new e_marketplace('xmlrpc'); // XXX temporary force xmplrpc
|
||||||
|
}
|
||||||
|
return $this->mp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function renderOnline($ajax=false)
|
function renderOnline($ajax=false)
|
||||||
{
|
{
|
||||||
|
global $e107SiteUsername, $e107SiteUserpass;
|
||||||
$xml = e107::getXml();
|
$xml = e107::getXml();
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
$frm = e107::getForm();
|
$frm = e107::getForm();
|
||||||
$ns = e107::getRender();
|
$ns = e107::getRender();
|
||||||
|
$mp = $this->getMarketplace();
|
||||||
$from = intval(varset($_GET['frm']));
|
$from = intval(varset($_GET['frm']));
|
||||||
$limit = 96;
|
$limit = 96; // FIXME - ajax pages load
|
||||||
$srch = preg_replace('/[^\w]/','', vartrue($_GET['srch']));
|
$srch = preg_replace('/[^\w]/','', vartrue($_GET['srch']));
|
||||||
|
|
||||||
// check for cURL
|
// check for cURL
|
||||||
@ -461,14 +481,26 @@ class themeHandler
|
|||||||
$mes->addWarning("cURL is currently required to use this feature. Contact your webhosting provider to enable cURL"); // TODO LAN?
|
$mes->addWarning("cURL is currently required to use this feature. Contact your webhosting provider to enable cURL"); // TODO LAN?
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = "http://e107.org/feed?type=theme&frm=".$from."&srch=".$srch."&limit=".$limit;
|
// auth
|
||||||
|
$mp->generateAuthKey($e107SiteUsername, $e107SiteUserpass);
|
||||||
|
|
||||||
|
// do the request, retrieve and parse data
|
||||||
|
$xdata = $mp->call('getList', array(
|
||||||
|
'type' => 'theme',
|
||||||
|
'params' => array('limit' => $limit, 'search' => $srch, 'from' => $from)
|
||||||
|
));
|
||||||
|
$total = $xdata['params']['count'];
|
||||||
|
|
||||||
|
// OLD BIT OF CODE ------------------------------->
|
||||||
|
/*$file = "http://e107.org/feed?type=theme&frm=".$from."&srch=".$srch."&limit=".$limit;
|
||||||
|
|
||||||
$mes->addDebug("File = ".$file);
|
$mes->addDebug("File = ".$file);
|
||||||
|
|
||||||
$xml->setOptArrayTags('theme,screenshots/image'); // make sure 'theme' tag always returns an array
|
$xml->setOptArrayTags('theme,screenshots/image'); // make sure 'theme' tag always returns an array
|
||||||
// $xdata = $xml->loadXMLfile($file,'advanced',true);
|
// $xdata = $xml->loadXMLfile($file,'advanced',true);
|
||||||
$xdata = $xml->loadXMLfile($file,true,false);
|
$xdata = $xml->loadXMLfile($file,true,false);
|
||||||
$total = $xdata['@attributes']['total'];
|
$total = $xdata['@attributes']['total'];*/
|
||||||
|
// OLD BIT OF CODE ------------------------------->
|
||||||
|
|
||||||
$amount =$limit;
|
$amount =$limit;
|
||||||
|
|
||||||
@ -498,15 +530,15 @@ class themeHandler
|
|||||||
$text .= '<div id="shop" style="margin-top:10px;min-height:585px" class=" carousel-inner">';
|
$text .= '<div id="shop" style="margin-top:10px;min-height:585px" class=" carousel-inner">';
|
||||||
|
|
||||||
|
|
||||||
|
//var_dump($xdata);
|
||||||
if(is_array($xdata['theme'] ))
|
if(is_array($xdata['data'] ))
|
||||||
{
|
{
|
||||||
|
|
||||||
$text .= '<div class="active item">';
|
$text .= '<div class="active item">';
|
||||||
|
|
||||||
$slides = array();
|
$slides = array();
|
||||||
|
|
||||||
foreach($xdata['theme'] as $r)
|
foreach($xdata['data'] as $r)
|
||||||
{
|
{
|
||||||
if(E107_DBG_PATH)
|
if(E107_DBG_PATH)
|
||||||
{
|
{
|
||||||
@ -514,19 +546,19 @@ class themeHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
$theme = array(
|
$theme = array(
|
||||||
'name' => stripslashes($r['@attributes']['name']),
|
'name' => stripslashes($r['name']),
|
||||||
'category' => $r['category'],
|
'category' => $r['category'],
|
||||||
'preview' => $r['screenshots']['image'],
|
'preview' => varset($r['screenshots']['image'][0]),
|
||||||
'date' => $r['@attributes']['date'],
|
'date' => $r['date'],
|
||||||
'version' => $r['@attributes']['version'],
|
'version' => $r['version'],
|
||||||
'thumbnail' => $r['@attributes']['thumbnail'],
|
'thumbnail' => $r['thumbnail'],
|
||||||
'url' => $r['@attributes']['url'],
|
'url' => $r['url'],
|
||||||
'author' => $r['@attributes']['author'],
|
'author' => $r['author'],
|
||||||
'website' => $r['@attributes']['authorUrl'],
|
'website' => $r['authorUrl'],
|
||||||
'compatibility' => $r['@attributes']['compatibility'],
|
'compatibility' => $r['compatibility'],
|
||||||
'description' => varset($r['description']),
|
'description' => $r['description'],
|
||||||
'price' => $r['@attributes']['price'],
|
'price' => $r['price'],
|
||||||
'livedemo' => $r['@attributes']['livedemo'],
|
'livedemo' => $r['livedemo'],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user