mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 20:00:37 +02:00
This commit is contained in:
@@ -34,8 +34,8 @@ $e_sub_cat = 'image';
|
||||
|
||||
// require_once("auth.php");
|
||||
// require_once(e_HANDLER."form_handler.php");
|
||||
require_once(e_HANDLER."userclass_class.php");
|
||||
require_once(e_HANDLER."message_handler.php");
|
||||
//require_once(e_HANDLER."userclass_class.php");
|
||||
//require_once(e_HANDLER."message_handler.php");
|
||||
// $frm = new e_form(); //new form handler
|
||||
$emessage = eMessage::getInstance();
|
||||
|
||||
@@ -50,9 +50,9 @@ class media_admin extends e_admin_dispatcher
|
||||
'uipath' => null
|
||||
),
|
||||
'cat' => array(
|
||||
'controller' => 'faq_cat_ui',
|
||||
'controller' => 'media_cat_ui',
|
||||
'path' => null,
|
||||
'ui' => 'faq_cat_form_ui',
|
||||
'ui' => 'media_cat_form_ui',
|
||||
'uipath' => null
|
||||
)
|
||||
);
|
||||
@@ -94,7 +94,7 @@ class media_admin extends e_admin_dispatcher
|
||||
|
||||
}
|
||||
|
||||
class faq_cat_ui extends e_admin_ui
|
||||
class media_cat_ui extends e_admin_ui
|
||||
{
|
||||
protected $pluginTitle = 'Media Categories';
|
||||
protected $pluginName = 'core';
|
||||
@@ -122,16 +122,16 @@ class faq_cat_ui extends e_admin_ui
|
||||
* @param mixed $default [optional] default value if not found (default 'n/a')
|
||||
* @return TBD
|
||||
*/
|
||||
function getFaqCategoryTree($id = false, $default = 'n/a')
|
||||
function getMediaCategoryTree($id = false, $default = 'n/a')
|
||||
{
|
||||
// TODO get faq category tree
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*class faq_cat_form_ui extends e_admin_form_ui
|
||||
class faq_cat_form_ui extends e_admin_form_ui
|
||||
{
|
||||
public function faq_info_parent($curVal,$mode)
|
||||
/*public function faq_info_parent($curVal,$mode)
|
||||
{
|
||||
// TODO - catlist combo without current cat ID in write mode, parents only for batch/filter
|
||||
// Get UI instance
|
||||
@@ -151,8 +151,8 @@ class faq_cat_ui extends e_admin_ui
|
||||
return $controller->getFaqCategoryTree();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -160,11 +160,11 @@ class faq_cat_ui extends e_admin_ui
|
||||
class media_form_ui extends e_admin_form_ui
|
||||
{
|
||||
|
||||
private $cats = array();
|
||||
//private $cats = array();
|
||||
|
||||
function init()
|
||||
{
|
||||
$sql = e107::getDb();
|
||||
/*$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");
|
||||
while($row = $sql->db_Fetch())
|
||||
@@ -172,7 +172,7 @@ class media_form_ui extends e_admin_form_ui
|
||||
$cat = $row['media_cat_nick'];
|
||||
$this->cats[$cat] = $row['media_cat_title'];
|
||||
}
|
||||
asort($this->cats);
|
||||
asort($this->cats);*/
|
||||
}
|
||||
|
||||
function media_category($curVal,$mode) // not really necessary since we can use 'dropdown' - but just an example of a custom function.
|
||||
@@ -180,22 +180,24 @@ class media_form_ui extends e_admin_form_ui
|
||||
|
||||
if($mode == 'read')
|
||||
{
|
||||
return $this->cats[$curVal];
|
||||
return $this->getController()->getMediaCategory($curVal);
|
||||
//return $this->cats[$curVal];
|
||||
}
|
||||
|
||||
if($mode == 'batch') // Custom Batch List for release_type
|
||||
{
|
||||
return $this->cats;
|
||||
return $this->getController()->getMediaCategory();
|
||||
}
|
||||
|
||||
if($mode == 'filter') // Custom Filter List for release_type
|
||||
{
|
||||
return $this->cats;
|
||||
return $this->getController()->getMediaCategory();
|
||||
}
|
||||
|
||||
|
||||
$text = "<select class='tbox>' name='media_category' >";
|
||||
foreach($this->cats as $key=>$val)
|
||||
$cats = $this->getController()->getMediaCategory();
|
||||
foreach($cats as $key => $val)
|
||||
{
|
||||
$selected = ($curVal == $key) ? "selected='selected'" : "";
|
||||
$text .= "<option value='{$key}' {$selected}>".$val."</option>\n";
|
||||
@@ -234,13 +236,13 @@ class media_admin_ui extends e_admin_ui
|
||||
protected $fields = array(
|
||||
'checkboxes' => array('title'=> '', 'type' => null, 'data'=> null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
|
||||
'media_id' => array('title'=> LAN_ID, 'type' => 'number', 'data'=> 'int', 'width' =>'5%', 'forced'=> TRUE, 'nolist'=>TRUE),
|
||||
'media_url' => array('title'=> 'Preview', 'type' => 'image', 'data'=> 'str', 'thclass' => 'center', 'class'=>'center', 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60', 'width' => '110px','readonly'=>TRUE),
|
||||
'media_url' => array('title'=> 'Preview', 'type' => 'image', 'data'=> 'str', 'thclass' => 'center', 'class'=>'center', 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60', 'writeParams' => 'path={e_MEDIA}', 'width' => '110px','readonly'=>false),
|
||||
|
||||
// 'media_preview' => array('title'=> "Preview", 'type' => 'image', 'data'=> null, 'width' => '10%'),
|
||||
// 'media_preview' => array('title'=> "Preview", 'type' => 'image', 'data'=> null, 'width' => '10%'),
|
||||
'media_upload' => array('title'=> "Upload File", 'type' => 'upload', 'data'=> false, 'readParm' => 'hidden', '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' => array('title'=> LAN_DESCRIPTION, 'type' => 'bbarea', 'data'=> 'str', 'width' => 'auto', 'thclass' => 'left first', 'readParms' => 'truncate=100', 'writeParms' => 'counter=0'),
|
||||
'media_description' => array('title'=> LAN_DESCRIPTION, 'type' => 'bbarea', 'data'=> 'str', 'width' => 'auto', 'thclass' => 'left first', 'readParms' => 'truncate=100', 'writeParms' => 'counter=0'),
|
||||
'media_category' => array('title'=> LAN_CATEGORY, 'type' => 'method', 'data'=> 'str', 'width' => 'auto', 'filter' => true, 'batch' => true,),
|
||||
'media_type' => array('title'=> "Mime Type", 'type' => 'text', 'data'=> 'str', 'width' => 'auto', 'noedit'=>TRUE),
|
||||
// 'media_author' => array('title'=> LAN_AUTHOR, 'type' => 'user', 'data'=> 'int'),
|
||||
@@ -250,7 +252,7 @@ class media_admin_ui extends e_admin_ui
|
||||
'media_dimensions' => array('title'=> "Dimensions", 'type' => 'text', 'data'=> 'str', 'width' => '5%', 'noedit'=>TRUE, 'class'=>'nowrap'),
|
||||
'media_userclass' => array('title'=> LAN_USERCLASS, 'type' => 'userclass', 'data'=> 'str', 'width' => '10%', 'thclass' => 'center','filter'=>TRUE,'batch'=>TRUE ),
|
||||
'media_tags' => array('title'=> "Tags/Keywords", 'type' => 'text', 'data'=> 'str', 'width' => '10%', 'filter'=>TRUE,'batch'=>TRUE ),
|
||||
'media_usedby' => array('title'=> '', 'type' => 'text', 'data'=> 'text', 'width' => 'auto', 'thclass' => 'center', 'class'=>'center', 'nolist'=>true, 'readonly'=>TRUE ),
|
||||
'media_usedby' => array('title'=> '', 'type' => 'text', 'data'=> 'text', 'width' => 'auto', 'thclass' => 'center', 'class'=>'center', 'nolist'=>true, 'readonly'=>TRUE ),
|
||||
|
||||
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'data'=> null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center')
|
||||
);
|
||||
@@ -281,7 +283,7 @@ class media_admin_ui extends e_admin_ui
|
||||
function init()
|
||||
{
|
||||
|
||||
//FIXME - would prefer not to have to read this twice on the same page.
|
||||
|
||||
$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");
|
||||
@@ -332,7 +334,7 @@ class media_admin_ui extends e_admin_ui
|
||||
$this->getRequest()->setPosted('media_upload', null);
|
||||
//$dataFields = $this->getModel()->getDataFields();
|
||||
//unset($dataFields['media_upload']);
|
||||
$this->getModel()->setDataFields($dataFields);
|
||||
//$this->getModel()->setDataFields($dataFields);
|
||||
return $this->observeUploaded($new_data);
|
||||
}
|
||||
|
||||
@@ -345,6 +347,23 @@ class media_admin_ui extends e_admin_ui
|
||||
// return data to be merged with posted model data
|
||||
return $this->observeUploaded($new_data);
|
||||
}
|
||||
|
||||
public function mediaData($sc_path)
|
||||
{
|
||||
if(!$sc_path) return array();
|
||||
$path = e107::getParser()->replaceConstants($sc_path);
|
||||
$info = e107::getFile()->get_file_info($path);
|
||||
return array(
|
||||
'media_type' => $info['mime'],
|
||||
'media_datestamp' => time(),
|
||||
'media_url' => e107::getParser()->createConstants($path, 'rel'),
|
||||
'media_size' => filesize($path),
|
||||
'media_author' => USERID,
|
||||
'media_usedby' => '',
|
||||
'media_tags' => '',
|
||||
'media_dimensions' => $info['img-width']." x ".$info['img-height']
|
||||
);
|
||||
}
|
||||
|
||||
// XXX - strict mysql error on Create without UPLOAD!
|
||||
function observeUploaded($new_data)
|
||||
@@ -352,56 +371,84 @@ class media_admin_ui extends e_admin_ui
|
||||
$fl = e107::getFile();
|
||||
|
||||
$mes = e107::getMessage();
|
||||
$pref['upload_storagetype'] = "1";
|
||||
require_once(e_HANDLER."upload_handler.php"); //TODO - still not a class!
|
||||
|
||||
$uploaded = process_uploaded_files(e_MEDIA.'temp/'); //FIXME doesn't handle xxx.JPG (uppercase)
|
||||
|
||||
foreach($uploaded as $upload)
|
||||
if(vartrue($_POST['file_userfile']))
|
||||
{
|
||||
$pref['upload_storagetype'] = "1";
|
||||
require_once(e_HANDLER."upload_handler.php"); //TODO - still not a class!
|
||||
$uploaded = process_uploaded_files(e_MEDIA.'temp/'); //FIXME doesn't handle xxx.JPG (uppercase)
|
||||
$upload = array_shift($uploaded);
|
||||
if(vartrue($upload['error']))
|
||||
{
|
||||
$mes->add($upload['message'], E_MESSAGE_ERROR);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(!$typePath = $this->getPath($upload['type']))
|
||||
{
|
||||
$mes->add($upload['message'], E_MESSAGE_ERROR);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(!$typePath = $this->getPath($upload['type']))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$oldpath = 'temp/'.$upload['name'];
|
||||
$newpath = $typePath.'/'.$upload['name'];
|
||||
|
||||
//$info = $fl->get_file_info(e_MEDIA.$oldpath);
|
||||
|
||||
/*$upload_data = array( // not saved if 'noedit' is active.
|
||||
'media_type' => $upload['type'],
|
||||
'media_datestamp' => time(),
|
||||
'media_url' => "{e_MEDIA}".$newpath,
|
||||
'media_size' => $upload['size'],
|
||||
'media_author' => USERID,
|
||||
'media_usedby' => '',
|
||||
'media_tags' => '',
|
||||
'media_dimensions' => $info['img-width']." x ".$info['img-height']
|
||||
);*/
|
||||
|
||||
// only one upload? Not sure what's the idea here
|
||||
// we are currently creating one media item
|
||||
if(!rename(e_MEDIA.$oldpath, e_MEDIA.$newpath))
|
||||
{
|
||||
$mes->add("Couldn't move file from ".$oldpath." to ".$newpath, E_MESSAGE_ERROR);
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
$img_data = $this->mediaData('{e_MEDIA}'.$newpath);
|
||||
if(!varset($new_data['media_name']))
|
||||
{
|
||||
$img_data['media_name'] = $upload['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$img_data = $this->mediaData($new_data['media_url']);
|
||||
if(!($typePath = $this->getPath($img_data['media_type'])))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$oldpath = 'temp/'.$upload['name'];
|
||||
$newpath = $typePath.'/'.$upload['name'];
|
||||
|
||||
$info = $fl->get_file_info(e_MEDIA.$oldpath);
|
||||
|
||||
$upload_data = array( // not saved if 'noedit' is active.
|
||||
'media_type' => $upload['type'],
|
||||
'media_datestamp' => time(),
|
||||
'media_url' => "{e_MEDIA}".$newpath,
|
||||
'media_size' => $upload['size'],
|
||||
'media_author' => USERID,
|
||||
'media_usedby' => '',
|
||||
'media_tags' => '',
|
||||
'media_dimensions' => $info['img-width']." x ".$info['img-height']
|
||||
);
|
||||
|
||||
|
||||
$fname = basename($new_data['media_url']);
|
||||
// move to the required place
|
||||
if(strpos($new_data['media_url'], '{e_MEDIA}temp/') !== FALSE)
|
||||
{
|
||||
$tp = e107::getParser();
|
||||
$oldpath = $tp->replaceConstants($new_data['media_url']);
|
||||
$newpath = e_MEDIA.$typePath.'/'.$fname;
|
||||
if(!rename($oldpath, $newpath))
|
||||
{
|
||||
$mes->add("Couldn't move file from ".$oldpath." to ".str_replace('../', '', $newpath), E_MESSAGE_ERROR);
|
||||
return FALSE;
|
||||
}
|
||||
$img_data['media_url'] = $tp->createConstants($newpath, 'rel');
|
||||
}
|
||||
|
||||
if(!varset($new_data['media_name']))
|
||||
{
|
||||
$upload_data['media_name'] = $upload['name'];
|
||||
$img_data['media_name'] = basename($new_data['media_url']);
|
||||
}
|
||||
|
||||
// only one upload? Not sure what's the idea here
|
||||
// we are currently creating one media item
|
||||
if(!rename(e_MEDIA.$oldpath, e_MEDIA.$newpath))
|
||||
{
|
||||
$mes->add("Couldn't move file from ".$oldpath." to ".$newpath, E_MESSAGE_ERROR);
|
||||
return FALSE;
|
||||
};
|
||||
return $upload_data;
|
||||
}
|
||||
|
||||
return $img_data;
|
||||
}
|
||||
|
||||
function beforeDelete($data, $id) // call before 'delete' is executed. - return false to prevent delete execution (e.g. some dependencies check)
|
||||
@@ -447,6 +494,7 @@ class media_admin_ui extends e_admin_ui
|
||||
|
||||
$fl->setFileInfo('all');
|
||||
$files = $fl->get_files(e_MEDIA."temp/");
|
||||
e107::getJs()->requireCoreLib('core/admin.js');
|
||||
|
||||
//TODO Detect XML file, and if found - read that instead of the directory.
|
||||
|
||||
@@ -474,7 +522,7 @@ class media_admin_ui extends e_admin_ui
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='center'>Checkbox</th>
|
||||
<th class='center'>".e107::getForm()->checkbox_toggle('e-column-toggle', 'batch_selected')."</th>
|
||||
<th class='center' style='width:50px'>Preview</th>
|
||||
<th class='center'>".LAN_NAME."</th>
|
||||
<th>Mime Type</th>
|
||||
@@ -575,7 +623,9 @@ class media_admin_ui extends e_admin_ui
|
||||
|
||||
if($type == 'image')
|
||||
{
|
||||
return "<img src='".$f['path'].$f['fname']."' alt=\"".$f['name']."\" width='50px' />";
|
||||
$url = e107::getParser()->thumbUrl($f['path'].$f['fname'], 'w=100', true);
|
||||
//echo $url;
|
||||
return "<img src='".$url."' alt=\"".$f['name']."\" width='50px' />";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -583,9 +633,12 @@ class media_admin_ui extends e_admin_ui
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getMediaCategory($id = false)
|
||||
{
|
||||
if($id) return (isset($this->cats[$id]) ? $this->cats[$id] : 0);
|
||||
return $this->cats;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
162
e107_core/shortcodes/single/imageselector.php
Normal file
162
e107_core/shortcodes/single/imageselector.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
// $Id: imageselector.sc 11438 2010-03-16 17:00:44Z secretr $
|
||||
//FIXME - full rewrite, backward compatible
|
||||
|
||||
function imageselector_shortcode($parm = '', $mod = '')
|
||||
{
|
||||
|
||||
$sql = e107::getDb('imageselector.sc');
|
||||
$tp = e107::getParser();
|
||||
|
||||
if (strstr($parm, "="))
|
||||
{ // query style parms.
|
||||
parse_str($parm, $parms);
|
||||
extract($parms);
|
||||
}
|
||||
else
|
||||
{ // comma separated parms.
|
||||
list($name, $path, $default, $width, $height, $multiple, $label, $subdirs, $filter, $fullpath, $click_target, $click_prefix, $click_postfix, $tabindex, $class) = explode(",", $parm);
|
||||
}
|
||||
|
||||
$paths = explode("|", $path);
|
||||
|
||||
if (trim($default[0]) == "{")
|
||||
{
|
||||
$pvw_default = $tp->replaceConstants($default, 'abs');
|
||||
$path = ""; // remove the default path if a constant is used.
|
||||
}
|
||||
|
||||
$scaction = varsettrue($scaction, 'all');
|
||||
$text = '';
|
||||
$name_id = e107::getForm()->name2id($name);
|
||||
|
||||
//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";
|
||||
// FIXME - media_type=image?
|
||||
if($sql->db_Select_gen($qry))
|
||||
{
|
||||
while($row = $sql->db_Fetch())
|
||||
{
|
||||
//$imagelist[$row['media_category']][$row['media_url']] = $row['media_name']. " (".$row['media_dimensions'].") ";
|
||||
$imagelist[$row['media_category']][] = array('path' => $row['media_url'], 'fname' => $row['media_name']. " (".$row['media_dimensions'].") ");
|
||||
}
|
||||
|
||||
asort($opts);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//require_once(e_HANDLER."file_class.php");
|
||||
$fl = e107::getFile(false);
|
||||
|
||||
$recurse = ($subdirs) ? $subdirs : 0;
|
||||
foreach ($paths as $pths)
|
||||
{
|
||||
$imagelist[$tp->createConstants($pths, 'mix')] = $fl->get_files($pths, '\.jpg|\.gif|\.png|\.JPG|\.GIF|\.PNG', 'standard', $recurse);
|
||||
}
|
||||
|
||||
if (!$fullpath && (count($paths) > 1))
|
||||
{
|
||||
$fullpath = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
$multi = ($multiple == "TRUE" || $multiple == "1") ? " multiple='multiple' style='height:{$height}'" : ""; //style='float:left'
|
||||
$width = ($width) ? $width : "0";
|
||||
$height = ($height) ? $height : "0";
|
||||
$label = ($label) ? $label : " -- -- ";
|
||||
$tabindex = varset($tabindex) ? " tabindex='{$tabindex}'" : '';
|
||||
$class = varset($class) ? " class='{$class}'" : " class='tbox imgselector'";
|
||||
|
||||
$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";
|
||||
|
||||
require_once(e_HANDLER.'admin_handler.php');
|
||||
foreach ($imagelist as $imagedirlabel => $icons)
|
||||
{
|
||||
if(!vartrue($parms['media'])) $imagedirlabel = str_replace('../', '', $tp->replaceConstants($imagedirlabel));
|
||||
$text .= "<optgroup label='".$imagedirlabel."'>";
|
||||
if (empty($icons)) $text .= "<option value=''>Empty</option>\n";
|
||||
else
|
||||
{
|
||||
$icons = multiarray_sort($icons, 'fname');
|
||||
|
||||
foreach ($icons as $icon)
|
||||
{
|
||||
$dir = str_replace($paths, "", $icon['path']);
|
||||
|
||||
if (!$filter || ($filter && ereg($filter, $dir.$icon['fname'])))
|
||||
{
|
||||
$pth = $dir;
|
||||
if($fullpath)
|
||||
{
|
||||
$pth = !vartrue($parms['media']) ? $tp->createConstants($icon['path'], 'rel') : $icon['path'];
|
||||
}
|
||||
$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 .= '</optgroup>';
|
||||
}
|
||||
$text .= "</select>";
|
||||
|
||||
if ($scaction == 'select') return $text;
|
||||
}
|
||||
|
||||
$hide = '';
|
||||
if (!$pvw_default)
|
||||
{
|
||||
if ($default)
|
||||
{
|
||||
$test = pathinfo($default);
|
||||
if ('.' == $test['dirname'])
|
||||
{
|
||||
// file only, add absolute path
|
||||
$path = $tp->createConstants($path, 1);
|
||||
$path = $tp->replaceConstants($path, 'abs');
|
||||
$pvw_default = $path.$default;
|
||||
}
|
||||
else
|
||||
{
|
||||
// path, convert to absolute path
|
||||
$pvw_default = $tp->createConstants($default, 1);
|
||||
$pvw_default = $tp->replaceConstants($pvw_default, 'abs');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$pvw_default = e_IMAGE_ABS."generic/blank.gif";
|
||||
$hide = ' style="display: none;"';
|
||||
}
|
||||
}
|
||||
|
||||
$text .= "<div class='imgselector-container' id='{$name_id}_prev'>";
|
||||
if (varset($click_target))
|
||||
{
|
||||
$pre = varset($click_prefix);
|
||||
$post = varset($click_postfix);
|
||||
$text .= "<a href='#'{$hide} title='Select' onclick='addtext(\"{$pre}\"+document.getElementById(\"{$name_id}\").value+\"{$post}\", true);document.getElementById(\"{$name_id}\").selectedIndex = -1;return false;'>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$text .= "<a href='{$pvw_default}'{$hide} rel='external' title='Preview {$pvw_default}' class='e-image-preview'>";
|
||||
}
|
||||
if (vartrue($height)) $height = intval($height);
|
||||
if (vartrue($width)) $width = intval($width);
|
||||
$thpath = isset($parms['nothumb']) || $hide ? $pvw_default : $tp->thumbUrl($pvw_default, 'w='.$width.'&h='.$height, true);
|
||||
$text .= "<img src='{$thpath}' alt='$pvw_default' class='image-selector' /></a>";
|
||||
|
||||
$text .= "</div>\n";
|
||||
|
||||
return "\n\n<!-- Start Image Selector [{$scaction}] -->\n\n".$text."\n\n<!-- End Image Selector [{$scaction}] -->\n\n";
|
||||
}
|
@@ -138,17 +138,37 @@ class e_form
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// FIXME - better GUI, {IMAGESELECTOR} rewrite, flexibility, thumbnails, tooltip image preivew, etc.
|
||||
//FIXME - use the media-manager as an image selector.
|
||||
/**
|
||||
* FIXME - better GUI, {IMAGESELECTOR} rewrite, flexibility, thumbnails, tooltip image preivew, etc.
|
||||
* FIXME - use the media-manager as an image selector.
|
||||
* SC Parameter list:
|
||||
* - media: if present - load from media table
|
||||
* - path: server pats to be listed (separated by |) - only if 'media' param is not present
|
||||
* - subdirs: folder search depth (default is 10)
|
||||
* - width: preview width in pixels
|
||||
* - height: preview height in pixels
|
||||
* Additional usage is <code>$sc_parameters = 'news'</code>
|
||||
* where
|
||||
* Full list can be found in shortcodes/imageselector.php
|
||||
* @param string $name input name
|
||||
* @param string $default default value
|
||||
* @param string $label custom label
|
||||
* @param string $sc_parameters shortcode parameters
|
||||
* @return string html output
|
||||
*/
|
||||
function imagepicker($name, $default, $label = '', $sc_parameters = '')
|
||||
{
|
||||
// Temporary Fix for using Media-Manager data
|
||||
$sql = e107::getDb();
|
||||
$tp = e107::getParser();
|
||||
|
||||
// $sc_parameters is currently being used to select the media-category.
|
||||
|
||||
$qry = "SELECT * FROM `#core_media` WHERE media_userclass IN (".USERCLASS_LIST.") ";
|
||||
$qry .= vartrue($sc_parameters) ? " AND media_category = '".$sc_parameters."' " : " AND `media_category` NOT REGEXP '_icon_16|_icon_32|_icon_48|_icon_64' ";
|
||||
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.") ";
|
||||
$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";
|
||||
|
||||
|
||||
@@ -161,7 +181,6 @@ class e_form
|
||||
|
||||
asort($opts);
|
||||
|
||||
$tp = e107::getParser();
|
||||
$hide = $default_url = '';
|
||||
$default_thumb = $default;
|
||||
if($default)
|
||||
@@ -193,26 +212,25 @@ class e_form
|
||||
$ret .= "<img src='{$thpath}' alt='{$default_url}' class='image-selector' /></a>";
|
||||
$ret .= "</div>\n";
|
||||
return $ret;
|
||||
}
|
||||
}*/
|
||||
// ----------------
|
||||
|
||||
if(is_string($sc_parameters)) parse_str($sc_parameters, $sc_parameters);
|
||||
|
||||
if(!$label) $label = LAN_SELECT;
|
||||
$parms = "name={$name}";
|
||||
$parms .= "&path=".rawurlencode(e107::getParser()->replaceConstants(vartrue($sc_parameters['path'], '{e_FILE}images/')));
|
||||
$parms .= "&path=".rawurlencode(e107::getParser()->replaceConstants(vartrue($sc_parameters['path'], '{e_MEDIA}images/|{e_MEDIA}temp/')));
|
||||
$parms .= "&filter=0";
|
||||
$parms .= "&fullpath=1";
|
||||
$parms .= "&default=".rawurlencode($default);
|
||||
$parms .= "&multiple=FALSE";
|
||||
$parms .= "&label=-- ".$label." --";
|
||||
$parms .= "&subdirs=".varset($sc_parameters['subdirs'], 1);
|
||||
$parms .= "&subdirs=".varset($sc_parameters['subdirs'], 10);
|
||||
$parms .= '&width='.vartrue($sc_parameters['width'], 150);
|
||||
if(vartrue($sc_parameters['height'])) $parms .= '&height='.$sc_parameters['height'].'px';
|
||||
//$parms .= "&tabindex=".$this->getNext();
|
||||
//$parms .= "&click_target=data";
|
||||
//$parms .= "&click_prefix=[img][[e_IMAGE]]newspost_images/";
|
||||
//$parms .= "&click_postfix=[/img]";
|
||||
$tp = e107::getParser();
|
||||
|
||||
$ret = "<div class='field-section'>".$tp->parseTemplate("{IMAGESELECTOR={$parms}&scaction=select}")."</div>";
|
||||
$ret .= "<div class='field-spacer'>".$tp->parseTemplate("{IMAGESELECTOR={$parms}&scaction=preview}")."</div>";
|
||||
@@ -1851,7 +1869,7 @@ class e_form
|
||||
{
|
||||
$key = $att['field'];
|
||||
}
|
||||
|
||||
|
||||
$parms = vartrue($att['formparms'], array());
|
||||
if(!is_array($parms)) parse_str($parms, $parms);
|
||||
$label = vartrue($att['note']) ? '<div class="label-note">'.deftrue($att['note'], $att['note']).'</div>' : '';
|
||||
@@ -1889,7 +1907,7 @@ class e_form
|
||||
$model_required[$key][] = varset($att['error']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$text .= "
|
||||
<tr>
|
||||
<td class='label'>
|
||||
|
Reference in New Issue
Block a user