2006-12-02 04:36:16 +00:00
< ? php
/*
2008-12-10 16:59:19 +00:00
* e107 website system
*
2009-11-18 01:06:08 +00:00
* Copyright ( C ) 2008 - 2009 e107 Inc ( e107 . org )
2008-12-10 16:59:19 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* Image Administration Area
*
2010-03-09 16:05:41 +00:00
* $URL $
* $Id $
2008-12-10 16:59:19 +00:00
*
2006-12-02 04:36:16 +00:00
*/
2012-04-22 06:19:21 +00:00
2013-02-23 23:08:30 -08:00
if ( $_GET [ 'action' ] == 'dialog' )
{
define ( 'e_MINIMAL' , true );
}
2012-04-22 06:19:21 +00:00
if ( ! defined ( 'e107_INIT' ))
{
require_once ( " ../class2.php " );
}
2012-07-07 06:04:04 +00:00
if ( ! getperms ( " A " ) && ( $_GET [ 'action' ] != 'dialog' ))
2008-12-29 15:23:06 +00:00
{
2008-12-10 16:59:19 +00:00
header ( " location: " . e_HTTP . " index.php " );
2006-12-02 04:36:16 +00:00
exit ;
}
2008-12-10 16:59:19 +00:00
2012-12-04 18:21:57 +01:00
e107 :: js ( 'core' , 'plupload/plupload.full.js' , 'jquery' , 2 );
e107 :: css ( 'core' , 'plupload/jquery.plupload.queue/css/jquery.plupload.queue.css' , 'jquery' );
e107 :: js ( 'core' , 'plupload/jquery.plupload.queue/jquery.plupload.queue.js' , 'jquery' , 2 );
e107 :: js ( 'core' , 'core/mediaManager.js' , " jquery " , 5 );
2012-05-22 13:32:49 +00:00
2009-11-07 11:20:34 +00:00
/*
* CLOSE - GO TO MAIN SCREEN
*/
if ( isset ( $_POST [ 'submit_cancel_show' ]))
{
header ( 'Location: ' . e_SELF );
exit ();
}
2009-08-28 16:11:02 +00:00
include_lan ( e_LANGUAGEDIR . e_LANGUAGE . '/admin/lan_' . e_PAGE );
2012-12-08 15:52:40 +01:00
if ( vartrue ( $_GET [ 'action' ]) == 'nav' && e_AJAX_REQUEST ) //XXX Doesn't work correctly inside the class for some reason
2012-08-04 04:15:41 +00:00
{
define ( " e_IFRAME " , true );
// require_once(e_ADMIN."auth.php");
$bbcodeMode = ( $_GET [ 'bbcode' ] == 'img' ) ? 'bbcode=img' : FALSE ;
if ( $_GET [ 'from' ])
{
$bbcodeMode .= " &from= " . intval ( $_GET [ 'from' ]);
}
$bbcodeMode .= " &nav=1 " ;
$tag = ( $bbcodeMode === false ) ? false : $_GET [ 'tagid' ]; // eg. news, news-thumbnail
if ( $_GET [ 'search' ])
{
$bbcodeMode .= " &search= " . preg_replace ( " /[^a-z0-9]/i " , " " , $_GET [ 'search' ]);
}
echo e107 :: getMedia () -> mediaSelect ( $_GET [ 'for' ], $tag , $bbcodeMode );
// require_once(e_ADMIN."footer.php");
exit ;
}
2012-09-03 23:02:45 +00:00
require ( e_HANDLER . 'phpthumb/ThumbLib.inc.php' ); // For resizing on import.
2012-08-04 04:15:41 +00:00
2006-12-02 04:36:16 +00:00
$e_sub_cat = 'image' ;
2008-12-10 16:59:19 +00:00
2012-04-28 01:31:30 +00:00
2009-11-07 11:20:34 +00:00
// $frm = new e_form(); //new form handler
2010-03-09 16:05:41 +00:00
$emessage = eMessage :: getInstance ();
2006-12-02 04:36:16 +00:00
2009-11-07 11:20:34 +00:00
class media_admin extends e_admin_dispatcher
2008-12-05 22:01:25 +00:00
{
2009-11-07 11:20:34 +00:00
protected $modes = array (
'main' => array (
'controller' => 'media_admin_ui' ,
'path' => null ,
2009-11-18 07:16:51 +00:00
'ui' => 'media_form_ui' ,
2009-11-07 11:20:34 +00:00
'uipath' => null
2009-11-18 07:16:51 +00:00
),
2012-05-25 11:30:49 +00:00
'dialog' => array (
'controller' => 'media_admin_ui' ,
'path' => null ,
'ui' => 'media_form_ui' ,
'uipath' => null
),
2009-11-18 07:16:51 +00:00
'cat' => array (
2010-10-04 16:01:17 +00:00
'controller' => 'media_cat_ui' ,
2009-11-18 07:16:51 +00:00
'path' => null ,
2010-10-04 16:01:17 +00:00
'ui' => 'media_cat_form_ui' ,
2009-11-18 07:16:51 +00:00
'uipath' => null
2010-03-09 16:05:41 +00:00
)
);
2009-11-07 11:20:34 +00:00
protected $adminMenu = array (
2012-12-04 18:21:57 +01:00
'main/list' => array ( 'caption' => LAN_IMA_M_01 , 'perm' => 'A' ),
2012-07-18 06:34:26 +00:00
// 'main/create' => array('caption'=> "Add New Media", 'perm' => 'A'), // Should be handled in Media-Import.
2012-12-04 18:21:57 +01:00
'main/import' => array ( 'caption' => LAN_IMA_M_02 , 'perm' => 'A|A2' ),
'cat/list' => array ( 'caption' => LAN_IMA_M_03 , 'perm' => 'A' ),
'cat/create' => array ( 'caption' => LAN_IMA_M_04 , 'perm' => 'A' ), // is automatic.
2012-06-17 11:52:10 +00:00
// 'main/settings' => array('caption'=> LAN_PREFS, 'perm' => 'A'), // legacy
'main/prefs' => array ( 'caption' => LAN_PREFS , 'perm' => 'A' ),
2012-12-04 18:21:57 +01:00
'main/avatar' => array ( 'caption' => LAN_IMA_M_05 , 'perm' => 'A' )
2009-11-07 11:20:34 +00:00
);
2010-03-09 16:05:41 +00:00
/*
2009-11-07 11:20:34 +00:00
$var [ 'main' ][ 'text' ] = IMALAN_7 ;
$var [ 'main' ][ 'link' ] = e_SELF ;
2012-06-02 08:12:16 +00:00
2009-11-07 11:20:34 +00:00
$var [ 'avatars' ][ 'text' ] = IMALAN_23 ;
$var [ 'avatars' ][ 'link' ] = e_SELF . " ?avatars " ;
$var [ 'editor' ][ 'text' ] = " Image Manipulation (future release) " ;
$var [ 'editor' ][ 'link' ] = e_SELF . " ?editor " ; */
2010-03-09 16:05:41 +00:00
2009-11-18 07:16:51 +00:00
2009-11-07 11:20:34 +00:00
protected $adminMenuAliases = array (
2010-03-09 16:05:41 +00:00
'main/edit' => 'main/list'
);
2009-11-07 11:20:34 +00:00
protected $menuTitle = LAN_MEDIAMANAGER ;
2010-03-09 16:05:41 +00:00
2009-11-07 11:20:34 +00:00
}
2010-10-04 16:01:17 +00:00
class media_cat_ui extends e_admin_ui
2010-03-09 16:05:41 +00:00
{
2012-12-04 18:21:57 +01:00
protected $pluginTitle = LAN_IMA_M_03 ;
2009-11-18 07:16:51 +00:00
protected $pluginName = 'core' ;
protected $table = " core_media_cat " ;
protected $pid = " media_cat_id " ;
protected $perPage = 0 ; //no limit
2009-12-02 10:03:53 +00:00
protected $batchDelete = false ;
2012-04-22 06:19:21 +00:00
public $ownerCount = array ();
2012-08-19 02:33:43 +00:00
// protected $listQry = "SELECT * FROM #core_media_cat"; // without any Order or Limit.
protected $listOrder = 'media_cat_owner asc' ;
2009-11-18 07:16:51 +00:00
// protected $editQry = "SELECT * FROM #faq_info WHERE faq_info_id = {ID}";
2010-03-09 16:05:41 +00:00
2009-11-18 07:16:51 +00:00
protected $fields = array (
2011-05-07 06:22:44 +00:00
//'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
2012-08-19 02:33:43 +00:00
'media_cat_id' => array ( 'title' => LAN_ID , 'type' => 'number' , 'width' => '5%' , 'nolist' => true , 'forced' => TRUE , 'readonly' => TRUE ),
2012-04-22 06:19:21 +00:00
'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 ),
2012-12-04 18:21:57 +01:00
'media_cat_owner' => array ( 'title' => LAN_OWNER , 'type' => 'dropdown' , 'width' => 'auto' , 'thclass' => 'left' , 'readonly' => FALSE ),
2012-10-31 21:28:20 +00:00
2012-12-04 18:21:57 +01:00
'media_cat_type' => array ( 'title' => LAN_TYPE , 'type' => 'radio' , 'data' => false , 'width' => 'auto' , 'thclass' => 'left' , 'validate' => true , 'nolist' => true ),
2012-10-31 21:28:20 +00:00
'media_cat_category' => array ( 'title' => LAN_CATEGORY , 'type' => 'text' , 'data' => 'str' , 'width' => 'auto' , 'thclass' => 'left' , 'readonly' => TRUE ),
2013-01-16 12:51:03 +02:00
'media_cat_title' => array ( 'title' => LAN_TITLE , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left' , 'readonly' => FALSE , 'required' => true ),
2013-01-15 23:19:34 -08:00
'media_cat_sef' => array ( 'title' => LAN_SEFURL , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left' , 'readonly' => FALSE ),
2012-04-22 06:19:21 +00:00
'media_cat_diz' => array ( 'title' => LAN_DESCRIPTION , 'type' => 'bbarea' , 'width' => '30%' , 'readParms' => 'expand=...&truncate=150&bb=1' , 'readonly' => FALSE ), // Display name
2009-11-18 07:16:51 +00:00
'media_cat_class' => array ( 'title' => LAN_VISIBILITY , 'type' => 'userclass' , 'width' => 'auto' , 'data' => 'int' ),
2012-04-22 06:19:21 +00:00
'media_cat_order' => array ( 'title' => LAN_ORDER , 'type' => 'text' , 'width' => '5%' , 'thclass' => 'right' , 'class' => 'right' ),
2012-08-19 02:33:43 +00:00
'options' => array ( 'title' => LAN_OPTIONS , 'type' => 'method' , 'noedit' => true , 'width' => '10%' , 'forced' => TRUE , 'thclass' => 'center last' , 'class' => 'center' )
2010-03-09 16:05:41 +00:00
);
2012-04-22 06:19:21 +00:00
function init ()
2009-11-18 07:16:51 +00:00
{
2012-08-19 02:33:43 +00:00
$restricted = array (
2012-04-22 06:19:21 +00:00
" _common " => " _common " ,
2012-04-22 07:53:34 +00:00
" _icon " => " _icon " ,
" news " => " news " ,
2012-04-22 06:19:21 +00:00
" page " => " page " ,
2012-08-19 02:33:43 +00:00
" download " => " download "
2012-04-22 06:19:21 +00:00
);
2012-10-31 21:28:20 +00:00
// FIXME lan
$this -> fields [ 'media_cat_type' ][ 'writeParms' ] = array ( 'image' => 'Image' , 'file' => 'File' , 'video' => 'Video' );
2012-10-31 20:18:18 +00:00
if ( $this -> getAction () == 'list' )
2012-08-19 02:33:43 +00:00
{
$this -> fields [ 'media_cat_owner' ][ 'writeParms' ] = $restricted ;
}
2012-10-31 20:18:18 +00:00
if ( $this -> getAction () == 'create' )
{
$this -> fields [ 'media_cat_category' ][ 'noedit' ] = true ;
}
2013-01-17 16:08:07 +02:00
elseif ( $this -> getAction () == 'edit' )
{
$this -> fields [ 'media_cat_type' ][ 'noedit' ] = true ;
}
2012-08-19 02:33:43 +00:00
2012-04-22 06:19:21 +00:00
$sql = e107 :: getDb ();
2012-08-19 02:33:43 +00:00
2012-04-22 06:19:21 +00:00
$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 ())
{
2012-08-19 02:33:43 +00:00
$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 ;
}
2012-04-22 06:19:21 +00:00
}
2009-11-18 07:16:51 +00:00
}
2012-04-22 06:19:21 +00:00
public function beforeCreate ( $new_data )
{
2010-03-09 16:05:41 +00:00
2012-04-22 06:19:21 +00:00
//$replace = array("_"," ","'",'"',"."); //FIXME Improve
//$new_data['media_cat_category'] = str_replace($replace,"-",$new_data['media_cat_category']);
2012-10-31 21:28:20 +00:00
$type = $this -> getRequest () -> getPosted ( 'media_cat_type' , 'image' ) . '_' ;
2012-04-22 06:19:21 +00:00
$increment = ( $this -> ownerCount [ $new_data [ 'media_cat_owner' ]] + 1 );
2012-10-31 21:28:20 +00:00
$new_data [ 'media_cat_category' ] = $new_data [ 'media_cat_owner' ] . '_' . $type . $increment ;
2013-01-17 16:08:07 +02:00
if ( empty ( $new_data [ 'media_cat_sef' ])) $new_data [ 'media_cat_sef' ] = eHelper :: title2sef ( $new_data [ 'media_cat_title' ]);
2012-04-22 06:19:21 +00:00
return $new_data ;
}
public function beforeUpdate ( $new_data , $old_data , $id )
2009-11-18 07:16:51 +00:00
{
2012-04-22 06:19:21 +00:00
$mes = e107 :: getMessage ();
if ( $new_data [ 'media_cat_owner' ] != " gallery " )
2009-11-18 07:16:51 +00:00
{
2012-12-04 18:21:57 +01:00
$mes -> addError ( LAN_IMA_001 );
2012-04-22 06:19:21 +00:00
return FALSE ;
2009-11-18 07:16:51 +00:00
}
2012-04-22 06:19:21 +00:00
2013-01-16 12:51:03 +02:00
if ( empty ( $new_data [ 'media_cat_sef' ])) $new_data [ 'media_cat_sef' ] = eHelper :: title2sef ( $new_data [ 'media_cat_title' ]);
2012-04-22 06:19:21 +00:00
return $new_data ;
}
}
class media_cat_form_ui extends e_admin_form_ui
{
2012-08-19 02:33:43 +00:00
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 );
}
2012-04-22 06:19:21 +00:00
2012-08-19 02:33:43 +00:00
// $save = ($_GET['bbcode']!='file') ? "e-dialog-save" : "";
// e-dialog-close
}
2010-10-04 16:01:17 +00:00
}
2009-11-18 07:16:51 +00:00
class media_form_ui extends e_admin_form_ui
{
2010-03-09 16:05:41 +00:00
2009-11-18 07:16:51 +00:00
function init ()
{
2010-10-04 16:01:17 +00:00
/* $sql = e107 :: getDb ();
2012-04-22 06:19:21 +00:00
// $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_owner GROUP BY m.media_category");
$sql -> db_Select_gen ( " SELECT media_cat_title, media_cat_owner FROM #core_media_cat " );
2009-11-18 07:16:51 +00:00
while ( $row = $sql -> db_Fetch ())
{
2012-04-22 06:19:21 +00:00
$cat = $row [ 'media_cat_owner' ];
2010-03-09 16:05:41 +00:00
$this -> cats [ $cat ] = $row [ 'media_cat_title' ];
2009-11-18 07:16:51 +00:00
}
2010-10-04 16:01:17 +00:00
asort ( $this -> cats ); */
2012-09-03 23:02:45 +00:00
// require(e_HANDLER.'phpthumb/ThumbLib.inc.php'); // For resizing on import.
2012-07-29 02:36:18 +00:00
if ( varset ( $_POST [ 'multiselect' ]) && varset ( $_POST [ 'e__execute_batch' ]) && ( varset ( $_POST [ 'etrigger_batch' ]) == 'options__rotate_cw' || varset ( $_POST [ 'etrigger_batch' ]) == 'options__rotate_ccw' ))
{
$type = str_replace ( 'options__' , '' , $_POST [ 'etrigger_batch' ]);
$ids = implode ( " , " , $_POST [ 'multiselect' ]);
$this -> rotateImages ( $ids , $type );
}
2012-09-03 23:02:45 +00:00
if ( varset ( $_POST [ 'multiselect' ]) && varset ( $_POST [ 'e__execute_batch' ]) && ( varset ( $_POST [ 'etrigger_batch' ]) == 'options__resize_2048' ))
{
$type = str_replace ( 'options__' , '' , $_POST [ 'etrigger_batch' ]);
$ids = implode ( " , " , $_POST [ 'multiselect' ]);
$this -> resizeImages ( $ids , $type );
}
2009-11-18 07:16:51 +00:00
}
2012-06-06 07:39:42 +00:00
function resize_method ( $curval )
{
$frm = e107 :: getForm ();
$options = array (
'gd1' => 'gd1' ,
'gd2' => 'gd2' ,
'ImageMagick' => 'ImageMagick'
);
return $frm -> selectbox ( 'resize_method' , $options , $curval ) . " <div class='field-help'> " . IMALAN_4 . " </div> " ;
}
2012-10-31 23:22:47 +00:00
public function rotateImages ( $ids , $type )
2012-07-29 02:36:18 +00:00
{
$sql = e107 :: getDb ();
$tp = e107 :: getParser ();
$mes = e107 :: getMessage ();
2012-09-03 23:02:45 +00:00
ini_set ( 'memory_limit' , '150M' );
ini_set ( 'gd.jpeg_ignore_warning' , 1 );
2012-07-29 02:36:18 +00:00
$degrees = ( $type == 'rotate_cw' ) ? 270 : 90 ;
// $mes->addDebug("Rotate Mode Set: ".$type);
//TODO GIF and PNG rotation.
if ( $sql -> db_Select ( " core_media " , " media_url " , " media_id IN ( " . $ids . " ) AND media_type = 'image/jpeg' " ))
{
while ( $row = $sql -> db_Fetch ())
{
$original = $tp -> replaceConstants ( $row [ 'media_url' ]);
$mes -> addDebug ( " Attempting to rotate by { $degrees } degrees: " . basename ( $original ));
$source = imagecreatefromjpeg ( $original );
2012-09-03 23:02:45 +00:00
try
{
$rotate = imagerotate ( $source , $degrees , 0 );
}
catch ( Exception $e )
{
2012-12-04 18:21:57 +01:00
$mes -> addError ( LAN_IMA_002 . " : " . basename ( $original ));
2012-09-03 23:02:45 +00:00
}
2012-07-29 02:36:18 +00:00
$srch = array ( " .jpg " , " .jpeg " );
$cacheFile = str_replace ( $srch , " " , strtolower ( basename ( $original ))) . " _(.*) \ .cache \ .bin " ;
2012-09-03 23:02:45 +00:00
try
2012-07-29 02:36:18 +00:00
{
2012-09-03 23:02:45 +00:00
imagejpeg ( $rotate , $original , 80 );
2012-12-04 18:21:57 +01:00
$mes -> addSuccess ( LAN_IMA_002 . " : " . basename ( $original ));
2012-07-29 02:36:18 +00:00
e107 :: getCache () -> clearAll ( 'image' , $cacheFile );
$mes -> addDebug ( " Clearing Image cache with mask: " . $cacheFile );
2012-09-03 23:02:45 +00:00
}
catch ( Exception $e )
{
2012-12-04 18:21:57 +01:00
$mes -> addError ( LAN_IMA_002 . " : " . basename ( $original ));
2012-09-03 23:02:45 +00:00
}
2012-07-29 02:36:18 +00:00
}
}
}
2012-09-03 23:02:45 +00:00
/**
* Resize a single image .
* @ param string
* @ param int
* @ param int
*/
2012-10-31 23:22:47 +00:00
public function resizeImage ( $oldpath , $img_import_w , $img_import_h )
2012-09-03 23:02:45 +00:00
{
try
{
$thumb = PhpThumbFactory :: create ( $oldpath );
$thumb -> setOptions ( array ( 'correctPermissions' => true ));
}
catch ( Exception $e )
{
$mes -> addError ( $e -> getMessage ());
return FALSE ;
// return $this;
}
if ( $WM ) // TODO Add watermark prefs for alpha and position.
{
$thumb -> resize ( $img_import_w , $img_import_h ) -> addWatermark ( $watermark , 'rightBottom' , 30 , 0 , 0 ) -> save ( $oldpath );
}
else
{
if ( $thumb -> resize ( $img_import_w , $img_import_h ) -> save ( $oldpath ))
{
return TRUE ;
}
}
}
2012-10-31 23:22:47 +00:00
public function resizeImages ( $ids , $type )
2012-09-03 23:02:45 +00:00
{
$sql = e107 :: getDb ();
$sql2 = e107 :: getDb ( 'sql2' );
$mes = e107 :: getMessage ();
$tp = e107 :: getParser ();
$fl = e107 :: getFile ();
// Max size is 6 megapixel.
$img_import_w = 2816 ;
$img_import_h = 2112 ;
if ( $sql -> db_Select ( " core_media " , " media_id,media_url " , " media_id IN ( " . $ids . " ) AND media_type = 'image/jpeg' " ))
{
while ( $row = $sql -> db_Fetch ())
{
$path = $tp -> replaceConstants ( $row [ 'media_url' ]);
$mes -> addDebug ( " Attempting to resize: " . basename ( $path ));
if ( $this -> resizeImage ( $path , $img_import_w , $img_import_h ))
{
$info = $fl -> get_file_info ( $path );
2012-12-04 18:21:57 +01:00
$mes -> addSuccess ( LAN_IMA_004 . " : " . basename ( $path ));
2012-09-03 23:02:45 +00:00
$mes -> addSuccess ( print_a ( $info , true ));
$dim = intval ( $info [ 'img-width' ]) . " x " . intval ( $info [ 'img-height' ]);
$sql2 -> db_Update ( " core_media " , " media_dimensions = ' " . $dim . " ', media_size = ' " . intval ( $info [ 'fsize' ]) . " ' WHERE media_id = " . intval ( $row [ 'media_id' ]) . " LIMIT 1 " );
}
else
{
2012-12-04 18:21:57 +01:00
$mes -> addError ( LAN_IMA_004 . " : " . basename ( $path ));
2012-09-03 23:02:45 +00:00
}
}
}
}
2012-07-29 02:36:18 +00:00
2012-10-31 23:22:47 +00:00
public function resize_dimensions ( $curval ) // ie. never manually resize another image again!
2012-06-06 07:39:42 +00:00
{
2012-10-31 23:22:47 +00:00
2012-06-06 07:39:42 +00:00
$text = " " ;
2012-10-31 23:22:47 +00:00
2012-06-06 07:39:42 +00:00
$frm = e107 :: getForm ();
2012-07-18 06:34:26 +00:00
$pref = e107 :: getPref ();
2012-06-06 07:39:42 +00:00
$options = array (
2012-12-04 18:21:57 +01:00
" news-image " => " News Images " , // TODO LAN.
2012-06-06 07:39:42 +00:00
" news-bbcode " => " News [img] bbcode " ,
" page-bbcode " => " Page [img] bbcode " ,
// "featurebox-image" => "Featurebox Images",
// "featurebox-bbcode" => "Featurebox [img] bbcode",
);
2012-06-17 11:52:10 +00:00
2012-11-01 00:13:24 +00:00
if ( vartrue ( $pref [ 'e_imageresize' ]) && is_array ( $pref [ 'e_imageresize' ]))
2012-07-18 06:34:26 +00:00
{
2012-12-12 19:28:39 -08:00
foreach ( $pref [ 'e_imageresize' ] as $k => $val )
2012-07-18 06:34:26 +00:00
{
$options [ $k ] = ucfirst ( $k ) . " [img] bbcode " ;
}
}
2012-12-12 19:28:39 -08:00
$options = $pref [ 'resize_dimensions' ];
2012-06-17 11:52:10 +00:00
2012-06-06 07:39:42 +00:00
foreach ( $options as $key => $title )
{
2012-12-12 19:28:39 -08:00
$title = ucwords ( str_replace ( " - " , " " , $key ));
2012-07-14 10:40:40 +00:00
$valW = vartrue ( $curval [ $key ][ 'w' ]);
$valH = vartrue ( $curval [ $key ][ 'h' ]);
2012-07-09 01:07:51 +00:00
2012-11-28 19:18:20 -08:00
$text .= " <div style='margin-bottomp:8px;text-align:right:width:400px'> " . $title . " : " ;
$text .= " <input class='e-tip e-spinner input-small' placeholder='ex. 400' style='text-align:right' type='text' name='resize_dimensions[ { $key } ][w]' value=' $valW ' size='5' title='maximum width in pixels' /> X " ;
$text .= " <input class='e-tip e-spinner input-small' placeholder='ex. 400' style='text-align:right' type='text' name='resize_dimensions[ { $key } ][h]' value=' $valH ' size='5' title='maximum height in pixels' /> " ;
2012-07-09 01:07:51 +00:00
$text .= " </div> " ;
2012-06-06 07:39:42 +00:00
// $text .= $frm->text("resize_dimensions[{$key}]",$val, 5, array('size'=>'5')).$title."<br />";
}
2012-07-29 02:36:18 +00:00
// $text .= "<div><br />Warning: This feature is experimental.</div>";
2012-07-09 01:07:51 +00:00
2012-06-06 07:39:42 +00:00
return $text ;
}
2010-03-09 16:05:41 +00:00
2012-07-29 02:36:18 +00:00
function options ( $parms , $value , $id )
2012-05-25 11:30:49 +00:00
{
//return print_a($_GET,true);
2012-07-29 02:36:18 +00:00
if ( $value == 'batch' )
{
return array (
2012-09-03 23:02:45 +00:00
" resize_2048 " => " Reduce Oversized Images " ,
2012-07-29 02:36:18 +00:00
" rotate_cw " => " Rotate 90° cw " ,
2012-09-03 23:02:45 +00:00
" rotate_ccw " => " Rotate 90° ccw "
2012-07-29 02:36:18 +00:00
);
}
if ( $_GET [ 'action' ] == 'edit' )
{
return ;
}
2012-12-08 15:52:40 +01:00
$tagid = vartrue ( $_GET [ 'tagid' ]);
2012-05-25 11:30:49 +00:00
$path = $this -> getController () -> getListModel () -> get ( 'media_url' );
2012-07-11 04:46:09 +00:00
$title = $this -> getController () -> getListModel () -> get ( 'media_name' );
$id = $this -> getController () -> getListModel () -> get ( 'media_id' );
2012-05-25 11:30:49 +00:00
$preview = basename ( $path );
2012-05-28 13:06:09 +00:00
2012-12-08 15:52:40 +01:00
$bbcode = ( vartrue ( $_GET [ 'bbcode' ]) == 'file' ) ? " file " : " " ;
2012-07-20 07:31:16 +00:00
// $save = ($_GET['bbcode']!='file') ? "e-dialog-save" : "";
// e-dialog-close
2012-07-29 02:36:18 +00:00
$text = $this -> renderValue ( 'options' , $value , '' , $id );
2013-02-23 03:04:45 -08:00
// File Picker.
2012-07-29 02:36:18 +00:00
if ( $_GET [ 'action' ] == 'dialog' )
{
2013-02-23 03:04:45 -08:00
$text .= " <input type='button' value='Select' data-placement='left' class='e-media-select e-dialog-save e-dialog-close btn' data-id=' { $id } ' data-name= \" " . $title . " \" data-target=' { $tagid } ' data-bbcode=' { $bbcode } ' data-path=' { $path } ' data-preview=' { $preview } ' title= \" " . $title . " \" /> " ;
2012-07-29 02:36:18 +00:00
}
2013-02-23 03:04:45 -08:00
return " <div class='nowrap'> " . $text . " </div> " ;
2012-07-29 02:36:18 +00:00
2012-05-25 11:30:49 +00:00
}
2012-04-22 06:19:21 +00:00
2013-01-09 10:49:33 +02:00
/*
2010-03-09 16:05:41 +00:00
function media_category ( $curVal , $mode ) // not really necessary since we can use 'dropdown' - but just an example of a custom function.
2009-11-18 07:16:51 +00:00
{
2012-08-02 02:11:22 +00:00
2012-05-23 08:29:57 +00:00
$curVal = explode ( " , " , $curVal );
2012-08-02 02:11:22 +00:00
2009-11-18 07:16:51 +00:00
if ( $mode == 'read' )
{
2010-10-04 16:01:17 +00:00
return $this -> getController () -> getMediaCategory ( $curVal );
//return $this->cats[$curVal];
2009-11-18 07:16:51 +00:00
}
2010-03-09 16:05:41 +00:00
2009-11-18 07:16:51 +00:00
if ( $mode == 'batch' ) // Custom Batch List for release_type
{
2010-10-04 16:01:17 +00:00
return $this -> getController () -> getMediaCategory ();
2009-11-18 07:16:51 +00:00
}
2010-03-09 16:05:41 +00:00
2009-11-18 07:16:51 +00:00
if ( $mode == 'filter' ) // Custom Filter List for release_type
{
2010-10-04 16:01:17 +00:00
return $this -> getController () -> getMediaCategory ();
2009-11-18 07:16:51 +00:00
}
2010-03-09 16:05:41 +00:00
2013-02-23 03:04:45 -08:00
$text = " <select class='tbox' name='media_category[]' multiple='multiple'> " ;
2010-10-04 16:01:17 +00:00
$cats = $this -> getController () -> getMediaCategory ();
2012-05-23 08:29:57 +00:00
2010-10-04 16:01:17 +00:00
foreach ( $cats as $key => $val )
2009-11-18 07:16:51 +00:00
{
2012-05-23 08:29:57 +00:00
$selected = ( in_array ( $key , $curVal )) ? " selected='selected' " : " " ;
2009-11-18 07:16:51 +00:00
$text .= " <option value=' { $key } ' { $selected } > " . $val . " </option> \n " ;
}
$text .= " </select> " ;
return $text ;
2013-01-09 10:49:33 +02:00
} */
2009-11-18 07:16:51 +00:00
}
2009-11-07 11:20:34 +00:00
2013-01-09 10:49:33 +02:00
2009-11-07 11:20:34 +00:00
class media_admin_ui extends e_admin_ui
{
2010-03-09 16:05:41 +00:00
protected $pluginTitle = LAN_MEDIAMANAGER ;
2009-11-07 11:20:34 +00:00
protected $pluginName = 'core' ;
protected $table = " core_media " ;
2010-03-09 16:05:41 +00:00
2011-05-07 06:22:44 +00:00
protected $listQry = " SELECT m.*,u.user_id,u.user_name FROM #core_media AS m LEFT JOIN #user AS u ON m.media_author = u.user_id " ; // without any Order or Limit.
2010-03-09 16:05:41 +00:00
2009-11-07 11:20:34 +00:00
// //protected $editQry = "SELECT * FROM #comments WHERE comment_id = {ID}";
2010-03-09 16:05:41 +00:00
2009-11-07 11:20:34 +00:00
protected $pid = " media_id " ;
protected $perPage = 10 ;
protected $batchDelete = true ;
2011-08-22 23:52:45 +00:00
// protected $defaultOrder = 'desc';
protected $listOrder = 'm.media_id desc' ; // show newest images first.
2012-10-31 21:54:55 +00:00
public $deleteConfirmScreen = true ;
public $deleteConfirmMessage = 'You are about to delete %d records and <strong>ALL CORRESPONDING FILES</strong>! Please confirm to continue!' ;
2010-03-09 16:05:41 +00:00
2009-11-07 11:20:34 +00:00
//TODO - finish 'user' type, set 'data' to all editable fields, set 'noedit' for all non-editable fields
2009-11-14 04:13:11 +00:00
/*
2010-03-09 16:05:41 +00:00
* 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 .
2009-11-14 04:13:11 +00:00
*/
2010-03-09 16:05:41 +00:00
2009-11-14 04:13:11 +00:00
protected $fields = array (
2009-11-07 11:20:34 +00:00
'checkboxes' => array ( 'title' => '' , 'type' => null , 'data' => null , 'width' => '5%' , 'forced' => TRUE , 'thclass' => 'center' , 'class' => 'center' ),
2009-12-02 10:03:53 +00:00
'media_id' => array ( 'title' => LAN_ID , 'type' => 'number' , 'data' => 'int' , 'width' => '5%' , 'forced' => TRUE , 'nolist' => TRUE ),
2012-05-23 13:59:12 +00:00
'media_url' => array ( 'title' => 'Preview' , 'type' => 'image' , 'data' => 'str' , 'thclass' => 'center' , 'class' => 'center' , 'readParms' => 'thumb=60&thumb_urlraw=0&thumb_aw=60' , 'readonly' => TRUE , 'writeParms' => 'thumb=180&thumb_urlraw=0&thumb_aw=180' , 'width' => '110px' ),
2013-01-09 10:49:33 +02:00
'media_category' => array ( 'title' => LAN_CATEGORY , 'type' => 'comma' , 'data' => 'str' , 'width' => 'auto' , 'filter' => true , 'batch' => true ),
2012-04-22 06:19:21 +00:00
2011-06-07 13:01:36 +00:00
// Upload should be managed completely separately via upload-handler.
2012-07-18 06:34:26 +00:00
// 'media_upload' => array('title'=> "Upload File", 'type' => 'upload', 'data'=> false, 'readParms' => 'hidden', 'writeParms' => 'disable_button=1', 'width' => '10%', 'nolist' => true),
2009-12-02 10:03:53 +00:00
'media_name' => array ( 'title' => LAN_TITLE , 'type' => 'text' , 'data' => 'str' , 'width' => 'auto' ),
'media_caption' => array ( 'title' => " Caption " , 'type' => 'text' , 'data' => 'str' , 'width' => 'auto' ),
2011-06-07 13:01:36 +00:00
// media_description is type = textarea until bbarea can be reduced to not include youtube etc
2011-05-07 07:16:45 +00:00
'media_description' => array ( 'title' => LAN_DESCRIPTION , 'type' => 'textarea' , 'data' => 'str' , 'width' => 'auto' , 'thclass' => 'left first' , 'readParms' => 'truncate=100' , 'writeParms' => 'counter=0' ),
2011-05-07 06:22:44 +00:00
'media_type' => array ( 'title' => " Mime Type " , 'type' => 'text' , 'data' => 'str' , 'width' => 'auto' , 'noedit' => TRUE ),
'media_author' => array ( 'title' => LAN_USER , 'type' => 'user' , 'data' => 'int' , 'width' => 'auto' , 'thclass' => 'center' , 'class' => 'center' , 'readParms' => 'link=1' , 'filter' => true , 'batch' => true , 'noedit' => TRUE ),
2009-12-02 10:03:53 +00:00
'media_datestamp' => array ( 'title' => LAN_DATESTAMP , 'type' => 'datestamp' , 'data' => 'int' , 'width' => '10%' , 'noedit' => TRUE ), // User date
2010-03-09 16:05:41 +00:00
'media_size' => array ( 'title' => " Size " , 'type' => 'number' , 'data' => 'int' , 'width' => 'auto' , 'noedit' => TRUE ),
2012-04-27 02:02:38 +00:00
'media_dimensions' => array ( 'title' => " Dimensions " , 'type' => 'text' , 'data' => 'str' , 'width' => '5%' , 'readonly' => TRUE , 'class' => 'nowrap' , 'noedit' => TRUE ),
2010-03-09 16:05:41 +00:00
'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 ),
2010-10-04 16:01:17 +00:00
'media_usedby' => array ( 'title' => '' , 'type' => 'text' , 'data' => 'text' , 'width' => 'auto' , 'thclass' => 'center' , 'class' => 'center' , 'nolist' => true , 'readonly' => TRUE ),
2010-03-09 16:05:41 +00:00
2012-07-29 02:36:18 +00:00
'options' => array ( 'title' => LAN_OPTIONS , 'type' => 'method' , 'data' => null , 'forced' => TRUE , 'width' => '10%' , 'thclass' => 'center last' , 'class' => 'center' , 'batch' => true , 'noedit' => true )
2009-11-07 11:20:34 +00:00
);
2011-05-07 06:22:44 +00:00
2009-11-18 07:16:51 +00:00
protected $mimePaths = array (
2011-05-07 06:22:44 +00:00
'text' => e_MEDIA_FILE ,
'multipart' => e_MEDIA_FILE ,
'application' => e_MEDIA_FILE ,
2012-11-29 23:12:20 -08:00
// 'audio' => e_MEDIA_AUDIO,
2011-05-07 06:22:44 +00:00
'image' => e_MEDIA_IMAGE ,
'video' => e_MEDIA_VIDEO ,
'other' => e_MEDIA_FILE
2009-11-18 07:16:51 +00:00
);
2009-11-14 04:13:11 +00:00
// protected $fieldpref = array('checkboxes','media_url', 'media_id', 'media_thumb', 'media_title', 'media_caption', 'media_description', 'media_category', 'media_datestamp','media_userclass', 'options');
2010-03-09 16:05:41 +00:00
2009-11-14 04:13:11 +00:00
2012-06-06 07:39:42 +00:00
protected $prefs = array (
'image_post' => array ( 'title' => IMALAN_1 , 'type' => 'boolean' , 'data' => 'int' , 'writeParms' => 'help=IMALAN_2' ),
'image_post_class' => array ( 'title' => IMALAN_10 , 'type' => 'userclass' , 'data' => 'int' , 'writeParms' => 'help=IMALAN_11&classlist=public,guest,nobody,member,admin,main,classes' ),
'image_post_disabled_method' => array ( 'title' => IMALAN_12 , 'type' => 'boolean' , 'writeParms' => 'enabled=IMALAN_15&disabled=IMALAN_14' ),
'resize_method' => array ( 'title' => IMALAN_3 , 'type' => 'method' , 'data' => 'str' ),
2012-11-01 00:13:24 +00:00
'im_width' => array ( 'title' => " Avatar Width " , 'type' => 'number' , 'data' => 'int' , 'writeParms' => 'help=Avatar images will be constrained to these dimensions (in pixels)' ), //TODO LAN
'im_height' => array ( 'title' => " Avatar Height " , 'type' => 'number' , 'data' => 'int' , 'writeParms' => 'help=Avatar images will be constrained to these dimensions (in pixels)' ),
2012-07-18 06:34:26 +00:00
'resize_dimensions' => array ( 'title' => " Resize-Image Dimensions " , 'type' => 'method' , 'data' => 'str' ),
2012-07-12 10:15:12 +00:00
2012-11-01 00:34:38 +00:00
'watermark_activate' => array ( 'title' => 'Watermark Activation' , 'type' => 'number' , 'data' => 'str' , 'help' => 'All images with a width or height greater than this value will be given a watermark during resizing.' ), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
2012-07-12 10:15:12 +00:00
'watermark_text' => array ( 'title' => 'Watermark Text' , 'type' => 'text' , 'data' => 'str' , 'help' => 'Optional Watermark Text' ), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
'watermark_font' => array ( 'title' => 'Watermark Font' , 'type' => 'dropdown' , 'data' => 'str' , 'help' => 'Optional Watermark Font. Upload more .ttf fonts to the /fonts folder in your theme directory.' ), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
2012-11-01 00:34:38 +00:00
'watermark_size' => array ( 'title' => 'Watermark Size' , 'type' => 'number' , 'data' => 'int' , 'help' => 'Size of the font in pts' ), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
2012-07-14 10:40:40 +00:00
2012-07-12 10:15:12 +00:00
'watermark_pos' => array ( 'title' => 'Watermark Position' , 'type' => 'dropdown' , 'data' => 'str' , 'help' => 'Watermark Position' ), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
2012-11-01 00:34:38 +00:00
'watermark_margin' => array ( 'title' => 'Watermark Margin' , 'type' => 'number' , 'data' => 'int' , 'help' => 'The distance that watermark will appear from the edge of the image.' ), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
2012-07-14 10:40:40 +00:00
'watermark_color' => array ( 'title' => 'Watermark Color' , 'type' => 'text' , 'data' => 'str' , 'help' => 'Color of the watermark eg. 000000' ), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
'watermark_shadowcolor' => array ( 'title' => 'Watermark Shadow-Color' , 'type' => 'text' , 'data' => 'str' , 'help' => 'Shadow Color of the watermark eg. ffffff ' ), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
2012-11-01 00:34:38 +00:00
'watermark_opacity' => array ( 'title' => 'Watermark Opacity' , 'type' => 'number' , 'data' => 'int' , 'help' => 'Enter a number between 1 and 100' ), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
2012-06-17 11:52:10 +00:00
2012-06-06 07:39:42 +00:00
);
2012-06-17 11:52:10 +00:00
2012-06-06 07:39:42 +00:00
2012-06-17 11:52:10 +00:00
2012-06-06 07:39:42 +00:00
/*
< tr >
2012-11-26 14:41:32 -08:00
< td >
2012-06-06 07:39:42 +00:00
" .IMALAN_1. "
</ td >
2012-11-26 14:41:32 -08:00
< td >
2012-06-06 07:39:42 +00:00
< div class = 'auto-toggle-area autocheck' >
" . $frm->checkbox ('image_post', 1, $pref['image_post'] ). "
< div class = 'field-help' > " .IMALAN_2. " </ div >
</ div >
</ td >
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td >
2012-06-06 07:39:42 +00:00
" .IMALAN_10. "
</ td >
2012-11-26 14:41:32 -08:00
< td >
2012-06-06 07:39:42 +00:00
" .r_userclass('image_post_class', $pref['image_post_class'] , " off " , " public , guest , nobody , member , admin , main , classes " ). "
< div class = 'field-help' > " .IMALAN_11. " </ div >
</ td >
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td >
2012-06-06 07:39:42 +00:00
" .IMALAN_12. "
</ td >
2012-11-26 14:41:32 -08:00
< td >
2012-06-06 07:39:42 +00:00
" . $frm->select_open ('image_post_disabled_method'). "
" . $frm->option (IMALAN_14, '0', ( $pref['image_post_disabled_method'] == " 0 " )). "
" . $frm->option (IMALAN_15, '1', ( $pref['image_post_disabled_method'] == " 1 " )). "
" . $frm->select_close (). "
< div class = 'field-help' > " .IMALAN_13. " </ div >
</ td >
</ tr > " ;
list ( $img_import_w , $img_import_h ) = explode ( " x " , $pref [ 'img_import_resize' ]);
//TODO LANS
$text .= "
< tr >
2012-11-26 14:41:32 -08:00
< td > Resize images during media import < div class = 'label-note' > Leave empty to disable </ div ></ td >
< td >
2012-06-06 07:39:42 +00:00
" . $frm->text ('img_import_resize_w', $img_import_w ,4). " px X " . $frm->text ('img_import_resize_h', $img_import_h ,4). " px
</ td >
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td > " .IMALAN_3. " < div class = 'label-note' > " .IMALAN_54. " { $gd_version } </ div ></ td >
< td >
2012-06-06 07:39:42 +00:00
" . $frm->select_open ('resize_method'). "
" . $frm->option ('gd1', 'gd1', ( $pref['resize_method'] == " gd1 " )). "
" . $frm->option ('gd2', 'gd2', ( $pref['resize_method'] == " gd2 " )). "
" . $frm->option ('ImageMagick', 'ImageMagick', ( $pref['resize_method'] == " ImageMagick " )). "
" . $frm->select_close (). "
< div class = 'field-help' > " .IMALAN_4. " </ div >
</ td >
</ tr > " ;
*/
2009-12-02 10:03:53 +00:00
protected $cats = array ();
2012-04-22 06:19:21 +00:00
protected $owner = array ();
protected $ownercats = array ();
2009-12-02 10:03:53 +00:00
function init ()
{
$sql = e107 :: getDb ();
2012-04-22 06:19:21 +00:00
// $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_owner GROUP BY m.media_category");
$sql -> db_Select_gen ( " SELECT media_cat_title, media_cat_owner, media_cat_category FROM #core_media_cat " );
2009-12-02 10:03:53 +00:00
while ( $row = $sql -> db_Fetch ())
{
2012-04-22 06:19:21 +00:00
$cat = $row [ 'media_cat_category' ];
$owner = $row [ 'media_cat_owner' ];
$this -> owner [ $owner ] = $owner ;
$this -> ownercats [ $owner . '|' . $cat ] = $row [ 'media_cat_title' ];
2010-03-09 16:05:41 +00:00
$this -> cats [ $cat ] = $row [ 'media_cat_title' ];
2009-12-02 10:03:53 +00:00
}
asort ( $this -> cats );
2013-01-09 10:49:33 +02:00
$this -> fields [ 'media_category' ][ 'writeParms' ] = $this -> cats ;
2012-07-12 10:15:12 +00:00
$pref = e107 :: getPref ();
$tp = e107 :: getParser ();
$fl = e107 :: getFile ();
$path = e_THEME . $pref [ 'sitetheme' ] . " /fonts/ " ;
$fDir = $fl -> get_files ( e_THEME . $pref [ 'sitetheme' ] . " /fonts/ " , " .ttf " , '' , 2 );
$fonts = array ( 0 => 'None' );
foreach ( $fDir as $f )
{
$id = $tp -> createConstants ( $f [ 'path' ] . $f [ 'fname' ], 'rel' );
$fonts [ $id ] = $f [ 'fname' ];
}
$this -> prefs [ 'watermark_font' ][ 'writeParms' ] = $fonts ;
$this -> prefs [ 'watermark_font' ][ 'readParms' ] = $fonts ;
$wm_pos = array (
'BR' => " Bottom Right " ,
'BL' => " Bottom Left " ,
'TR' => " Top Right " ,
'TL' => " Top Left " ,
'C' => " Center " ,
'R' => " Right " ,
'L' => " Left " ,
'T' => " Top " ,
'B' => " Bottom " ,
'*' => " Tile "
);
$this -> prefs [ 'watermark_pos' ][ 'writeParms' ] = $wm_pos ;
$this -> prefs [ 'watermark_pos' ][ 'readParms' ] = $wm_pos ;
//FIXME TODO - clear thumbnail cache when prefs are saved/updated.
// e107::getCache()->clearAll('image');
2012-08-04 04:15:41 +00:00
// print_a($_GET);
2012-07-12 10:15:12 +00:00
2012-08-04 04:15:41 +00:00
if ( $_GET [ 'action' ] == 'nav' )
{
//echo $this->navPage();\
// $this->getResponse()->setIframeMod(); // disable header/footer menus etc.
// print_a($_GET);
}
2012-07-12 10:15:12 +00:00
2012-04-28 01:31:30 +00:00
2010-03-09 16:05:41 +00:00
2009-12-02 10:03:53 +00:00
if ( varset ( $_POST [ 'batch_import_selected' ]))
{
$this -> batchImport ();
}
2012-07-18 06:34:26 +00:00
if ( varset ( $_POST [ 'batch_import_delete' ]))
{
$this -> batchDelete ();
}
2011-06-07 13:01:36 +00:00
2012-04-22 07:53:34 +00:00
if ( varset ( $_POST [ 'update_options' ]))
{
$this -> updateSettings ();
}
2012-05-25 11:30:49 +00:00
2012-08-12 00:24:02 +00:00
// filepicker stuff.
2012-07-07 06:04:04 +00:00
if ( $this -> getQuery ( 'mode' ) == 'dialog' ) //TODO Check this actually does something, as it was changed to 'action'.
2012-05-25 11:30:49 +00:00
{
2012-07-07 06:04:04 +00:00
if ( ! ADMIN ){ exit ; }
2012-05-25 11:30:49 +00:00
}
2012-04-22 07:53:34 +00:00
2010-10-04 22:14:05 +00:00
if ( $this -> getQuery ( 'iframe' ))
2012-04-30 10:39:03 +00:00
{
2012-04-28 01:31:30 +00:00
$this -> getResponse () -> setIframeMod (); // disable header/footer menus etc.
2012-08-04 04:15:41 +00:00
2012-04-28 01:31:30 +00:00
if ( ! $this -> getQuery ( 'for' ))
{
$this -> setPosted ( 'media_category' , " _common " );
$this -> getModel () -> set ( 'media_category' , " _common " );
}
elseif ( $this -> getMediaCategory ( $this -> getQuery ( 'for' )))
2010-10-04 22:14:05 +00:00
{
2012-04-28 01:31:30 +00:00
$this -> setPosted ( 'media_category' , $this -> getQuery ( 'for' ));
if ( ! $this -> getId ())
{
$this -> getModel () -> set ( 'media_category' , $this -> getQuery ( 'for' ));
}
2010-10-04 22:14:05 +00:00
}
2012-04-30 10:39:03 +00:00
2010-10-04 22:14:05 +00:00
}
2012-04-28 01:31:30 +00:00
//
// if($this->getQuery('for') && $this->getMediaCategory($this->getQuery('for')))
// {
//
// $this->setPosted('media_category', $this->getQuery('for'));
// if(!$this->getId())
// {
// $this->getModel()->set('media_category', $this->getQuery('for'));
// }
// }
//
2010-10-04 22:14:05 +00:00
}
2009-12-02 10:03:53 +00:00
2012-08-04 04:15:41 +00:00
function navPage () // no functioning correctly - see e_AJAX_REQUEST above.
{
$bbcodeMode = ( $this -> getQuery ( 'bbcode' ) == 'img' ) ? 'bbcode=img' : FALSE ;
if ( $_GET [ 'from' ])
{
$bbcodeMode .= " &from= " . intval ( $_GET [ 'from' ]);
}
$bbcodeMode .= " &nav=1 " ;
$tag = ( $bbcodeMode ) ? " " : $this -> getQuery ( 'tagid' );
echo e107 :: getMedia () -> mediaSelect ( $this -> getQuery ( 'for' ), $this -> getQuery ( 'tagid' ), $bbcodeMode ); // eg. news, news-thumbnail
return ;
}
2012-04-28 01:31:30 +00:00
function dialogPage () // Popup dialogPage for Image Selection.
{
2012-05-25 11:30:49 +00:00
$cat = $this -> getQuery ( 'for' );
$file = ( substr ( $cat , - 5 ) == " _file " ) ? TRUE : FALSE ;
2012-08-12 00:24:02 +00:00
$mes = e107 :: getMessage ();
$mes -> addDebug ( " For: " . $cat );
2012-05-25 11:30:49 +00:00
if ( $file )
{
2012-10-31 20:18:18 +00:00
$cat = e107 :: getParser () -> toDB ( $cat );
2012-08-12 00:24:02 +00:00
if ( ! isset ( $this -> cats [ $cat ]))
{
return ;
}
2012-05-25 11:30:49 +00:00
2012-08-12 00:24:02 +00:00
$this -> listQry = " SELECT m.*,u.user_id,u.user_name FROM #core_media AS m LEFT JOIN #user AS u ON m.media_author = u.user_id WHERE m.media_category = ' " . $cat . " ' " ; // without any Order or Limit.
2012-05-25 11:30:49 +00:00
2012-08-12 00:24:02 +00:00
unset ( $this -> fields [ 'checkboxes' ]);
$this -> fields [ 'options' ][ 'type' ] = 'method' ;
$this -> fields [ 'media_category' ][ 'nolist' ] = true ;
$this -> fields [ 'media_userclass' ][ 'nolist' ] = true ;
$this -> fields [ 'media_dimensions' ][ 'nolist' ] = true ;
$this -> fields [ 'media_description' ][ 'nolist' ] = true ;
$this -> fields [ 'media_type' ][ 'nolist' ] = true ;
foreach ( $this -> fields as $k => $v )
{
$this -> fields [ $k ][ 'filter' ] = false ;
}
echo $this -> mediaSelectUpload ( 'file' );
2012-04-28 01:31:30 +00:00
}
2012-08-12 00:24:02 +00:00
else
{
echo $this -> mediaSelectUpload ();
}
2012-04-28 01:31:30 +00:00
}
2012-05-22 13:32:49 +00:00
2012-08-04 04:15:41 +00:00
2012-05-22 13:32:49 +00:00
function uploadPage ()
{
2012-07-07 06:04:04 +00:00
if ( ! ADMIN ){ exit ; } //TODO check for upload-access in perms.
2012-10-31 20:18:18 +00:00
2012-07-18 06:34:26 +00:00
// if 'for' has no value, files are placed in /temp and not added to the db.
2012-07-01 00:56:59 +00:00
$text = '<div id="uploader" rel="' . e_JS . 'plupload/upload.php?for=' . $this -> getQuery ( 'for' ) . ' " >
2012-05-22 13:32:49 +00:00
< p > No HTML5 support .</ p >
</ div > ' ;
return $text ;
}
2012-04-28 01:31:30 +00:00
2012-08-12 00:24:02 +00:00
function mediaSelectUpload ( $type = 'image' )
2012-04-28 01:31:30 +00:00
{
2012-04-30 10:39:03 +00:00
$frm = e107 :: getForm ();
2012-07-11 04:46:09 +00:00
$bbcodeMode = ( $this -> getQuery ( 'bbcode' ) == 'img' ) ? 'bbcode=img' : FALSE ;
2012-07-23 02:25:17 +00:00
2012-04-28 01:31:30 +00:00
$text = "
2013-02-25 02:47:23 -08:00
< ul class = 'nav nav-tabs' >
< li class = 'active' >< a data - toggle = 'tab' href = '#core-media-select' > Choose from Library </ a ></ li >
< li >< a data - toggle = 'tab' href = '#core-media-upload' > Upload a File </ a ></ li > " ;
2012-04-30 10:39:03 +00:00
if ( $bbcodeMode )
{
2013-02-25 02:47:23 -08:00
$text .= " <li><a data-toggle='tab' href='#core-media-style'>Appearance</a></li> \n " ;
2012-04-30 10:39:03 +00:00
}
2012-05-24 07:24:49 +00:00
if ( $_GET [ 'from' ])
{
$bbcodeMode .= " &from= " . intval ( $_GET [ 'from' ]);
}
2012-04-30 10:39:03 +00:00
$text .= "
2012-04-28 01:31:30 +00:00
</ ul >
2013-02-25 02:47:23 -08:00
< div class = 'tab-content' >
< div class = 'tab-pane active' id = 'core-media-select' >
2012-04-28 01:31:30 +00:00
< legend > Library </ legend >
2012-11-30 13:47:06 -08:00
< div class = 'table' style = 'display:block; height:500px' >
2012-04-29 11:15:44 +00:00
" ;
2012-07-07 22:04:49 +00:00
$tag = ( $bbcodeMode ) ? " " : $this -> getQuery ( 'tagid' );
2012-04-28 01:31:30 +00:00
2012-08-12 00:24:02 +00:00
if ( $type == 'file' )
{
2012-10-31 20:18:18 +00:00
$this -> perPage = 0 ;
$this -> getTreeModel () -> setParam ( 'db_query' , $this -> _modifyListQry ( false , false , false , false , $this -> listQry )) -> load ();
$text .= $this -> getUI () -> getList ();
2012-08-12 00:24:02 +00:00
}
else
{
$text .= e107 :: getMedia () -> mediaSelect ( $this -> getQuery ( 'for' ), $this -> getQuery ( 'tagid' ), $bbcodeMode ); // eg. news, news-thumbnail
}
2012-04-28 01:31:30 +00:00
2012-04-29 11:15:44 +00:00
$text .= "
2012-11-30 13:47:06 -08:00
</ div >
2013-02-25 02:47:23 -08:00
</ div >
2012-04-28 01:31:30 +00:00
2013-02-25 02:47:23 -08:00
< div class = 'tab-pane' id = 'core-media-upload' >
2012-04-28 01:31:30 +00:00
< legend > Upload </ legend > " ;
$this -> fields [ 'media_category' ][ 'readonly' ] = TRUE ;
$this -> fields [ 'media_url' ][ 'noedit' ] = TRUE ;
$this -> fields [ 'media_userclass' ][ 'noedit' ] = TRUE ;
2012-05-25 11:30:49 +00:00
$text .= $this -> uploadPage (); // To test upload script with plupload
// $text .= $this->CreatePage(); // comment me out to test plupload
2012-04-28 01:31:30 +00:00
$text .= "
2013-02-25 02:47:23 -08:00
</ div > " ;
2012-04-30 10:39:03 +00:00
/* In BBCODE - Mode this dialog rerturns an [ img ] bbcode to the 'tagid' container with the appropriate parms generated .
* eg . [ img style = float : left ; margin - right : 3 px ]{ e_MEDIA_IMAGE } someimage . jpg [ / img ]
* Then the dialog may be used as a bbcode img popup and within TinyMce also .
*
*/
if ( $bbcodeMode )
{
2013-02-25 02:55:41 -08:00
$text .= " <div class='tab-pane' id='core-media-style'>
2012-04-30 10:39:03 +00:00
< legend > Appearance </ legend >
2012-11-27 14:32:40 -08:00
< table class = 'table adminform' >
2012-05-13 05:50:32 +00:00
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
2012-04-30 10:39:03 +00:00
</ colgroup >
< tbody >
< tr >
< td > Dimensions : </ td >
< td >
2012-05-24 07:24:49 +00:00
< input type = 'text' class = 'e-media-attribute' id = 'width' name = 'width' size = '4' style = 'width:50px' value = '' /> px
X < input type = 'text' class = 'e-media-attribute' id = 'height' name = 'height' size = '4' style = 'width:50px' value = '' /> px
2012-04-30 10:39:03 +00:00
</ td >
</ tr >
< tr >
< td > Text flow : </ td >
2013-02-21 12:21:42 +02:00
< td > " . $frm->selectbox ('float', array('default'=>'Default','left'=> " Left " ,'right'=>'Right')). " </ td >
2012-04-30 10:39:03 +00:00
</ tr >
< tr >
< td > Margin - Left : </ td >
2012-05-24 07:24:49 +00:00
< td >< input class = 'e-media-attribute' type = 'text' id = 'margin-left' name = 'margin_left' value = '' /></ td >
2012-04-30 10:39:03 +00:00
</ tr >
< tr >
< td > Margin - Right : </ td >
2012-05-24 07:24:49 +00:00
< td >< input class = 'e-media-attribute' type = 'text' id = 'margin-right' name = 'margin_right' value = '' /></ td >
2012-04-30 10:39:03 +00:00
</ tr >
< tr >
< td > Margin - Top : </ td >
2012-05-24 07:24:49 +00:00
< td >< input class = 'e-media-attribute' type = 'text' id = 'margin-top' name = 'margin_top' value = '' /></ td >
2012-04-30 10:39:03 +00:00
</ tr >
< tr >
< td > Margin - Bottom : </ td >
2012-05-24 07:24:49 +00:00
< td >< input class = 'e-media-attribute' type = 'text' id = 'margin-bottom' name = 'margin_bottom' value = '' /></ td >
2012-04-30 10:39:03 +00:00
</ tr >
</ tbody ></ table >
2012-04-30 20:35:59 +00:00
< table >< tr >< td > Preview < br /></ td ></ tr >
< tr >< td style = 'text-align:center' >
< img id = 'preview' src = '".e_IMAGE_ABS."generic/blank.gif' style = 'border:1px solid silver; min-width:220px; min-height:180px;' />
</ td ></ tr ></ table >
2013-02-25 02:55:41 -08:00
</ div > " ;
2012-04-30 10:39:03 +00:00
}
$text .= " </div> " ;
// For BBCODE mode. //TODO image-float.
if ( $bbcodeMode )
{
2012-05-24 07:24:49 +00:00
2012-04-30 10:39:03 +00:00
$text .= " <div style='text-align:right;padding:5px'>
2012-11-26 15:43:42 -08:00
< button type = 'submit' class = 'btn btn-success submit e-dialog-save e-dialog-close' data - target = '".$this->getQuery(' tagid ')."' name = 'save_image' value = 'Save it' >
2012-07-07 06:04:04 +00:00
< span > Save </ span >
2012-04-30 10:39:03 +00:00
</ button >
2012-11-26 15:43:42 -08:00
< button type = 'submit' class = 'btn submit e-dialog-close' name = 'cancel_image' value = 'Cancel' >
2012-04-30 10:39:03 +00:00
< span > Cancel </ span >
</ button >
</ div > " ;
2012-05-24 07:24:49 +00:00
// TODO to eventually be hidden.
2012-08-04 04:26:05 +00:00
$text .= " bbcode: <input title='bbcode' type='text' readonly='readonly' style='border:0px; width:700px' id='bbcode_holder' name='bbcode_holder' value='' />
< input title = 'html' type = 'hidden' style = 'width:800px' id = 'html_holder' name = 'html_holder' value = '' />
< input title = 'src' type = 'hidden' style = 'width:600px' id = 'src' name = 'src' value = '' />
< input title = 'path' type = 'hidden' style = 'width:600px' id = 'path' name = 'path' value = '' />
2012-05-24 07:24:49 +00:00
" ;
2012-04-30 10:39:03 +00:00
}
2012-04-28 01:31:30 +00:00
return $text ;
}
2009-12-02 10:03:53 +00:00
function importPage ()
{
2010-03-09 16:05:41 +00:00
$this -> batchImportForm ();
2009-12-02 10:03:53 +00:00
}
2010-03-09 16:05:41 +00:00
2009-12-02 10:03:53 +00:00
function settingsPage ()
{
2012-06-02 08:12:16 +00:00
global $pref ;
$frm = e107 :: getForm ();
$tp = e107 :: getParser ();
$sql = e107 :: getDb ();
$ns = e107 :: getRender ();
$mes = e107 :: getMessage ();
if ( function_exists ( 'gd_info' ))
{
$gd_info = gd_info ();
$gd_version = $gd_info [ 'GD Version' ];
}
else
{
$gd_version = " <span class='error'> " . IMALAN_55 . " </span> " ;
}
if ( $pref [ 'resize_method' ] == " ImageMagick " && ( ! vartrue ( e107 :: getFolder ( 'imagemagick' ))))
{
$mes -> addWarning ( 'Please add: <b>$IMAGEMAGICK_DIRECTORY="' . $pref [ 'im_path' ] . '";</b> to your e107_config.php file' );
}
//$IM_NOTE = "";
$im_path = vartrue ( e107 :: getFolder ( 'imagemagick' ));
if ( $im_path != " " )
{
$im_file = $im_path . 'convert' ;
if ( ! file_exists ( $im_file ))
{
//$IM_NOTE = "<span class='error'>".IMALAN_52."</span>";
$mes -> addWarning ( IMALAN_52 );
}
else
{
$cmd = " { $im_file } -version " ;
$tmp = `$cmd` ;
if ( strpos ( $tmp , " ImageMagick " ) === FALSE )
{
//$IM_NOTE = "<span class='error'>".IMALAN_53."</span>";
$mes -> addWarning ( IMALAN_53 );
}
}
}
$text = "
< form method = 'post' action = '".e_SELF."?".e_QUERY."' >
< fieldset id = 'core-image-settings' >
< legend class = 'e-hideme' > " .IMALAN_7. " </ legend >
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' >
2012-06-02 08:12:16 +00:00
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
< tr >
2012-11-26 14:41:32 -08:00
< td >
2012-06-02 08:12:16 +00:00
" .IMALAN_1. "
</ td >
2012-11-26 14:41:32 -08:00
< td >
2012-06-02 08:12:16 +00:00
< div class = 'auto-toggle-area autocheck' >
" . $frm->checkbox ('image_post', 1, $pref['image_post'] ). "
< div class = 'field-help' > " .IMALAN_2. " </ div >
</ div >
</ td >
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td >
2012-06-02 08:12:16 +00:00
" .IMALAN_10. "
</ td >
2012-11-26 14:41:32 -08:00
< td >
2012-06-02 08:12:16 +00:00
" .r_userclass('image_post_class', $pref['image_post_class'] , " off " , " public , guest , nobody , member , admin , main , classes " ). "
< div class = 'field-help' > " .IMALAN_11. " </ div >
</ td >
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td >
2012-06-02 08:12:16 +00:00
" .IMALAN_12. "
</ td >
2012-11-26 14:41:32 -08:00
< td >
2012-06-02 08:12:16 +00:00
" . $frm->select_open ('image_post_disabled_method'). "
" . $frm->option (IMALAN_14, '0', ( $pref['image_post_disabled_method'] == " 0 " )). "
" . $frm->option (IMALAN_15, '1', ( $pref['image_post_disabled_method'] == " 1 " )). "
" . $frm->select_close (). "
< div class = 'field-help' > " .IMALAN_13. " </ div >
</ td >
</ tr > " ;
list ( $img_import_w , $img_import_h ) = explode ( " x " , $pref [ 'img_import_resize' ]);
//TODO LANS
$text .= "
< tr >
2012-11-26 14:41:32 -08:00
< td > Resize images during media import < div class = 'label-note' > Leave empty to disable </ div ></ td >
< td >
2012-06-02 08:12:16 +00:00
" . $frm->text ('img_import_resize_w', $img_import_w ,4). " px X " . $frm->text ('img_import_resize_h', $img_import_h ,4). " px
</ td >
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td > " .IMALAN_3. " < div class = 'label-note' > " .IMALAN_54. " { $gd_version } </ div ></ td >
< td >
2012-06-02 08:12:16 +00:00
" . $frm->select_open ('resize_method'). "
" . $frm->option ('gd1', 'gd1', ( $pref['resize_method'] == " gd1 " )). "
" . $frm->option ('gd2', 'gd2', ( $pref['resize_method'] == " gd2 " )). "
" . $frm->option ('ImageMagick', 'ImageMagick', ( $pref['resize_method'] == " ImageMagick " )). "
" . $frm->select_close (). "
< div class = 'field-help' > " .IMALAN_4. " </ div >
</ td >
</ tr > " ;
/*
$text .= "
// Removed to prevent mod_security blocks, and show only when relevant (non-GD2 users)
< tr >
2012-11-26 14:41:32 -08:00
< td > " .IMALAN_5. " < div class = 'label-note' > { $IM_NOTE } </ div ></ td >
< td >
2012-06-02 08:12:16 +00:00
" . $frm->text ('im_path', $pref['im_path'] ). "
< div class = 'field-help' > " .IMALAN_6. " </ div >
</ td >
</ tr > " ;
// Removed as IE6 should no longer be supported. A 3rd-party plugin can be made for this functionality if really needed.
$text .= "
< tr >
2012-11-26 14:41:32 -08:00
< td > " .IMALAN_34. "
2012-06-02 08:12:16 +00:00
</ td >
2012-11-26 14:41:32 -08:00
< td >
2012-06-02 08:12:16 +00:00
< div class = 'auto-toggle-area autocheck' >
" . $frm->checkbox ('enable_png_image_fix', 1, ( $pref['enable_png_image_fix'] )). "
< div class = 'field-help' > " .IMALAN_35. " </ div >
</ div >
</ td >
</ tr > " ;
*/
$text .= "
< tr >
2012-11-26 14:41:32 -08:00
< td > " .IMALAN_36. " </ td >
< td >
2012-06-02 08:12:16 +00:00
" . $frm->admin_button ('check_avatar_sizes', ADLAN_145). "
</ td >
</ tr >
</ tbody >
</ table >
< div class = 'buttons-bar center' >
" . $frm->admin_button ('update_options', IMALAN_8, 'update'). "
</ div >
</ fieldset >
</ form > " ;
echo $mes -> render () . $text ;
return ;
// $ns->tablerender(LAN_MEDIAMANAGER." :: ".IMALAN_7, $mes->render().$text);
2009-12-02 10:03:53 +00:00
}
2010-03-09 16:05:41 +00:00
2009-12-02 10:03:53 +00:00
function avatarPage ()
{
show_avatars ();
}
2010-03-09 16:05:41 +00:00
2009-12-02 10:03:53 +00:00
function iconsPage ()
{
2010-03-14 02:11:23 +00:00
// $this->icon_editor();
2009-12-02 10:03:53 +00:00
}
2010-03-09 16:05:41 +00:00
2009-11-15 20:24:55 +00:00
/**
* Invoked just before item create event
* @ return array
*/
2009-11-17 15:23:01 +00:00
public function beforeCreate ( $new_data )
2009-11-15 20:24:55 +00:00
{
2012-04-28 01:31:30 +00:00
// print_a($_POST);
2009-11-15 20:24:55 +00:00
// return data to be merged with posted model data
2009-11-18 07:16:51 +00:00
$this -> getRequest () -> setPosted ( 'media_upload' , null );
2009-11-18 14:46:28 +00:00
//$dataFields = $this->getModel()->getDataFields();
//unset($dataFields['media_upload']);
2010-10-04 16:01:17 +00:00
//$this->getModel()->setDataFields($dataFields);
2010-10-04 22:14:05 +00:00
if ( $this -> getQuery ( 'for' ) && $this -> getMediaCategory ( $this -> getQuery ( 'for' )))
{
$new_data [ 'media_category' ] = $this -> getQuery ( 'for' );
}
2009-11-18 09:53:39 +00:00
return $this -> observeUploaded ( $new_data );
2009-11-15 20:24:55 +00:00
}
2010-03-09 16:05:41 +00:00
2009-11-15 20:24:55 +00:00
/**
2010-03-09 16:05:41 +00:00
* Same as beforeCreate () but invoked on edit
2009-12-13 21:52:32 +00:00
* @ return TBD
2009-11-15 20:24:55 +00:00
*/
2009-11-17 15:23:01 +00:00
public function beforeUpdate ( $new_data , $old_data , $id )
2009-11-15 20:24:55 +00:00
{
// return data to be merged with posted model data
2012-08-02 02:11:22 +00:00
// $new_data['media_category'] = implode(",",$new_data['media_category']);
$this -> fields [ 'media_category' ][ 'data' ] = 'str' ; //XXX Quick fix for 'comma' incompatibility in Db-Update routines.
2012-05-23 08:29:57 +00:00
return $new_data ;
2012-08-02 02:11:22 +00:00
// return $this->observeUploaded($new_data);
2009-11-15 20:24:55 +00:00
}
2011-06-07 13:01:36 +00:00
2010-10-04 16:01:17 +00:00
public function mediaData ( $sc_path )
{
if ( ! $sc_path ) return array ();
$path = e107 :: getParser () -> replaceConstants ( $sc_path );
2012-05-17 09:19:44 +00:00
$info = e107 :: getFile () -> get_file_info ( $path , true );
2011-06-07 13:01:36 +00:00
return array (
2010-10-04 16:01:17 +00:00
'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' ]
);
}
2010-03-09 16:05:41 +00:00
2009-11-18 14:46:28 +00:00
// XXX - strict mysql error on Create without UPLOAD!
2009-11-18 09:53:39 +00:00
function observeUploaded ( $new_data )
2009-11-15 20:24:55 +00:00
{
2009-12-02 10:03:53 +00:00
$fl = e107 :: getFile ();
2010-03-09 16:05:41 +00:00
2009-11-18 07:16:51 +00:00
$mes = e107 :: getMessage ();
2011-06-07 13:01:36 +00:00
2012-04-28 01:31:30 +00:00
if ( vartrue ( $_FILES [ 'file_userfile' ])) // CREATE
2009-11-15 20:24:55 +00:00
{
2012-04-27 02:02:38 +00:00
2010-10-04 16:01:17 +00:00
$pref [ 'upload_storagetype' ] = " 1 " ;
require_once ( e_HANDLER . " upload_handler.php " ); //TODO - still not a class!
2012-11-12 21:46:10 +00:00
// $uploaded = process_uploaded_files(e_MEDIA.'temp/'); //FIXME doesn't handle xxx.JPG (uppercase)
$uploaded = process_uploaded_files ( e_TEMP ); //FIXME doesn't handle xxx.JPG (uppercase)
2010-10-04 16:01:17 +00:00
$upload = array_shift ( $uploaded );
2009-11-18 07:16:51 +00:00
if ( vartrue ( $upload [ 'error' ]))
2010-03-09 16:05:41 +00:00
{
2012-04-28 01:31:30 +00:00
$mes -> addError ( $upload [ 'message' ]);
2012-04-27 02:02:38 +00:00
return FALSE ;
}
2011-06-07 13:01:36 +00:00
2010-10-04 16:01:17 +00:00
if ( ! $typePath = $this -> getPath ( $upload [ 'type' ]))
{
2012-04-28 01:31:30 +00:00
$mes -> addError ( " Couldn't generated path from upload data " );
2010-10-04 16:01:17 +00:00
return FALSE ;
}
2012-04-28 01:31:30 +00:00
$mes -> addDebug ( print_a ( $upload , TRUE ));
2011-06-07 13:01:36 +00:00
2012-11-12 21:46:10 +00:00
// $oldpath = e_MEDIA."temp/".$upload['name'];
$oldpath = e_TEMP . $upload [ 'name' ];
2012-04-28 01:31:30 +00:00
$newpath = $this -> checkDupe ( $oldpath , $typePath . '/' . $upload [ 'name' ]);
2011-06-07 13:01:36 +00:00
2012-04-28 01:31:30 +00:00
if ( ! rename ( $oldpath , e_MEDIA . $newpath ))
2010-10-04 16:01:17 +00:00
{
$mes -> add ( " Couldn't move file from " . $oldpath . " to " . $newpath , E_MESSAGE_ERROR );
return FALSE ;
};
2011-06-07 13:01:36 +00:00
2012-04-28 01:31:30 +00:00
$img_data = $this -> mediaData ( $newpath ); // Basic File Info only
$img_data [ 'media_name' ] = $new_data [ 'name' ];
$img_data [ 'media_caption' ] = $new_data [ 'media_caption' ];
$img_data [ 'media_category' ] = $new_data [ 'media_category' ];
$img_data [ 'media_description' ] = $new_data [ 'media_description' ];
$img_data [ 'media_tags' ] = $new_data [ 'media_tags' ];
$img_data [ 'media_userclass' ] = 0 ;
$img_data [ 'media_author' ] = USERID ;
if ( ! varset ( $img_data [ 'media_name' ]))
2010-10-04 16:01:17 +00:00
{
$img_data [ 'media_name' ] = $upload [ 'name' ];
2012-04-28 01:31:30 +00:00
}
2012-04-27 02:02:38 +00:00
$mes -> addDebug ( print_a ( $img_data , TRUE ));
2012-04-28 01:31:30 +00:00
return $img_data ;
2010-10-04 16:01:17 +00:00
}
2012-04-28 01:31:30 +00:00
else // Update Only ?
2010-10-04 16:01:17 +00:00
{
2012-05-23 08:29:57 +00:00
2010-10-04 16:01:17 +00:00
$img_data = $this -> mediaData ( $new_data [ 'media_url' ]);
2011-06-07 13:01:36 +00:00
2010-10-04 16:01:17 +00:00
if ( ! ( $typePath = $this -> getPath ( $img_data [ 'media_type' ])))
{
2012-04-27 02:02:38 +00:00
$mes -> addError ( " Couldn't get path " . $typePath );
2009-11-18 09:53:39 +00:00
return FALSE ;
}
2012-04-27 02:02:38 +00:00
2010-10-04 16:01:17 +00:00
$fname = basename ( $new_data [ 'media_url' ]);
// move to the required place
2012-11-12 21:46:10 +00:00
if ( strpos ( $new_data [ 'media_url' ], '{e_TEMP}' ) !== FALSE )
// if(strpos($new_data['media_url'], '{e_MEDIA}temp/') !== FALSE)
2009-11-18 09:53:39 +00:00
{
2010-10-04 16:01:17 +00:00
$tp = e107 :: getParser ();
$oldpath = $tp -> replaceConstants ( $new_data [ 'media_url' ]);
2012-04-28 01:31:30 +00:00
$newpath = $this -> checkDupe ( $oldpath , $typePath . '/' . $fname );
2010-10-04 16:01:17 +00:00
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' );
2009-11-18 07:16:51 +00:00
}
2011-06-07 13:01:36 +00:00
2009-11-18 09:53:39 +00:00
if ( ! varset ( $new_data [ 'media_name' ]))
{
2010-10-04 16:01:17 +00:00
$img_data [ 'media_name' ] = basename ( $new_data [ 'media_url' ]);
2009-11-18 09:53:39 +00:00
}
2012-04-28 01:31:30 +00:00
return $img_data ;
2009-11-15 20:24:55 +00:00
}
2012-04-27 02:02:38 +00:00
2012-04-28 01:31:30 +00:00
2009-11-15 20:24:55 +00:00
}
2010-03-09 16:05:41 +00:00
2012-04-28 01:31:30 +00:00
// Check for existing image path in db and rename if found.
function checkDupe ( $oldpath , $newpath )
{
$mes = e107 :: getMessage ();
$tp = e107 :: getParser ();
$f = e107 :: getFile () -> get_file_info ( $oldpath , TRUE );
2012-07-14 10:40:40 +00:00
$mes -> addDebug ( " checkDupe(): newpath= " . $newpath . " <br />oldpath= " . $oldpath . " <br /> " . print_r ( $upload , TRUE ));
2012-07-12 01:43:38 +00:00
if ( file_exists ( $newpath ) || e107 :: getDb () -> db_Select ( " core_media " , " * " , " media_url = ' " . $tp -> createConstants ( $newpath , 'rel' ) . " ' LIMIT 1 " ) )
2012-04-28 01:31:30 +00:00
{
2012-07-18 06:34:26 +00:00
$mes -> addWarning ( $newpath . " already exists. " );
2012-04-28 01:31:30 +00:00
$file = $f [ 'pathinfo' ][ 'filename' ] . " _. " . $f [ 'pathinfo' ][ 'extension' ];
2012-07-18 06:34:26 +00:00
$newpath = $this -> getPath ( $f [ 'mime' ]) . '/' . $file ;
return false ;
2012-04-28 01:31:30 +00:00
}
return $newpath ;
}
2009-11-17 15:23:01 +00:00
function beforeDelete ( $data , $id ) // call before 'delete' is executed. - return false to prevent delete execution (e.g. some dependencies check)
2009-11-15 20:24:55 +00:00
{
return true ;
}
2010-03-09 16:05:41 +00:00
2009-11-17 15:23:01 +00:00
function afterDelete ( $deleted_data , $id ) // call after 'delete' is successfully executed. - delete the file with the db record (optional pref)
2009-11-15 20:24:55 +00:00
{
2010-03-09 16:05:41 +00:00
2009-11-15 20:24:55 +00:00
}
2010-03-09 16:05:41 +00:00
2012-04-23 20:24:24 +00:00
function getPath ( $mime )
2009-11-15 20:24:55 +00:00
{
2009-11-18 07:16:51 +00:00
$mes = e107 :: getMessage ();
2010-03-09 16:05:41 +00:00
2009-12-02 10:03:53 +00:00
list ( $pmime , $tmp ) = explode ( '/' , $mime );
2010-03-09 16:05:41 +00:00
2009-11-18 07:16:51 +00:00
if ( ! vartrue ( $this -> mimePaths [ $pmime ]))
2010-03-09 16:05:41 +00:00
{
2010-10-10 22:08:57 +00:00
$mes -> add ( " Couldn't detect mime-type( $mime ). Upload failed. " , E_MESSAGE_ERROR );
2009-11-18 07:16:51 +00:00
return FALSE ;
}
2010-03-09 16:05:41 +00:00
2012-04-23 20:24:24 +00:00
$dir = $this -> mimePaths [ $pmime ] . date ( " Y-m " );
2009-11-18 07:16:51 +00:00
2012-04-23 20:24:24 +00:00
if ( ! is_dir ( $dir ))
2009-11-15 20:24:55 +00:00
{
2011-05-07 06:22:44 +00:00
if ( ! mkdir ( $dir , 0755 ))
2009-11-18 10:16:50 +00:00
{
$mes -> add ( " Couldn't create folder ( $dir ). " , E_MESSAGE_ERROR );
2010-03-09 16:05:41 +00:00
return FALSE ;
2009-11-18 10:16:50 +00:00
};
2009-11-15 20:24:55 +00:00
}
2010-03-09 16:05:41 +00:00
return $dir ;
2009-11-15 20:24:55 +00:00
}
2010-03-09 16:05:41 +00:00
2009-12-02 10:03:53 +00:00
function batchImportForm ()
{
$frm = e107 :: getForm ();
$mes = e107 :: getMessage ();
$fl = e107 :: getFile ();
2010-03-09 16:05:41 +00:00
2009-12-02 10:03:53 +00:00
$fl -> setFileInfo ( 'all' );
2012-07-12 01:43:38 +00:00
$rejectArray = array ( '^\.ftpquota$' , '^index\.html$' , '^null\.txt$' , '\.bak$' , '^.tmp' , '.*\.xml$' , '^\.$' , '^\.\.$' , '^\/$' , '^CVS$' , 'thumbs\.db' , '.*\._$' , '^\.htaccess$' , 'index\.html' , 'null\.txt' );
2012-07-13 06:32:42 +00:00
$fl -> setFileFilter ( $rejectArray );
2012-11-12 21:46:10 +00:00
// $files = $fl->get_files(e_MEDIA."temp/");
$files = $fl -> get_files ( e_TEMP );
2012-07-12 01:43:38 +00:00
2013-02-25 02:47:23 -08:00
// e107::js('core','core/admin.js','prototype');
2012-07-12 01:43:38 +00:00
2010-03-09 16:05:41 +00:00
2009-12-02 10:03:53 +00:00
//TODO Detect XML file, and if found - read that instead of the directory.
if ( ! vartrue ( $_POST [ 'batch_import_selected' ]))
{
2012-07-18 06:34:26 +00:00
$mes -> add ( " Scanning for new media (images, videos, files) in folder: <b> " . e_UPLOAD . " </b> " , E_MESSAGE_INFO );
2009-12-02 10:03:53 +00:00
}
2012-07-18 06:34:26 +00:00
if ( ! count ( $files ))
2009-12-02 10:03:53 +00:00
{
2012-07-18 06:34:26 +00:00
if ( ! vartrue ( $_POST [ 'batch_import_selected' ]))
{
$mes -> add ( " No media Found! Please upload some files. " , E_MESSAGE_INFO );
}
$text = $this -> uploadPage ();
echo $mes -> render () . $text ;
2010-03-09 16:05:41 +00:00
return ;
2009-12-02 10:03:53 +00:00
}
2010-03-09 16:05:41 +00:00
2009-12-02 10:03:53 +00:00
$text = "
< form method = 'post' action = '".e_SELF."?".e_QUERY."' id = 'batch_import' >
< fieldset id = 'core-mediamanager-batch' >
< legend class = 'e-hideme' > " .DBLAN_20. " </ legend >
2012-11-26 14:41:32 -08:00
< table class = 'table adminlist' >
2012-05-16 03:10:56 +00:00
< colgroup >
2012-05-13 05:50:32 +00:00
< col style = 'width: 5%' />
< col />
< col />
< col />
2009-12-02 10:03:53 +00:00
</ colgroup >
< thead >
< tr >
2010-10-04 16:01:17 +00:00
< th class = 'center' > " .e107::getForm()->checkbox_toggle('e-column-toggle', 'batch_selected'). " </ th >
2009-12-02 10:03:53 +00:00
< th class = 'center' style = 'width:50px' > Preview </ th >
2011-05-07 06:22:44 +00:00
< th class = 'center' > " .LAN_FILE. " </ th >
2012-07-14 10:40:40 +00:00
< th > Title ( internal use ) </ th >
< th > Caption ( seen by public ) </ th >
2012-07-12 01:43:38 +00:00
< th > Author </ th >
2010-03-09 16:05:41 +00:00
< th > Mime Type </ th >
2009-12-02 10:03:53 +00:00
< th > File Size </ th >
< th > " .LAN_DATESTAMP. " </ th >
< th class = 'center last' > Dimensions </ th >
</ tr >
</ thead >
< tbody > " ;
2012-04-22 06:19:21 +00:00
2012-09-03 23:02:45 +00:00
// $c = 0;
2009-12-02 10:03:53 +00:00
foreach ( $files as $f )
{
2012-07-12 01:43:38 +00:00
$default = $this -> getFileXml ( $f [ 'fname' ]);
2012-07-14 10:40:40 +00:00
$f = $fl -> cleanFileName ( $f , true );
2012-09-03 23:02:45 +00:00
$c = md5 ( $f [ 'path' ] . $f [ 'fname' ]);
2012-07-14 10:40:40 +00:00
if ( $f [ 'error' ])
{
$mes -> addWarning ( $f [ 'fname' ] . " couldn't be renamed. Check file perms. " );
}
2012-08-19 02:33:43 +00:00
$large = e107 :: getParser () -> thumbUrl ( $f [ 'path' ] . $f [ 'fname' ], 'w=800' , true );
2012-04-22 07:53:34 +00:00
$text .= "
< tr >
< td class = 'center' > " . $frm->checkbox ( " batch_selected [ " . $c . " ] " , $f['fname'] ). " </ td >
2012-04-22 06:19:21 +00:00
< td class = 'center' > " . $this->preview ( $f ). " </ td >
2012-08-19 02:33:43 +00:00
< td >< a class = 'e-dialog' href = '".$large."' > " . $f['fname'] . " </ a ></ td >
2012-07-12 01:43:38 +00:00
< td > " . $frm->text ('batch_import_name['. $c .']', ( $_POST['batch_import_name'] [ $c ] ? $_POST['batch_import_name'] [ $c ] : $default['title'] )). " </ td >
2012-07-18 06:34:26 +00:00
< 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 >
2012-07-12 01:43:38 +00:00
2012-09-03 23:02:45 +00:00
< td >< a href = 'mailto:".$default[' authorEmail ']."' > " . $default['authorName'] . " </ a >< br /> " . $default['authorEmail'] . " </ td >
2009-12-02 10:03:53 +00:00
< td > " . $f['mime'] . " </ td >
< td > " . $f['fsize'] . " </ td >
< td > " .e107::getDateConvert()->convert_date( $f['modified'] ). " </ td >
2010-03-09 16:05:41 +00:00
< td class = 'center last' > " . $f['img-width'] . " x " . $f['img-height'] . " </ td >
2012-04-22 07:53:34 +00:00
</ tr >
2012-09-03 23:02:45 +00:00
\n " ;
2012-04-22 07:53:34 +00:00
2012-09-03 23:02:45 +00:00
// $c++;
2012-07-18 06:34:26 +00:00
$lastMime = $f [ 'mime' ];
2010-03-09 16:05:41 +00:00
}
2012-07-12 01:43:38 +00:00
// <td>".$frm->textarea('batch_import_diz['.$c.']', ($_POST['batch_import_diz'][$c] ? $_POST['batch_import_diz'][$c] : $default['description']))."</td>
2009-12-02 10:03:53 +00:00
2012-07-18 06:34:26 +00:00
if ( ! isset ( $_POST [ 'batch_category' ]) && substr ( $lastMime , 0 , 5 ) == 'image' )
{
$_POST [ 'batch_category' ] = " _common_image " ;
}
2009-12-02 10:03:53 +00:00
$text .= "
</ tbody >
</ table >
< div class = 'buttons-bar center' >
2012-07-18 06:34:26 +00:00
Import into Category : " . $frm->selectbox ('batch_category', $this->cats , $_POST['batch_category'] );
2011-08-23 02:51:56 +00:00
2012-07-18 06:34:26 +00:00
// $waterMarkPath = e_THEME.e107::getPref('sitetheme')."/images/watermark.png"; // Now performed site-wide dynamically.
2011-08-23 02:51:56 +00:00
if ( is_readable ( $waterMarkPath ))
{
2012-07-14 10:40:40 +00:00
// $text .= $frm->checkbox_label("Add Watermark", 'batch_import_watermark',1);
2011-08-23 02:51:56 +00:00
}
$text .= "
2009-12-02 10:03:53 +00:00
</ div >
< div class = 'buttons-bar center' >
2012-07-18 06:34:26 +00:00
" . $frm->admin_button ('batch_import_selected', " Import Selected Files " , 'import')
. $frm -> admin_button ( 'batch_import_delete' , " Delete Selected Files " , 'delete' );
2011-08-23 02:51:56 +00:00
$text .= "
2009-12-02 10:03:53 +00:00
</ div >
</ fieldset >
</ form >
2010-03-09 16:05:41 +00:00
2009-12-02 10:03:53 +00:00
" ;
2010-03-09 16:05:41 +00:00
2009-12-02 10:03:53 +00:00
echo $mes -> render () . $text ;
}
2010-03-09 16:05:41 +00:00
2012-07-12 01:43:38 +00:00
// Check for matching XML file name and if found, return data from it during import.
function getFileXml ( $imgFile )
{
list ( $file , $ext ) = explode ( " . " , $imgFile );
$xmlFile = e_UPLOAD . $file . " .xml " ;
if ( is_readable ( $xmlFile ))
{
$data = file_get_contents ( $xmlFile );
$tmp = preg_match ( " /<author name=(?:'| \" )([^' \" ]*)/i " , $data , $authorName );
$tmp = preg_match ( " /email=(?:'| \" )([^' \" ]*)/i " , $data , $authorEmail );
$tmp = preg_match ( " /<title>(.*)< \ /title>/i " , $data , $title );
$tmp = preg_match ( " /<description>(.*)< \ /description>/i " , $data , $diz );
return array (
'title' => $title [ 1 ],
'description' => $diz [ 1 ],
'authorName' => $authorName [ 1 ],
'authorEmail' => $authorEmail [ 1 ]
);
}
return array ( 'title' => basename ( $file ), 'description' => '' , 'authorName' => '' , 'authorEmail' => '' );
/*
Example : matchingfilename . xml ( ie . same name as jpg |. gif |. png etc )
< ? xml version = '1.0' encoding = 'utf-8' ?>
< e107Media >
< item file = 'filename.jpg' date = '2012-10-25' >
< author name = 'MyName' url = 'http://mysite.com' email = 'email@email.com' />
< title > Title of File </ title >
< description > Description of File </ description >
< category ></ category >
</ item >
</ e107Media >
*/
}
function deleteFileXml ( $imgFile )
{
list ( $file , $ext ) = explode ( " . " , $imgFile );
$xmlFile = e_UPLOAD . $file . " .xml " ;
if ( file_exists ( $xmlFile ))
{
unlink ( $xmlFile );
}
}
2012-07-18 06:34:26 +00:00
function batchDelete ()
{
foreach ( $_POST [ 'batch_selected' ] as $key => $file )
{
if ( trim ( $file ) == '' )
{
continue ;
}
2012-11-12 21:46:10 +00:00
// $oldpath = e_MEDIA."temp/".$file;
$oldpath = e_TEMP . $file ;
2012-07-18 06:34:26 +00:00
if ( file_exists ( $oldpath ))
{
unlink ( $oldpath );
}
}
}
2012-07-12 01:43:38 +00:00
2012-09-03 23:02:45 +00:00
2009-12-02 10:03:53 +00:00
function batchImport ()
{
$fl = e107 :: getFile ();
$mes = e107 :: getMessage ();
$sql = e107 :: getDb ();
2011-05-07 06:22:44 +00:00
$tp = e107 :: getParser ();
2011-08-22 23:52:45 +00:00
2011-07-10 23:21:09 +00:00
if ( ! count ( $_POST [ 'batch_selected' ]))
{
2013-02-20 18:11:28 +01:00
$mes -> addError ( " Please check at least one file. " );
2011-07-10 23:21:09 +00:00
return ;
}
2012-04-22 06:19:21 +00:00
2012-09-03 23:02:45 +00:00
2011-08-22 23:52:45 +00:00
list ( $img_import_w , $img_import_h ) = explode ( " x " , e107 :: getPref ( 'img_import_resize' ));
2011-08-23 02:51:56 +00:00
if ( vartrue ( $_POST [ 'batch_import_watermark' ]))
{
$WM = TRUE ;
$watermarkPath = e_THEME . e107 :: getPref ( 'sitetheme' ) . " /images/watermark.png " ;
$watermark = PhpThumbFactory :: create ( $watermarkPath );
}
else
{
$WM = FALSE ;
}
2010-03-09 16:05:41 +00:00
2012-07-11 04:46:09 +00:00
// Disable resize-on-import and watermark for now.
2012-09-03 23:02:45 +00:00
$img_import_w = 2816 ;
$img_import_h = 2112 ;
2012-07-11 04:46:09 +00:00
2012-04-22 06:19:21 +00:00
foreach ( $_POST [ 'batch_selected' ] as $key => $file )
2009-12-02 10:03:53 +00:00
{
2012-04-22 06:19:21 +00:00
2012-11-12 21:46:10 +00:00
// $oldpath = e_MEDIA."temp/".$file;
$oldpath = e_TEMP . $file ;
2011-08-22 23:52:45 +00:00
// Resize on Import Routine ------------------------
if ( vartrue ( $img_import_w ) && vartrue ( $img_import_h ))
{
2012-09-03 23:02:45 +00:00
// $this->resizeImage($file,$img_import_w,$img_import_h);
2011-08-22 23:52:45 +00:00
}
// End Resize routine. ---------------------
2011-06-07 13:01:36 +00:00
2011-05-07 06:22:44 +00:00
$f = $fl -> get_file_info ( $oldpath );
2011-06-07 13:01:36 +00:00
2010-10-10 22:08:57 +00:00
if ( ! $f [ 'mime' ])
{
2012-07-11 04:46:09 +00:00
$mes -> add ( " Couldn't get file info from : " . $oldpath , E_MESSAGE_WARNING );
// $mes->add(print_a($f,true), E_MESSAGE_ERROR);
$f [ 'mime' ] = " other/file " ;
2010-10-10 22:08:57 +00:00
}
2011-06-07 13:01:36 +00:00
2012-04-28 01:31:30 +00:00
$newpath = $this -> checkDupe ( $oldpath , $this -> getPath ( $f [ 'mime' ]) . '/' . $file );
2012-04-22 06:19:21 +00:00
$newname = $tp -> toDB ( $_POST [ 'batch_import_name' ][ $key ]);
$newdiz = $tp -> toDB ( $_POST [ 'batch_import_diz' ][ $key ]);
2009-12-02 10:03:53 +00:00
$f [ 'fname' ] = $file ;
2012-04-22 06:19:21 +00:00
2012-04-28 01:31:30 +00:00
/*
if ( file_exists ( $newpath ) || $sql -> db_Select ( " core_media " , " media_url = ' " . $tp -> createConstants ( $newpath , 'rel' ) . " ' LIMIT 1 " ) )
{
$mes -> addWarning ( $newpath . " already exists and was renamed during import. " );
$file = $f [ 'pathinfo' ][ 'filename' ] . " _. " . $f [ 'pathinfo' ][ 'extension' ];
$newpath = $this -> getPath ( $f [ 'mime' ]) . '/' . $file ;
}
*/
2012-04-22 07:53:34 +00:00
2011-05-07 06:22:44 +00:00
if ( rename ( $oldpath , $newpath ))
2009-12-02 10:03:53 +00:00
{
$insert = array (
2012-04-22 06:19:21 +00:00
'media_caption' => $newdiz ,
2010-03-09 16:05:41 +00:00
'media_description' => '' ,
2012-04-23 20:24:24 +00:00
'media_category' => $_POST [ 'batch_category' ],
2010-03-09 16:05:41 +00:00
'media_datestamp' => $f [ 'modified' ],
2011-05-07 06:22:44 +00:00
'media_url' => $tp -> createConstants ( $newpath , 'rel' ),
2012-07-11 04:46:09 +00:00
'media_userclass' => '0' ,
2012-04-22 06:19:21 +00:00
'media_name' => $newname ,
2011-05-07 06:22:44 +00:00
'media_author' => USERID ,
'media_size' => $f [ 'fsize' ],
2010-03-09 16:05:41 +00:00
'media_dimensions' => $f [ 'img-width' ] . " x " . $f [ 'img-height' ],
2011-05-07 06:22:44 +00:00
'media_usedby' => '' ,
'media_tags' => '' ,
'media_type' => $f [ 'mime' ]
2009-12-02 10:03:53 +00:00
);
2010-03-09 16:05:41 +00:00
2009-12-02 10:03:53 +00:00
if ( $sql -> db_Insert ( " core_media " , $insert ))
{
2010-03-09 16:05:41 +00:00
$mes -> add ( " Importing Media: " . $f [ 'fname' ], E_MESSAGE_SUCCESS );
2012-07-12 01:43:38 +00:00
$this -> deleteFileXml ( $f [ 'fname' ]);
2009-12-02 10:03:53 +00:00
}
else
{
2011-05-07 06:22:44 +00:00
rename ( $newpath , $oldpath ); //move it back.
2009-12-02 10:03:53 +00:00
}
}
2010-03-09 16:05:41 +00:00
}
2009-12-02 10:03:53 +00:00
}
2010-03-09 16:05:41 +00:00
2009-12-02 10:03:53 +00:00
function preview ( $f )
{
list ( $type , $tmp ) = explode ( " / " , $f [ 'mime' ]);
if ( $type == 'image' )
{
2010-10-04 16:01:17 +00:00
$url = e107 :: getParser () -> thumbUrl ( $f [ 'path' ] . $f [ 'fname' ], 'w=100' , true );
2012-07-12 01:43:38 +00:00
$large = e107 :: getParser () -> thumbUrl ( $f [ 'path' ] . $f [ 'fname' ], 'w=800' , true );
2010-10-04 16:01:17 +00:00
//echo $url;
2012-07-12 01:43:38 +00:00
return " <a class='e-dialog' href=' " . $large . " '><img src=' " . $url . " ' alt= \" " . $f [ 'name' ] . " \" width='100px' /></a> " ;
2009-12-02 10:03:53 +00:00
}
else
{
2010-03-09 16:05:41 +00:00
return ; //TODO generic icon/image for no preview.
2009-12-02 10:03:53 +00:00
}
}
2010-03-09 16:05:41 +00:00
2010-10-04 16:01:17 +00:00
public function getMediaCategory ( $id = false )
{
2012-05-23 08:29:57 +00:00
if ( is_array ( $id ))
{
$text = " " ;
foreach ( $id as $val )
{
$text .= ( isset ( $this -> cats [ $val ]) ? " <span class='nowrap'> " . $this -> cats [ $val ] . " </span><br /> " : '' );
}
return $text ;
}
2010-10-04 16:01:17 +00:00
if ( $id ) return ( isset ( $this -> cats [ $id ]) ? $this -> cats [ $id ] : 0 );
return $this -> cats ;
}
2012-04-22 07:53:34 +00:00
/*
* UPDATE IMAGE OPTIONS - MAIN SCREEN
*/
function updateSettings ()
{
global $pref , $admin_log , $tp ;
$mes = e107 :: getMessage ();
$tmp = array ();
$tmp [ 'image_post' ] = intval ( $_POST [ 'image_post' ]);
$tmp [ 'resize_method' ] = $tp -> toDB ( $_POST [ 'resize_method' ]);
$tmp [ 'im_path' ] = trim ( $tp -> toDB ( $_POST [ 'im_path' ]));
$tmp [ 'image_post_class' ] = intval ( $_POST [ 'image_post_class' ]);
$tmp [ 'image_post_disabled_method' ] = intval ( $_POST [ 'image_post_disabled_method' ]);
$tmp [ 'enable_png_image_fix' ] = intval ( $_POST [ 'enable_png_image_fix' ]);
if ( $_POST [ 'img_import_resize_w' ] && $_POST [ 'img_import_resize_h' ])
{
$tmp [ 'img_import_resize' ] = intval ( $_POST [ 'img_import_resize_w' ]) . " x " . intval ( $_POST [ 'img_import_resize_h' ]);
}
if ( $admin_log -> logArrayDiffs ( $tmp , $pref , 'IMALAN_04' ))
{
save_prefs (); // Only save if changes
$mes -> add ( IMALAN_9 , E_MESSAGE_SUCCESS );
}
else
{
$mes -> add ( IMALAN_20 , E_MESSAGE_INFO );
}
}
2011-06-07 13:01:36 +00:00
2006-12-02 04:36:16 +00:00
}
2009-11-07 11:20:34 +00:00
new media_admin ();
require_once ( e_ADMIN . " auth.php " );
e107 :: getAdminUI () -> runPage ();
// -----------------------------------------------------------------------
2010-03-09 16:05:41 +00:00
2009-11-07 11:20:34 +00:00
2009-07-16 08:15:35 +00:00
$action = e_QUERY ;
2009-11-08 13:22:02 +00:00
if ( varset ( $_GET [ 'action' ]) == " icons " )
2009-07-16 08:15:35 +00:00
{
2009-12-02 10:03:53 +00:00
// icon_editor();
2009-07-16 08:15:35 +00:00
}
2009-11-08 13:22:02 +00:00
if ( varset ( $_GET [ 'action' ]) == " avatars " )
2009-07-16 08:15:35 +00:00
{
2009-12-02 10:03:53 +00:00
// show_avatars();
2009-07-16 08:15:35 +00:00
}
2009-11-08 13:22:02 +00:00
if ( varset ( $_GET [ 'action' ]) == 'settings' )
2009-07-16 08:15:35 +00:00
{
2009-12-02 10:03:53 +00:00
// main_config();
2009-07-16 08:15:35 +00:00
}
2008-12-10 16:59:19 +00:00
/*
* DELETE CHECKED AVATARS - SHOW AVATAR SCREEN
*/
2009-07-16 08:15:35 +00:00
2008-12-10 16:59:19 +00:00
if ( isset ( $_POST [ 'submit_show_delete_multi' ]))
{
if ( varset ( $_POST [ 'multiaction' ]))
{
$tmp = array (); $tmp1 = array (); $message = array ();
foreach ( $_POST [ 'multiaction' ] as $todel )
{
$todel = explode ( '#' , $todel );
$todel [ 1 ] = basename ( $todel [ 1 ]);
$image_type = 2 ;
if ( strpos ( $todel [ 1 ], '-upload-' ) === 0 )
{
$image_type = 1 ;
$todel [ 1 ] = substr ( $todel [ 1 ], strlen ( '-upload-' ));
}
//delete it from server
2009-11-07 02:10:52 +00:00
@ unlink ( e_UPLOAD . " avatars/ " . $todel [ 1 ]);
2008-12-10 16:59:19 +00:00
//admin log & sysmessage
$message [] = $todel [ 1 ];
//It's owned by an user
if ( $todel [ 0 ])
{
switch ( $image_type )
{
case 1 : //avatar
$tmp [] = intval ( $todel [ 0 ]);
break ;
case 2 : //photo
$tmp1 [] = intval ( $todel [ 0 ]);
break ;
}
}
}
//Reset all deleted user avatars with one query
if ( ! empty ( $tmp ))
{
$sql -> db_Update ( " user " , " user_image='' WHERE user_id IN ( " . implode ( ',' , $tmp ) . " ) " );
}
//Reset all deleted user photos with one query
if ( ! empty ( $tmp1 ))
{
$sql -> db_Update ( " user " , " user_sess='' WHERE user_id IN ( " . implode ( ',' , $tmp1 ) . " ) " );
}
unset ( $tmp , $tmp1 );
//Format system message
if ( ! empty ( $message ))
{
$admin_log -> log_event ( 'IMALAN_01' , implode ( '[!br!]' , $message ), E_LOG_INFORMATIVE , '' );
2008-12-11 22:09:11 +00:00
$emessage -> add ( implode ( ', ' , $message ) . ' ' . IMALAN_28 , E_MESSAGE_SUCCESS );
2008-12-10 16:59:19 +00:00
}
}
}
2008-12-05 22:01:25 +00:00
2008-12-10 16:59:19 +00:00
/*
* DELETE ALL UNUSED IMAGES - SHOW AVATAR SCREEN
*/
if ( isset ( $_POST [ 'submit_show_deleteall' ]))
2008-12-05 22:01:25 +00:00
{
2009-11-07 02:10:52 +00:00
$handle = opendir ( e_UPLOAD . " avatars/ " );
2008-12-10 16:59:19 +00:00
$dirlist = array ();
2008-12-09 15:19:03 +00:00
while ( $file = readdir ( $handle )) {
2009-11-07 02:10:52 +00:00
if ( ! is_dir ( e_UPLOAD . " avatars/ { $file } " ) && $file != '.' && $file != '..' && $file != " index.html " && $file != " null.txt " && $file != '/' && $file != 'CVS' && $file != 'Thumbs.db' ) {
2006-12-02 04:36:16 +00:00
$dirlist [] = $file ;
}
}
closedir ( $handle );
2008-12-10 16:59:19 +00:00
if ( ! empty ( $dirlist ))
2008-12-05 22:01:25 +00:00
{
2008-12-10 16:59:19 +00:00
$imgList = '' ;
$count = 0 ;
foreach ( $dirlist as $image_name )
{
$image_name = basename ( $image_name );
$image_todb = $tp -> toDB ( $image_name );
if ( ! $sql -> db_Count ( 'user' , '(*)' , " WHERE user_image='-upload- { $image_todb } ' OR user_sess=' { $image_todb } ' " )) {
2009-11-07 02:10:52 +00:00
unlink ( e_UPLOAD . " avatars/ " . $image_name );
2008-12-10 16:59:19 +00:00
$imgList .= '[!br!]' . $image_name ;
$count ++ ;
}
2006-12-02 04:36:16 +00:00
}
2008-12-10 16:59:19 +00:00
$message = $count . " " . IMALAN_26 ;
2008-12-11 22:09:11 +00:00
$emessage -> add ( $message , E_MESSAGE_SUCCESS );
2008-12-10 16:59:19 +00:00
$admin_log -> log_event ( 'IMALAN_02' , $message . $imgList , E_LOG_INFORMATIVE , '' );
unset ( $imgList );
2006-12-02 04:36:16 +00:00
}
}
2008-12-05 22:01:25 +00:00
2008-12-10 16:59:19 +00:00
/*
* DELETE ALL CHECKED BAD IMAGES - VALIDATE SCREEN
*/
if ( isset ( $_POST [ 'submit_avdelete_multi' ]))
2008-12-05 22:01:25 +00:00
{
2006-12-02 04:36:16 +00:00
require_once ( e_HANDLER . " avatar_handler.php " );
2008-12-05 22:01:25 +00:00
$avList = array ();
2008-12-10 16:59:19 +00:00
$tmp = array ();
$uids = array ();
//Sanitize
$_POST [ 'multiaction' ] = $tp -> toDB ( $_POST [ 'multiaction' ]);
//sql queries significant reduced
if ( ! empty ( $_POST [ 'multiaction' ]) && $sql -> db_Select ( " user " , 'user_id, user_name, user_image' , " user_id IN ( " . implode ( ',' , $_POST [ 'multiaction' ]) . " ) " ))
2006-12-02 04:36:16 +00:00
{
2008-12-10 16:59:19 +00:00
$search_users = $sql -> db_getList ( 'ALL' , FALSE , FALSE , 'user_id' );
foreach ( $_POST [ 'multiaction' ] as $uid )
2008-12-05 22:01:25 +00:00
{
2008-12-10 16:59:19 +00:00
if ( varsettrue ( $search_users [ $uid ]))
{
$avname = avatar ( $search_users [ $uid ][ 'user_image' ]);
if ( strpos ( $avname , " http:// " ) === FALSE )
{ // Internal file, so unlink it
@ unlink ( $avname );
}
$uids [] = $uid ;
$tmp [] = $search_users [ $uid ][ 'user_name' ];
$avList [] = $uid . ':' . $search_users [ $uid ][ 'user_name' ] . ':' . $search_users [ $uid ][ 'user_image' ];
2006-12-02 04:36:16 +00:00
}
}
2008-12-10 16:59:19 +00:00
//sql queries significant reduced
if ( ! empty ( $uids ))
{
$sql -> db_Update ( " user " , " user_image='' WHERE user_id IN ( " . implode ( ',' , $uids ) . " ) " );
}
2008-12-11 22:09:11 +00:00
$emessage -> add ( IMALAN_51 . '<strong>' . implode ( ', ' , $tmp ) . '</strong> ' . IMALAN_28 , E_MESSAGE_SUCCESS );
2008-12-10 16:59:19 +00:00
$admin_log -> log_event ( 'IMALAN_03' , implode ( '[!br!]' , $avList ), E_LOG_INFORMATIVE , '' );
2008-12-12 09:55:33 +00:00
2008-12-10 16:59:19 +00:00
unset ( $search_users );
2006-12-02 04:36:16 +00:00
}
2008-12-10 16:59:19 +00:00
unset ( $avList , $tmp , $uids );
2006-12-02 04:36:16 +00:00
}
2008-12-10 16:59:19 +00:00
2006-12-02 04:36:16 +00:00
2008-12-10 16:59:19 +00:00
/*
* SHOW AVATARS SCREEN
*/
2009-07-16 08:15:35 +00:00
function show_avatars ()
2008-12-05 22:01:25 +00:00
{
2009-11-07 11:20:34 +00:00
global $e107 , $pref ;
2010-03-09 16:05:41 +00:00
2009-11-07 11:20:34 +00:00
$ns = e107 :: getRender ();
$sql = e107 :: getDb ();
$frm = e107 :: getForm ();
$tp = e107 :: getParser ();
$mes = e107 :: getMessage ();
2009-07-16 08:15:35 +00:00
2012-06-15 04:15:46 +00:00
$avFiles = e107 :: getFile () -> get_files ( e_MEDIA . " avatars/ " , " .jpg|.png|.gif|.jpeg|.JPG|.GIF|.PNG " );
2008-12-10 16:59:19 +00:00
$dirlist = array ();
2012-06-15 04:15:46 +00:00
foreach ( $avFiles as $f )
2008-12-09 15:19:03 +00:00
{
2012-06-15 04:15:46 +00:00
$dirlist [] = $f [ 'fname' ];
2006-12-02 04:36:16 +00:00
}
2008-12-09 15:19:03 +00:00
$text = '' ;
2006-12-02 04:36:16 +00:00
2008-12-10 16:59:19 +00:00
if ( empty ( $dirlist ))
2008-12-05 22:01:25 +00:00
{
2006-12-02 04:36:16 +00:00
$text .= IMALAN_29 ;
2008-12-09 15:19:03 +00:00
}
else
2008-12-05 22:01:25 +00:00
{
2008-12-09 17:49:59 +00:00
$text = "
2009-07-16 08:15:35 +00:00
< form method = 'post' action = '".e_SELF."?avatars' id = 'core-iamge-show-avatars-form' >
2008-12-10 16:59:19 +00:00
< fieldset id = 'core-iamge-show-avatars' >
2008-12-09 17:49:59 +00:00
" ;
2008-12-09 15:19:03 +00:00
$count = 0 ;
while ( list ( $key , $image_name ) = each ( $dirlist ))
2008-12-05 22:01:25 +00:00
{
2006-12-02 04:36:16 +00:00
$users = IMALAN_21 . " | " ;
2008-12-10 16:59:19 +00:00
$row = array ( 'user_id' => '' );
$image_pre = '' ;
2008-12-12 22:39:17 +00:00
$disabled = false ;
2008-12-10 16:59:19 +00:00
if ( $sql -> db_Select ( " user " , " * " , " user_image='-upload- " . $tp -> toDB ( $image_name ) . " ' OR user_sess=' " . $tp -> toDB ( $image_name ) . " ' " ))
2008-12-09 15:19:03 +00:00
{
$row = $sql -> db_Fetch ();
2008-12-10 16:59:19 +00:00
if ( $row [ 'user_image' ] == '-upload-' . $image_name ) $image_pre = '-upload-' ;
2011-11-26 18:17:42 +00:00
$users .= " <a href=' " . $e107 -> url -> create ( 'user/profile/view' , 'name=' . $row [ 'user_name' ] . '&id=' . $row [ 'user_id' ]) . " '> { $row [ 'user_name' ] } </a> <span class='smalltext'>( " . ( $row [ 'user_sess' ] == $image_name ? IMALAN_24 : IMALAN_23 ) . " )</span> " ;
2009-07-16 08:15:35 +00:00
}
else
{
2008-12-09 15:19:03 +00:00
$users = '<span class="warning">' . IMALAN_22 . '</span>' ;
2006-12-02 04:36:16 +00:00
}
2008-12-10 16:59:19 +00:00
//directory?
2012-06-15 04:15:46 +00:00
if ( is_dir ( e_MEDIA . " avatars/ " . $image_name ))
2008-12-10 16:59:19 +00:00
{
//File info
2012-06-15 04:15:46 +00:00
$users = " <a href='#' title=' " . IMALAN_69 . " : { $image_name } '><img class='e-tip icon S16' src=' " . e_IMAGE_ABS . " admin_images/info_16.png' alt=' " . IMALAN_66 . " : { $image_name } ' title=' " . IMALAN_69 . " : { $image_name } ' /></a> <span class='error'> " . IMALAN_69 . " </span> " ;
2008-12-09 15:19:03 +00:00
2008-12-10 16:59:19 +00:00
//Friendly UI - click text to select a form element
$img_src = '<span class="error">' . IMALAN_70 . '</span>' ;
2008-12-12 22:39:17 +00:00
$disabled = true ;
2008-12-09 15:19:03 +00:00
}
2008-12-10 16:59:19 +00:00
else
{
//File info
2012-06-15 04:15:46 +00:00
// $users = "<a class='e-tip' href='#' title='".IMALAN_66.": {$image_name}'><img src='".e_IMAGE_ABS."admin_images/info_16.png' alt='".IMALAN_66.": {$image_name}' /></a> ".$users;
2008-12-10 16:59:19 +00:00
// Control over the image size (design)
2012-06-17 11:52:10 +00:00
// $image_size = getimagesize(e_MEDIA."avatars/".$image_name);
2008-12-09 15:19:03 +00:00
2008-12-10 16:59:19 +00:00
//Friendly UI - click text to select a form element
2012-06-17 11:52:10 +00:00
// Resized on-the-fly - avatar-size no longer an issue.
$attr = " aw= " . $pref [ 'im_width' ] . " &ah= " . $pref [ 'im_height' ];
$img_path = $tp -> thumbUrl ( e_MEDIA_ABS . " avatars/ " . $image_name , $attr );
2012-06-15 04:15:46 +00:00
$img_src = " <label for='image-action- { $count } ' title=' " . IMALAN_56 . " '>
2012-06-17 11:52:10 +00:00
< img class = 'e-tip' src = '".$img_path."' alt = '{$image_name}' title = '".IMALAN_66.": {$image_name}' />
2012-06-15 04:15:46 +00:00
</ label > " ;
2012-06-17 11:52:10 +00:00
// if ($image_size[0] > $pref['im_width'] || $image_size[1] > $pref['im_height'])
// {
// $img_src = "<a class='image-preview' href='".e_MEDIA."avatars/".rawurlencode($image_name)."' rel='external'>".IMALAN_57."</a>";
// }
2008-12-10 16:59:19 +00:00
}
2008-12-11 11:25:21 +00:00
2008-12-10 16:59:19 +00:00
//style attribute allowed here - server side width/height control
2008-12-11 11:25:21 +00:00
//autocheck class - used for JS selectors (see eCoreImage object)
2008-12-09 15:19:03 +00:00
$text .= "
2008-12-11 11:25:21 +00:00
< div class = 'image-box f-left center autocheck' style = 'width: ".(intval($pref[' im_width '])+40)."px; height: ".(intval($pref[' im_height '])+100)."px;' >
2008-12-09 15:19:03 +00:00
< div class = 'spacer' >
< div class = 'image-users' > { $users } </ div >
< div class = 'image-preview' > { $img_src } </ div >
2008-12-11 11:25:21 +00:00
< div class = 'image-delete' >
2008-12-12 22:39:17 +00:00
" . $frm->checkbox ('multiaction[]', " { $row [ 'user_id' ]} #{$image_pre}{$image_name}", false, array('id' => false, 'disabled' => $disabled))."
2008-12-09 15:19:03 +00:00
</ div >
2008-12-09 17:49:59 +00:00
2008-12-09 15:19:03 +00:00
</ div >
</ div >
" ;
$count ++ ;
2006-12-02 04:36:16 +00:00
}
2008-12-09 15:19:03 +00:00
$text .= "
< div class = 'spacer clear' >
2008-12-10 16:59:19 +00:00
< div class = 'buttons-bar' >
< input type = 'hidden' name = 'show_avatars' value = '1' />
2012-06-17 11:52:10 +00:00
" . $frm->admin_button ('e_check_all', LAN_CHECKALL, 'action'). "
" . $frm->admin_button ('e_uncheck_all', LAN_UNCHECKALL, 'action'). "
2009-11-08 09:14:39 +00:00
" . $frm->admin_button ('submit_show_delete_multi', LAN_DELCHECKED, 'delete'). "
2008-12-12 22:39:17 +00:00
" . $frm->admin_button ('submit_show_deleteall', IMALAN_25, 'delete'). "
" . $frm->admin_button ('submit_cancel_show', IMALAN_68, 'cancel'). "
2008-12-10 16:59:19 +00:00
</ div >
2008-12-09 17:49:59 +00:00
</ div >
2008-12-10 16:59:19 +00:00
</ fieldset >
2006-12-02 04:36:16 +00:00
</ form >
2008-12-09 17:49:59 +00:00
" ;
2006-12-02 04:36:16 +00:00
}
2009-12-02 10:03:53 +00:00
echo $mes -> render () . $text ;
return ;
// $ns->tablerender(LAN_MEDIAMANAGER." :: ".IMALAN_18, $mes->render().$text);
2006-12-02 04:36:16 +00:00
}
2008-12-10 16:59:19 +00:00
/*
* CHECK AVATARS SCREEN
*/
2008-12-09 15:19:03 +00:00
if ( isset ( $_POST [ 'check_avatar_sizes' ]))
2008-12-05 22:01:25 +00:00
{
2006-12-02 04:36:16 +00:00
// Set up to track what we've done
//
$iUserCount = 0 ;
$iAVinternal = 0 ;
$iAVexternal = 0 ;
$iAVnotfound = 0 ;
$iAVtoobig = 0 ;
require_once ( e_HANDLER . " avatar_handler.php " );
2008-12-09 15:19:03 +00:00
$text = "
< form method = 'post' action = '".e_SELF."' >
2008-12-10 16:59:19 +00:00
< fieldset id = 'core-image-check-avatar' >
2008-12-09 15:19:03 +00:00
< legend class = 'e-hideme' > " .CACLAN_3. " </ legend >
2012-11-26 14:41:32 -08:00
< table class = 'table adminlist' >
2012-05-13 05:50:32 +00:00
< colgroup >
< col style = 'width:10%' />
< col style = 'width:20%' />
< col style = 'width:25%' />
< col style = 'width:45%' />
2008-12-09 15:19:03 +00:00
</ colgroup >
< thead >
< tr >
2009-07-16 08:15:35 +00:00
< th class = 'center' > " .LAN_OPTIONS. " </ th >
2009-11-08 09:14:39 +00:00
< th class = 'center' > " .LAN_USER. " </ th >
2008-12-09 15:19:03 +00:00
< th class = 'center' > " .IMALAN_62. " </ th >
2009-11-08 09:14:39 +00:00
< th class = 'center last' > " .LAN_URL. " </ th >
2008-12-09 15:19:03 +00:00
</ tr >
</ thead >
< tbody >
" ;
2006-12-02 04:36:16 +00:00
//
// Loop through avatar field for every user
//
$iUserCount = $sql -> db_Count ( " user " );
2008-12-10 16:59:19 +00:00
$found = false ;
$allowedWidth = intval ( $pref [ 'im_width' ]);
$allowedHeight = intval ( $pref [ 'im_width' ]);
2006-12-02 04:36:16 +00:00
if ( $sql -> db_Select ( " user " , " * " , " user_image!='' " )) {
2008-12-10 16:59:19 +00:00
2008-12-09 15:19:03 +00:00
while ( $row = $sql -> db_Fetch ())
2008-12-05 22:01:25 +00:00
{
2008-12-10 16:59:19 +00:00
//Check size
$avname = avatar ( $row [ 'user_image' ]);
2008-12-09 15:19:03 +00:00
if ( strpos ( $avname , " http:// " ) !== FALSE )
2006-12-02 04:36:16 +00:00
{
$iAVexternal ++ ;
$bAVext = TRUE ;
} else {
$iAVinternal ++ ;
$bAVext = FALSE ;
}
2008-12-10 16:59:19 +00:00
2006-12-02 04:36:16 +00:00
$image_stats = getimagesize ( $avname );
$sBadImage = " " ;
2008-12-10 16:59:19 +00:00
2006-12-02 04:36:16 +00:00
if ( ! $image_stats )
{
$iAVnotfound ++ ;
// allow delete
$sBadImage = IMALAN_42 ;
2008-12-10 16:59:19 +00:00
}
else
{
2006-12-02 04:36:16 +00:00
$imageWidth = $image_stats [ 0 ];
$imageHeight = $image_stats [ 1 ];
2008-12-10 16:59:19 +00:00
if ( ( $imageHeight > $allowedHeight ) || ( $imageWidth > $allowedWidth ) )
2006-12-02 04:36:16 +00:00
{ // Too tall or too wide
$iAVtoobig ++ ;
2008-12-10 16:59:19 +00:00
if ( $imageWidth > $allowedWidth )
{
2006-12-02 04:36:16 +00:00
$sBadImage = IMALAN_40 . " ( $imageWidth ) " ;
}
2008-12-10 16:59:19 +00:00
if ( $imageHeight > $allowedHeight )
{
2006-12-02 04:36:16 +00:00
if ( strlen ( $sBadImage ))
{
$sBadImage .= " , " ;
}
$sBadImage .= IMALAN_41 . " ( $imageHeight ) " ;
}
}
}
2008-12-09 15:19:03 +00:00
2008-12-10 16:59:19 +00:00
//If not found or too large, allow delete
2006-12-02 04:36:16 +00:00
if ( strlen ( $sBadImage ))
{
2008-12-10 16:59:19 +00:00
$found = true ;
2006-12-02 04:36:16 +00:00
$text .= "
< tr >
2008-12-11 11:25:21 +00:00
< td class = 'autocheck center' >
2008-12-10 16:59:19 +00:00
< input class = 'checkbox' type = 'checkbox' name = 'multiaction[]' id = 'avdelete-{$row[' user_id ']}' value = '{$row[' user_id ']}' />
2008-12-09 15:19:03 +00:00
</ td >
< td >
2008-12-10 16:59:19 +00:00
< label for = 'avdelete-{$row[' user_id ']}' title = '".IMALAN_56."' > " .IMALAN_51. " </ label >< a href = '".e_BASE."user.php?id.{$row[' user_id ']}' > " . $row['user_name'] . " </ a >
2008-12-09 15:19:03 +00:00
</ td >
< td > " . $sBadImage . " </ td >
< td > " . $avname . " </ td >
2006-12-02 04:36:16 +00:00
</ tr > " ;
}
2008-12-10 16:59:19 +00:00
}
}
//Nothing found
if ( ! $found )
{
$text .= "
2008-12-09 15:19:03 +00:00
< tr >
< td colspan = '4' class = 'center' > " .IMALAN_65. " </ td >
2008-12-10 16:59:19 +00:00
</ tr >
" ;
2006-12-02 04:36:16 +00:00
}
2008-12-10 16:59:19 +00:00
2006-12-02 04:36:16 +00:00
$text .= "
2008-12-09 15:19:03 +00:00
</ tbody >
</ table >
< div class = 'buttons-bar' >
2008-12-10 16:59:19 +00:00
< input type = 'hidden' name = 'check_avatar_sizes' value = '1' />
2009-11-08 09:14:39 +00:00
" . $frm->admin_button ('check_all', LAN_CHECKALL, 'action'). "
" . $frm->admin_button ('uncheck_all', LAN_UNCHECKALL, 'action'). "
" . $frm->admin_button ('submit_avdelete_multi', LAN_DELCHECKED, 'delete'). "
2008-12-09 15:19:03 +00:00
</ div >
</ fieldset >
</ form >
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' >
2012-05-13 05:50:32 +00:00
< colgroup >
2009-07-16 08:15:35 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
2008-12-10 16:59:19 +00:00
</ colgroup >
< tbody >
< tr >
2009-07-16 08:15:35 +00:00
< td > " .IMALAN_38. " </ td >
< td > { $allowedWidth } </ td >
2008-12-10 16:59:19 +00:00
</ tr >
< tr >
2009-07-16 08:15:35 +00:00
< td > " .IMALAN_39. " </ td >
< td > { $allowedHeight } </ td >
2008-12-10 16:59:19 +00:00
</ tr >
< tr >
2009-07-16 08:15:35 +00:00
< td > " .IMALAN_45. " </ td >
< td > { $iAVnotfound } </ td >
2008-12-10 16:59:19 +00:00
</ tr >
< tr >
2009-07-16 08:15:35 +00:00
< td > " .IMALAN_46. " </ td >
< td > { $iAVtoobig } </ td >
2008-12-10 16:59:19 +00:00
</ tr >
< tr >
2009-07-16 08:15:35 +00:00
< td > " .IMALAN_47. " </ td >
< td > { $iAVinternal } </ td >
2008-12-10 16:59:19 +00:00
</ tr >
< tr >
2009-07-16 08:15:35 +00:00
< td > " .IMALAN_48. " </ td >
< td > { $iAVexternal } </ td >
2008-12-10 16:59:19 +00:00
</ tr >
< tr >
2009-07-16 08:15:35 +00:00
< td > " .IMALAN_49. " </ td >
< td > " .( $iAVexternal + $iAVinternal ). " ( " .(int)(100.0*(( $iAVexternal + $iAVinternal )/ $iUserCount )).'%, '. $iUserCount . " " .IMALAN_50. " ) </ td >
2008-12-10 16:59:19 +00:00
</ tr >
</ tbody >
2008-12-09 15:19:03 +00:00
</ table >
" ;
2006-12-02 04:36:16 +00:00
2008-12-11 22:09:11 +00:00
$ns -> tablerender ( IMALAN_37 , $emessage -> render () . $text );
2006-12-02 04:36:16 +00:00
}
2009-11-07 11:20:34 +00:00
2009-07-16 08:15:35 +00:00
//Just in case...
2012-06-09 04:44:11 +00:00
if ( ! e_AJAX_REQUEST ) require_once ( " footer.php " );
2009-07-16 08:15:35 +00:00
2008-12-09 15:19:03 +00:00
?>