diff --git a/e107_admin/plugin.php b/e107_admin/plugin.php
index fc34bfdba..5c53da310 100644
--- a/e107_admin/plugin.php
+++ b/e107_admin/plugin.php
@@ -32,6 +32,15 @@ $plugin = new e107plugin;
$pman = new pluginManager;
define("e_PAGETITLE",ADLAN_98." - ".$pman->pagetitle);
+if(e_AJAX_REQUEST) // Ajax
+{
+ print_a($_POST);
+ print_a($_GET);
+ exit;
+
+}
+
+
if(e_AJAX_REQUEST && isset($_GET['action'])) // Ajax
{
if($_GET['action'] == 'download')
@@ -39,7 +48,7 @@ if(e_AJAX_REQUEST && isset($_GET['action'])) // Ajax
$string = base64_decode($_GET['src']);
parse_str($string, $p);
- print_a($p);
+ // print_a($p);
// $mp = $pman->getMarketplace();
// $mp->generateAuthKey($e107SiteUsername, $e107SiteUserpass);
@@ -49,7 +58,7 @@ if(e_AJAX_REQUEST && isset($_GET['action'])) // Ajax
// Server flush useless. It's ajax ready state 4, we can't flush (sadly) before that (at least not for all browsers)
echo "
Connecting...\n"; flush(); // FIXME change the modal default label, default is Loading...
// download and flush
- $mp->download($p['plugin_id'], $p['plugin_mode'], 'plugin');
+ // $mp->download($p['plugin_id'], $p['plugin_mode'], 'plugin');
echo "
"; flush();
}
@@ -307,6 +316,13 @@ class pluginManager{
$this->fieldpref[] = $key;
}
}
+
+ if($this->action == 'download')
+ {
+ $this->pluginDownload();
+ return;
+
+ }
if($this->action == 'avail' || $this->action == 'installed') // Plugin Check is done during upgrade_routine.
@@ -579,12 +595,16 @@ class pluginManager{
$d = http_build_query($data,false,'&');
//$url = e_SELF."?src=".base64_encode($d);
- $url = e_SELF.'?action=download&src='.base64_encode($d);//$url.'&action=download';
+ // $url = e_SELF.'?action=download&src='.base64_encode($d);//$url.'&action=download';
$id = 'plug_'.$data['plugin_id'];
//
+ $url = e_SELF.'?mode=download&src='.base64_encode($d);
+ $dicon = '
';
+
+
// Temporary Pop-up version.
- $dicon = '
';
+ // $dicon = '
';
// $dicon = "
";
@@ -592,6 +612,60 @@ class pluginManager{
{$dicon}
";
}
+
+
+
+ private function pluginDownload()
+ {
+ define('e_IFRAME', true);
+ $frm = e107::getForm();
+ $mes = e107::getMessage();
+
+ // print_a($_GET);
+
+ $string = base64_decode($_GET['src']);
+ parse_str($string, $data);
+
+
+ $mp = $this->getMarketplace();
+ // $mp->generateAuthKey($e107SiteUsername, $e107SiteUserpass);
+
+ // print_a($data);
+
+ // Server flush useless. It's ajax ready state 4, we can't flush (sadly) before that (at least not for all browsers)
+ $mes->addSuccess("Connecting...");
+
+ if($mp->download($data['plugin_id'], $data['plugin_mode'], 'plugin'))
+ {
+ $text = e107::getPlugin()->install($data['plugin_folder']);
+
+ $mes->addInfo($text);
+ echo $mes->render('default', 'success');
+ }
+ else
+ {
+ echo $mes->addError('Unable to continue')->render('default', 'error');
+ }
+
+ echo $mes->render('default', 'debug');
+ return;
+
+
+
+ $text ="";
+ // print_a($data);
+ $text .= $frm->open('upload-url-form','post');
+
+ $text .= "";
+ $text .= "";
+ $text .= $frm->admin_button('upload_remote_url',1,'create','Install');
+ $text .= "
";
+ $text .= "\n\n";
+
+ $text .= $frm->close();
+ echo $text;
+
+ }
// FIXME - move it to plugin handler, similar to install_plugin() routine
diff --git a/e107_handlers/e_marketplace.php b/e107_handlers/e_marketplace.php
index b9caca90e..f7a957ec5 100644
--- a/e107_handlers/e_marketplace.php
+++ b/e107_handlers/e_marketplace.php
@@ -226,7 +226,7 @@ abstract class e_marketplace_adapter_abstract
* e107.org download URL
* @var string
*/
- protected $downloadUrl = 'http://e107.org/request';
+ protected $downloadUrl = 'http://e107.org/request/';
/**
* e107.org service URL [adapter implementation required]
@@ -240,6 +240,7 @@ abstract class e_marketplace_adapter_abstract
*/
public $requestMethod = null;
+
/**
* @var eAuth
*/
@@ -311,40 +312,47 @@ abstract class e_marketplace_adapter_abstract
public function download($id, $mode, $type)
{
$tp = e107::getParser();
+ $mes = e107::getMessage();
+
$id = intval($id);
$qry = 'id='.$id.'&type='.$type.'&mode='.$mode;
$remotefile = $this->downloadUrl."?auth=".$this->getAuthKey()."&".$qry;
$localfile = md5($remotefile.time()).".zip";
- echo "Downloading...
";
- flush();
+ $mes->addSuccess("Downloading...");
+
// FIXME call the service, check status first, then download (if status OK), else retireve the error break and show it
$result = $this->getRemoteFile($remotefile, $localfile);
if(!$result)
{
- echo "Download Error.
"; flush();
+ $mes->addError("Download Error"); // flush();
if(filesize(e_TEMP.$localfile))
{
$contents = file_get_contents(e_TEMP.$localfile);
$contents = explode('REQ_', $contents);
- echo '[#'.trim($contents[1]).'] '.trim($contents[0]); flush();
+ $mes->addError('[#'.trim($contents[1]).'] '.trim($contents[0])); flush();
}
@unlink(e_TEMP.$localfile);
- return;
+ return false;
}
+
+
if(!file_exists(e_TEMP.$localfile))
{
- //ADMIN_FALSE_ICON
- echo "Automated download not possible. Please Download Manually"; flush();
+ $mes->addError( "Automated download not possible. Please Download Manually");
if(E107_DEBUG_LEVEL > 0)
{
- echo '
local='.$localfile; flush();
+ $mes->addDebug('local='.$localfile); // ; flush();
}
- return;
+ return false;
+ }
+ else
+ {
+ // $mes->addSuccess("Download Successful");
}
/*
else
@@ -371,49 +379,65 @@ abstract class e_marketplace_adapter_abstract
if($dir && is_dir($destpath.$dir))
{
- echo "(".ucfirst($type).") Already Downloaded - ".basename($destpath).'/'.$dir; flush();
+ $mes->addError("(".ucfirst($type).") Already Downloaded - ".basename($destpath).'/'.$dir); flush();
@unlink(e_TEMP.$localfile);
- return;
+ @unlink(e_TEMP.$dir );
+ return false;
}
if($dir == '')
{
- echo "Couldn't detect the root folder in the zip."; flush();
+ $mes->addError("Couldn't detect the root folder in the zip."); // flush();
@unlink(e_TEMP.$localfile);
- return;
+ return false;
}
if(is_dir(e_TEMP.$dir))
{
- echo "Unzipping...
";
+ $this->success[] = "Unzipping...";
if(!rename(e_TEMP.$dir,$destpath.$dir))
{
- echo "Couldn't Move ".e_TEMP.$dir." to ".$destpath.$dir." Folder"; flush(); usleep(50000);
+ $mes->addError("Couldn't Move ".e_TEMP.$dir." to ".$destpath.$dir." Folder"); // flush(); usleep(50000);
@unlink(e_TEMP.$localfile);
- return;
+ return false;
}
- echo "Download Complete!
"; flush();
+ $mes->addSuccess("Download Complete!"); flush();
// $dir = basename($unarc[0]['filename']);
// $plugPath = preg_replace("/[^a-z0-9-\._]/", "-", strtolower($dir));
//$status = "Done"; // ADMIN_TRUE_ICON;
@unlink(e_TEMP.$localfile);
- return;
+ return true;
}
else
{
//ADMIN_FALSE_ICON.
- echo "Download Manually"; flush(); usleep(50000);
+ $mes->addSuccess( "Download Manually"); // flush(); usleep(50000);
if(E107_DEBUG_LEVEL > 0)
{
- echo print_a($unarc, true); flush();
+ $mes->addDebug(print_a($unarc, true)); flush();
}
+
}
@unlink(e_TEMP.$localfile);
+ return false;
}
+
+ public function getErrors()
+ {
+ return $this->errors;
+ }
+
+ public function getSuccess()
+ {
+ return $this->success;
+ }
+
+
+
// Grab a remote file and save it in the /temp directory. requires CURL
function getRemoteFile($remote_url, $local_file, $type='temp')
{
diff --git a/e107_handlers/file_class.php b/e107_handlers/file_class.php
index 217bb734f..87e52696d 100644
--- a/e107_handlers/file_class.php
+++ b/e107_handlers/file_class.php
@@ -946,7 +946,8 @@ class e_file
$text .= "\\n target=".$target;
if(E107_DEBUG_LEVEL > 0)
{
- echo "";
+ e107::getMessage()->addDebug($text);
+ // echo "";
}
return $target;