mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 03:40:37 +02:00
media manager work - upload link can be added now (see newspost.php); improved imageselector; several bugfixes
This commit is contained in:
@@ -282,8 +282,6 @@ class media_admin_ui extends e_admin_ui
|
||||
|
||||
function init()
|
||||
{
|
||||
|
||||
|
||||
$sql = e107::getDb();
|
||||
// $sql->db_Select_gen("SELECT media_cat_title, media_title_nick FROM #core_media as m LEFT JOIN #core_media_cat as c ON m.media_category = c.media_cat_nick GROUP BY m.media_category");
|
||||
$sql->db_Select_gen("SELECT media_cat_title, media_cat_nick FROM #core_media_cat");
|
||||
@@ -299,8 +297,21 @@ class media_admin_ui extends e_admin_ui
|
||||
{
|
||||
$this->batchImport();
|
||||
}
|
||||
}
|
||||
|
||||
if($this->getQuery('iframe'))
|
||||
{
|
||||
$this->getResponse()->setIframeMod();
|
||||
}
|
||||
|
||||
if($this->getQuery('for') && $this->getMediaCategory($this->getQuery('for')))
|
||||
{
|
||||
$this->setPosted('media_category', $this->getQuery('for'));
|
||||
if(!$this->getId())
|
||||
{
|
||||
$this->getModel()->set('media_category', $this->getQuery('for'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function importPage()
|
||||
{
|
||||
@@ -335,6 +346,10 @@ class media_admin_ui extends e_admin_ui
|
||||
//$dataFields = $this->getModel()->getDataFields();
|
||||
//unset($dataFields['media_upload']);
|
||||
//$this->getModel()->setDataFields($dataFields);
|
||||
if($this->getQuery('for') && $this->getMediaCategory($this->getQuery('for')))
|
||||
{
|
||||
$new_data['media_category'] = $this->getQuery('for');
|
||||
}
|
||||
return $this->observeUploaded($new_data);
|
||||
}
|
||||
|
||||
|
@@ -112,9 +112,8 @@ function headerjs()
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script type='text/javascript' src='".e_FILE_ABS."jslib/core/admin.js'></script>
|
||||
|
||||
";
|
||||
e107::getJs()->requireCoreLib('core/admin.js');
|
||||
|
||||
if($newspost->getAction() == 'cat')
|
||||
{
|
||||
@@ -1538,9 +1537,27 @@ class admin_newspost
|
||||
<td>".NWSLAN_66.":</td>
|
||||
<td>";
|
||||
|
||||
//FIXME - below is a quick fix for media-manager upload. Requires popup window without header/footer.
|
||||
$text .= "<a rel='external' href='".e_ADMIN_ABS."image.php?mode=main&action=create'>".NWSLAN_69."</a>";
|
||||
|
||||
$text .= $frm->mediaUrl('news', NWSLAN_69);
|
||||
/* //FIXME - below is a quick fix for media-manager upload. Requires popup window without header/footer.
|
||||
$text .= "<a rel='external' class='e-dialog' href='".e_ADMIN_ABS."image.php?mode=main&action=create&for=news'>".NWSLAN_69."</a>";
|
||||
// FIXME - make it system wide available
|
||||
e107::getJs()->requireCoreLib('core/admin.js')
|
||||
->requireCoreLib('core/dialog.js')
|
||||
->requireCoreLib('core/draggable.js')
|
||||
->coreCSS('core/dialog/dialog.css')
|
||||
->coreCSS('core/dialog/e107/e107.css')
|
||||
->footerInline('
|
||||
$$("a.e-dialog").invoke("observe", "click", function(ev) {
|
||||
var element = ev.findElement("a");
|
||||
ev.stop();
|
||||
new e107Widgets.URLDialog(element.href + "&iframe=1", {
|
||||
id: element["id"] || "e-dialog",
|
||||
width: 800,
|
||||
height: 600,
|
||||
title: "Media Manager"
|
||||
}).center().activate().show();
|
||||
});
|
||||
');*/
|
||||
// e_NEWSIMAGE is deprecated.
|
||||
|
||||
// DEPRECATED METHOD below.
|
||||
|
@@ -56,5 +56,5 @@ function imagepreview_shortcode($parm)
|
||||
{
|
||||
$thpath = !varset($nothumb) ? e107::getParser()->thumbUrl($path, 'w='.$width.'h='.$height, true) : $path;
|
||||
}
|
||||
return "<a href='{$path}' rel='external' class='e-image-preview'{$hide}><img src='{$thpath}' alt=\"\" class='image-selector' /></a>";
|
||||
return "<a href='{$path}' rel='external shadowbox' class='e-image-preview'{$hide}><img src='{$thpath}' alt=\"\" class='image-selector' /></a>";
|
||||
}
|
@@ -29,18 +29,17 @@ function imageselector_shortcode($parm = '', $mod = '')
|
||||
$scaction = varsettrue($scaction, 'all');
|
||||
$text = '';
|
||||
$name_id = e107::getForm()->name2id($name);
|
||||
|
||||
$imagelist = array();
|
||||
|
||||
//Get Select Box Only!
|
||||
if ($scaction == 'select' || $scaction == 'all')
|
||||
{
|
||||
$imagelist = array();
|
||||
|
||||
// Media manager support
|
||||
if(vartrue($parms['media']))
|
||||
{
|
||||
$qry = "SELECT * FROM `#core_media` WHERE media_userclass IN (".USERCLASS_LIST.") ";
|
||||
$qry .= vartrue($parms['media']) && $parms['media'] !== 'all' ? " AND media_category='".$tp->toDB($parms['media'])."' " : " AND `media_category` NOT REGEXP '_icon_16|_icon_32|_icon_48|_icon_64' ";
|
||||
$qry .= " AND media_category REGEX '.jpg|.png|.gif' ORDER BY media_name";
|
||||
$qry .= " AND media_url REGEXP '.jpg|.png|.gif|.JPG|.PNG|.GIF' ORDER BY media_name";
|
||||
// FIXME - media_type=image?
|
||||
if($sql->db_Select_gen($qry))
|
||||
{
|
||||
@@ -76,6 +75,11 @@ function imageselector_shortcode($parm = '', $mod = '')
|
||||
$label = ($label) ? $label : " -- -- ";
|
||||
$tabindex = varset($tabindex) ? " tabindex='{$tabindex}'" : '';
|
||||
$class = varset($class) ? " class='{$class}'" : " class='tbox imgselector'";
|
||||
|
||||
if(!e_AJAX_REQUEST)
|
||||
{
|
||||
$text .= '<div id="'.$name_id.'_cont">';
|
||||
}
|
||||
|
||||
$text .= "<select{$multi}{$tabindex}{$class} name='{$name}' id='{$name_id}' onchange=\"replaceSC('imagepreview={$name}|{$width}|{$height}',this.form,'{$name_id}_prev'); \">
|
||||
<option value=''>".$label."</option>\n";
|
||||
@@ -99,16 +103,32 @@ function imageselector_shortcode($parm = '', $mod = '')
|
||||
$pth = $dir;
|
||||
if($fullpath)
|
||||
{
|
||||
$pth = !vartrue($parms['media']) ? $tp->createConstants($icon['path'], 'rel') : $icon['path'];
|
||||
if(!vartrue($parms['media']))
|
||||
{
|
||||
$pth = $tp->createConstants($icon['path'], 'rel');
|
||||
$_value = $pth.$icon['fname'];
|
||||
$_label = $dir.$icon['fname'];
|
||||
$selected = ($default == $_value || $pth.$default == $_value) ? " selected='selected'" : "";
|
||||
}
|
||||
else
|
||||
{
|
||||
// convert e.g. {e_MEDIA}images/ to {e_MEDIA_IMAGES}
|
||||
$pth = $tp->createConstants($tp->replaceConstants($icon['path']), 'rel');
|
||||
$_value = $pth;
|
||||
$_label = $icon['fname'];
|
||||
$selected = ($default == $_value) ? " selected='selected'" : "";
|
||||
}
|
||||
}
|
||||
$selected = ($default == $pth.$icon['fname'] || $pth.$default == $pth.$icon['fname']) ? " selected='selected'" : "";
|
||||
$text .= "<option value='{$pth}{$icon['fname']}'{$selected}> {$dir}{$icon['fname']}</option>\n";
|
||||
|
||||
$text .= "<option value='{$_value}'{$selected}> {$_label}</option>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$text .= '</optgroup>';
|
||||
}
|
||||
$text .= "</select>";
|
||||
$text .= "<a href='#' onclick=\"replaceSC('imageselector=".rawurlencode($parm)."&saction=select',\$('{$name_id}').up('form'),'{$name_id}_cont'); return false;\">refresh</a>";
|
||||
if(!e_AJAX_REQUEST) $text .= '</div>';
|
||||
|
||||
if ($scaction == 'select') return $text;
|
||||
}
|
||||
@@ -149,7 +169,7 @@ function imageselector_shortcode($parm = '', $mod = '')
|
||||
}
|
||||
else
|
||||
{
|
||||
$text .= "<a href='{$pvw_default}'{$hide} rel='external' title='Preview {$pvw_default}' class='e-image-preview'>";
|
||||
$text .= "<a href='{$pvw_default}'{$hide} rel='external shadowbox' title='Preview {$pvw_default}' class='e-image-preview'>";
|
||||
}
|
||||
if (vartrue($height)) $height = intval($height);
|
||||
if (vartrue($width)) $width = intval($width);
|
||||
|
@@ -56,7 +56,10 @@ e107Widgets.Dialog = Class.create(e107WidgetAbstract, {
|
||||
this.events = new e107EventManager(this);
|
||||
|
||||
this.initMod('core-dialog', options);
|
||||
if(!e107Widgets['DialogManagerDefault']) e107Widgets.DialogManagerDefault = new e107Widgets.DialogManager();
|
||||
|
||||
this.dialogManager = this.options.dialogManager || e107Widgets.DialogManagerDefault;
|
||||
|
||||
if(this.options.id && this.dialogManager.getWindow($(this.options.id))) return;
|
||||
|
||||
this.setMethodChains();
|
||||
|
@@ -411,7 +411,7 @@ class e_admin_request
|
||||
//special case - exclude all current
|
||||
if(true === $exclude_from_query)
|
||||
{
|
||||
$exclude_from_query = $ret;
|
||||
$exclude_from_query = array_keys($ret);
|
||||
}
|
||||
// to array
|
||||
if(is_string($exclude_from_query))
|
||||
@@ -1834,7 +1834,7 @@ class e_admin_controller
|
||||
if($mode) $request->setMode($mode);
|
||||
if($action) $request->setAction($action);
|
||||
if(!$path) $path = e_SELF;
|
||||
|
||||
|
||||
$url = $path.'?'.$request->buildQueryString($merge_query, false, $exclude_query);
|
||||
// Transfer all messages to session
|
||||
e107::getMessage()->moveToSession();
|
||||
|
@@ -137,6 +137,35 @@ class e_form
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function mediaUrl($category = '', $label = '')
|
||||
{
|
||||
if($category) $category = '&for='.$category;
|
||||
if(!$label) $label = ' Upload an image or file';
|
||||
$ret = "<a rel='external' class='e-dialog' href='".e_ADMIN_ABS."image.php?mode=main&action=create{$category}'>".$label."</a>";
|
||||
|
||||
if(!e107::getRegistry('core/form/mediaurl'))
|
||||
{
|
||||
e107::getJs()->requireCoreLib('core/admin.js')
|
||||
->requireCoreLib('core/dialog.js')
|
||||
->requireCoreLib('core/draggable.js')
|
||||
->coreCSS('core/dialog/dialog.css')
|
||||
->coreCSS('core/dialog/e107/e107.css')
|
||||
->footerInline('
|
||||
$$("a.e-dialog").invoke("observe", "click", function(ev) {
|
||||
var element = ev.findElement("a");
|
||||
ev.stop();
|
||||
new e107Widgets.URLDialog(element.href + "&iframe=1", {
|
||||
id: element["id"] || "e-dialog",
|
||||
width: 900,
|
||||
height: 550
|
||||
}).center().activate().show();
|
||||
});
|
||||
');
|
||||
e107::setRegistry('core/form/mediaurl', true);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME - better GUI, {IMAGESELECTOR} rewrite, flexibility, thumbnails, tooltip image preivew, etc.
|
||||
@@ -166,7 +195,7 @@ class e_form
|
||||
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.") ";
|
||||
$qry .= vartrue($sc_parameters['media']) ? " AND media_category = '".$tp->toDB($sc_parameters['media'])."' " : " AND `media_category` NOT REGEXP '_icon_16|_icon_32|_icon_48|_icon_64' ";
|
||||
$qry .= "ORDER BY media_name";
|
||||
@@ -218,6 +247,7 @@ class e_form
|
||||
|
||||
if(!$label) $label = LAN_SELECT;
|
||||
$parms = "name={$name}";
|
||||
$parms .= '&media='.varset($sc_parameters['media']);
|
||||
$parms .= "&path=".rawurlencode(e107::getParser()->replaceConstants(vartrue($sc_parameters['path'], '{e_MEDIA}images/|{e_MEDIA}temp/')));
|
||||
$parms .= "&filter=0";
|
||||
$parms .= "&fullpath=1";
|
||||
|
Reference in New Issue
Block a user