mirror of
https://github.com/e107inc/e107.git
synced 2025-03-14 01:19:44 +01:00
Ajax theme downloads
This commit is contained in:
parent
380e46cd56
commit
c4121e5fd7
@ -69,35 +69,30 @@ if(e_AJAX_REQUEST)
|
||||
define('e_IFRAME',true);
|
||||
}
|
||||
|
||||
// XXX message till we have better way to do the things
|
||||
if(isset($_GET['action']) && $_GET['action'] == 'download') // Process Theme Download.
|
||||
{
|
||||
$string = base64_decode($_GET['src']);
|
||||
parse_str($string,$p);
|
||||
$mp = $themec->getMarketplace();
|
||||
$mp->generateAuthKey($e107SiteUsername, $e107SiteUserpass);
|
||||
$status = $mp->download($p['id'], $p['mode'], $p['type']);
|
||||
|
||||
if($status)
|
||||
{
|
||||
e107::getMessage()->addInfo($status, 'default', true);
|
||||
}
|
||||
unset($_GET['src'], $_GET['action']);
|
||||
$qry = '';
|
||||
if($_GET) $qry = '?'.http_build_query($_GET, false, '&');
|
||||
e107::getRedirect()->redirect(e_REQUEST_SELF.$qry);
|
||||
}
|
||||
|
||||
if(e_AJAX_REQUEST)
|
||||
{
|
||||
switch ($_GET['action'])
|
||||
{
|
||||
case 'download':
|
||||
$string = base64_decode($_GET['src']);
|
||||
parse_str($string,$p);
|
||||
$mp = $themec->getMarketplace();
|
||||
$mp->generateAuthKey($e107SiteUsername, $e107SiteUserpass);
|
||||
// Server flush useless. It's ajax ready state 4, we can't flush (sadly) before that (at least not for all browsers)
|
||||
echo "<pre>Connecting...<br />"; flush(); // FIXME change the modal default label, default is Loading...
|
||||
// download and flush
|
||||
$mp->download($p['id'], $p['mode'], $p['type']);
|
||||
echo "</pre>"; flush();
|
||||
exit;
|
||||
break;
|
||||
|
||||
case 'info':
|
||||
$string = base64_decode($_GET['src']);
|
||||
parse_str($string,$p);
|
||||
echo $themec->renderThemeInfo($p);
|
||||
exit;
|
||||
break;
|
||||
|
||||
case 'preview':
|
||||
// Theme Info Ajax
|
||||
$tm = (string) $_GET['id'];
|
||||
|
@ -156,7 +156,7 @@ abstract class e_marketplace_adapter_abstract
|
||||
* XXX better way to return status (e.g. getError(), getStatus() service call before download)
|
||||
* XXX temp is not well cleaned
|
||||
* XXX themes/plugins not well tested after unzip (example - Headline 1.0, non-default structure, same applies to most FS net free themes)
|
||||
*
|
||||
* This method is direct outputting the status. If not needed - use buffer
|
||||
* @param string $remotefile URL
|
||||
* @param string $type plugin or theme
|
||||
*/
|
||||
@ -168,35 +168,35 @@ abstract class e_marketplace_adapter_abstract
|
||||
$remotefile = $this->downloadUrl."?auth=".$this->getAuthKey()."&".$qry;
|
||||
|
||||
$localfile = md5($remotefile.time()).".zip";
|
||||
$status = "Downloading...";
|
||||
|
||||
echo "Downloading...<br />";
|
||||
flush();
|
||||
// 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)
|
||||
{
|
||||
$status = "Download Error.";
|
||||
echo "Download Error.<br />"; flush();
|
||||
if(filesize(e_TEMP.$localfile))
|
||||
{
|
||||
$contents = file_get_contents(e_TEMP.$localfile);
|
||||
$contents = explode('REQ_', $contents);
|
||||
$status .= '<br />[#'.trim($contents[1]).'] '.trim($contents[0]);
|
||||
echo '[#'.trim($contents[1]).'] '.trim($contents[0]); flush();
|
||||
}
|
||||
@unlink(e_TEMP.$localfile);
|
||||
return $status;
|
||||
return;
|
||||
}
|
||||
if(!file_exists(e_TEMP.$localfile))
|
||||
{
|
||||
//ADMIN_FALSE_ICON
|
||||
$status = "<a href='".$remotefile."'>Download Manually</a>";
|
||||
echo "Automated download not possible. Please <a href='".$remotefile."'>Download Manually</a>"; flush();
|
||||
|
||||
if(E107_DEBUG_LEVEL > 0)
|
||||
{
|
||||
$status .= '<br />local='.$localfile;
|
||||
echo '<br />local='.$localfile; flush();
|
||||
}
|
||||
|
||||
return $status;
|
||||
return;
|
||||
}
|
||||
/*
|
||||
else
|
||||
@ -223,50 +223,46 @@ abstract class e_marketplace_adapter_abstract
|
||||
|
||||
if($dir && is_dir($destpath.$dir))
|
||||
{
|
||||
$alert = $tp->toJS(ucfirst($type)." Already Installed".$destpath.$dir);
|
||||
echo "<script>alert('".$alert."')</script>";
|
||||
echo "Already Installed";
|
||||
echo "(".ucfirst($type).") Already Installed".$destpath.$dir; flush();
|
||||
@unlink(e_TEMP.$localfile);
|
||||
return;
|
||||
}
|
||||
|
||||
if($dir == '')
|
||||
{
|
||||
echo "<script>alert('Couldn\'t detect the root folder in the zip.')</script>";
|
||||
echo "Couldn't detect the root folder in the zip."; flush();
|
||||
@unlink(e_TEMP.$localfile);
|
||||
return;
|
||||
}
|
||||
|
||||
if(is_dir(e_TEMP.$dir))
|
||||
{
|
||||
$status = "Unzipping...";
|
||||
echo "Unzipping...<br />";
|
||||
if(!rename(e_TEMP.$dir,$destpath.$dir))
|
||||
{
|
||||
$alert = $tp->toJS("Couldn't Move ".e_TEMP.$dir." to ".$destpath.$dir." Folder");
|
||||
echo "<script>alert('".$alert."')</script>";
|
||||
echo "Couldn't Move ".e_TEMP.$dir." to ".$destpath.$dir." Folder"; flush(); usleep(50000);
|
||||
@unlink(e_TEMP.$localfile);
|
||||
return;
|
||||
}
|
||||
|
||||
$alert = $tp->toJS("Download Complete!");
|
||||
echo "<script>alert('".$alert."')</script>";
|
||||
echo "Download Complete!<br />"; flush();
|
||||
|
||||
// $dir = basename($unarc[0]['filename']);
|
||||
// $plugPath = preg_replace("/[^a-z0-9-\._]/", "-", strtolower($dir));
|
||||
$status = "Done"; // ADMIN_TRUE_ICON;
|
||||
return $status;
|
||||
//$status = "Done"; // ADMIN_TRUE_ICON;
|
||||
@unlink(e_TEMP.$localfile);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//ADMIN_FALSE_ICON.
|
||||
$status = "<a href='".$remotefile."'>Download Manually</a>";
|
||||
echo "<a href='".$remotefile."'>Download Manually</a>"; flush(); usleep(50000);
|
||||
if(E107_DEBUG_LEVEL > 0)
|
||||
{
|
||||
$status .= print_a($unarc, true);
|
||||
echo print_a($unarc, true); flush();
|
||||
}
|
||||
}
|
||||
|
||||
return $status;
|
||||
@unlink(e_TEMP.$localfile);
|
||||
}
|
||||
|
||||
|
@ -1037,7 +1037,8 @@ class themeHandler
|
||||
$downloadUrl = e_SELF.'?'.(e_QUERY ? e_QUERY.'&' : '').'&action=download&src='.base64_encode($d);//$url.'&action=download';
|
||||
$infoUrl = $url.'&action=info';
|
||||
|
||||
$main_icon = "<a data-src='".$downloadUrl."' href='{$downloadUrl}' data-target='{$id}' data-loading='".e_IMAGE."/generic/loading_32.gif' class='-e-ajax' title='".$LAN_DOWNLOAD."' ><img class='top' src='".e_IMAGE_ABS."icons/download_32.png' alt='' /></a> ";
|
||||
//$main_icon = "<a data-src='".$downloadUrl."' href='{$downloadUrl}' data-target='{$id}' data-loading='".e_IMAGE."/generic/loading_32.gif' class='-e-ajax' title='".$LAN_DOWNLOAD."' ><img class='top' src='".e_IMAGE_ABS."icons/download_32.png' alt='' /></a> ";
|
||||
$main_icon = "<a data-toggle='modal' data-modal-caption=\"Downloading ".$theme['name']." ".$theme['version']."\" href='{$downloadUrl}' data-cache='false' data-target='#uiModal' title='".$LAN_DOWNLOAD."' ><img class='top' src='".e_IMAGE_ABS."icons/download_32.png' alt='' /></a> ";
|
||||
$info_icon = "<a data-toggle='modal' data-modal-caption=\"".$theme['name']." ".$theme['version']."\" href='".$infoUrl."' data-cache='false' data-target='#uiModal' title='".TPVLAN_7."'>".trim(E_32_CAT_ABOUT)."</a>";
|
||||
|
||||
if($theme['livedemo'])
|
||||
|
Loading…
x
Reference in New Issue
Block a user