1
0
mirror of https://github.com/e107inc/e107.git synced 2025-06-05 02:15:13 +02:00

Media-Manager fixes and refinements

This commit is contained in:
CaMer0n 2012-07-18 06:34:26 +00:00
parent 2b57902e68
commit 1f073d0552
9 changed files with 126 additions and 30 deletions

View File

@ -70,8 +70,8 @@ class media_admin extends e_admin_dispatcher
protected $adminMenu = array(
'main/list' => array('caption'=> 'Media Library', 'perm' => 'A'),
'main/create' => array('caption'=> "Add New Media", 'perm' => 'A'), // Should be handled in Media-Import.
'main/import' => array('caption'=> "Media Import", 'perm' => 'A|A2'),
// 'main/create' => array('caption'=> "Add New Media", 'perm' => 'A'), // Should be handled in Media-Import.
'main/import' => array('caption'=> "Media Upload/Import", 'perm' => 'A|A2'),
'cat/list' => array('caption'=> 'Media Categories', 'perm' => 'A'),
'cat/create' => array('caption'=> "Create Category", 'perm' => 'A'), // is automatic.
// 'main/settings' => array('caption'=> LAN_PREFS, 'perm' => 'A'), // legacy
@ -218,6 +218,7 @@ class media_form_ui extends e_admin_form_ui
{
$text = "";
$frm = e107::getForm();
$pref = e107::getPref();
$options = array(
"news-image" => "News Images",
@ -227,6 +228,16 @@ class media_form_ui extends e_admin_form_ui
// "featurebox-bbcode" => "Featurebox [img] bbcode",
);
if(vartrue($pref['e_imageresize']))
{
foreach($pref['e_imageresize'] as $val)
{
$options[$k] = ucfirst($k). " [img] bbcode";
}
}
foreach($options as $key=>$title)
{
@ -330,7 +341,7 @@ class media_admin_ui extends e_admin_ui
'media_category' => array('title'=> LAN_CATEGORY, 'type' => 'method', 'data'=> 'str', 'width' => 'auto', 'filter' => true, 'batch' => true,'writeParms'=>'multiple=1'),
// Upload should be managed completely separately via upload-handler.
'media_upload' => array('title'=> "Upload File", 'type' => 'upload', 'data'=> false, 'readParms' => 'hidden', 'writeParms' => 'disable_button=1', 'width' => '10%', 'nolist' => true),
// 'media_upload' => array('title'=> "Upload File", 'type' => 'upload', 'data'=> false, 'readParms' => 'hidden', 'writeParms' => 'disable_button=1', 'width' => '10%', 'nolist' => true),
'media_name' => array('title'=> LAN_TITLE, 'type' => 'text', 'data'=> 'str', 'width' => 'auto'),
'media_caption' => array('title'=> "Caption", 'type' => 'text', 'data'=> 'str', 'width' => 'auto'),
// media_description is type = textarea until bbarea can be reduced to not include youtube etc
@ -370,7 +381,7 @@ class media_admin_ui extends e_admin_ui
'resize_method' => array('title'=> IMALAN_3, 'type'=>'method', 'data'=>'str'),
'im_width' => array('title'=> "Avatar Width", 'type'=>'text', 'data'=>'int', 'writeParms'=>'help=Avatar images will be constrained to these dimensions (in pixels)'), //TODO LAN
'im_height' => array('title'=> "Avatar Height", 'type'=>'text', 'data'=>'int', 'writeParms'=>'help=Avatar images will be constrained to these dimensions (in pixels)'),
'resize_dimensions' => array('title'=> "Resize Dimensions", 'type'=>'method', 'data'=>'str'),
'resize_dimensions' => array('title'=> "Resize-Image Dimensions", 'type'=>'method', 'data'=>'str'),
'watermark_activate' => array('title'=> 'Watermark Activation', 'type' => 'text', 'data' => 'str', 'help'=>'All images with a width or height greater than this value will be given a watermark during resizing.'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
'watermark_text' => array('title'=> 'Watermark Text', 'type' => 'text', 'data' => 'str', 'help'=>'Optional Watermark Text'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
@ -513,6 +524,11 @@ class media_admin_ui extends e_admin_ui
{
$this->batchImport();
}
if(varset($_POST['batch_import_delete']))
{
$this->batchDelete();
}
if(varset($_POST['update_options']))
{
@ -640,7 +656,7 @@ class media_admin_ui extends e_admin_ui
{
if(!ADMIN){ exit; } //TODO check for upload-access in perms.
// if 'for' has no value, files are placed in /temp and not added to the db.
$text = '<div id="uploader" rel="'.e_JS.'plupload/upload.php?for='.$this->getQuery('for').'">
<p>No HTML5 support.</p>
</div>';
@ -1136,9 +1152,10 @@ class media_admin_ui extends e_admin_ui
$mes->addDebug("checkDupe(): newpath=".$newpath."<br />oldpath=".$oldpath."<br />".print_r($upload,TRUE));
if(file_exists($newpath) || e107::getDb()->db_Select("core_media","*","media_url = '".$tp->createConstants($newpath,'rel')."' LIMIT 1") )
{
// $mes->addWarning($newpath." already exists and was renamed during import.");
$mes->addWarning($newpath." already exists.");
$file = $f['pathinfo']['filename']."_.".$f['pathinfo']['extension'];
$newpath = $this->getPath($f['mime']).'/'.$file;
$newpath = $this->getPath($f['mime']).'/'.$file;
return false;
}
return $newpath;
@ -1198,12 +1215,18 @@ class media_admin_ui extends e_admin_ui
if(!vartrue($_POST['batch_import_selected']))
{
$mes->add("Scanning for new media (images, videos, files) in folder: ".e_MEDIA."temp/", E_MESSAGE_INFO);
$mes->add("Scanning for new media (images, videos, files) in folder: <b> ".e_UPLOAD."</b>", E_MESSAGE_INFO);
}
if(!count($files) && !$_POST['batch_import_selected'])
if(!count($files))
{
$mes->add("No media Found! Please upload some files and then refresh this page.", E_MESSAGE_INFO);
if(!vartrue($_POST['batch_import_selected']))
{
$mes->add("No media Found! Please upload some files.", E_MESSAGE_INFO);
}
$text = $this->uploadPage();
echo $mes->render().$text;
return;
}
@ -1253,7 +1276,7 @@ class media_admin_ui extends e_admin_ui
<td class='center'>".$this->preview($f)."</td>
<td>".$f['fname']."</td>
<td>".$frm->text('batch_import_name['.$c.']', ($_POST['batch_import_name'][$c] ? $_POST['batch_import_name'][$c] : $default['title']))."</td>
<td><textarea name='batch_import_diz['.$c.']' rows='3' cols='50'>". ($_POST['batch_import_diz'][$c] ? $_POST['batch_import_diz'][$c] : $default['description'])."</textarea></td>
<td><textarea name='batch_import_diz[".$c."]' rows='3' cols='50'>". ($_POST['batch_import_diz'][$c] ? $_POST['batch_import_diz'][$c] : $default['description'])."</textarea></td>
<td><a href='mailto:".$default['authorEmail']."'>".$default['authorName']."</a></td>
<td>".$f['mime']."</td>
@ -1265,17 +1288,23 @@ class media_admin_ui extends e_admin_ui
\n";
$c++;
$lastMime = $f['mime'];
}
// <td>".$frm->textarea('batch_import_diz['.$c.']', ($_POST['batch_import_diz'][$c] ? $_POST['batch_import_diz'][$c] : $default['description']))."</td>
if(!isset($_POST['batch_category']) && substr($lastMime,0,5)=='image')
{
$_POST['batch_category'] = "_common_image";
}
$text .= "
</tbody>
</table>
<div class='buttons-bar center'>
Import into Category: ".$frm->selectbox('batch_category',$this->cats);
Import into Category: ".$frm->selectbox('batch_category',$this->cats, $_POST['batch_category']);
$waterMarkPath = e_THEME.e107::getPref('sitetheme')."/images/watermark.png";
// $waterMarkPath = e_THEME.e107::getPref('sitetheme')."/images/watermark.png"; // Now performed site-wide dynamically.
if(is_readable($waterMarkPath))
{
@ -1285,11 +1314,8 @@ class media_admin_ui extends e_admin_ui
$text .= "
</div>
<div class='buttons-bar center'>
".$frm->admin_button('batch_import_selected', "Import Selected Files", 'import');
".$frm->admin_button('batch_import_selected', "Import Selected Files", 'import')
.$frm->admin_button('batch_import_delete', "Delete Selected Files", 'delete');
$text .= "
</div>
</fieldset>
@ -1360,6 +1386,23 @@ class media_admin_ui extends e_admin_ui
}
}
function batchDelete()
{
foreach($_POST['batch_selected'] as $key=>$file)
{
if(trim($file) == '')
{
continue;
}
$oldpath = e_MEDIA."temp/".$file;
if(file_exists($oldpath))
{
unlink($oldpath);
}
}
}
function batchImport()

View File

@ -199,8 +199,8 @@ $(document).ready(function()
// Basic Delete Confirmation
$("input.delete").click(function(){
var answer = confirm($(this).attr("title")+ " ?");
$("input.delete,button.delete").click(function(){
var answer = confirm($(this).attr("data-confirm"));
return answer // answer is a boolean
});

View File

@ -137,7 +137,11 @@ if (!$chunks || $chunk == $chunks - 1) {
// rename($targetDir.$fileName,e_MEDIA."images/2012-05/",$fileName);
$result = e107::getMedia()->importFile($fileName,$_GET['for']);
if($_GET['for'] !='') // leave in upload directory if no category given.
{
$result = e107::getMedia()->importFile($fileName,$_GET['for']);
}
$array = array("jsonrpc"=>"2.0", "result"=>$result,"id"=>"id");
echo json_encode($array);

View File

@ -131,7 +131,7 @@ class e_file
public function cleanFileName($f,$rename=false)
{
$fullpath = $f['path'].$f['fname'];
$newfile = preg_replace("/[^a-z0-9-\.]/", "-", strtolower($f['fname']));
$newfile = preg_replace("/[^a-z0-9-\._]/", "-", strtolower($f['fname']));
$newpath = $f['path'].$newfile;
if($rename == true)

View File

@ -1046,6 +1046,7 @@ class e_form
case 'delete':
$image = ADMIN_DELETE_ICON_PATH;
$options['class'] = $options['class'] == 'action' ? 'action delete' : $options['class'];
$options['other'] = 'data-confirm="'.LAN_JSCONFIRM.'"';
break;
case 'execute':
@ -1080,6 +1081,11 @@ class e_form
$options['class'] = $action;//shorthand
if(empty($label)) $label = $value;
if($action == 'delete')
{
$options['other'] = 'data-confirm="'.LAN_JSCONFIRM.'"';
}
return "
<button type='{$btype}' name='{$name}' value='{$value}'".$this->get_attributes($options, $name)."><span>{$label}</span></button>
";

View File

@ -80,7 +80,7 @@ class e_media
'media_category' => $cat,
'media_datestamp' => $f['modified'],
'media_url' => $fullpath,
'media_userclass' => 0,
'media_userclass' => '0',
'media_name' => $f['fname'],
'media_author' => USERID,
'media_size' => $f['fsize'],

View File

@ -1265,13 +1265,11 @@ class e107plugin
}
if (varset($plug_vars['mainPrefs'])) //Core pref items <mainPrefs>
{
$this->XmlPrefs('core', $function, $plug_vars['mainPrefs']);
}
if (varset($plug_vars['pluginPrefs'])) //Plugin pref items <pluginPrefs>
{
$this->XmlPrefs($plug['plugin_path'], $function, $plug_vars['pluginPrefs']);
}
@ -1290,6 +1288,11 @@ class e107plugin
{
$this->XmlLanguageFiles($function, $plug_vars['languageFiles']);
}
if (varset($plug_vars['bbcodes']))
{
$this->XmlBBcodes($function, $plug_vars);
}
$this->manage_icons($this->plugFolder, $function);
@ -1536,6 +1539,42 @@ class e107plugin
}
}
}
/**
* Process XML Tag <bbcodes>
* @return none
*/
function XmlBBcodes($function, $tag)
{
$mes = e107::getMessage();
//print_a($tag);
switch ($function)
{
case 'install': // Probably best to leave well alone
if(vartrue($tag['bbcodes']['@attributes']['imgResize']))
{
e107::getConfig('core')->add("e_imageresize",$tag['folder']); //FIXME - should be saved as an array;
$mes->debug('Adding imageResize for: '.$tag['folder']);
}
break;
case 'uninstall': // Probably best to leave well alone
if(vartrue($tag['bbcodes']['@attributes']['imgResize']))
{
// e107::getConfig('core')->add("e_imageresize",$tag['folder']);
}
break;
}
return;
}
/**
* Process XML Tag <userClasses>

View File

@ -4,11 +4,12 @@
<e107Plugin name="FAQs" version="1.0" compatibility="0.8" installRequired="true">
<author name="e107 Inc" url="http://www.e107.org" email="security@e107.org" />
<description>Based on the original FAQ plugin by Cameron of e107 Inc.</description>
<description>Based on the original FAQ plugin by Cameron @ e107 Inc.</description>
<copyright>Copyright e107 Inc e107.org, Licensed under GPL (http://www.gnu.org/licenses/gpl.txt)</copyright>
<bbcodes imgResize="true" />
<category>content</category>
<adminLinks>
<link url='admin_config.php' description='Configure FAQs' icon='images/icon_32.png' iconSmall='images/icon_16.png' primary='true' >Facebook Connect</link>
<link url='admin_config.php' description='Configure FAQs' icon='images/icon_32.png' iconSmall='images/icon_16.png' primary='true' >FAQs</link>
</adminLinks>
<siteLinks>
<link url='{e_PLUGIN}faqs/faqs.php' description='FAQs' icon='images/icon_32.png' iconSmall='images/icon_16.png'>FAQs</link>

View File

@ -25,15 +25,17 @@
define('e107_INIT', true);
//error_reporting(E_ALL);
// error_reporting(E_ALL);
error_reporting(0); // suppress all errors or image will be corrupted.
//require_once './e107_handlers/benchmark.php';
//$bench = new e_benchmark();
//$bench->start();
$thumbpage = new e_thumbpage();
if(!$thumbpage->checkSrc())
{
die(' Access denied!');
@ -300,6 +302,7 @@ class e_thumbpage
echo 'Headers already sent! ';
exit;
}
if (function_exists('date_default_timezone_set'))
{
date_default_timezone_set('UTC');