mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 14:46:56 +02:00
Plugin manager - online list using new communication protocol
This commit is contained in:
@@ -255,6 +255,12 @@ class pluginManager{
|
||||
var $fieldpref;
|
||||
var $titlearray = array();
|
||||
var $pagetitle;
|
||||
|
||||
/**
|
||||
* Marketplace handler instance
|
||||
* @var e_marketplace
|
||||
*/
|
||||
var $mp;
|
||||
|
||||
protected $pid = 'plugin_id';
|
||||
|
||||
@@ -305,7 +311,14 @@ class pluginManager{
|
||||
$this->pagetitle = (in_array($this->action,$keys)) ? $this -> titlearray[$this->action] : $this -> titlearray['installed'];
|
||||
|
||||
|
||||
|
||||
// temporary - create e_marketpalce instnace
|
||||
// it'll be moved to e107::getMarketplace() soon
|
||||
if($this->action == 'online')
|
||||
{
|
||||
// force xmlrpc temporary
|
||||
require_once(e_HANDLER.'e_marketplace.php');
|
||||
$this->mp = new e_marketplace('xmlrpc');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -445,7 +458,7 @@ class pluginManager{
|
||||
|
||||
function pluginOnline()
|
||||
{
|
||||
global $plugin;
|
||||
global $plugin, $e107SiteUsername, $e107SiteUserpass;
|
||||
$tp = e107::getParser();
|
||||
$frm = e107::getForm();
|
||||
|
||||
@@ -461,25 +474,37 @@ class pluginManager{
|
||||
{
|
||||
$mes->addWarning("cURL is currently required to use this feature. Contact your webhosting provider to enable cURL"); // TODO LAN?
|
||||
}
|
||||
|
||||
$from = intval(varset($_GET['frm']));
|
||||
|
||||
//TODO use admin_ui including filter capabilities by sending search queries back to the xml script.
|
||||
$from = isset($_GET['frm']) ? intval($_GET['frm']) : 0;
|
||||
$srch = preg_replace('/[^\w]/','', vartrue($_GET['srch']));
|
||||
|
||||
|
||||
// auth
|
||||
$this->mp->generateAuthKey($e107SiteUsername, $e107SiteUserpass);
|
||||
|
||||
// do the request, retrieve and parse data
|
||||
$xdata = $this->mp->call('getList', array(
|
||||
'type' => 'plugin',
|
||||
'params' => array('limit' => 10, 'search' => $srch, 'from' => $from)
|
||||
));
|
||||
$total = $xdata['params']['count'];
|
||||
|
||||
// OLD BIT OF CODE ------------------------------->
|
||||
/*
|
||||
// $file = SITEURLBASE.e_PLUGIN_ABS."release/release.php"; // temporary testing
|
||||
$file = "http://e107.org/feed?type=plugin&frm=".$from."&srch=".$srch."&limit=10";
|
||||
|
||||
$xml->setOptArrayTags('plugin'); // make sure 'plugin' tag always returns an array
|
||||
$xdata = $xml->loadXMLfile($file,'advanced');
|
||||
|
||||
$total = $xdata['@attributes']['total'];
|
||||
$total = $xdata['@attributes']['total'];*/
|
||||
// OLD BIT OF CODE END ------------------------------->
|
||||
|
||||
//TODO use admin_ui including filter capabilities by sending search queries back to the xml script.
|
||||
|
||||
// XML data array.
|
||||
|
||||
$c = 1;
|
||||
foreach($xdata['plugin'] as $r)
|
||||
foreach($xdata['data'] as $row)
|
||||
{
|
||||
$row = $r['@attributes'];
|
||||
//$row = $r['@attributes'];
|
||||
|
||||
$badge = $this->compatibilityLabel($row['compatibility']);;
|
||||
$featured = ($row['featured']== 1) ? " <span class='label label-info'>Featured</span>" : '';
|
||||
@@ -491,10 +516,10 @@ class pluginManager{
|
||||
'plugin_name' => stripslashes($row['name']).$featured,
|
||||
'plugin_folder' => $row['folder'],
|
||||
'plugin_date' => vartrue($row['date']),
|
||||
'plugin_category' => vartrue($r['category'][0]),
|
||||
'plugin_category' => vartrue($row['category'], 'n/a'),
|
||||
'plugin_author' => vartrue($row['author']),
|
||||
'plugin_version' => $row['version'],
|
||||
'plugin_description' => nl2br(vartrue($r['description'][0])),
|
||||
'plugin_description' => nl2br(vartrue($row['description'])),
|
||||
'plugin_compatible' => $badge,
|
||||
|
||||
'plugin_website' => vartrue($row['authorUrl']),
|
||||
@@ -505,17 +530,10 @@ class pluginManager{
|
||||
|
||||
$c++;
|
||||
}
|
||||
|
||||
// print_a($data);
|
||||
|
||||
$fieldList = $this->fields;
|
||||
unset($fieldList['checkboxes']);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$text = "
|
||||
<form class='form-search' action='".e_SELF."?".e_QUERY."' id='core-plugin-list-form' method='get'>
|
||||
<div class='e-search'>".$frm->search('srch', $srch, 'go', $filterName, $filterArray, $filterVal).$frm->hidden('mode','online')."
|
||||
|
@@ -245,6 +245,11 @@ abstract class e_marketplace_adapter_abstract
|
||||
// Grab a remote file and save it in the /temp directory. requires CURL
|
||||
function getRemoteFile($remote_url, $local_file, $type='temp')
|
||||
{
|
||||
// FIXME - different methods (see xml handler getRemoteFile()), error handling, appropriate error messages,
|
||||
if (function_exists("curl_init"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$path = ($type == 'media') ? e_MEDIA : e_TEMP;
|
||||
|
||||
$fp = fopen($path.$local_file, 'w'); // media-directory is the root.
|
||||
@@ -289,7 +294,7 @@ class e_marketplace_adapter_wsdl extends e_marketplace_adapter_abstract
|
||||
'exception' => true,
|
||||
"uri" => "http://server.soap.e107.inc.com/",
|
||||
'cache_wsdl' => WSDL_CACHE_NONE,
|
||||
'connection_timeout' => 10,
|
||||
'connection_timeout' => 60,
|
||||
);
|
||||
|
||||
$this->client = new SoapClient($this->wsdl, $options);
|
||||
@@ -339,27 +344,38 @@ class e_marketplace_adapter_wsdl extends e_marketplace_adapter_abstract
|
||||
}
|
||||
else $ret = $this->client->$method($args);
|
||||
|
||||
$result = $ret;
|
||||
if(isset($ret['exception']))
|
||||
{
|
||||
$result['error']['message'] = "API Exception [call::{$method}]: (#".$ret['exception']['code'].") ".$ret['exception']['message'];
|
||||
$result['error']['code'] = $ret['exception']['code'];
|
||||
unset($ret['exception']);
|
||||
$result['exception'] = array();
|
||||
$result['exception']['message'] = "API Exception [call::{$method}]: (#".$ret['exception']['code'].") ".$ret['exception']['message'];
|
||||
$result['exception']['code'] = 'API_'.$ret['exception']['code'];
|
||||
}
|
||||
$result['data'] = $ret['data'];
|
||||
unset($ret);
|
||||
}
|
||||
catch(SoapFault $e)
|
||||
{
|
||||
$result['error']['message'] = "SoapFault Exception [call::{$method}]: (#".$e->getCode().") ".$e->getMessage();
|
||||
$result['error']['code'] = 'SOAP_'.$e->getCode();
|
||||
$result['exception']['message'] = "SoapFault Exception [call::{$method}]: (#".$e->faultcode.") ".$e->faultstring;
|
||||
$result['exception']['code'] = 'SOAP_'.$e->faultcode;
|
||||
if(E107_DEBUG_LEVEL)
|
||||
{
|
||||
$result['exception']['trace'] = $e->getTraceAsString();
|
||||
$result['exception']['message'] .= ". Header fault: ".($e->headerfault ? $e->headerfault : 'n/a');
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$result['error']['message'] = "Generic Exception [call::{$method}]: (#".$e->getCode().") ".$e->getMessage();
|
||||
$result['error']['code'] = 'GEN_'.$e->getCode();
|
||||
$result['exception']['message'] = "Generic Exception [call::{$method}]: (#".$e->getCode().") ".$e->getMessage();
|
||||
$result['exception']['code'] = 'GEN_'.$e->getCode();
|
||||
if(E107_DEBUG_LEVEL)
|
||||
{
|
||||
$result['exception']['trace'] = $e->getTraceAsString();
|
||||
}
|
||||
}
|
||||
if(E107_DEBUG_LEVEL)
|
||||
{
|
||||
print_a($this->client->__getLastRequest());
|
||||
$result['exception']['response'] = $this->client->__getLastResponse();
|
||||
$result['exception']['request'] = $this->client->__getLastRequest();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
@@ -431,20 +447,43 @@ class e_marketplace_adapter_xmlrpc extends e_marketplace_adapter_abstract
|
||||
// build the request query
|
||||
$qry = str_replace(array('s%5B', '%5D'), array('[', ']'), http_build_query($data, null, '&'));
|
||||
$url = $this->url.'?'.$qry;
|
||||
|
||||
$result = array();
|
||||
|
||||
// call it
|
||||
$xmlString = $client->loadXMLfile($url,false);
|
||||
$result = new SimpleXMLIterator($xmlString);
|
||||
//$result = $client->loadXMLfile($url, 'advanced');
|
||||
|
||||
return $this->fetch($method, $result);
|
||||
try
|
||||
{
|
||||
$xmlString = $client->loadXMLfile($url,false);
|
||||
$xml = new SimpleXMLIterator($xmlString);
|
||||
//$result = $client->loadXMLfile($url, 'advanced');
|
||||
$result = $this->fetch($method, $xml);
|
||||
if(isset($result['exception']))
|
||||
{
|
||||
$exception = $result['exception'];
|
||||
$result['exception'] = array();
|
||||
$result['exception']['message'] = "API Exception [call::{$method}]: (#".$exception['code'].") ".$exception['message'];
|
||||
$result['exception']['code'] = 'API_'.$exception['code'];
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$result['exception']['message'] = "Generic Exception [call::{$method}]: (#".$e->getCode().") ".$e->getMessage();
|
||||
$result['exception']['code'] = 'GEN_'.$e->getCode();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function fetch($method, &$result)
|
||||
{
|
||||
$ret = $this->parse($result);
|
||||
$this->fetchParams($ret);
|
||||
|
||||
switch ($method)
|
||||
{
|
||||
// normalize
|
||||
case 'getList':
|
||||
$ret['data'] = $ret['data']['item'];
|
||||
break;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
@@ -504,9 +543,9 @@ class e_marketplace_adapter_xmlrpc extends e_marketplace_adapter_abstract
|
||||
$_res = $this->parse($node, $name);
|
||||
if(is_string($_res)) $_res = trim($res);
|
||||
|
||||
if(empty($_res)) $ret[$name] = array();
|
||||
elseif(is_string($_res)) $ret[$name][] = $_res;
|
||||
else $ret[$name] = $_res; //array
|
||||
if(empty($_res)) $ret[$name] = array(); // empty
|
||||
elseif(is_string($_res)) $ret[$name][] = $_res; // string
|
||||
else $ret[$name][] = $_res; //array - test case, we wanna always force numerical array for now
|
||||
}
|
||||
else $ret[$name] = $this->parse($node, $name);
|
||||
}
|
||||
|
Reference in New Issue
Block a user