mirror of
https://github.com/e107inc/e107.git
synced 2025-04-20 20:51:53 +02:00
IN PROGRESS - task EONE-10: System thumbnails
- media manager now uses thumb.php - form handler uses thumb.php (UI) when type is image and parameter thumb is passed - minor issues fixed - thumbUrl() method added (Parser, for now)
This commit is contained in:
parent
b1b33d1870
commit
2a0529f631
@ -8,10 +8,8 @@
|
||||
*
|
||||
* Cache Administration Area
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_admin/cache.php,v $
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Author$
|
||||
* $URL$
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
require_once("../class2.php");
|
||||
|
@ -8,10 +8,8 @@
|
||||
*
|
||||
* Image Administration Area
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_admin/image.php,v $
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Author$
|
||||
* $URL$
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
require_once("../class2.php");
|
||||
@ -39,7 +37,7 @@ $e_sub_cat = 'image';
|
||||
require_once(e_HANDLER."userclass_class.php");
|
||||
require_once(e_HANDLER."message_handler.php");
|
||||
// $frm = new e_form(); //new form handler
|
||||
$emessage = &eMessage::getInstance();
|
||||
$emessage = eMessage::getInstance();
|
||||
|
||||
class media_admin extends e_admin_dispatcher
|
||||
{
|
||||
@ -56,8 +54,8 @@ class media_admin extends e_admin_dispatcher
|
||||
'path' => null,
|
||||
'ui' => 'faq_cat_form_ui',
|
||||
'uipath' => null
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
protected $adminMenu = array(
|
||||
@ -68,11 +66,11 @@ class media_admin extends e_admin_dispatcher
|
||||
// 'cat/create' => array('caption'=> "Create Category", 'perm' => 'A'),
|
||||
'main/icons' => array('caption'=> IMALAN_71, 'perm' => 'A'),
|
||||
'main/settings' => array('caption'=> LAN_PREFS, 'perm' => 'A'),
|
||||
|
||||
'main/avatar' => array('caption'=> IMALAN_23, 'perm' => 'A')
|
||||
|
||||
'main/avatar' => array('caption'=> IMALAN_23, 'perm' => 'A')
|
||||
);
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
$var['main']['text'] = IMALAN_7;
|
||||
$var['main']['link'] = e_SELF;
|
||||
|
||||
@ -85,38 +83,38 @@ class media_admin extends e_admin_dispatcher
|
||||
|
||||
$var['editor']['text'] = "Image Manipulation (future release)";
|
||||
$var['editor']['link'] = e_SELF."?editor";*/
|
||||
|
||||
|
||||
|
||||
|
||||
protected $adminMenuAliases = array(
|
||||
'main/edit' => 'main/list'
|
||||
);
|
||||
|
||||
'main/edit' => 'main/list'
|
||||
);
|
||||
|
||||
protected $menuTitle = LAN_MEDIAMANAGER;
|
||||
|
||||
|
||||
}
|
||||
|
||||
class faq_cat_ui extends e_admin_ui
|
||||
{
|
||||
{
|
||||
protected $pluginTitle = 'Media Categories';
|
||||
protected $pluginName = 'core';
|
||||
protected $table = "core_media_cat";
|
||||
protected $pid = "media_cat_id";
|
||||
protected $perPage = 0; //no limit
|
||||
protected $batchDelete = false;
|
||||
// protected $listQry = "SELECT * FROM #faq_info"; // without any Order or Limit.
|
||||
// protected $listQry = "SELECT * FROM #faq_info"; // without any Order or Limit.
|
||||
// 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_nick' => array('title'=> "Nickname", 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>TRUE),
|
||||
'media_cat_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>TRUE),
|
||||
'media_cat_id' => array('title'=> LAN_ID, 'type' => 'number', 'width' =>'5%', 'forced'=> TRUE, 'readonly'=>TRUE),
|
||||
'media_cat_nick' => array('title'=> "Nickname", 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>TRUE),
|
||||
'media_cat_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>TRUE),
|
||||
'media_cat_diz' => array('title'=> LAN_DESCRIPTION, 'type' => 'bbarea', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1','readonly'=>TRUE), // Display name
|
||||
'media_cat_class' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'width' => 'auto', 'data' => 'int'),
|
||||
// 'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'width' => '10%', 'forced'=>TRUE, 'thclass' => 'center last', 'class' => 'center')
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
/**
|
||||
* Get FAQ Category data
|
||||
*
|
||||
@ -128,14 +126,14 @@ class faq_cat_ui extends e_admin_ui
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
// TODO - catlist combo without current cat ID in write mode, parents only for batch/filter
|
||||
// TODO - catlist combo without current cat ID in write mode, parents only for batch/filter
|
||||
// Get UI instance
|
||||
$controller = $this->getController();
|
||||
switch($mode)
|
||||
@ -143,27 +141,27 @@ class faq_cat_form_ui extends e_admin_form_ui
|
||||
case 'read':
|
||||
return e107::getParser()->toHTML($controller->getFaqCategoryTree($curVal), false, 'TITLE');
|
||||
break;
|
||||
|
||||
|
||||
case 'write':
|
||||
return $this->selectbox('faq_info_parent', $controller->getFaqCategoryTree(), $curVal);
|
||||
break;
|
||||
|
||||
|
||||
case 'filter':
|
||||
case 'batch':
|
||||
return $controller->getFaqCategoryTree();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
class media_form_ui extends e_admin_form_ui
|
||||
{
|
||||
|
||||
|
||||
private $cats = array();
|
||||
|
||||
|
||||
function init()
|
||||
{
|
||||
$sql = e107::getDb();
|
||||
@ -172,30 +170,30 @@ class media_form_ui extends e_admin_form_ui
|
||||
while($row = $sql->db_Fetch())
|
||||
{
|
||||
$cat = $row['media_cat_nick'];
|
||||
$this->cats[$cat] = $row['media_cat_title'];
|
||||
$this->cats[$cat] = $row['media_cat_title'];
|
||||
}
|
||||
asort($this->cats);
|
||||
}
|
||||
|
||||
function media_category($curVal,$mode) // not really necessary since we can use 'dropdown' - but just an example of a custom function.
|
||||
|
||||
function media_category($curVal,$mode) // not really necessary since we can use 'dropdown' - but just an example of a custom function.
|
||||
{
|
||||
|
||||
|
||||
if($mode == 'read')
|
||||
{
|
||||
return $this->cats[$curVal];
|
||||
}
|
||||
|
||||
|
||||
if($mode == 'batch') // Custom Batch List for release_type
|
||||
{
|
||||
return $this->cats;
|
||||
return $this->cats;
|
||||
}
|
||||
|
||||
|
||||
if($mode == 'filter') // Custom Filter List for release_type
|
||||
{
|
||||
return $this->cats;
|
||||
return $this->cats;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$text = "<select class='tbox>' name='media_category' >";
|
||||
foreach($this->cats as $key=>$val)
|
||||
{
|
||||
@ -209,51 +207,51 @@ class media_form_ui extends e_admin_form_ui
|
||||
|
||||
class media_admin_ui extends e_admin_ui
|
||||
{
|
||||
|
||||
protected $pluginTitle = LAN_MEDIAMANAGER;
|
||||
|
||||
protected $pluginTitle = LAN_MEDIAMANAGER;
|
||||
protected $pluginName = 'core';
|
||||
protected $table = "core_media";
|
||||
|
||||
// protected $listQry = "SELECT * FROM #core_media"; // without any Order or Limit.
|
||||
|
||||
|
||||
// protected $listQry = "SELECT * FROM #core_media"; // without any Order or Limit.
|
||||
|
||||
// //protected $editQry = "SELECT * FROM #comments WHERE comment_id = {ID}";
|
||||
|
||||
|
||||
// protected $tableJoin = array(
|
||||
// 'u.user' => array('leftField' => 'media_author', 'rightField' => 'user_id', 'fields' => 'user_id,user_loginname,user_name')
|
||||
// );
|
||||
|
||||
|
||||
protected $pid = "media_id";
|
||||
protected $perPage = 10;
|
||||
protected $batchDelete = true;
|
||||
|
||||
|
||||
//TODO - finish 'user' type, set 'data' to all editable fields, set 'noedit' for all non-editable fields
|
||||
/*
|
||||
* We need a column with a preview that is generated from the path of another field.
|
||||
* ie. the preview column should show a thumbnail which is generated from the media_url column.
|
||||
* It needs to also take into consideration the type of media (image, video etc) which comes from another field.
|
||||
* We need a column with a preview that is generated from the path of another field.
|
||||
* ie. the preview column should show a thumbnail which is generated from the media_url column.
|
||||
* It needs to also take into consideration the type of media (image, video etc) which comes from another field.
|
||||
*/
|
||||
|
||||
|
||||
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=100', 'width' => 'auto','readonly'=>TRUE),
|
||||
|
||||
// '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_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_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_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_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'),
|
||||
'media_author' => array('title'=> LAN_USER, 'type' => 'user', 'data'=> 'int', 'width' => 'auto', 'thclass' => 'center', 'class'=>'center', 'filter' => true, 'batch' => true, 'noedit'=>TRUE ),
|
||||
'media_author' => array('title'=> LAN_USER, 'type' => 'user', 'data'=> 'int', 'width' => 'auto', 'thclass' => 'center', 'class'=>'center', 'filter' => true, 'batch' => true, 'noedit'=>TRUE ),
|
||||
'media_datestamp' => array('title'=> LAN_DATESTAMP, 'type' => 'datestamp', 'data'=> 'int', 'width' => '10%', 'noedit'=>TRUE), // User date
|
||||
'media_size' => array('title'=> "Size", 'type' => 'number', 'data'=> 'int', 'width' => 'auto', 'noedit'=>TRUE),
|
||||
'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_size' => array('title'=> "Size", 'type' => 'number', 'data'=> 'int', 'width' => 'auto', 'noedit'=>TRUE),
|
||||
'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 ),
|
||||
|
||||
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'data'=> null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center')
|
||||
);
|
||||
|
||||
@ -267,34 +265,34 @@ class media_admin_ui extends e_admin_ui
|
||||
'other' => 'files'
|
||||
);
|
||||
// protected $fieldpref = array('checkboxes','media_url', 'media_id', 'media_thumb', 'media_title', 'media_caption', 'media_description', 'media_category', 'media_datestamp','media_userclass', 'options');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
protected $prefs = array(
|
||||
protected $prefs = array(
|
||||
'pref_type' => array('title'=> 'type', 'type'=>'text'),
|
||||
'pref_folder' => array('title'=> 'folder', 'type' => 'boolean'),
|
||||
'pref_name' => array('title'=> 'name', 'type' => 'text')
|
||||
'pref_folder' => array('title'=> 'folder', 'type' => 'boolean'),
|
||||
'pref_name' => array('title'=> 'name', 'type' => 'text')
|
||||
);*/
|
||||
|
||||
protected $cats = array();
|
||||
|
||||
function init()
|
||||
{
|
||||
|
||||
//FIXME - would prefer not to have to read this twice on the same page.
|
||||
|
||||
//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");
|
||||
while($row = $sql->db_Fetch())
|
||||
{
|
||||
$cat = $row['media_cat_nick'];
|
||||
$this->cats[$cat] = $row['media_cat_title'];
|
||||
$this->cats[$cat] = $row['media_cat_title'];
|
||||
}
|
||||
asort($this->cats);
|
||||
|
||||
|
||||
|
||||
|
||||
if(varset($_POST['batch_import_selected']))
|
||||
{
|
||||
$this->batchImport();
|
||||
@ -304,26 +302,26 @@ class media_admin_ui extends e_admin_ui
|
||||
|
||||
function importPage()
|
||||
{
|
||||
$this->batchImportForm();
|
||||
$this->batchImportForm();
|
||||
}
|
||||
|
||||
|
||||
function settingsPage()
|
||||
{
|
||||
main_config();
|
||||
}
|
||||
|
||||
|
||||
function avatarPage()
|
||||
{
|
||||
show_avatars();
|
||||
}
|
||||
|
||||
|
||||
function iconsPage()
|
||||
{
|
||||
$this->icon_editor();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Invoked just before item create event
|
||||
* @return array
|
||||
@ -337,9 +335,9 @@ class media_admin_ui extends e_admin_ui
|
||||
$this->getModel()->setDataFields($dataFields);
|
||||
return $this->observeUploaded($new_data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Same as beforeCreate() but invoked on edit
|
||||
* Same as beforeCreate() but invoked on edit
|
||||
* @return TBD
|
||||
*/
|
||||
public function beforeUpdate($new_data, $old_data, $id)
|
||||
@ -347,122 +345,122 @@ class media_admin_ui extends e_admin_ui
|
||||
// return data to be merged with posted model data
|
||||
return $this->observeUploaded($new_data);
|
||||
}
|
||||
|
||||
|
||||
// XXX - strict mysql error on Create without UPLOAD!
|
||||
function observeUploaded($new_data)
|
||||
{
|
||||
$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($upload['error']))
|
||||
{
|
||||
{
|
||||
$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.
|
||||
|
||||
$upload_data = array( // not saved if 'noedit' is active.
|
||||
'media_type' => $upload['type'],
|
||||
'media_datestamp' => time(),
|
||||
'media_url' => "{e_MEDIA}".$newpath,
|
||||
'media_datestamp' => time(),
|
||||
'media_url' => "{e_MEDIA}".$newpath,
|
||||
'media_size' => $upload['size'],
|
||||
'media_author' => USERID,
|
||||
'media_usedby' => '',
|
||||
'media_author' => USERID,
|
||||
'media_usedby' => '',
|
||||
'media_tags' => '',
|
||||
'media_dimensions' => $info['img-width']." x ".$info['img-height']
|
||||
);
|
||||
|
||||
|
||||
|
||||
if(!varset($new_data['media_name']))
|
||||
{
|
||||
$upload_data['media_name'] = $upload['name'];
|
||||
}
|
||||
|
||||
|
||||
// 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 FALSE;
|
||||
};
|
||||
return $upload_data;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function beforeDelete($data, $id) // call before 'delete' is executed. - return false to prevent delete execution (e.g. some dependencies check)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function afterDelete($deleted_data, $id) // call after 'delete' is successfully executed. - delete the file with the db record (optional pref)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function getPath($mime)
|
||||
{
|
||||
$mes = e107::getMessage();
|
||||
|
||||
|
||||
list($pmime,$tmp) = explode('/',$mime);
|
||||
|
||||
|
||||
if(!vartrue($this->mimePaths[$pmime]))
|
||||
{
|
||||
{
|
||||
$mes->add("Couldn't detected mime-type($type). Upload failed.", E_MESSAGE_ERROR);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$dir = $this->mimePaths[$pmime]."/".date("Y-m");
|
||||
|
||||
$dir = $this->mimePaths[$pmime]."/".date("Y-m");
|
||||
|
||||
if(!is_dir(e_MEDIA.$dir))
|
||||
{
|
||||
if(!mkdir(e_MEDIA.$dir, 0755))
|
||||
{
|
||||
$mes->add("Couldn't create folder ($dir).", E_MESSAGE_ERROR);
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
};
|
||||
}
|
||||
return $dir;
|
||||
return $dir;
|
||||
}
|
||||
|
||||
|
||||
function batchImportForm()
|
||||
{
|
||||
$frm = e107::getForm();
|
||||
$mes = e107::getMessage();
|
||||
$fl = e107::getFile();
|
||||
|
||||
|
||||
$fl->setFileInfo('all');
|
||||
$files = $fl->get_files(e_MEDIA."temp/");
|
||||
|
||||
|
||||
//TODO Detect XML file, and if found - read that instead of the directory.
|
||||
|
||||
if(!vartrue($_POST['batch_import_selected']))
|
||||
{
|
||||
$mes->add("Scanning Media in folder: ".e_MEDIA."temp/", E_MESSAGE_INFO);
|
||||
$mes->add("Scanning Media in folder: ".e_MEDIA."temp/", E_MESSAGE_INFO);
|
||||
}
|
||||
|
||||
if(!count($files))
|
||||
{
|
||||
$mes->add("No media Found!", E_MESSAGE_INFO);
|
||||
return;
|
||||
$mes->add("No media Found!", E_MESSAGE_INFO);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$text = "
|
||||
<form method='post' action='".e_SELF."?".e_QUERY."' id='batch_import'>
|
||||
<fieldset id='core-mediamanager-batch'>
|
||||
@ -479,7 +477,7 @@ class media_admin_ui extends e_admin_ui
|
||||
<th class='center'>Checkbox</th>
|
||||
<th class='center' style='width:50px'>Preview</th>
|
||||
<th class='center'>".LAN_NAME."</th>
|
||||
<th>Mime Type</th>
|
||||
<th>Mime Type</th>
|
||||
<th>File Size</th>
|
||||
<th>".LAN_DATESTAMP."</th>
|
||||
<th class='center last'>Dimensions</th>
|
||||
@ -497,12 +495,12 @@ class media_admin_ui extends e_admin_ui
|
||||
<td>".$f['mime']."</td>
|
||||
<td>".$f['fsize']."</td>
|
||||
<td>".e107::getDateConvert()->convert_date($f['modified'])."</td>
|
||||
<td class='center last'>".$f['img-width']." x ".$f['img-height']."</td>
|
||||
<td class='center last'>".$f['img-width']." x ".$f['img-height']."</td>
|
||||
</tr>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$text .= "
|
||||
</tbody>
|
||||
</table>
|
||||
@ -514,63 +512,63 @@ class media_admin_ui extends e_admin_ui
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
";
|
||||
|
||||
|
||||
|
||||
|
||||
echo $mes->render().$text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function batchImport()
|
||||
{
|
||||
$fl = e107::getFile();
|
||||
$mes = e107::getMessage();
|
||||
$sql = e107::getDb();
|
||||
|
||||
|
||||
|
||||
|
||||
foreach($_POST['batch_selected'] as $file)
|
||||
{
|
||||
$oldpath = "temp/".$file;
|
||||
$f = $fl->get_file_info(e_MEDIA.$oldpath);
|
||||
$newpath = $this->getPath($f['mime']).'/'.$file;
|
||||
|
||||
|
||||
$f['fname'] = $file;
|
||||
|
||||
if(rename(e_MEDIA.$oldpath,e_MEDIA.$newpath))
|
||||
{
|
||||
$insert = array(
|
||||
'media_caption' => $f['fname'],
|
||||
'media_description' => '',
|
||||
'media_category' => $_POST['batch_category'],
|
||||
'media_datestamp' => $f['modified'],
|
||||
'media_url' => "{e_MEDIA}".$newpath,
|
||||
'media_userclass' => 0,
|
||||
'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_caption' => $f['fname'],
|
||||
'media_description' => '',
|
||||
'media_category' => $_POST['batch_category'],
|
||||
'media_datestamp' => $f['modified'],
|
||||
'media_url' => "{e_MEDIA}".$newpath,
|
||||
'media_userclass' => 0,
|
||||
'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']
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
if($sql->db_Insert("core_media",$insert))
|
||||
{
|
||||
$mes->add("Importing Media: ".$f['fname'], E_MESSAGE_SUCCESS);
|
||||
$mes->add("Importing Media: ".$f['fname'], E_MESSAGE_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
rename(e_MEDIA.$newpath,e_MEDIA.$oldpath); //move it back.
|
||||
rename(e_MEDIA.$newpath,e_MEDIA.$oldpath); //move it back.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function preview($f)
|
||||
{
|
||||
list($type,$tmp) = explode("/",$f['mime']);
|
||||
@ -581,22 +579,22 @@ class media_admin_ui extends e_admin_ui
|
||||
}
|
||||
else
|
||||
{
|
||||
return; //TODO generic icon/image for no preview.
|
||||
return; //TODO generic icon/image for no preview.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function icon_editor()
|
||||
{
|
||||
global $iconpool, $e107;
|
||||
|
||||
|
||||
$ns = e107::getRender();
|
||||
$tp = e107::getParser();
|
||||
$frm = e107::getForm();
|
||||
$mes = e107::getMessage();
|
||||
|
||||
|
||||
ksort($iconpool);
|
||||
|
||||
|
||||
$text = "
|
||||
<form method='post' action='".e_SELF."?".e_QUERY."' id='icon_edit'>
|
||||
<fieldset id='core-imagemanager-icons'>
|
||||
@ -619,7 +617,7 @@ class media_admin_ui extends e_admin_ui
|
||||
<tbody>
|
||||
";
|
||||
$tmp = array(16, 32, 48, 64, 128);
|
||||
|
||||
|
||||
foreach($iconpool as $key => $val)
|
||||
{
|
||||
$tmp1 = array();
|
||||
@ -628,7 +626,7 @@ class media_admin_ui extends e_admin_ui
|
||||
$filepath = $icon;
|
||||
$filepath_abs = $tp->replaceConstants($icon);
|
||||
$icon_file = basename($filepath_abs);
|
||||
|
||||
|
||||
$str = "<img class='icon picker list%%size%%' src='{$filepath_abs}' alt='{$icon_file}' />";
|
||||
foreach ($tmp as $isize)
|
||||
{
|
||||
@ -640,12 +638,12 @@ class media_admin_ui extends e_admin_ui
|
||||
}
|
||||
$tmp1['other'] = varset($tmp1['other']).$str;//other
|
||||
}
|
||||
|
||||
|
||||
$ptext = "<div class='field-spacer iconeditor'>".str_replace('%%size%%', '', implode('</div><div class="field-spacer iconeditor">', $tmp1))."</div>";
|
||||
|
||||
|
||||
// $ptext = (is_array($val)) ? "<pre>".print_r($val, TRUE)."</pre>" : htmlspecialchars($val, ENT_QUOTES, CHARSET);
|
||||
// $ptext = $e107->tp->textclean($ptext, 80);
|
||||
|
||||
|
||||
$text .= "
|
||||
<tr>
|
||||
<td class='center autocheck e-pointer'>".$frm->checkbox("delpref2[$key]", 1)."</td>
|
||||
@ -655,7 +653,7 @@ class media_admin_ui extends e_admin_ui
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
|
||||
|
||||
$text .= "
|
||||
</tbody>
|
||||
</table>
|
||||
@ -664,15 +662,15 @@ class media_admin_ui extends e_admin_ui
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
";
|
||||
//$text .= "<div style='text-align:center'><a href='".e_SELF."'>".DBLAN_13."</a></div>\n";
|
||||
// $ns->tablerender(LAN_MEDIAMANAGER." :: ".IMALAN_71, $mes->render().$text);
|
||||
|
||||
|
||||
echo $mes->render().$text;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -694,7 +692,7 @@ e107::getAdminUI()->runPage();
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$action = e_QUERY;
|
||||
@ -900,7 +898,7 @@ if (isset($_POST['update_options']))
|
||||
function show_avatars()
|
||||
{
|
||||
global $e107, $pref;
|
||||
|
||||
|
||||
$ns = e107::getRender();
|
||||
$sql = e107::getDb();
|
||||
$frm = e107::getForm();
|
||||
@ -1195,7 +1193,7 @@ if (isset($_POST['check_avatar_sizes']))
|
||||
function main_config()
|
||||
{
|
||||
global $pref;
|
||||
|
||||
|
||||
$frm = e107::getForm();
|
||||
$tp = e107::getParser();
|
||||
$sql = e107::getDb();
|
||||
|
@ -14,8 +14,9 @@
|
||||
|
||||
/**
|
||||
* @package e107
|
||||
* @subpackage shortcodes|admin|user|e107_handler|bbcodes
|
||||
* @subpackage e107_handler
|
||||
* @version $Id$
|
||||
* @author secretr
|
||||
*
|
||||
* Simple, quick and efective way of testing performance of parts of your code
|
||||
* Example:
|
||||
@ -28,7 +29,7 @@
|
||||
* // Do something, e.g. loop 1000000 times
|
||||
*
|
||||
* // stop timer and check your e_LOG folder
|
||||
* $bench->end()->$bench->('myevent');
|
||||
* $bench->end()->logResult('myevent');
|
||||
* //OR print out the result (don't forget to stop the timer if used without the above line!
|
||||
* $bench->printResult();
|
||||
* </code>
|
||||
|
@ -1612,6 +1612,28 @@ class e_parse
|
||||
return $text;
|
||||
}
|
||||
|
||||
public function thumbUrl($url, $options = array(), $raw = false, $full = false)
|
||||
{
|
||||
if(!is_array($options))
|
||||
{
|
||||
parse_str($options, $options);
|
||||
}
|
||||
|
||||
if($raw) $url = $this->createConstants($url, 'mix');
|
||||
|
||||
$thurl = ($full ? SITEURL : e_HTTP).'thumb.php?src='.$url.'&';
|
||||
if(vartrue($options['aw']))
|
||||
{
|
||||
$thurl .= 'aw='.intval($options['aw']).'&ah='.(vartrue($options['ah']) ? intval($options['ah']) : intval($options['aw']));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!vartrue($options['w'])) $options['w'] = 100;
|
||||
$thurl .= 'aw='.intval($options['w']).'&ah='.(vartrue($options['h']) ? intval($options['h']) : intval($options['w']));
|
||||
}
|
||||
|
||||
return $thurl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace e107 path constants
|
||||
@ -1687,7 +1709,6 @@ class e_parse
|
||||
"{e_THEME}",
|
||||
//,"{e_DOWNLOAD}"
|
||||
"{e_HANDLER}",
|
||||
//FIXME need another name
|
||||
"{e_MEDIA}"
|
||||
);
|
||||
|
||||
|
@ -1226,10 +1226,31 @@ class e_form
|
||||
case 'image': //TODO - thumb, js tooltip...
|
||||
if($value)
|
||||
{
|
||||
$src = $tp->replaceConstants(vartrue($parms['pre']).$value, 'abs');
|
||||
$alt = $src; //basename($value);
|
||||
$ttl = vartrue($parms['thumb']) ? '<img src="'.$src.'" alt="'.$alt.'" style="width: '.(is_numeric($parms['thumb']) ? $parms['thumb'] : 80).'px" />' : vartrue($parms['title'], 'LAN_PREVIEW');
|
||||
$value = '<a href="'.$src.'" class="e-image-preview" title="'.$alt.'" rel="external">'.defset($ttl, $ttl).'</a>';
|
||||
if(vartrue($parms['thumb']))
|
||||
{
|
||||
$src = $tp->replaceConstants(vartrue($parms['pre']).$value, 'abs');
|
||||
$thumb = $parms['thumb'];
|
||||
$thparms = array();
|
||||
if(is_numeric($thumb) && '1' != $thumb)
|
||||
{
|
||||
$thparms['w'] = intval($thumb);
|
||||
}
|
||||
elseif(vartrue($parms['thumb_aw']))
|
||||
{
|
||||
$thparms['aw'] = intval($parms['thumb_aw']);
|
||||
}
|
||||
$thsrc = $tp->thumbUrl(vartrue($parms['pre']).$value, $thparms, varset($parms['thumb_urlraw']));
|
||||
$alt = $src;
|
||||
$ttl = '<img src="'.$thsrc.'" alt="'.$alt.'" class="e-thumb" />';
|
||||
$value = '<a href="'.$src.'" class="e-image-preview" title="'.$alt.'" rel="external">'.$ttl.'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$src = $tp->replaceConstants(vartrue($parms['pre']).$value, 'abs');
|
||||
$alt = $src; //basename($value);
|
||||
$ttl = vartrue($parms['title'], 'LAN_PREVIEW');
|
||||
$value = '<a href="'.$src.'" class="e-image-preview" title="'.$alt.'" rel="external">'.defset($ttl, $ttl).'</a>';
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -8,10 +8,8 @@
|
||||
*
|
||||
* Release Plugin Administration UI
|
||||
*
|
||||
* $Source: /cvsroot/e107/e107_0.8/e107_plugins/release/includes/admin.php,v $
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Author$
|
||||
* $URL$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
//require_once(e_HANDLER.'admin_handler.php'); - autoloaded - see class2.php __autoload()
|
||||
@ -26,9 +24,9 @@ class plugin_release_admin extends e_admin_dispatcher
|
||||
* @var array
|
||||
*/
|
||||
protected $modes = array(
|
||||
'main' => array('controller' => 'plugin_release_admin_ui', 'path' => null, 'ui' => 'plugin_release_admin_form_ui', 'uipath' => null)
|
||||
);
|
||||
|
||||
'main' => array('controller' => 'plugin_release_admin_ui', 'path' => null, 'ui' => 'plugin_release_admin_form_ui', 'uipath' => null)
|
||||
);
|
||||
|
||||
/* Both are optional
|
||||
protected $defaultMode = null;
|
||||
protected $defaultAction = null;
|
||||
@ -43,19 +41,19 @@ class plugin_release_admin extends e_admin_dispatcher
|
||||
'main/list' => array('caption'=> 'Manage', 'perm' => '0'),
|
||||
'main/create' => array('caption'=> LAN_CREATE, 'perm' => '0'),
|
||||
'main/prefs' => array('caption'=> 'Settings', 'perm' => '0'),
|
||||
'main/custom' => array('caption'=> 'Custom Page', 'perm' => '0')
|
||||
'main/custom' => array('caption'=> 'Custom Page', 'perm' => '0')
|
||||
);
|
||||
|
||||
/**
|
||||
* Optional, mode/action aliases, related with 'selected' menu CSS class
|
||||
* Optional, mode/action aliases, related with 'selected' menu CSS class
|
||||
* Format: 'MODE/ACTION' => 'MODE ALIAS/ACTION ALIAS';
|
||||
* This will mark active main/list menu item, when current page is main/edit
|
||||
* @var array
|
||||
*/
|
||||
protected $adminMenuAliases = array(
|
||||
'main/edit' => 'main/list'
|
||||
);
|
||||
|
||||
'main/edit' => 'main/list'
|
||||
);
|
||||
|
||||
/**
|
||||
* Navigation menu title
|
||||
* @var string
|
||||
@ -67,180 +65,182 @@ class plugin_release_admin_ui extends e_admin_ui
|
||||
{
|
||||
// required
|
||||
protected $pluginTitle = "e107 Release";
|
||||
|
||||
|
||||
/**
|
||||
* plugin name or 'core'
|
||||
* IMPORTANT: should be 'core' for non-plugin areas because this
|
||||
* value defines what CONFIG will be used. However, I think this should be changed
|
||||
* very soon (awaiting discussion with Cam)
|
||||
* IMPORTANT: should be 'core' for non-plugin areas because this
|
||||
* value defines what CONFIG will be used. However, I think this should be changed
|
||||
* very soon (awaiting discussion with Cam)
|
||||
* Maybe we need something like $prefs['core'], $prefs['release'] ... multiple getConfig support?
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $pluginName = 'release';
|
||||
|
||||
|
||||
/**
|
||||
* DB Table, table alias is supported
|
||||
* Example: 'r.release'
|
||||
* @var string
|
||||
*/
|
||||
protected $table = "release";
|
||||
|
||||
|
||||
/**
|
||||
* If present this array will be used to build your list query
|
||||
* You can link fileds from $field array with 'table' parameter, which should equal to a key (table) from this array
|
||||
* 'leftField', 'rightField' and 'fields' attributes here are required, the rest is optional
|
||||
* Table alias is supported
|
||||
* Note:
|
||||
* Note:
|
||||
* - 'leftTable' could contain only table alias
|
||||
* - 'leftField' and 'rightField' shouldn't contain table aliases, they will be auto-added
|
||||
* - 'whereJoin' and 'where' should contain table aliases e.g. 'whereJoin' => 'AND u.user_ban=0'
|
||||
*
|
||||
*
|
||||
* @var array [optional] table_name => array join parameters
|
||||
*/
|
||||
protected $tableJoin = array(
|
||||
//'u.user' => array('leftField' => 'comment_author_id', 'rightField' => 'user_id', 'fields' => '*'/*, 'leftTable' => '', 'joinType' => 'LEFT JOIN', 'whereJoin' => '', 'where' => ''*/)
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* This is only needed if you need to JOIN tables AND don't wanna use $tableJoin
|
||||
* Write your list query without any Order or Limit.
|
||||
* NOTE: $tableJoin array is recommended join method
|
||||
*
|
||||
* Write your list query without any Order or Limit.
|
||||
* NOTE: $tableJoin array is recommended join method
|
||||
*
|
||||
* @var string [optional]
|
||||
*/
|
||||
protected $listQry = "";
|
||||
//
|
||||
|
||||
protected $listQry = "";
|
||||
//
|
||||
|
||||
// optional - required only in case of e.g. tables JOIN. This also could be done with custom model (set it in init())
|
||||
// NOT NEEDED ANYMORE!!!
|
||||
//protected $editQry = "SELECT * FROM #release WHERE release_id = {ID}";
|
||||
|
||||
|
||||
// required - if no custom model is set in init() (primary id)
|
||||
protected $pid = "release_id";
|
||||
|
||||
// optional
|
||||
|
||||
// optional
|
||||
protected $perPage = 20;
|
||||
|
||||
|
||||
// default - true - TODO - move to displaySettings
|
||||
protected $batchDelete = true;
|
||||
|
||||
|
||||
// UNDER CONSTRUCTION
|
||||
protected $displaySettings = array();
|
||||
|
||||
|
||||
// UNDER CONSTRUCTION
|
||||
protected $disallowPages = array('main/create', 'main/prefs');
|
||||
|
||||
//TODO change the release_url type back to URL before release.
|
||||
|
||||
//TODO change the release_url type back to URL before release.
|
||||
// required
|
||||
/**
|
||||
* (use this as starting point for wiki documentation)
|
||||
* $fields format (string) $field_name => (array) $attributes
|
||||
*
|
||||
*
|
||||
* $field_name format:
|
||||
* 'table_alias_or_name.field_name.field_alias' (if JOIN support is needed) OR just 'field_name'
|
||||
* NOTE: Keep in mind the count of exploded data can be 1 or 3!!! This means if you wanna give alias
|
||||
* on main table field you can't omit the table (first key), alternative is just '.' e.g. '.field_name.field_alias'
|
||||
*
|
||||
*
|
||||
* $attributes format:
|
||||
* - title (string) Human readable field title, constant name will be accpeted as well (multi-language support
|
||||
*
|
||||
*
|
||||
* - type (string) null (means system), number, text, dropdown, url, image, icon, datestamp, userclass, userclasses, user[_name|_loginname|_login|_customtitle|_email],
|
||||
* boolean, method, ip
|
||||
* full/most recent reference list - e_form::renderTableRow(), e_form::renderElement(), e_admin_form_ui::renderBatchFilter()
|
||||
* for list of possible read/writeParms per type see below
|
||||
*
|
||||
*
|
||||
* - data (string) Data type, one of the following: int, integer, string, str, float, bool, boolean, model, null
|
||||
* Default is 'str'
|
||||
* Used only if $dataFields is not set
|
||||
* full/most recent reference list - e_admin_model::sanitize(), db::_getFieldValue()
|
||||
* - dataPath (string) - xpath like path to the model/posted value. Example: 'dataPath' => 'prefix/mykey' will result in $_POST['prefix']['mykey']
|
||||
* - dataPath (string) - xpath like path to the model/posted value. Example: 'dataPath' => 'prefix/mykey' will result in $_POST['prefix']['mykey']
|
||||
* - primary (boolean) primary field (obsolete, $pid is now used)
|
||||
*
|
||||
*
|
||||
* - help (string) edit/create table - inline help, constant name will be accpeted as well, optional
|
||||
* - note (string) edit/create table - text shown below the field title (left column), constant name will be accpeted as well, optional
|
||||
*
|
||||
*
|
||||
* - validate (boolean|string) any of accepted validation types (see e_validator::$_required_rules), true == 'required'
|
||||
* - rule (string) condition for chosen above validation type (see e_validator::$_required_rules), not required for all types
|
||||
* - error (string) Human readable error message (validation failure), constant name will be accepted as well, optional
|
||||
*
|
||||
*
|
||||
* - batch (boolean) list table - add current field to batch actions, in use only for boolean, dropdown, datestamp, userclass, method field types
|
||||
* NOTE: batch may accept string values in the future...
|
||||
* full/most recent reference type list - e_admin_form_ui::renderBatchFilter()
|
||||
*
|
||||
*
|
||||
* - filter (boolean) list table - add current field to filter actions, rest is same as batch
|
||||
*
|
||||
*
|
||||
* - forced (boolean) list table - forced fields are always shown in list table
|
||||
* - nolist (boolean) list table - don't show in column choice list
|
||||
* - noedit (boolean) edit table - don't show in edit mode
|
||||
*
|
||||
*
|
||||
* - width (string) list table - width e.g '10%', 'auto'
|
||||
* - thclass (string) list table header - th element class
|
||||
* - class (string) list table body - td element additional class
|
||||
*
|
||||
*
|
||||
* - readParms (mixed) parameters used by core routine for showing values of current field. Structure on this attribute
|
||||
* depends on the current field type (see below). readParams are used mainly by list page
|
||||
*
|
||||
* - writeParms (mixed) parameters used by core routine for showing control element(s) of current field.
|
||||
* Structure on this attribute depends on the current field type (see below).
|
||||
*
|
||||
* - writeParms (mixed) parameters used by core routine for showing control element(s) of current field.
|
||||
* Structure on this attribute depends on the current field type (see below).
|
||||
* writeParams are used mainly by edit page, filter (list page), batch (list page)
|
||||
*
|
||||
*
|
||||
* $attributes['type']->$attributes['read/writeParams'] pairs:
|
||||
*
|
||||
*
|
||||
* - null -> read: n/a
|
||||
* -> write: n/a
|
||||
*
|
||||
*
|
||||
* - dropdown -> read: 'pre', 'post', array in format posted_html_name => value
|
||||
* -> write: 'pre', 'post', array in format as required by e_form::selectbox()
|
||||
*
|
||||
*
|
||||
* - user -> read: [optional] 'link' => true - create link to user profile, 'idField' => 'author_id' - tells to renderValue() where to search for user id (used when 'link' is true and current field is NOT ID field)
|
||||
* 'nameField' => 'comment_author_name' - tells to renderValue() where to search for user name (used when 'link' is true and current field is ID field)
|
||||
* -> write: [optional] 'nameField' => 'comment_author_name' the name of a 'user_name' field; 'currentInit' - use currrent user if no data provided; 'current' - use always current user(editor); '__options' e_form::userpickup() options
|
||||
*
|
||||
*
|
||||
* - number -> read: (array) [optional] 'point' => '.', [optional] 'sep' => ' ', [optional] 'decimals' => 2, [optional] 'pre' => '€ ', [optional] 'post' => 'LAN_CURRENCY'
|
||||
* -> write: (array) [optional] 'pre' => '€ ', [optional] 'post' => 'LAN_CURRENCY', [optional] 'maxlength' => 50, [optional] '__options' => array(...) see e_form class description for __options format
|
||||
*
|
||||
*
|
||||
* - ip -> read: n/a
|
||||
* -> write: [optional] element options array (see e_form class description for __options format)
|
||||
*
|
||||
*
|
||||
* - text -> read: (array) [optional] 'htmltruncate' => 100, [optional] 'truncate' => 100, [optional] 'pre' => '', [optional] 'post' => ' px'
|
||||
* -> write: (array) [optional] 'pre' => '', [optional] 'post' => ' px', [optional] 'maxlength' => 50 (default - 255), [optional] '__options' => array(...) see e_form class description for __options format
|
||||
*
|
||||
* - textarea -> read: (array) 'noparse' => '1' default 0 (disable toHTML text parsing), [optional] 'bb' => '1' (parse bbcode) default 0,
|
||||
* [optional] 'parse' => '' modifiers passed to e_parse::toHTML() e.g. 'BODY', [optional] 'htmltruncate' => 100,
|
||||
*
|
||||
* - textarea -> read: (array) 'noparse' => '1' default 0 (disable toHTML text parsing), [optional] 'bb' => '1' (parse bbcode) default 0,
|
||||
* [optional] 'parse' => '' modifiers passed to e_parse::toHTML() e.g. 'BODY', [optional] 'htmltruncate' => 100,
|
||||
* [optional] 'truncate' => 100, [optional] 'expand' => '[more]' title for expand link, empty - no expand
|
||||
* -> write: (array) [optional] 'rows' => '' default 15, [optional] 'cols' => '' default 40, [optional] '__options' => array(...) see e_form class description for __options format
|
||||
* [optional] 'counter' => 0 number of max characters - has only visual effect, doesn't truncate the value (default - false)
|
||||
*
|
||||
* [optional] 'counter' => 0 number of max characters - has only visual effect, doesn't truncate the value (default - false)
|
||||
*
|
||||
* - bbarea -> read: same as textarea type
|
||||
* -> write: (array) [optional] 'pre' => '', [optional] 'post' => ' px', [optional] 'maxlength' => 50 (default - 0),
|
||||
* -> write: (array) [optional] 'pre' => '', [optional] 'post' => ' px', [optional] 'maxlength' => 50 (default - 0),
|
||||
* [optional] 'size' => [optional] - medium, small, large - default is medium,
|
||||
* [optional] 'counter' => 0 number of max characters - has only visual effect, doesn't truncate the value (default - false)
|
||||
*
|
||||
* - image -> read: [optional] 'title' => 'SOME_LAN' (default - LAN_PREVIEW), [optional] 'pre' => '{e_PLUGIN}myplug/images/'
|
||||
* [optional] 'counter' => 0 number of max characters - has only visual effect, doesn't truncate the value (default - false)
|
||||
*
|
||||
* - image -> read: [optional] 'title' => 'SOME_LAN' (default - LAN_PREVIEW), [optional] 'pre' => '{e_PLUGIN}myplug/images/',
|
||||
* 'thumb' => 1 (true) or number width in pixels, 'thumb_urlraw' => 1|0 if true, it's a 'raw' url (no sc path constants),
|
||||
* 'thumb_aw' => if 'thumb' is 1|true, this is used for Adaptive thumb width
|
||||
* -> write: (array) [optional] 'label' => '', [optional] '__options' => array(...) see e_form::imagepicker() for allowed options
|
||||
*
|
||||
*
|
||||
* - icon -> read: [optional] 'class' => 'S16', [optional] 'pre' => '{e_PLUGIN}myplug/images/'
|
||||
* -> write: (array) [optional] 'label' => '', [optional] 'ajax' => true/false , [optional] '__options' => array(...) see e_form::iconpicker() for allowed options
|
||||
*
|
||||
*
|
||||
* - datestamp -> read: [optional] 'mask' => 'long'|'short'|strftime() string, default is 'short'
|
||||
* -> write: (array) [optional] 'label' => '', [optional] 'ajax' => true/false , [optional] '__options' => array(...) see e_form::iconpicker() for allowed options
|
||||
*
|
||||
* - url -> read: [optional] 'pre' => '{ePLUGIN}myplug/'|'http://somedomain.com/', 'truncate' => 50 default - no truncate, NOTE:
|
||||
* -> write:
|
||||
*
|
||||
*
|
||||
* - url -> read: [optional] 'pre' => '{ePLUGIN}myplug/'|'http://somedomain.com/', 'truncate' => 50 default - no truncate, NOTE:
|
||||
* -> write:
|
||||
*
|
||||
* - method -> read: optional, passed to given method (the field name)
|
||||
* -> write: optional, passed to given method (the field name)
|
||||
*
|
||||
* - hidden -> read: 'show' => 1|0 - show hidden value, 'empty' => 'something' - what to be shown if value is empty (only id 'show' is 1)
|
||||
*
|
||||
* - hidden -> read: 'show' => 1|0 - show hidden value, 'empty' => 'something' - what to be shown if value is empty (only id 'show' is 1)
|
||||
* -> write: same as readParms
|
||||
*
|
||||
*
|
||||
* - upload -> read: n/a
|
||||
* -> write: Under construction
|
||||
*
|
||||
*
|
||||
* Special attribute types:
|
||||
* - method (string) field name should be method from the current e_admin_form_ui class (or its extension).
|
||||
* Example call: field_name($value, $render_action, $parms) where $value is current value,
|
||||
* - method (string) field name should be method from the current e_admin_form_ui class (or its extension).
|
||||
* Example call: field_name($value, $render_action, $parms) where $value is current value,
|
||||
* $render_action is on of the following: read|write|batch|filter, parms are currently used paramateres ( value of read/writeParms attribute).
|
||||
* Return type expected (by render action):
|
||||
* - read: list table - formatted value only
|
||||
@ -253,36 +253,36 @@ class plugin_release_admin_ui extends e_admin_ui
|
||||
'checkboxes' => array('title'=> '', 'type' => null, 'data' => null, 'width'=>'5%', 'thclass' =>'center', 'forced'=> TRUE, 'class'=>'center', 'toggle' => 'e-multiselect'),
|
||||
'release_id' => array('title'=> ID, 'type' => 'number', 'data' => 'int', 'width'=>'5%', 'thclass' => '', 'forced'=> TRUE, 'primary'=>TRUE/*, 'noedit'=>TRUE*/), //Primary ID is not editable
|
||||
'release_type' => array('title'=> 'Type', 'type' => 'method', 'data' => 'str', 'width'=>'auto', 'thclass' => '', 'batch' => TRUE, 'filter'=>TRUE),
|
||||
'release_folder' => array('title'=> 'Folder', 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'thclass' => ''),
|
||||
'release_folder' => array('title'=> 'Folder', 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'thclass' => ''),
|
||||
'release_name' => array('title'=> 'Name', 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'thclass' => ''),
|
||||
'release_version' => array('title'=> 'Version', 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'thclass' => ''),
|
||||
'release_author' => array('title'=> LAN_AUTHOR, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'thclass' => 'left'),
|
||||
'release_authorURL' => array('title'=> LAN_AUTHOR_URL, 'type' => 'url', 'data' => 'str', 'width' => 'auto', 'thclass' => 'left'),
|
||||
'release_date' => array('title'=> LAN_DATE, 'type' => 'datestamp', 'data' => 'int', 'width' => 'auto', 'thclass' => '', 'readParms' => 'long', 'writeParms' => ''),
|
||||
'release_compatibility' => array('title'=> 'compatib', 'type' => 'text', 'data' => 'str', 'width' => '10%', 'thclass' => 'center' ),
|
||||
'release_url' => array('title'=> 'release_url', 'type' => 'url', 'data' => 'str', 'width' => '20%', 'thclass' => 'center', 'batch' => TRUE, 'filter'=>TRUE, 'parms' => 'truncate=30', 'validate' => true, 'help' => 'Enter release URL here', 'error' => 'please, ener valid URL'),
|
||||
'release_author' => array('title'=> LAN_AUTHOR, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'thclass' => 'left'),
|
||||
'release_authorURL' => array('title'=> LAN_AUTHOR_URL, 'type' => 'url', 'data' => 'str', 'width' => 'auto', 'thclass' => 'left'),
|
||||
'release_date' => array('title'=> LAN_DATE, 'type' => 'datestamp', 'data' => 'int', 'width' => 'auto', 'thclass' => '', 'readParms' => 'long', 'writeParms' => ''),
|
||||
'release_compatibility' => array('title'=> 'compatib', 'type' => 'text', 'data' => 'str', 'width' => '10%', 'thclass' => 'center' ),
|
||||
'release_url' => array('title'=> 'release_url', 'type' => 'url', 'data' => 'str', 'width' => '20%', 'thclass' => 'center', 'batch' => TRUE, 'filter'=>TRUE, 'parms' => 'truncate=30', 'validate' => true, 'help' => 'Enter release URL here', 'error' => 'please, ener valid URL'),
|
||||
'test_list_1' => array('title'=> 'test 1', 'type' => 'boolean', 'data' => 'int', 'width' => '5%', 'thclass' => 'center', 'batch' => TRUE, 'filter'=>TRUE, 'noedit' => true),
|
||||
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'data' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced'=>TRUE)
|
||||
);
|
||||
|
||||
//required - default column user prefs
|
||||
|
||||
//required - default column user prefs
|
||||
protected $fieldpref = array('checkboxes', 'release_id', 'release_type', 'release_url', 'release_compatibility', 'options');
|
||||
|
||||
|
||||
// FORMAT field_name=>type - optional if fields 'data' attribute is set or if custom model is set in init()
|
||||
/*protected $dataFields = array();*/
|
||||
|
||||
|
||||
// optional, could be also set directly from $fields array with attributes 'validate' => true|'rule_name', 'rule' => 'condition_name', 'error' => 'Validation Error message'
|
||||
/*protected $validationRules = array(
|
||||
'release_url' => array('required', '', 'Release URL', 'Help text', 'not valid error message')
|
||||
);*/
|
||||
|
||||
|
||||
// optional, if $pluginName == 'core', core prefs will be used, else e107::getPluginConfig($pluginName);
|
||||
protected $prefs = array(
|
||||
protected $prefs = array(
|
||||
'pref_type' => array('title'=> 'type', 'type'=>'text', 'data' => 'string', 'validate' => true),
|
||||
'pref_folder' => array('title'=> 'folder', 'type' => 'boolean', 'data' => 'integer'),
|
||||
'pref_name' => array('title'=> 'name', 'type' => 'text', 'data' => 'string', 'validate' => 'regex', 'rule' => '#^[\w]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')
|
||||
'pref_folder' => array('title'=> 'folder', 'type' => 'boolean', 'data' => 'integer'),
|
||||
'pref_name' => array('title'=> 'name', 'type' => 'text', 'data' => 'string', 'validate' => 'regex', 'rule' => '#^[\w]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')
|
||||
);
|
||||
|
||||
|
||||
// optional
|
||||
public function init()
|
||||
{
|
||||
@ -291,23 +291,23 @@ class plugin_release_admin_ui extends e_admin_ui
|
||||
|
||||
class plugin_release_admin_form_ui extends e_admin_form_ui
|
||||
{
|
||||
function release_type($curVal,$mode) // not really necessary since we can use 'dropdown' - but just an example of a custom function.
|
||||
function release_type($curVal,$mode) // not really necessary since we can use 'dropdown' - but just an example of a custom function.
|
||||
{
|
||||
if($mode == 'read')
|
||||
{
|
||||
return $curVal.' (custom!)';
|
||||
}
|
||||
|
||||
|
||||
if($mode == 'batch') // Custom Batch List for release_type
|
||||
{
|
||||
return array('theme'=>"Theme","plugin"=>'Plugin');
|
||||
return array('theme'=>"Theme","plugin"=>'Plugin');
|
||||
}
|
||||
|
||||
|
||||
if($mode == 'filter') // Custom Filter List for release_type
|
||||
{
|
||||
return array('theme'=>"Theme","plugin"=>'Plugin');
|
||||
return array('theme'=>"Theme","plugin"=>'Plugin');
|
||||
}
|
||||
|
||||
|
||||
$types = array("theme","plugin");
|
||||
$text = "<select class='tbox' name='release_type' >";
|
||||
foreach($types as $val)
|
||||
|
56
thumb.php
56
thumb.php
@ -15,13 +15,21 @@
|
||||
/**
|
||||
* @package e107
|
||||
* @subpackage core
|
||||
* @author secretr
|
||||
* @version $Id$
|
||||
*
|
||||
* @todo cache management - max age, max size, image cache manager (?), cron (?)
|
||||
*
|
||||
* On-the-fly thumbnail generator
|
||||
*/
|
||||
|
||||
define('e107_INIT', true);
|
||||
|
||||
//error_reporting(E_ALL);
|
||||
//require_once './e107_handlers/benchmark.php';
|
||||
//$bench = new e_benchmark();
|
||||
//$bench->start();
|
||||
|
||||
$thumbpage = new e_thumbpage();
|
||||
|
||||
if(!$thumbpage->checkSrc())
|
||||
@ -30,17 +38,28 @@ if(!$thumbpage->checkSrc())
|
||||
}
|
||||
$thumbpage->sendImage();
|
||||
|
||||
/**
|
||||
* Handle on-the-fly created thumbnails
|
||||
*
|
||||
* @author secretr
|
||||
*
|
||||
*/
|
||||
// Check your e_LOG folder
|
||||
//$bench->end()->logResult('thumb.php', $_GET['src'].' - no cache');
|
||||
exit;
|
||||
|
||||
class e_thumbpage
|
||||
{
|
||||
/**
|
||||
* Page request
|
||||
* @var array
|
||||
*/
|
||||
protected $_request = array();
|
||||
|
||||
/**
|
||||
* @var string image source path (e107 path shortcode)
|
||||
*/
|
||||
protected $_src = null;
|
||||
|
||||
/**
|
||||
* @var string source path modified/sanitized
|
||||
*/
|
||||
protected $_src_path = null;
|
||||
|
||||
/**
|
||||
* Constructor - init paths
|
||||
* @todo FIX e107 (new folder structure), simplify all this, e.g. e107::getInstance()->initMinimal($path_to_e107_config);
|
||||
@ -80,7 +99,14 @@ class e_thumbpage
|
||||
'CORE_DIRECTORY'
|
||||
);
|
||||
$sql_info = array(); //compact('mySQLserver', 'mySQLuser', 'mySQLpassword', 'mySQLdefaultdb', 'mySQLprefix', 'mySQLcharset');
|
||||
e107::getInstance()->initCore($e107_paths, $self, $sql_info, varset($e107_CONFIG, array()));
|
||||
//e107::getInstance()->initCore($e107_paths, $self, $sql_info, varset($e107_CONFIG, array()));
|
||||
$e107 = e107::getInstance();
|
||||
$e107->setDirs($e107_paths, varset($e107_CONFIG, array()));
|
||||
$e107->set_constants();
|
||||
$e107->set_paths();
|
||||
$e107->file_path = $e107->fix_windows_paths($self)."/";
|
||||
$e107->set_base_path();
|
||||
$e107->set_urls();
|
||||
unset($tmp, $self);
|
||||
|
||||
// parse request
|
||||
@ -89,8 +115,9 @@ class e_thumbpage
|
||||
|
||||
function parseRequest()
|
||||
{
|
||||
parse_str(str_replace('&', '&', e_QUERY), $request);
|
||||
$this->_request = $request;
|
||||
//parse_str(str_replace('&', '&', e_QUERY), $this->_request);
|
||||
parse_str($_SERVER['QUERY_STRING'], $this->_request);
|
||||
return $this;
|
||||
}
|
||||
|
||||
function checkSrc()
|
||||
@ -119,7 +146,8 @@ class e_thumbpage
|
||||
return false;
|
||||
}
|
||||
|
||||
$path = $tp->replaceConstants($this->_src);
|
||||
// should be safe enough
|
||||
$path = $tp->replaceConstants(str_replace('..', '', $this->_src));
|
||||
|
||||
if(is_file($path) && is_readable($path))
|
||||
{
|
||||
@ -131,6 +159,7 @@ class e_thumbpage
|
||||
|
||||
function sendImage()
|
||||
{
|
||||
//global $bench;
|
||||
if(!$this->_src_path)
|
||||
{
|
||||
return $this;
|
||||
@ -139,7 +168,7 @@ class e_thumbpage
|
||||
$thumbnfo = pathinfo($this->_src_path);
|
||||
$options = $this->getRequestOptions();
|
||||
|
||||
$cache_str = md5(serialize($options).md5_file($this->_src_path));
|
||||
$cache_str = md5(serialize($options).$this->_src_path);
|
||||
$fname = strtolower('Thumb_'.$thumbnfo['filename'].'_'.$cache_str.'.'.$thumbnfo['extension']).'.cache.bin';
|
||||
|
||||
if(is_file(e_CACHE_IMAGE.$fname) && is_readable(e_CACHE_IMAGE.$fname))
|
||||
@ -152,6 +181,7 @@ class e_thumbpage
|
||||
if (@$_SERVER['HTTP_IF_MODIFIED_SINCE'] && ($thumbnfo['lmodified'] <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) && (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == $thumbnfo['md5s']))
|
||||
{
|
||||
header('HTTP/1.1 304 Not Modified');
|
||||
//$bench->end()->logResult('thumb.php', $_GET['src'].' - 304 not modified');
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -159,6 +189,7 @@ class e_thumbpage
|
||||
$this->sendHeaders($thumbnfo);
|
||||
|
||||
@readfile(e_CACHE_IMAGE.$fname);
|
||||
//$bench->end()->logResult('thumb.php', $_GET['src'].' - retrieve cache');
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -189,7 +220,6 @@ class e_thumbpage
|
||||
|
||||
// show thumb
|
||||
$thumb->show();
|
||||
exit;
|
||||
}
|
||||
|
||||
function getRequestOptions()
|
||||
@ -243,3 +273,5 @@ class e_thumbpage
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user