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
*
*
2006-12-02 04:36:16 +00:00
*/
2012-04-22 06:19:21 +00:00
2020-12-31 16:14:43 -08:00
if ( ! empty ( $_GET [ 'action' ]) && $_GET [ 'action' ] === 'dialog' )
2013-02-23 23:08:30 -08:00
{
define ( 'e_MINIMAL' , true );
}
2012-04-22 06:19:21 +00:00
if ( ! defined ( 'e107_INIT' ))
{
2021-01-16 13:32:35 -08:00
require_once ( __DIR__ . '/../class2.php' );
2012-04-22 06:19:21 +00:00
}
2020-12-31 16:14:43 -08:00
if ( ! getperms ( 'A' ) && ( $_GET [ 'action' ] !== 'dialog' ) && ( $_GET [ 'action' ] !== 'youtube' ))
2008-12-29 15:23:06 +00:00
{
2016-01-13 19:17:37 -08:00
e107 :: redirect ( 'admin' );
2006-12-02 04:36:16 +00:00
exit ;
}
2008-12-10 16:59:19 +00:00
2020-12-31 09:06:20 -08:00
if ( varset ( $_GET [ 'action' ]) === 'youtube' )
2016-11-25 17:59:17 -08:00
{
if ( ! getperms ( 'A' ) && ! getperms ( 'A1' ))
{
exit ;
}
}
2016-12-20 10:58:43 +01:00
// TODO use library manager
2018-11-23 13:24:14 -08:00
e107 :: js ( 'core' , 'plupload/plupload.full.min.js' , 'jquery' , 2 );
2012-12-04 18:21:57 +01:00
e107 :: css ( 'core' , 'plupload/jquery.plupload.queue/css/jquery.plupload.queue.css' , 'jquery' );
2016-10-01 14:29:03 -07:00
e107 :: js ( 'core' , 'plupload/jquery.plupload.queue/jquery.plupload.queue.min.js' , 'jquery' , 2 );
2020-12-31 16:14:43 -08:00
e107 :: js ( 'core' , 'core/mediaManager.js' , 'jquery' , 5 );
2018-07-04 13:28:45 +02:00
// issue #3051 Preview url is wrong when target page is a plugin
// Using this variable to check for the plugins directory and replace with empty space in case of...
// see mediaManager.js (line ~399ff)
e107 :: js ( 'inline' , 'var e107_plugins_directory = "' . str_replace ( '../' , '' , e_PLUGIN ) . '";' );
2015-01-29 11:26:56 -08:00
e107 :: wysiwyg ( true );
2009-11-07 11:20:34 +00:00
/*
* CLOSE - GO TO MAIN SCREEN
*/
if ( isset ( $_POST [ 'submit_cancel_show' ]))
{
header ( 'Location: ' . e_SELF );
exit ();
}
2017-01-17 01:33:03 +01:00
e107 :: coreLan ( 'image' , true );
2009-08-28 16:11:02 +00:00
2020-12-18 19:55:12 -08:00
2014-01-08 15:51:14 -08:00
2020-12-31 16:14:43 -08:00
if ( e_AJAX_REQUEST && ( vartrue ( $_GET [ 'action' ]) === 'nav' )) //XXX Doesn't work correctly inside the class for some reason
2012-08-04 04:15:41 +00:00
{
2020-12-31 16:14:43 -08:00
define ( 'e_IFRAME' , true );
2015-07-19 17:10:03 -07:00
2012-08-04 04:15:41 +00:00
// require_once(e_ADMIN."auth.php");
2020-12-31 16:14:43 -08:00
$bbcodeMode = ( $_GET [ 'bbcode' ] === 'img' ) ? 'bbcode=img' : FALSE ;
2012-08-04 04:15:41 +00:00
if ( $_GET [ 'from' ])
{
2020-12-31 16:14:43 -08:00
$bbcodeMode .= '&from=' . ( int ) $_GET [ 'from' ];
2012-08-04 04:15:41 +00:00
}
2013-03-22 16:55:22 -07:00
if ( $_GET [ 'w' ])
{
2020-12-31 16:14:43 -08:00
$bbcodeMode .= '&w=' . ( int ) $_GET [ 'w' ];
2013-03-22 16:55:22 -07:00
}
2020-12-31 16:14:43 -08:00
$bbcodeMode .= '&nav=1' ;
2012-08-04 04:15:41 +00:00
2016-12-15 15:08:49 +01:00
$tag = ( $bbcodeMode === false ) ? false : e107 :: getParser () -> filter ( $_GET [ 'tagid' ]); // eg. news, news-thumbnail
2012-08-04 04:15:41 +00:00
if ( $_GET [ 'search' ])
{
2016-12-15 15:08:49 +01:00
$search = e107 :: getParser () -> filter ( $_GET [ 'search' ]);
2020-12-31 16:14:43 -08:00
$bbcodeMode .= '&search=' . preg_replace ( '/[^a-z0-9]/i' , '' , $search );
2012-08-04 04:15:41 +00:00
}
2016-12-15 15:08:49 +01:00
$for = e107 :: getParser () -> filter ( $_GET [ 'for' ]);
2012-08-04 04:15:41 +00:00
2016-12-15 15:08:49 +01:00
echo e107 :: getMedia () -> mediaSelect ( $for , $tag , $bbcodeMode );
2012-08-04 04:15:41 +00:00
// require_once(e_ADMIN."footer.php");
exit ;
}
2020-12-06 11:33:09 -08:00
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
2013-02-25 20:14:59 +01:00
$mes = e107 :: getMessage ();
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 (
2022-04-02 09:34:06 -07:00
'main/grid' => 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.
2016-11-25 17:59:17 -08:00
'main/import' => array ( 'caption' => LAN_IMA_M_02 , 'perm' => 'A|A1' ),
2017-11-16 20:17:07 -08:00
'divider/01' => array ( 'divider' => true ),
2016-11-25 17:59:17 -08:00
'cat/list' => array ( 'caption' => LAN_IMA_M_03 , 'perm' => 'A|A2' ),
'cat/create' => array ( 'caption' => LAN_IMA_M_04 , 'perm' => 'A|A2' ), // is automatic.
2012-06-17 11:52:10 +00:00
// 'main/settings' => array('caption'=> LAN_PREFS, 'perm' => 'A'), // legacy
2017-11-16 20:17:07 -08:00
'divider/02' => array ( 'divider' => true ),
2012-06-17 11:52:10 +00:00
'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
2017-02-01 18:25:32 -08:00
protected $adminMenuIcon = 'e-images-24' ;
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 (
2022-04-02 09:34:06 -07:00
'main/edit' => 'main/grid' ,
'main/list' => 'main/grid'
2010-03-09 16:05:41 +00:00
);
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' ;
2020-12-31 16:14:43 -08:00
protected $table = 'core_media_cat' ;
protected $pid = 'media_cat_id' ;
2009-11-18 07:16:51 +00:00
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
2017-09-22 14:55:44 -07: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
2014-10-04 10:33:56 -07: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
2014-10-04 10:33:56 -07:00
'media_cat_category' => array ( 'title' => LAN_CATEGORY , 'type' => 'text' , 'data' => 'str' , 'width' => 'auto' , 'thclass' => 'left' , 'readonly' => TRUE ),
2016-10-18 16:10:52 -07:00
'media_cat_title' => array ( 'title' => LAN_TITLE , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left' , 'readonly' => FALSE , 'validate' => true , 'writeParms' => array ( 'size' => 'xxlarge' )),
'media_cat_sef' => array ( 'title' => LAN_SEFURL , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left' , 'readonly' => FALSE , 'writeParms' => array ( 'size' => 'xxlarge' , 'sef' => 'media_cat_title' )),
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
);
2016-10-18 16:10:52 -07:00
private $restricted = array ();
2012-04-22 06:19:21 +00:00
function init ()
2009-11-18 07:16:51 +00:00
{
2022-04-02 09:34:06 -07:00
2016-10-18 16:10:52 -07:00
$this -> restricted = array (
2020-12-31 16:14:43 -08:00
'_common' => '_common' ,
'_icon' => '_icon' ,
'news' => 'news' ,
'page' => 'page' ,
'download' => 'download'
2012-04-22 06:19:21 +00:00
);
2014-01-09 04:42:13 -08:00
// FIXME LAN
2016-10-07 11:43:44 +02:00
$this -> fields [ 'media_cat_type' ][ 'writeParms' ] = array ( 'image' => IMALAN_143 , 'file' => IMALAN_144 , 'video' => IMALAN_163 );
2012-10-31 21:28:20 +00:00
2020-12-31 16:14:43 -08:00
if ( $this -> getAction () === 'list' )
2012-08-19 02:33:43 +00:00
{
2016-10-18 16:10:52 -07:00
$this -> fields [ 'media_cat_owner' ][ 'writeParms' ] = $this -> restricted ;
2012-08-19 02:33:43 +00:00
}
2012-10-31 20:18:18 +00:00
2020-12-31 16:14:43 -08:00
if ( $this -> getAction () === 'create' )
2012-10-31 20:18:18 +00:00
{
$this -> fields [ 'media_cat_category' ][ 'noedit' ] = true ;
}
2020-12-31 16:14:43 -08:00
elseif ( $this -> getAction () === 'edit' )
2013-01-17 16:08:07 +02:00
{
$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
2014-10-14 15:35:53 -07:00
if ( $sql -> gen ( " SELECT media_cat_owner, MAX(CAST(SUBSTRING_INDEX(media_cat_category, '_', -1 ) AS UNSIGNED)) as maxnum, count(media_cat_id) as number FROM `#core_media_cat` GROUP BY media_cat_owner " ))
2012-04-22 06:19:21 +00:00
{
2020-12-31 16:14:43 -08:00
while ( $row = $sql -> fetch ())
2012-08-19 02:33:43 +00:00
{
2013-04-27 13:20:17 +03:00
$this -> ownerCount [ $row [ 'media_cat_owner' ]] = $row [ 'number' ];
2014-10-04 10:33:56 -07:00
$own = $row [ 'media_cat_owner' ];
2016-10-18 16:10:52 -07:00
if ( ! in_array ( $own , $this -> restricted ))
2014-10-04 10:33:56 -07:00
{
2013-04-27 13:20:17 +03:00
$this -> fields [ 'media_cat_owner' ][ 'writeParms' ][ $own ] = $own ;
2014-10-14 15:35:53 -07:00
if ( $row [ 'maxnum' ] > 0 )
2014-10-04 10:33:56 -07:00
{
2014-10-14 15:35:53 -07:00
$this -> ownerCount [ $row [ 'media_cat_owner' ]] = $row [ 'maxnum' ]; // $maxnum;
2014-10-04 10:33:56 -07:00
}
2013-04-27 13:20:17 +03:00
}
}
}
2013-05-04 20:17:58 -07:00
2020-12-31 16:14:43 -08:00
e107 :: getMessage () -> addDebug ( 'Max value for category names: ' . print_a ( $this -> ownerCount , true ));
2013-05-04 20:17:58 -07:00
}
2014-10-04 10:33:56 -07:00
2013-05-04 20:17:58 -07:00
public function createPage ()
{
if ( ! count ( $this -> fields [ 'media_cat_owner' ][ 'writeParms' ]))
2013-04-27 13:20:17 +03:00
{
2020-12-31 16:14:43 -08:00
e107 :: getMessage () -> addInfo ( 'Category creation not available.' );
2020-12-06 11:33:09 -08:00
return null ;
2012-04-22 06:19:21 +00:00
}
2013-05-04 20:17:58 -07:00
return $this -> getUI () -> getCreate ();
2009-11-18 07:16:51 +00:00
}
2013-05-04 20:17:58 -07:00
2012-04-22 06:19:21 +00:00
2018-08-11 10:44:05 -07:00
public function beforeCreate ( $new_data , $old_data )
2012-04-22 06:19:21 +00:00
{
2013-04-27 13:20:17 +03:00
// XXX temporary disable when there is no owners, discuss
if ( ! $new_data [ 'media_cat_owner' ])
{
2016-12-20 10:58:43 +01:00
e107 :: getMessage () -> addError ( IMALAN_173 );
2013-04-27 13:20:17 +03:00
return false ;
}
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 ;
2020-12-31 16:14:43 -08:00
if ( empty ( $new_data [ 'media_cat_sef' ]))
{
$new_data [ 'media_cat_sef' ] = eHelper :: title2sef ( $new_data [ 'media_cat_title' ]);
}
2013-01-17 16:08:07 +02:00
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 ();
2016-10-18 16:10:52 -07:00
if ( in_array ( $new_data [ 'media_cat_owner' ], $this -> restricted ))
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
2020-12-31 16:14:43 -08:00
if ( empty ( $new_data [ 'media_cat_sef' ]))
{
$new_data [ 'media_cat_sef' ] = eHelper :: title2sef ( $new_data [ 'media_cat_title' ]);
}
2013-01-16 12:51:03 +02:00
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 )
{
2020-12-31 16:14:43 -08:00
if ( $_GET [ 'action' ] === 'create' || $_GET [ 'action' ] === 'edit' )
2012-08-19 02:33:43 +00:00
{
return ;
}
$owner = $this -> getController () -> getListModel () -> get ( 'media_cat_owner' );
if ( ! in_array ( $owner , $this -> restrictedOwners ))
{
2022-04-02 09:34:06 -07:00
2020-12-18 19:55:12 -08:00
return $this -> renderValue ( 'options' , $value , null , $id );
2012-08-19 02:33:43 +00:00
}
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 ();
2016-02-15 00:14:45 -08:00
// $sql->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 -> gen ( " SELECT media_cat_title, media_cat_owner FROM #core_media_cat " );
2020-12-17 05:52:54 -08:00
while ( $row = $sql -> fetch ())
2009-11-18 07:16:51 +00:00
{
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.
2018-08-07 17:05:08 -07:00
/*
2017-11-16 20:17:07 -08:00
if ( ! empty ( $_POST [ 'multiselect' ]) && varset ( $_POST [ 'e__execute_batch' ]) && ( varset ( $_POST [ 'etrigger_batch' ]) == 'options__rotate_cw' || varset ( $_POST [ 'etrigger_batch' ]) == 'options__rotate_ccw' ))
2012-07-29 02:36:18 +00:00
{
$type = str_replace ( 'options__' , '' , $_POST [ 'etrigger_batch' ]);
2016-12-01 15:38:40 -08:00
$ids = implode ( " , " , e107 :: getParser () -> filter ( $_POST [ 'multiselect' ], 'int' ));
2012-07-29 02:36:18 +00:00
$this -> rotateImages ( $ids , $type );
2016-12-01 15:38:40 -08:00
2012-07-29 02:36:18 +00:00
}
2012-09-03 23:02:45 +00:00
2017-11-16 20:17:07 -08:00
if ( ! empty ( $_POST [ 'multiselect' ]) && varset ( $_POST [ 'e__execute_batch' ]) && ( varset ( $_POST [ 'etrigger_batch' ]) == 'options__resize_2048' ))
2012-09-03 23:02:45 +00:00
{
$type = str_replace ( 'options__' , '' , $_POST [ 'etrigger_batch' ]);
2016-12-01 15:38:40 -08:00
$ids = implode ( " , " , e107 :: getParser () -> filter ( $_POST [ 'multiselect' ], 'int' ));
2012-09-03 23:02:45 +00:00
$this -> resizeImages ( $ids , $type );
}
2017-11-16 20:17:07 -08:00
if ( ! empty ( $_POST [ 'multiselect' ]) && varset ( $_POST [ 'e__execute_batch' ]) && ( varset ( $_POST [ 'etrigger_batch' ]) == 'options__convert_to_jpeg' ))
{
// $type = str_replace('options__','',$_POST['etrigger_batch']);
$ids = implode ( " , " , e107 :: getParser () -> filter ( $_POST [ 'multiselect' ], 'int' ));
$this -> convertImagesToJpeg ( $ids );
}
2018-08-07 17:05:08 -07:00
2017-11-16 20:17:07 -08:00
if ( ! empty ( $_POST [ 'multiselect' ]) && varset ( $_POST [ 'e__execute_batch' ]) && ( varset ( $_POST [ 'etrigger_batch' ]) == 'options__convert_all_to_jpeg' ))
{
// $type = str_replace('options__','',$_POST['etrigger_batch']);
$ids = implode ( " , " , e107 :: getParser () -> filter ( $_POST [ 'multiselect' ], 'int' ));
$this -> convertImagesToJpeg ( $ids , 'all' );
2018-08-07 17:05:08 -07:00
} */
2012-09-03 23:02:45 +00:00
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'
);
2020-12-31 16:14:43 -08:00
return $frm -> selectbox ( 'resize_method' , $options , $curval ) . " <div class='field-help'> " . IMALAN_4 . '</div>' ;
2012-06-06 07:39:42 +00:00
}
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
2020-12-31 16:14:43 -08:00
$degrees = ( $type === 'rotate_cw' ) ? 270 : 90 ;
2012-07-29 02:36:18 +00:00
// $mes->addDebug("Rotate Mode Set: ".$type);
//TODO GIF and PNG rotation.
2020-12-31 16:14:43 -08:00
if ( $sql -> select ( 'core_media' , 'media_url' , 'media_id IN (' . $ids . " ) AND media_type = 'image/jpeg' " ))
2012-07-29 02:36:18 +00:00
{
2016-11-25 17:59:17 -08:00
while ( $row = $sql -> fetch ())
2012-07-29 02:36:18 +00:00
{
$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 )
{
2020-12-31 16:14:43 -08:00
$mes -> addError ( LAN_IMA_002 . ': ' . basename ( $original ));
return null ;
2012-09-03 23:02:45 +00:00
}
2020-12-31 16:14:43 -08:00
$srch = array ( '.jpg' , '.jpeg' );
$cacheFile = str_replace ( $srch , '' , strtolower ( basename ( $original ))) . " _(.*) \ .cache \ .bin " ;
2012-07-29 02:36:18 +00:00
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 )
{
2020-12-31 16:14:43 -08:00
$mes -> addError ( LAN_IMA_002 . ': ' . basename ( $original ));
}
2012-07-29 02:36:18 +00:00
}
}
}
2012-09-03 23:02:45 +00:00
/**
2021-12-03 14:58:33 -08:00
* Resize a single image .
* @ param string $oldpath
* @ param int $w
* @ param int $h
* @ return bool | void
2012-09-03 23:02:45 +00:00
*/
2020-12-06 11:33:09 -08:00
public function resizeImage ( $oldpath , $w , $h )
2012-09-03 23:02:45 +00:00
{
2020-12-31 16:14:43 -08:00
if ( e107 :: getMedia () -> resizeImage ( $oldpath , $oldpath , compact ( 'w' , 'h' )))
2012-09-03 23:02:45 +00:00
{
2020-12-06 11:33:09 -08:00
return true ;
2012-09-03 23:02:45 +00:00
}
2020-12-06 11:33:09 -08:00
2012-09-03 23:02:45 +00:00
}
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 ;
2020-12-31 16:14:43 -08:00
if ( $sql -> select ( 'core_media' , 'media_id,media_url' , 'media_id IN (' . $ids . " ) AND media_type = 'image/jpeg' " ))
2012-09-03 23:02:45 +00:00
{
2016-11-25 17:59:17 -08:00
while ( $row = $sql -> fetch ())
2012-09-03 23:02:45 +00:00
{
$path = $tp -> replaceConstants ( $row [ 'media_url' ]);
2020-12-31 16:14:43 -08:00
$mes -> addDebug ( 'Attempting to resize: ' . basename ( $path ));
2012-09-03 23:02:45 +00:00
if ( $this -> resizeImage ( $path , $img_import_w , $img_import_h ))
{
2020-12-14 16:21:48 -08:00
$info = $fl -> getFileInfo ( $path );
2020-12-31 16:14:43 -08:00
$mes -> addSuccess ( LAN_IMA_004 . ': ' . basename ( $path ));
2012-09-03 23:02:45 +00:00
$mes -> addSuccess ( print_a ( $info , true ));
2020-12-31 16:14:43 -08:00
$dim = ( int ) $info [ 'img-width' ] . ' x ' . ( int ) $info [ 'img-height' ];
$sql2 -> update ( 'core_media' , " media_dimensions = ' " . $dim . " ', media_size = ' " . ( int ) $info [ 'fsize' ] . " ' WHERE media_id = " . ( int ) $row [ 'media_id' ] . '' );
2012-09-03 23:02:45 +00:00
}
else
{
2020-12-31 16:14:43 -08:00
$mes -> addError ( LAN_IMA_004 . ': ' . basename ( $path ));
2012-09-03 23:02:45 +00:00
}
}
}
2017-11-16 20:17:07 -08:00
}
2018-08-07 17:05:08 -07:00
public function convertImagesToJpeg ( $ids , $mode = null )
2017-11-16 20:17:07 -08:00
{
$sql = e107 :: getDb ();
$tp = e107 :: getParser ();
$mm = e107 :: getMedia ();
2020-12-31 16:14:43 -08:00
$insert = empty ( $mode ) ? 'media_id IN (' . $ids . ') AND ' : ' media_size > 225000 AND ' ;
2017-11-16 20:17:07 -08:00
2020-12-31 16:14:43 -08:00
$data = $sql -> retrieve ( 'core_media' , 'media_id,media_url' , $insert . " (media_type = 'image/png' OR media_type = 'image/gif') " , true , true );
2017-11-16 20:17:07 -08:00
if ( empty ( $data ))
{
return null ;
}
foreach ( $data as $row )
{
$path = $tp -> replaceConstants ( $row [ 'media_url' ]);
if ( $jpegFile = $mm -> convertImageToJpeg ( $path , true ))
{
2018-08-07 17:05:08 -07:00
$url = $tp -> createConstants ( $jpegFile , 1 );
2017-11-16 20:17:07 -08:00
$size = filesize ( $jpegFile );
$update = array (
'media_size' => $size ,
'media_url' => $url ,
'media_type' => 'image/jpeg' ,
'WHERE' => 'media_id = ' . $row [ 'media_id' ]
);
$message = basename ( $path ) . SEP . basename ( $url );
2020-12-31 16:14:43 -08:00
if ( $sql -> update ( 'core_media' , $update ))
2017-11-16 20:17:07 -08:00
{
e107 :: getMessage () -> addSuccess ( $message );
}
else
{
e107 :: getMessage () -> addError ( $message );
}
}
}
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
2020-12-31 16:14:43 -08:00
$text = '' ;
2018-01-26 15:54:54 -08:00
2012-07-18 06:34:26 +00:00
$pref = e107 :: getPref ();
2012-06-06 07:39:42 +00:00
2020-12-20 19:42:09 -08:00
// $options = array(
2018-01-26 15:54:54 -08:00
// "news-image" => LAN_IMA_O_001,
// "news-bbcode" => LAN_IMA_O_002,
// "page-bbcode" => LAN_IMA_O_003,
2015-05-01 12:46:46 +02:00
// "featurebox-image" => LAN_IMA_O_004,
// "featurebox-bbcode" => LAN_IMA_O_005,
2020-12-20 19:42:09 -08:00
// );
2018-01-26 15:54:54 -08:00
$options = $pref [ 'resize_dimensions' ];
/* @deprecated */
if ( ! empty ( $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
{
2022-12-10 07:06:47 -08:00
$options [ $k ] = ucfirst ( $k ) . ' ' . defset ( 'LAN_IMA_O_006' );
2012-07-18 06:34:26 +00:00
}
}
2018-01-26 15:54:54 -08:00
unset ( $options [ 'news-image' ]); /* @deprecated */
$text = " <table class='table table-striped table-condensed table-bordered' style='width:400px; margin-bottom:0'>
< tr >
< th > " .LAN_TYPE. " </ th >
< th class = 'text-right' > " .LAN_WIDTH. " </ th >
< th class = 'text-right' > " .LAN_HEIGHT. " </ th >
</ tr > \n " ;
2012-06-06 07:39:42 +00:00
foreach ( $options as $key => $title )
{
2020-12-31 16:14:43 -08:00
$title = ucwords ( str_replace ( '-' , ' ' , $key ));
2020-12-25 10:23:56 -08:00
$valW = ! empty ( $curval [ $key ][ 'w' ]) ? $curval [ $key ][ 'w' ] : 400 ;
$valH = ! empty ( $curval [ $key ][ 'h' ]) ? $curval [ $key ][ 'h' ] : 400 ;
2012-07-09 01:07:51 +00:00
2018-01-26 15:54:54 -08:00
$text .= " <tr><td style='width:45%'> " . $title . " </td><td class='text-right'> " ;
$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' /> " ;
$text .= " </td><td class='text-right'><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' /> " ;
2020-12-31 16:14:43 -08:00
$text .= '</td></tr>' ;
2018-01-26 15:54:54 -08:00
}
2020-12-31 16:14:43 -08:00
$text .= '</table>' ;
2012-06-06 07:39:42 +00:00
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);
2020-12-31 16:14:43 -08:00
if ( $value === 'batch' )
2012-07-29 02:36:18 +00:00
{
2017-11-16 20:17:07 -08:00
$arr = array (
2020-12-31 16:14:43 -08:00
'resize_2048' => 'Reduce Oversized Images' ,
'rotate_cw' => 'Rotate 90° cw' ,
'rotate_ccw' => 'Rotate 90° ccw' ,
'convert_to_jpeg' => 'Convert to jpeg format'
2017-11-16 20:17:07 -08:00
);
if ( deftrue ( 'e_DEBUG' ))
{
2020-12-31 16:14:43 -08:00
$arr [ 'convert_all_to_jpeg' ] = 'Convert All Oversized to jpeg format' ; // rare situations.
2017-11-16 20:17:07 -08:00
}
return $arr ;
2012-07-29 02:36:18 +00:00
}
2020-12-31 16:14:43 -08:00
if ( $_GET [ 'action' ] === 'edit' )
2012-07-29 02:36:18 +00:00
{
2017-11-16 20:17:07 -08:00
return null ;
2012-07-29 02:36:18 +00:00
}
2016-12-15 15:35:18 +01:00
$tagid = vartrue ( $_GET [ 'tagid' ]);
$tagid = e107 :: getParser () -> filter ( $tagid );
2022-04-02 09:34:06 -07:00
$model = $this -> getController () -> getListModel ();
$path = $model -> get ( 'media_url' );
$title = $model -> get ( 'media_name' );
$id = $model -> get ( 'media_id' );
2012-05-25 11:30:49 +00:00
$preview = basename ( $path );
2012-05-28 13:06:09 +00:00
2020-12-31 16:14:43 -08: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
2013-03-09 19:22:30 -08:00
2021-09-04 15:06:19 +02:00
$for = ( string ) $this -> getController () -> getQuery ( 'for' );
2015-05-10 11:16:55 -07:00
2016-10-31 20:34:59 -07:00
if ( strpos ( $for , '_file' ) !== false )
2015-05-10 11:16:55 -07:00
{
$type = 'file' ;
}
else
{
$type = 'image' ;
}
// File Picker.
2020-12-31 16:14:43 -08:00
if ( $_GET [ 'action' ] === 'dialog' && ( $type === 'file' ))
2012-07-29 02:36:18 +00:00
{
2020-12-31 16:14:43 -08:00
$text = " <input type='button' value='Select' data-placement='left' class='e-tip e-media-select e-dialog-save e-dialog-close btn btn-primary btn-large' data-id=' { $id } ' data-name= \" " . $title . " \" data-type='file' data-target=' { $tagid } ' data-bbcode=' { $bbcode } ' data-path=' { $path } ' data-preview=' { $preview } ' title= \" " . $title . '" />' ;
2012-07-29 02:36:18 +00:00
}
2015-05-10 11:16:55 -07:00
else
{
2022-04-02 09:34:06 -07:00
if ( $dimensions = $model -> get ( 'media_dimensions' ))
{
$title .= " ( " . $dimensions . " ) " ;
}
$type = $model -> get ( 'media_type' );
$action = $this -> getController () -> getAction ();
$att = [ 'query' => e_QUERY . " &after= " . $action ];
$url = $this -> media_sef ( '' , 'read' , [ 'url' => 1 ]);
$modal = ( strpos ( $type , 'application' ) === false ) ? 'e-modal' : '' ;
if ( $action === 'grid' )
{
$text = " <a class='btn btn-default " . $modal . " ' title=' " . LAN_VIEW . " ' href=' " . $url . " ' data-modal-caption= \" " . $title . " \" target='_blank'> " . $this -> tp -> toGlyph ( 'e-search-16' ) . " </a> " ;
$att [ 'icons' ] = [
'edit' => $this -> tp -> toGlyph ( 'e-edit-16' ),
'delete' => $this -> tp -> toGlyph ( 'e-delete-16' ),
];
$text .= $this -> renderValue ( 'options' , $value , $att , $id );
}
else
{
// $text = "<a class='btn btn-default ".$modal."' href='".$url."' data-modal-caption=\"".$title."\" target='_blank'>".$this->tp->toGlyph('e-search-32')."</a>";
$text = $this -> renderValue ( 'options' , $value , $att , $id );
}
2015-05-10 11:16:55 -07:00
}
2017-07-20 13:28:19 -07:00
2020-12-31 16:14:43 -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
2020-02-21 14:20:33 -08:00
private function getMediaType ()
2014-11-22 16:35:45 -08:00
{
2020-12-31 16:14:43 -08:00
list ( $type , $extra ) = explode ( '/' , $this -> getController () -> getFieldVar ( 'media_type' ));
2020-02-21 14:20:33 -08:00
$category = $this -> getController () -> getFieldVar ( 'media_category' );
if ( strpos ( $category , '_icon' ) === 0 )
2014-11-22 16:35:45 -08:00
{
2020-02-21 14:20:33 -08:00
$type = 'icon' ;
}
return $type ;
}
2017-09-22 14:55:44 -07:00
2020-02-21 14:20:33 -08:00
function media_preview ( $curVal , $mode , $attributes , $id = null )
{
2020-12-31 16:14:43 -08:00
if ( $mode === 'filter' || $mode === 'batch' || $mode === 'inline' )
2020-02-21 14:20:33 -08:00
{
return null ;
}
2014-11-22 16:35:45 -08:00
2020-02-21 14:20:33 -08:00
$attributes [ 'type' ] = 'image' ;
$value = $this -> getController () -> getFieldVar ( 'media_url' );
$type = $this -> getMediaType ();
2014-11-22 16:35:45 -08:00
2020-02-21 14:20:33 -08:00
if ( $this -> getController () -> getAction () === 'grid' )
{
2022-04-02 09:34:06 -07:00
$size = 235 ;
// min-height:".$size."px
return " <div> " . e107 :: getMedia () -> previewTag ( $value , array ( 'type' => $type , 'w' => $size , 'h' => $size , 'crop' => 1 )) . '</div>' ;
2014-11-22 16:35:45 -08:00
}
2012-04-22 06:19:21 +00:00
2020-02-21 14:20:33 -08:00
$size = ( $mode === 'write' ) ? 400 : 180 ;
return e107 :: getMedia () -> previewTag ( $value , array ( 'type' => $type , 'w' => $size , 'h' => $size ));
2014-11-22 16:35:45 -08:00
}
2012-04-22 06:19:21 +00:00
2017-04-19 15:04:05 -07:00
function media_sef ( $curVal , $mode , $attributes , $id = null )
{
2020-12-31 16:14:43 -08:00
if ( $mode === 'filter' || $mode === 'batch' )
2020-02-21 14:20:33 -08:00
{
return null ;
}
2017-04-19 15:04:05 -07:00
$val = $this -> getController () -> getFieldVar ( 'media_url' );
2020-02-21 14:20:33 -08:00
$type = $this -> getMediaType ();
switch ( $type )
2017-04-19 15:04:05 -07:00
{
2020-12-31 16:14:43 -08:00
case 'application' :
case 'audio' :
case 'icon' :
case 'file' :
case 'video' :
2020-02-21 14:20:33 -08:00
$path = e107 :: getParser () -> replaceConstants ( $val , 'abs' );
break ;
2017-04-19 15:04:05 -07:00
2020-02-21 14:20:33 -08:00
default :
$parm = array ( 'w' => 800 );
$path = e107 :: getParser () -> thumbUrl ( $val , $parm );
// code to be executed if n is different from all labels;
2017-04-19 15:04:05 -07:00
}
2020-05-25 12:34:18 -07:00
$url = SITEURLBASE . $path ;
2022-04-02 09:34:06 -07:00
if ( ! empty ( $attributes [ 'url' ]))
{
return $url ;
}
return " <a href=' " . $url . " ' rel='external' title=' " . LAN_EFORM_010 . " ' target='_blank'><small> " . $url . '</small></a>' ;
2020-02-21 14:20:33 -08:00
2017-04-19 15:04:05 -07: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' ;
2020-12-31 16:14:43 -08:00
protected $table = 'core_media' ;
2010-03-09 16:05:41 +00:00
2020-12-31 16:14:43 -08:00
protected $listQry = 'SELECT SQL_CALC_FOUND_ROWS 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
2020-12-31 16:14:43 -08:00
protected $pid = 'media_id' ;
2009-11-07 11:20:34 +00:00
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 ;
2016-11-02 09:29:18 +01:00
public $deleteConfirmMessage = IMALAN_129 ;
2010-03-09 16:05:41 +00:00
2022-04-02 09:34:06 -07:00
protected $grid = array ( 'id' => 'media_id' , 'title' => 'media_name' , 'image' => 'media_preview' , 'body' => '' , 'class' => 'col-sm-6 col-md-4 col-lg-2' , 'perPage' => 24 , 'carousel' => false );
2017-09-22 14:55:44 -07:00
2010-03-09 16:05:41 +00:00
2020-12-31 16:14:43 -08:00
protected $preftabs = array ( IMALAN_78 , IMALAN_89 , 'Youtube' );
2014-03-12 14:09:48 -07: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 ),
2018-08-07 17:05:08 -07:00
'media_preview' => array ( 'title' => LAN_PREVIEW , 'type' => 'method' , 'data' => false , 'forced' => true , 'width' => '110px' , 'thclass' => 'center' , 'class' => 'center' ),
'media_url' => array ( 'title' => IMALAN_110 , 'type' => 'text' , 'data' => 'str' , 'inline' => false , 'thclass' => 'left' , 'class' => 'left' , 'width' => 'auto' , 'writeParms' => 'size=xxlarge' ),
'media_category' => array ( 'title' => LAN_CATEGORY , 'type' => 'comma' , 'inline' => false , 'data' => 'str' , 'width' => '10%' , 'filter' => true , 'batch' => true , 'class' => 'left' ),
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),
2016-10-18 16:10:52 -07:00
'media_name' => array ( 'title' => LAN_TITLE , 'type' => 'text' , 'data' => 'str' , 'inline' => true , 'width' => 'auto' , 'writeParms' => array ( 'size' => 'xxlarge' )),
'media_caption' => array ( 'title' => LAN_CAPTION , 'type' => 'text' , 'data' => 'str' , 'inline' => true , 'width' => 'auto' , 'writeParms' => array ( 'size' => 'xxlarge' )),
2011-06-07 13:01:36 +00:00
// media_description is type = textarea until bbarea can be reduced to not include youtube etc
2017-04-19 15:31:57 -07:00
'media_sef' => array ( 'title' => LAN_URL , 'readonly' => 1 , 'type' => 'method' , 'data' => false ),
2017-04-19 15:04:05 -07:00
2016-10-18 16:10:52 -07:00
'media_description' => array ( 'title' => LAN_DESCRIPTION , 'type' => 'textarea' , 'data' => 'str' , 'width' => 'auto' , 'thclass' => 'left first' , 'readParms' => 'truncate=100' , 'writeParms' => 'size=xxlarge&counter=0' ),
2016-10-01 11:26:30 +02:00
'media_type' => array ( 'title' => IMALAN_118 , 'type' => 'dropdown' , 'data' => 'str' , 'filter' => true , 'width' => 'auto' , 'noedit' => TRUE ),
2011-05-07 06:22:44 +00:00
'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
2016-10-01 11:26:30 +02:00
'media_size' => array ( 'title' => LAN_SIZE , 'type' => 'number' , 'data' => 'int' , 'width' => 'auto' , 'readonly' => 2 ),
'media_dimensions' => array ( 'title' => IMALAN_120 , 'type' => 'text' , 'data' => 'str' , 'width' => '5%' , 'readonly' => TRUE , 'class' => 'nowrap' , 'noedit' => TRUE ),
2013-02-25 03:20:11 -08:00
'media_userclass' => array ( 'title' => LAN_USERCLASS , 'type' => 'userclass' , 'data' => 'str' , 'inline' => true , 'width' => '10%' , 'thclass' => 'center' , 'filter' => TRUE , 'batch' => TRUE ),
2016-10-01 11:26:30 +02:00
'media_tags' => array ( 'title' => IMALAN_132 , 'type' => 'tags' , 'inline' => true , 'data' => 'str' , 'width' => '10%' , 'filter' => TRUE , 'batch' => TRUE ),
'media_usedby' => array ( 'title' => IMALAN_21 , 'type' => 'hidden' , '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 ,
2018-07-19 12:43:04 -07:00
'audio' => e_MEDIA_FILE ,
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
);
2014-11-22 16:35:45 -08:00
2016-03-06 00:23:41 -08:00
protected $fieldpref = array ( 'media_id' , 'media_name' , 'media_caption' , '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 (
2014-03-12 14:09:48 -07:00
'image_post' => array ( 'title' => IMALAN_1 , 'tab' => 0 , 'type' => 'boolean' , 'data' => 'int' , 'writeParms' => 'help=IMALAN_2' ),
2012-06-06 07:39:42 +00:00
'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' ),
2022-04-02 09:34:06 -07:00
// XXX TBD 'thumbnail_per_page' => array('title'=> "Thumbnails per page", 'type'=>'dropdown', 'data'=>'int', 'help'=>'Applies to the Media Library page', 'writeParms'=>['optArray'=> [8=>8, 12=>12, 16=>16, 24=>24, 36=>36, 48=>48]]),
2017-11-16 20:17:07 -08:00
'thumbnail_quality' => array ( 'title' => IMALAN_73 , 'type' => 'number' , 'data' => 'int' , 'writeParms' => '' , 'help' => IMALAN_74 ),
2022-04-02 09:34:06 -07:00
2017-11-16 20:17:07 -08:00
// 'convert_to_jpeg' => array('title'=> IMALAN_182, 'type'=>'number', 'data'=>'int', 'writeParms'=> array('tdClassRight'=>'form-inline', 'post'=> CORE_LAN_KB), 'help'=>IMALAN_183),
'convert_to_jpeg' => array ( 'title' => IMALAN_182 , 'type' => 'boolean' , 'data' => 'int' , 'writeParms' => '' , 'help' => IMALAN_183 ),
2020-12-08 18:15:08 -08:00
'convert_to_webp' => array ( 'title' => IMALAN_187 , 'type' => 'boolean' , 'data' => 'int' , 'writeParms' => '' , 'help' => IMALAN_189 ),
'thumb_to_webp' => array ( 'title' => IMALAN_188 , 'type' => 'boolean' , 'data' => 'int' , 'writeParms' => '' , 'help' => IMALAN_189 ),
2017-11-16 20:17:07 -08:00
'im_width' => array ( 'title' => IMALAN_75 , 'type' => 'number' , 'data' => 'int' , 'writeParms' => '' , 'help' => IMALAN_76 ),
'im_height' => array ( 'title' => IMALAN_77 , 'type' => 'number' , 'data' => 'int' , 'writeParms' => '' , 'help' => IMALAN_76 ),
2018-01-26 15:54:54 -08:00
'resize_dimensions' => array ( 'title' => IMALAN_184 , 'type' => 'method' , 'data' => 'str' ),
2012-07-12 10:15:12 +00:00
2015-05-01 12:46:46 +02:00
'watermark_activate' => array ( 'title' => IMALAN_80 , 'tab' => 1 , 'type' => 'number' , 'data' => 'str' , 'help' => IMALAN_81 ), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
'watermark_text' => array ( 'title' => IMALAN_82 , 'tab' => 1 , 'type' => 'text' , 'data' => 'str' , 'help' => IMALAN_83 ), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
'watermark_font' => array ( 'title' => IMALAN_84 , 'tab' => 1 , 'type' => 'dropdown' , 'data' => 'str' , 'help' => IMALAN_85 ), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
'watermark_size' => array ( 'title' => IMALAN_86 , 'tab' => 1 , 'type' => 'number' , 'data' => 'int' , 'help' => IMALAN_87 ), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
2012-07-14 10:40:40 +00:00
2015-05-08 10:49:52 +02:00
'watermark_pos' => array ( 'title' => IMALAN_88 , 'tab' => 1 , 'type' => 'dropdown' , 'data' => 'str' , 'help' => IMALAN_88 ), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
2015-05-01 12:46:46 +02:00
'watermark_margin' => array ( 'title' => IMALAN_90 , 'tab' => 1 , 'type' => 'number' , 'data' => 'int' , 'help' => IMALAN_91 ), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
2012-07-14 10:40:40 +00:00
2015-05-01 12:46:46 +02:00
'watermark_color' => array ( 'title' => IMALAN_92 , 'tab' => 1 , 'type' => 'text' , 'data' => 'str' , 'help' => IMALAN_93 ), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
'watermark_shadowcolor' => array ( 'title' => IMALAN_94 , 'tab' => 1 , 'type' => 'text' , 'data' => 'str' , 'help' => IMALAN_95 ), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
2012-07-14 10:40:40 +00:00
2015-05-01 12:46:46 +02:00
'watermark_opacity' => array ( 'title' => IMALAN_96 , 'tab' => 1 , 'type' => 'number' , 'data' => 'int' , 'help' => IMALAN_97 ), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
2015-06-08 15:55:05 -07:00
2014-03-12 14:09:48 -07:00
// https://developers.google.com/youtube/player_parameters
2020-12-31 16:14:43 -08:00
'youtube_apikey' => array ( 'title' => 'YouTube Public API key' , 'tab' => 2 , 'type' => 'text' , 'data' => 'str' , 'help' => IMALAN_99 , 'writeParms' => array ( 'size' => 'xxlarge' , 'post' => '' )),
2015-06-08 15:55:05 -07:00
2020-12-31 16:14:43 -08:00
'youtube_default_account' => array ( 'title' => IMALAN_98 , 'tab' => 2 , 'type' => 'text' , 'data' => 'str' , 'help' => IMALAN_99 , 'writeParms' => array ( 'size' => 'xxlarge' , 'post' => '' )),
2015-03-31 14:48:07 -07:00
2015-05-01 12:46:46 +02:00
'youtube_rel' => array ( 'title' => IMALAN_100 , 'tab' => 2 , 'type' => 'boolean' , 'data' => 'int' , 'help' => '' ),
'youtube_showinfo' => array ( 'title' => IMALAN_101 , 'tab' => 2 , 'type' => 'boolean' , 'data' => 'int' , 'help' => '' ),
'youtube_cc_load_policy' => array ( 'title' => IMALAN_102 , 'tab' => 2 , 'type' => 'boolean' , 'data' => 'int' , 'help' => '' ),
'youtube_modestbranding' => array ( 'title' => IMALAN_103 , 'tab' => 2 , 'type' => 'boolean' , 'data' => 'int' , 'help' => '' ),
'youtube_bbcode_responsive' => array ( 'title' => IMALAN_104 , 'tab' => 2 , 'type' => 'boolean' , 'data' => 'int' , 'help' => '' ),
2014-10-22 17:59:15 -07:00
2014-03-12 14:09:48 -07:00
//
2012-06-06 07:39:42 +00:00
);
2012-06-17 11:52:10 +00:00
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 ();
2021-01-30 19:21:23 -08:00
protected $fontawesome ; // frontend loaded version from theme.xml.
2015-02-22 17:41:55 -08:00
2009-12-02 10:03:53 +00:00
function init ()
{
2021-01-30 19:21:23 -08:00
$this -> fontawesome = ( int ) e107 :: getTheme () -> getFontAwesome ();
2017-07-20 13:28:19 -07:00
2020-12-31 16:14:43 -08:00
$this -> prefs [ 'youtube_apikey' ][ 'writeParms' ][ 'post' ] = " <a target='_blank' href='https://code.google.com/apis/console/'> " . LAN_MORE . '</a>' ;
2016-10-14 22:09:34 +02:00
2015-02-22 17:41:55 -08:00
if ( E107_DEBUG_LEVEL > 0 )
{
$this -> fields [ 'media_url' ][ 'inline' ] = true ;
}
2009-12-02 10:03:53 +00:00
$sql = e107 :: getDb ();
2016-02-15 00:14:45 -08:00
// $sql->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");
2022-04-02 09:34:06 -07:00
$sql -> gen ( 'SELECT media_cat_title, media_cat_owner, media_cat_category FROM `#core_media_cat` WHERE media_cat_title !="" ' );
2015-02-22 17:41:55 -08:00
while ( $row = $sql -> fetch ())
2009-12-02 10:03:53 +00:00
{
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' ];
2016-10-18 16:10:52 -07:00
// $ownerLabel = (substr($owner,0,1) == '_') ? '' : $owner.": ";
2010-03-09 16:05:41 +00:00
$this -> cats [ $cat ] = $row [ 'media_cat_title' ];
2009-12-02 10:03:53 +00:00
}
2021-01-30 19:21:23 -08:00
2009-12-02 10:03:53 +00:00
asort ( $this -> cats );
2013-01-09 10:49:33 +02:00
2015-02-01 17:28:38 -08:00
$tmp = $sql -> retrieve ( 'core_media' , 'media_type' , 'media_type !="" GROUP BY media_type' , true );
$mimeTypes = array ();
foreach ( $tmp as $val )
{
$id = $val [ 'media_type' ];
$mimeTypes [ $id ] = $id ;
}
2022-04-02 09:34:06 -07:00
2022-04-02 13:03:01 -07:00
$mimeTypes [ 'image/%' ] = 'image/*' ;
$mimeTypes [ 'video/%' ] = 'video/*' ;
$mimeTypes [ 'audio/%' ] = 'audio/*' ;
$mimeTypes [ 'application/%' ] = 'application/*' ;
2015-02-01 17:28:38 -08:00
asort ( $mimeTypes );
2013-01-09 10:49:33 +02:00
$this -> fields [ 'media_category' ][ 'writeParms' ] = $this -> cats ;
2015-02-01 17:28:38 -08:00
$this -> fields [ 'media_type' ][ 'writeParms' ] = $mimeTypes ;
2012-07-12 10:15:12 +00:00
$pref = e107 :: getPref ();
$tp = e107 :: getParser ();
$fl = e107 :: getFile ();
2020-12-31 16:14:43 -08:00
$path = e_THEME . $pref [ 'sitetheme' ] . '/fonts/' ;
2012-07-12 10:15:12 +00:00
2020-12-31 16:14:43 -08:00
$fDir = $fl -> get_files ( e_THEME . $pref [ 'sitetheme' ] . '/fonts/' , '.ttf' , '' , 2 );
2016-10-01 11:26:30 +02:00
$fonts = array ( 0 => LAN_NONE );
2012-07-12 10:15:12 +00:00
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 (
2016-10-01 11:26:30 +02:00
'BR' => IMALAN_133 ,
'BL' => IMALAN_134 ,
'TR' => IMALAN_135 ,
'TL' => IMALAN_136 ,
'C' => IMALAN_137 ,
'R' => IMALAN_138 ,
'L' => IMALAN_139 ,
'T' => IMALAN_140 ,
'B' => IMALAN_141 ,
'*' => IMALAN_142
2012-07-12 10:15:12 +00:00
);
$this -> prefs [ 'watermark_pos' ][ 'writeParms' ] = $wm_pos ;
$this -> prefs [ 'watermark_pos' ][ 'readParms' ] = $wm_pos ;
2014-01-09 04:42:13 -08:00
e107 :: getCache () -> clearAll ( 'image' );
2012-07-12 10:15:12 +00:00
2020-12-31 16:14:43 -08:00
if ( e_AJAX_REQUEST && isset ( $_GET [ 'search' ]))
2018-08-11 14:06:21 -07:00
{
$parm = array ( 'search' => $tp -> filter ( $_GET [ 'search' ]));
2017-04-12 09:50:07 -07:00
2018-08-11 14:06:21 -07:00
switch ( $this -> getAction ())
{
2020-12-31 16:14:43 -08:00
case 'youtube' :
2018-08-11 14:06:21 -07:00
echo $this -> youtubeTab ( $parm );
break ;
2020-12-31 16:14:43 -08:00
case 'glyph' :
2018-09-08 11:37:39 -07:00
echo $this -> glyphTab ( null , $parm );
2018-08-11 14:06:21 -07:00
break ;
2020-12-31 16:14:43 -08:00
case 'icon' :
2018-09-08 11:37:39 -07:00
echo $this -> iconTab ( null , $parm );
2018-08-11 14:06:21 -07:00
break ;
2020-12-31 16:14:43 -08:00
case 'image2' :
2018-08-11 14:06:21 -07:00
$cat = $tp -> filter ( $_GET [ 'for' ]);
echo $this -> imageTab2 ( $cat , $parm );
break ;
2020-12-31 16:14:43 -08:00
case 'video' :
2018-08-11 14:06:21 -07:00
$cat = $tp -> filter ( $_GET [ 'for' ]);
echo $this -> videoTab ( $cat , $parm );
break ;
2017-04-12 09:50:07 -07:00
2020-12-31 16:14:43 -08:00
case 'audio' :
2018-08-11 14:06:21 -07:00
$cat = $tp -> filter ( $_GET [ 'for' ]);
echo $this -> audioTab ( $cat , $parm );
break ;
2017-04-12 09:50:07 -07:00
2018-08-11 14:06:21 -07:00
default :
// code to be executed if n is different from all labels;
}
2017-04-12 09:50:07 -07:00
2018-08-11 14:06:21 -07:00
exit ;
}
2017-04-12 09:50:07 -07:00
2022-04-02 09:34:06 -07:00
2018-08-11 14:06:21 -07:00
/*
2018-07-16 17:14:10 -07:00
if ( $this -> getAction () === 'youtube' )
2014-01-08 15:51:14 -08:00
{
2018-08-11 14:06:21 -07:00
2018-07-16 17:14:10 -07:00
echo $this -> youtubeTab ( $parm );
2014-01-08 15:51:14 -08:00
exit ;
}
2018-08-11 14:06:21 -07:00
if ( $this -> getAction () === 'glyph' )
{
$parm = array ( 'search' => $tp -> filter ( $_GET [ 'search' ]));
echo $this -> glyphTab ( $parm );
exit ;
}
2014-01-08 15:51:14 -08:00
2018-07-16 17:14:10 -07:00
if ( $this -> getAction () === 'glyph' )
2014-01-09 04:42:13 -08:00
{
2016-12-15 15:35:18 +01:00
$parm = array ( 'search' => $tp -> filter ( $_GET [ 'search' ]));
2014-01-09 04:42:13 -08:00
echo $this -> glyphTab ( $parm );
exit ;
}
2018-07-16 17:14:10 -07:00
if ( $this -> getAction () === 'video' )
{
$parm = array ( 'search' => $tp -> filter ( $_GET [ 'search' ]));
2018-07-26 19:13:27 -07:00
$cat = $tp -> filter ( $_GET [ 'for' ]);
echo $this -> videoTab ( $cat , $parm );
2018-07-16 17:14:10 -07:00
exit ;
}
if ( $this -> getAction () === 'audio' )
{
$parm = array ( 'search' => $tp -> filter ( $_GET [ 'search' ]));
2018-07-26 19:13:27 -07:00
$cat = $tp -> filter ( $_GET [ 'for' ]);
echo $this -> audioTab ( $cat , $parm );
2018-07-16 17:14:10 -07:00
exit ;
}
2018-07-22 14:45:26 -07:00
if ( $this -> getAction () === 'image2' )
{
$parm = array ( 'search' => $tp -> filter ( $_GET [ 'search' ]));
$cat = $tp -> filter ( $_GET [ 'for' ]);
echo $this -> imageTab2 ( $cat , $parm );
exit ;
}
2018-08-11 14:06:21 -07:00
*/
2020-12-18 19:55:12 -08:00
/*
2014-01-09 04:42:13 -08:00
if ( $this -> getAction () == 'nav' )
2012-08-04 04:15:41 +00:00
{
2020-12-18 19:55:12 -08:00
echo $this -> navPage (); \
$this -> getResponse () -> setIframeMod (); // disable header/footer menus etc.
print_a ( $_GET );
2012-08-04 04:15:41 +00:00
}
2020-12-18 19:55:12 -08: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.
2020-12-31 16:14:43 -08: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
}
2017-07-20 13:28:19 -07: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
{
2017-07-20 13:28:19 -07:00
2016-03-10 13:33:11 -08:00
// e107::js('tinymce4','plugins/compat3x/tiny_mce_popup.js');
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' ))
{
2020-12-31 16:14:43 -08:00
$this -> setPosted ( 'media_category' , '_common' );
$this -> getModel () -> set ( 'media_category' , '_common' );
2012-04-28 01:31:30 +00:00
}
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
}
2014-01-09 04:42:13 -08:00
2010-10-04 22:14:05 +00:00
}
2009-12-02 10:03:53 +00:00
2022-04-02 09:34:06 -07:00
/** Wildcard support for media-type filter */
function handleGridMediaTypeFilter ( $var )
{
2022-04-02 13:03:01 -07:00
if ( strpos ( $var , '%' ) !== false )
2022-04-02 09:34:06 -07:00
{
return " m.media_type LIKE ' " . $var . " ' " ;
}
return " m.media_type = ' " . $var . " ' " ;
}
2018-08-07 17:05:08 -07:00
/**
* Handle Batch options as defined in media_form_ui :: options (); handle + action + field + Batch
* @ param $selected
* @ param $type
*/
function handleListOptionsBatch ( $selected , $type )
{
/** @var media_form_ui $frm */
$frm = $this -> getUI ();
2020-12-31 16:14:43 -08:00
$ids = implode ( ',' , $selected );
2018-08-07 17:05:08 -07:00
switch ( $type )
{
2020-12-31 16:14:43 -08:00
case 'resize_2048' :
2018-08-07 17:05:08 -07:00
$frm -> resizeImages ( $ids , $type );
break ;
2020-12-31 16:14:43 -08:00
case 'rotate_cw' :
case 'rotate_ccw' :
2018-08-07 17:05:08 -07:00
$frm -> rotateImages ( $ids , $type );
break ;
2020-12-31 16:14:43 -08:00
case 'convert_to_jpeg' :
2018-08-07 17:05:08 -07:00
$frm -> convertImagesToJpeg ( $ids );
break ;
2020-12-31 16:14:43 -08:00
case 'convert_all_to_jpeg' :
2018-08-07 17:05:08 -07:00
$frm -> convertImagesToJpeg ( $ids , 'all' );
break ;
default :
// code to be executed if n is different from all labels;
}
}
2012-08-04 04:15:41 +00:00
function navPage () // no functioning correctly - see e_AJAX_REQUEST above.
{
2017-07-20 13:28:19 -07:00
2020-12-31 16:14:43 -08:00
$bbcodeMode = ( $this -> getQuery ( 'bbcode' ) === 'img' ) ? 'bbcode=img' : FALSE ;
2012-08-04 04:15:41 +00:00
if ( $_GET [ 'from' ])
{
2020-12-31 16:14:43 -08:00
$bbcodeMode .= '&from=' . ( int ) $_GET [ 'from' ];
2012-08-04 04:15:41 +00:00
}
2020-12-31 16:14:43 -08:00
$bbcodeMode .= '&nav=1' ;
2012-08-04 04:15:41 +00:00
2020-12-31 16:14:43 -08:00
$tag = ( $bbcodeMode ) ? '' : $this -> getQuery ( 'tagid' );
2012-08-04 04:15:41 +00:00
echo e107 :: getMedia () -> mediaSelect ( $this -> getQuery ( 'for' ), $this -> getQuery ( 'tagid' ), $bbcodeMode ); // eg. news, news-thumbnail
return ;
}
2017-07-20 13:28:19 -07:00
public function ListAjaxObserver ()
{
$cat = $this -> getQuery ( 'for' );
$file = ( preg_match ( '/_file(_[\d]{1,2})?$/' , $cat )) ? true : false ;
if ( $file === true ) // Make sure dialog mode is used when ajax searches occur.
{
$this -> setQuery ( 'action' , 'dialog' );
$this -> setFileListMode ( $cat );
}
2019-06-03 16:29:38 -07:00
$this -> getTreeModel () -> setParam ( 'db_query' , $this -> _modifyListQry ( false , false , 0 , false , $this -> listQry )) -> loadBatch ();
2017-07-20 13:28:19 -07:00
}
2022-04-02 09:34:06 -07:00
function EditObserver ()
{
$mode = $this -> getMode ();
$this -> afterSubmitOptions = ( $mode === 'main' && ( $this -> getQuery ( 'after' ) === 'grid' )) ? [ 'grid' => LAN_UI_VIEW_GRID_LABEL ] : true ;
parent :: EditObserver ();
}
function CreateObserver ()
{
$mode = $this -> getMode ();
// Return to the same 'view' based
$this -> afterSubmitOptions = ( $mode === 'main' && ( $this -> getQuery ( 'after' ) === 'grid' )) ? [ 'grid' => LAN_UI_VIEW_GRID_LABEL ] : true ;
parent :: CreateObserver ();
}
function GridObserver ()
{
$this -> setGridObserver ();
parent :: GridObserver ();
}
function GridAjaxObserver ()
{
$this -> setGridObserver ();
parent :: GridAjaxObserver ();
}
private function setGridObserver ()
{
/* $this -> grid [ 'perPage' ] = e107 :: pref ( 'core' , 'thumbnail_per_page' , 24 ); // XXX TBD
switch ( $this -> grid [ 'perPage' ])
{
case 8 :
$cols = '1fr 1fr 1fr 1fr' ; // 4 columns.
break ;
case 12 :
$cols = '1fr 1fr 1fr 1fr 1fr 1fr' ; // 6 columns.
break ;
case 16 :
case 24 :
$cols = '1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr' ; // 8 columns.
break ;
case 36 :
case 48 :
$cols = '1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr' ; // 12 columns.
break ;
default :
// code to be executed if n is different from all labels;
}
e107 :: css ( 'inline' , '#core-core-media-list-grid { grid-template-columns: ' . $cols . ';' ); */
$this -> grid [ 'template' ] = ' < div class = " panel panel-default " >
< div class = " e-overlay " > { IMAGE }
< div class = " e-overlay-content " >
< p > { TITLE } </ p >
< p > { OPTIONS } </ p >
< p > { CHECKBOX } < label for = " multiselect- { ID}- { ID} " > '.LAN_SELECT.' </ label ></ p >
</ div >
</ div >
</ div > ' ;
2012-08-04 04:15:41 +00:00
2022-04-02 09:34:06 -07:00
}
2012-04-28 01:31:30 +00:00
function dialogPage () // Popup dialogPage for Image Selection.
{
2017-07-20 13:28:19 -07:00
2012-05-25 11:30:49 +00:00
$cat = $this -> getQuery ( 'for' );
2021-02-07 13:26:36 -08:00
$file = ( preg_match ( '/_file(_[\d]{1,2})?$/' , $cat )) ? true : false ;
2012-08-12 00:24:02 +00:00
$mes = e107 :: getMessage ();
2020-12-31 16:14:43 -08:00
$mes -> addDebug ( 'For:' . $cat );
$mes -> addDebug ( 'Bbcode: ' . $this -> getQuery ( 'bbcode' ));
2013-03-09 19:22:30 -08:00
2017-01-24 19:53:40 -08:00
$video = $this -> getQuery ( 'video' );
if ( $video == 2 )
{
echo $this -> mediaSelectUpload ( 'video' );
return ;
}
2014-01-09 04:42:13 -08:00
2013-11-06 16:36:48 -08:00
$this -> processUploadUrl ( true , $cat );
2021-02-07 13:26:36 -08:00
2012-05-25 11:30:49 +00:00
if ( $file )
{
2021-02-07 13:26:36 -08:00
// echo $this->fileTab($cat); // FIXME use this instead.
2017-07-20 13:28:19 -07:00
$this -> setFileListMode ( $cat );
2016-10-31 20:34:59 -07:00
echo $this -> mediaSelectUpload ( 'file' );
2021-02-07 13:26:36 -08:00
2016-10-31 20:34:59 -07:00
$tagid = e107 :: getParser () -> filter ( $this -> getQuery ( 'tagid' ));
echo '<div class="media-select-file-footer"><a class="btn btn-danger e-media-select-file-none e-dialog-close" data-target="' . $tagid . '" data-target-label="' . LAN_CHOOSE_FILE . '" href="#" ><span><i class="fa fa-ban"></i> ' . IMALAN_167 . '</span></a></div>' ;
2012-04-28 01:31:30 +00:00
}
2012-08-12 00:24:02 +00:00
else
{
2018-08-22 17:20:49 -07:00
return $this -> mediaManagerTabs ();
// echo $this->mediaSelectUpload();
2012-08-12 00:24:02 +00:00
}
2012-04-28 01:31:30 +00:00
}
2012-05-22 13:32:49 +00:00
2017-07-20 13:28:19 -07:00
private function setFileListMode ( $cat )
{
$cat = e107 :: getParser () -> toDB ( $cat );
if ( ! isset ( $this -> cats [ $cat ]))
{
return ;
}
2017-07-20 13:49:44 -07: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 FIND_IN_SET(' " . $cat . " ', m.media_category) " ; // without any Order or Limit.
2017-07-20 13:28:19 -07: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 ;
$this -> fields [ 'media_url' ][ 'nolist' ] = true ;
$this -> fields [ 'media_sef' ][ 'nolist' ] = true ;
foreach ( $this -> fields as $k => $v )
{
$this -> fields [ $k ][ 'filter' ] = false ;
}
}
2012-08-04 04:15:41 +00:00
2018-08-16 19:02:02 -07:00
private function uploadTab ()
2012-05-22 13:32:49 +00:00
{
2015-11-04 19:35:00 -08:00
if ( ! ADMIN ){ exit ; }
if ( ! getperms ( 'A' ) && ! getperms ( 'A1' ))
{
return '' ;
}
2013-11-06 16:07:58 -08:00
2016-01-11 20:53:05 -08:00
// if 'for' has no value, files are placed in /temp and not added to the db.
2016-11-17 12:34:09 -08:00
2016-12-03 20:47:26 -08:00
$maxFileSize = e107 :: pref ( 'core' , 'upload_maxfilesize' );
if ( empty ( $maxFileSize ))
{
2020-12-31 16:14:43 -08:00
$maxFileSize = '20M' ;
2016-12-03 20:47:26 -08:00
}
2016-11-17 12:34:09 -08:00
2020-12-31 16:14:43 -08:00
$text = '<h4>' . IMALAN_145 . '</h4>' ;
2016-12-06 19:24:48 -08:00
$text .= '<div id="uploader" data-max-size="' . str_replace ( 'M' , 'mb' , $maxFileSize ) . '" rel="' . e_JS . 'plupload/upload.php?for=' . $this -> getQuery ( 'for' ) . '&path=' . $this -> getQuery ( 'path' ) . ' " >
2016-10-01 11:26:30 +02:00
< p > '.IMALAN_146.' </ p >
2012-05-22 13:32:49 +00:00
</ div > ' ;
2016-01-11 20:53:05 -08:00
$text .= '<hr />' ;
2013-11-06 16:07:58 -08:00
$frm = e107 :: getForm ();
2016-01-11 20:53:05 -08:00
2013-11-06 16:07:58 -08:00
$text .= $frm -> open ( 'upload-url-form' , 'post' );
$text .= '<div class="plupload_header_content">' ;
2020-12-31 16:14:43 -08:00
$text .= '<h4>' . IMALAN_147 . '</h4>' ;
2016-01-11 20:53:05 -08:00
$text .= " <div class='plupload_header_text form-inline' style='padding-left:20px;padding-right:20px'> " ;
$text .= " <table class='table'> " ;
$text .= " <tr>
2016-10-01 11:26:30 +02:00
< td class = 'text-nowrap' > " .IMALAN_148. " :</ td >
2017-03-02 11:44:15 -08:00
< td >< input class = 'form-control' type = 'text' name = 'upload_url' size = '255' style = 'width:100%' placeholder = 'eg. http://website.com/some-image.jpg' /></ td >
2020-12-31 16:14:43 -08:00
< td style = 'text-align:left' > " . $frm->admin_button ('upload_remote_url',1,'create',IMALAN_149). '</td>
</ tr > ' ;
$text .= '<tr><td>' . LAN_CAPTION . ' (' . LAN_OPTIONAL . " ):</td><td><input type='text' class='form-control' name='upload_caption' size='255' style='width:100%' placeholder='eg. My Image Caption' /></td>
2016-01-11 20:53:05 -08:00
< td ></ td ></ tr > " ;
2020-12-31 16:14:43 -08:00
$text .= '</table>' ;
2016-01-11 20:53:05 -08:00
// $text .= ;
2020-12-31 16:14:43 -08:00
$text .= '</div>' ;
2014-01-09 04:42:13 -08:00
$text .= " </div> \n \n " ;
2013-11-06 16:07:58 -08:00
2014-01-09 04:42:13 -08:00
$text .= $frm -> close ();
2013-11-06 16:07:58 -08:00
2012-05-22 13:32:49 +00:00
return $text ;
}
2012-04-28 01:31:30 +00:00
2018-07-25 20:28:30 -07:00
/**
* Media - Manager Tabs ( new in v2 . 1.9 )
* Replacement for mediaSelectUpload ()
* @ return string
*/
2018-08-16 19:02:02 -07:00
private function mediaManagerTabs ()
2018-07-25 20:28:30 -07:00
{
$frm = e107 :: getForm ();
$tp = e107 :: getParser ();
$options = array ();
2020-12-31 16:14:43 -08:00
$options [ 'bbcode' ] = ( $this -> getQuery ( 'bbcode' )) ? : false ;
2018-07-25 20:28:30 -07:00
if ( isset ( $_GET [ 'from' ]))
{
2020-12-31 16:14:43 -08:00
$options [ 'from' ] .= ( int ) $_GET [ 'from' ];
2018-07-25 20:28:30 -07:00
}
$cat = $this -> getQuery ( 'for' );
2018-08-22 18:09:46 -07:00
$cat = urldecode ( $cat );
2018-07-25 20:28:30 -07:00
$tabOptions = array (
2018-08-16 19:02:02 -07:00
'core-media-icon' => array ( 'caption' => $tp -> toGlyph ( 'fa-file-photo-o' ) . IMALAN_72 , 'method' => 'iconTab' ),
2018-07-28 09:40:45 -07:00
'core-media-image' => array ( 'caption' => $tp -> toGlyph ( 'fa-file-photo-o' ) . ADLAN_105 , 'method' => 'imageTab2' ),
'core-media-video' => array ( 'caption' => $tp -> toGlyph ( 'fa-file-video-o' ) . IMALAN_163 , 'method' => 'videoTab' ),
2018-08-16 19:02:02 -07:00
'core-media-file' => array ( 'caption' => $tp -> toGlyph ( 'fa-file' ) . ADLAN_CL_5 , 'method' => 'fileTab' ),
2020-12-31 16:14:43 -08:00
'core-media-audio' => array ( 'caption' => $tp -> toGlyph ( 'fa-file-audio-o' ) . 'Audio' , 'method' => 'audioTab' ),
'core-media-youtube' => array ( 'caption' => $tp -> toGlyph ( 'fa-youtube-play' ) . 'Youtube' , 'method' => 'youtubeTab' ),
'core-media-glyph' => array ( 'caption' => $tp -> toGlyph ( 'fa-flag' ) . 'Glyphs' , 'method' => 'glyphTab' ),
2018-07-25 20:28:30 -07:00
);
2018-08-10 15:30:44 -07:00
if ( ! empty ( $options [ 'bbcode' ]))
{
$tabOptions [ 'core-media-img' ] = $tabOptions [ 'core-media-image' ];
}
2018-07-25 20:28:30 -07:00
$tabs = array ();
// check tab options against URL
foreach ( $tabOptions as $key => $val )
{
$id = str_replace ( 'core-media-' , '' , $key );
if ( $this -> getQuery ( $id ) == 1 || $this -> getQuery ( 'bbcode' ) == $id )
{
2018-07-28 09:40:45 -07:00
$tabMethod = $val [ 'method' ];
$text = $this -> $tabMethod ( $cat , $options );
$tabs [ $key ] = array ( 'caption' => $val [ 'caption' ], 'text' => $text );
2018-07-25 20:28:30 -07:00
}
}
2012-04-28 01:31:30 +00:00
2018-08-10 15:30:44 -07:00
if ( $options [ 'bbcode' ] === 'img' )
{
$tabs [ 'core-media-attributes' ] = array ( 'caption' => $tp -> toGlyph ( 'fa-image' ) . IMALAN_152 , 'text' => $this -> imageAttributesTab ());
}
2018-07-25 20:28:30 -07:00
if ( getperms ( 'A|A1' ))
{
$tabs [ 'core-media-upload' ] = array ( 'caption' => $tp -> toGlyph ( 'fa-upload' ) . IMALAN_150 , 'text' => $this -> uploadTab ());
}
2018-08-10 15:30:44 -07:00
2018-07-27 17:39:44 -07:00
$text = $frm -> tabs ( $tabs , array ( 'id' => 'admin-ui-media-manager' , 'class' => 'media-manager' ));
2018-08-22 17:20:49 -07:00
/* if ( $options [ 'bbcode' ] || E107_DEBUG_LEVEL > 0 )
2018-08-10 15:30:44 -07:00
{
2018-08-22 17:20:49 -07:00
} */
2018-08-23 08:45:07 -07:00
$text .= $this -> mediaManagerSaveButtons ( $options );
2018-08-10 15:30:44 -07:00
$text .= $this -> mediaManagerPlaceholders ();
2018-07-27 17:39:44 -07:00
return $text ;
2018-07-25 20:28:30 -07:00
}
/**
* @ deprecated by mediaManagerTabs
* @ param string $type
* @ return string
*/
2012-08-12 00:24:02 +00:00
function mediaSelectUpload ( $type = 'image' )
2012-04-28 01:31:30 +00:00
{
2018-08-22 17:20:49 -07:00
// return $this->mediaManagerTabs();
2012-04-30 10:39:03 +00:00
$frm = e107 :: getForm ();
2018-07-25 20:28:30 -07:00
$tp = e107 :: getParser ();
2017-01-24 19:53:40 -08:00
if ( $type === 'video' )
{
$tabs = array (
2018-07-16 17:14:10 -07:00
'youtube' => array ( 'caption' => 'Youtube' , 'text' => $this -> youtubeTab ())
2017-01-24 19:53:40 -08:00
);
return $frm -> tabs ( $tabs , array ( 'class' => 'media-manager' ));
}
2018-07-16 17:14:10 -07:00
$youtubeActive = 'inactive' ;
2013-03-09 19:22:30 -08:00
$options = array ();
2018-08-16 19:02:02 -07:00
switch ( $this -> getQuery ( 'bbcode' ))
{
2020-12-31 16:14:43 -08:00
case 'img' :
2018-08-16 19:02:02 -07:00
$options [ 'bbcode' ] = 'img' ;
break ;
2020-12-31 16:14:43 -08:00
case 'video' :
2018-08-16 19:02:02 -07:00
$options [ 'bbcode' ] = 'video' ;
break ;
2020-12-31 16:14:43 -08:00
case 'glyph' :
2018-08-16 19:02:02 -07:00
$options [ 'bbcode' ] = 'glyph' ;
break ;
default :
$options [ 'bbcode' ] = false ;
}
2012-07-23 02:25:17 +00:00
2015-07-19 17:10:03 -07:00
$text = " <ul id='admin-ui-media-manager' class='nav nav-tabs'> \n " ;
2020-12-31 16:14:43 -08:00
$bbcodeQuery = $this -> getQuery ( 'bbcode' );
2021-02-07 13:26:36 -08:00
// files.
$text .= " <li class='active'><a data-toggle='tab' data-bs-toggle='tab' href='#core-media-select'> " . $tp -> toGlyph ( 'fa-file' ) . ADLAN_CL_5 . " </a></li> \n " ;
2018-07-25 20:28:30 -07:00
2014-01-17 06:49:55 -08:00
2020-12-31 16:14:43 -08:00
if ( varset ( $options [ 'bbcode' ]) === 'img' )
2012-04-30 10:39:03 +00:00
{
2021-01-26 15:08:58 -08:00
$text .= " <li><a data-toggle='tab' data-bs-toggle='tab' href='#core-media-style'> " . IMALAN_152 . " </a></li> \n " ;
2013-07-12 03:21:27 -07:00
}
2018-07-25 20:28:30 -07:00
2020-12-31 16:14:43 -08:00
if ( $this -> getQuery ( 'video' ) == 1 || $this -> getQuery ( 'bbcode' ) === 'video' )
2014-01-08 15:51:14 -08:00
{
2021-01-26 15:08:58 -08:00
$text .= " <li class=' { $youtubeActive } '><a data-toggle='tab' data-bs-toggle='tab' href='#core-media-youtube'> " . " Youtube</a></li> \n " ;
2014-01-08 15:51:14 -08:00
}
2018-07-19 12:43:04 -07:00
2018-07-25 20:28:30 -07:00
2020-12-31 16:14:43 -08:00
if ( $this -> getQuery ( 'glyph' ) == 1 || $this -> getQuery ( 'bbcode' ) === 'glyph' )
2018-07-19 12:43:04 -07:00
{
2021-01-26 15:08:58 -08:00
$text .= " <li class=' { $glyphActive } '><a data-toggle='tab' data-bs-toggle='tab' href='#core-media-glyphs'> " . " Glyphs</a></li> \n " ;
2018-07-25 20:28:30 -07:00
}
2018-07-19 12:43:04 -07:00
2020-12-31 16:14:43 -08:00
if ( getperms ( 'A|A1' ) && ( $this -> getQuery ( 'bbcode' ) !== 'video' && $this -> getQuery ( 'bbcode' ) !== 'glyph' ))
2018-07-25 20:28:30 -07:00
{
2021-01-26 15:08:58 -08:00
$text .= " <li><a data-toggle='tab' data-bs-toggle='tab' href='#core-media-upload'> " . IMALAN_150 . '</a></li>' ;
2018-07-19 12:43:04 -07:00
}
2013-07-12 03:21:27 -07:00
2013-03-21 18:23:40 -07:00
if ( varset ( $_GET [ 'from' ]))
2012-05-24 07:24:49 +00:00
{
2020-12-31 16:14:43 -08:00
$options [ 'from' ] .= ( int ) $_GET [ 'from' ];
2012-05-24 07:24:49 +00:00
}
2013-03-09 19:22:30 -08:00
2012-04-30 10:39:03 +00:00
$text .= "
2012-04-28 01:31:30 +00:00
</ ul >
2014-05-31 23:15:26 -07:00
< div class = 'tab-content media-manager' > " ;
2012-04-28 01:31:30 +00:00
2020-12-31 16:14:43 -08:00
if ( $bbcodeQuery !== 'video' && $bbcodeQuery !== 'glyph' )
2014-01-23 15:56:53 -08:00
{
$text .= " <div class='tab-pane active' id='core-media-select'>
2016-03-11 12:31:09 -08:00
< div style = 'display:block;width:100%' > " ;
2014-01-23 15:56:53 -08:00
$text .= $this -> imageTab ( $type , $options );
2020-12-31 16:14:43 -08:00
$text .= '</div></div>' ;
2014-01-23 15:56:53 -08:00
}
2012-04-28 01:31:30 +00:00
2014-01-23 15:56:53 -08:00
$text .= " <div class='tab-pane' id='core-media-upload'>
2014-01-09 04:42:13 -08:00
" ;
2012-04-28 01:31:30 +00:00
$this -> fields [ 'media_category' ][ 'readonly' ] = TRUE ;
$this -> fields [ 'media_url' ][ 'noedit' ] = TRUE ;
$this -> fields [ 'media_userclass' ][ 'noedit' ] = TRUE ;
2015-11-04 19:35:00 -08:00
if ( getperms ( 'A|A1' ))
{
$text .= $this -> uploadTab (); // To test upload script with plupload
}
2012-05-25 11:30:49 +00:00
// $text .= $this->CreatePage(); // comment me out to test plupload
2012-04-28 01:31:30 +00:00
2020-12-31 16:14:43 -08:00
$text .= '
</ 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 .
*
*/
2018-08-10 15:30:44 -07:00
if ( $options [ 'bbcode' ])
2012-04-30 10:39:03 +00:00
{
2020-12-31 16:14:43 -08:00
$text .= " <div class='tab-pane' id='core-media-style'> " . $this -> imageAttributesTab () . '</div>' ;
2018-08-10 15:30:44 -07:00
}
2020-12-31 16:14:43 -08:00
if ( $this -> getQuery ( 'video' ) || $this -> getQuery ( 'bbcode' ) === 'video' )
2018-08-10 15:30:44 -07:00
{
$text .= " <div class='tab-pane clearfix { $youtubeActive } ' id='core-media-youtube' > " ;
$text .= $this -> youtubeTab ();
2020-12-31 16:14:43 -08:00
$text .= '</div>' ;
2018-08-10 15:30:44 -07:00
}
2018-08-11 10:44:05 -07:00
/*
2018-08-10 15:30:44 -07:00
if ( $this -> getQuery ( 'audio' ) || $this -> getQuery ( 'bbcode' ) == 'audio' )
{
$text .= " <div class='tab-pane clearfix { $videoActive } ' id='core-media-audio' > " ;
$text .= $this -> audioTab ();
$text .= " </div> " ;
2018-08-11 10:44:05 -07:00
} */
2018-08-10 15:30:44 -07:00
2020-12-31 16:14:43 -08:00
if ( $this -> getQuery ( 'glyph' ) == 1 || $this -> getQuery ( 'bbcode' ) === 'glyph' )
2018-08-10 15:30:44 -07:00
{
$text .= " <div class='tab-pane clearfix { $glyphActive } ' id='core-media-glyphs'> " ;
$text .= $this -> glyphTab ();
2020-12-31 16:14:43 -08:00
$text .= ' </ div >
' ;
2018-08-10 15:30:44 -07:00
}
2020-12-31 16:14:43 -08:00
$text .= '</div>' ;
2018-08-10 15:30:44 -07:00
// For BBCODE/TinyMce mode.
// e-dialog-save
2014-01-09 04:42:13 -08:00
2018-08-10 15:30:44 -07:00
if ( $options [ 'bbcode' ] || E107_DEBUG_LEVEL > 0 )
{
$text .= $this -> mediaManagerSaveButtons ( $options );
}
$text .= $this -> mediaManagerPlaceholders ();
return $text ;
}
private function imageAttributesTab ()
{
$frm = e107 :: getForm ();
$text = " <div class='row'>
2015-07-14 12:13:46 -07:00
< div class = 'col-md-6 span6' >
2013-03-21 18:23:40 -07:00
< table class = 'table' >
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 >
2016-01-11 20:53:05 -08:00
< tr >
2016-10-01 11:26:30 +02:00
< td > " .LAN_CAPTION. " : </ td >
2016-01-11 20:53:05 -08:00
< td >
< input type = 'text' class = 'e-media-attribute' id = 'alt' name = 'alt' size = '4' style = 'width:100%' value = '' />
</ td >
</ tr >
2012-04-30 10:39:03 +00:00
< tr >
2016-10-01 11:26:30 +02:00
< td > " .IMALAN_120. " : </ td >
2012-04-30 10:39:03 +00:00
< td >
2016-01-11 20:53:05 -08:00
< input type = 'text' class = 'e-media-attribute' id = 'width' name = 'width' size = '4' style = 'width:50px' value = '' /> px & nbsp ;
& #10060; <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 >
2020-12-31 16:14:43 -08:00
< td > " .IMALAN_157. ': </td>
< td > ' .$frm->selectbox(' float ', array(' default ' =>LAN_DEFAULT, ' left ' =>IMALAN_139, ' right ' =>IMALAN_138)). ' </ td >
2012-04-30 10:39:03 +00:00
</ tr >
< tr >
2020-12-31 16:14:43 -08:00
< td > ' . IMALAN_158 . " : </td>
2013-03-21 18:23:40 -07:00
< td >< input class = 'e-media-attribute input-mini' type = 'text' id = 'margin-left' name = 'margin_left' value = '' /> px </ td >
2012-04-30 10:39:03 +00:00
</ tr >
< tr >
2016-10-01 11:26:30 +02:00
< td > " .IMALAN_159. " : </ td >
2013-03-21 18:23:40 -07:00
< td >< input class = 'e-media-attribute input-mini' type = 'text' id = 'margin-right' name = 'margin_right' value = '' /> px </ td >
2012-04-30 10:39:03 +00:00
</ tr >
< tr >
2016-10-01 11:26:30 +02:00
< td > " .IMALAN_160. " : </ td >
2013-03-21 18:23:40 -07:00
< td >< input class = 'e-media-attribute input-mini' type = 'text' id = 'margin-top' name = 'margin_top' value = '' /> px </ td >
2012-04-30 10:39:03 +00:00
</ tr >
< tr >
2016-10-01 11:26:30 +02:00
< td > " .IMALAN_161. " : </ td >
2013-03-21 18:23:40 -07:00
< td >< input class = 'e-media-attribute input-mini' type = 'text' id = 'margin-bottom' name = 'margin_bottom' value = '' /> px </ td >
2012-04-30 10:39:03 +00:00
</ tr >
</ tbody ></ table >
2013-03-21 18:23:40 -07:00
</ div >
2015-07-14 12:13:46 -07:00
< div class = 'col-md-6 span6' >
2016-01-11 20:53:05 -08:00
< h5 > " .LAN_PREVIEW. " </ h5 >
2013-03-21 18:23:40 -07:00
< img class = 'well' id = 'preview' src = '".e_IMAGE_ABS."generic/blank.gif' style = 'min-width:220px; min-height:180px;' />
2012-04-30 20:35:59 +00:00
2013-03-21 18:23:40 -07:00
</ div >
2013-02-25 02:55:41 -08:00
</ div > " ;
2018-07-25 20:28:30 -07:00
2018-08-10 15:30:44 -07:00
return $text ;
2018-07-16 17:14:10 -07:00
2018-08-10 15:30:44 -07:00
}
2018-07-19 12:43:04 -07:00
2018-07-25 20:28:30 -07:00
2018-08-10 15:30:44 -07:00
private function mediaManagerPlaceholders ()
{
2021-04-06 18:41:15 -07:00
$type = ( E107_DEBUG_LEVEL > 0 ) ? 'text' : 'hidden' ;
$valueHolders = [
'bbcode_holder' => 'bbcode' ,
'html_holder' => 'html/wysiwyg' ,
'src' => '(preview) src' ,
'path' => 'path (save to db)'
];
$text = '' ;
foreach ( $valueHolders as $name => $label )
{
$text .= ( E107_DEBUG_LEVEL > 0 ) ? " <br /><span style='margin-left:20px;display:inline-block;width:150px'> " . $label . " </span> " : '' ;
$text .= " <input title=' " . $label . " ' type=' { $type } ' readonly style='width:800px' class='' id=' " . $name . " ' name=' " . $name . " ' value='' /> \n " ;
}
if ( E107_DEBUG_LEVEL > 0 )
{
$text .= " <br /><span style='margin-left:20px;display:inline-block;width:150px'>FontAwesome</span> " . e107 :: getTheme () -> getFontAwesome ();
}
2018-07-25 20:28:30 -07:00
2018-08-10 15:30:44 -07:00
return $text ;
}
private function mediaManagerSaveButtons ( $options = array ())
{
2018-08-22 17:20:49 -07:00
if ( empty ( $options [ 'bbcode' ])) // media picker mode.
2018-08-16 19:02:02 -07:00
{
2018-08-22 17:20:49 -07:00
$text = " <div class='buttons-bar' style='display:none;text-align:right;padding-right:15px;'>
< button id = 'etrigger-submit' style = 'display:none' type = 'submit' data - modal - submit - class = 'btn-danger' class = ' submit e-media-select-file-none e-dialog-close' data - target - label = '' data - bbcode = '".$options[' bbcode ']."' data - target = '".$this->getQuery(' tagid ')."' name = 'reset_value' value = 'reset' >
2020-12-31 16:14:43 -08:00
< span > " .LAN_CLEAR. '</span>
2018-08-22 17:20:49 -07:00
</ button >
2020-12-31 16:14:43 -08:00
</ div > ' ;
2018-08-22 17:20:49 -07:00
return $text ;
2018-08-16 19:02:02 -07:00
}
2018-08-22 17:20:49 -07:00
// bbcode/wysiwyg mode.
2018-08-16 19:02:02 -07:00
// hidden from view but used by javascript to re-create the button in the modal-footer.
// Tinymce will remove the 'display:none' when loaded.
$text = " <div id='media-manager-submit-buttons' class='buttons-bar' style='text-align:right;padding-right:15px;display:none;'>
2012-04-30 10:39:03 +00:00
2018-08-16 19:02:02 -07:00
< button id = 'etrigger-submit' type = 'submit' class = 'btn btn-success submit e-dialog-save e-dialog-close' data - bbcode = '".$options[' bbcode ']."' data - target = '".$this->getQuery(' tagid ')."' name = 'save_image' value = 'Save it' >
2016-11-02 09:29:18 +01:00
< span > " .LAN_SAVE. " </ span >
2012-04-30 10:39:03 +00:00
</ button >
2018-08-26 12:25:08 -07:00
< button type = 'submit' class = ' btn btn-default btn-secondary submit e-dialog-close e-dialog-cancel' name = 'cancel_image' value = 'Cancel' data - close = 'true' >
2020-12-31 16:14:43 -08:00
< span > " .LAN_CANCEL. '</span>
2012-04-30 10:39:03 +00:00
</ button >
2020-12-31 16:14:43 -08:00
</ div > ' ;
2014-01-23 17:23:38 -08:00
2015-04-02 02:49:19 -07:00
2012-04-28 01:31:30 +00:00
return $text ;
}
2014-01-23 15:56:53 -08:00
2018-08-10 15:30:44 -07:00
2018-07-27 12:07:43 -07:00
/**
* @ deprecated to be replaced by imageTab2
* @ param $type
* @ param $options
* @ return string
*/
2014-01-23 15:56:53 -08:00
function imageTab ( $type , $options )
{
2020-12-31 16:14:43 -08:00
$tag = ( $options [ 'bbcode' ]) ? '' : $this -> getQuery ( 'tagid' );
2014-01-23 15:56:53 -08:00
if ( varset ( $_GET [ 'w' ]))
{
2020-12-31 16:14:43 -08:00
$options [ 'w' ] = ( int ) $_GET [ 'w' ];
2014-01-23 15:56:53 -08:00
}
2020-12-31 16:14:43 -08:00
if ( $type === 'file' )
2014-01-23 15:56:53 -08:00
{
$this -> perPage = 0 ;
2019-06-03 16:29:38 -07:00
$this -> getTreeModel () -> setParam ( 'db_query' , $this -> _modifyListQry ( false , false , false , false , $this -> listQry )) -> loadBatch ();
2014-01-23 15:56:53 -08:00
$text = $this -> getUI () -> getList ();
}
else
{
2018-07-26 19:13:27 -07:00
$text = e107 :: getMedia () -> mediaSelect ( $this -> getQuery ( 'for' ), $this -> getQuery ( 'tagid' ), $options ); // eg. news, news-thumbnail
2014-01-23 15:56:53 -08:00
}
return $text ;
}
2018-07-22 14:45:26 -07:00
2018-07-27 17:39:44 -07:00
2018-08-16 19:02:02 -07:00
private function iconTab ( $cat , $option = array ())
2018-07-27 17:39:44 -07:00
{
2018-08-16 19:02:02 -07:00
$tp = e107 :: getParser ();
2018-07-27 17:39:44 -07:00
$parms = array (
'width' => 64 ,
'height' => 64 ,
'type' => 'icon' , // how should it be rendered?
2018-08-13 13:17:54 -07:00
// 'category' => $category,
2018-07-27 17:39:44 -07:00
'tagid' => $this -> getQuery ( 'tagid' ),
2018-08-11 14:06:21 -07:00
'action' => 'icon' , // Used by AJAX to identify correct function.
2018-07-27 17:39:44 -07:00
'perPage' => 80 ,
'gridClass' => 'media-carousel-item-glyph pull-left' ,
2018-08-13 17:42:06 -07:00
'bbcode' => 'icon' ,
2018-07-27 17:39:44 -07:00
'close' => 'true'
);
$items = array ();
$frm = ! empty ( $option [ 'from' ]) ? $option [ 'from' ] : 0 ;
$limit = ! empty ( $option [ 'limit' ]) ? $option [ 'limit' ] : 200 ;
// $cat = ($category) ? $category."+" : ""; // the '+' loads category '_common' as well as the chosen category.
$images = e107 :: getMedia () -> getIcons ( '' , $frm , $limit );
foreach ( $images as $val )
{
$items [] = array (
'previewHtml' => $tp -> toIcon ( $val [ 'media_url' ]),
'previewUrl' => '' ,
'saveValue' => $val [ 'media_url' ],
'thumbUrl' => $val [ 'media_url' ],
'title' => $val [ 'media_name' ],
2020-12-31 16:14:43 -08:00
'tooltip' => basename ( $val [ 'media_url' ]) . ' (' . $val [ 'media_dimensions' ] . ')' ,
2018-07-27 17:39:44 -07:00
'slideCaption' => '' ,
'slideCategory' => 'bootstrap' ,
'mime' => $val [ 'media_type' ]
);
}
if ( ! empty ( $option [ 'search' ]))
{
$filtered = array ();
if ( ! empty ( $items ))
{
foreach ( $items as $v )
{
if ( strpos ( $v [ 'title' ], $option [ 'search' ]) !== false )
{
$filtered [] = $v ;
}
}
}
$items = $filtered ;
}
return e107 :: getMedia () -> browserCarousel ( $items , $parms );
}
2018-07-22 14:45:26 -07:00
private function imageTab2 ( $category , $option = array ())
{
$tp = e107 :: getParser ();
$parms = array (
2018-08-11 12:04:46 -07:00
'width' => 340 , // when inserting into wysiwyg
2018-07-22 14:45:26 -07:00
'height' => 220 ,
'type' => 'image' ,
'category' => $category ,
'tagid' => $this -> getQuery ( 'tagid' ),
'action' => 'image2' , // Used by AJAX to identify correct function.
'perPage' => 8 ,
2018-08-13 13:17:54 -07:00
'gridClass' => 'col-xs-6 col-sm-3 media-carousel-item-image' ,
2018-08-10 15:30:44 -07:00
'bbcode' => 'img' , // bbcode tag.
2018-07-22 14:45:26 -07:00
);
2018-08-11 10:44:05 -07:00
$close = true ;
if ( ! empty ( $option [ 'bbcode' ]))
{
$close = false ;
2018-08-11 12:04:46 -07:00
e107 :: getBB () -> setClass ( $category );
$parms [ 'width' ] = ( int ) e107 :: getBB () -> resizeWidth (); // resize the image according to prefs.
$parms [ 'height' ] = ( int ) e107 :: getBB () -> resizeHeight ();
2020-05-25 12:34:18 -07:00
e107 :: getBB () -> clearClass ();
2018-08-11 10:44:05 -07:00
}
2018-07-22 14:45:26 -07:00
$items = array ();
$frm = ! empty ( $option [ 'from' ]) ? $option [ 'from' ] : 0 ;
$limit = ! empty ( $option [ 'limit' ]) ? $option [ 'limit' ] : 200 ;
// $newfrm = $frm + $limit;
// $bbcode = varset($option['bbcode']) ? $option['bbcode'] : null;
// $navMode = varset($option['nav']) ? TRUE : FALSE;
$search = ! empty ( $option [ 'search' ]) ? $option [ 'search' ] : null ;
2018-08-06 14:11:28 -07:00
// $cat = ($category) ? $category."+" : "";
$images = e107 :: getMedia () -> getImages ( $category , $frm , $limit , $search );
2018-07-22 14:45:26 -07:00
foreach ( $images as $val )
{
$items [] = array (
2018-07-26 19:13:27 -07:00
'previewHtml' => $tp -> toImage ( $val [ 'media_url' ], array ( 'w' => 210 , 'h' => 140 )),
2018-08-11 10:44:05 -07:00
'previewUrl' => $tp -> thumbUrl ( $val [ 'media_url' ], array ( 'w' => 210 , 'h' => 140 )),
2018-07-22 14:45:26 -07:00
'saveValue' => $val [ 'media_url' ],
'thumbUrl' => $tp -> thumbUrl ( $val [ 'media_url' ], array ( 'w' => 340 , 'h' => 220 )),
'title' => $val [ 'media_name' ],
2020-12-31 16:14:43 -08:00
'tooltip' => basename ( $val [ 'media_url' ]) . ' (' . $val [ 'media_dimensions' ] . ')' ,
2018-07-22 14:45:26 -07:00
'slideCaption' => '' ,
'slideCategory' => 'bootstrap' ,
2018-08-11 10:44:05 -07:00
'mime' => $val [ 'media_type' ],
'close' => $close
2018-07-22 14:45:26 -07:00
);
}
if ( ! empty ( $option [ 'search' ]))
{
$filtered = array ();
if ( ! empty ( $items ))
{
foreach ( $items as $v )
{
if ( strpos ( $v [ 'title' ], $option [ 'search' ]) !== false )
{
$filtered [] = $v ;
}
}
}
$items = $filtered ;
}
return e107 :: getMedia () -> browserCarousel ( $items , $parms );
}
2018-08-16 19:02:02 -07:00
private function fileTab ( $cat = '' , $parm = array ())
{
$this -> perPage = 0 ;
2019-06-03 16:29:38 -07:00
$this -> getTreeModel () -> setParam ( 'db_query' , $this -> _modifyListQry ( false , false , false , false , $this -> listQry )) -> loadBatch ();
2018-08-16 19:02:02 -07:00
$this -> setFileListMode ( $cat );
$text = $this -> getUI () -> getList ();
$tagid = e107 :: getParser () -> filter ( $this -> getQuery ( 'tagid' ));
// $text .= '<div class="media-select-file-footer"><a class="btn btn-danger e-media-select-file-none e-dialog-close" data-target="'.$tagid.'" data-target-label="'.LAN_CHOOSE_FILE.'" href="#" ><span><i class="fa fa-ban"></i> '.IMALAN_167.'</span></a></div>';
return $text ;
}
2014-01-23 15:56:53 -08:00
2018-07-26 19:13:27 -07:00
private function audioTab ( $cat = '' , $parm = array ())
2018-07-16 17:14:10 -07:00
{
2018-07-19 12:43:04 -07:00
$tp = e107 :: getParser ();
$parms = array (
'width' => 340 ,
'height' => 220 ,
'type' => 'audio' ,
'tagid' => $this -> getQuery ( 'tagid' ),
'action' => 'audio' , // Used by AJAX to identify correct function.
2018-07-21 13:20:17 -07:00
'perPage' => 8 ,
'gridClass' => 'col-sm-3 media-carousel-item-audio' ,
2018-07-19 12:43:04 -07:00
'bbcode' => 'audio' ,
'close' => 'true'
);
$items = array ();
2018-07-26 19:13:27 -07:00
$audios = e107 :: getMedia () -> getAudios ( $cat );
2018-07-19 12:43:04 -07:00
foreach ( $audios as $val )
{
$items [] = array (
'previewHtml' => $tp -> toAudio ( $val [ 'media_url' ], array ( 'mime' => $val [ 'media_type' ], 'w' => 210 , 'h' => 140 )),
'saveValue' => $val [ 'media_url' ],
'thumbUrl' => $val [ 'media_url' ],
'title' => $val [ 'media_name' ],
'slideCaption' => '' ,
'slideCategory' => 'bootstrap' ,
'mime' => $val [ 'media_type' ]
);
}
if ( ! empty ( $parm [ 'search' ]))
{
$filtered = array ();
if ( ! empty ( $items ))
{
foreach ( $items as $v )
{
if ( strpos ( $v [ 'title' ], $parm [ 'search' ]) !== false )
{
$filtered [] = $v ;
}
}
}
$items = $filtered ;
}
return e107 :: getMedia () -> browserCarousel ( $items , $parms );
2018-07-16 17:14:10 -07:00
}
2018-07-26 19:13:27 -07:00
private function videoTab ( $cat = '' , $parm = array ())
2018-07-16 17:14:10 -07:00
{
$tp = e107 :: getParser ();
$parms = array (
'width' => 340 ,
'height' => 220 ,
'type' => 'video' ,
'tagid' => $this -> getQuery ( 'tagid' ),
'action' => 'video' , // Used by AJAX to identify correct function.
2018-07-21 13:20:17 -07:00
'perPage' => 8 ,
2018-08-13 13:17:54 -07:00
'gridClass' => 'col-xs-6 col-sm-3 admin-ui-grid media-carousel-item-video' ,
2018-07-16 17:14:10 -07:00
'bbcode' => 'video' ,
);
2018-08-23 08:45:07 -07:00
$bbcode = $this -> getQuery ( 'bbcode' );
$close = ( ! empty ( $bbcode )) ? false : true ; // only close on 'select' when bbcodes are not in use.
2018-08-16 19:02:02 -07:00
2018-07-16 17:14:10 -07:00
$items = array ();
2018-07-26 19:13:27 -07:00
$videos = e107 :: getMedia () -> getVideos ( $cat );
2018-07-16 17:14:10 -07:00
2018-07-25 20:28:30 -07:00
2018-07-16 17:14:10 -07:00
foreach ( $videos as $val )
{
2018-07-25 20:28:30 -07:00
$size = e107 :: getFile () -> file_size_encode ( $val [ 'media_size' ]);
2018-07-16 17:14:10 -07:00
$items [] = array (
2018-07-22 14:45:26 -07:00
'previewHtml' => $tp -> toVideo ( $val [ 'media_url' ], array ( 'w' => 210 , 'h' => 140 )), // e_IMAGE_ABS."generic/playlist_120.png",
2018-07-16 17:14:10 -07:00
'saveValue' => $val [ 'media_url' ],
2018-07-19 12:43:04 -07:00
'thumbUrl' => $val [ 'media_url' ],
2018-07-16 17:14:10 -07:00
'title' => $val [ 'media_name' ],
2020-12-31 16:14:43 -08:00
'tooltip' => basename ( $val [ 'media_url' ]) . ' (' . $size . ')' ,
2018-07-16 17:14:10 -07:00
'slideCaption' => '' ,
'slideCategory' => 'bootstrap' ,
2018-08-16 19:02:02 -07:00
'mime' => $val [ 'media_type' ],
'close' => $close
2018-07-16 17:14:10 -07:00
);
}
if ( ! empty ( $parm [ 'search' ]))
{
$filtered = array ();
if ( ! empty ( $items ))
{
foreach ( $items as $v )
{
if ( strpos ( $v [ 'title' ], $parm [ 'search' ]) !== false )
{
$filtered [] = $v ;
}
}
}
$items = $filtered ;
}
return e107 :: getMedia () -> browserCarousel ( $items , $parms );
}
2014-01-23 15:56:53 -08:00
2014-01-09 04:42:13 -08:00
2018-08-16 19:02:02 -07:00
private function glyphTab ( $cat = '' , $parm = array ())
2014-01-09 04:42:13 -08:00
{
$parms = array (
'width' => 32 ,
'height' => 32 ,
'type' => 'glyph' ,
'tagid' => $this -> getQuery ( 'tagid' ),
'action' => 'glyph' , // Used by AJAX to identify correct function.
2021-02-11 16:39:50 -08:00
'perPage' => 70 ,
2018-07-27 17:39:44 -07:00
'gridClass' => 'media-carousel-item-glyph pull-left icon-preview' ,
2014-01-23 17:23:38 -08:00
'bbcode' => 'glyph' ,
'close' => 'true'
2014-01-09 04:42:13 -08:00
);
2016-12-22 08:47:54 -08:00
2018-07-27 17:39:44 -07:00
2021-01-30 19:21:23 -08:00
// --------------------------
$items = array ();
2018-07-27 17:39:44 -07:00
$md = e107 :: getMedia ();
2021-01-30 19:21:23 -08:00
if ( $this -> fontawesome === 5 )
2014-01-09 04:42:13 -08:00
{
2021-01-30 19:21:23 -08:00
// e107::getParser()->setFontAwesome(5);
$fab = e107 :: getMedia () -> getGlyphs ( 'fab' );
2015-11-13 14:44:38 -08:00
2021-01-30 19:21:23 -08:00
foreach ( $fab as $val )
{
$items [] = array (
'previewHtml' => $md -> previewTag ( 'fab-' . $val , array ( 'type' => 'glyph' )),
'previewUrl' => 'fab fa-' . $val ,
'saveValue' => 'fab-' . $val . '.glyph' ,
'thumbUrl' => 'fab-' . $val ,
'title' => 'FA5 fa-' . $val ,
'slideCaption' => 'Font-Awesome 5 (brand)' ,
'slideCategory' => 'font-awesome'
);
2014-01-09 04:42:13 -08:00
2021-01-30 19:21:23 -08:00
}
$fas = e107 :: getMedia () -> getGlyphs ( 'fas' );
foreach ( $fas as $val )
{
$items [] = array (
'previewHtml' => $md -> previewTag ( 'fas-' . $val , array ( 'type' => 'glyph' )),
'previewUrl' => 'fas fa-' . $val ,
'saveValue' => 'fas-' . $val . '.glyph' ,
'thumbUrl' => 'fas-' . $val ,
'title' => 'FA5 fa-' . $val ,
2021-01-31 13:09:53 -08:00
'slideCaption' => 'Font-Awesome 5 (solid)' ,
2021-01-30 19:21:23 -08:00
'slideCategory' => 'font-awesome'
);
2016-12-22 08:47:54 -08:00
2021-01-30 19:21:23 -08:00
}
2021-01-31 13:09:53 -08:00
$far = e107 :: getMedia () -> getGlyphs ( 'far' );
2014-01-09 04:42:13 -08:00
2021-01-31 13:09:53 -08:00
foreach ( $far as $val )
2021-01-30 19:21:23 -08:00
{
$items [] = array (
2021-01-31 13:09:53 -08:00
'previewHtml' => $md -> previewTag ( 'far-' . $val , array ( 'type' => 'glyph' )),
'previewUrl' => 'far fa-' . $val ,
'saveValue' => 'far-' . $val . '.glyph' ,
'thumbUrl' => 'far-' . $val ,
'title' => 'FA5 far-' . $val ,
'slideCaption' => 'Font-Awesome 5 (regular)' ,
2021-01-30 19:21:23 -08:00
'slideCategory' => 'font-awesome'
);
}
2021-01-31 13:09:53 -08:00
}
2021-04-06 18:41:15 -07:00
if ( $this -> fontawesome === 4 )
2021-01-31 13:09:53 -08:00
{
2021-04-06 18:41:15 -07:00
e107 :: getParser () -> setFontAwesome ( 4 );;
$fa4 = e107 :: getMedia () -> getGlyphs ( 'fa4' );
2017-01-01 08:13:42 -08:00
2021-04-06 18:41:15 -07:00
foreach ( $fa4 as $val )
{
$items [] = array (
'previewHtml' => $md -> previewTag ( 'fa-' . $val , array ( 'type' => 'glyph' )),
'previewUrl' => 'fa fa-' . $val ,
'saveValue' => 'fa-' . $val . '.glyph' ,
'thumbUrl' => 'fa-' . $val ,
'title' => 'FA4 ' . $val ,
'slideCaption' => 'Font-Awesome 4' ,
'slideCategory' => 'font-awesome'
);
}
}
2021-01-31 13:09:53 -08:00
2021-01-30 19:21:23 -08:00
if ( $this -> fontawesome === false || ( $this -> fontawesome < 4 ))
{
$bs3 = e107 :: getMedia () -> getGlyphs ( 'bs3' , 'glyphicon-' );
foreach ( $bs3 as $val )
{
$items [] = array (
'previewHtml' => $md -> previewTag ( $val , array ( 'type' => 'glyph' )),
'previewUrl' => 'glyphicon ' . $val ,
'saveValue' => $val . '.glyph' ,
'thumbUrl' => $val ,
'title' => 'BS3 ' . $val ,
'slideCaption' => 'Bootstrap' ,
'slideCategory' => 'bootstrap'
);
}
}
2017-01-01 08:13:42 -08:00
$custom = e107 :: getThemeGlyphs ();
if ( ! empty ( $custom ))
{
foreach ( $custom as $glyphConfig )
{
2017-12-03 09:50:44 -08:00
2021-01-30 19:21:23 -08:00
$tmp = e107 :: getMedia () -> getGlyphs ( $glyphConfig , $glyphConfig [ 'prefix' ]);
2017-01-01 08:13:42 -08:00
if ( ! empty ( $tmp ))
{
foreach ( $tmp as $val )
{
$items [] = array (
2020-12-31 16:14:43 -08:00
'previewHtml' => $md -> previewTag ( $glyphConfig [ 'class' ] . ' ' . $val , array ( 'type' => 'glyph' )),
'previewUrl' => $glyphConfig [ 'class' ] . ' ' . $val ,
2017-01-01 08:13:42 -08:00
'saveValue' => $val . '.glyph' ,
'thumbUrl' => $val ,
'title' => $val ,
'slideCaption' => ucfirst ( $glyphConfig [ 'name' ]),
'slideCategory' => $glyphConfig [ 'name' ]
);
}
}
}
}
2014-01-09 04:42:13 -08:00
2017-01-18 09:32:45 -08:00
if ( ! empty ( $parm [ 'search' ]))
2014-01-09 04:42:13 -08:00
{
$filtered = array ();
2016-12-22 08:47:54 -08:00
if ( ! empty ( $items ))
2014-01-09 04:42:13 -08:00
{
2016-12-22 08:47:54 -08:00
foreach ( $items as $v )
2014-01-09 04:42:13 -08:00
{
2016-12-22 08:47:54 -08:00
if ( strpos ( $v [ 'title' ], $parm [ 'search' ]) !== false )
{
$v [ 'slideCaption' ] = '' ;
$filtered [] = $v ;
}
}
}
2014-01-09 04:42:13 -08:00
$items = $filtered ;
}
return e107 :: getMedia () -> browserCarousel ( $items , $parms );
}
2015-06-08 15:55:05 -07:00
/**
* Extract Video or Playlist code from a URL
* Currently works with v = xxx or list = xxxx
* @ param $url
* @ return string
*/
2015-03-31 14:48:07 -07:00
function getYouTubeCode ( $url )
{
2020-12-31 16:14:43 -08:00
$url = str_replace ( 'url:' , 'http://' , $url );
2015-06-08 15:55:05 -07:00
2020-12-31 16:14:43 -08:00
list ( $tmp , $qry ) = explode ( '?' , $url );
2015-03-31 14:48:07 -07:00
parse_str ( $qry , $opt );
2015-06-08 15:55:05 -07:00
if ( ! empty ( $opt [ 'list' ]))
{
return 'playlist:' . $opt [ 'list' ];
}
if ( ! empty ( $opt [ 'v' ]))
{
return 'video:' . $opt [ 'v' ];
}
$pattern = '#^(?:https?://)?(?:www\.|m\.)?(?:youtu\.be/|youtube\.com(?:/embed/|/v/|/watch\?v=|/watch\?.+&v=))([\w-]{11})(?:.+)?$#x' ;
preg_match ( $pattern , $url , $matches );
return isset ( $matches [ 1 ]) ? 'video:' . trim ( $matches [ 1 ]) : false ;
2015-03-31 14:48:07 -07:00
}
2012-04-28 01:31:30 +00:00
2015-06-08 15:55:05 -07:00
/**
* @ param string $parm
2022-04-04 10:54:24 -07:00
* @ return string
2015-06-08 15:55:05 -07:00
* @ see https :// www . googleapis . com / youtube / v3 / search
*/
2018-08-16 19:02:02 -07:00
private function youtubeTab ( $parm = '' )
2014-01-08 15:51:14 -08:00
{
2016-02-14 13:44:00 -06:00
$apiKey = e107 :: pref ( 'core' , 'youtube_apikey' );
2015-06-08 15:55:05 -07:00
$searchQry = $this -> getQuery ( 'search' );
2015-03-31 14:48:07 -07:00
2020-12-31 16:14:43 -08:00
if ( strpos ( $searchQry , 'url:' ) === 0 )
2015-06-08 15:55:05 -07:00
{
$searchQry = $this -> getYouTubeCode ( $searchQry );
2015-03-31 14:48:07 -07:00
2015-06-08 15:55:05 -07:00
}
2015-03-31 14:48:07 -07:00
2015-06-08 15:55:05 -07:00
if ( ! empty ( $searchQry )) // -- Search Active.
{
2020-12-31 16:14:43 -08:00
if ( strpos ( $searchQry , 'video:' ) === 0 || strpos ( $searchQry , 'v=' ) === 0 ) // YouTube video code
2014-01-08 15:51:14 -08:00
{
2020-12-31 16:14:43 -08:00
$searchQry = ( strpos ( $searchQry , 'v=' ) === 0 ) ? trim ( substr ( $searchQry , 2 )) : trim ( substr ( $searchQry , 6 ));
2015-06-08 15:55:05 -07:00
$extension = 'youtube' ;
// $feed = "https://www.googleapis.com/youtube/v3/videos?part=snippet&id=".urlencode($searchQry)."&key=".$apiKey;
2015-03-31 14:48:07 -07:00
2015-06-08 15:55:05 -07:00
$data = array ();
$data [ 'items' ][ 0 ][ 'id' ][ 'videoId' ] = $searchQry ;
2020-12-31 16:14:43 -08:00
$data [ 'items' ][ 0 ][ 'snippet' ][ 'thumbnails' ][ 'medium' ][ 'url' ] = 'https://i.ytimg.com/vi/' . $searchQry . '/mqdefault.jpg' ;
2015-06-08 15:55:05 -07:00
$data [ 'items' ][ 0 ][ 'snippet' ][ 'title' ] = 'Specified Video' ;
}
2020-12-31 16:14:43 -08:00
elseif ( strpos ( $searchQry , 'playlist:' ) === 0 ) // playlist
2015-06-08 15:55:05 -07:00
{
2015-12-12 16:54:10 -08:00
if ( empty ( $apiKey ))
{
$playlistID = substr ( $searchQry , 9 );
$data = array ();
$data [ 'items' ][ 0 ][ 'id' ][ 'videoId' ] = $playlistID ;
2020-12-31 16:14:43 -08:00
$data [ 'items' ][ 0 ][ 'snippet' ][ 'thumbnails' ][ 'medium' ][ 'url' ] = e_IMAGE_ABS . 'generic/playlist_120.png' ; // "http://i.ytimg.com/vi/".$playlistID."/mqdefault.jpg"; // not really possible, so it will show a generic grey image.
2015-12-12 16:54:10 -08:00
$data [ 'items' ][ 0 ][ 'snippet' ][ 'title' ] = 'Specified Playlist' ;
}
else
{
$searchQry = trim ( substr ( $searchQry , 9 ));
2020-12-31 16:14:43 -08:00
$feed = 'https://www.googleapis.com/youtube/v3/search?part=snippet&q=' . urlencode ( $searchQry ) . '&type=playlist&maxResults=1&key=' . $apiKey ;
2015-12-12 16:54:10 -08:00
}
$extension = 'youtubepl' ;
2015-06-08 15:55:05 -07:00
}
2020-12-31 16:14:43 -08:00
elseif ( strpos ( $searchQry , 'channel:' ) === 0 )
2015-06-08 15:55:05 -07:00
{
$searchQry = trim ( substr ( $searchQry , 8 ));
$extension = 'youtube' ;
2020-12-31 16:14:43 -08:00
$feed = 'https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=' . urlencode ( $searchQry ) . '&type=video&maxResults=20&key=' . $apiKey ;
2015-06-08 15:55:05 -07:00
}
else
{
2020-12-31 16:14:43 -08:00
$feed = 'https://www.googleapis.com/youtube/v3/search?part=snippet&q=' . urlencode ( $searchQry ) . '&type=video&maxResults=20&key=' . $apiKey ;
2015-06-08 15:55:05 -07:00
$extension = 'youtube' ;
}
2015-03-31 14:48:07 -07:00
2015-06-08 15:55:05 -07:00
}
else // -- default state.
{
2015-03-31 14:48:07 -07:00
2015-06-08 15:55:05 -07:00
$defaultAccount = e107 :: pref ( 'core' , 'youtube_default_account' );
if ( empty ( $defaultAccount ))
{
$defaultAccount = 'e107inc' ;
}
2015-03-31 14:48:07 -07:00
2020-12-31 16:14:43 -08:00
$accFeed = 'https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername=' . $defaultAccount . '&key=' . $apiKey ;
2015-06-08 15:55:05 -07:00
$accData = e107 :: getFile () -> getRemoteContent ( $accFeed );
$accData = json_decode ( $accData , true );
2016-02-14 13:44:00 -06:00
$channelID = e107 :: pref ( 'core' , 'youtube_default_account' );
2015-03-31 14:48:07 -07:00
2017-02-02 09:34:20 +01:00
if ( ! empty ( $accData [ 'items' ]))
2014-01-08 15:51:14 -08:00
{
2017-02-02 09:34:20 +01:00
foreach ( $accData [ 'items' ] as $val )
2015-04-14 10:31:21 -07:00
{
2020-12-31 16:14:43 -08:00
if ( $val [ 'kind' ] === 'youtube#channel' )
2017-02-02 09:34:20 +01:00
{
2015-06-08 15:55:05 -07:00
$channelID = $val [ 'id' ];
break ;
2017-02-02 09:34:20 +01:00
}
2015-04-14 10:31:21 -07:00
}
2015-03-31 14:48:07 -07:00
}
2020-12-31 16:14:43 -08:00
$feed = 'https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=' . $channelID . '&type=video&maxResults=20&key=' . $apiKey ;
2015-06-08 15:55:05 -07:00
$extension = 'youtube' ;
}
if ( ! empty ( $feed ) )
{
2015-03-31 14:48:07 -07:00
2015-06-08 15:55:05 -07:00
if ( ! empty ( $apiKey ))
2015-03-31 14:48:07 -07:00
{
2015-06-08 15:55:05 -07:00
$data = e107 :: getFile () -> getRemoteContent ( $feed );
$data = json_decode ( $data , true );
$items = array ();
2015-03-31 14:48:07 -07:00
}
2015-06-08 15:55:05 -07:00
else // empty key.
2014-01-08 15:51:14 -08:00
{
2016-11-02 09:29:18 +01:00
$link = '<a style="color:black" target="_blank" href="' . e_ADMIN . 'image.php?mode=main&action=prefs#/tab2">' . IMALAN_177 . '</a>' ;
2018-07-25 20:28:30 -07:00
$items = "
2020-12-31 16:14:43 -08:00
< div class = 'alert alert-info' style = 'margin-left: 15px;' >< p > " .e107::getParser()->lanVars(e107::getParser()->toHTML(IMALAN_174, true), array('x'=> $link )). '</p>
</ div > ' ;
2016-11-02 09:29:18 +01:00
2014-01-08 15:51:14 -08:00
}
2015-03-31 14:48:07 -07:00
2015-06-08 15:55:05 -07:00
}
2015-03-31 14:48:07 -07:00
2018-08-23 08:45:07 -07:00
$bbcode = $this -> getQuery ( 'bbcode' );
$close = ( ! empty ( $bbcode )) ? false : true ; // only close on 'select' when bbcodes are not in use.
2018-08-16 19:02:02 -07:00
2015-06-08 15:55:05 -07:00
if ( ! empty ( $data ))
{
2018-10-23 12:54:19 -07:00
$tp = e107 :: getParser ();
2021-09-29 10:43:52 -07:00
2015-06-08 15:55:05 -07:00
foreach ( $data [ 'items' ] as $value )
{
$id = $value [ 'id' ][ 'videoId' ];
$thumbnail = $value [ 'snippet' ][ 'thumbnails' ][ 'medium' ][ 'url' ];
2021-09-29 10:43:52 -07:00
2015-06-08 15:55:05 -07:00
$items [] = array (
2021-09-29 10:43:52 -07:00
// 'previewHtml' => $bbcode !== 'video' ? null : $tp->toVideo($id. '.' .$extension, array('w' =>210, 'h' =>140)),
'previewHtml' => $tp -> toVideo ( $id . '.' . $extension , array ( 'w' => 210 , 'h' => 140 )),
2015-06-08 15:55:05 -07:00
'previewUrl' => $thumbnail ,
2020-12-31 16:14:43 -08:00
'saveValue' => $id . '.' . $extension , // youtube",
2015-06-08 15:55:05 -07:00
'thumbUrl' => $thumbnail ,
2020-12-31 16:14:43 -08:00
'title' => varset ( $value [ 'snippet' ][ 'title' ]),
2018-08-16 19:02:02 -07:00
'close' => $close
2015-06-08 15:55:05 -07:00
);
2020-12-31 16:14:43 -08:00
if ( $extension === 'youtubepl' ) // save Image for background.
2015-06-08 15:55:05 -07:00
{
2020-12-31 16:14:43 -08:00
$thumbnail = $value [ 'snippet' ][ 'thumbnails' ][ 'high' ][ 'url' ];
$hiresThumbnail = $thumbnail ;
2015-06-08 15:55:05 -07:00
e107 :: getMedia () -> saveThumb ( $hiresThumbnail , $id ); //TODO move to $tp->Video(); ?
}
}
}
// return print_a($data,true);
2018-08-13 13:17:54 -07:00
$parms = array (
'width' => 200 ,
'height' => 113 ,
'type' => 'image' ,
'bbcode' => 'video' ,
'tagid' => $this -> getQuery ( 'tagid' ),
'action' => 'youtube' ,
'searchPlaceholder' => IMALAN_175 ,
'gridClass' => 'col-xs-6 col-sm-3 media-carousel-item-youtube' ,
'perPage' => 8 ,
);
2018-08-16 19:02:02 -07:00
2015-06-08 15:55:05 -07:00
$text = e107 :: getMedia () -> browserCarousel ( $items , $parms );
2014-01-08 15:51:14 -08:00
2015-06-08 15:55:05 -07:00
if ( E107_DEBUG_LEVEL > 0 && ! empty ( $feed ))
{
2020-12-31 16:14:43 -08:00
$text .= '<div><small>Debug: ' . $feed . '</small></div>' ;
2015-06-08 15:55:05 -07:00
if ( ! empty ( $data ))
{
$text .= print_a ( $data , true );
}
}
2014-01-08 15:51:14 -08:00
return $text ;
}
2012-04-28 01:31:30 +00:00
2009-12-02 10:03:53 +00:00
function importPage ()
{
2013-11-06 16:36:48 -08:00
$this -> processUploadUrl ();
2010-03-09 16:05:41 +00:00
$this -> batchImportForm ();
2009-12-02 10:03:53 +00:00
}
2014-01-08 15:51:14 -08:00
2013-11-06 16:36:48 -08:00
function processUploadUrl ( $import = false , $cat = '_common' )
{
$fl = e107 :: getFile ();
$mes = e107 :: getMessage ();
2016-12-15 15:08:49 +01:00
$tp = e107 :: getParser ();
2020-12-31 16:14:43 -08:00
if ( ! empty ( $_POST [ 'upload_remote_url' ]))
2013-11-06 16:36:48 -08:00
{
$fileName = basename ( $_POST [ 'upload_url' ]);
2015-09-01 15:53:48 -07:00
if ( strpos ( $fileName , '?' ) !== false )
{
2020-12-31 16:14:43 -08:00
list ( $fileName , $bla ) = explode ( '?' , $fileName );
2015-09-01 15:53:48 -07:00
}
2020-12-31 16:14:43 -08:00
$uploadCaption = ! empty ( $_POST [ 'upload_caption' ]) ? $tp -> filter ( $_POST [ 'upload_caption' ]) : '' ;
2016-07-06 17:08:17 -07:00
$fileName = str_replace ( array ( '%' , '+' ), '' , $fileName );
2016-05-30 15:19:19 -07:00
2016-01-11 20:53:05 -08:00
// remove script extensions.
2020-12-31 16:14:43 -08:00
if ( substr ( $fileName , - 4 ) === '.php' || substr ( $fileName , - 4 ) === '.htm' || substr ( $fileName , - 5 ) === '.html' || substr ( $fileName , - 4 ) === '.asp' )
2016-01-11 20:53:05 -08:00
{
2020-12-31 16:14:43 -08:00
$fileName = empty ( $uploadCaption ) ? str_replace ( array ( '.php' , '.html' , '.asp' , '.htm' ), '' , $fileName ) . '_' . time () : eHelper :: dasherize ( strtolower ( $uploadCaption ));
2016-01-11 20:53:05 -08:00
}
2021-12-17 11:31:37 -08:00
if ( ! $fl -> isAllowedType ( $_POST [ 'upload_url' ]))
{
$mes -> addError ( defset ( 'IMALAN_190' , " Importing of this file-type is not allowed. " ));
}
elseif ( ! $fl -> getRemoteFile ( $tp -> filter ( $_POST [ 'upload_url' ], 'url' ), $fileName , 'import' ))
2013-11-06 16:36:48 -08:00
{
2016-11-02 09:29:18 +01:00
$mes -> addError ( IMALAN_176 );
2013-11-06 16:36:48 -08:00
}
elseif ( $import == true )
{
2016-12-20 10:58:43 +01:00
$data = array ( 'media_caption' => $uploadCaption );
e107 :: getMedia () -> importFile ( $fileName , $cat , null , $data );
2013-11-06 16:36:48 -08:00
}
}
}
2010-03-09 16:05:41 +00:00
2018-08-26 12:25:08 -07:00
/**
2022-04-04 10:54:24 -07:00
* @ return bool | false
*@ deprecated by $prefs .
2018-08-26 12:25:08 -07:00
*/
2009-12-02 10:03:53 +00:00
function settingsPage ()
{
2018-08-26 12:25:08 -07:00
return false ;
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
{
2020-12-31 16:14:43 -08:00
$gd_version = " <span class='error'> " . IMALAN_55 . '</span>' ;
2012-06-02 08:12:16 +00:00
}
2020-05-25 12:34:18 -07:00
$folder1 = e107 :: getFolder ( 'imagemagick' );
2020-12-31 16:14:43 -08:00
if ( $pref [ 'resize_method' ] === 'ImageMagick' && ( ! vartrue ( $folder1 )))
2012-06-02 08:12:16 +00:00
{
$mes -> addWarning ( 'Please add: <b>$IMAGEMAGICK_DIRECTORY="' . $pref [ 'im_path' ] . '";</b> to your e107_config.php file' );
}
//$IM_NOTE = "";
2020-05-25 12:34:18 -07:00
$folder = e107 :: getFolder ( 'imagemagick' );
$im_path = vartrue ( $folder );
2020-12-31 16:14:43 -08:00
if ( $im_path != '' )
2012-06-02 08:12:16 +00:00
{
$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` ;
2020-12-31 16:14:43 -08:00
if ( strpos ( $tmp , 'ImageMagick' ) === FALSE )
2012-06-02 08:12:16 +00:00
{
//$IM_NOTE = "<span class='error'>".IMALAN_53."</span>";
$mes -> addWarning ( IMALAN_53 );
}
}
}
$text = "
2020-12-31 16:14:43 -08:00
< form method = 'post' action = '".e_SELF. ' ? ' .e_QUERY."' >
2012-06-02 08:12:16 +00:00
< 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'] ). "
2020-12-31 16:14:43 -08:00
< div class = 'field-help' > " .IMALAN_2. '</div>
2012-06-02 08:12:16 +00:00
</ div >
</ td >
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td >
2020-12-31 16:14:43 -08:00
' .IMALAN_10. '
2012-06-02 08:12:16 +00:00
</ td >
2012-11-26 14:41:32 -08:00
< td >
2020-12-31 16:14:43 -08: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>
2012-06-02 08:12:16 +00:00
</ td >
</ tr >
< tr >
2012-11-26 14:41:32 -08:00
< td >
2020-12-31 16:14:43 -08:00
' .IMALAN_12. '
2012-06-02 08:12:16 +00:00
</ td >
2012-11-26 14:41:32 -08:00
< td >
2020-12-31 16:14:43 -08: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>
2012-06-02 08:12:16 +00:00
</ td >
2020-12-31 16:14:43 -08:00
</ tr > ' ;
2012-06-02 08:12:16 +00:00
2020-12-31 16:14:43 -08:00
list ( $img_import_w , $img_import_h ) = explode ( 'x' , $pref [ 'img_import_resize' ]);
2012-06-02 08:12:16 +00:00
2020-12-31 16:14:43 -08:00
$text .= '
2012-06-02 08:12:16 +00:00
< tr >
2020-12-31 16:14:43 -08:00
< td > ' .IMALAN_105."<div class=' label - note '>".IMALAN_106. ' </ div ></ td >
2012-11-26 14:41:32 -08:00
< td >
2020-12-31 16:14:43 -08:00
' .$frm->text(' img_import_resize_w ', $img_import_w,4). ' px X ' .$frm->text(' img_import_resize_h ', $img_import_h,4). ' px
2012-06-02 08:12:16 +00:00
</ td >
</ tr >
< tr >
2020-12-31 16:14:43 -08:00
< td > ' .IMALAN_3."<div class=' label - note ' > " .IMALAN_54. " { $gd_version } </ div ></ td >
2012-11-26 14:41:32 -08:00
< td >
2020-12-31 16:14:43 -08: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>
2012-06-02 08:12:16 +00:00
</ td >
2020-12-31 16:14:43 -08:00
</ tr > ' ;
2012-06-02 08:12:16 +00:00
/*
$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 > " ;
*/
2020-12-31 16:14:43 -08:00
$text .= '
2012-06-02 08:12:16 +00:00
< tr >
2020-12-31 16:14:43 -08:00
< td > ' .IMALAN_36. ' </ td >
2012-11-26 14:41:32 -08:00
< td >
2020-12-31 16:14:43 -08:00
' .$frm->admin_button(' check_avatar_sizes ' , ADLAN_145 ) . "
2012-06-02 08:12:16 +00:00
</ td >
</ tr >
</ tbody >
</ table >
< div class = 'buttons-bar center' >
2020-12-31 16:14:43 -08:00
" . $frm->admin_button ('update_options', IMALAN_8, 'update'). '
2012-06-02 08:12:16 +00:00
</ div >
</ fieldset >
2020-12-31 16:14:43 -08:00
</ form > ' ;
2012-06-02 08:12:16 +00:00
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
2015-06-18 01:17:26 -07:00
function avatarPageDeleteChecked ()
{
$sql = e107 :: getDb ();
$mes = e107 :: getMessage ();
2016-12-02 13:14:50 -08:00
$tp = e107 :: getParser ();
2015-06-18 01:17:26 -07:00
if ( ! empty ( $_POST [ 'multiaction' ]))
{
2016-12-15 15:08:49 +01:00
$actions = $tp -> filter ( $_POST [ 'multiaction' ]);
2015-06-18 01:17:26 -07:00
$tmp = array (); $tmp1 = array (); $message = array ();
2016-12-15 15:08:49 +01:00
foreach ( $actions as $todel )
2015-06-18 01:17:26 -07:00
{
list ( $usr , $path ) = explode ( '#' , $todel );
// $path = basename($path);
2020-12-31 16:14:43 -08:00
$path = str_replace ( '../' , '' , $path ); // clean the path.
2015-06-18 01:17:26 -07:00
2020-12-31 16:14:43 -08:00
$mes -> addDebug ( 'usr: ' . ( int ) $usr . ' path: ' . $path );
2015-06-18 01:17:26 -07:00
$image_type = 2 ;
if ( strpos ( $path , '-upload-' ) === 0 )
{
$image_type = 1 ;
$path = substr ( $path , strlen ( '-upload-' ));
}
//delete it from server
2016-12-02 13:14:50 -08:00
$deletePath = e_AVATAR . $tp -> filter ( $path );
2015-06-18 01:17:26 -07:00
if ( @ unlink ( $deletePath ))
{
$mes -> addDebug ( 'Deleted: ' . $deletePath );
$message [] = basename ( $path ); //admin log & sysmessage
}
else
{
$mes -> addError ( 'Unable to delete: ' . $deletePath ); // Do not translate, temporary during beta stage.
}
//It's owned by an user
if ( ! empty ( $usr ))
{
switch ( $image_type )
{
case 1 : //avatar
2020-12-31 16:14:43 -08:00
$tmp [] = ( int ) $usr ;
2015-06-18 01:17:26 -07:00
break ;
case 2 : //photo
2020-12-31 16:14:43 -08:00
$tmp1 [] = ( int ) $usr ;
2015-06-18 01:17:26 -07:00
break ;
}
}
}
//Reset all deleted user avatars with one query
if ( ! empty ( $tmp ))
{
2020-12-31 16:14:43 -08:00
$sql -> update ( 'user' , " user_image='' WHERE user_id IN ( " . implode ( ',' , $tmp ) . ')' );
$mes -> addDebug ( " user_image='' WHERE user_id IN ( " . implode ( ',' , $tmp ) . ')' );
2015-06-18 01:17:26 -07:00
}
//Reset all deleted user photos with one query
if ( ! empty ( $tmp1 ))
{
2020-12-31 16:14:43 -08:00
$sql -> update ( 'user' , " user_sess='' WHERE user_id IN ( " . implode ( ',' , $tmp1 ) . ')' );
$mes -> addDebug ( " user_sess='' WHERE user_id IN ( " . implode ( ',' , $tmp1 ) . ')' );
2015-06-18 01:17:26 -07:00
}
unset ( $tmp , $tmp1 );
//Format system message
if ( ! empty ( $message ))
{
2020-12-31 16:14:43 -08:00
e107 :: getLog () -> add ( 'IMALAN_01' , implode ( '[!br!]' , $message ));
2015-06-18 01:17:26 -07:00
$mes -> addSuccess ( implode ( ', ' , $message ) . ' ' . IMALAN_28 );
}
}
}
2016-02-25 12:53:04 -08:00
function renderHelp ()
{
2020-12-31 16:14:43 -08:00
if ( $this -> getAction () === 'avatar' )
2016-02-25 12:53:04 -08:00
{
2020-12-31 16:14:43 -08:00
$text = IMALAN_155 . ': <br /><code>' . e_AVATAR_DEFAULT . '</code>' ;
2016-02-25 12:53:04 -08:00
return array ( 'caption' => EMESSLAN_TITLE_INFO , 'text' => $text );
}
2015-06-18 01:17:26 -07:00
2016-02-25 12:53:04 -08:00
}
2015-06-18 01:17:26 -07:00
2009-12-02 10:03:53 +00:00
function avatarPage ()
{
2015-06-18 01:17:26 -07:00
global $pref ;
if ( isset ( $_POST [ 'submit_show_delete_multi' ]))
{
$this -> avatarPageDeleteChecked ();
}
2015-08-16 15:05:34 -07:00
e107 :: css ( 'inline' , '
span . avatar - label { width : 100 % ; display : block ; padding : 5 px ; margin - bottom : 5 px }
div . avatar - container { margin - bottom : 5 px ; max - height : 350 px }
' );
2015-06-18 01:17:26 -07:00
$sql = e107 :: getDb ();
$frm = e107 :: getForm ();
$tp = e107 :: getParser ();
$mes = e107 :: getMessage ();
2020-12-31 16:14:43 -08:00
$avFiles = e107 :: getFile () -> get_files ( e_MEDIA . 'avatars/' , '.jpg|.png|.gif|.jpeg|.JPG|.GIF|.PNG' , null , 2 );
2015-06-18 01:17:26 -07:00
$dirlist = array ();
foreach ( $avFiles as $f )
{
2020-12-31 16:14:43 -08:00
$dirlist [] = str_replace ( e_MEDIA . 'avatars/' , '' , $f [ 'path' ]) . $f [ 'fname' ];
2015-06-18 01:17:26 -07:00
}
$text = '' ;
if ( empty ( $dirlist ))
{
$text .= IMALAN_29 ;
}
else
{
$tmp = $sql -> retrieve ( 'user' , 'user_id,user_image' , 'user_image !="" ' , true );
$imageUsed = array ();
foreach ( $tmp as $val )
{
$id = $val [ 'user_id' ];
2020-12-31 16:14:43 -08:00
$imageUsed [ $id ] = str_replace ( '-upload-' , '' , $val [ 'user_image' ]);
2015-06-18 01:17:26 -07:00
}
$userImages = array_flip ( $imageUsed );
$text = $frm -> open ( 'core-image-avatars' );
2015-08-16 15:05:34 -07:00
$text .= " <div id='core-image-show-avatars' class='row'> " ;
2015-06-18 01:17:26 -07:00
$count = 0 ;
2018-08-11 10:44:05 -07:00
$prevType = '' ;
2020-12-08 12:21:12 -08:00
foreach ( $dirlist as $key => $image_name )
2015-06-18 01:17:26 -07:00
{
//$users = IMALAN_21." | ";
$row = array ( 'user_id' => '' );
$image_pre = '' ;
$disabled = false ;
/*
2020-12-17 05:52:54 -08:00
if ( $sql -> select ( " user " , " * " , " user_image='-upload- " . $tp -> toDB ( $image_name ) . " ' OR user_sess=' " . $tp -> toDB ( $image_name ) . " ' " ))
2015-06-18 01:17:26 -07:00
{
2020-12-17 05:52:54 -08:00
$row = $sql -> fetch ();
2015-06-18 01:17:26 -07:00
if ( $row [ 'user_image' ] == '-upload-' . $image_name ) $image_pre = '-upload-' ;
$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> " ;
}
else
{
}
*/
// :
2015-08-16 15:05:34 -07:00
// $fileName = basename($image_name);
2015-06-18 01:17:26 -07:00
$fileName = basename ( $image_name );
2015-08-16 15:05:34 -07:00
2020-12-31 16:14:43 -08:00
$users = ( in_array ( $fileName , $imageUsed )) ? " <span class='label label-warning avatar-label'> " . IMALAN_153 . '</span>' : '<span class="label label-default avatar-label" >' . IMALAN_154 . '</span>' ;
2015-06-18 01:17:26 -07:00
//directory?
2020-12-31 16:14:43 -08:00
if ( is_dir ( e_MEDIA . 'avatars/' . $image_name ))
2015-06-18 01:17:26 -07:00
{
//File info
2020-12-31 16:14:43 -08: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>' ;
2015-06-18 01:17:26 -07:00
//Friendly UI - click text to select a form element
$img_src = '<span class="error">' . IMALAN_70 . '</span>' ;
$disabled = true ;
}
else
{
//File info
// $users = "<a class='e-tip' href='#' title='".IMALAN_66.": {$image_name}'><img src='".e_IMAGE_ABS."admin_imaXXXges/info_16.png' alt='".IMALAN_66.": {$image_name}' /></a> ".$users;
// Control over the image size (design)
// $image_size = getimagesize(e_MEDIA."avatars/".$image_name);
//Friendly UI - click text to select a form element
// Resized on-the-fly - avatar-size no longer an issue.
2015-08-16 15:05:34 -07:00
// $attr = "aw=".$pref['im_width']."&ah=".$pref['im_height'];
2020-12-31 16:14:43 -08:00
$attr = 'aw=200&ah=200' ;
$img_path = $tp -> thumbUrl ( e_MEDIA_ABS . 'avatars/' . $image_name , $attr );
2015-06-18 01:17:26 -07:00
$type = dirname ( $image_name );
if ( $prevType != $type )
{
2015-08-16 15:05:34 -07:00
$text .= " <div class='col-md-12 clearfix'></div>
2020-12-31 16:14:43 -08:00
< h4 class = 'clearfix col-md-12' > " . $type . '</h4>';
2015-06-18 01:17:26 -07:00
}
$for = $frm -> name2id ( 'multiaction-' . $image_name );
2015-08-16 15:05:34 -07:00
$img_src = "
2015-06-18 01:17:26 -07:00
< div class = 'thumbnail' >
2017-01-20 10:40:05 -08:00
< label for = '".$for."' >< img class = 'img-responsive img-fluid' src = '".$img_path."' alt = '{$image_name}' title = '".IMALAN_66.": {$image_name}' /></ label >
2015-06-18 01:17:26 -07:00
</ div >
2015-08-16 15:05:34 -07:00
" ;
2015-06-18 01:17:26 -07:00
$prevType = $type ;
}
//style attribute allowed here - server side width/height control
//autocheck class - used for JS selectors (see eCoreImage object)
$text .= "
2015-08-16 16:38:50 -07:00
< div class = 'col-md-2 col-sm-4 center autocheck avatar-container' >
2015-06-18 01:17:26 -07:00
< div class = 'well' >
< div class = 'image-users' > { $users } </ div >
< div class = 'image-preview' > { $img_src } </ div >
< div class = 'image-delete' >
2020-12-31 16:14:43 -08:00
" . $frm->checkbox ('multiaction[]', (int) $userImages[$fileName] . " #{$image_pre}{$image_name}", false, array('id' => $for, 'disabled' => $disabled)). '
2015-06-18 01:17:26 -07:00
</ div >
</ div >
</ div >
2020-12-31 16:14:43 -08:00
' ;
2015-06-18 01:17:26 -07:00
$count ++ ;
}
2015-08-16 15:05:34 -07:00
$text .= " </div>
< div class = 'col-md-12 spacer clearfix' >
< div class = 'row buttons-bar' >
2015-06-18 01:17:26 -07:00
< input type = 'hidden' name = 'show_avatars' value = '1' />
2020-12-31 16:14:43 -08:00
" . $frm->admin_button ('e_check_all', LAN_CHECKALL, 'action'). '
' .$frm->admin_button(' e_uncheck_all ', LAN_UNCHECKALL, ' action '). '
' .$frm->admin_button(' submit_show_delete_multi ', LAN_DELCHECKED, ' delete '). '
' .$frm->admin_button(' submit_show_deleteall ', IMALAN_156, ' delete '). '
2015-06-18 01:17:26 -07:00
</ div >
</ div >
2015-08-16 15:05:34 -07:00
2015-06-18 01:17:26 -07:00
</ form >
2020-12-31 16:14:43 -08:00
' ;
2015-06-18 01:17:26 -07:00
// $frm->admin_button('submit_cancel_show', IMALAN_68, 'cancel')
}
return $mes -> render () . $text ;
// $ns->tablerender(LAN_MEDIAMANAGER." :: ".IMALAN_18, $mes->render().$text);
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
*/
2018-08-11 10:44:05 -07:00
public function beforeCreate ( $new_data , $old_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
2020-12-31 16:14:43 -08:00
$this -> getRequest () -> setPosted ( 'media_upload' );
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 )
{
2020-12-31 16:14:43 -08:00
if ( ! $sc_path )
{
return array ();
}
2010-10-04 16:01:17 +00:00
$path = e107 :: getParser () -> replaceConstants ( $sc_path );
2020-12-31 16:14:43 -08:00
$info = e107 :: getFile () -> getFileInfo ( $path );
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' => '' ,
2020-12-31 16:14:43 -08:00
'media_dimensions' => $info [ 'img-width' ] . ' x ' . $info [ 'img-height' ]
2010-10-04 16:01:17 +00:00
);
}
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
2020-12-31 16:14:43 -08: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)
2013-05-17 18:17:04 -07:00
$uploaded = process_uploaded_files ( e_IMPORT ); //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' ]))
{
2015-05-01 15:55:13 +02:00
$mes -> addError ( IMALAN_107 );
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'];
2013-05-17 18:17:04 -07:00
$oldpath = e_IMPORT . $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
{
2015-05-01 15:55:13 +02:00
$srch = array ( '[x]' , '[y]' );
$repl = array ( $oldpath , $newpath );
$text = str_replace ( $srch , $repl , IMALAN_108 );
$mes -> add ( $text , E_MESSAGE_ERROR );
2010-10-04 16:01:17 +00:00
return FALSE ;
2020-12-31 16:14:43 -08:00
}
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' ])))
{
2020-12-31 16:14:43 -08:00
$mes -> addError ( IMALAN_109 . ' ' . $typePath );
2012-04-27 02:02:38 +00:00
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
2013-05-17 18:17:04 -07:00
if ( strpos ( $new_data [ 'media_url' ], '{e_IMPORT}' ) !== FALSE )
2012-11-12 21:46:10 +00:00
// 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 ))
{
2015-05-01 15:55:13 +02:00
$srch = array ( '[x]' , '[y]' );
$repl = array ( $oldpath , str_replace ( '../' , '' , $newpath ));
2015-05-08 10:49:52 +02:00
$text = str_replace ( $srch , $repl , IMALAN_108 );
2015-05-01 15:55:13 +02:00
$mes -> add ( $text , E_MESSAGE_ERROR );
2010-10-04 16:01:17 +00:00
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 ();
2020-12-18 09:39:02 -08:00
$f = e107 :: getFile () -> getFileInfo ( $oldpath , TRUE );
2012-04-28 01:31:30 +00:00
2020-12-31 16:14:43 -08:00
$mes -> addDebug ( 'checkDupe(): newpath=' . $newpath . '<br />oldpath=' . $oldpath . '<br />' . print_r ( $newpath , TRUE ));
if ( file_exists ( $newpath ) || e107 :: getDb () -> select ( 'core_media' , '*' , " media_url = ' " . $tp -> createConstants ( $newpath , 'rel' ) . " ' LIMIT 1 " ) )
2012-04-28 01:31:30 +00:00
{
2020-12-31 16:14:43 -08:00
$mes -> addWarning ( $newpath . ' already exists.' );
$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
2018-08-11 10:44:05 -07:00
function afterDelete ( $deleted_data , $id , $deleted_check ) // 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
2017-12-09 15:06:10 -08:00
if ( ! empty ( $deleted_data [ 'media_url' ]))
{
$status = e107 :: getFile () -> delete ( $deleted_data [ 'media_url' ]);
$message = ( $status !== false ) ? LAN_UI_FILE_DELETED : LAN_UI_FILE_DELETED_FAILED ;
$mes = e107 :: getParser () -> lanVars ( $message , $deleted_data [ 'media_url' ], true );
$errType = ( $status ) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR ;
e107 :: getMessage () -> add ( $mes , $errType );
}
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
{
2016-01-24 00:37:36 -08:00
return e107 :: getMedia () -> getPath ( $mime );
/*
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
{
2015-05-01 15:55:13 +02:00
$text = str_replace ( '[x]' , $mime , IMALAN_111 );
$mes -> add ( $text , 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
{
2015-05-01 15:55:13 +02:00
$text = str_replace ( '[x]' , $dir , IMALAN_112 );
$mes -> add ( $text , 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
}
2016-01-24 00:37:36 -08: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 ();
2016-12-15 15:08:49 +01:00
$tp = e107 :: getParser ();
2013-11-06 16:07:58 -08:00
2013-11-06 16:36:48 -08:00
2013-11-06 16:07:58 -08: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/");
2013-05-17 18:17:04 -07:00
$files = $fl -> get_files ( e_IMPORT );
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' ]))
{
2020-12-31 16:14:43 -08:00
$mes -> add ( IMALAN_113 . ' <b> ' . e_IMPORT . '</b>' , E_MESSAGE_INFO );
2009-12-02 10:03:53 +00:00
}
2016-12-21 14:25:26 -08: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' ]))
{
2015-05-01 15:55:13 +02:00
$mes -> add ( IMALAN_114 , E_MESSAGE_INFO );
2012-07-18 06:34:26 +00:00
}
2014-01-09 04:42:13 -08:00
$text = $this -> uploadTab ();
2012-07-18 06:34:26 +00:00
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
2016-12-21 14:25:26 -08:00
2009-12-02 10:03:53 +00:00
$text = "
2020-12-31 16:14:43 -08:00
< form method = 'post' action = '".e_SELF. ' ? ' .e_QUERY."' id = 'batch_import' >
2009-12-02 10:03:53 +00:00
< fieldset id = 'core-mediamanager-batch' >
2020-12-25 10:23:56 -08:00
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 >
2015-05-01 15:55:13 +02:00
< th class = 'center' style = 'width:50px' > " .IMALAN_121. " </ th >
2020-12-31 16:14:43 -08:00
< th class = 'center' > " .LAN_FILE. '</th>
< th > ' .IMALAN_115. ' </ th >
< th > ' .IMALAN_116. ' </ th >
< th > ' .LAN_AUTHOR. ' </ th >
< th > ' .IMALAN_118. ' </ th >
< th > ' .IMALAN_119. ' </ th >
< th > ' . LAN_DATESTAMP . " </th>
< th class = 'center last' > " .IMALAN_120. '</th>
2009-12-02 10:03:53 +00:00
</ tr >
</ thead >
2020-12-31 16:14:43 -08:00
< tbody > ' ;
2012-04-22 06:19:21 +00:00
2012-09-03 23:02:45 +00:00
// $c = 0;
2016-12-21 14:25:26 -08:00
2009-12-02 10:03:53 +00:00
foreach ( $files as $f )
{
2016-12-21 14:25:26 -08:00
if ( empty ( $f ))
{
2020-12-31 16:14:43 -08:00
e107 :: getMessage () -> addWarning ( IMALAN_180 . ' ' . e_IMPORT . '<br />' . IMALAN_181 );
2016-12-21 14:25:26 -08:00
////rename(e_IMPORT.$f['path'].$f['fname'],e_IMPOT.$f['path'].$f['fname']."-bad");
continue ;
}
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 );
2018-07-16 17:14:10 -07:00
2012-09-03 23:02:45 +00:00
$c = md5 ( $f [ 'path' ] . $f [ 'fname' ]);
2012-07-14 10:40:40 +00:00
2018-11-26 11:15:53 -08:00
if ( ! empty ( $f [ 'error' ]))
2012-07-14 10:40:40 +00:00
{
2015-05-01 15:55:13 +02:00
$text = str_replace ( '[x]' , $f [ 'fname' ], IMALAN_122 );
$mes -> addWarning ( $text );
2012-07-14 10:40:40 +00:00
}
2012-08-19 02:33:43 +00:00
$large = e107 :: getParser () -> thumbUrl ( $f [ 'path' ] . $f [ 'fname' ], 'w=800' , true );
2016-01-24 00:37:36 -08:00
$checked = empty ( $_POST [ 'batch_selected' ]) ? true : false ;
2012-04-22 07:53:34 +00:00
$text .= "
< tr >
2020-12-31 16:14:43 -08:00
< td class = 'center' > " . $frm->checkbox ('batch_selected[' . $c . ']', $f['fname'] , $checked ). " </ td >
2012-04-22 06:19:21 +00:00
< td class = 'center' > " . $this->preview ( $f ). " </ td >
2020-12-31 16:14:43 -08:00
< td >< a class = 'e-dialog' href = '".$large."' > " . $f['fname'] . '</a></td>
< td > ' .$frm->text(' batch_import_name [ '.$c.' ] ', (!empty($_POST[' batch_import_name '][$c]) ? $tp->filter($_POST[' batch_import_name '][$c]) : $default[' title ' ])) . " </td>
2020-12-25 10:23:56 -08:00
< td >< textarea name = 'batch_import_diz[".$c."]' rows = '3' cols = '50' > " . (!empty( $_POST['batch_import_diz'] [ $c ]) ? $tp->filter ( $_POST['batch_import_diz'] [ $c ]) : $default['description'] ). " </ textarea ></ td >
2012-07-12 01:43:38 +00:00
2020-12-31 16:14:43 -08:00
< td >< a href = 'mailto:".$default[' authorEmail ']."' > " . $default['authorName'] . '</a><br />' . $default['authorEmail'] . '</td>
< td > ' .$f[' mime ']. ' </ td >
< td > ' .$f[' fsize ']. ' </ td >
< td > ' .e107::getDateConvert()->convert_date($f[' modified ' ]) . " </td>
< td class = 'center last' > " . $f['img-width'] . ' x ' . $f['img-height'] . " </ td >
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
2016-03-14 13:03:55 -07:00
2016-11-02 09:29:18 +01:00
$this -> cats [ '_avatars_public' ] = IMALAN_178 ;
$this -> cats [ '_avatars_private' ] = IMALAN_179 ;
2016-03-14 13:03:55 -07:00
2020-12-31 16:14:43 -08:00
if ( ! isset ( $_POST [ 'batch_category' ]) && strpos ( $lastMime , 'image' ) === 0 )
2012-07-18 06:34:26 +00:00
{
2020-12-31 16:14:43 -08:00
$_POST [ 'batch_category' ] = '_common_image' ;
2012-07-18 06:34:26 +00:00
}
2009-12-02 10:03:53 +00:00
$text .= "
</ tbody >
</ table >
2016-01-24 00:37:36 -08:00
< div class = 'buttons-bar center form-inline' >
2020-12-31 16:14:43 -08:00
" .IMALAN_123. ' ' . $frm->selectbox ('batch_category', $this->cats , $tp->filter ( $_POST['batch_category'] ));
2011-08-23 02:51:56 +00:00
2020-12-06 11:33:09 -08:00
2011-08-23 02:51:56 +00:00
$text .= "
2009-12-02 10:03:53 +00:00
</ div >
< div class = 'buttons-bar center' >
2015-05-01 15:55:13 +02:00
" . $frm->admin_button ('batch_import_selected', IMALAN_124, 'import')
. $frm -> admin_button ( 'batch_import_delete' , IMALAN_125 , 'delete' );
2020-12-31 16:14:43 -08:00
$text .= '
2009-12-02 10:03:53 +00:00
</ div >
</ fieldset >
</ form >
2010-03-09 16:05:41 +00:00
2020-12-31 16:14:43 -08: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 )
{
2020-12-31 16:14:43 -08:00
list ( $file , $ext ) = explode ( '.' , $imgFile );
2012-07-12 01:43:38 +00:00
2020-12-31 16:14:43 -08:00
$xmlFile = e_IMPORT . $file . '.xml' ;
2012-07-12 01:43:38 +00:00
if ( is_readable ( $xmlFile ))
{
$data = file_get_contents ( $xmlFile );
2020-12-20 19:42:09 -08:00
preg_match ( " /<author name=(?:'| \" )([^' \" ]*)/i " , $data , $authorName );
preg_match ( " /email=(?:'| \" )([^' \" ]*)/i " , $data , $authorEmail );
preg_match ( " /<title>(.*)< \ /title>/i " , $data , $title );
preg_match ( " /<description>(.*)< \ /description>/i " , $data , $diz );
2012-07-12 01:43:38 +00:00
return array (
'title' => $title [ 1 ],
'description' => $diz [ 1 ],
'authorName' => $authorName [ 1 ],
'authorEmail' => $authorEmail [ 1 ]
);
}
2020-12-31 16:14:43 -08:00
$srch = array ( '_' , '-' );
$description = str_replace ( $srch , ' ' , $file );
2015-02-03 12:57:35 -08:00
$file = utf8_encode ( $file );
$description = utf8_encode ( $description );
2013-05-17 18:17:04 -07:00
return array ( 'title' => basename ( $file ), 'description' => $description , 'authorName' => USERNAME , 'authorEmail' => '' );
2012-07-12 01:43:38 +00:00
/*
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 )
{
2020-12-31 16:14:43 -08:00
list ( $file , $ext ) = explode ( '.' , $imgFile );
2012-07-12 01:43:38 +00:00
2020-12-31 16:14:43 -08:00
$xmlFile = e_IMPORT . $file . '.xml' ;
2012-07-12 01:43:38 +00:00
if ( file_exists ( $xmlFile ))
{
unlink ( $xmlFile );
}
}
2012-07-18 06:34:26 +00:00
function batchDelete ()
{
2016-12-20 10:58:43 +01:00
$tp = e107 :: getParser ();
2012-07-18 06:34:26 +00:00
foreach ( $_POST [ 'batch_selected' ] as $key => $file )
{
if ( trim ( $file ) == '' )
{
continue ;
}
2012-11-12 21:46:10 +00:00
// $oldpath = e_MEDIA."temp/".$file;
2016-12-20 10:58:43 +01:00
$oldpath = e_IMPORT . $tp -> filter ( $file , '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' ]))
{
2015-05-01 15:55:13 +02:00
$mes -> addError ( IMALAN_126 );
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
2020-12-06 11:33:09 -08:00
// list($img_import_w,$img_import_h) = explode("x",e107::getPref('img_import_resize'));
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
{
2016-03-14 13:42:41 -07:00
2016-12-05 20:35:48 -08:00
$oldpath = e_IMPORT . $tp -> filter ( $file , 'file' );
2016-03-14 13:03:55 -07:00
2020-12-31 16:14:43 -08:00
if ( $_POST [ 'batch_category' ] === '_avatars_public' || $_POST [ 'batch_category' ] === '_avatars_private' )
2016-03-14 13:03:55 -07:00
{
2020-12-31 16:14:43 -08:00
$newpath = ( $_POST [ 'batch_category' ] === '_avatars_public' ) ? e_AVATAR_DEFAULT . $tp -> filter ( $file , 'file' ) : $newpath = e_AVATAR_UPLOAD . $tp -> filter ( $file , 'file' );
2016-03-14 13:03:55 -07:00
if ( rename ( $oldpath , $newpath ))
{
2020-12-31 16:14:43 -08:00
$mes -> addSuccess ( IMALAN_128 . ' ' . $newpath );
2016-03-14 13:03:55 -07:00
}
else
{
2020-12-31 16:14:43 -08:00
$mes -> addError ( IMALAN_128 . ' ' . $newpath );
2016-03-14 13:03:55 -07:00
}
continue ;
}
2011-08-22 23:52:45 +00:00
// Resize on Import Routine ------------------------
2020-12-18 19:55:12 -08:00
// 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);
2020-12-18 19:55:12 -08:00
// }
2011-08-22 23:52:45 +00:00
// End Resize routine. ---------------------
2011-06-07 13:01:36 +00:00
2020-12-18 09:39:02 -08:00
$f = $fl -> getFileInfo ( $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
2020-12-31 16:14:43 -08:00
$mes -> add ( IMALAN_127 . ' ' . $oldpath , E_MESSAGE_WARNING );
2012-07-11 04:46:09 +00:00
// $mes->add(print_a($f,true), E_MESSAGE_ERROR);
2020-12-31 16:14:43 -08:00
$f [ 'mime' ] = 'other/file' ;
2010-10-10 22:08:57 +00:00
}
2011-06-07 13:01:36 +00:00
2016-01-24 00:37:36 -08:00
if ( ! $newDir = $this -> getPath ( $f [ 'mime' ]))
{
continue ;
}
$newpath = $this -> checkDupe ( $oldpath , $newDir . '/' . $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
/*
2020-12-17 05:52:54 -08:00
if ( file_exists ( $newpath ) || $sql -> select ( " core_media " , " media_url = ' " . $tp -> createConstants ( $newpath , 'rel' ) . " ' LIMIT 1 " ) )
2012-04-28 01:31:30 +00:00
{
$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' => '' ,
2016-12-15 15:08:49 +01:00
'media_category' => $tp -> filter ( $_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' ],
2020-12-31 16:14:43 -08: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
2020-12-31 16:14:43 -08:00
if ( $sql -> insert ( 'core_media' , $insert ))
2009-12-02 10:03:53 +00:00
{
2020-12-31 16:14:43 -08:00
$mes -> add ( IMALAN_128 . ' ' . $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 )
{
2020-12-31 16:14:43 -08:00
list ( $type , $tmp ) = explode ( '/' , $f [ 'mime' ]);
2009-12-02 10:03:53 +00:00
2020-12-31 16:14:43 -08:00
if ( $type === 'image' )
2009-12-02 10:03:53 +00:00
{
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;
2020-12-25 10:23:56 -08:00
return " <a class='e-dialog' href=' " . $large . " '><img src=' " . $url . " ' alt= \" " . varset ( $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
2020-12-31 16:14:43 -08:00
public function getMediaCategory ( $id = null )
2010-10-04 16:01:17 +00:00
{
2020-12-31 16:14:43 -08:00
if ( is_array ( $id ))
2012-05-23 08:29:57 +00:00
{
2020-12-31 16:14:43 -08:00
$text = '' ;
foreach ( $id as $val )
2012-05-23 08:29:57 +00:00
{
2020-12-31 16:14:43 -08:00
$text .= ( isset ( $this -> cats [ $val ]) ? " <span class='nowrap'> " . $this -> cats [ $val ] . '</span><br />' : '' );
}
return $text ;
}
if ( ! empty ( $id ))
{
{
return ( isset ( $this -> cats [ $id ]) ? $this -> cats [ $id ] : 0 );
}
2012-05-23 08:29:57 +00:00
}
2010-10-04 16:01:17 +00:00
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 ();
2020-12-18 09:39:02 -08:00
$tmp [ 'image_post' ] = ( int ) $_POST [ 'image_post' ];
$tmp [ 'resize_method' ] = $tp -> toDB ( $_POST [ 'resize_method' ]);
$tmp [ 'im_path' ] = trim ( $tp -> toDB ( $_POST [ 'im_path' ]));
$tmp [ 'image_post_class' ] = ( int ) $_POST [ 'image_post_class' ];
$tmp [ 'image_post_disabled_method' ] = ( int ) $_POST [ 'image_post_disabled_method' ];
$tmp [ 'enable_png_image_fix' ] = ( int ) $_POST [ 'enable_png_image_fix' ];
2012-04-22 07:53:34 +00:00
if ( $_POST [ 'img_import_resize_w' ] && $_POST [ 'img_import_resize_h' ])
{
2020-12-31 16:14:43 -08:00
$tmp [ 'img_import_resize' ] = ( int ) $_POST [ 'img_import_resize_w' ] . 'x' . ( int ) $_POST [ 'img_import_resize_h' ];
2012-04-22 07:53:34 +00:00
}
2020-12-18 09:39:02 -08:00
e107 :: getConfig () -> setPref ( $tmp ) -> save ( true , true , true );
2012-04-22 07:53:34 +00:00
}
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 ();
2020-12-31 16:14:43 -08:00
require_once ( e_ADMIN . 'auth.php' );
2009-11-07 11:20:34 +00:00
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 ;
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
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
{
2013-04-19 22:50:41 -07:00
$handle = opendir ( e_AVATAR_UPLOAD );
2008-12-10 16:59:19 +00:00
$dirlist = array ();
2020-12-31 16:14:43 -08:00
$ignore = [ '.' , '..' , 'index.html' , 'null.txt' , '/' , 'CVS' , 'Thumbs.db' ];
2013-04-19 22:50:41 -07:00
while ( $file = readdir ( $handle ))
{
2020-12-31 16:14:43 -08:00
if ( in_array ( $file , $ignore ))
{
continue ;
}
if ( ! is_dir ( e_AVATAR_UPLOAD . $file ))
{
2006-12-02 04:36:16 +00:00
$dirlist [] = $file ;
}
}
2020-12-31 16:14:43 -08:00
2006-12-02 04:36:16 +00:00
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 );
2020-12-14 16:21:48 -08:00
if ( ! $sql -> count ( 'user' , '(*)' , " WHERE user_image='-upload- { $image_todb } ' OR user_sess=' { $image_todb } ' " )) {
2013-04-19 22:50:41 -07:00
unlink ( e_AVATAR_UPLOAD . $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
2020-12-31 16:14:43 -08:00
$message = $count . ' ' . IMALAN_26 ;
2013-02-25 20:14:59 +01:00
$mes -> addSuccess ( $message );
2020-12-31 16:14:43 -08:00
e107 :: getLog () -> add ( 'IMALAN_02' , $message . $imgList );
2008-12-10 16:59:19 +00:00
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
{
2020-12-31 16:14:43 -08: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 ();
2016-12-20 10:58:43 +01:00
$tp = e107 :: getParser ();
$sql = e107 :: getDb ();
2008-12-10 16:59:19 +00:00
//Sanitize
2016-12-20 10:58:43 +01:00
$multiaction = $tp -> filter ( $_POST [ 'multiaction' ], 'int' );
2008-12-10 16:59:19 +00:00
//sql queries significant reduced
2020-12-31 16:14:43 -08:00
if ( ! empty ( $multiaction ) && $sql -> select ( 'user' , 'user_id, user_name, user_image' , 'user_id IN (' . implode ( ',' , $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' );
2016-12-20 10:58:43 +01:00
foreach ( $multiaction as $uid )
2008-12-05 22:01:25 +00:00
{
2015-02-14 23:34:15 -08:00
if ( vartrue ( $search_users [ $uid ]))
2008-12-10 16:59:19 +00:00
{
$avname = avatar ( $search_users [ $uid ][ 'user_image' ]);
2020-12-31 16:14:43 -08:00
if ( strpos ( $avname , 'http://' ) === FALSE )
2008-12-10 16:59:19 +00:00
{ // 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 ))
{
2020-12-31 16:14:43 -08:00
$sql -> update ( 'user' , " user_image='' WHERE user_id IN ( " . implode ( ',' , $uids ) . ')' );
2008-12-10 16:59:19 +00:00
}
2013-02-25 20:14:59 +01:00
$mes -> addSuccess ( IMALAN_51 . '<strong>' . implode ( ', ' , $tmp ) . '</strong> ' . IMALAN_28 );
2020-12-31 16:14:43 -08:00
e107 :: getLog () -> add ( 'IMALAN_03' , implode ( '[!br!]' , $avList ));
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
/*
* 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 ;
2020-12-31 16:14:43 -08:00
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 >
2020-12-31 16:14:43 -08:00
< th class = 'center last' > " .LAN_URL. '</th>
2008-12-09 15:19:03 +00:00
</ tr >
</ thead >
< tbody >
2020-12-31 16:14:43 -08:00
' ;
2008-12-09 15:19:03 +00:00
2006-12-02 04:36:16 +00:00
//
// Loop through avatar field for every user
//
2020-12-31 16:14:43 -08:00
$iUserCount = $sql -> count ( 'user' );
2008-12-10 16:59:19 +00:00
$found = false ;
2020-12-31 16:14:43 -08:00
$allowedWidth = ( int ) $pref [ 'im_width' ];
$allowedHeight = ( int ) $pref [ 'im_width' ];
if ( $sql -> select ( 'user' , '*' , " user_image!='' " )) {
2008-12-10 16:59:19 +00:00
2020-12-14 16:21:48 -08:00
while ( $row = $sql -> fetch ())
2008-12-05 22:01:25 +00:00
{
2008-12-10 16:59:19 +00:00
//Check size
$avname = avatar ( $row [ 'user_image' ]);
2020-12-31 16:14:43 -08: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 );
2020-12-31 16:14:43 -08:00
$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 ))
{
2020-12-31 16:14:43 -08:00
$sBadImage .= ', ' ;
2006-12-02 04:36:16 +00:00
}
$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 ))
{
2016-01-31 18:50:39 -08:00
$uparams = array ( 'id' => $row [ 'user_id' ], 'name' => $row [ 'user_name' ]);
$ulink = e107 :: getUrl () -> create ( 'user/profile/view' , $uparams );
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 >
2020-12-31 16:14:43 -08:00
< label for = 'avdelete-{$row[' user_id ']}' title = '".IMALAN_56."' > " .IMALAN_51. " </ label >< a href = '".$ulink."' > " . $row['user_name'] . '</a>
2008-12-09 15:19:03 +00:00
</ td >
2020-12-31 16:14:43 -08:00
< td > ' .$sBadImage. ' </ td >
< td > ' .$avname. ' </ td >
</ tr > ' ;
2006-12-02 04:36:16 +00:00
}
2008-12-10 16:59:19 +00:00
}
}
//Nothing found
if ( ! $found )
{
$text .= "
2008-12-09 15:19:03 +00:00
< tr >
2020-12-31 16:14:43 -08:00
< td colspan = '4' class = 'center' > " .IMALAN_65. '</td>
2008-12-10 16:59:19 +00:00
</ tr >
2020-12-31 16:14:43 -08:00
' ;
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' />
2020-12-31 16:14:43 -08: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 >
2020-12-31 16:14:43 -08: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 >
2020-12-31 16:14:43 -08:00
' ;
2006-12-02 04:36:16 +00:00
2013-02-25 20:14:59 +01:00
$ns -> tablerender ( IMALAN_37 , $mes -> 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...
2020-12-31 16:14:43 -08:00
if ( ! e_AJAX_REQUEST )
{
require_once ( __DIR__ . '/footer.php' );
}
2009-07-16 08:15:35 +00:00