mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 12:48:24 +01:00
Media-Manager fixes. filepicker() /jquery fix. e_AJAX_REQUEST - header detect added. Plugin install from xml feed. (tested locally only)
This commit is contained in:
parent
8e7f63fe25
commit
23c4e06972
@ -269,8 +269,9 @@ class media_form_ui extends e_admin_form_ui
|
||||
$preview = basename($path);
|
||||
|
||||
$bbcode = ($_GET['bbcode']=='file') ? "file" : "";
|
||||
|
||||
return "<input type='button' value='Select' class='e-media-select e-dialog-close' data-id='{$id}' data-name=\"".$title."\" data-target='{$tagid}' data-bbcode='{$bbcode}' data-path='{$path}' data-preview='{$preview}' title=\"".$title."\" />";
|
||||
// $save = ($_GET['bbcode']!='file') ? "e-dialog-save" : "";
|
||||
// e-dialog-close
|
||||
return "<input type='button' value='Select' class='e-media-select e-dialog-save e-dialog-close' data-id='{$id}' data-name=\"".$title."\" data-target='{$tagid}' data-bbcode='{$bbcode}' data-path='{$path}' data-preview='{$preview}' title=\"".$title."\" />";
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,6 +20,64 @@ if (!getperms("Z"))
|
||||
exit;
|
||||
}
|
||||
|
||||
// Only tested Locally so far.
|
||||
if(e_AJAX_REQUEST && isset($_GET['src'])) // Ajax
|
||||
{
|
||||
$string = base64_decode($_GET['src']);
|
||||
parse_str($string,$p);
|
||||
$remotefile = $p['plugin_url'];
|
||||
|
||||
$localfile = md5($remotefile.time()).".zip";
|
||||
$status = "Downloading...";
|
||||
|
||||
e107::getFile()->getRemoteFile($remotefile,$localfile);
|
||||
|
||||
if(!file_exists(e_UPLOAD.$localfile))
|
||||
{
|
||||
echo 'There was a problem retrieving the file';
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(e_HANDLER."pclzip.lib.php");
|
||||
$archive = new PclZip(e_UPLOAD.$localfile);
|
||||
$unarc = ($fileList = $archive -> extract(PCLZIP_OPT_PATH, e_PLUGIN, PCLZIP_OPT_SET_CHMOD, 0666));
|
||||
|
||||
$dir = basename($unarc[0]['filename']);
|
||||
|
||||
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));
|
||||
|
||||
e107::getSingleton('e107plugin')->update_plugins_table();
|
||||
e107::getDb()->db_Select_gen("SELECT plugin_id FROM #plugin WHERE plugin_path = '".$plugPath."' LIMIT 1");
|
||||
$row = e107::getDb()->db_Fetch(MYSQL_ASSOC);
|
||||
$status = e107::getSingleton('e107plugin')->install_plugin($row['plugin_id']);
|
||||
unlink(e_UPLOAD.$localfile);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
print_a($unarc);
|
||||
$status = "There was a problem";
|
||||
}
|
||||
|
||||
echo $status;
|
||||
|
||||
// echo "file=".$file;
|
||||
exit;
|
||||
}
|
||||
|
||||
e107::coreLan('plugin', true);
|
||||
|
||||
$e_sub_cat = 'plug_manage';
|
||||
@ -76,7 +134,7 @@ class pluginManager{
|
||||
$this-> fields = array(
|
||||
|
||||
"plugin_checkboxes" => array("title" => "", "forced"=>TRUE, "width"=>"3%"),
|
||||
"plugin_icon" => array("title" => EPL_ADLAN_82, "type"=>"image", "width" => "5%", "thclass" => "middle center", "url" => ""),
|
||||
"plugin_icon" => array("title" => EPL_ADLAN_82, "type"=>"icon", "width" => "5%", "thclass" => "middle center",'class'=>'center', "url" => ""),
|
||||
"plugin_name" => array("title" => EPL_ADLAN_10, "type"=>"text", "width" => "30", "thclass" => "middle", "url" => ""),
|
||||
"plugin_version" => array("title" => EPL_ADLAN_11, "type"=>"numeric", "width" => "5%", "thclass" => "middle", "url" => ""),
|
||||
"plugin_folder" => array("title" => EPL_ADLAN_64, "type"=>"text", "width" => "10%", "thclass" => "middle", "url" => ""),
|
||||
@ -166,6 +224,13 @@ class pluginManager{
|
||||
{
|
||||
$this -> pluginUpload();
|
||||
}
|
||||
|
||||
if($this->action == "online")
|
||||
{
|
||||
$this -> pluginOnline();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(isset($_POST['install-selected']))
|
||||
{
|
||||
@ -190,6 +255,93 @@ class pluginManager{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function pluginOnline()
|
||||
{
|
||||
global $plugin, $frm;
|
||||
$caption = "Search Online";
|
||||
|
||||
$e107 = e107::getInstance();
|
||||
$xml = e107::getXml();
|
||||
// $file = "http://www.e107.org/releases.php"; //pluginfeed.php or similar.
|
||||
$file = "http://localhost:8080/e107_0.8/e107_plugins/release/release.php"; // temporary testing
|
||||
|
||||
$xml->setOptArrayTags('plugin'); // make sure 'plugin' tag always returns an array
|
||||
$xdata = $xml->loadXMLfile($file,'advanced');
|
||||
|
||||
//TODO use admin_ui including filter capabilities by sending search queries back to the xml script.
|
||||
|
||||
// XML data array.
|
||||
foreach($xdata['plugin'] as $r)
|
||||
{
|
||||
$row = $r['@attributes'];
|
||||
|
||||
$data[] = array(
|
||||
'plugin_icon' => $row['icon'],
|
||||
'plugin_name' => $row['name'],
|
||||
'plugin_folder' => $row['folder'],
|
||||
'plugin_version' => $row['version'],
|
||||
'plugin_description' => vartrue($row['description']),
|
||||
'plugin_category' => vartrue($row['category']),
|
||||
'plugin_author' => vartrue($row['author']),
|
||||
'plugin_website' => vartrue($row['authorUrl']),
|
||||
'plugin_url' => $row['url'],
|
||||
'plugin_notes' => ''
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$text = "
|
||||
<form action='".e_SELF."?".e_QUERY."' id='core-plugin-list-form' method='post'>
|
||||
<fieldset id='core-plugin-list'>
|
||||
<legend class='e-hideme'>".$caption."</legend>
|
||||
<table class='adminlist'>
|
||||
".$frm->colGroup($this->fields,$this->fieldpref).
|
||||
$frm->thead($this->fields,$this->fieldpref)."
|
||||
<tbody>
|
||||
";
|
||||
|
||||
foreach($data as $key=>$val )
|
||||
{
|
||||
$text .= "<tr>";
|
||||
$text .= "<td>checkbox</td>\n";
|
||||
foreach($this->fieldpref as $k=>$v)
|
||||
{
|
||||
$text .= "<td class='".vartrue($this->fields[$v]['class'],'left')."'>".$frm->renderValue($v, $val[$v], $this->fields[$v])."</td>\n";
|
||||
}
|
||||
$text .= "<td class='center'>".$this->options($val)."</td>";
|
||||
$text .= "</tr>";
|
||||
|
||||
}
|
||||
|
||||
|
||||
$text .= "
|
||||
</tbody>
|
||||
</table>";
|
||||
$text .= "
|
||||
</fieldset>
|
||||
</form>
|
||||
";
|
||||
|
||||
$emessage = &eMessage::getInstance();
|
||||
|
||||
|
||||
e107::getRender()->tablerender(ADLAN_98." :: ".$caption, $emessage->render(). $text);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function options($data)
|
||||
{
|
||||
$d = http_build_query($data,false,'&');
|
||||
$url = e_SELF."?src=".base64_encode($d);
|
||||
$id = 'plug_'.$data['plugin_folder'];
|
||||
return "<div id='{$id}'><input type='button' data-target='{$id}' data-loading='".e_IMAGE."/generic/loading_32.gif' class='button e-ajax' value='Download and Install' data-src='".$url."' /></div>";
|
||||
}
|
||||
|
||||
|
||||
// FIXME - move it to plugin handler, similar to install_plugin() routine
|
||||
function pluginUninstall()
|
||||
{
|
||||
@ -1037,8 +1189,11 @@ class pluginManager{
|
||||
$var['avail']['text'] = EPL_ADLAN_23;
|
||||
$var['avail']['link'] = e_SELF."?avail";
|
||||
|
||||
$var['upload']['text'] = EPL_ADLAN_38;
|
||||
$var['upload']['link'] = e_SELF."?upload";
|
||||
// $var['upload']['text'] = EPL_ADLAN_38;
|
||||
// $var['upload']['link'] = e_SELF."?upload";
|
||||
|
||||
$var['online']['text'] = "Search";
|
||||
$var['online']['link'] = e_SELF."?online";
|
||||
|
||||
$keys = array_keys($var);
|
||||
|
||||
|
@ -404,18 +404,32 @@ $(document).ready(function()
|
||||
|
||||
$(".e-ajax").click(function(){
|
||||
|
||||
|
||||
var id = $(this).attr("href");
|
||||
var src = $(this).attr("data-src");
|
||||
|
||||
var target = $(this).attr("data-target"); // support for input buttons etc.
|
||||
var loading = $(this).attr('data-loading'); // image to show loading.
|
||||
|
||||
if(target != null)
|
||||
{
|
||||
id = '#' + target;
|
||||
}
|
||||
|
||||
if(loading != null)
|
||||
{
|
||||
$(id).html("<img src='"+loading+"' alt='' />");
|
||||
}
|
||||
|
||||
if(src == null) // old way - href='myscript.php#id-to-target
|
||||
{
|
||||
var tmp = src.split('#');
|
||||
id = tmp[1];
|
||||
src = tmp[0];
|
||||
}
|
||||
var effect = $(this).attr("data-effect");
|
||||
|
||||
$(id).load(src + " ",function() {
|
||||
// var effect = $(this).attr("data-effect");
|
||||
|
||||
$(id).load(src,function() {
|
||||
// alert(src);
|
||||
// $(id).effect("slide");
|
||||
});
|
||||
|
||||
|
@ -1,13 +1,15 @@
|
||||
$(document).ready(function()
|
||||
{
|
||||
|
||||
$(".e-dialog-save").click(function () { // FIXME TODO missing caret , text selection overwrite etc.
|
||||
$(".e-dialog-save").live("click", function(){// FIXME TODO missing caret , text selection overwrite etc.
|
||||
|
||||
|
||||
//alert('hello');
|
||||
var newval = $('#bbcode_holder').val();
|
||||
// alert(newval);
|
||||
var target = $(this).attr('data-target');
|
||||
|
||||
|
||||
//alert('hello');
|
||||
if(!target){return true; }
|
||||
//('#' + target, window.top.document).insertAtCaret(newVal);
|
||||
|
||||
@ -103,7 +105,7 @@ $(document).ready(function()
|
||||
// $(".e-media-select").click(function () {
|
||||
$(".e-media-select").live("click", function(){
|
||||
|
||||
|
||||
|
||||
// console.log(this);
|
||||
|
||||
var id = $(this).attr('data-id');
|
||||
@ -143,14 +145,16 @@ $(document).ready(function()
|
||||
$('div#' + target + "_prev", window.top.document).html(preview); // set new value
|
||||
$('span#' + target + "_prev", window.top.document).html(preview); // set new value
|
||||
|
||||
// see $frm->filepicker()
|
||||
$('input#' + target , window.top.document).attr('value',path); // set new value
|
||||
|
||||
|
||||
|
||||
eMediaAttribute(this);
|
||||
|
||||
|
||||
// $(this).parent('#src').attr('value',preview); // set new value
|
||||
// $(this).parent('#preview').attr('src',preview); // set new value
|
||||
|
||||
return true;
|
||||
return false;
|
||||
|
||||
});
|
||||
});
|
@ -2191,8 +2191,16 @@ class e107
|
||||
if (isset($_COOKIE)) array_walk($_COOKIE, array('self', 'filter_request'), '_COOKIE');
|
||||
if (isset($_REQUEST)) array_walk($_REQUEST, array('self', 'filter_request'), '_REQUEST');
|
||||
|
||||
// TODO - better ajax detection method (headers when possible)
|
||||
define('e_AJAX_REQUEST', isset($_REQUEST['ajax_used']));
|
||||
// A better way to detect an AJAX request. No need for "ajax_used=1";
|
||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
|
||||
{
|
||||
define('e_AJAX_REQUEST', true);
|
||||
}
|
||||
else
|
||||
{
|
||||
define('e_AJAX_REQUEST', isset($_REQUEST['ajax_used']));
|
||||
}
|
||||
|
||||
unset($_REQUEST['ajax_used']); // removed because it's auto-appended from JS (AJAX), could break something...
|
||||
|
||||
//$GLOBALS['_E107'] - minimal mode - here because of the e_AJAX_REQUEST
|
||||
|
@ -130,7 +130,7 @@ class e_file
|
||||
*/
|
||||
public function cleanFileName($f,$rename=false)
|
||||
{
|
||||
$fullpath = $f['path'].$f['fname'];
|
||||
$fullpath = $f['path'].$f['fname'];
|
||||
$newfile = preg_replace("/[^a-z0-9-\._]/", "-", strtolower($f['fname']));
|
||||
$newpath = $f['path'].$newfile;
|
||||
|
||||
@ -284,6 +284,23 @@ class e_file
|
||||
return $finfo;
|
||||
}
|
||||
|
||||
// Grab a remote file and save it in the /temp directory. requires CURL
|
||||
function getRemoteFile($remote_url, $local_file)
|
||||
{
|
||||
$fp = fopen(e_UPLOAD.$local_file, 'w'); // always download to temp directory.
|
||||
|
||||
$cp = curl_init($remote_url);
|
||||
curl_setopt($cp, CURLOPT_FILE, $fp);
|
||||
|
||||
$buffer = curl_exec($cp);
|
||||
|
||||
curl_close($cp);
|
||||
fclose($fp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of directories matching $fmask, omitting any in the $omit array - same calling syntax as get_files()
|
||||
* N.B. - no recursion - just looks in the specified directory.
|
||||
|
@ -404,13 +404,14 @@ class e_form
|
||||
parse_str($sc_parameters, $sc_parameters);
|
||||
}
|
||||
|
||||
$cat = $tp->toDB($sc_parameters['media']);
|
||||
$default = ($default) ? $default : "Choose a file";
|
||||
$label = "<span id='{$name_id}_prev' >".basename($default)."</span>";
|
||||
$cat = vartrue($sc_parameters['media']) ? $tp->toDB($sc_parameters['media']) : "_common_file";
|
||||
|
||||
$default_label = ($default) ? $default : "Choose a file";
|
||||
$label = "<span id='{$name_id}_prev' >".basename($default_label)."</span>";
|
||||
|
||||
|
||||
$ret .= $this->mediaUrl($cat, $label,$name_id,"mode=dialog&action=list");
|
||||
$ret .= "<input type='hidden' name='{$name}' id='{$name_id}' value='{$default}' />";
|
||||
$ret .= "<input type='hidden' name='{$name}' id='{$name_id}' value='{$default}' style='width:400px' />";
|
||||
|
||||
return $ret;
|
||||
|
||||
@ -1587,7 +1588,7 @@ class e_form
|
||||
*/
|
||||
function renderValue($field, $value, $attributes, $id = 0)
|
||||
{
|
||||
|
||||
|
||||
$parms = array();
|
||||
if(isset($attributes['readParms']))
|
||||
{
|
||||
@ -2071,6 +2072,12 @@ class e_form
|
||||
unset($parms['label']);
|
||||
$ret = $this->imagepicker($key, $value, defset($label, $label), vartrue($parms['__options']));
|
||||
break;
|
||||
|
||||
case 'file': //TODO - thumb, image list shortcode, js tooltip...
|
||||
$label = varset($parms['label'], 'LAN_EDIT');
|
||||
unset($parms['label']);
|
||||
$ret = $this->filepicker($key, $value, defset($label, $label), vartrue($parms['__options']));
|
||||
break;
|
||||
|
||||
case 'icon':
|
||||
$label = varset($parms['label'], 'LAN_EDIT');
|
||||
|
@ -194,8 +194,7 @@ class xmlClass
|
||||
/**
|
||||
* Set Xml tags that should always return arrays.
|
||||
*
|
||||
*FIXME is this an array or a string???
|
||||
* @param object $array
|
||||
* @param object $string (comma separated)
|
||||
* @return xmlClass
|
||||
*/
|
||||
public function setOptArrayTags($string)
|
||||
@ -260,7 +259,7 @@ class xmlClass
|
||||
|
||||
/**
|
||||
* Get Remote file contents
|
||||
*
|
||||
* use setOptArrayTags above if you require a consistent array result by in 1 item or many.
|
||||
* @param string $address
|
||||
* @param integer $timeout [optional] seconds
|
||||
* @return string
|
||||
|
@ -249,7 +249,8 @@ class plugin_release_admin_ui extends e_admin_ui
|
||||
*/
|
||||
protected $fields = array(
|
||||
'checkboxes' => array('title'=> '', 'type' => null, 'data' => null, 'width'=>'5%', 'thclass' =>'center', 'forced'=> TRUE, 'class'=>'center', 'toggle' => 'e-multiselect'),
|
||||
'release_id' => array('title'=> ID, 'type' => 'number', 'data' => 'int', 'width'=>'5%', 'thclass' => '', 'forced'=> TRUE, 'primary'=>TRUE/*, 'noedit'=>TRUE*/), //Primary ID is not editable
|
||||
'release_id' => array('title'=> ID, 'type' => 'number', 'data' => 'int', 'width'=>'5%', 'thclass' => '', 'class'=>'center', 'forced'=> TRUE, 'primary'=>TRUE/*, 'noedit'=>TRUE*/), //Primary ID is not editable
|
||||
'release_icon' => array('title'=> LAN_ICON, 'type' => 'icon', 'data' => 'str', 'width'=>'5%', 'thclass' => '', 'forced'=> TRUE, 'primary'=>TRUE/*, 'noedit'=>TRUE*/), //Primary ID is not editable
|
||||
'release_type' => array('title'=> 'Type', 'type' => 'method', 'data' => 'str', 'width'=>'auto', 'thclass' => '', 'batch' => TRUE, 'filter'=>TRUE),
|
||||
'release_folder' => array('title'=> 'Folder', 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'thclass' => ''),
|
||||
'release_name' => array('title'=> 'Name', 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'thclass' => ''),
|
||||
@ -258,7 +259,7 @@ class plugin_release_admin_ui extends e_admin_ui
|
||||
'release_authorURL' => array('title'=> LAN_AUTHOR_URL, 'type' => 'url', 'data' => 'str', 'width' => 'auto', 'thclass' => 'left'),
|
||||
'release_date' => array('title'=> LAN_DATE, 'type' => 'datestamp', 'data' => 'int', 'width' => 'auto', 'thclass' => '', 'readParms' => 'long', 'writeParms' => 'type=datetime'),
|
||||
'release_compatibility' => array('title'=> 'compatib', 'type' => 'text', 'data' => 'str', 'width' => '10%', 'thclass' => 'center' ),
|
||||
'release_url' => array('title'=> 'release_url', 'type' => 'url', 'data' => 'str', 'width' => '20%', 'thclass' => 'center', 'batch' => TRUE, 'filter'=>TRUE, 'parms' => 'truncate=30', 'validate' => true, 'help' => 'Enter release URL here', 'error' => 'please, ener valid URL'),
|
||||
'release_url' => array('title'=> 'File Package', 'type' => 'file', 'data' => 'str', 'width' => '20%', 'thclass' => 'center', 'batch' => TRUE, 'filter'=>TRUE, 'parms' => 'truncate=30', 'validate' => true, 'help' => 'Enter release URL here', 'error' => 'please, ener valid URL'),
|
||||
'test_list_1' => array('title'=> 'test 1', 'type' => 'boolean', 'data' => 'int', 'width' => '5%', 'thclass' => 'center', 'batch' => TRUE, 'filter'=>TRUE, 'noedit' => true),
|
||||
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'data' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced'=>TRUE)
|
||||
);
|
||||
|
@ -23,7 +23,7 @@ $tp = e107::getParser();
|
||||
e107::getDb()->db_Select_gen("SELECT * FROM #release ORDER BY release_type,release_date DESC");
|
||||
while ($row = e107::getDb()->db_Fetch(MYSQL_ASSOC))
|
||||
{
|
||||
echo "\t<".$row['release_type']." name='".$tp->toRss($row['release_name'])."' folder='".$tp->toRss($row['release_folder'])."' author='".$tp->toRss($row['release_author'])."' authorURL='".$row['release_authorURL']."' version='".$row['release_version']."' date='".$row['release_date']."' compatibility='".$row['release_compatibility']."' url='".$row['release_url']."' />\n";
|
||||
echo "\t<".$row['release_type']." name='".$tp->toRss($row['release_name'])."' folder='".$tp->toRss(strtolower($row['release_folder']))."' author='".$tp->toRss($row['release_author'])."' authorURL='".$row['release_authorURL']."' version='".$row['release_version']."' date='".$row['release_date']."' compatibility='".$row['release_compatibility']."' url='".$tp->replaceConstants($row['release_url'],'full')."' icon='".$tp->replaceConstants($row['release_icon'],'full')."' />\n";
|
||||
}
|
||||
|
||||
echo "</e107Release>";
|
||||
|
@ -1,5 +1,6 @@
|
||||
CREATE TABLE release (
|
||||
`release_id` int(10) NOT NULL AUTO_INCREMENT,
|
||||
`release_icon` varchar(255) NOT NULL,
|
||||
`release_type` varchar(10) NOT NULL,
|
||||
`release_name` varchar(50) NOT NULL,
|
||||
`release_folder` varchar(50) NOT NULL,
|
||||
@ -9,5 +10,6 @@ CREATE TABLE release (
|
||||
`release_date` int(10) NOT NULL,
|
||||
`release_compatibility` varchar(5) NOT NULL,
|
||||
`release_url` varchar(255) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`release_id`)
|
||||
) ENGINE=MyISAM;
|
||||
|
Loading…
x
Reference in New Issue
Block a user