mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 20:58:30 +01:00
Media-Manager importing of files
This commit is contained in:
parent
06df7308bb
commit
e9811d8b8f
@ -53,6 +53,12 @@ class media_admin extends e_admin_dispatcher
|
||||
'ui' => 'media_form_ui',
|
||||
'uipath' => null
|
||||
),
|
||||
'dialog' => array(
|
||||
'controller' => 'media_admin_ui',
|
||||
'path' => null,
|
||||
'ui' => 'media_form_ui',
|
||||
'uipath' => null
|
||||
),
|
||||
'cat' => array(
|
||||
'controller' => 'media_cat_ui',
|
||||
'path' => null,
|
||||
@ -197,7 +203,19 @@ class media_form_ui extends e_admin_form_ui
|
||||
asort($this->cats);*/
|
||||
}
|
||||
|
||||
|
||||
function options()
|
||||
{
|
||||
//return print_a($_GET,true);
|
||||
$tagid = $_GET['tagid'];
|
||||
$path = $this->getController()->getListModel()->get('media_url');
|
||||
$preview = basename($path);
|
||||
|
||||
|
||||
$text .= "<input type='button' value='Select' class='button e-media-select e-dialog-close' data-target='{$tagid}' data-path='{$path}' data-preview='{$preview}' title=\"".$diz."\" style='float:left' href='#' />";
|
||||
// $text .= "SELECT";
|
||||
// $text .= "</a>\n\n";
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -336,6 +354,27 @@ class media_admin_ui extends e_admin_ui
|
||||
{
|
||||
$this->updateSettings();
|
||||
}
|
||||
|
||||
if($this->getQuery('mode') == 'dialog')
|
||||
{
|
||||
$cat = $_GET['for'];
|
||||
$this->listQry = "SELECT m.*,u.user_id,u.user_name FROM #core_media AS m LEFT JOIN #user AS u ON m.media_author = u.user_id WHERE media_category = '".$cat."' "; // without any Order or Limit.
|
||||
|
||||
unset($this->fields['checkboxes']);
|
||||
$this->fields['options']['type'] = 'method';
|
||||
$this->fields['media_userclass']['nolist'] = true;
|
||||
$this->fields['media_dimentions']['nolist'] = true;
|
||||
$this->fields['media_description']['nolist'] = true;
|
||||
$this->fields['media_type']['nolist'] = true;
|
||||
|
||||
foreach($this->fields as $k=>$v)
|
||||
{
|
||||
$this->fields[$k]['filter'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if($this->getQuery('iframe'))
|
||||
{
|
||||
@ -397,15 +436,26 @@ class media_admin_ui extends e_admin_ui
|
||||
|
||||
function dialogPage() // Popup dialogPage for Image Selection.
|
||||
{
|
||||
$cat = $this->getQuery('for');
|
||||
$file = (substr($cat,-5) == "_file") ? TRUE : FALSE;
|
||||
|
||||
if($file)
|
||||
{
|
||||
|
||||
echo $this->getUI()->getList();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// $this->getModel()->setAction('create');
|
||||
// $this->getUI()->getController()->getRequest()->setAction('create');
|
||||
//$this->setAction('create');;
|
||||
|
||||
if($_POST['etrigger_submit'])
|
||||
{
|
||||
$data = $this->beforeCreate($_POST);
|
||||
e107::getDb()->db_Insert('core_media',$data); // Replace with Generic (needs parm sent)
|
||||
// $data = $this->beforeCreate($_POST);
|
||||
// e107::getDb()->db_Insert('core_media',$data); // Replace with Generic (needs parm sent)
|
||||
}
|
||||
echo $this->imageSelectUpload();
|
||||
}
|
||||
@ -467,8 +517,8 @@ class media_admin_ui extends e_admin_ui
|
||||
$this->fields['media_url']['noedit'] = TRUE;
|
||||
$this->fields['media_userclass']['noedit'] = TRUE;
|
||||
|
||||
// $text .= $this->uploadPage(); // To test upload script with plupload
|
||||
$text .= $this->CreatePage(); // comment me out to test plupload
|
||||
$text .= $this->uploadPage(); // To test upload script with plupload
|
||||
// $text .= $this->CreatePage(); // comment me out to test plupload
|
||||
|
||||
$text .= "
|
||||
</fieldset>";
|
||||
|
@ -1119,6 +1119,36 @@ function update_706_to_800($type='')
|
||||
$med->import('download_thumb',e_FILE.'downloadthumbs');
|
||||
}
|
||||
|
||||
$dl_files = $fl->get_files(e_DOWNLOAD, "","standard",5);
|
||||
$public_files = $fl->get_files(e_FILE.'public');
|
||||
|
||||
if((count($dl_files) || count($public_files)) && !$sql->db_Select_gen("SELECT * FROM `#core_media` WHERE `media_category` = 'download_file' "))
|
||||
{
|
||||
if ($just_check) return update_needed('Import Download and Public Files into Media Manager');
|
||||
// check for file-types;
|
||||
if (is_readable(e_ADMIN.'filetypes.php'))
|
||||
{
|
||||
$a_types = strtolower(trim(file_get_contents(e_ADMIN.'filetypes.php')));
|
||||
$srch = array("png","jpg","jpeg","gif");
|
||||
$a_types = str_replace($srch,"",$a_types); // filter-out images.
|
||||
|
||||
} else
|
||||
{
|
||||
$a_types = 'zip, gz, pdf';
|
||||
}
|
||||
|
||||
$a_types = explode(',', $a_types);
|
||||
foreach ($a_types as $f_type) {
|
||||
$allowed_types[] = trim(str_replace('.', '', $f_type));
|
||||
}
|
||||
|
||||
$fmask = '[a-zA-z0-9_-]+\.('.implode('|',$allowed_types).')$';
|
||||
$med->import('download_file',e_DOWNLOAD, $fmask);
|
||||
$med->import('_common_file',e_FILE.'public', $fmask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$count = $sql->db_Select_gen("SELECT * FROM `#core_media_cat` WHERE media_cat_owner='_icon' ");
|
||||
|
||||
|
@ -61,7 +61,7 @@ $(document).ready(function()
|
||||
$("a.e-dialog").colorbox({
|
||||
iframe:true,
|
||||
width:"60%",
|
||||
height:"65%",
|
||||
height:"70%",
|
||||
speed:100
|
||||
});
|
||||
|
||||
@ -352,7 +352,7 @@ $(document).ready(function()
|
||||
var opt = linkid.split('-');
|
||||
|
||||
if(area == 'remove')
|
||||
{ alert(area);
|
||||
{ // alert(area);
|
||||
var remove = linkid;
|
||||
areaList = '';
|
||||
$('#check-' + opt[1]).show('fast');
|
||||
|
@ -98,7 +98,7 @@ $(document).ready(function()
|
||||
$(".e-media-select").live("click", function(){
|
||||
|
||||
|
||||
// console.log(this);
|
||||
console.log(this);
|
||||
|
||||
|
||||
|
||||
@ -111,7 +111,9 @@ $(document).ready(function()
|
||||
$(this).closest("img").addClass("active");
|
||||
|
||||
$('#' + target, window.top.document).attr('value',path); // set new value
|
||||
$('#' + target + "_prev", window.top.document).attr('src',preview); // set new value
|
||||
$('img#' + target + "_prev", window.top.document).attr('src',preview); // set new value
|
||||
$('div#' + target + "_prev", window.top.document).html(preview); // set new value
|
||||
$('span#' + target + "_prev", window.top.document).html(preview); // set new value
|
||||
|
||||
$('#src').attr('value',src); // working old
|
||||
$('#preview').attr('src',preview); // working old
|
||||
|
@ -144,21 +144,31 @@ class e_form
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// FIXME - Dialog JS no more working, investigate
|
||||
public function mediaUrl($category = '', $label = '', $tagid='', $bbcode='')
|
||||
/**
|
||||
* Internal Function used by imagepicker and filepicker
|
||||
*/
|
||||
private function mediaUrl($category = '', $label = '', $tagid='', $extras='')
|
||||
{
|
||||
|
||||
$cat = ($category) ? '&for='.$category : "";
|
||||
if(!$label) $label = ' Upload an image or file';
|
||||
if($tagid) $cat .= '&tagid='.$tagid;
|
||||
|
||||
parse_str($extras);
|
||||
|
||||
if($bbcode) $cat .= '&bbcode=1';
|
||||
|
||||
if(!$mode) $mode = 'main';
|
||||
if(!$action) $action = 'dialog';
|
||||
|
||||
// $tabs // TODO - option to choose which tabs to display.
|
||||
|
||||
//TODO Parse selection data back to parent form.
|
||||
|
||||
$url = e_ADMIN_ABS."image.php?mode=main&action=dialog".$cat;
|
||||
$url = e_ADMIN_ABS."image.php?mode={$mode}&action={$action}".$cat;
|
||||
$url .= "&iframe=1";
|
||||
|
||||
$ret = "<a title='Click on a thumbnail to change..' rel='external' class='e-dialog' href='".$url."'>".$label."</a>";
|
||||
$ret = "<a title=\"{$title}\" rel='external' class='e-dialog' href='".$url."'>".$label."</a>";
|
||||
|
||||
// $footer = "<div style=\'padding:5px;text-align:center\' <a href=\'#\' >Save</a></div>";
|
||||
$footer = '';
|
||||
@ -262,88 +272,46 @@ class e_form
|
||||
// $ret .= $this->text($name,$default); // to be hidden eventually.
|
||||
return $ret;
|
||||
|
||||
|
||||
// ---------------- OLD DROPDOWN METHOD BELOW -----------------------------
|
||||
|
||||
$tp = e107::getParser();
|
||||
$sql = e107::getDb();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ----------------
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function filepicker($name, $default, $label = '', $sc_parameters = '')
|
||||
{
|
||||
$tp = e107::getParser();
|
||||
$name_id = $this->name2id($name);
|
||||
if(is_string($sc_parameters))
|
||||
{
|
||||
if(strpos($sc_parameters, '=') === false) $sc_parameters = 'media='.$sc_parameters;
|
||||
parse_str($sc_parameters, $sc_parameters);
|
||||
}
|
||||
|
||||
$qry = "SELECT * FROM `#core_media` WHERE media_userclass IN (".USERCLASS_LIST.") ";
|
||||
$cat = $tp->toDB($sc_parameters['media']);
|
||||
$default = ($default) ? $default : "Choose a file";
|
||||
$label = "<span id='{$name_id}_prev' >".$default."</span>";
|
||||
|
||||
|
||||
// Old Method
|
||||
$qry .= vartrue($sc_parameters['media']) ? " AND (`media_category` = '".$tp->toDB($sc_parameters['media'])."' OR `media_category` = '_common' )" : " AND `media_category` = '_common' ";
|
||||
$ret .= $this->mediaUrl($cat, $label,$name_id,"mode=dialog&action=list");
|
||||
$ret .= "<input type='hidden' name='{$name}' id='{$name_id}' value='{$default}' />";
|
||||
|
||||
return $ret;
|
||||
|
||||
|
||||
// New Method
|
||||
/*
|
||||
if(vartrue($sc_parameters['owner']) && vartrue($sc_parameters['cat']))
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
$qry = "SELECT * FROM `#core_media` WHERE media_userclass IN (".USERCLASS_LIST.") ";
|
||||
$qry .= " AND (`media_owner` = '".$tp->toDB($sc_parameters['owner'])."' AND `media_category` = '".$tp->toDB($sc_parameters['cat'])."' ) OR `media_owner` = '_common' ";
|
||||
} */
|
||||
|
||||
|
||||
$qry .= "ORDER BY media_name";
|
||||
|
||||
|
||||
if($sql->db_Select_gen($qry))
|
||||
{
|
||||
while($row = $sql->db_Fetch())
|
||||
{
|
||||
$opts[$row['media_category']][$row['media_url']] = $row['media_name']. " (".$row['media_dimensions'].") ";
|
||||
}
|
||||
|
||||
asort($opts);
|
||||
|
||||
$hide = $default_url = '';
|
||||
$default_thumb = $default;
|
||||
if($default)
|
||||
{
|
||||
if('{' != $default[0])
|
||||
{
|
||||
// convert to sc path
|
||||
$default_thumb = $tp->createConstants($default, 'nice');
|
||||
$default = $tp->createConstants($default, 'mix');
|
||||
}
|
||||
$default_url = $tp->replaceConstants($default, 'abs');
|
||||
}
|
||||
else
|
||||
{
|
||||
$default = $default_url = e_IMAGE_ABS."generic/blank.gif";
|
||||
$hide = ' style="display: none;"';
|
||||
}
|
||||
|
||||
if(is_string($sc_parameters)) parse_str($sc_parameters, $sc_parameters);
|
||||
$name_id = $this->name2id($name);
|
||||
$width = intval(vartrue($sc_parameters['width'], 150));
|
||||
$onchange = "onchange=\"replaceSC('imagepreview={$name}|{$width}',this.form,'{$name_id}_prev'); \"";
|
||||
|
||||
$ret = $this->selectbox($name, $opts, $default, array('default'=>' ', 'other' => $onchange));
|
||||
$ret .= "<div class='imgselector-container' id='{$name_id}_prev'>";
|
||||
$ret .= "<a href='{$default_url}'{$hide} rel='external' title='Preview {$default_url}' class='e-image-preview'>";
|
||||
|
||||
$thpath = isset($sc_parameters['nothumb']) || $hide ? $default : $tp->thumbUrl($default_thumb, 'w='.$width, true);
|
||||
$ret .= "<img src='{$thpath}' alt='{$default_url}' class='image-selector' /></a>";
|
||||
$ret .= "</div>\n";
|
||||
|
||||
return $ret;
|
||||
}
|
||||
// ----------------
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Date field with popup calendar
|
||||
* Date field with popup calendar // NEW in 0.8/2.0
|
||||
* $options allowed keys:
|
||||
* - time: show time, default is true
|
||||
* - others: ???, default is false
|
||||
@ -356,6 +324,12 @@ class e_form
|
||||
*/
|
||||
function datepicker($name, $datestamp = false, $options = array())
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
// DHTML Calendar is deprecated in 2.0.
|
||||
|
||||
$cal = new DHTML_Calendar(true);
|
||||
$cal_options['showsTime'] = varset($options['time'], true);
|
||||
$cal_options['showOthers'] = varset($options['others'], false);
|
||||
@ -1537,6 +1511,14 @@ class e_form
|
||||
case 'image': //TODO - thumb, js tooltip...
|
||||
if($value)
|
||||
{
|
||||
|
||||
if(!preg_match("/[a-zA-z0-9_-]+\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF)$/",$value))
|
||||
{
|
||||
$value = "{e_IMAGE}filemanager/zip_32.png";
|
||||
$src = $tp->replaceConstants(vartrue($parms['pre']).$value, 'abs');
|
||||
return '<img src="'.$src.'" alt="'.$alt.'" class="e-thumb" />';
|
||||
}
|
||||
|
||||
if(vartrue($parms['thumb']))
|
||||
{
|
||||
$src = $tp->replaceConstants(vartrue($parms['pre']).$value, 'abs');
|
||||
|
@ -67,8 +67,8 @@ class e_media
|
||||
|
||||
if(!count($img_array)){ return $this;}
|
||||
|
||||
//print_a($img_array);
|
||||
//return;
|
||||
// print_a($img_array);
|
||||
// return;
|
||||
|
||||
foreach($img_array as $f)
|
||||
{
|
||||
@ -79,15 +79,15 @@ class e_media
|
||||
'media_description' => '',
|
||||
'media_category' => $cat,
|
||||
'media_datestamp' => $f['modified'],
|
||||
'media_url' => $fullpath,
|
||||
'media_url' => $fullpath,
|
||||
'media_userclass' => 0,
|
||||
'media_name' => $f['fname'],
|
||||
'media_author' => USERID,
|
||||
'media_size' => $f['fsize'],
|
||||
'media_name' => $f['fname'],
|
||||
'media_author' => USERID,
|
||||
'media_size' => $f['fsize'],
|
||||
'media_dimensions' => $f['img-width']." x ".$f['img-height'],
|
||||
'media_usedby' => '',
|
||||
'media_tags' => '',
|
||||
'media_type' => $f['mime']
|
||||
'media_usedby' => '',
|
||||
'media_tags' => '',
|
||||
'media_type' => $f['mime']
|
||||
);
|
||||
|
||||
if(!$sql->db_Select('core_media','media_url',"media_url = '".$fullpath."' LIMIT 1"))
|
||||
@ -429,6 +429,7 @@ class e_media
|
||||
$limit = ($option['limit']) ? $option['limit'] : 20;
|
||||
$newfrm = $frm + $limit;
|
||||
$bbcode = ($option['bbcode']) ? $option['bbcode'] : null;
|
||||
|
||||
|
||||
if($category !='_icon')
|
||||
{
|
||||
|
@ -620,7 +620,7 @@ $columnInfo = array(
|
||||
|
||||
$text = "
|
||||
<div class='admintabs' id='tab-container'>
|
||||
<ul class='e-tabs e-hideme' id='core-download-tabs'>
|
||||
<ul class='e-tabs' id='core-download-tabs'>
|
||||
<li id='tab-general'><a href='#download-create'>".DOWLAN_175."</a></li>
|
||||
<li id='tab-external'><a href='#download-edit-external'>".DOWLAN_176."</a></li>
|
||||
<li id='tab-mirror'><a href='#download-edit-mirror'>".DOWLAN_128."</a></li>
|
||||
@ -632,10 +632,11 @@ $columnInfo = array(
|
||||
<tr>
|
||||
<td style='width:20%;'>".DOWLAN_13."</td>
|
||||
<td style='width:80%'>
|
||||
<div>".DOWLAN_131."
|
||||
<select name='download_url' class='tbox'>
|
||||
<option value=''> </option>
|
||||
";
|
||||
<div>".DOWLAN_131." ";
|
||||
|
||||
// $text .= "<select name='download_url' class='tbox'>
|
||||
// <option value=''> </option>\n";
|
||||
|
||||
|
||||
$counter = 0;
|
||||
while (isset($file_array[$counter]))
|
||||
@ -648,7 +649,7 @@ $columnInfo = array(
|
||||
$found = 1;
|
||||
}
|
||||
|
||||
$text .= "<option value='".$fpath."' $selected>".$fpath."</option>\n";
|
||||
// $text .= "<option value='".$fpath."' $selected>".$fpath."</option>\n";
|
||||
$counter++;
|
||||
}
|
||||
|
||||
@ -666,10 +667,14 @@ $columnInfo = array(
|
||||
|
||||
if (!$found && $download_url)
|
||||
{
|
||||
$text .= "<option value='".$download_url."' selected='selected'>".$download_url.$etext."</option>\n";
|
||||
// $text .= "<option value='".$download_url."' selected='selected'>".$download_url.$etext."</option>\n";
|
||||
}
|
||||
|
||||
$text .= " </select>
|
||||
// $text .= " </select>";
|
||||
|
||||
$text .= e107::getForm()->filepicker("download_url",$download_url,DOWLAN_131,"media=download_file&title=Choose a file");
|
||||
|
||||
$text .= "
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
Loading…
x
Reference in New Issue
Block a user