mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 06:38:00 +02:00
MediaCategories added to plugin.xml spec. and install/uninstall routine. Paste fixes for wysiwyg. Custom-Page issue corrected. admin-ui enhanced for images categories.
This commit is contained in:
@@ -782,14 +782,26 @@ class page_admin_ui extends e_admin_ui
|
||||
if(!$type && (!$page_title || !$page_sef))
|
||||
{
|
||||
e107::getMessage()->addError(CUSLAN_34, 'default', true);
|
||||
|
||||
|
||||
|
||||
e107::getRedirect()->redirect(e_ADMIN_ABS.'cpage.php');
|
||||
}
|
||||
|
||||
if(!$type && $sql->db_Count('page', '(page_id)', ($mode ? "page_id<>{$mode} AND " : '')."page_sef!='{$page_sef}'"))
|
||||
// FIXME Causes false positives on Update.. - what is trying to be achieved with this check?
|
||||
/*
|
||||
if(!$type && $sql->db_Count('page', '(page_id)', ($mode ? "page_id != {$mode} AND " : '')."page_sef != '{$page_sef}'"))
|
||||
{
|
||||
e107::getMessage()->addError(CUSLAN_34, 'default', true);
|
||||
|
||||
e107::getMessage()->addDebug("type=".$type, 'default', true);
|
||||
e107::getMessage()->addDebug("page_title=".$page_title, 'default', true);
|
||||
e107::getMessage()->addDebug("page_sef=".$page_sef, 'default', true);
|
||||
e107::getMessage()->addDebug("Mode=".$mode, 'default', true);
|
||||
|
||||
e107::getRedirect()->redirect(e_ADMIN_ABS.'cpage.php');
|
||||
}
|
||||
*/
|
||||
|
||||
if($type && empty($_POST['menu_name']))
|
||||
{
|
||||
|
@@ -145,39 +145,54 @@ class media_cat_ui extends e_admin_ui
|
||||
protected $batchDelete = false;
|
||||
|
||||
public $ownerCount = array();
|
||||
// protected $listQry = "SELECT * FROM #faq_info"; // without any Order or Limit.
|
||||
// protected $listQry = "SELECT * FROM #core_media_cat"; // without any Order or Limit.
|
||||
protected $listOrder = 'media_cat_owner asc';
|
||||
|
||||
// protected $editQry = "SELECT * FROM #faq_info WHERE faq_info_id = {ID}";
|
||||
|
||||
protected $fields = array(
|
||||
//'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
|
||||
'media_cat_id' => array('title'=> LAN_ID, 'type' => 'number', 'width' =>'5%', 'forced'=> TRUE, 'readonly'=>TRUE),
|
||||
'media_cat_id' => array('title'=> LAN_ID, 'type' => 'number', 'width' =>'5%', 'nolist'=>true, 'forced'=> TRUE, 'readonly'=>TRUE),
|
||||
'media_cat_image' => array('title'=> LAN_IMAGE, 'type' => 'image', 'data' => 'str', 'width' => '100px', 'thclass' => 'center', 'class'=>'center', 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60','readonly'=>FALSE, 'batch' => FALSE, 'filter'=>FALSE),
|
||||
'media_cat_owner' => array('title'=> "Owner", 'type' => 'dropdown', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE),
|
||||
'media_cat_owner' => array('title'=> "Owner", 'type' => 'dropdown', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE),
|
||||
'media_cat_category' => array('title'=> LAN_CATEGORY, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>TRUE),
|
||||
'media_cat_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE),
|
||||
'media_cat_diz' => array('title'=> LAN_DESCRIPTION, 'type' => 'bbarea', 'width' => '30%', 'readParms' => 'expand=...&truncate=150&bb=1','readonly'=>FALSE), // Display name
|
||||
'media_cat_class' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'width' => 'auto', 'data' => 'int'),
|
||||
'media_cat_order' => array('title'=> LAN_ORDER, 'type' => 'text', 'width' => '5%', 'thclass' => 'right', 'class'=> 'right' ),
|
||||
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'width' => '10%', 'forced'=>TRUE, 'thclass' => 'center last', 'class' => 'center')
|
||||
'options' => array('title'=> LAN_OPTIONS, 'type' => 'method', 'noedit'=>true, 'width' => '10%', 'forced'=>TRUE, 'thclass' => 'center last', 'class' => 'center')
|
||||
);
|
||||
|
||||
function init()
|
||||
{
|
||||
$this->fields['media_cat_owner']['writeParms'] = array(
|
||||
|
||||
$restricted = array(
|
||||
"_common" => "_common",
|
||||
"_icon" => "_icon",
|
||||
"news" => "news",
|
||||
"page" => "page",
|
||||
"gallery" => "gallery",
|
||||
"download" => "download"
|
||||
|
||||
"download" => "download"
|
||||
);
|
||||
|
||||
if($_GET['action'] == 'list')
|
||||
{
|
||||
$this->fields['media_cat_owner']['writeParms'] = $restricted;
|
||||
}
|
||||
|
||||
$sql = e107::getDb();
|
||||
|
||||
|
||||
$sql->db_Select_gen("SELECT media_cat_owner, count(media_cat_id) as number FROM `#core_media_cat` GROUP BY media_cat_owner");
|
||||
while($row = $sql->db_Fetch())
|
||||
{
|
||||
$this->ownerCount[$row['media_cat_owner']] = $row['number'];
|
||||
$this->ownerCount[$row['media_cat_owner']] = $row['number'];
|
||||
$own = $row['media_cat_owner'];
|
||||
if(!in_array($own,$restricted))
|
||||
{
|
||||
|
||||
$this->fields['media_cat_owner']['writeParms'][$own] = $own;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -212,7 +227,37 @@ class media_cat_ui extends e_admin_ui
|
||||
|
||||
class media_cat_form_ui extends e_admin_form_ui
|
||||
{
|
||||
protected $restrictedOwners = array(
|
||||
'_common',
|
||||
'news',
|
||||
'page',
|
||||
'download',
|
||||
'_icon'
|
||||
);
|
||||
|
||||
|
||||
function options($parms, $value, $id)
|
||||
{
|
||||
|
||||
if($_GET['action'] == 'create' || $_GET['action'] == 'edit')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$owner = $this->getController()->getListModel()->get('media_cat_owner');
|
||||
if(!in_array($owner,$this->restrictedOwners))
|
||||
{
|
||||
return $this->renderValue('options',$value,'',$id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// $save = ($_GET['bbcode']!='file') ? "e-dialog-save" : "";
|
||||
// e-dialog-close
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1379,13 +1424,13 @@ class media_admin_ui extends e_admin_ui
|
||||
$mes->addWarning($f['fname']." couldn't be renamed. Check file perms.");
|
||||
}
|
||||
|
||||
|
||||
$large = e107::getParser()->thumbUrl($f['path'].$f['fname'], 'w=800', true);
|
||||
$text .= "
|
||||
|
||||
<tr>
|
||||
<td class='center'>".$frm->checkbox("batch_selected[".$c."]",$f['fname'])."</td>
|
||||
<td class='center'>".$this->preview($f)."</td>
|
||||
<td>".$f['fname']."</td>
|
||||
<td><a class='e-dialog' href='".$large."'>".$f['fname']."</a></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>
|
||||
|
||||
|
@@ -1117,14 +1117,14 @@ function update_706_to_800($type='')
|
||||
e107::getMessage()->addDebug("core-media-cat `media_cat_nick` field removed.");
|
||||
}
|
||||
|
||||
$query = "INSERT INTO `".MPREFIX."core_media_cat` (`media_cat_id`, `media_cat_owner`, `media_cat_category`, `media_cat_title`, `media_cat_diz`, `media_cat_class`, `media_cat_image`, `media_cat_order`) VALUES
|
||||
(0, 'gallery', 'gallery_1', 'Gallery 1', 'Visible to the public at /gallery.php', 0, '', 0);
|
||||
";
|
||||
|
||||
if(mysql_query($query))
|
||||
{
|
||||
e107::getMessage()->addDebug("Added core-media-cat Gallery.");
|
||||
}
|
||||
// $query = "INSERT INTO `".MPREFIX."core_media_cat` (`media_cat_id`, `media_cat_owner`, `media_cat_category`, `media_cat_title`, `media_cat_diz`, `media_cat_class`, `media_cat_image`, `media_cat_order`) VALUES
|
||||
// (0, 'gallery', 'gallery_1', 'Gallery 1', 'Visible to the public at /gallery.php', 0, '', 0);
|
||||
/// ";
|
||||
//
|
||||
// if(mysql_query($query))
|
||||
// {
|
||||
// e107::getMessage()->addDebug("Added core-media-cat Gallery.");
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1183,7 +1183,7 @@ function update_706_to_800($type='')
|
||||
mysql_query("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'download', 'download_thumb', 'Download Thumbnails', '', 253, '', 0);");
|
||||
mysql_query("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'download', 'download_file', 'Download Files', '', 253, '', 0);");
|
||||
|
||||
mysql_query("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'gallery', 'gallery_1', 'Gallery', 'Visible to the public at /gallery.php', 0, '', 0);");
|
||||
// mysql_query("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'gallery', 'gallery_1', 'Gallery', 'Visible to the public at /gallery.php', 0, '', 0);");
|
||||
|
||||
mysql_query("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'news', 'news_thumb', 'News Thumbnails (Legacy)', 'Legacy news thumbnails. ', 253, '', 1);");
|
||||
|
||||
|
@@ -891,7 +891,10 @@ class eRouter
|
||||
|
||||
public static function clearCache()
|
||||
{
|
||||
@unlink(e_CACHE_URL.'config.php');
|
||||
if(file_exists(e_CACHE_URL.'config.php'))
|
||||
{
|
||||
@unlink(e_CACHE_URL.'config.php');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2083,13 +2083,13 @@ class e_form
|
||||
case 'image': //TODO - thumb, image list shortcode, js tooltip...
|
||||
$label = varset($parms['label'], 'LAN_EDIT');
|
||||
unset($parms['label']);
|
||||
$ret = $this->imagepicker($key, $value, defset($label, $label), vartrue($parms['__options']));
|
||||
$ret = $this->imagepicker($key, $value, defset($label, $label), $parms);
|
||||
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']));
|
||||
$ret = $this->filepicker($key, $value, defset($label, $label), $parms);
|
||||
break;
|
||||
|
||||
case 'icon':
|
||||
|
@@ -203,17 +203,20 @@ class e_media
|
||||
* Create media category.
|
||||
* 'class' data is optional, 'id' key is ignored
|
||||
*
|
||||
* @param array $data associative array, db keys should be passed without the leading 'media_cat_' e.g. 'class', 'nick', etc.
|
||||
* @param array $data associative array, db keys should be passed without the leading 'media_cat_' e.g. 'class', 'type', etc.
|
||||
* @return integer last inserted ID or false on error
|
||||
*/
|
||||
public function createCategory($data)
|
||||
public function createCategory($datas)
|
||||
{
|
||||
foreach ($data as $k => $v)
|
||||
foreach ($datas as $k => $v)
|
||||
{
|
||||
$data['media_cat_'.$k] = $v;
|
||||
}
|
||||
$data['media_cat_id'] = 0;
|
||||
if(!isset($data['media_cat_class']) || '' === $data['media_cat_class']) $data['media_cat_class'] = defset('e_UC_MEMBER', 253);
|
||||
if(!isset($data['media_cat_class']) || '' === $data['media_cat_class'])
|
||||
{
|
||||
$data['media_cat_class'] = defset('e_UC_MEMBER', 253);
|
||||
}
|
||||
return e107::getDb()->db_Insert('core_media_cat', $data);
|
||||
}
|
||||
|
||||
@@ -237,6 +240,31 @@ class e_media
|
||||
// TODO
|
||||
}
|
||||
|
||||
public function deleteAllCategories($owner='')
|
||||
{
|
||||
if($owner == '')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = e107::getDb();
|
||||
|
||||
$sql->db_Select('core_media_cat',"media_cat_category", "media_cat_owner = '".$owner."' ");
|
||||
while($row = $sql->db_Fetch())
|
||||
{
|
||||
$categories[] = "'".$row['media_cat_category']."'";
|
||||
}
|
||||
|
||||
if($sql->db_Delete('core_media_cat', "media_cat_owner = '".$owner."' "))
|
||||
{
|
||||
//TODO retrieve all category names for owner, and reset all media categories to _common.
|
||||
return TRUE;
|
||||
// return $sql->db_Update('core_media', "media_category = '_common_image' WHERE media_category IN (".implode(",",$categories).")");
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an Array of Media Categories
|
||||
*/
|
||||
|
@@ -54,7 +54,8 @@ class e107plugin
|
||||
'e_cron',
|
||||
'e_mailout',
|
||||
'e_sitelink',
|
||||
'e_tohtml'
|
||||
'e_tohtml',
|
||||
'e_featurebox'
|
||||
);
|
||||
|
||||
// List of all plugin variables which need to be checked - install required if one or more set and non-empty
|
||||
@@ -1293,6 +1294,11 @@ class e107plugin
|
||||
{
|
||||
$this->XmlBBcodes($function, $plug_vars);
|
||||
}
|
||||
|
||||
if (varset($plug_vars['mediaCategories']))
|
||||
{
|
||||
$this->XmlMediaCategories($function, $plug_vars);
|
||||
}
|
||||
|
||||
$this->manage_icons($this->plugFolder, $function);
|
||||
|
||||
@@ -1499,7 +1505,7 @@ class e107plugin
|
||||
|
||||
{
|
||||
$status = ($this->manage_link('add', $url, $linkName, $perm)) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
|
||||
$mes->add("Adding Link: {$linkName} with url [{$url}] and perm {$perm} ", $status);
|
||||
$mes->add("Adding Link: {$linkName} with url [{$url}] and perm {$perm} ", $status); //TODO LAN
|
||||
}
|
||||
|
||||
if ($function == 'upgrade' && $remove) //remove inactive links on upgrade
|
||||
@@ -1539,6 +1545,67 @@ class e107plugin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Only 1 category per file-type allowed. ie. 1 for images, 1 for files.
|
||||
function XmlMediaCategories($function, $tag)
|
||||
{
|
||||
$mes = e107::getMessage();
|
||||
// print_a($tag);
|
||||
|
||||
$folder = $tag['folder'];
|
||||
$prevType = "";
|
||||
|
||||
|
||||
//print_a($tag);
|
||||
switch ($function)
|
||||
{
|
||||
case 'install':
|
||||
$c = 1;
|
||||
foreach($tag['mediaCategories']['category'] as $v)
|
||||
{
|
||||
$type = $v['@attributes']['type'];
|
||||
|
||||
if($type != 'image' && $type !='file')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if($c == 3 || ($prevType == $type))
|
||||
{
|
||||
$mes->addDebug("Only 2 Media Categories are permitted during install. One for images and one for files.");
|
||||
break;
|
||||
}
|
||||
|
||||
$prevType = $type;
|
||||
|
||||
$data['owner'] = $folder;
|
||||
$data['category'] = $folder."_".$c;
|
||||
$data['title'] = $v['@value'];
|
||||
// $data['type'] = $v['@attributes']['type']; //TODO
|
||||
$data['class'] = 253;
|
||||
$status = e107::getMedia()->createCategory($data) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
|
||||
$mes->add("Adding Media Category: {$data['category']}", $status);
|
||||
|
||||
$c++;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'uninstall': // Probably best to leave well alone
|
||||
$status = e107::getMedia()->deleteAllCategories($folder)? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
|
||||
$mes->add("Deleting All Media Categories owned by : {$folder}", $status);
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -15,6 +15,9 @@
|
||||
</siteLinks>
|
||||
<mainPrefs>
|
||||
</mainPrefs>
|
||||
<mediaCategories>
|
||||
<category type="image">Gallery 1</category>
|
||||
</mediaCategories>
|
||||
<pluginPrefs>
|
||||
<pref name="popup_w">800</pref>
|
||||
<pref name="popup_h">800</pref>
|
||||
|
@@ -313,14 +313,10 @@ class wysiwyg
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if(ADMIN)
|
||||
{
|
||||
$this->config['external_link_list_url'] = e_PLUGIN_ABS."tiny_mce/filelist.php";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user