mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 12:48:24 +01:00
Theme downloading fixes and Theme info GUI fixes. jQuery cache fix.
This commit is contained in:
parent
a63abab93e
commit
67afc1515e
@ -70,7 +70,6 @@ if(e_AJAX_REQUEST)
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(e_AJAX_REQUEST)
|
||||
{
|
||||
if(vartrue($_GET['src'])) // Process Theme Download.
|
||||
@ -87,66 +86,12 @@ if(e_AJAX_REQUEST)
|
||||
|
||||
$remotefile = $p['url'];
|
||||
|
||||
$localfile = md5($remotefile.time()).".zip";
|
||||
$status = "Downloading...";
|
||||
|
||||
e107::getFile()->getRemoteFile($remotefile,$localfile);
|
||||
|
||||
if(!file_exists(e_TEMP.$localfile))
|
||||
{
|
||||
$status = ADMIN_FALSE_ICON."<br /><a href='".$remotefile."'>Download Manually</a>";
|
||||
echo $status;
|
||||
exit;
|
||||
}
|
||||
// chmod(e_PLUGIN,0777);
|
||||
chmod(e_TEMP.$localfile,0755);
|
||||
|
||||
require_once(e_HANDLER."pclzip.lib.php");
|
||||
$archive = new PclZip(e_TEMP.$localfile);
|
||||
$unarc = ($fileList = $archive -> extract(PCLZIP_OPT_PATH, e_THEME, PCLZIP_OPT_SET_CHMOD, 0755));
|
||||
// chmod(e_PLUGIN,0755);
|
||||
$dir = basename($unarc[0]['filename']);
|
||||
// chmod(e_UPLOAD.$localfile,0666);
|
||||
|
||||
|
||||
|
||||
/* Cannot use this yet until 'folder' is included in feed.
|
||||
if($dir != $p['plugin_folder'])
|
||||
{
|
||||
|
||||
echo "<br />There is a problem with the data submitted by the author of the plugin.";
|
||||
echo "dir=".$dir;
|
||||
echo "<br />pfolder=".$p['plugin_folder'];
|
||||
exit;
|
||||
}
|
||||
*/
|
||||
|
||||
if($unarc[0]['folder'] ==1 && is_dir($unarc[0]['filename']))
|
||||
{
|
||||
$status = "Unzipping...";
|
||||
$dir = basename($unarc[0]['filename']);
|
||||
$plugPath = preg_replace("/[^a-z0-9-\._]/", "-", strtolower($dir));
|
||||
$status = ADMIN_TRUE_ICON;
|
||||
//unlink(e_UPLOAD.$localfile);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// print_a($fileList);
|
||||
$status = ADMIN_FALSE_ICON."<br /><a href='".$remotefile."'>Download Manually</a>";
|
||||
//echo $archive->errorInfo(true);
|
||||
// $status = "There was a problem";
|
||||
//unlink(e_UPLOAD.$localfile);
|
||||
}
|
||||
|
||||
echo $status;
|
||||
// @unlink(e_TEMP.$localfile);
|
||||
|
||||
// echo "file=".$file;
|
||||
e107::getFile()->download($remotefile,'theme');
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Theme Info Ajax
|
||||
$tm = (string) $_GET['id'];
|
||||
$data = $themec->getThemeInfo($tm);
|
||||
echo $themec->renderThemeInfo($data);
|
||||
@ -157,7 +102,7 @@ else
|
||||
{
|
||||
require_once("auth.php");
|
||||
|
||||
|
||||
/*
|
||||
echo '
|
||||
|
||||
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
@ -172,6 +117,7 @@ else
|
||||
<a href="#" data-dismiss="modal" class="btn btn-primary">Close</a>
|
||||
</div>
|
||||
</div>';
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -657,5 +657,129 @@ class e_file
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Download a Plugin or Theme to Temp, then test and move to plugin/theme folder and backup to system backup folder.
|
||||
* @param $remotefile URL
|
||||
* @param $type plugin or theme
|
||||
*/
|
||||
public function download($remotefile, $type='theme')
|
||||
{
|
||||
$tp = e107::getParser();
|
||||
|
||||
$localfile = md5($remotefile.time()).".zip";
|
||||
$status = "Downloading...";
|
||||
|
||||
$result = $this->getRemoteFile($remotefile,$localfile);
|
||||
|
||||
if(!file_exists(e_TEMP.$localfile))
|
||||
{
|
||||
$status = ADMIN_FALSE_ICON."<br /><a href='".$remotefile."'>Download Manually</a>";
|
||||
|
||||
if(E107_DEBUG_LEVEL > 0)
|
||||
{
|
||||
$status .= 'local='.$localfile;
|
||||
//$status .= ($result) ? "Downloaded" : "Couldn't get Remote";
|
||||
}
|
||||
|
||||
echo $status;
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
// chmod(e_PLUGIN,0777);
|
||||
chmod(e_TEMP.$localfile,0755);
|
||||
|
||||
require_once(e_HANDLER."pclzip.lib.php");
|
||||
|
||||
$archive = new PclZip(e_TEMP.$localfile);
|
||||
$unarc = ($fileList = $archive -> extract(PCLZIP_OPT_PATH, e_TEMP, PCLZIP_OPT_SET_CHMOD, 0755)); // Store in TEMP first.
|
||||
$dir = $this->getRootFolder($unarc);
|
||||
$destpath = ($type == 'theme') ? e_THEME : e_PLUGIN;
|
||||
|
||||
@copy(e_TEMP.$localfile,e_BACKUP.$dir.".zip"); // Make a Backup in the system folder.
|
||||
|
||||
if($dir && is_dir($destpath.$dir))
|
||||
{
|
||||
$alert = $tp->toJS("Theme Already Installed".$destpath.$dir);
|
||||
echo "<script>alert('".$alert."')</script>";
|
||||
@unlink(e_TEMP.$localfile);
|
||||
exit;
|
||||
}
|
||||
|
||||
if(is_dir(e_TEMP.$dir))
|
||||
{
|
||||
$status = "Unzipping...";
|
||||
if(!rename(e_TEMP.$dir,$destpath.$dir))
|
||||
{
|
||||
$alert = $tp->toJS("Couldn't Move Theme to Theme Folder");
|
||||
echo "<script>alert('".$alert."')</script>";
|
||||
@unlink(e_TEMP.$localfile);
|
||||
exit;
|
||||
}
|
||||
|
||||
$alert = $tp->toJS("Download Complete!");
|
||||
echo "<script>alert('".$alert."')</script>";
|
||||
|
||||
// $dir = basename($unarc[0]['filename']);
|
||||
// $plugPath = preg_replace("/[^a-z0-9-\._]/", "-", strtolower($dir));
|
||||
$status = ADMIN_TRUE_ICON;
|
||||
|
||||
}
|
||||
// elseif(already_a_directory
|
||||
else
|
||||
{
|
||||
// print_a($fileList);
|
||||
$status = ADMIN_FALSE_ICON."<br /><a href='".$remotefile."'>Download Manually</a>";
|
||||
if(E107_DEBUG_LEVEL > 0)
|
||||
{
|
||||
$status .= print_a($unarc, true);
|
||||
}
|
||||
//
|
||||
// $status = "There was a problem";
|
||||
//unlink(e_UPLOAD.$localfile);
|
||||
}
|
||||
|
||||
// echo "<script>alert('".$tp->toJS($status)."')</script>";
|
||||
echo $status;
|
||||
@unlink(e_TEMP.$localfile);
|
||||
|
||||
// echo "file=".$file;
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Runs through the zip archive array and finds the root directory.
|
||||
*/
|
||||
private function getRootFolder($unarc)
|
||||
{
|
||||
foreach($unarc as $d)
|
||||
{
|
||||
$target = trim($d['stored_filename'],'/');
|
||||
|
||||
$test = basename(str_replace(e_TEMP,"", $d['stored_filename']),'/');
|
||||
|
||||
if($d['folder'] == 1 && $target == $test) //
|
||||
{
|
||||
// $text .= "\\n test = ".$test;
|
||||
$text .= "\\n test=".$test;
|
||||
$text .= "\\n target=".$target;
|
||||
if(E107_DEBUG_LEVEL > 0)
|
||||
{
|
||||
echo "<script>alert('".$text."')</script>";
|
||||
}
|
||||
return $target;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class themeHandler
|
||||
var $themeConfigObj = null;
|
||||
var $noLog = FALSE;
|
||||
|
||||
private $approvedAdminThemes = array('bootstrap','jayya');
|
||||
private $approvedAdminThemes = array('bootstrap');
|
||||
|
||||
public $allowedCategories = array('generic',
|
||||
'adult',
|
||||
@ -499,7 +499,10 @@ class themeHandler
|
||||
$text = "";
|
||||
foreach($xdata['theme'] as $r)
|
||||
{
|
||||
$mes->addDebug(print_a($r,true));
|
||||
if(E107_DBG_PATH)
|
||||
{
|
||||
$mes->addDebug(print_a($r,true));
|
||||
}
|
||||
|
||||
$theme = array(
|
||||
'name' => $r['@attributes']['name'],
|
||||
@ -643,8 +646,8 @@ class themeHandler
|
||||
$preview = "<a href='".e_BASE."news.php?themepreview.".$theme['id']."' title='".TPVLAN_9."' >".($theme['preview'] ? "<img src='".$theme['preview']."' style='border: 1px solid #000;width:200px' alt='' />" : "<img src='".e_IMAGE_ABS."admin_images/nopreview.png' title='".TPVLAN_12."' alt='' />")."</a>";
|
||||
$description = vartrue($theme['description'],'');
|
||||
|
||||
$text = "<table class='table table-striped'>
|
||||
<tr><th colspan='2'><h3>".$theme['name']." ".$theme['version']."</h3></th></tr>";
|
||||
$text = "<table class='table table-striped'>";
|
||||
// $text .= "<tr><th colspan='2'><h3>".$theme['name']." ".$theme['version']."</h3></th></tr>";
|
||||
|
||||
|
||||
|
||||
@ -668,22 +671,7 @@ class themeHandler
|
||||
}
|
||||
|
||||
|
||||
if(count($theme['preview']))
|
||||
{
|
||||
$text .= "<tr><td colspan='2'>";
|
||||
foreach($theme['preview'] as $pic)
|
||||
{
|
||||
$text .= "<div style='padding:5px;width:700px'>
|
||||
<img src='".$pic."' alt='' />
|
||||
</div>";
|
||||
|
||||
}
|
||||
|
||||
$text .= "</td>
|
||||
</tr>";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// New in 0.8 WORK IN PROGRESS ----
|
||||
@ -691,7 +679,7 @@ class themeHandler
|
||||
{
|
||||
$itext .= "<tr>
|
||||
<td style='vertical-align:top; width:24%'><b>".TPVLAN_50."</b>:</td>
|
||||
<td style='vertical-align:top'><table style='margin-left:0px;margin-right:auto' >
|
||||
<td style='vertical-align:top'><table class='table' style='margin-left:0px;margin-right:auto' >
|
||||
<tr>";
|
||||
$itext .= ($mode == 1) ? "<td class='fcaption' style='text-align:center;vertical-align:top;'>Default</td>" : "";
|
||||
$itext .= "
|
||||
@ -730,9 +718,16 @@ class themeHandler
|
||||
</tr>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$itext .= "</table></td></tr>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
// $text .= "<tr><td><b>".TPVLAN_22.": </b></td><td colspan='2'>";
|
||||
// foreach ($theme['css'] as $val)
|
||||
// {
|
||||
@ -741,7 +736,37 @@ class themeHandler
|
||||
// $text .= "</td></tr>";
|
||||
|
||||
$text .= $itext."</table>";
|
||||
|
||||
if(count($theme['preview']))
|
||||
{
|
||||
$text .= "<tr><td colspan='2'>";
|
||||
foreach($theme['preview'] as $pic)
|
||||
{
|
||||
|
||||
$picFull = (substr($pic,0,4) == 'http') ? $pic : e_THEME.$theme['path']."/".$pic;
|
||||
|
||||
|
||||
$text .= "<div style='padding:5px;width:700px'>
|
||||
<img src='".$picFull."' alt=\"".$theme['name']."\" />
|
||||
</div>";
|
||||
|
||||
}
|
||||
|
||||
// $text .= "</td>
|
||||
// </tr>";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// $text .= "<div class='right'><a href='#themeInfo_".$theme['id']."' class='e-expandit'>Close</a></div>";
|
||||
|
||||
if(E107_DEBUG_LEVEL > 0)
|
||||
{
|
||||
$text .= print_a($theme, true);
|
||||
}
|
||||
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
@ -823,11 +848,11 @@ class themeHandler
|
||||
$author = ($theme['email'] ? "<a href='mailto:".$theme['email']."' title='".$theme['email']."'>".$theme['author']."</a>" : $theme['author']);
|
||||
$website = ($theme['website'] ? "<a href='".$theme['website']."' rel='external'>".$theme['website']."</a>" : "");
|
||||
$preview = "<a href='".e_BASE."news.php?themepreview.".$theme['id']."' title='".TPVLAN_9."' >".($theme['preview'] ? "<img src='".$theme['preview']."' style='border: 1px solid #000;width:200px' alt='' />" : "<img src='".e_IMAGE_ABS."admin_images/nopreview.png' title='".TPVLAN_12."' alt='' />")."</a>";
|
||||
$main_icon = ($pref['sitetheme'] != $theme['path']) ? "<input class='top e-tip' type='image' src='".e_IMAGE_ABS."admin_images/main_32.png' name='selectmain[".$theme['id']."]' alt=\"".TPVLAN_10."\" title=\"".TPVLAN_10."\" />" : E_32_TRUE;
|
||||
$main_icon = ($pref['sitetheme'] != $theme['path']) ? "<input class='top' type='image' src='".e_IMAGE_ABS."admin_images/main_32.png' name='selectmain[".$theme['id']."]' alt=\"".TPVLAN_10."\" title=\"".TPVLAN_10."\" />" : E_32_TRUE;
|
||||
// $info_icon = "<a data-toggle='modal' data-target='".e_SELF."' href='#themeInfo_".$theme['id']."' class='e-tip' title='".TPVLAN_7."'><img src='".e_IMAGE_ABS."admin_images/info_32.png' alt='' class='icon S32' /></a>";
|
||||
$info_icon = "<a data-toggle='modal' href='".e_SELF."?id=".$theme['path']."' data-target='#myModal' class='e-tip' title='".TPVLAN_7."'>".E_32_CAT_ABOUT."</a>";
|
||||
$preview_icon = "<a title='Preview : ".$theme['name']."' rel='external' class='e-tip e-dialog' href='".e_BASE."index.php?themepreview.".$theme['id']."'>".E_32_SEARCH."</a>";
|
||||
$admin_icon = ($pref['admintheme'] != $theme['path'] ) ? "<input class='top e-tip' type='image' src='".e_IMAGE_ABS."e107_icon_32.png' name='selectadmin[".$theme['id']."]' alt=\"".TPVLAN_32."\" title=\"".TPVLAN_32."\" />\n" : E_32_TRUE;
|
||||
$info_icon = "<a data-toggle='modal' data-modal-caption=\"".$theme['name']." ".$theme['version']."\" href='".e_SELF."?id=".$theme['path']."' data-target='#uiModal' title='".TPVLAN_7."'>".E_32_CAT_ABOUT."</a>";
|
||||
$preview_icon = "<a title='Preview : ".$theme['name']."' rel='external' class='e-dialog' href='".e_BASE."index.php?themepreview.".$theme['id']."'>".E_32_SEARCH."</a>";
|
||||
$admin_icon = ($pref['admintheme'] != $theme['path'] ) ? "<input class='top' type='image' src='".e_IMAGE_ABS."e107_icon_32.png' name='selectadmin[".$theme['id']."]' alt=\"".TPVLAN_32."\" title=\"".TPVLAN_32."\" />\n" : E_32_TRUE;
|
||||
|
||||
|
||||
if($_GET['mode'] == 'online')
|
||||
@ -836,8 +861,8 @@ class themeHandler
|
||||
$d = http_build_query($theme,false,'&');
|
||||
$url = e_SELF."?src=".base64_encode($d);
|
||||
$id = $frm->name2id($theme['name']);
|
||||
$main_icon = "<a data-src='".$url."' href='#' data-target='{$id}' data-loading='".e_IMAGE."/generic/loading_32.gif' class='e-ajax e-tip' title='Download' ><img class='top' src='".e_IMAGE_ABS."icons/download_32.png' alt='' /></a> ";
|
||||
$info_icon = "<a data-toggle='modal' href='".$url."&info=1' data-cache='false' data-target='#myModal' class='e-tip' title='".TPVLAN_7."'>".E_32_CAT_ABOUT."</a>";
|
||||
$main_icon = "<a data-src='".$url."' href='#' data-target='{$id}' data-loading='".e_IMAGE."/generic/loading_32.gif' class='e-ajax' title='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='".$url."&info=1' data-cache='false' data-target='#uiModal' title='".TPVLAN_7."'>".E_32_CAT_ABOUT."</a>";
|
||||
|
||||
//XXX modal-Cache is currently enabled by default. Awaiting inclusion of data-cache feature.
|
||||
// See here: https://github.com/twitter/bootstrap/pull/4224
|
||||
@ -876,7 +901,7 @@ class themeHandler
|
||||
}
|
||||
|
||||
$thumbnail = "<img src='".$thumbPath."' style='width:200px; height:160px;' alt='' />";
|
||||
$preview_icon = "<a title='Preview : ".$theme['name']."' rel='external' class='e-dialog e-tip' href='".$previewPath."'>".E_32_SEARCH."</a>";
|
||||
$preview_icon = "<a title='Preview : ".$theme['name']."' rel='external' class='e-dialog' href='".$previewPath."'>".E_32_SEARCH."</a>";
|
||||
|
||||
// $thumbnail .= "</a>";
|
||||
|
||||
|
@ -84,6 +84,7 @@ a.brand:hover img {
|
||||
}
|
||||
|
||||
.modal { min-width:800px; left:42% }
|
||||
.modal-header { padding-left:20px; background-image: -moz-linear-gradient(center top , rgb(253, 253, 253) 0%, rgb(234, 234, 234) 100%); }
|
||||
|
||||
@media (min-width: 1500px) {
|
||||
|
||||
|
@ -40,15 +40,14 @@ $(document).ready(function()
|
||||
$('a[data-toggle="modal"]').on('click', function()
|
||||
{
|
||||
var link = $(this).attr('href');
|
||||
var caption = $(this).attr('data-modal-caption');
|
||||
$('#uiModal .modal-caption').text(caption);
|
||||
// $('#uiModal .modal-label').text('Loading...');
|
||||
// $('#uiModal .modal-body').html(link);
|
||||
alert(link);
|
||||
// alert(caption);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
$('a[data-toggle="modal"]').on('click', function()
|
||||
|
@ -3,7 +3,8 @@ $.ajaxSetup({
|
||||
dataFilter: function(data, type) {
|
||||
if(type != 'json' || !data) return data;
|
||||
return data.replace(/^\/\*-secure-([\s\S]*)\*\/\s*$/, '$1');
|
||||
}
|
||||
},
|
||||
cache: false // Was Really NEeded!
|
||||
});
|
||||
|
||||
$(document).ready(function()
|
||||
|
Loading…
x
Reference in New Issue
Block a user