2006-12-02 04:36:16 +00:00
< ? php
/*
2012-01-11 14:54:47 +00:00
* e107 website system
*
2013-02-27 17:18:33 +01:00
* Copyright ( C ) 2008 - 2013 e107 Inc ( e107 . org )
2012-01-11 14:54:47 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
2012-01-11 14:58:35 +00:00
* Plugin administration area
2012-01-11 14:54:47 +00:00
*
*/
2021-01-16 13:32:35 -08:00
require_once ( __DIR__ . '/../class2.php' );
2017-01-17 01:33:03 +01:00
if ( ! getperms ( " Z " ))
2008-12-10 22:39:43 +00:00
{
2016-01-13 19:17:37 -08:00
e107 :: redirect ( 'admin' );
2006-12-02 04:36:16 +00:00
exit ;
}
2009-08-28 16:11:02 +00:00
2012-01-11 14:58:35 +00:00
e107 :: coreLan ( 'plugin' , true );
2009-08-28 16:11:02 +00:00
2006-12-02 04:36:16 +00:00
$e_sub_cat = 'plug_manage' ;
2009-07-07 02:22:57 +00:00
define ( 'PLUGIN_SHOW_REFRESH' , FALSE );
2015-03-30 13:02:51 -07:00
define ( 'PLUGIN_SCAN_INTERVAL' , ! empty ( $_SERVER [ 'E_DEV' ]) ? 0 : 360 );
2017-02-05 15:49:03 -08:00
define ( " ADMIN_GITSYNC_ICON " , e107 :: getParser () -> toGlyph ( 'fa-refresh' , array ( 'size' => '2x' , 'fw' => 1 )));
2016-06-02 19:20:58 -07:00
2009-07-07 02:22:57 +00:00
global $user_pref ;
2017-02-07 14:54:02 -08:00
/*
2017-02-05 15:49:03 -08:00
2017-02-05 19:53:45 -08:00
if ( ! deftrue ( 'e_DEBUG_PLUGMANAGER' ))
2017-02-05 15:49:03 -08:00
{
require_once ( e_HANDLER . 'plugin_class.php' );
require_once ( e_HANDLER . 'file_class.php' );
$plugin = new e107plugin ;
$pman = new pluginManager ;
2017-02-06 08:47:39 -08:00
define ( " e_PAGETITLE " , ADLAN_98 . " - " . $pman -> pagetitle );
2017-02-05 15:49:03 -08:00
}
2017-02-07 14:54:02 -08:00
*/
2017-02-05 15:49:03 -08:00
if ( isset ( $_POST [ 'uninstall_cancel' ]))
{
2020-12-22 14:48:28 -08:00
e107 :: redirect ( e_SELF );
2017-02-05 15:49:03 -08:00
exit ;
}
// Experimental rewrite for v2.1.5 ----------------------
class plugman_adminArea extends e_admin_dispatcher
{
protected $modes = array (
'installed' => array (
'controller' => 'plugin_ui' ,
'path' => null ,
'ui' => 'plugin_form_ui' ,
'uipath' => null
),
'avail' => array (
'controller' => 'plugin_ui' ,
'path' => null ,
'ui' => 'plugin_form_ui' ,
'uipath' => null
),
'online' => array (
'controller' => 'plugin_online_ui' ,
'path' => null ,
2017-12-25 16:20:44 -08:00
'ui' => 'plugin_form_online_ui' ,
2017-02-05 15:49:03 -08:00
'uipath' => null
),
'create' => array (
'controller' => 'plugin_ui' ,
'path' => null ,
'ui' => 'plugin_form_ui' ,
'uipath' => null
),
2017-09-18 13:43:31 -07:00
'lans' => array (
'controller' => 'pluginLanguage' ,
'path' => null ,
'ui' => 'plugin_form_ui' ,
'uipath' => null
),
2017-02-05 15:49:03 -08:00
);
protected $adminMenu = array (
'installed/list' => array ( 'caption' => EPL_ADLAN_22 , 'perm' => 'Z' ),
'avail/list' => array ( 'caption' => EPL_ADLAN_23 , 'perm' => 'Z' ),
2021-02-03 08:10:23 -08:00
'online/grid' => array ( 'caption' => EPL_ADLAN_220 , 'perm' => 'Z' , 'icon' => 'fas-search' ),
2017-02-05 15:49:03 -08:00
'avail/upload' => array ( 'caption' => EPL_ADLAN_38 , 'perm' => '0' ),
2021-02-03 08:10:23 -08:00
'create/build' => array ( 'caption' => EPL_ADLAN_114 , 'perm' => '0' , 'icon' => 'fas-toolbox' ),
2017-02-05 15:49:03 -08:00
// 'main/create' => array('caption'=> LAN_CREATE, 'perm' => 'P'),
// 'main/custom' => array('caption'=> 'Custom Page', 'perm' => 'P')
);
protected $defaultMode = 'installed' ;
protected $adminMenuAliases = array (
2017-09-18 13:43:31 -07:00
'installed/uninstall' => 'installed/list' ,
2021-01-23 14:21:55 -08:00
'lans/list' => 'create/build' ,
'online/list' => 'online/grid' ,
2017-02-05 15:49:03 -08:00
);
protected $adminMenuIcon = 'e-plugmanager-24' ;
function init ()
{
$mode = $this -> getRequest () -> getMode ();
$action = $this -> getRequest () -> getAction ();
if ( $mode === 'online' && $action === 'download' )
{
define ( 'e_IFRAME' , true );
}
2017-12-21 13:40:10 -08:00
if ( deftrue ( 'e_DEVELOPER' ))
{
e107 :: getPlug () -> clearCache ();
}
2017-02-05 15:49:03 -08:00
}
public static function getPluginManagerFields ()
{
return array (
'checkboxes' => array ( 'title' => '' , 'type' => null , 'data' => null , 'width' => '5%' , 'thclass' => 'center' , 'forced' => '1' , 'class' => 'center' , 'toggle' => 'e-multiselect' ,),
'plugin_id' => array ( 'title' => LAN_ID , 'data' => 'int' , 'width' => '5%' , 'help' => '' , 'readParms' => '' , 'writeParms' => '' , 'class' => 'left' , 'thclass' => 'left' ,),
'plugin_icon' => array ( 'title' => LAN_ICON , 'type' => 'icon' , 'data' => false , " width " => " 5% " , 'help' => '' , 'readParms' => '' , 'writeParms' => '' , 'class' => 'left' , 'thclass' => 'left' ,),
'plugin_name' => array ( 'title' => LAN_TITLE , 'type' => 'text' , 'data' => 'str' , 'width' => 'auto' , 'help' => '' , 'readParms' => '' , 'writeParms' => '' , 'class' => 'left' , 'thclass' => 'left' ,),
'plugin_version' => array ( 'title' => LAN_VERSION , 'type' => 'text' , 'data' => false , 'width' => 'auto' , 'help' => '' , 'readParms' => '' , 'writeParms' => '' , 'class' => 'left' , 'thclass' => 'left' ,),
2021-01-23 14:21:55 -08:00
'plugin_description' => array ( 'title' => LAN_DESCRIPTION , 'type' => 'textarea' , 'data' => false , 'width' => 'auto' , 'help' => '' , 'readParms' => 'expand=1&truncate=180&bb=1' , 'writeParms' => '' , 'class' => 'left' , 'thclass' => 'left' ,),
2017-02-09 10:31:19 +01:00
'plugin_date' => array ( 'title' => LAN_RELEASED , 'type' => 'text' , 'data' => false , " width " => " 8% " , 'help' => '' , 'readParms' => '' , 'writeParms' => '' , 'class' => 'left' , 'thclass' => 'left' ,),
2017-02-05 15:49:03 -08:00
'plugin_category' => array ( 'title' => LAN_CATEGORY , 'type' => 'dropdown' , 'data' => 'str' , 'width' => 'auto' , 'batch' => true , 'filter' => true , 'inline' => true , 'help' => '' , 'readParms' => '' , 'writeParms' => array (), 'class' => 'left' , 'thclass' => 'left' ,),
'plugin_author' => array ( 'title' => LAN_AUTHOR , 'type' => 'text' , 'data' => false , 'width' => 'auto' , 'help' => '' , 'readParms' => '' , 'writeParms' => '' , 'class' => 'left' , 'thclass' => 'left' ,),
" plugin_license " => array ( " title " => " License " , 'nolist' => false , 'data' => false , " type " => " text " , " width " => " 5% " , " thclass " => " left " ),
2017-02-09 10:31:19 +01:00
'plugin_compatible' => array ( 'title' => EPL_ADLAN_13 , 'type' => 'method' , 'data' => false , 'width' => 'auto' , 'help' => '' , 'readParms' => '' , 'writeParms' => '' , 'class' => 'center' , 'thclass' => 'center' ,),
2017-02-05 15:49:03 -08:00
2017-02-09 10:31:19 +01:00
'plugin_path' => array ( 'title' => LAN_PATH , 'type' => 'text' , 'data' => 'str' , 'width' => 'auto' , 'help' => '' , 'readParms' => '' , 'writeParms' => '' , 'class' => 'left' , 'thclass' => 'left' ,),
'plugin_installflag' => array ( 'title' => EPL_ADLAN_22 , 'type' => 'boolean' , 'data' => 'int' , 'width' => 'auto' , 'filter' => false , 'help' => '' , 'readParms' => '' , 'writeParms' => '' , 'class' => 'center' , 'thclass' => 'center' ,),
'plugin_addons' => array ( 'title' => LAN_ADDONS , 'type' => 'method' , 'data' => 'str' , 'width' => 'auto' , 'help' => '' , 'readParms' => '' , 'writeParms' => '' , 'class' => 'left' , 'thclass' => 'left' ,),
2017-02-05 15:49:03 -08:00
'options' => array ( 'title' => LAN_OPTIONS , 'type' => 'method' , 'data' => null , 'width' => '10%' , 'thclass' => 'center last' , 'class' => 'center last' , 'forced' => '1' ,),
);
}
protected $menuTitle = ADLAN_98 ;
}
class plugin_ui extends e_admin_ui
{
protected $pluginTitle = ADLAN_98 ;
protected $pluginName = 'core' ;
// protected $eventName = 'plugman-plugin'; // remove comment to enable event triggers in admin.
protected $table = 'plugin' ;
protected $pid = 'plugin_id' ;
protected $perPage = 10 ;
2017-12-18 09:56:10 +01:00
2017-02-05 15:49:03 -08:00
protected $batchDelete = false ;
protected $batchExport = false ;
protected $batchCopy = false ;
2020-12-19 10:52:52 -08:00
protected $batchOptions = array ();
2017-02-05 15:49:03 -08:00
// protected $sortField = 'somefield_order';
// protected $orderStep = 10;
// protected $tabs = array('Tabl 1','Tab 2'); // Use 'tab'=>0 OR 'tab'=>1 in the $fields below to enable.
protected $listQry = " SELECT * FROM `#plugin` WHERE plugin_installflag = 1 AND plugin_category != 'menu' " ; // Example Custom Query. LEFT JOINS allowed. Should be without any Order or Limit.
protected $listOrder = 'plugin_path ASC' ;
protected $fields = array ();
protected $fieldpref = array ( 'plugin_icon' , 'plugin_name' , 'plugin_version' , 'plugin_description' , 'plugin_compatible' , 'plugin_released' , 'plugin_author' , 'plugin_category' , 'plugin_installflag' );
// protected $preftabs = array('General', 'Other' );
protected $prefs = array (
);
// Ideal way to set field data.
public function __construct ( $request , $response , $params = array ())
{
$this -> fields = plugman_adminArea :: getPluginManagerFields ();
$this -> fields [ 'plugin_category' ][ 'writeParms' ][ 'optArray' ] = e107 :: getPlug () -> getCategoryList (); // array('plugin_category_0','plugin_category_1', 'plugin_category_2'); // Example Drop-down array.
2017-02-06 07:35:43 -08:00
unset ( $this -> fields [ 'plugin_category' ][ 'writeParms' ][ 'optArray' ][ 'menu' ]);
unset ( $this -> fields [ 'plugin_category' ][ 'writeParms' ][ 'optArray' ][ 'about' ]);
2020-12-19 10:52:52 -08:00
2017-02-05 15:49:03 -08:00
parent :: __construct ( $request , $response , $params );
2020-12-19 10:52:52 -08:00
if ( $this -> getMode () === 'installed' ) // TODO more batch options install, uninstall etc.
{
$this -> batchOptions = array ( 'repairall' => 'Repair selected' ); // TODO LAN "[x] selected"
}
2017-02-05 15:49:03 -08:00
}
2020-12-19 10:52:52 -08:00
public function handleListRepairallBatch ( $arr )
{
if ( empty ( $arr ))
{
return null ;
}
$arr = e107 :: getParser () -> filter ( $arr , 'int' );
$data = e107 :: getDb () -> retrieve ( 'plugin' , 'plugin_path' , 'plugin_id IN (' . implode ( ',' , $arr ) . ')' , true );
if ( empty ( $data ))
{
return null ;
}
foreach ( $data as $row )
{
$this -> repair ( $row [ 'plugin_path' ]);
}
}
2017-02-05 15:49:03 -08:00
public function init ()
{
2017-02-08 17:37:24 -08:00
if ( ! e_QUERY )
{
e107 :: getPlug () -> clearCache ();
}
2017-02-05 15:49:03 -08:00
if ( $this -> getMode () === 'avail' )
{
$this -> listQry = " SELECT * FROM `#plugin` WHERE plugin_installflag = 0 AND plugin_category != 'menu' " ;
}
// Set drop-down values (if any).
}
// Modify the list data.
public function ListObserver ()
{
parent :: ListObserver ();
$this -> setPlugData ();
}
private function setPlugData ()
{
$tree = $this -> getTreeModel ();
$plg = e107 :: getPlug ();
2019-02-03 11:09:07 -08:00
/**
* @ var $id
* @ var e_model $model
*/
foreach ( $tree -> getTree () as $id => $model )
2017-02-05 15:49:03 -08:00
{
$path = $model -> get ( 'plugin_path' );
$plg -> load ( $path );
$model -> set ( 'plugin_name' , $plg -> getName ());
$model -> set ( 'plugin_date' , $plg -> getDate ());
$model -> set ( 'plugin_author' , $plg -> getAuthor ());
$model -> set ( 'plugin_compatible' , $plg -> getCompat ());
$model -> set ( 'plugin_admin_url' , $plg -> getAdminUrl ());
2017-02-06 08:47:39 -08:00
$model -> set ( 'plugin_admin_caption' , $plg -> getAdminCaption ());
2017-02-05 15:49:03 -08:00
$model -> set ( 'plugin_description' , $plg -> getDescription ());
$model -> set ( 'plugin_version_file' , $plg -> getVersion ());
$model -> set ( 'plugin_install_required' , $plg -> getInstallRequired ());
$model -> set ( 'plugin_icon' , $plg -> getIcon ( 32 , 'path' ));
}
}
public function ListAjaxObserver ()
{
2019-06-03 16:29:38 -07:00
$this -> getTreeModel () -> setParam ( 'db_query' , $this -> _modifyListQry ( false , false , 0 , false , $this -> listQry )) -> loadBatch ();
2017-02-05 15:49:03 -08:00
$this -> setPlugData ();
}
private function pluginProcessUpload ()
{
if ( ! $_POST [ 'ac' ] == md5 ( ADMINPWCHANGE ))
{
exit ;
}
$fl = e107 :: getFile ();
$data = $fl -> getUploaded ( e_TEMP );
$mes = e107 :: getMessage ();
if ( empty ( $data [ 0 ][ 'error' ]))
{
if ( $fl -> unzipArchive ( $data [ 0 ][ 'name' ], 'plugin' ))
{
$mes -> addSuccess ( EPL_ADLAN_43 );
}
else
{
$mes -> addError ( EPL_ADLAN_97 );
}
}
//echo $mes->render();
return true ;
}
2017-02-06 08:47:39 -08:00
function renderHelp ()
{
$plg = e107 :: getPlug ();
2020-12-31 10:24:13 -08:00
$plg -> clearCache ();
2017-02-06 08:47:39 -08:00
if ( ! $list = $plg -> getUpgradableList ())
{
return null ;
}
2017-02-07 14:54:02 -08:00
$text = " <ul class='media-list'> " ;
2017-02-06 08:47:39 -08:00
foreach ( $list as $path => $ver )
{
$plg -> load ( $path );
2020-12-31 10:24:13 -08:00
$name = $plg -> getName ();
$url = e_ADMIN . " plugin.php?mode=installed&action=upgrade&path= " . $path ;
2017-02-07 14:54:02 -08:00
$text .= " <li class='media'>
< div class = 'media-left' >
< a href = '".$url."' > " . $plg->getIcon (32). " </ a >
2020-12-31 10:24:13 -08:00
</ div >< div class = 'media-body' >< a class = 'e-spinner' href = '".$url."' title = \ " " . EPL_UPGRADE . " " . $name . " v " . $ver . " \" > " . $name . " </a></div></li> " ;
2017-02-06 08:47:39 -08:00
}
$text .= " </ul> " ;
2017-04-28 10:17:56 +02:00
return array ( 'caption' => EPL_ADLAN_247 , 'text' => $text );
2017-02-06 08:47:39 -08:00
}
2017-02-05 15:49:03 -08:00
// Action Pages.
function installPage ()
{
2019-02-07 15:58:51 -08:00
$id = $this -> getQuery ( 'path' );
2017-02-05 15:49:03 -08:00
$text = e107 :: getPlugin () -> install ( $id );
2020-11-02 10:36:07 -08:00
// $log = e107::getAdminLog();
2017-02-05 15:49:03 -08:00
if ( $text === FALSE )
{
e107 :: getMessage () -> add ( EPL_ADLAN_99 , E_MESSAGE_ERROR );
}
else
{
//$plugin->save_addon_prefs('update');
// $info = $plugin->getinfo($this->id); //FIXME use e107::getPlug();
// $name = deftrue($info['plugin_name'],$info['plugin_name']). " v".$info['plugin_version']. "({e_PLUGIN}".$info['plugin_path'].")";
2020-12-18 09:39:02 -08:00
// $log->add('PLUGMAN_01', $name, E_LOG_INFORMATIVE, '');
2017-02-05 15:49:03 -08:00
2018-07-15 15:35:31 +02:00
// make sure ALL plugin/addon pref lists get update and are current
e107 :: getPlug () -> clearCache () -> buildAddonPrefLists ();
2017-02-05 15:49:03 -08:00
e107 :: getMessage () -> add ( $text , E_MESSAGE_SUCCESS );
}
$this -> redirectAction ( 'list' );
}
function buildPage ()
{
$pc = new pluginBuilder ;
2017-02-07 14:54:02 -08:00
$ret = $pc -> run ();
if ( is_array ( $ret ))
{
$this -> addTitle ( $ret [ 'caption' ]);
return $ret [ 'text' ];
}
return $ret ;
2017-02-05 15:49:03 -08:00
}
2017-09-18 13:43:31 -07:00
function lanPage ()
{
2017-02-05 15:49:03 -08:00
2017-09-18 13:43:31 -07:00
}
2017-02-05 15:49:03 -08:00
function uninstallPage ()
{
2019-02-07 15:58:51 -08:00
$id = $this -> getQuery ( 'path' );
2017-02-05 15:49:03 -08:00
if ( empty ( $_POST [ 'uninstall_confirm' ]))
{
$plug_vars = e107 :: getPlug () -> load ( $id ) -> getMeta ();
2019-02-07 15:58:51 -08:00
2017-02-05 15:49:03 -08:00
$name = e107 :: getPlug () -> getName ();
$this -> addTitle ( EPL_ADLAN_63 );
$this -> addTitle ( $name );
return $this -> pluginConfirmUninstall ( $plug_vars );
}
$post = e107 :: getParser () -> filter ( $_POST );
2017-03-02 12:51:03 -08:00
if ( empty ( $_POST [ 'e-token' ]))
{
return false ;
}
2017-02-05 15:49:03 -08:00
// $id = e107::getPlugin
$text = e107 :: getPlugin () -> uninstall ( $id , $post );
2019-02-07 15:58:51 -08:00
2018-07-15 15:35:31 +02:00
// make sure ALL plugin/addon pref lists get update and are current
e107 :: getPlug () -> clearCache () -> buildAddonPrefLists ();
2017-02-05 15:49:03 -08:00
e107 :: getMessage () -> add ( $text , E_MESSAGE_SUCCESS );
$log = e107 :: getPlugin () -> getLog ();
e107 :: getDebug () -> log ( $log );
$this -> redirectAction ( 'list' );
}
function repairPage ()
{
2019-02-07 15:58:51 -08:00
$id = $this -> getQuery ( 'path' );
2017-02-05 15:49:03 -08:00
2020-12-19 10:52:52 -08:00
$this -> repair ( $id );
$this -> redirectAction ( 'list' );
}
private function repair ( $id )
{
2017-04-03 15:55:37 -07:00
if ( ! is_dir ( e_PLUGIN . $id ))
2017-02-05 15:49:03 -08:00
{
2020-12-19 10:52:52 -08:00
e107 :: getMessage () -> addError ( " Plugin { $id } doesn't exist " );
2017-02-05 15:49:03 -08:00
return false ;
}
e107 :: getSingleton ( 'e107plugin' ) -> refresh ( $id );
e107 :: getLog () -> add ( 'PLUGMAN_04' , $id , E_LOG_INFORMATIVE , '' );
2017-04-03 15:55:37 -07:00
e107 :: getMessage () -> addSuccess ( " Repair Complete ( " . $id . " ) " ); // Repair Complete ([x])
2017-02-05 15:49:03 -08:00
}
function pullPage ()
{
2019-02-07 15:58:51 -08:00
$id = $this -> getQuery ( 'path' );
2017-02-05 15:49:03 -08:00
if ( ! e107 :: isInstalled ( $id ))
{
$this -> redirectAction ( 'list' );
}
$return = e107 :: getFile () -> gitPull ( $id , 'plugin' );
e107 :: getMessage () -> addSuccess ( $return );
e107 :: getPlugin () -> refresh ( $id );
$this -> redirectAction ( 'list' );
}
function upgradePage ()
{
2017-02-07 14:54:02 -08:00
$this -> pluginUpgrade ();
2020-12-31 10:24:13 -08:00
2017-02-05 15:49:03 -08:00
}
function uploadPage ()
{
global $plugin ;
$frm = e107 :: getForm ();
if ( ! empty ( $_POST [ 'upload' ]))
{
$this -> pluginProcessUpload ();
$this -> redirectAction ( 'list' );
}
//TODO 'install' checkbox in plugin upload form. (as it is for theme upload)
/* plugin upload form */
if ( ! is_writable ( e_PLUGIN ))
{
$text = EPL_ADLAN_44 ;
}
else
{
// Get largest allowable file upload
require_once ( e_HANDLER . 'upload_handler.php' );
$max_file_size = get_user_max_upload ();
$text = "
2020-11-02 10:36:07 -08:00
< form enctype = 'multipart/form-data' method = 'post' action = '".e_SELF."?mode=avail&action=upload' >
2017-02-05 15:49:03 -08:00
< table class = 'table adminform' >
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tr >
< td > " .EPL_ADLAN_37. " </ td >
< td >
< input type = 'hidden' name = 'MAX_FILE_SIZE' value = '{$max_file_size}' />
< input type = 'hidden' name = 'ac' value = '".md5(ADMINPWCHANGE)."' />
< input class = 'tbox' type = 'file' name = 'file_userfile[]' size = '50' />
</ td >
</ tr >
</ table >
< div class = 'center buttons-bar' > " ;
$text .= $frm -> admin_button ( 'upload' , EPL_ADLAN_38 , 'submit' , EPL_ADLAN_38 );
$text .= "
</ div >
</ form > \n " ;
}
return $text ;
2020-11-02 10:36:07 -08:00
// e107::getRender()->tablerender(ADLAN_98.SEP.EPL_ADLAN_38, $text);
2017-02-05 15:49:03 -08:00
}
private function pluginUpgrade ()
{
$pref = e107 :: getPref ();
2020-12-22 09:36:02 -08:00
$admin_log = e107 :: getLog ();
2017-02-05 15:49:03 -08:00
$plugin = e107 :: getPlugin ();
$sql = e107 :: getDb ();
$mes = e107 :: getMessage ();
2019-02-07 15:58:51 -08:00
$id = $this -> getQuery ( 'path' );
2017-02-05 15:49:03 -08:00
$plug = e107 :: getPlug () -> load ( $id ) -> getMeta ();
$text = '' ;
$_path = e_PLUGIN . $id . '/' ;
if ( file_exists ( $_path . 'plugin.xml' ))
{
2020-12-31 10:24:13 -08:00
2017-02-05 15:49:03 -08:00
$plugin -> install_plugin_xml ( $id , 'upgrade' );
2019-04-11 12:28:14 -07:00
$text = LAN_UPGRADE_SUCCESSFUL ;
2017-02-05 15:49:03 -08:00
}
else
{
2020-12-31 10:24:13 -08:00
e107 :: getMessage () -> addDebug ( " Running Legacy plugin upgrade. <b> " . $_path . " </b> not found. " ); // NO LAN
2017-02-05 15:49:03 -08:00
$eplug_folder = null ;
$upgrade_alter_tables = null ;
$upgrade_add_prefs = null ;
$upgrade_remove_prefs = null ;
$upgrade_add_array_pref = null ;
$upgrade_remove_array_pref = null ;
$eplug_version = null ;
include ( e_PLUGIN . $plug [ 'plugin_path' ] . '/plugin.php' );
$text = '' ;
$func = $eplug_folder . '_upgrade' ;
if ( function_exists ( $func ))
{
$text .= call_user_func ( $func );
}
if ( is_array ( $upgrade_alter_tables ))
{
$result = $plugin -> manage_tables ( 'upgrade' , $upgrade_alter_tables );
if ( true !== $result )
{
//$text .= EPL_ADLAN_9.'<br />';
$mes -> addWarning ( EPL_ADLAN_9 )
-> addDebug ( $result );
}
else
{
$text .= EPL_ADLAN_7 . " <br /> " ;
}
}
if ( is_array ( $upgrade_add_prefs ))
{
$plugin -> manage_prefs ( 'add' , $upgrade_add_prefs );
$text .= EPL_ADLAN_8 . '<br />' ;
}
if ( is_array ( $upgrade_remove_prefs ))
{
$plugin -> manage_prefs ( 'remove' , $upgrade_remove_prefs );
}
if ( is_array ( $upgrade_add_array_pref ))
{
foreach ( $upgrade_add_array_pref as $key => $val )
{
$plugin -> manage_plugin_prefs ( 'add' , $key , $eplug_folder , $val );
}
}
if ( is_array ( $upgrade_remove_array_pref ))
{
foreach ( $upgrade_remove_array_pref as $key => $val )
{
$plugin -> manage_plugin_prefs ( 'remove' , $key , $eplug_folder , $val );
}
}
$plugin -> manage_search ( 'upgrade' , $eplug_folder );
$plugin -> manage_notify ( 'upgrade' , $eplug_folder );
$eplug_addons = $plugin -> getAddons ( $eplug_folder );
2018-07-22 09:36:23 -07:00
$info = e107plugin :: getPluginRecord ( $this -> id );
2017-02-05 15:49:03 -08:00
$name = deftrue ( $info [ 'plugin_name' ], $info [ 'plugin_name' ]) . " v " . $eplug_version . " ( { e_PLUGIN} " . $info [ 'plugin_path' ] . " ) " ;
2021-03-02 08:33:27 -08:00
e107 :: getLog () -> add ( 'PLUGMAN_02' , $name );
2017-02-05 15:49:03 -08:00
$text .= ( isset ( $eplug_upgrade_done )) ? '<br />' . $eplug_upgrade_done : " <br /> " . LAN_UPGRADE_SUCCESSFUL ;
$sql -> update ( 'plugin' , " plugin_version =' { $eplug_version } ', plugin_addons=' { $eplug_addons } ' WHERE plugin_id=' $this->id ' " );
$pref [ 'plug_installed' ][ $plug [ 'plugin_path' ]] = $eplug_version ; // Update the version
2021-03-02 08:33:27 -08:00
e107 :: getConfig () -> setPref ( $pref );
2017-02-05 15:49:03 -08:00
$plugin -> rebuildUrlConfig ();
2021-03-02 08:33:27 -08:00
e107 :: getConfig () -> save ();
2017-02-05 15:49:03 -08:00
}
$mes -> addSuccess ( $text );
2018-07-15 15:35:31 +02:00
//$plugin->save_addon_prefs('update');
// make sure ALL plugin/addon pref lists get update and are current
e107 :: getPlug () -> clearCache () -> buildAddonPrefLists ();
2017-02-05 15:49:03 -08:00
2019-04-11 12:28:14 -07:00
// clear infopanel in admin dashboard.
e107 :: getCache () -> clear ( 'Infopanel_plugin' , true );
e107 :: getSession () -> clear ( 'addons-update-status' );
e107 :: getSession () -> set ( 'addons-update-checked' , false ); // set to recheck it.
2017-02-05 15:49:03 -08:00
$this -> redirectAction ( 'list' );
}
private function pluginConfirmUninstall ( $plug_vars )
{
global $plugin ;
$frm = e107 :: getForm ();
$tp = e107 :: getParser ();
$mes = e107 :: getMessage ();
$path = $plug_vars [ 'folder' ];
// $plug = $plugin->getinfo($this->id);
if ( ! e107 :: isInstalled ( $path ))
{
return false ;
}
$userclasses = '' ;
$eufields = '' ;
if ( isset ( $plug_vars [ 'userClasses' ]))
{
if ( isset ( $plug_vars [ 'userclass' ][ '@attributes' ]))
{
$plug_vars [ 'userclass' ][ 0 ][ '@attributes' ] = $plug_vars [ 'userclass' ][ '@attributes' ];
unset ( $plug_vars [ 'userclass' ][ '@attributes' ]);
}
$spacer = '' ;
foreach ( $plug_vars [ 'userClasses' ][ 'class' ] as $uc )
{
$userclasses .= $spacer . $uc [ '@attributes' ][ 'name' ] . ' - ' . $uc [ '@attributes' ][ 'description' ];
$spacer = '<br />' ;
}
}
if ( isset ( $plug_vars [ 'extendedFields' ]))
{
if ( isset ( $plug_vars [ 'extendedFields' ][ '@attributes' ]))
{
$plug_vars [ 'extendedField' ][ 0 ][ '@attributes' ] = $plug_vars [ 'extendedField' ][ '@attributes' ];
unset ( $plug_vars [ 'extendedField' ][ '@attributes' ]);
}
$spacer = '' ;
foreach ( $plug_vars [ 'extendedFields' ][ 'field' ] as $eu )
{
$eufields .= $spacer . 'plugin_' . $plug_vars [ 'folder' ] . '_' . $eu [ '@attributes' ][ 'name' ];
$spacer = '<br />' ;
}
}
if ( is_writable ( e_PLUGIN . $path ))
{
$del_text = $frm -> select ( 'delete_files' , 'yesno' , 0 );
}
else
{
$del_text = "
" .EPL_ADLAN_53. "
< input type = 'hidden' name = 'delete_files' value = '0' />
" ;
}
$text = "
< form action = '".e_SELF."?".e_QUERY."' method = 'post' >
< fieldset id = 'core-plugin-confirmUninstall' >
2019-02-26 12:22:36 -08:00
< legend > " .EPL_ADLAN_54. " " . $tp->toHTML ( $plug_vars['@attributes'] ['name'], " " , " defs , emotes_off , no_make_clickable " ). " </ legend >
2017-02-05 15:49:03 -08:00
< table class = 'table adminform' >
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tr >
< td > " .EPL_ADLAN_55. " </ td >
< td > " .LAN_YES. " </ td >
</ tr > " ;
$opts = array ();
$opts [ 'delete_tables' ] = array (
'label' => EPL_ADLAN_57 ,
'helpText' => EPL_ADLAN_58 ,
'itemList' => array ( 1 => LAN_YES , 0 => LAN_NO ),
'itemDefault' => 1
);
if ( $userclasses )
{
$opts [ 'delete_userclasses' ] = array (
'label' => EPL_ADLAN_78 ,
'preview' => $userclasses ,
'helpText' => EPL_ADLAN_79 ,
'itemList' => array ( 1 => LAN_YES , 0 => LAN_NO ),
'itemDefault' => 1
);
}
if ( $eufields )
{
$opts [ 'delete_xfields' ] = array (
'label' => EPL_ADLAN_80 ,
'preview' => $eufields ,
'helpText' => EPL_ADLAN_79 ,
'itemList' => array ( 1 => LAN_YES , 0 => LAN_NO ),
'itemDefault' => 0
);
}
$med = e107 :: getMedia ();
2021-03-02 08:33:27 -08:00
$icons = ( array ) $med -> listIcons ( e_PLUGIN . $path );
2017-02-05 15:49:03 -08:00
$iconText = '' ;
2021-03-02 08:33:27 -08:00
if ( count ( $icons ) > 0 )
2017-02-05 15:49:03 -08:00
{
foreach ( $icons as $key => $val )
{
$iconText .= " <img src=' " . $tp -> replaceConstants ( $val ) . " ' alt='' /> " ;
}
$iconText = '<div class="icon-pool-preview">' . $iconText . '</div>' ;
$opts [ 'delete_ipool' ] = array (
'label' => EPL_ADLAN_231 ,
'preview' => $iconText ,
'helpText' => EPL_ADLAN_79 ,
'itemList' => array ( 1 => LAN_YES , 0 => LAN_NO ),
'itemDefault' => 1
);
}
if ( is_readable ( e_PLUGIN . $path . " / " . $path . " _setup.php " ))
{
include_once ( e_PLUGIN . $path . " / " . $path . " _setup.php " );
$mes -> add ( " Loading " . e_PLUGIN . $path . " / " . $path . " _setup.php " , E_MESSAGE_DEBUG );
$class_name = $path . " _setup " ;
if ( class_exists ( $class_name ))
{
$obj = new $class_name ;
if ( method_exists ( $obj , 'uninstall_options' ))
{
$arr = call_user_func ( array ( $obj , 'uninstall_options' ), $this );
foreach ( $arr as $key => $val )
{
$newkey = $path . " _ " . $key ;
$opts [ $newkey ] = $val ;
}
}
}
}
foreach ( $opts as $key => $val )
{
$text .= " <tr> \n <td class='top'> " . $tp -> toHTML ( $val [ 'label' ], FALSE , 'TITLE' );
$text .= varset ( $val [ 'preview' ]) ? " <div class='indent'> " . $val [ 'preview' ] . " </div> " : " " ;
2021-02-12 12:19:58 -08:00
$text .= varset ( $val [ 'helpText' ]) ? " " . $frm -> help ( $val [ 'helpText' ]) . " " : " " ;
2017-02-05 15:49:03 -08:00
$text .= " </td> \n <td> " . $frm -> select ( $key , $val [ 'itemList' ], $val [ 'itemDefault' ]);
2021-02-12 12:19:58 -08:00
2017-02-05 15:49:03 -08:00
$text .= " </td> \n </tr> \n " ;
}
$text .= " <tr>
< td > " .EPL_ADLAN_59. " </ td >
< td > { $del_text }
< div class = 'field-help' > " .EPL_ADLAN_60. " </ div >
</ td >
</ tr >
</ table >
< div class = 'buttons-bar center' > " ;
$text .= $frm -> admin_button ( 'uninstall_confirm' , EPL_ADLAN_3 , 'submit' );
$text .= $frm -> admin_button ( 'uninstall_cancel' , EPL_ADLAN_62 , 'cancel' );
/*
$text .= " <input class='btn' type='submit' name='uninstall_confirm' value= \" " . EPL_ADLAN_3 . " \" />
< input class = 'btn' type = 'submit' name = 'uninstall_cancel' value = '".EPL_ADLAN_62."' onclick = \ " location.href=' " . e_SELF . " '; return false; \" /> " ;
*/
// $frm->admin_button($name, $value, $action = 'submit', $label = '', $options = array());
2017-03-02 12:51:03 -08:00
$text .= " <input type='hidden' name='e-token' value=' " . e_TOKEN . " ' /></div>
2017-02-05 15:49:03 -08:00
</ fieldset >
</ form >
" ;
return $text ;
2019-02-26 12:22:36 -08:00
// e107::getRender()->tablerender(EPL_ADLAN_63.SEP.$tp->toHTML($plug_vars['@attributes']['name'], "", "defs,emotes_off, no_make_clickable"),$mes->render(). $text);
2017-02-05 15:49:03 -08:00
}
/*
// optional - a custom page.
public function customPage ()
{
$text = 'Hello World!' ;
$otherField = $this -> getController () -> getFieldVar ( 'other_field_name' );
return $text ;
}
*/
}
class plugin_form_ui extends e_admin_form_ui
{
// Custom Method/Function
function plugin_compatible ( $curVal , $mode )
{
$frm = e107 :: getForm ();
switch ( $mode )
{
case 'read' : // List Page
if ( intval ( $curVal ) > 1 )
{
return " <span class='label label-warning'> " . $curVal . " </span> " ;
}
return $curVal ;
break ;
case 'write' : // Edit Page
return $frm -> text ( 'plugin_name' , $curVal , 255 , 'size=large' );
break ;
case 'filter' :
case 'batch' :
return array ();
break ;
}
}
// Custom Method/Function
function plugin_addons ( $curVal , $mode )
{
$frm = e107 :: getForm ();
switch ( $mode )
{
case 'read' : // List Page
return $curVal ;
break ;
case 'write' : // Edit Page
return $frm -> text ( 'plugin_addons' , $curVal , 255 , 'size=large' );
break ;
case 'filter' :
case 'batch' :
return array ();
break ;
}
}
function options ( $val , $curVal )
{
$tp = e107 :: getParser ();
$var = $this -> getController () -> getListModel () -> getData ();
$mode = $this -> getController () -> getMode ();
// e107::getDebug()->log($var);
$_path = e_PLUGIN . $var [ 'plugin_path' ] . '/' ;
if ( $var [ 'plugin_admin_url' ] && $var [ 'plugin_installflag' ] == true )
{
2017-02-06 08:47:39 -08:00
$conf_title = ! empty ( $var [ 'plugin_admin_caption' ]) ? $var [ 'plugin_admin_caption' ] : LAN_CONFIGURE . ' ' . $tp -> toHTML ( $var [ 'plugin_name' ], " " , " defs,emotes_off, no_make_clickable " );
2017-02-05 15:49:03 -08:00
$plugin_config_icon = " <a class='btn btn-default' title=' { $conf_title } ' href=' " . $var [ 'plugin_admin_url' ] . " ' > " . ADMIN_CONFIGURE_ICON . " </a> " ;
}
$text = " <div class='btn-group'> " ;
$text .= vartrue ( $plugin_config_icon );
if ( $var [ 'plugin_install_required' ] == true )
{
if ( $var [ 'plugin_installflag' ])
{
2019-02-07 15:58:51 -08:00
$text .= ( $var [ 'plugin_installflag' ] ? " <a class='btn btn-default' href= \" " . e_SELF . " ?mode= " . $mode . " &action=uninstall&path= { $var [ 'plugin_path' ] } \" title=' " . EPL_ADLAN_1 . " ' > " . ADMIN_UNINSTALLPLUGIN_ICON . " </a> " : " <a class='btn' href= \" " . e_SELF . " ?install. { $var [ 'plugin_id' ] } \" title=' " . EPL_ADLAN_0 . " ' > " . ADMIN_INSTALLPLUGIN_ICON . " </a> " );
2017-02-05 15:49:03 -08:00
}
else
{
2019-02-07 15:58:51 -08:00
$text .= " <a class='btn btn-default' href= \" " . e_SELF . " ?mode=installed&action=install&path= { $var [ 'plugin_path' ] } \" title=' " . EPL_ADLAN_0 . " ' > " . ADMIN_INSTALLPLUGIN_ICON . " </a> " ;
2017-02-05 15:49:03 -08:00
}
}
2020-12-18 19:55:12 -08:00
// else
// {
/* if ( $var [ 'menuName' ])
2017-02-05 15:49:03 -08:00
{
// $text .= EPL_NOINSTALL . str_replace("..", "", e_PLUGIN . $var['plugin_path']) . "/ " . EPL_DIRECTORY;
}
else
{
// $text .= EPL_NOINSTALL_1 . str_replace("..", "", e_PLUGIN . $var['plugin_path']) . "/ " . EPL_DIRECTORY;
if ( $var [ 'plugin_installflag' ] == false )
{
// e107::getDb()->delete('plugin', "plugin_installflag=0 AND (plugin_path='{$var['plugin_path']}' OR plugin_path='{$var['plugin_path']}/' ) ");
}
2020-12-18 19:55:12 -08:00
} */
// }
2017-02-05 15:49:03 -08:00
if ( $var [ 'plugin_version' ] != $var [ 'plugin_version_file' ] && $var [ 'plugin_installflag' ])
{
2019-02-07 15:58:51 -08:00
$text .= " <a class='btn btn-default' href=' " . e_SELF . " ?mode= " . $mode . " &action=upgrade&path= { $var [ 'plugin_path' ] } ' title= \" " . EPL_UPGRADE . " v " . $var [ 'plugin_version_file' ] . " \" > " . ADMIN_UPGRADEPLUGIN_ICON . " </a> " ;
2017-02-05 15:49:03 -08:00
}
2020-12-19 10:52:52 -08:00
if ( $var [ 'plugin_installflag' ])
2017-02-05 15:49:03 -08:00
{
2019-02-07 15:58:51 -08:00
$text .= " <a class='btn btn-default' href=' " . e_SELF . " ?mode= " . $mode . " &action=repair&path= { $var [ 'plugin_path' ] } ' title=' " . LAN_REPAIR_PLUGIN_SETTINGS . " '> " . ADMIN_REPAIRPLUGIN_ICON . " </a> " ;
2017-02-05 15:49:03 -08:00
}
if ( $var [ 'plugin_installflag' ] && is_dir ( $_path . " .git " ))
{
2019-02-07 15:58:51 -08:00
$text .= " <a class='plugin-manager btn btn-default' href=' " . e_SELF . " ?mode= " . $mode . " &action=pull&path= { $var [ 'plugin_path' ] } ' title=' " . LAN_SYNC_WITH_GIT_REPO . " '> " . ADMIN_GITSYNC_ICON . " </a> " ;
2017-02-05 15:49:03 -08:00
}
$text .= " </div> " ;
return $text ;
}
}
class plugin_online_ui extends e_admin_ui
{
protected $pluginTitle = ADLAN_98 ;
protected $pluginName = 'core' ;
// protected $eventName = 'plugman-plugin'; // remove comment to enable event triggers in admin.
protected $table = false ;
2021-01-23 14:21:55 -08:00
protected $pid = 'plugin_id' ;
2017-02-05 15:49:03 -08:00
protected $perPage = 10 ;
protected $batchDelete = true ;
protected $batchExport = true ;
protected $batchCopy = true ;
2021-01-23 14:21:55 -08:00
protected $grid = array ();
2017-02-05 15:49:03 -08:00
// protected $sortField = 'somefield_order';
// protected $orderStep = 10;
// protected $tabs = array('Tabl 1','Tab 2'); // Use 'tab'=>0 OR 'tab'=>1 in the $fields below to enable.
// protected $listQry = "SELECT * FROM `#tableName` WHERE field != '' "; // Example Custom Query. LEFT JOINS allowed. Should be without any Order or Limit.
protected $listOrder = '' ;
protected $fields = array ();
2021-01-23 14:21:55 -08:00
protected $fieldpref = array ( 'plugin_icon' , 'plugin_name' , 'plugin_version' , 'plugin_description' , 'plugin_license' , 'plugin_compatible' , 'plugin_date' , 'plugin_author' , 'plugin_category' , 'plugin_installflag' );
2017-02-05 15:49:03 -08:00
// protected $preftabs = array('General', 'Other' );
protected $prefs = array (
);
2021-01-23 14:21:55 -08:00
/** @var e_marketplace */
2017-02-05 15:49:03 -08:00
protected $mp = null ;
public function __construct ( $request , $response , $params = array ())
{
$this -> fields = plugman_adminArea :: getPluginManagerFields ();
2021-01-23 14:21:55 -08:00
unset ( $this -> fields [ 'checkboxes' ]);
2017-02-05 15:49:03 -08:00
$this -> fields [ 'plugin_category' ][ 'writeParms' ][ 'optArray' ] = e107 :: getPlug () -> getCategoryList (); // array('plugin_category_0','plugin_category_1', 'plugin_category_2'); // Example Drop-down array.
$this -> fields [ " plugin_license " ][ 'nolist' ] = false ;
2017-04-03 15:24:09 -07:00
$this -> fields [ 'plugin_category' ][ 'inline' ] = false ;
2021-01-23 14:21:55 -08:00
2017-02-05 15:49:03 -08:00
parent :: __construct ( $request , $response , $params );
}
public function init ()
{
require_once ( e_HANDLER . 'e_marketplace.php' );
}
function pluginCheck ( $force = false )
{
if ( ! PLUGIN_SCAN_INTERVAL )
{
2017-02-12 10:07:13 -08:00
e107 :: getPlugin () -> update_plugins_table ( 'update' );
2017-02-05 15:49:03 -08:00
return ;
}
if (( time () > vartrue ( $_SESSION [ 'nextPluginFolderScan' ], 0 )) || $force == true )
{
2017-02-12 10:07:13 -08:00
e107 :: getPlugin () -> update_plugins_table ( 'update' );
2017-02-05 15:49:03 -08:00
}
$_SESSION [ 'nextPluginFolderScan' ] = time () + PLUGIN_SCAN_INTERVAL ;
//echo "TIME = ".$_SESSION['nextPluginFolderScan'];
}
// Modal Download.
public function downloadPage ()
{
$frm = e107 :: getForm ();
$mes = e107 :: getMessage ();
$tp = e107 :: getParser ();
// print_a($_GET);
$string = base64_decode ( $_GET [ 'src' ]);
parse_str ( $string , $data );
if ( deftrue ( 'e_DEBUG_MARKETPLACE' ))
{
echo " <b>DEBUG MODE ACTIVE (no downloading)</b><br /> " ;
echo '$_GET[src]: ' ;
print_a ( $_GET );
echo 'base64 decoded and parsed as $data:' ;
print_a ( $data );
return false ;
}
2012-07-29 02:36:18 +00:00
2017-02-05 15:49:03 -08:00
$pluginFolder = ! empty ( $data [ 'plugin_folder' ]) ? $tp -> filter ( $data [ 'plugin_folder' ]) : '' ;
$pluginUrl = ! empty ( $data [ 'plugin_url' ]) ? $tp -> filter ( $data [ 'plugin_url' ]) : '' ;
$pluginID = ! empty ( $data [ 'plugin_id' ]) ? $tp -> filter ( $data [ 'plugin_id' ]) : '' ;
$pluginMode = ! empty ( $data [ 'plugin_mode' ]) ? $tp -> filter ( $data [ 'plugin_mode' ]) : '' ;
2009-07-07 02:22:57 +00:00
2017-02-05 15:49:03 -08:00
if ( ! empty ( $data [ 'plugin_price' ]))
{
e107 :: getRedirect () -> go ( $pluginUrl );
return true ;
}
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
$mp = $this -> getMarketplace ();
// $mp->generateAuthKey($e107SiteUsername, $e107SiteUserpass);
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
// Server flush useless. It's ajax ready state 4, we can't flush (sadly) before that (at least not for all browsers)
$mes -> addSuccess ( EPL_ADLAN_94 );
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
if ( $mp -> download ( $pluginID , $pluginMode , 'plugin' ))
{
$this -> pluginCheck ( true ); // rescan the plugin directory
$text = e107 :: getPlugin () -> install ( $pluginFolder );
2017-02-04 15:52:26 -08:00
2017-04-16 09:22:15 -07:00
2017-02-05 15:49:03 -08:00
$mes -> addInfo ( $text );
2017-04-16 09:22:15 -07:00
$upgradable = e107 :: getPlug () -> getUpgradableList ();
if ( ! empty ( $upgradable [ $pluginFolder ]))
{
$mes -> addSuccess ( " <a target='_top' href=' " . e_ADMIN . " plugin.php?mode=installed&action=upgrade&id= " . $pluginFolder . " ' class='btn btn-primary'> " . LAN_UPDATE . " </a> " );
}
2017-02-05 15:49:03 -08:00
echo $mes -> render ( 'default' , 'success' );
}
else
{
// Unable to continue
echo $mes -> addError ( EPL_ADLAN_95 ) -> render ( 'default' , 'error' );
}
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
echo $mes -> render ( 'default' , 'debug' );
return null ;
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
}
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
public function ListObserver ()
{
2021-01-23 14:21:55 -08:00
$this -> setupGridData ();
$this -> setPlugData ();
parent :: ListObserver ();
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
}
2017-02-04 15:52:26 -08:00
2021-01-23 14:21:55 -08:00
public function ListAjaxObserver ()
{
parent :: ListAjaxObserver ();
$this -> setPlugData ();
}
public function GridAjaxObserver ()
{
$this -> setupGridData ();
$this -> setPlugData ();
parent :: GridAjaxObserver ();
}
public function GridObserver ()
{
$this -> setupGridData ();
$this -> setPlugData ();
parent :: GridObserver ();
}
private function setupGridData ()
{
$this -> fields [ 'plugin_description' ][ 'readParms' ] = 'expand=0&truncate=1800&bb=1' ;
$this -> fields [ 'plugin_license' ][ 'class' ] = 'right' ;
$this -> grid = array (
'price' => 'plugin_license' ,
'title' => 'plugin_name' ,
'image' => 'plugin_icon' ,
'date' => 'plugin_date' ,
'body' => 'plugin_description' ,
'version' => 'plugin_version' ,
'class' => 'col-md-6 col-lg-4' ,
'author' => 'plugin_author' ,
'perPage' => 6 ,
'carousel' => true
);
$this -> grid [ 'template' ] = '
< div class = " panel panel-primary " style = " height:190px " >
< table class = " table " style = " height:180px;display:block " >
< tr >
< td style = " width:25% " >
< div class = " text-center " style = " height:90px; " > { IMAGE }
</ div >
</ td >
< td >< h4 > { TITLE } < small > v { VERSION } { PRICE } </ small ></ h4 >
< div style = " height:100px; overflow:hidden " > { BODY } </ div >
< div >< small class = " text-muted " >< i class = " fa fa-user " ></ i > { AUTHOR } < i > { DATE } </ i ></ small > < span class = " pull-right " >& nbsp ; { OPTIONS } </ span ></ div >
</ td ></ tr >
</ table >
</ div > ' ;
$this -> perPage = 180 ;
}
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
/**
* @ return e_marketplace | null
*/
public function getMarketplace ()
{
if ( null === $this -> mp )
{
$this -> mp = new e_marketplace (); // autodetect the best method
}
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
return $this -> mp ;
}
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
private function compatibilityLabel ( $val = '' )
{
$badge = ( vartrue ( $val ) > 1.9 ) ? " <span class='label label-warning'> " . EPL_ADLAN_88 . " </span> " : '1.x' ;
return $badge ;
}
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
function options ( $data )
{
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
/*
if ( ! e107 :: getFile () -> hasAuthKey ())
{
// return "<a href='".e_SELF."' class='btn btn-primary e-modal' >Download and Install</a>";
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
}
*/
2017-02-12 10:20:40 -08:00
if ( $data [ 'plugin_installflag' ])
{
return null ;
}
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
//$url = e_SELF."?src=".base64_encode($d);
// $url = e_SELF.'?action=download&src='.base64_encode($d);//$url.'&action=download';
$id = 'plug_' . $data [ 'plugin_id' ];
//<button type='button' data-target='{$id}' data-loading='".e_IMAGE."/generic/loading_32.gif' class='btn btn-primary e-ajax middle' value='Download and Install' data-src='".$url."' ><span>Download and Install</span></button>
$modalCaption = ( ! empty ( $data [ 'plugin_price' ])) ? EPL_ADLAN_92 . " " . $data [ 'plugin_name' ] . " " . $data [ 'plugin_version' ] : EPL_ADLAN_230 . " " . $data [ 'plugin_name' ] . " " . $data [ 'plugin_version' ];
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
$srcData = array (
'plugin_id' => $data [ 'plugin_id' ],
'plugin_folder' => $data [ 'plugin_folder' ],
'plugin_price' => $data [ 'plugin_price' ],
'plugin_mode' => $data [ 'plugin_mode' ],
'plugin_url' => $data [ 'plugin_url' ],
);
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
$url = $this -> getMarketplace () -> getDownloadModal ( 'plugin' , $srcData );
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
// $d = http_build_query($srcData,false,'&');
// $url = e_SELF.'?mode=download&src='.base64_encode($d);
2018-01-10 15:11:12 -08:00
$dicon = '<a title="' . EPL_ADLAN_237 . '" class="e-modal btn btn-default btn-secondary" href="' . $url . '" rel="external" data-loading="' . e_IMAGE . '/generic/loading_32.gif" data-cache="false" data-modal-caption="' . $modalCaption . '" target="_blank" >' . ADMIN_INSTALLPLUGIN_ICON . '</a>' ;
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
/*
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
// DEBUGGER .
$base64 = base64_encode ( $d );
$tmp = base64_decode ( $base64 );
parse_str ( $tmp , $data );
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
// XXX Suhosin has a 512 char limit for $_GET strings.
e107 :: getDebug () -> log ( $data [ 'plugin_name' ] . ' : ' . strlen ( $base64 ) . " <br /> " . print_a ( $data , true )); //FIXME - enable when needed to debug.
*/
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
// Temporary Pop-up version.
// $dicon = '<a class="e-modal" href="'.$data['plugin_url'].'" rel="external" data-modal-caption="'.$data['plugin_name']." ".$data['plugin_version'].'" target="_blank" ><img class="top" src="'.e_IMAGE_ABS.'icons/download_32.png" alt="" /></a>';
2017-02-04 15:52:26 -08:00
2021-01-26 15:08:58 -08:00
// $dicon = "<a data-toggle='modal' data-bs-toggle='modal' data-modal-caption=\"Downloading ".$data['plugin_name']." ".$data['plugin_version']."\" href='{$url}' data-cache='false' data-target='#uiModal' title='".$LAN_DOWNLOAD."' ><img class='top' src='".e_IMAGE_ABS."icons/download_32.png' alt='' /></a> ";
2017-02-04 15:52:26 -08:00
2017-02-12 10:20:40 -08:00
return " <div id=' { $id } ' class='center' >
2017-02-05 15:49:03 -08:00
{ $dicon }
</ div > " ;
}
2017-02-04 15:52:26 -08:00
2021-01-23 14:21:55 -08:00
private function truncateSentence ( $string , $limit = 120 )
{
if ( strlen ( $string ) <= $limit )
{
$text = nl2br ( $string );
return $string ;
}
$tmp = explode ( " . " , $string );
$chars = 0 ;
$arr = array ();
foreach ( $tmp as $line )
2017-02-05 15:49:03 -08:00
{
2021-01-23 14:21:55 -08:00
$line = str_replace ( " \n " , '' , trim ( $line ));
$len = strlen ( $line );
2017-02-04 15:52:26 -08:00
2021-01-23 14:21:55 -08:00
if ( $chars >= $limit )
{
break ;
}
2017-02-04 15:52:26 -08:00
2021-01-23 14:21:55 -08:00
$arr [] = $line ;
$chars += $len ;
2017-02-04 15:52:26 -08:00
2021-01-23 14:21:55 -08:00
}
2017-02-04 15:52:26 -08:00
2021-01-23 14:21:55 -08:00
$text = implode ( '. ' , $arr ) . '.' ;
$text = nl2br ( $text );
return $text ;
}
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
2021-01-23 14:21:55 -08:00
private function setPlugData ()
{
$from = $this -> getQuery ( 'from' , 0 );
$srch = $this -> getQuery ( 'searchquery' );
// $srch = preg_replace('/[^\w]/','', vartrue($_GET['srch']));
$mp = $this -> getMarketplace ();
$cat = '' ;
2017-02-04 15:52:26 -08:00
2021-01-23 14:21:55 -08:00
if ( $filter = $this -> getQuery ( 'filter_options' ))
{
list ( $bla , $cat ) = explode ( " __ " , $filter );
2017-02-04 15:52:26 -08:00
}
2021-01-23 14:21:55 -08:00
// do the request, retrieve and parse data
$xdata = $mp -> call ( 'getList' , array (
'type' => 'plugin' ,
'params' => array ( 'limit' => $this -> perPage , 'search' => $srch , 'from' => $from , 'cat' => $cat )
));
$total = ( int ) $xdata [ 'params' ][ 'count' ];
// e107::getDebug()->log($xdata);
$tree = $this -> getTreeModel ();
$tree -> setTotal ( $total );
$tp = e107 :: getParser ();
foreach ( $xdata [ 'data' ] as $id => $row )
2017-02-05 15:49:03 -08:00
{
2021-01-23 14:21:55 -08:00
$v [ 'id' ] = $id ;
$model = new e_model ( $v );
$tree -> setNode ( $id , $model );
2021-03-02 08:33:27 -08:00
$badge = $this -> compatibilityLabel ( $row [ 'compatibility' ]);
2021-01-23 14:21:55 -08:00
$featured = ( $row [ 'featured' ] == 1 ) ? " <span class='label label-info'> " . EPL_ADLAN_91 . " </span> " : '' ;
$price = ( ! empty ( $row [ 'price' ])) ? " <span class='label label-primary'> " . $row [ 'price' ] . " " . $row [ 'currency' ] . " </span> " : " <span class='label label-success'> " . EPL_ADLAN_93 . " </span> " ;
$node = array (
'plugin_id' => $row [ 'params' ][ 'id' ],
'plugin_mode' => $row [ 'params' ][ 'mode' ],
'plugin_icon' => vartrue ( $row [ 'icon' ], e_IMAGE . " logo_template.png " ),
'plugin_name' => stripslashes ( $row [ 'name' ]),
'plugin_description' => $this -> truncateSentence ( vartrue ( $row [ 'description' ])),
'plugin_featured' => $featured ,
'plugin_sef' => '' ,
'plugin_folder' => $row [ 'folder' ],
'plugin_path' => $row [ 'folder' ],
'plugin_date' => $tp -> toDate ( strtotime ( $row [ 'date' ]), 'relative' ),
'plugin_category' => vartrue ( $row [ 'category' ], 'n/a' ),
'plugin_author' => vartrue ( $row [ 'author' ]),
'plugin_version' => $row [ 'version' ],
'plugin_compatible' => $row [ 'compatibility' ], // $badge,
'plugin_website' => vartrue ( $row [ 'authorUrl' ]),
'plugin_url' => $row [ 'urlView' ],
'plugin_notes' => '' ,
'plugin_price' => $row [ 'price' ],
'plugin_license' => $price ,
'plugin_installflag' => e107 :: isInstalled ( $row [ 'folder' ]),
'options' => $row ,
);
2017-02-04 15:52:26 -08:00
2021-01-23 14:21:55 -08:00
$model -> setData ( $node );
2017-02-04 15:52:26 -08:00
2021-01-23 14:21:55 -08:00
}
2017-02-04 15:52:26 -08:00
2021-01-23 14:21:55 -08:00
}
public function listoldPage ()
{
// e107SiteUsername
global $plugin ;
$tp = e107 :: getParser ();
$frm = $this -> getUI ();
$caption = EPL_ADLAN_89 ;
$e107 = e107 :: getInstance ();
$xml = e107 :: getXml ();
$mes = e107 :: getMessage ();
2017-02-04 15:52:26 -08:00
2017-02-05 15:49:03 -08:00
// $mes->addWarning("Some older plugins may produce unpredictable results.");
2021-01-23 14:21:55 -08:00
// check for cURL
if ( ! function_exists ( 'curl_init' ))
{
$mes -> addWarning ( EPL_ADLAN_90 );
}
2017-02-04 15:52:26 -08:00
2021-01-23 14:21:55 -08:00
//TODO use admin_ui including filter capabilities by sending search queries back to the xml script.
$from = isset ( $_GET [ 'frm' ]) ? intval ( $_GET [ 'frm' ]) : 0 ;
$srch = preg_replace ( '/[^\w]/' , '' , vartrue ( $_GET [ 'srch' ]));
2017-02-04 15:52:26 -08:00
2021-01-23 14:21:55 -08:00
$mp = $this -> getMarketplace ();
2017-02-05 15:49:03 -08:00
2021-01-23 14:21:55 -08:00
// auth
// $mp->generateAuthKey($e107SiteUsername, $e107SiteUserpass);
2017-02-05 15:49:03 -08:00
2021-01-23 14:21:55 -08:00
// do the request, retrieve and parse data
$xdata = $mp -> call ( 'getList' , array (
'type' => 'plugin' ,
'params' => array ( 'limit' => $this -> perPage , 'search' => $srch , 'from' => $from )
));
$total = $xdata [ 'params' ][ 'count' ];
2017-02-05 15:49:03 -08:00
2021-01-23 14:21:55 -08:00
// OLD BIT OF CODE ------------------------------->
2017-02-05 15:49:03 -08:00
/*
// $file = SITEURLBASE.e_PLUGIN_ABS."release/release.php"; // temporary testing
$file = " http://e107.org/feed?type=plugin&frm= " . $from . " &srch= " . $srch . " &limit=10 " ;
$xml -> setOptArrayTags ( 'plugin' ); // make sure 'plugin' tag always returns an array
$xdata = $xml -> loadXMLfile ( $file , 'advanced' );
$total = $xdata [ '@attributes' ][ 'total' ];
echo 'file=' . $file ;
// print_a($xdata);
$xdata [ 'data' ] = $xdata [ 'plugin' ];
*/
2021-01-23 14:21:55 -08:00
// OLD BIT OF CODE END ------------------------------->
2017-02-05 15:49:03 -08:00
2021-01-23 14:21:55 -08:00
// print_a($xdata);
2017-02-05 15:49:03 -08:00
2021-01-23 14:21:55 -08:00
$c = 1 ;
foreach ( $xdata [ 'data' ] as $row )
{
//$row = $r['@attributes'];
// print_a($row);
2021-03-02 08:33:27 -08:00
$badge = $this -> compatibilityLabel ( $row [ 'compatibility' ]);
2021-01-23 14:21:55 -08:00
$featured = ( $row [ 'featured' ] == 1 ) ? " <span class='label label-info'> " . EPL_ADLAN_91 . " </span> " : '' ;
$price = ( ! empty ( $row [ 'price' ])) ? " <span class='label label-primary'> " . $row [ 'price' ] . " " . $row [ 'currency' ] . " </span> " : " <span class='label label-success'> " . EPL_ADLAN_93 . " </span> " ;
$data [] = array (
'plugin_id' => $row [ 'params' ][ 'id' ],
'plugin_mode' => $row [ 'params' ][ 'mode' ],
'plugin_icon' => vartrue ( $row [ 'icon' ], 'e-plugins-32' ),
'plugin_name' => stripslashes ( $row [ 'name' ]),
'plugin_featured' => $featured ,
'plugin_sef' => '' ,
'plugin_folder' => $row [ 'folder' ],
'plugin_path' => $row [ 'folder' ],
'plugin_date' => vartrue ( $row [ 'date' ]),
'plugin_category' => vartrue ( $row [ 'category' ], 'n/a' ),
'plugin_author' => vartrue ( $row [ 'author' ]),
'plugin_version' => $row [ 'version' ],
'plugin_description' => nl2br ( vartrue ( $row [ 'description' ])),
'plugin_compatible' => $badge ,
'plugin_website' => vartrue ( $row [ 'authorUrl' ]),
'plugin_url' => $row [ 'urlView' ],
'plugin_notes' => '' ,
'plugin_price' => $row [ 'price' ],
'plugin_license' => $price ,
'plugin_installflag' => e107 :: isInstalled ( $row [ 'folder' ])
);
2017-02-05 15:49:03 -08:00
2021-01-23 14:21:55 -08:00
$c ++ ;
}
2017-02-05 15:49:03 -08:00
2021-01-23 14:21:55 -08:00
$fieldList = $this -> fields ;
unset ( $fieldList [ 'checkboxes' ]);
$text = "
< form class = 'form-search form-inline' action = '" . e_SELF . "?" . e_QUERY . "' id = 'core-plugin-list-form' method = 'get' >
< div id = 'admin-ui-list-filter' class = 'e-search ' > " . $frm->search ('srch', $srch , 'go') . $frm->hidden ('mode', 'online') . "
2017-02-05 15:49:03 -08:00
</ div >
</ form >
2021-01-23 14:21:55 -08:00
< form action = '" . e_SELF . "?" . e_QUERY . "' id = 'core-plugin-list-form' method = 'post' >
2017-02-05 15:49:03 -08:00
< fieldset class = 'e-filter' id = 'core-plugin-list' >
2021-01-23 14:21:55 -08:00
< legend class = 'e-hideme' > " . $caption . " </ legend >
2017-02-05 15:49:03 -08:00
< table id = core - plugin - list ' class=' table adminlist table - striped ' >
2021-01-23 14:21:55 -08:00
" . $frm->colGroup ( $fieldList , $this->fieldpref ) .
$frm -> thead ( $fieldList , $this -> fieldpref ) . "
2017-02-05 15:49:03 -08:00
< tbody >
" ;
2021-01-23 14:21:55 -08:00
foreach ( $data as $key => $val )
{
2017-02-05 15:49:03 -08:00
// print_a($val);
2021-01-23 14:21:55 -08:00
$text .= " <tr> " ;
2017-02-05 15:49:03 -08:00
2021-01-23 14:21:55 -08:00
foreach ( $this -> fields as $v => $foo )
{
if ( ! in_array ( $v , $this -> fieldpref ) || $v == 'checkboxes' || $v === 'options' )
2017-02-05 15:49:03 -08:00
{
2021-01-23 14:21:55 -08:00
continue ;
2017-02-05 15:49:03 -08:00
}
2021-01-23 14:21:55 -08:00
$_value = $val [ $v ];
if ( $v == 'plugin_name' )
{
$_value .= $val [ 'plugin_featured' ];
}
// echo '<br />v='.$v;
$text .= " <td style='height: 40px' class=' " . vartrue ( $this -> fields [ $v ][ 'class' ], 'left' ) . " '> " . $frm -> renderValue ( $v , $_value , $this -> fields [ $v ], $key ) . " </td> \n " ;
2017-02-05 15:49:03 -08:00
}
2021-01-23 14:21:55 -08:00
$text .= " <td class='center'> " . $this -> options ( $val ) . " </td> " ;
$text .= " </tr> " ;
}
2017-02-05 15:49:03 -08:00
2021-01-23 14:21:55 -08:00
$text .= "
2017-02-05 15:49:03 -08:00
</ tbody >
</ table > " ;
2021-01-23 14:21:55 -08:00
$text .= "
2017-02-05 15:49:03 -08:00
</ fieldset >
</ form >
" ;
2017-02-04 15:52:26 -08:00
2021-01-23 14:21:55 -08:00
if ( $total > $this -> perPage )
{
$parms = $total . " , " . $this -> perPage . " , " . $from . " , " . e_SELF . '?mode=online&action=list&frm=[FROM]' ;
2017-02-05 15:49:03 -08:00
2021-01-23 14:21:55 -08:00
if ( ! empty ( $srch ))
{
$parms .= '&srch=' . $srch ;
2017-02-05 15:49:03 -08:00
}
2021-03-02 08:33:27 -08:00
$text .= " <div class='control-group form-inline input-inline' style='text-align:center;margin-top:10px'> " . $tp -> parseTemplate ( " { NEXTPREV= $parms } " ) . " </div> " ;
2017-02-05 15:49:03 -08:00
}
2021-01-23 14:21:55 -08:00
return $text ;
}
2017-02-04 15:52:26 -08:00
// ------- Customize Create --------
public function beforeCreate ( $new_data , $old_data )
{
return $new_data ;
}
public function afterCreate ( $new_data , $old_data , $id )
{
// do something
}
public function onCreateError ( $new_data , $old_data )
{
// do something
}
// ------- Customize Update --------
public function beforeUpdate ( $new_data , $old_data , $id )
{
return $new_data ;
}
public function afterUpdate ( $new_data , $old_data , $id )
{
// do something
}
public function onUpdateError ( $new_data , $old_data , $id )
{
// do something
}
/*
// optional - a custom page.
public function customPage ()
{
$text = 'Hello World!' ;
$otherField = $this -> getController () -> getFieldVar ( 'other_field_name' );
return $text ;
}
*/
}
2017-02-05 15:49:03 -08:00
class plugin_form_online_ui extends e_admin_form_ui
2017-02-04 15:52:26 -08:00
{
// Custom Method/Function
function plugin_name ( $curVal , $mode )
{
$frm = e107 :: getForm ();
switch ( $mode )
{
case 'read' : // List Page
return $curVal ;
break ;
case 'write' : // Edit Page
return $frm -> text ( 'plugin_name' , $curVal , 255 , 'size=large' );
break ;
case 'filter' :
case 'batch' :
return array ();
break ;
}
}
// Custom Method/Function
function plugin_addons ( $curVal , $mode )
{
$frm = e107 :: getForm ();
switch ( $mode )
{
case 'read' : // List Page
return $curVal ;
break ;
case 'write' : // Edit Page
return $frm -> text ( 'plugin_addons' , $curVal , 255 , 'size=large' );
break ;
case 'filter' :
case 'batch' :
return array ();
break ;
}
}
2017-12-25 16:20:44 -08:00
// Custom Method/Function
function plugin_compatible ( $curVal , $mode )
{
$frm = e107 :: getForm ();
switch ( $mode )
{
case 'read' : // List Page
if ( intval ( $curVal ) > 1 )
{
return " <span class='label label-warning'> " . $curVal . " </span> " ;
}
return $curVal ;
break ;
case 'write' : // Edit Page
return $frm -> text ( 'plugin_name' , $curVal , 255 , 'size=large' );
break ;
case 'filter' :
case 'batch' :
return array ();
break ;
}
}
2021-01-23 14:21:55 -08:00
function plugin_icon ( $curVal , $mode )
2017-12-25 16:20:44 -08:00
{
2021-01-23 14:21:55 -08:00
return e107 :: getParser () -> toIcon ( $curVal );
}
function options ( $bla , $data )
{
$action = $this -> getController () -> getAction ();
if ( e107 :: isInstalled ( $data [ 'folder' ]))
{
if ( $action === 'grid' )
{
return " <button class='btn btn-sm btn-default btn-secondary' disabled> " . LAN_INSTALLED . " </button> " ;
}
return ' <span class="label label-default">' . LAN_INSTALLED . " </span> " ;
return null ;
}
$id = 'plug_' . $data [ 'params' ][ 'id' ];
$modalCaption = ( ! empty ( $data [ 'price' ])) ? EPL_ADLAN_92 . " " . $data [ 'name' ] . " " . $data [ 'version' ] : EPL_ADLAN_230 . " " . $data [ 'name' ] . " " . $data [ 'version' ];
$srcData = array (
'plugin_id' => $data [ 'params' ][ 'id' ],
'plugin_folder' => $data [ 'folder' ],
'plugin_price' => $data [ 'price' ],
'plugin_mode' => 'addon' ,
'plugin_url' => $data [ 'url' ],
);
$url = $this -> getController () -> getMarketplace () -> getDownloadModal ( 'plugin' , $data );
$button = ADMIN_INSTALLPLUGIN_ICON ;
$class = 'btn btn-sm btn-default btn-secondary' ;
$disable = '' ;
$title = EPL_ADLAN_237 ;
$tp = e107 :: getParser ();
if ( $action === 'grid' )
{
$button = e107 :: getParser () -> toGlyph ( 'fa-bolt' ) . ADLAN_121 ; // Install
$class = 'btn btn-sm btn-primary' ;
$version = $tp -> filter ( e_VERSION , 'version' );
$compat = ( float ) $tp -> filter ( $data [ 'compatibility' ], 'version' );
if ( $compat == 2 )
{
$compat = $version ;
}
2021-02-13 06:15:42 -08:00
if ( ! e107 :: isCompatible ( $compat , 'plugin' ))
2021-01-23 14:21:55 -08:00
{
$button = e107 :: getParser () -> toGlyph ( 'fa-bolt' ) . ADLAN_121 ;
$class = 'btn btn-sm btn-warning' ;
// $disable = 'data-confirm="This plugin may not be compatible with your version of e107. Are you sure?"';
$title = " Install: May not be compatible " ;
}
}
2021-03-02 08:33:27 -08:00
return '<a title="' . $title . '" ' . $disable . ' class="e-modal ' . $class . '" href="' . $url . '" rel="external" data-loading="' . e_IMAGE . '/generic/loading_32.gif" data-cache="false" data-modal-caption="' . $modalCaption . '" target="_blank" >' . $button . '</a>' ;
2021-01-26 15:08:58 -08:00
// $dicon = "<a data-toggle='modal' data-bs-toggle='modal' data-modal-caption=\"Downloading ".$data['plugin_name']." ".$data['plugin_version']."\" href='{$url}' data-cache='false' data-target='#uiModal' title='".LAN_DOWNLOAD."' ><img class='top' src='".e_IMAGE_ABS."icons/download_32.png' alt='' /></a> ";
2021-01-23 14:21:55 -08:00
2017-12-25 16:20:44 -08:00
}
2017-02-04 15:52:26 -08:00
}
2017-02-05 15:49:03 -08:00
2017-09-18 13:43:31 -07:00
class pluginLanguage extends e_admin_ui
{
2017-02-05 15:49:03 -08:00
2017-09-18 13:43:31 -07:00
private $scriptFiles = array ();
private $lanFiles = array ();
2017-02-05 15:49:03 -08:00
2017-09-18 13:43:31 -07:00
private $lanDefs = array ();
private $scriptDefs = array ();
2017-02-05 15:49:03 -08:00
2017-09-18 13:43:31 -07:00
private $lanDefsData = array ();
private $scriptDefsData = array ();
2017-02-05 15:49:03 -08:00
2017-09-18 13:43:31 -07:00
private $unused = array ();
private $unsure = array ();
2017-02-05 15:49:03 -08:00
2017-09-18 13:43:31 -07:00
private $excludeLans = array ( 'CORE_LC' , 'CORE_LC2' , 'e_LAN' , 'e_LANGUAGE' , 'e_LANGUAGEDIR' , 'LAN' , 'LANGUAGE' );
2017-02-05 15:49:03 -08:00
2017-09-18 13:43:31 -07:00
private $useSimilar = false ;
2017-02-05 15:49:03 -08:00
2017-09-18 13:43:31 -07:00
function listPage ()
{
if ( ! empty ( $_GET [ 'newplugin' ]) && $_GET [ 'step' ] == 2 )
{
$plugin = e107 :: getParser () -> filter ( $_GET [ 'newplugin' ], 'file' );
return $this -> step2 ( $plugin );
2017-02-05 15:49:03 -08:00
2017-09-18 13:43:31 -07:00
}
2017-02-04 15:52:26 -08:00
2017-09-18 13:43:31 -07:00
}
2017-02-04 15:52:26 -08:00
2017-09-18 13:43:31 -07:00
function step2 ( $path )
{
$this -> plugin = $path ;
2017-02-04 15:52:26 -08:00
2017-09-18 13:43:31 -07:00
$fl = e107 :: getFile ();
2017-02-04 15:52:26 -08:00
2017-09-18 13:43:31 -07:00
$files = $fl -> get_files ( e_PLUGIN . $path . '/languages' , null , null , 3 );
$files2 = $fl -> get_files ( e_PLUGIN . $path , '\.php|\.sc|\.bb|\.xml' , 'languages' , 3 );
2017-02-04 15:52:26 -08:00
2017-09-18 13:43:31 -07:00
$this -> scanLanFile ( e_LANGUAGEDIR . " English/English.php " );
$this -> scanLanFile ( e_LANGUAGEDIR . " English/admin/lan_admin.php " );
2017-02-04 15:52:26 -08:00
2017-09-18 13:43:31 -07:00
foreach ( $files as $v )
{
if ( strpos ( $v [ 'path' ], 'English' ) !== false OR strpos ( $v [ 'fname' ], 'English' ) !== false )
{
$path = $v [ 'path' ] . $v [ 'fname' ];
$this -> lanFiles [] = $path ;
2017-02-04 15:52:26 -08:00
2017-09-18 13:43:31 -07:00
$this -> scanLanFile ( $path );
}
}
2017-02-04 15:52:26 -08:00
2017-09-18 13:43:31 -07:00
foreach ( $files2 as $v )
{
$path = $v [ 'path' ] . $v [ 'fname' ];
$this -> scriptFiles [] = $path ;
$this -> scanScriptFile ( $path );
}
2017-02-04 15:52:26 -08:00
2017-09-18 13:43:31 -07:00
return $this -> renderResults ();
2017-02-04 15:52:26 -08:00
2017-09-18 13:43:31 -07:00
}
2017-02-04 15:52:26 -08:00
2017-09-18 13:43:31 -07:00
function findSimilar ( $data )
{
$sim = array ();
2017-02-04 15:52:26 -08:00
2017-09-18 13:43:31 -07:00
foreach ( $this -> lanDefsData as $k => $v )
{
if ( empty ( $v [ 'value' ]))
{
continue ;
}
2017-02-04 15:52:26 -08:00
2017-09-18 13:43:31 -07:00
if ( $this -> useSimilar == true )
{
similar_text ( $v [ 'value' ], $data [ 'value' ], $percentSimilar );
}
else
{
$percentSimilar = 0 ;
}
2017-02-04 15:52:26 -08:00
2017-09-18 13:43:31 -07:00
if ((( $v [ 'value' ] == $data [ 'value' ] || $percentSimilar > 89 ) && $data [ 'file' ] != $v [ 'file' ]))
{
if ( strpos ( $v [ 'lan' ], 'LAN' ) === false ) // Defined constants that don't contain 'LAN'.
{
$v [ 'status' ] = 2 ;
}
else
{
$v [ 'status' ] = ( in_array ( $v [ 'lan' ], $this -> used )) ? 1 : 0 ;
}
2017-02-04 15:52:26 -08:00
2017-09-18 13:43:31 -07:00
$sim [] = $v ;
2017-02-04 15:52:26 -08:00
2017-09-18 13:43:31 -07:00
}
}
2017-02-04 15:52:26 -08:00
2017-09-18 13:43:31 -07:00
return $sim ;
2017-02-04 15:52:26 -08:00
2013-03-05 06:11:05 -08:00
}
2017-09-18 13:43:31 -07:00
function renderSimilar ( $data , $mode = '' )
2013-03-05 06:11:05 -08:00
{
2017-09-18 13:43:31 -07:00
2021-03-02 08:33:27 -08:00
$sim = ( array ) $this -> findSimilar ( $data );
2017-09-18 13:43:31 -07:00
if ( empty ( $sim ) || ( $mode == 'script' && count ( $sim ) < 2 ))
2013-03-05 06:11:05 -08:00
{
2017-09-18 13:43:31 -07:00
return ; // ADMIN_TRUE_ICON;
2013-03-05 06:11:05 -08:00
}
2017-09-18 13:43:31 -07:00
$text = " <table class='table table-striped table-bordered'>
" ;
foreach ( $sim as $k => $val )
2013-03-05 06:11:05 -08:00
{
2017-09-18 13:43:31 -07:00
$text .= " <tr>
< td style = 'width:30%' > " . $this->shortPath ( $val['file'] ). " </ td >
< td style = 'width:45%' > " . $val['lan'] . " < br />< small > " . $val['value'] . " </ small ></ td >
< td style = 'width:25%' > " . $this->renderStatus ( $val['status'] ). " </ td >
</ tr > " ;
2013-03-05 06:11:05 -08:00
}
2017-09-18 13:43:31 -07:00
$text .= " </table> " ;
return $text ;
2013-03-05 06:11:05 -08:00
}
2017-09-18 13:43:31 -07:00
function renderFilesList ( $list )
2013-03-05 06:11:05 -08:00
{
2017-09-18 13:43:31 -07:00
$l = array ();
foreach ( $list as $v )
2013-03-05 06:11:05 -08:00
{
2017-09-18 13:43:31 -07:00
$l [] = $this -> shortPath ( $v , 'script' );
2013-03-05 06:11:05 -08:00
}
2017-09-18 13:43:31 -07:00
if ( ! empty ( $l ))
2013-03-05 06:11:05 -08:00
{
2017-09-18 13:43:31 -07:00
return implode ( " <br /> " , $l );
2013-03-05 06:11:05 -08:00
}
2016-01-12 15:44:54 -08:00
}
2017-09-18 13:43:31 -07:00
function renderStatus ( $val , $mode = 'lan' )
2016-06-02 19:20:58 -07:00
{
2017-09-18 13:43:31 -07:00
$diz = array (
'lan' => array ( 0 => 'Unused by ' . $this -> plugin , 1 => 'Used by ' . $this -> plugin , 2 => 'Unsure' ),
'script' => array ( 0 => 'Missing from Language Files' , 1 => 'Found in Language Files' , 3 => " Generic " )
);
2016-01-12 15:44:54 -08:00
2013-03-05 06:11:05 -08:00
2017-09-18 13:43:31 -07:00
if ( $val == 1 )
{
return " <span class='label label-success'> " . $diz [ $mode ][ $val ] . " </span> " ;
}
2013-03-05 06:11:05 -08:00
2017-09-18 13:43:31 -07:00
if ( $val == 2 )
{
return " <span class='label label-warning'> " . $diz [ $mode ][ $val ] . " </span> " ;
}
2013-04-17 15:22:47 -07:00
2017-09-18 13:43:31 -07:00
return " <span class='label label-important label-danger'> " . $diz [ $mode ][ $val ] . " </span> " ;
}
2006-12-02 04:36:16 +00:00
2017-09-18 13:43:31 -07:00
function shortPath ( $path , $mode = 'lan' )
{
2013-03-05 06:11:05 -08:00
2017-09-18 13:43:31 -07:00
if ( $path == e_LANGUAGEDIR . 'English/English.php' )
{
return " <i>Core Frontend Language File</i> " ;
}
2008-12-10 22:39:43 +00:00
2017-09-18 13:43:31 -07:00
if ( $path == e_LANGUAGEDIR . 'English/admin/lan_admin.php' )
{
return " <i>Core Admin-area Language File</i> " ;
}
2017-02-07 14:54:02 -08:00
2017-09-18 13:43:31 -07:00
if ( $mode == 'script' )
{
return str_replace ( e_PLUGIN . $this -> plugin . '/' , '' , $path );
}
else
{
2013-03-05 06:11:05 -08:00
2017-09-18 13:43:31 -07:00
$text = str_replace ( e_PLUGIN . $this -> plugin . '/languages/' , '' , $path );
2013-03-05 06:11:05 -08:00
2017-09-18 13:43:31 -07:00
if ( strpos ( $path , '_front.php' ) === false && strpos ( $path , '_admin.php' ) === false && strpos ( $path , '_global.php' ) === false && strpos ( $path , '_menu.php' ) === false && strpos ( $path , '_notify.php' ) === false && strpos ( $path , '_search.php' ) === false )
{
return " <span class='text-error e-tip' title='File name should be either English_front.php, English_admin.php or English_global.php'> " . $text . " </span> " ;
}
2008-12-10 22:39:43 +00:00
2017-09-18 13:43:31 -07:00
return $text ;
2017-02-03 20:18:45 -08:00
2017-09-18 13:43:31 -07:00
}
2016-06-02 19:20:58 -07:00
2012-07-24 00:42:17 +00:00
}
2009-08-14 21:11:49 +00:00
2013-05-06 05:19:20 -07:00
2017-09-18 13:43:31 -07:00
function renderTable ( $array , $mode )
{
if ( empty ( $array ))
{
return " <div class='alert alert-info alert-block'>No Matches</div> " ;
}
2009-07-07 02:22:57 +00:00
2017-09-18 13:43:31 -07:00
$text2 = '' ;
2009-07-07 06:26:51 +00:00
2017-09-18 13:43:31 -07:00
if ( $mode == 'unsure' )
{
$text2 .= " <div class='alert alert-info alert-block'>LAN items in this list have been named incorrectly. They should include 'LAN' in their name. eg. LAN_ " . strtoupper ( $this -> plugin ) . " _001</div> " ;
2009-07-07 02:22:57 +00:00
2017-09-18 13:43:31 -07:00
}
2009-07-07 02:22:57 +00:00
2017-09-18 13:43:31 -07:00
$text2 .= " <table class='table table-striped table-bordered'>
< tr >
< th > LAN </ th >
< th > File </ th >
< th > Value </ th >
< th > Duplicate or Similar Value </ th >
</ tr >
" ;
2017-02-07 14:54:02 -08:00
2017-09-18 13:43:31 -07:00
foreach ( $array as $k => $v )
{
$text2 .= " <tr>
< td style = 'width:5%' > " . $v . " </ td >
< td > " . $this->shortPath ( $this->lanDefsData [ $k ]['file']). " </ td >
< td style = 'width:20%' > " . $this->lanDefsData [ $k ]['value']. " </ td >
< td > " . $this->renderSimilar ( $this->lanDefsData [ $k ]). " </ td >
</ tr > " ;
2009-08-14 21:11:49 +00:00
2017-09-18 13:43:31 -07:00
}
2009-08-14 21:11:49 +00:00
2017-09-18 13:43:31 -07:00
$text2 .= " </table> " ;
2010-06-23 10:21:21 +00:00
2017-09-18 13:43:31 -07:00
return $text2 ;
2009-07-09 02:47:17 +00:00
}
2009-07-13 09:31:19 +00:00
2017-09-18 13:43:31 -07:00
function renderScriptTable ()
2009-08-14 21:11:49 +00:00
{
2009-07-09 02:47:17 +00:00
2017-09-18 13:43:31 -07:00
// return print_a($this->scriptDefsData,true);
2009-07-09 02:47:17 +00:00
2017-09-18 13:43:31 -07:00
$text2 = " <table class='table table-striped table-bordered'>
< tr >
< th > id </ th >
< th > File </ th >
< th > Detected LAN </ th >
< th > LAN Value </ th >
< th class = 'right' > Found on Line </ th >
< th style = 'width:10%' > Status </ th >
< th > Duplicates / Possible Substitions </ th >
</ tr >
" ;
2009-07-07 06:26:51 +00:00
2017-09-18 13:43:31 -07:00
foreach ( $this -> scriptDefsData as $k => $v )
2013-05-06 05:19:20 -07:00
{
2017-09-18 13:43:31 -07:00
$status = in_array ( $v [ 'lan' ], $this -> lanDefs ) ? 1 : 0 ;
// $lan = $v['lan'];
// $v['value'] = $this->lanDefsRaw[$lan];
// $sim = $this->findSimilar($v);
$text2 .= " <tr>
< td style = 'width:5%' > " . $k . " </ td >
< td > " . $this->shortPath ( $v['file'] ,'script'). " </ td >
< td > " . $v['lan'] . " </ td >
< td >< small > " . $this->lanDefsRaw [ $v['lan'] ]. " </ small ></ td >
< td class = 'right' > " . $v['line'] . " </ td >
< td > " . $this->renderStatus ( $status ,'script'). " </ td >
< td > " . $this->renderSimilar ( $v ,'script'). " </ td >
</ tr > " ;
}
$text2 .= " </table> " ;
return $text2 ;
2015-02-03 21:58:26 -08:00
}
2016-06-02 19:20:58 -07:00
2017-09-18 13:43:31 -07:00
function renderResults ()
2016-06-02 19:20:58 -07:00
{
2017-09-18 13:43:31 -07:00
$frm = e107 :: getForm ();
$ns = e107 :: getRender ();
2016-06-02 19:20:58 -07:00
2017-09-18 13:43:31 -07:00
$this -> unused = array_diff ( $this -> lanDefs , $this -> scriptDefs );
$this -> used = array_intersect ( $this -> lanDefs , $this -> scriptDefs );
foreach ( $this -> unused as $k => $v )
2016-06-02 19:20:58 -07:00
{
2017-09-18 13:43:31 -07:00
if ( strpos ( $v , 'LAN' ) === false )
{
unset ( $this -> unused [ $k ]);
$this -> unsure [ $k ] = $v ;
}
if ( strpos ( $this -> lanDefsData [ $k ][ 'file' ], $this -> plugin ) === false || in_array ( $v , $this -> excludeLans ))
{
unset ( $this -> unused [ $k ]);
unset ( $this -> unsure [ $k ]);
}
2016-06-02 19:20:58 -07:00
}
2017-09-18 13:43:31 -07:00
// print_a($this->scriptData);
2016-06-02 19:20:58 -07:00
2017-09-18 13:43:31 -07:00
$used = $this -> renderTable ( $this -> used , 'used' );
$unused = $this -> renderTable ( $this -> unused , 'unused' );
$unsure = $this -> renderTable ( $this -> unsure , 'unsure' );
2016-06-02 19:20:58 -07:00
2009-07-09 02:47:17 +00:00
2017-09-18 13:43:31 -07:00
// echo $text2;
$tabs = array (
0 => array ( 'caption' => EPL_ADLAN_222 , 'text' => $this -> renderScriptTable ()),
1 => array ( 'caption' => EPL_ADLAN_223 , 'text' => $used ),
2 => array ( 'caption' => EPL_ADLAN_224 , 'text' => $unused ),
3 => array ( 'caption' => EPL_ADLAN_225 , 'text' => $unsure ),
2009-07-09 02:47:17 +00:00
2016-04-30 12:02:02 -07:00
2017-09-18 13:43:31 -07:00
);
2016-06-02 19:20:58 -07:00
2017-09-18 13:43:31 -07:00
$this -> addTitle ( ADLAN_98 . SEP . EPL_ADLAN_114 . SEP . EPL_ADLAN_221 . SEP . $this -> plugin );
2016-06-02 19:20:58 -07:00
2017-09-18 13:43:31 -07:00
$text = " <div class='center'><a class='btn btn-default' href=' " . e_ADMIN_ABS . " plugin.php?mode=create&action=build'> " . LAN_BACK . " </a></div> " ;
2016-06-02 19:20:58 -07:00
2017-09-18 13:43:31 -07:00
return $frm -> tabs ( $tabs ) . $text ;
2009-07-07 02:22:57 +00:00
2017-09-18 13:43:31 -07:00
//$ns->tablerender(ADLAN_98.SEP.EPL_ADLAN_114.SEP.EPL_ADLAN_221.SEP.$this->plugin, $frm->tabs($tabs));
2009-07-07 02:22:57 +00:00
2015-01-30 18:15:17 -08:00
}
2009-07-07 06:26:51 +00:00
2006-12-02 04:36:16 +00:00
2016-04-30 12:02:02 -07:00
2009-07-07 06:26:51 +00:00
2017-09-18 13:43:31 -07:00
function scanScriptFile ( $path )
2009-07-09 02:47:17 +00:00
{
2017-09-18 13:43:31 -07:00
$lines = file ( $path , FILE_IGNORE_NEW_LINES );
foreach ( $lines as $ln => $row )
2009-07-09 02:47:17 +00:00
{
2017-09-18 13:43:31 -07:00
$row = trim ( $row );
2020-12-18 19:55:12 -08:00
// if(substr($row,0,2) == '/*')
// {
2017-09-18 13:43:31 -07:00
// $skip =true; ;
2020-12-18 19:55:12 -08:00
// }
// if(substr($row,0,2) == '*/')
// {
2017-09-18 13:43:31 -07:00
// $skip =false;
// continue;
2020-12-18 19:55:12 -08:00
// }
2017-09-18 13:43:31 -07:00
2019-06-03 16:29:38 -07:00
if ( empty ( $row ) /*|| $skip == true*/ || substr ( $row , 0 , 5 ) == '<?php' || substr ( $row , 0 , 2 ) == '?>' || substr ( $row , 0 , 2 ) == '//' )
2017-09-18 13:43:31 -07:00
{
continue ;
}
if ( preg_match_all ( " /([ \ w_]*LAN[ \ w_]*)/ " , $row , $match ))
{
foreach ( $match [ 1 ] as $lan )
{
if ( ! in_array ( $lan , $this -> excludeLans ))
{
$this -> scriptDefs [] = $lan ;
$this -> scriptDefsData [] = array ( 'file' => $path , 'line' => $ln , 'lan' => $lan , 'value' => $this -> lanDefsRaw [ $lan ]);
// $this->scriptData[$path][$ln] = $row;
}
}
}
2009-07-09 02:47:17 +00:00
}
2010-06-23 10:21:21 +00:00
2009-07-07 06:26:51 +00:00
}
2010-06-23 10:21:21 +00:00
2017-09-18 13:43:31 -07:00
function scanLanFile ( $path )
2013-05-14 22:42:06 +02:00
{
2015-03-30 13:02:51 -07:00
2012-07-20 07:31:16 +00:00
2017-09-18 13:43:31 -07:00
$data = file_get_contents ( $path );
2013-05-17 15:41:02 +03:00
2017-09-18 13:43:31 -07:00
if ( preg_match_all ( '/(\/\*[\s\S]*?\*\/)/i' , $data , $multiComment ))
{
$data = str_replace ( $multiComment [ 1 ], '' , $data ); // strip multi-line comments.
}
2013-05-17 15:41:02 +03:00
2017-09-18 13:43:31 -07:00
$type = basename ( $path );
if ( preg_match_all ( '/^\s*?define\s*?\(\s*?(\'|\")([\w]+)(\'|\")\s*?,\s*?(\'|\")([\s\S]*?)\s*?(\'|\")\s*?\)\s*?;/im' , $data , $matches ))
2012-07-20 07:31:16 +00:00
{
2017-09-18 13:43:31 -07:00
$def = $matches [ 2 ];
$values = $matches [ 5 ];
foreach ( $def as $k => $d )
2012-07-24 00:42:17 +00:00
{
2017-09-18 13:43:31 -07:00
if ( $d == 'e_PAGETITLE' || $d == 'PAGE_NAME' || $d == 'CORE_LC' && $d == 'CORE_LC2' )
{
continue ;
}
$retloc [ $type ][ $d ] = $values [ $k ];
$this -> lanDefs [] = $d ;
$this -> lanDefsData [] = array ( 'file' => $path , 'lan' => $d , 'value' => $values [ $k ]);
$this -> lanDefsRaw [ $d ] = $values [ $k ];
2012-07-24 00:42:17 +00:00
}
2012-07-20 07:31:16 +00:00
}
2017-09-18 13:43:31 -07:00
//print_a($this->lanDefsData);
return ;
2012-07-20 07:31:16 +00:00
}
2017-01-04 11:59:57 -08:00
2017-02-05 15:49:03 -08:00
2017-02-07 14:54:02 -08:00
2016-11-20 20:12:33 -08:00
2017-09-18 13:43:31 -07:00
}
2015-07-17 23:09:36 -07:00
2021-01-16 13:32:35 -08:00
new plugman_adminArea ();
require_once ( e_ADMIN . " auth.php " );
e107 :: getAdminUI () -> runPage ();
require_once ( e_ADMIN . " footer.php " );
2016-11-20 20:12:33 -08:00
2016-11-19 14:07:06 -08:00
2016-11-21 15:17:12 -08:00
2017-02-07 14:54:02 -08:00
2015-02-03 21:58:26 -08:00
2015-07-17 23:09:36 -07:00
2016-11-19 14:07:06 -08:00
2017-01-26 15:37:42 -08:00
2009-07-07 02:22:57 +00:00
2009-07-07 06:26:51 +00:00
2016-12-04 11:54:02 -08:00
2009-07-07 02:22:57 +00:00
2008-12-04 21:36:09 +00:00
2016-12-04 11:54:02 -08:00
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
2017-09-18 13:43:31 -07:00
// --------------------------------------
2009-07-07 02:22:57 +00:00
2017-09-18 13:43:31 -07:00
/*
class pluginmanager_form extends e_form
{
var $plug ;
var $plug_vars ;
//FIXME _ there's a problem with calling this.
function plugin_website ( $parms , $value , $id , $attributes )
2012-01-06 09:49:08 +00:00
{
2017-09-18 13:43:31 -07:00
return ( varset ( $plugURL , false )) ? " <a href=' { $plugURL } ' title=' { $plugURL } ' > " . ADMIN_URL_ICON . " </a> " : " " ;
}
function options ( $val , $curVal )
{
$tp = e107 :: getParser ();
$_path = e_PLUGIN . $this -> plug [ 'plugin_path' ] . '/' ;
$icon_src = ( isset ( $this -> plug_vars [ 'plugin_php' ]) ? e_PLUGIN : $_path ) . $this -> plug_vars [ 'administration' ][ 'icon' ];
$plugin_icon = $this -> plug_vars [ 'administration' ][ 'icon' ] ? " <img src=' { $icon_src } ' alt='' class='icon S32' /> " : $tp -> toGlyph ( 'e-cat_plugins-32' );
$conf_file = " # " ;
$conf_title = " " ;
if ( $this -> plug_vars [ 'administration' ][ 'configFile' ] && $this -> plug [ 'plugin_installflag' ] == true )
2012-01-06 09:49:08 +00:00
{
2017-09-18 13:43:31 -07:00
$conf_file = e_PLUGIN . $this -> plug [ 'plugin_path' ] . '/' . $this -> plug_vars [ 'administration' ][ 'configFile' ];
$conf_title = LAN_CONFIGURE . ' ' . $tp -> toHTML ( $this -> plug_vars [ '@attributes' ][ 'name' ], " " , " defs,emotes_off, no_make_clickable " );
$plugin_icon = " <a title=' { $conf_title } ' href=' { $conf_file } ' > " . $plugin_icon . " </a> " ;
$plugin_config_icon = " <a class='btn btn-default' title=' { $conf_title } ' href=' { $conf_file } ' > " . ADMIN_CONFIGURE_ICON . " </a> " ;
2012-01-06 09:49:08 +00:00
}
2017-09-18 13:43:31 -07:00
$text = " <div class='btn-group'> " ;
$text .= vartrue ( $plugin_config_icon );
if ( $this -> plug_vars [ '@attributes' ][ 'installRequired' ])
2012-01-06 09:49:08 +00:00
{
2017-09-18 13:43:31 -07:00
if ( $this -> plug [ 'plugin_installflag' ])
2012-01-06 09:49:08 +00:00
{
2017-09-18 13:43:31 -07:00
$text .= ( $this -> plug [ 'plugin_installflag' ] ? " <a class='btn btn-default' href= \" " . e_SELF . " ?uninstall. { $this -> plug [ 'plugin_id' ] } \" title=' " . EPL_ADLAN_1 . " ' > " . ADMIN_UNINSTALLPLUGIN_ICON . " </a> " : " <a class='btn' href= \" " . e_SELF . " ?install. { $this -> plug [ 'plugin_id' ] } \" title=' " . EPL_ADLAN_0 . " ' > " . ADMIN_INSTALLPLUGIN_ICON . " </a> " );
// $text .= ($this->plug['plugin_installflag'] ? "<button type='button' class='delete' value='no-value' onclick=\"location.href='".e_SELF."?uninstall.{$this->plug['plugin_id']}'\"><span>".EPL_ADLAN_1."</span></button>" : "<button type='button' class='update' value='no-value' onclick=\"location.href='".e_SELF."?install.{$this->plug['plugin_id']}'\"><span>".EPL_ADLAN_0."</span></button>");
if ( e_DEBUG && ! vartrue ( $this -> plug_vars [ 'plugin_php' ]))
2009-07-07 02:22:57 +00:00
{
2017-09-18 13:43:31 -07:00
// $text .= "<br /><br /><input type='button' class='btn btn-default button' onclick=\"location.href='".e_SELF."?refresh.{$this->plug['plugin_id']}'\" title='".'Refresh plugin settings'."' value='".'Refresh plugin settings'."' /> ";
2009-07-07 02:22:57 +00:00
}
2012-01-06 09:49:08 +00:00
}
2017-09-18 13:43:31 -07:00
else
2012-01-06 09:49:08 +00:00
{
2017-09-18 13:43:31 -07:00
// $text .= "<input type='button' class='btn' onclick=\"location.href='".e_SELF."?install.{$this->plug['plugin_id']}'\" title='".EPL_ADLAN_0."' value='".EPL_ADLAN_0."' />";
// $text .= "<button type='button' class='update' value='no-value' onclick=\"location.href='".e_SELF."?install.{$this->plug['plugin_id']}'\"><span>".EPL_ADLAN_0."</span></button>";
$text .= " <a class='btn btn-default' href= \" " . e_SELF . " ?install. { $this -> plug [ 'plugin_id' ] } \" title=' " . EPL_ADLAN_0 . " ' > " . ADMIN_INSTALLPLUGIN_ICON . " </a> " ;
2012-01-06 09:49:08 +00:00
}
2017-09-18 13:43:31 -07:00
}
else
{
if ( $this -> plug_vars [ 'menuName' ])
2012-01-06 09:49:08 +00:00
{
2017-09-18 13:43:31 -07:00
$text .= EPL_NOINSTALL . str_replace ( " .. " , " " , e_PLUGIN . $this -> plug [ 'plugin_path' ]) . " / " . EPL_DIRECTORY ;
2012-01-06 09:49:08 +00:00
}
2017-09-18 13:43:31 -07:00
else
2012-01-06 09:49:08 +00:00
{
2017-09-18 13:43:31 -07:00
$text .= EPL_NOINSTALL_1 . str_replace ( " .. " , " " , e_PLUGIN . $this -> plug [ 'plugin_path' ]) . " / " . EPL_DIRECTORY ;
if ( $this -> plug [ 'plugin_installflag' ] == false )
{
e107 :: getDb () -> delete ( 'plugin' , " plugin_installflag=0 AND (plugin_path=' { $this -> plug [ 'plugin_path' ] } ' OR plugin_path=' { $this -> plug [ 'plugin_path' ] } /' ) " );
2009-07-07 02:22:57 +00:00
}
2012-01-06 09:49:08 +00:00
}
2017-09-18 13:43:31 -07:00
}
2008-12-04 21:36:09 +00:00
2017-09-18 13:43:31 -07:00
if ( $this -> plug [ 'plugin_version' ] != $this -> plug_vars [ '@attributes' ][ 'version' ] && $this -> plug [ 'plugin_installflag' ])
{
// $text .= "<br /><input type='button' class='btn' onclick=\"location.href='".e_SELF."?upgrade.{$this->plug['plugin_id']}'\" title='".EPL_UPGRADE." to v".$this->plug_vars['@attributes']['version']."' value='".EPL_UPGRADE."' />";
2019-02-26 12:22:36 -08:00
e107 :: getMessage () -> addInfo ( " <b> " . $tp -> toHTML ( $this -> plug [ 'plugin_name' ], false , 'TITLE' ) . " </b> is ready to be upgraded. (see below) " ); // TODO LAN
2017-09-18 13:43:31 -07:00
$text .= " <a class='btn btn-default' href=' " . e_SELF . " ?upgrade. { $this -> plug [ 'plugin_id' ] } ' title= \" " . EPL_UPGRADE . " v " . $this -> plug_vars [ '@attributes' ][ 'version' ] . " \" > " . ADMIN_UPGRADEPLUGIN_ICON . " </a> " ;
}
2014-01-01 18:38:02 -08:00
2017-09-18 13:43:31 -07:00
if ( $this -> plug [ 'plugin_installflag' ] && e_DEBUG == true )
{
$text .= " <a class='btn btn-default' href=' " . e_SELF . " ?repair. " . $this -> plug [ 'plugin_id' ] . " ' title=' " . LAN_REPAIR_PLUGIN_SETTINGS . " '> " . ADMIN_REPAIRPLUGIN_ICON . " </a> " ;
2012-01-06 09:49:08 +00:00
}
2010-06-23 10:21:21 +00:00
2017-09-18 13:43:31 -07:00
if ( $this -> plug [ 'plugin_installflag' ] && is_dir ( $_path . " .git " ))
{
$text .= " <a class='plugin-manager btn btn-default' href=' " . e_SELF . " ?pull. " . $this -> plug [ 'plugin_id' ] . " ' title=' " . LAN_SYNC_WITH_GIT_REPO . " '> " . ADMIN_GITSYNC_ICON . " </a> " ;
}
2010-06-23 10:21:21 +00:00
2008-12-04 21:36:09 +00:00
2017-09-18 13:43:31 -07:00
$text .= " </div> " ;
return $text ;
}
2008-12-04 21:36:09 +00:00
2017-09-18 13:43:31 -07:00
}
*/
/*
require_once ( " auth.php " );
$pman -> pluginObserver ();
$mes = e107 :: getMessage ();
$frm = e107 :: getForm (); */
2008-12-04 21:36:09 +00:00
2017-09-18 13:43:31 -07:00
require_once ( " footer.php " );
2017-02-04 13:45:11 -08:00
2010-06-23 10:21:21 +00:00
2015-01-30 18:15:17 -08:00
2012-12-02 01:14:02 -08:00
/**
2014-02-11 05:58:07 -08:00
* Plugin Admin Generator by CaMer0n . //TODO - Added dummy template and shortcode creation, plus e_search, e_cron, e_xxxxx etc.
2012-12-02 01:14:02 -08:00
*/
2012-12-02 18:12:46 -08:00
class pluginBuilder
2012-12-02 01:14:02 -08:00
{
var $fields = array ();
var $table = '' ;
var $pluginName = '' ;
var $special = array ();
2012-12-05 16:43:53 -08:00
var $tableCount = 0 ;
2013-04-15 14:08:54 -07:00
var $tableList = array ();
2016-04-10 18:47:40 -07:00
var $createFiles = false ;
2016-04-15 10:46:58 -07:00
private $buildTable = false ;
2016-04-10 18:47:40 -07:00
private $debug = false ;
2012-12-02 01:14:02 -08:00
function __construct ()
{
2016-04-10 18:47:40 -07:00
if ( e_DEBUG == true )
{
$this -> debug = true ;
}
2012-12-02 01:14:02 -08:00
$this -> special [ 'checkboxes' ] = array ( 'title' => '' , 'type' => null , 'data' => null , 'width' => '5%' , 'thclass' => 'center' , 'forced' => TRUE , 'class' => 'center' , 'toggle' => 'e-multiselect' , 'fieldpref' => true );
2015-02-09 01:05:33 -08:00
$this -> special [ 'options' ] = array ( 'title' => 'LAN_OPTIONS' , 'type' => null , 'data' => null , 'width' => '10%' , 'thclass' => 'center last' , 'class' => 'center last' , 'forced' => TRUE , 'fieldpref' => true );
2012-12-02 01:14:02 -08:00
2017-02-07 14:54:02 -08:00
}
function run ()
{
2016-12-02 12:04:08 -08:00
if ( ! empty ( $_GET [ 'newplugin' ]))
2012-12-02 18:12:46 -08:00
{
2016-12-04 11:54:02 -08:00
$this -> pluginName = e107 :: getParser () -> filter ( $_GET [ 'newplugin' ], 'file' );
2012-12-02 18:12:46 -08:00
}
2017-02-07 14:54:02 -08:00
2016-12-02 12:04:08 -08:00
if ( ! empty ( $_GET [ 'createFiles' ]))
2013-04-15 14:08:54 -07:00
{
2017-02-07 14:54:02 -08:00
$this -> createFiles = true ;
2013-04-15 14:08:54 -07:00
}
2016-04-20 17:25:32 -07:00
if ( vartrue ( $_POST [ 'step' ]) == 4 )
2012-12-02 01:14:02 -08:00
{
2017-02-07 14:54:02 -08:00
return $this -> step4 ();
2016-04-18 19:14:55 -07:00
}
2016-04-20 17:25:32 -07:00
if ( vartrue ( $_GET [ 'step' ]) == 3 )
2016-04-18 19:14:55 -07:00
{
2017-02-07 14:54:02 -08:00
return $this -> step3 ();
2012-12-02 01:14:02 -08:00
}
2016-04-18 19:14:55 -07:00
2016-04-20 17:25:32 -07:00
2017-02-05 15:49:03 -08:00
2016-12-02 12:04:08 -08:00
if ( ! empty ( $_GET [ 'newplugin' ]) && $_GET [ 'step' ] == 2 )
2012-12-02 01:14:02 -08:00
{
2017-02-05 15:49:03 -08:00
return $this -> step2 ();
2012-12-02 01:14:02 -08:00
}
2017-02-05 15:49:03 -08:00
return $this -> step1 ();
2017-02-07 14:54:02 -08:00
2012-12-02 01:14:02 -08:00
}
function step1 ()
{
2017-02-05 15:49:03 -08:00
2012-12-02 01:14:02 -08:00
$fl = e107 :: getFile ();
$frm = e107 :: getForm ();
$ns = e107 :: getRender ();
$mes = e107 :: getMessage ();
2016-04-02 12:47:27 -07:00
$tp = e107 :: getParser ();
2012-12-02 01:14:02 -08:00
$plugFolders = $fl -> get_dirs ( e_PLUGIN );
foreach ( $plugFolders as $dir )
{
2015-01-30 18:15:17 -08:00
$lanDir [ $dir ] = $dir ;
2015-02-01 02:07:56 -08:00
if ( E107_DEBUG_LEVEL == 0 && file_exists ( e_PLUGIN . $dir . " /admin_config.php " ))
2012-12-02 01:14:02 -08:00
{
continue ;
}
$newDir [ $dir ] = $dir ;
}
2015-05-01 17:54:44 +02:00
2017-09-18 13:43:31 -07:00
2015-05-01 17:54:44 +02:00
$info = EPL_ADLAN_102 ;
$info .= " <ul> " ;
2019-02-01 13:10:15 +01:00
$info .= " <li> " . str_replace ( array ( '[x]' , '[b]' , '[/b]' ), array ( e_PLUGIN , '<strong>' , '</strong>' ), EPL_ADLAN_103 ) . " </li> " ;
2016-04-18 19:14:55 -07:00
// $info .= "<li>".EPL_ADLAN_104."</li>";
2019-02-01 13:10:15 +01:00
$info .= " <li> " . str_replace ( array ( '[b]' , '[/b]' ), array ( '<strong>' , '</strong>' ), EPL_ADLAN_105 ) . " </li> " ;
2015-05-01 17:54:44 +02:00
$info .= " <li> " . EPL_ADLAN_106 . " </li> " ;
$info .= " </ul> " ;
2019-02-26 12:22:36 -08:00
// $mes->addInfo($tp->toHTML($info,true));
2012-12-02 01:14:02 -08:00
2017-02-05 15:49:03 -08:00
$text = $frm -> open ( 'createPlugin' , 'get' , e_SELF );
$text .= $frm -> hidden ( 'action' , 'build' );
2017-09-18 13:43:31 -07:00
2012-12-02 18:12:46 -08:00
$text .= " <table class='table adminform'>
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
2017-09-18 13:43:31 -07:00
< col class = 'col-control' />
2012-12-02 18:12:46 -08:00
</ colgroup >
< tr >
2015-05-01 17:54:44 +02:00
< td > " .EPL_ADLAN_107. " </ td >
2017-11-02 19:44:48 -07:00
< td >< div class = 'input-append form-inline' > " . $frm->open ('createPlugin','get',e_SELF. " ? mode = create " ). $frm->select ( " newplugin " , $newDir , false, 'size=xlarge'). $frm->admin_button ('step', 2,'other',LAN_GO). " </ div > " . $frm->checkbox ('createFiles',1,1,EPL_ADLAN_255). $frm->close (). " </ td >
2017-09-18 13:43:31 -07:00
< td >< div class = 'alert alert-info' > " . $info . " </ div ></ td >
2015-01-30 18:15:17 -08:00
</ tr >
2012-12-06 20:34:57 -08:00
< tr >
2015-05-01 17:54:44 +02:00
< td > " .EPL_ADLAN_108. " </ td >
2017-09-18 13:43:31 -07:00
< td >< div class = 'input-append form-inline' > " . $frm->open ('checkPluginLangs','get',e_SELF. " ? mode = lans " ). $frm->select ( " newplugin " , $lanDir , false, 'size=xlarge'). $frm->admin_button ('step', 2,'other',LAN_GO). " </ div > " . $frm->close (). " </ td >
< td >< div class = 'alert alert-info' > " .EPL_ADLAN_254. " </ div ></ td >
2012-12-06 20:34:57 -08:00
</ tr > " ;
2015-01-30 18:15:17 -08:00
2012-12-02 18:12:46 -08:00
/* NOT a good idea - requires the use of $_POST which would prevent browser 'go Back' navigation .
if ( e_DOMAIN == FALSE ) // localhost.
{
$text .= " <tr>
< td > Pasted MySql Dump Here </ td >
< td > " . $frm->textarea ('mysql','', 10,80). "
< span class = 'field-help' > eg . </ span ></ td >
</ tr > " ;
}
*/
$text .= "
</ table >
< div class = 'buttons-bar center' >
2015-01-30 18:15:17 -08:00
2012-12-02 18:12:46 -08:00
</ div > " ;
2013-02-22 21:34:06 -08:00
2012-12-02 01:14:02 -08:00
$text .= $frm -> close ();
2017-02-05 15:49:03 -08:00
2017-02-07 14:54:02 -08:00
return $text ;
2017-02-05 15:49:03 -08:00
2017-02-07 14:54:02 -08:00
// $ns->tablerender(ADLAN_98.SEP.EPL_ADLAN_114, $mes->render() . $text);
2012-12-02 01:14:02 -08:00
2015-01-30 18:15:17 -08:00
2015-05-01 17:54:44 +02:00
// $var['lans']['text'] = EPL_ADLAN_226;
2015-01-30 18:15:17 -08:00
// $var['lans']['link'] = e_SELF."?mode=lans";
2012-12-02 01:14:02 -08:00
}
2012-12-02 18:12:46 -08:00
function enterMysql ()
{
$frm = e107 :: getForm ();
2021-03-02 08:33:27 -08:00
return " <div> " . $frm -> textarea ( 'mysql' , '' ) . " </div> " ;
2012-12-02 18:12:46 -08:00
}
2016-04-18 19:14:55 -07:00
/**
* @ param string $table
* @ param string $file
*/
private function buildSQLFile ( $table , $file )
{
$table = e107 :: getParser () -> filter ( $table );
2012-12-02 18:12:46 -08:00
2016-04-18 19:14:55 -07:00
e107 :: getDb () -> gen ( " SHOW CREATE TABLE `# " . $table . " ` " );
$data = e107 :: getDb () -> fetch ( 'num' );
2012-12-02 18:12:46 -08:00
2016-04-18 19:14:55 -07:00
if ( ! empty ( $data [ 1 ]))
{
$createData = str_replace ( " ` " . MPREFIX , '`' , $data [ 1 ]);
$createData .= " ; " ;
2018-08-07 09:49:38 -07:00
if ( ! file_exists ( $file ) /* && empty($this->createFiles)*/ )
2016-04-30 12:02:02 -07:00
{
file_put_contents ( $file , $createData );
}
2016-04-18 19:14:55 -07:00
}
}
function step3 ()
2012-12-02 01:14:02 -08:00
{
2017-02-07 14:54:02 -08:00
// require_once(e_HANDLER."db_verify_class.php");
// $dv = new db_verify;
$dv = e107 :: getSingleton ( 'db_verify' , e_HANDLER . " db_verify_class.php " );
2012-12-02 01:14:02 -08:00
$frm = e107 :: getForm ();
$ns = e107 :: getRender ();
$mes = e107 :: getMessage ();
2016-04-18 19:14:55 -07:00
$tp = e107 :: getParser ();
2016-04-15 10:46:58 -07:00
2018-08-07 09:49:38 -07:00
2016-12-04 11:54:02 -08:00
$newplug = $tp -> filter ( $_GET [ 'newplugin' ], 'file' );
2012-12-02 01:14:02 -08:00
$this -> pluginName = $newplug ;
2016-04-18 19:14:55 -07:00
2012-12-10 18:41:24 -08:00
$sqlFile = e_PLUGIN . $newplug . " / " . $newplug . " _sql.php " ;
2016-04-18 19:14:55 -07:00
if ( ! empty ( $_GET [ 'build' ]) && ! file_exists ( $sqlFile ))
{
$this -> buildSQLFile ( $_GET [ 'build' ], $sqlFile );
}
2012-12-10 18:41:24 -08:00
$ret = array ();
2012-12-02 18:12:46 -08:00
2012-12-10 18:41:24 -08:00
if ( file_exists ( $sqlFile ))
{
$data = file_get_contents ( $sqlFile );
2017-02-03 13:02:08 -08:00
$ret = $dv -> getSqlFileTables ( $data );
2012-12-10 18:41:24 -08:00
}
2016-04-15 10:46:58 -07:00
else
{
2016-04-18 19:14:55 -07:00
e107 :: getDebug () -> log ( " SQL File Not Found " );
// $this->buildTable = true;
2016-04-15 10:46:58 -07:00
}
2012-12-02 01:14:02 -08:00
2017-02-07 14:54:02 -08:00
$text = $frm -> open ( 'newplugin-step3' , 'post' , e_SELF . '?mode=create&action=build&newplugin=' . $newplug . '&createFiles=' . $this -> createFiles . '&step=3' );
2013-02-25 02:47:23 -08:00
$text .= " <ul class='nav nav-tabs'> \n " ;
2021-01-26 15:08:58 -08:00
$text .= " <li class='active'><a data-toggle='tab' data-bs-toggle='tab' href='#xml'> " . EPL_ADLAN_109 . " </a></li> " ;
2012-12-02 01:14:02 -08:00
2021-06-03 09:56:00 -07:00
$this -> tableCount = ! empty ( $ret [ 'tables' ]) ? count ( $ret [ 'tables' ]) : 0 ;
2016-04-11 12:49:45 -07:00
if ( ! empty ( $ret [ 'tables' ]))
2012-12-02 01:14:02 -08:00
{
2016-04-11 12:49:45 -07:00
foreach ( $ret [ 'tables' ] as $key => $table )
{
2016-04-18 19:14:55 -07:00
$label = " Table: " . $table ;
2021-01-26 15:08:58 -08:00
$text .= " <li><a data-toggle='tab' data-bs-toggle='tab' href='# " . $table . " '> " . $label . " </a></li> " ;
2016-04-11 12:49:45 -07:00
$this -> tableList [] = $table ;
}
2012-12-02 01:14:02 -08:00
}
2016-04-11 12:49:45 -07:00
2016-04-18 19:14:55 -07:00
2021-01-26 15:08:58 -08:00
$text .= " <li><a data-toggle='tab' data-bs-toggle='tab' href='#preferences'> " . LAN_PREFS . " </a></li> " ;
$text .= " <li><a data-toggle='tab' data-bs-toggle='tab' href='#addons'> " . LAN_ADDONS . " </a></li> " ; //TODO LAN
2016-04-10 18:47:40 -07:00
2012-12-05 16:43:53 -08:00
2012-12-02 01:14:02 -08:00
$text .= " </ul> " ;
2013-02-25 02:47:23 -08:00
$text .= " <div class='tab-content'> \n " ;
$text .= " <div class='tab-pane active' id='xml'> \n " ;
$text .= $this -> pluginXml ();
$text .= " </div> " ;
2015-06-15 23:27:36 -07:00
if ( ! empty ( $ret [ 'tables' ]))
2012-12-02 01:14:02 -08:00
{
2015-06-15 23:27:36 -07:00
foreach ( $ret [ 'tables' ] as $key => $table )
{
$text .= " <div class='tab-pane' id=' " . $table . " '> \n " ;
$fields = $dv -> getFields ( $ret [ 'data' ][ $key ]);
$text .= $this -> form ( $table , $fields );
$text .= " </div> " ;
}
2012-12-02 01:14:02 -08:00
}
2016-04-18 19:14:55 -07:00
2013-02-25 02:47:23 -08:00
$text .= " <div class='tab-pane' id='preferences'> \n " ;
2012-12-02 01:14:02 -08:00
$text .= $this -> prefs ();
2013-02-25 02:47:23 -08:00
$text .= " </div> " ;
2016-04-10 18:47:40 -07:00
2016-04-11 12:49:45 -07:00
$text .= " <div class='tab-pane' id='addons'> \n " ;
$text .= $this -> addons ();
$text .= " </div> " ;
2016-04-10 18:47:40 -07:00
2015-06-15 23:27:36 -07:00
if ( empty ( $ret [ 'tables' ]))
{
$text .= $frm -> hidden ( $this -> pluginName . '_ui[mode]' , 'main' );
$text .= $frm -> hidden ( $this -> pluginName . '_ui[pluginName]' , $this -> pluginName );
}
2012-12-02 01:14:02 -08:00
$text .= " </div> " ;
$text .= "
< div class = 'buttons-bar center' >
" . $frm->hidden ('newplugin', $this->pluginName ). "
2016-04-18 19:14:55 -07:00
" . $frm->admin_button ('step', 4,'other', LAN_GENERATE). "
2012-12-02 01:14:02 -08:00
</ div > " ;
$text .= $frm -> close ();
2015-05-01 17:54:44 +02:00
$mes -> addInfo ( EPL_ADLAN_112 );
2012-12-05 16:43:53 -08:00
2015-05-01 17:54:44 +02:00
$mes -> addInfo ( EPL_ADLAN_113 );
2012-12-05 16:43:53 -08:00
2017-02-07 14:54:02 -08:00
return array ( 'caption' => EPL_ADLAN_115 , 'text' => $text );
// $ns->tablerender(ADLAN_98.SEP.EPL_ADLAN_114.SEP., $mes->render() . $text);
2012-12-02 01:14:02 -08:00
}
2016-04-15 10:46:58 -07:00
2016-04-18 19:14:55 -07:00
private function step2 ()
2016-04-15 10:46:58 -07:00
{
2016-04-18 19:14:55 -07:00
$frm = e107 :: getForm ();
$tables = e107 :: getDb () -> tables ();
$text = $frm -> open ( 'buildTab' , 'get' , e_REQUEST_SELF );
$text .= " <table class='table adminform'>
< tr >< td colspan = '2' >< h4 > " .ucfirst(LAN_OPTIONAL). " </ h4 ></ td ></ tr >
< tr >
< td class = 'col-label' > To generate your < em > " . $this->pluginName . " _sql . php </ em > table creation file , please select your sql table then click 'Refresh' </ td >
< td class = 'form-inline' > " ;
$text .= $frm -> select ( 'build' , $tables , null , array ( 'useValues' => 1 ), " ( " . LAN_OPTIONAL . " ) " );
// $text .= "<a href='#' id='build-table-submit' class='btn btn-success'>Refresh</a>";
// $text .= $frm->button('step', 3, 'submit', "Continue");
unset ( $_GET [ 'step' ]);
foreach ( $_GET as $k => $v )
{
$text .= $frm -> hidden ( $k , $v );
}
// $text .= $frm->hidden("build_table_url", e_REQUEST_SELF.'?'.$qry, array('id'=>'build-table-url'));
2016-04-15 10:46:58 -07:00
2016-04-18 19:14:55 -07:00
$text .= " </td></tr>
< tr >< td >& nbsp ; </ td >< td >
" . $frm->button ('step', 3, 'submit', LAN_CONTINUE). "
</ td ></ tr ></ table > " ;
2016-04-15 10:46:58 -07:00
2016-04-18 19:14:55 -07:00
$text .= $frm -> close ();
/*
e107 :: js ( 'footer-inline' , '
$ ( document ) . on ( " click " , " #build-table-submit " , function ( e ){
e . preventDefault ();
$ ( this ) . addClass ( " disabled " );
var url = $ ( " #build-table-url " ) . val ();
var sel = $ ( " #build-table-tbl " ) . val ();
url = url + " &build= " + sel ;
window . location . href = url ;
return false ;
});
2016-04-15 10:46:58 -07:00
2016-04-18 19:14:55 -07:00
' ); */
$ns = e107 :: getRender ();
2017-02-07 14:54:02 -08:00
return array ( 'caption' => EPL_ADLAN_115 , 'text' => $text );
// $ns->tablerender(ADLAN_98.SEP.EPL_ADLAN_114.SEP.EPL_ADLAN_115, $text);
2016-04-18 19:14:55 -07:00
return $text ;
2016-04-15 10:46:58 -07:00
}
2017-11-02 19:44:48 -07:00
private function buildTemplateFile ()
{
$dirName = e_PLUGIN . $this -> pluginName . " /templates " ;
if ( ! is_dir ( $dirName ))
{
mkdir ( $dirName , 0755 );
}
$file = $dirName . " / " . $this -> pluginName . " _template.php " ;
$shortFileName = " templates/ " . $this -> pluginName . " _template.php " ;
if ( file_exists ( $file ) && empty ( $this -> createFiles ))
{
return e107 :: getParser () -> lanVars ( EPL_ADLAN_256 , $shortFileName );
}
$content = <<< TMPL
< ? php
// Template File
TMPL ;
$upperName = strtoupper ( $this -> pluginName );
$content .= "
// ".$this->pluginName." Template file
if ( ! defined ( 'e107_INIT' )) { exit ; }
\ $ " . $upperName . " _TEMPLATE = array ();
\ $ " . $upperName . " _TEMPLATE [ 'default' ][ 'start' ] \t = '{SETIMAGE: w=400&h=300}' ;
\ $ " . $upperName . " _TEMPLATE [ 'default' ][ 'item' ] \t = '' ;
\ $ " . $upperName . " _TEMPLATE [ 'default' ][ 'end' ] \t = '' ;
" ;
return file_put_contents ( $file , $content ) ? LAN_CREATED . ': ' . $shortFileName : LAN_CREATED_FAILED . ': ' . $shortFileName ;
}
2016-04-15 10:46:58 -07:00
2017-11-02 19:44:48 -07:00
private function buildShortcodesFile ()
{
$file = e_PLUGIN . $this -> pluginName . " / " . $this -> pluginName . " _shortcodes.php " ;
$content = <<< TMPL
< ? php
TMPL ;
$content .= "
// ".$this->pluginName." Shortcodes file
if ( ! defined ( 'e107_INIT' )) { exit ; }
2017-11-02 20:33:17 -07:00
class plugin_ " . $this->pluginName . " _ " . $this->pluginName . " _shortcodes extends e_shortcode
2017-11-02 19:44:48 -07:00
{
" ;
if ( ! empty ( $_POST [ 'bullets_ui' ][ 'fields' ]))
{
foreach ( $_POST [ 'bullets_ui' ][ 'fields' ] as $key => $row )
{
if ( $key === 'options' || $key === 'checkboxes' )
{
continue ;
}
$content .= "
/**
* { " .strtoupper( $key ). " }
*/
public function sc_ " . $key . " ( \ $parm = null )
{
return \ $this -> var [ '".$key."' ];
}
" ;
}
}
2017-11-02 19:49:16 -07:00
$content .= '}' ;
2017-11-02 19:44:48 -07:00
return file_put_contents ( $file , $content ) ? LAN_CREATED . ': ' . $this -> pluginName . " _shortcodes.php " : LAN_CREATED_FAILED . ': ' . $this -> pluginName . " _shortcodes.php " ;
}
2016-04-11 12:49:45 -07:00
private function createAddons ( $list )
{
2016-04-10 18:47:40 -07:00
2016-04-11 12:49:45 -07:00
$srch = array ( '_blank' , 'blank' );
$result = array ();
foreach ( $list as $addon )
{
2016-10-18 13:48:47 -07:00
$addonDest = str_replace ( " _blank " , $this -> pluginName , $addon );
2016-04-11 12:49:45 -07:00
$source = e_PLUGIN . " _blank/ " . $addon . " .php " ;
2016-10-18 13:48:47 -07:00
$destination = e_PLUGIN . $this -> pluginName . " / " . $addonDest . " .php " ;
2016-04-11 12:49:45 -07:00
2017-11-02 19:44:48 -07:00
if ( file_exists ( $destination ) && empty ( $this -> createFiles ))
{
$result [] = e107 :: getParser () -> lanVars ( EPL_ADLAN_256 , $addonDest . '.php' );
continue ;
}
if ( $addon === '_blank_template' )
{
$result [] = $this -> buildTemplateFile ();
continue ;
}
if ( $addon === '_blank_shortcodes' )
2016-04-11 12:49:45 -07:00
{
2017-11-02 19:44:48 -07:00
$result [] = $this -> buildShortcodesFile ();
2016-04-11 12:49:45 -07:00
continue ;
}
if ( $content = file_get_contents ( $source ))
{
$content = str_replace ( $srch , $this -> pluginName , $content );
2016-04-30 12:02:02 -07:00
2017-11-02 19:44:48 -07:00
if ( file_exists ( $destination ) && empty ( $this -> createFiles ))
2016-04-30 12:02:02 -07:00
{
2017-11-02 19:44:48 -07:00
$result [] = e107 :: getParser () -> lanVars ( EPL_ADLAN_256 , $addonDest . '.php' );
2016-04-30 12:02:02 -07:00
}
else
2016-04-11 12:49:45 -07:00
{
2017-11-02 19:44:48 -07:00
if ( file_put_contents ( $destination , $content ))
{
$result [] = LAN_CREATED . " : " . $addonDest . " .php " ;
}
2016-04-11 12:49:45 -07:00
}
}
2020-12-18 19:55:12 -08:00
2016-04-11 12:49:45 -07:00
}
return $result ;
}
2016-04-10 18:47:40 -07:00
private function addons ()
{
$plg = e107 :: getPlugin ();
$list = $plg -> getAddonsList ();
$frm = e107 :: getForm ();
2016-04-11 12:49:45 -07:00
$text = " <table class='table table-striped adminlist' > " ;
2016-04-10 18:47:40 -07:00
2016-10-18 13:48:47 -07:00
//Todo LANS
$dizOther = array (
'_blank' => " Simple frontend script " ,
'_blank_setup' => " Create default table data during install, upgrade, uninstall etc " ,
2017-11-02 19:44:48 -07:00
'_blank_menu' => " Menu item for use in the menu manager. " ,
'_blank_template' => " Template to allow layout customization by themes. " ,
'_blank_shortcodes' => " Shortcodes for the template. "
2016-10-18 13:48:47 -07:00
);
2017-11-02 19:44:48 -07:00
array_unshift ( $list , '_blank' , '_blank_setup' , '_blank_menu' , '_blank_template' , '_blank_shortcodes' );
2016-04-10 18:47:40 -07:00
2016-04-11 12:49:45 -07:00
$templateFiles = scandir ( e_PLUGIN . " _blank " );
2016-10-18 13:48:47 -07:00
//print_a($list);
// $list[] = "_blank";
// $list[] = "_blank_setup";
2016-04-10 18:47:40 -07:00
foreach ( $list as $v )
{
2017-11-02 19:44:48 -07:00
if ( ! in_array ( $v . " .php " , $templateFiles ) && $v != '_blank_template' && $v != '_blank_shortcodes' )
2016-04-11 12:49:45 -07:00
{
continue ;
}
2016-10-18 13:48:47 -07:00
$diz = ! empty ( $dizOther [ $v ]) ? $dizOther [ $v ] : $plg -> getAddonsDiz ( $v );
$label = str_replace ( " _blank " , $this -> pluginName , $v );
$id = str_replace ( '_blank' , 'blank' , $v );
2016-04-10 18:47:40 -07:00
$text .= " <tr> " ;
2016-10-18 13:48:47 -07:00
$text .= " <td> " . $frm -> checkbox ( 'addons[]' , $v , false , $label ) . " </td> " ;
$text .= " <td><label for=' " . $frm -> name2id ( 'addons-' . $id ) . " '> " . $diz . " </label></td> " ;
2016-04-10 18:47:40 -07:00
$text .= " </tr> " ;
}
$text .= " </table> " ;
return $text ;
}
2012-12-02 01:14:02 -08:00
function prefs ()
{
2013-05-18 18:23:24 -07:00
$frm = e107 :: getForm ();
$text = '' ;
$options = array (
2015-05-01 17:54:44 +02:00
'text' => EPL_ADLAN_116 ,
'number' => EPL_ADLAN_117 ,
'url' => EPL_ADLAN_118 ,
'textarea' => EPL_ADLAN_119 ,
'bbarea' => EPL_ADLAN_120 ,
'boolean' => EPL_ADLAN_121 ,
" method " => EPL_ADLAN_122 ,
" image " => EPL_ADLAN_123 ,
2015-02-07 22:24:16 -08:00
2015-05-01 17:54:44 +02:00
" dropdown " => EPL_ADLAN_124 ,
" userclass " => EPL_ADLAN_125 ,
" language " => EPL_ADLAN_126 ,
2015-02-07 22:24:16 -08:00
2015-05-01 17:54:44 +02:00
" icon " => EPL_ADLAN_127 ,
2015-02-07 22:24:16 -08:00
2015-05-01 17:54:44 +02:00
" file " => EPL_ADLAN_128 ,
2015-02-07 22:24:16 -08:00
2013-05-18 18:23:24 -07:00
);
2016-04-10 18:47:40 -07:00
$text = " <table class='table table-striped'> " ;
2013-05-18 18:23:24 -07:00
for ( $i = 0 ; $i < 10 ; $i ++ )
{
2016-04-10 18:47:40 -07:00
$text .= " <tr><td> " .
$frm -> text ( " pluginPrefs[ " . $i . " ][index] " , '' , 40 , 'placeholder=' . EPL_ADLAN_129 ) . " </td><td> " .
$frm -> text ( " pluginPrefs[ " . $i . " ][value] " , '' , 50 , 'placeholder=' . EPL_ADLAN_130 ) . " </td><td> " .
$frm -> select ( " pluginPrefs[ " . $i . " ][type] " , $options , '' , 'class=null' , EPL_ADLAN_131 ) . " </td><td> " .
$frm -> text ( " pluginPrefs[ " . $i . " ][help] " , '' , 80 , 'size=xxlarge&placeholder=' . EPL_ADLAN_174 ) . " </td> " .
2017-03-07 17:43:59 -08:00
" </tr> " ;
2013-05-18 18:23:24 -07:00
}
2016-04-10 18:47:40 -07:00
$text .= " </table> " ;
2013-05-18 18:23:24 -07:00
return $text ;
2012-12-02 01:14:02 -08:00
}
function pluginXml ()
{
2012-12-02 18:12:46 -08:00
2012-12-02 01:14:02 -08:00
//TODO Plugin.xml Form Fields. .
2012-12-02 18:12:46 -08:00
$data = array (
2012-12-05 16:43:53 -08:00
'main' => array ( 'name' , 'lang' , 'version' , 'date' , 'compatibility' ),
2012-12-02 18:12:46 -08:00
'author' => array ( 'name' , 'url' ),
2012-12-05 16:43:53 -08:00
'summary' => array ( 'summary' ),
2012-12-02 18:12:46 -08:00
'description' => array ( 'description' ),
2016-04-12 19:56:29 -07:00
'keywords' => array ( 'one' , 'two' , 'three' ),
2012-12-02 18:12:46 -08:00
'category' => array ( 'category' ),
'copyright' => array ( 'copyright' ),
// 'adminLinks' => array('url','description','icon','iconSmall','primary'),
// 'sitelinks' => array('url','description','icon','iconSmall')
);
2013-01-22 13:12:30 -08:00
// Load old plugin.php file if it exists;
$legacyFile = e_PLUGIN . $this -> pluginName . " /plugin.php " ;
if ( file_exists ( $legacyFile ))
{
2015-06-11 12:29:19 -07:00
$eplug_name = $eplug_author = $eplug_url = $eplug_description = " " ;
$eplug_tables = array ();
2013-01-22 13:12:30 -08:00
require_once ( $legacyFile );
$mes = e107 :: getMessage ();
$mes -> addInfo ( " Loading plugin.php file " );
$defaults = array (
" main-name " => $eplug_name ,
" author-name " => $eplug_author ,
" author-url " => $eplug_url ,
" description-description " => $eplug_description ,
" summary-summary " => $eplug_description
);
if ( count ( $eplug_tables ) && ! file_exists ( e_PLUGIN . $this -> pluginName . " / " . $this -> pluginName . " _sql.php " ))
{
$cont = '' ;
foreach ( $eplug_tables as $tab )
{
if ( strpos ( $tab , " INSERT INTO " ) !== FALSE )
{
continue ;
}
$cont .= " \n " . str_replace ( " \t " , " " , $tab );
}
if ( file_put_contents ( e_PLUGIN . $this -> pluginName . " / " . $this -> pluginName . " _sql.php " , $cont ))
{
2015-05-07 10:55:44 +02:00
$info = str_replace ( '[x]' , $this -> pluginName . " _sql.php " , EPL_ADLAN_132 );
2015-05-01 17:54:44 +02:00
$mes -> addInfo ( $info , 'default' , true );
2013-01-22 13:12:30 -08:00
$red = e107 :: getRedirect ();
$red -> redirect ( e_REQUEST_URL , true );
// $red->redirect(e_SELF."?mode=create&newplugin=".$this->pluginName."&createFiles=1&step=2",true);
}
else
{
2015-05-07 10:55:44 +02:00
$msg = str_replace ( '[x]' , $this -> pluginName . " _sql.php " , EPL_ADLAN_133 ) . " <br /> " ;
$msg .= str_replace ( array ( '[x]' , '[y]' ), array ( $this -> pluginName . " _sql.php " , $cont ), EPL_ADLAN_134 );
2013-01-22 13:12:30 -08:00
$mes -> addWarning ( $msg );
}
}
}
2014-07-09 20:33:20 -07:00
$existingXml = e_PLUGIN . $this -> pluginName . " /plugin.xml " ;
if ( file_exists ( $existingXml ))
{
2014-10-24 13:56:03 -07:00
$p = e107 :: getXml () -> loadXMLfile ( $existingXml , true );
// print_a($p);
2014-07-09 20:33:20 -07:00
$defaults = array (
" main-name " => varset ( $p [ '@attributes' ][ 'name' ]),
2017-03-04 20:38:49 +01:00
" main-lang " => varset ( $p [ '@attributes' ][ 'lan' ]),
2014-07-09 20:33:20 -07:00
" author-name " => varset ( $p [ 'author' ][ '@attributes' ][ 'name' ]),
" author-url " => varset ( $p [ 'author' ][ '@attributes' ][ 'url' ]),
" description-description " => varset ( $p [ 'description' ]),
" summary-summary " => varset ( $p [ 'summary' ], $p [ 'description' ]),
" category-category " => varset ( $p [ 'category' ]),
2017-03-04 20:38:49 +01:00
" copyright-copyright " => varset ( $p [ 'copyright' ]),
2014-10-24 13:56:03 -07:00
" keywords-one " => varset ( $p [ 'keywords' ][ 'word' ][ 0 ]),
" keywords-two " => varset ( $p [ 'keywords' ][ 'word' ][ 1 ]),
2016-04-12 19:56:29 -07:00
" keywords-three " => varset ( $p [ 'keywords' ][ 'word' ][ 2 ]),
2014-07-09 20:33:20 -07:00
);
unset ( $p );
}
2013-01-22 13:12:30 -08:00
2013-02-25 02:47:23 -08:00
$text = " <table class='table adminform'> " ;
2012-12-02 18:12:46 -08:00
foreach ( $data as $key => $val )
{
$text .= " <tr><td> $key </td><td>
< div class = 'controls' > " ;
foreach ( $val as $type )
{
$nm = $key . '-' . $type ;
$name = " xml[ $nm ] " ;
2015-07-29 00:14:17 -07:00
$size = ( count ( $val ) == 1 ) ? 'span7 col-md-7' : 'span2 col-md-2' ;
2013-01-22 13:12:30 -08:00
$text .= " <div class=' { $size } '> " . $this -> xmlInput ( $name , $key . " - " . $type , vartrue ( $defaults [ $nm ])) . " </div> " ;
2012-12-02 18:12:46 -08:00
}
$text .= " </div></td></tr> " ;
}
$text .= " </table> " ;
return $text ;
2012-12-02 01:14:02 -08:00
}
2012-12-02 18:12:46 -08:00
2013-01-22 13:12:30 -08:00
function xmlInput ( $name , $info , $default = '' )
2012-12-02 18:12:46 -08:00
{
$frm = e107 :: getForm ();
list ( $cat , $type ) = explode ( " - " , $info );
2017-12-26 08:46:22 +01:00
$size = 30 ; // Textbox size.
2012-12-02 18:12:46 -08:00
$help = '' ;
2013-04-15 14:08:54 -07:00
$pattern = " " ;
$required = false ;
2012-12-02 18:12:46 -08:00
switch ( $info )
{
case 'main-name' :
2015-05-01 17:54:44 +02:00
$help = EPL_ADLAN_135 ;
2012-12-02 18:12:46 -08:00
$required = true ;
2015-04-16 17:05:42 -07:00
$pattern = " [A-Za-z0-9 -]* " ;
2014-07-09 20:33:20 -07:00
$xsize = 'medium' ;
2012-12-02 18:12:46 -08:00
break ;
case 'main-lang' :
2015-05-01 17:54:44 +02:00
$help = EPL_ADLAN_136 ;
2012-12-02 18:12:46 -08:00
$required = false ;
2012-12-05 19:28:22 -08:00
$placeholder = " " ;
$pattern = " [A-Z0-9_]* " ;
2014-07-09 20:33:20 -07:00
$xsize = 'medium' ;
2012-12-02 18:12:46 -08:00
break ;
case 'main-date' :
2015-05-01 17:54:44 +02:00
$help = EPL_ADLAN_137 ;
2012-12-02 18:12:46 -08:00
$required = true ;
2014-07-09 20:33:20 -07:00
$xsize = 'medium' ;
2012-12-02 18:12:46 -08:00
break ;
case 'main-version' :
$default = '1.0' ;
$required = true ;
2015-05-01 17:54:44 +02:00
$help = EPL_ADLAN_138 ;
2016-10-26 13:12:12 -07:00
$pattern = " ^[ \ d] { 1,2} \ .[ \ d] { 1,2}( \ .[ \ d] { 1,2})? $ " ;
2014-07-09 20:33:20 -07:00
$xsize = 'small' ;
2012-12-02 18:12:46 -08:00
break ;
2012-12-02 01:14:02 -08:00
2012-12-02 18:12:46 -08:00
case 'main-compatibility' :
$default = '2.0' ;
$required = true ;
2015-05-01 17:54:44 +02:00
$help = EPL_ADLAN_139 ;
2012-12-05 19:28:22 -08:00
$pattern = " ^[ \ d] { 1,2} \ .[ \ d] { 1,2} $ " ;
2014-07-09 20:33:20 -07:00
$xsize = 'small' ;
2012-12-02 18:12:46 -08:00
break ;
case 'author-name' :
2013-01-22 13:12:30 -08:00
$default = ( vartrue ( $default )) ? $default : USERNAME ;
2012-12-02 18:12:46 -08:00
$required = true ;
2015-05-01 17:54:44 +02:00
$help = EPL_ADLAN_140 ;
2012-12-05 19:28:22 -08:00
$pattern = " [A-Za-z \ .0-9]* " ;
2014-07-09 20:33:20 -07:00
$xsize = 'medium' ;
2012-12-02 18:12:46 -08:00
break ;
case 'author-url' :
$required = true ;
2015-05-01 17:54:44 +02:00
$help = EPL_ADLAN_141 ;
2012-12-05 21:30:17 -08:00
// $pattern = "https?://.+";
2014-07-09 20:33:20 -07:00
$xsize = 'medium' ;
2012-12-02 18:12:46 -08:00
break ;
2012-12-05 19:28:22 -08:00
//case 'main-installRequired':
// return "Installation required: ".$frm->radio_switch($name,'',LAN_YES, LAN_NO);
//break;
2012-12-05 16:43:53 -08:00
case 'summary-summary' :
2015-05-01 17:54:44 +02:00
$help = EPL_ADLAN_142 . " <br /> " . EPL_ADLAN_143 ;
2012-12-05 16:43:53 -08:00
$required = true ;
2016-04-20 17:25:32 -07:00
$size = 130 ;
2012-12-05 16:43:53 -08:00
$placeholder = " " ;
2016-10-18 13:48:47 -07:00
$pattern = " [A-Za-z - \ .0-9]* " ;
2014-07-09 20:33:20 -07:00
$xsize = 'block-level' ;
2012-12-05 16:43:53 -08:00
break ;
2016-04-12 19:56:29 -07:00
2012-12-05 16:43:53 -08:00
case 'keywords-one' :
2016-04-12 19:56:29 -07:00
$type = 'keywordDropDown' ;
$required = true ;
$help = EPL_ADLAN_144 ;
break ;
case 'keywords-three' :
2012-12-05 16:43:53 -08:00
case 'keywords-two' :
2015-05-01 17:54:44 +02:00
$help = EPL_ADLAN_144 . " <br /> " . EPL_ADLAN_143 ;
2012-12-05 16:43:53 -08:00
$required = true ;
$size = 20 ;
$placeholder = " " ;
2012-12-05 19:28:22 -08:00
$pattern = '^[a-z]*$' ;
2014-07-09 20:33:20 -07:00
$xsize = 'medium' ;
2012-12-05 16:43:53 -08:00
break ;
2012-12-02 18:12:46 -08:00
case 'description-description' :
2015-05-01 17:54:44 +02:00
$help = EPL_ADLAN_145 . " <br /> " . EPL_ADLAN_143 ;
2012-12-02 18:12:46 -08:00
$required = true ;
$size = 100 ;
2012-12-05 16:43:53 -08:00
$placeholder = " " ;
2016-10-18 13:48:47 -07:00
$pattern = " [A-Za-z - \ .0-9]* " ;
2014-07-09 20:33:20 -07:00
$xsize = 'block-level' ;
2012-12-02 18:12:46 -08:00
break ;
case 'category-category' :
2015-05-01 17:54:44 +02:00
$help = EPL_ADLAN_146 ;
2012-12-02 18:12:46 -08:00
$required = true ;
$size = 20 ;
break ;
default :
break ;
}
2012-12-02 01:14:02 -08:00
2012-12-02 18:12:46 -08:00
$req = ( $required == true ) ? " &required=1 " : " " ;
2012-12-05 16:43:53 -08:00
$placeholder = ( varset ( $placeholder )) ? $placeholder : $type ;
2021-03-02 08:33:27 -08:00
$pat = ! empty ( $pattern ) ? " &pattern= " . $pattern : " " ;
$sz = ! empty ( $xsize ) ? " &size= " . $xsize : " " ;
2012-12-02 18:12:46 -08:00
2012-12-05 16:43:53 -08:00
switch ( $type )
2012-12-02 18:12:46 -08:00
{
2012-12-05 16:43:53 -08:00
case 'date' :
2016-10-18 16:10:52 -07:00
$text = $frm -> datepicker ( $name , time (), 'format=yyyy-mm-dd&return=string' . $req . $sz );
2012-12-05 16:43:53 -08:00
break ;
case 'description' :
2014-07-09 20:33:20 -07:00
$text = $frm -> textarea ( $name , $default , 3 , 100 , $req . $sz ); // pattern not supported.
2012-12-05 16:43:53 -08:00
break ;
2012-12-05 19:28:22 -08:00
2012-12-05 16:43:53 -08:00
case 'category' :
$options = array (
2015-05-01 17:54:44 +02:00
'settings' => EPL_ADLAN_147 ,
'users' => EPL_ADLAN_148 ,
'content' => EPL_ADLAN_149 ,
'tools' => EPL_ADLAN_150 ,
'manage' => EPL_ADLAN_151 ,
'misc' => EPL_ADLAN_152 ,
'menu' => EPL_ADLAN_153 ,
'about' => EPL_ADLAN_154
2012-12-05 16:43:53 -08:00
);
2012-12-02 18:12:46 -08:00
2017-02-08 17:37:24 -08:00
$text = $frm -> select ( $name , $options , $default , 'required=1&class=form-control' , true );
2012-12-05 16:43:53 -08:00
break ;
2016-04-12 19:56:29 -07:00
case 'keywordDropDown' :
$options = array (
'generic' ,
'admin' ,
'messaging' ,
'enhancement' ,
'date' ,
'commerce' ,
'form' ,
'gaming' ,
'intranet' ,
'multimedia' ,
'information' ,
'mail' ,
'search' ,
'stats' ,
'files' ,
'security' ,
'generic' ,
'language'
);
sort ( $options );
2017-02-08 17:37:24 -08:00
$text = $frm -> select ( $name , $options , $default , 'required=1&class=form-control&useValues=1' , true );
2016-04-12 19:56:29 -07:00
break ;
2012-12-05 16:43:53 -08:00
default :
2014-07-09 20:33:20 -07:00
$text = $frm -> text ( $name , $default , $size , 'placeholder=' . $placeholder . $sz . $req . $pat );
2012-12-05 16:43:53 -08:00
break ;
2012-12-02 18:12:46 -08:00
}
2012-12-05 16:43:53 -08:00
2012-12-02 18:12:46 -08:00
$text .= ( $help ) ? " <span class='field-help'> " . $help . " </span> " : " " ;
return $text ;
}
2012-12-05 16:43:53 -08:00
function createXml ( $data )
2012-12-02 18:12:46 -08:00
{
2013-05-18 18:23:24 -07:00
// print_a($_POST);
2012-12-02 18:12:46 -08:00
$ns = e107 :: getRender ();
$mes = e107 :: getMessage ();
2012-12-05 19:28:22 -08:00
$tp = e107 :: getParser ();
2012-12-02 18:12:46 -08:00
foreach ( $data as $key => $val )
{
$key = strtoupper ( str_replace ( " - " , " _ " , $key ));
2021-03-02 08:33:27 -08:00
$newArray [ $key ] = $val ;
2012-12-02 18:12:46 -08:00
}
2016-12-15 15:08:49 +01:00
$newArray [ 'DESCRIPTION_DESCRIPTION' ] = strip_tags ( $tp -> toHTML ( $newArray [ 'DESCRIPTION_DESCRIPTION' ], true ));
$_POST [ 'pluginPrefs' ] = $tp -> filter ( $_POST [ 'pluginPrefs' ]);
2021-03-02 08:33:27 -08:00
$plugPref = array ();
2013-05-18 18:23:24 -07:00
foreach ( $_POST [ 'pluginPrefs' ] as $val )
{
if ( vartrue ( $val [ 'index' ]))
{
$id = $val [ 'index' ];
$plugPref [ $id ] = $val [ 'value' ];
}
}
// print_a($_POST['pluginPrefs']);
2021-03-02 08:33:27 -08:00
if ( ! empty ( $plugPref ))
2013-05-18 18:23:24 -07:00
{
$xmlPref = " <pluginPrefs> \n " ;
foreach ( $plugPref as $k => $v )
{
$xmlPref .= " <pref name=' " . $k . " '> " . $v . " </pref> \n " ;
}
$xmlPref .= " </pluginPrefs> " ;
$newArray [ 'PLUGINPREFS' ] = $xmlPref ;
}
2012-12-02 18:12:46 -08:00
// print_a($newArray);
// print_a($this);
$template = <<< TEMPLATE
< ? xml version = " 1.0 " encoding = " utf-8 " ?>
2012-12-05 19:28:22 -08:00
< e107Plugin name = " { MAIN_NAME} " lan = " { MAIN_LANG} " version = " { MAIN_VERSION} " date = " { MAIN_DATE} " compatibility = " { MAIN_COMPATIBILITY} " installRequired = " true " >
2012-12-02 18:12:46 -08:00
< author name = " { AUTHOR_NAME} " url = " { AUTHOR_URL} " />
2012-12-05 16:43:53 -08:00
< summary lan = " " > { SUMMARY_SUMMARY } </ summary >
< description lan = " " > { DESCRIPTION_DESCRIPTION } </ description >
< keywords >
< word > { KEYWORDS_ONE } </ word >
< word > { KEYWORDS_TWO } </ word >
2016-04-12 19:56:29 -07:00
< word > { KEYWORDS_THREE } </ word >
2012-12-05 16:43:53 -08:00
</ keywords >
2012-12-02 18:12:46 -08:00
< category > { CATEGORY_CATEGORY } </ category >
< copyright > { COPYRIGHT_COPYRIGHT } </ copyright >
< adminLinks >
2016-02-13 13:20:33 -08:00
< link url = " admin_config.php " description = " { ADMINLINKS_DESCRIPTION} " icon = " " iconSmall = " " icon128 = " " primary = " true " > LAN_CONFIGURE </ link >
2012-12-02 18:12:46 -08:00
</ adminLinks >
2013-05-18 18:23:24 -07:00
{ PLUGINPREFS }
2012-12-02 18:12:46 -08:00
</ e107Plugin >
TEMPLATE ;
2013-05-18 18:23:24 -07:00
// pluginPrefs
2013-01-22 13:12:30 -08:00
// TODO
2012-12-02 18:12:46 -08:00
/*
< siteLinks >
< link url = " { e_PLUGIN}_blank/_blank.php " perm = " everyone " > Blank </ link >
</ siteLinks >
< pluginPrefs >
< pref name = " blank_pref_1 " > 1 </ pref >
< pref name = " blank_pref_2 " > [ more ... ] </ pref >
</ pluginPrefs >
< userClasses >
< class name = " blank_userclass " description = " Blank Userclass Description " />
</ userClasses >
< extendedFields >
< field name = " custom " type = " EUF_TEXTAREA " default = " 0 " active = " true " />
</ extendedFields >
*/
$result = e107 :: getParser () -> simpleParse ( $template , $newArray );
$path = e_PLUGIN . $this -> pluginName . " /plugin.xml " ;
2017-11-02 19:44:48 -07:00
if ( file_exists ( $path ) && empty ( $this -> createFiles ))
{
return htmlentities ( $result );
}
2018-08-18 14:13:10 -07:00
if ( $this -> createFiles == true || ! file_exists ( $path ))
2012-12-02 18:12:46 -08:00
{
2013-04-15 14:08:54 -07:00
if ( file_put_contents ( $path , $result ) )
{
2015-05-01 17:54:44 +02:00
$mes -> addSuccess ( EPL_ADLAN_155 . " " . $path );
2013-04-15 14:08:54 -07:00
}
else {
2015-05-01 17:54:44 +02:00
$mes -> addError ( EPL_ADLAN_156 . " " . $path );
2013-04-15 14:08:54 -07:00
}
2012-12-02 18:12:46 -08:00
}
return htmlentities ( $result );
// $ns->tablerender(LAN_CREATED.": plugin.xml", "<pre style='font-size:80%'>".htmlentities($result)."</pre>");
}
2012-12-02 01:14:02 -08:00
function form ( $table , $fieldArray )
{
2020-11-18 14:17:26 -08:00
2012-12-02 01:14:02 -08:00
$frm = e107 :: getForm ();
2015-05-01 17:54:44 +02:00
$modes = array (
2021-03-02 08:33:27 -08:00
" main " => EPL_ADLAN_157 ,
" cat " => EPL_ADLAN_158 ,
" other1 " => EPL_ADLAN_159 ,
" other2 " => EPL_ADLAN_160 ,
" other3 " => EPL_ADLAN_161 ,
" other4 " => EPL_ADLAN_162 ,
'exclude' => EPL_ADLAN_163 ,
2015-05-01 17:54:44 +02:00
);
2012-12-02 01:14:02 -08:00
2012-12-05 16:43:53 -08:00
// echo "TABLE COUNT= ".$this->tableCount ;
2012-12-02 01:14:02 -08:00
$this -> table = $table . " _ui " ;
2013-04-15 14:08:54 -07:00
$c = 0 ;
foreach ( $modes as $id => $md )
{
2021-03-02 08:33:27 -08:00
if ( $tbl = varset ( $this -> tableList [ $c ], false ))
{
$defaultMode [ $tbl ] = $id ;
$c ++ ;
}
2013-04-15 14:08:54 -07:00
}
2012-12-05 16:43:53 -08:00
2013-04-15 14:08:54 -07:00
// print_a($defaultMode);
2012-12-02 01:14:02 -08:00
2013-04-15 14:08:54 -07:00
$text = $frm -> hidden ( $this -> table . '[pluginName]' , $this -> pluginName , 15 ) .
2012-12-05 16:43:53 -08:00
$frm -> hidden ( $this -> table . '[table]' , $table , 15 );
if ( $this -> tableCount > 1 )
{
$text .= " <table class='table adminform'> \n " ;
$text .= "
2012-12-02 01:14:02 -08:00
< tr >
< td > Mode </ td >
2013-04-25 17:29:46 -07:00
< td > " . $frm->select ( $this->table . " [ mode ] " , $modes , $defaultMode[$table] , 'required=1&class=null', true). " </ td >
2012-12-02 01:14:02 -08:00
</ tr >
" ;
2012-12-05 16:43:53 -08:00
}
else
{
$text .= $frm -> hidden ( $this -> table . '[mode]' , 'main' );
}
2015-06-15 23:27:36 -07:00
2012-12-02 01:14:02 -08:00
$text .= " </table> " . $this -> special ( 'checkboxes' );
$text .= " <table class='table adminlist'>
< thead >
< tr >
2015-05-01 17:54:44 +02:00
< th > " .EPL_ADLAN_164. " </ th >
< th > " .EPL_ADLAN_165. " </ th >
< th > " .EPL_ADLAN_166. " </ th >
< th > " .EPL_ADLAN_167. " </ th >
< th > " .EPL_ADLAN_168. " </ th >
< th class = 'center' > " .EPL_ADLAN_169. " </ th >
< th class = 'center' > " .EPL_ADLAN_170. " </ th >
< th class = 'center' > " .EPL_ADLAN_171. " </ th >
2020-11-18 14:17:26 -08:00
< th class = 'center' title = '".EPL_ADLAN_177."' > " .EPL_ADLAN_172. " </ th >
< th class = 'center' title = '".EPL_ADLAN_178."' > " .EPL_ADLAN_173. " </ th >
< th class = 'center' title = '".EPL_ADLAN_257."' > R / O </ th >
2015-05-01 17:54:44 +02:00
< th > " .EPL_ADLAN_174. " </ th >
< th > " .EPL_ADLAN_175. " </ th >
< th > " .EPL_ADLAN_176. " </ th >
2012-12-02 01:14:02 -08:00
</ tr >
</ thead >
< tbody >
" ;
foreach ( $fieldArray as $name => $val )
{
$text .= " <tr>
< td > " . $name . " </ td >
< td > " . $frm->text ( $this->table . " [ fields ][ " . $name . " ][ title ] " , $this->guess ( $name , $val ,'title'),35, 'required=1'). " </ td >
< td > " . $this->fieldType ( $name , $val ). " </ td >
< td > " . $this->fieldData ( $name , $val ). " </ td >
2013-04-15 14:08:54 -07:00
< td > " . $frm->text ( $this->table . " [ fields ][ " . $name . " ][ width ] " , $this->guess ( $name , $val ,'width'), 4, 'size=mini'). " </ td >
2012-12-02 01:14:02 -08:00
< td class = 'center' > " . $frm->checkbox ( $this->table . " [ fields ][ " . $name . " ][ batch ] " , true, $this->guess ( $name , $val ,'batch')). " </ td >
< td class = 'center' > " . $frm->checkbox ( $this->table . " [ fields ][ " . $name . " ][ filter ] " , true, $this->guess ( $name , $val ,'filter')). " </ td >
2013-04-15 14:08:54 -07:00
< td class = 'center' > " . $frm->checkbox ( $this->table . " [ fields ][ " . $name . " ][ inline ] " , true, $this->guess ( $name , $val ,'inline')). " </ td >
2012-12-02 01:14:02 -08:00
< td class = 'center' > " . $frm->checkbox ( $this->table . " [ fields ][ " . $name . " ][ validate ] " , true). " </ td >
< td class = 'center' > " . $frm->checkbox ( $this->table . " [ fields ][ " . $name . " ][ fieldpref ] " , true, $this->guess ( $name , $val ,'fieldpref')). " </ td >
2020-11-18 14:17:26 -08:00
< td class = 'center' > " . $frm->checkbox ( $this->table . " [ fields ][ " . $name . " ][ readonly ] " , true). " </ td >
2013-04-15 14:08:54 -07:00
< td > " . $frm->text ( $this->table . " [ fields ][ " . $name . " ][ help ] " ,'', 50,'size=medium'). " </ td >
2015-02-07 22:24:16 -08:00
< td > " . $frm->text ( $this->table . " [ fields ][ " . $name . " ][ readParms ] " ,'', 60,'size=small'). " </ td >
< td > " . $frm->text ( $this->table . " [ fields ][ " . $name . " ][ writeParms ] " ,'', 60,'size=small').
2012-12-03 13:21:50 -08:00
$frm -> hidden ( $this -> table . " [fields][ " . $name . " ][class] " , $this -> guess ( $name , $val , 'class' )) .
$frm -> hidden ( $this -> table . " [fields][ " . $name . " ][thclass] " , $this -> guess ( $name , $val , 'thclass' )) .
" </td>
2012-12-02 01:14:02 -08:00
</ tr > " ;
}
//'width' => '20%', 'thclass' => 'center', 'batch' => TRUE, 'filter'=>TRUE, 'parms' => 'truncate=30', 'validate' => false, 'help' => 'Enter blank URL here', 'error' => 'please, ener valid URL'),
$text .= " </tbody></table> " . $this -> special ( 'options' );
return $text ;
}
// Checkboxes and Options.
function special ( $name )
{
$frm = e107 :: getForm ();
$text = " " ;
foreach ( $this -> special [ $name ] as $key => $val )
{
$text .= $frm -> hidden ( $this -> table . " [fields][ " . $name . " ][ " . $key . " ] " , $val );
}
return $text ;
}
2017-02-06 19:25:43 -08:00
/**
* @ param $name
* @ param $val
* @ return string
*/
2012-12-02 01:14:02 -08:00
function fieldType ( $name , $val )
{
$type = strtolower ( $val [ 'type' ]);
$frm = e107 :: getForm ();
if ( strtolower ( $val [ 'default' ]) == " auto_increment " )
{
$key = $this -> table . " [pid] " ;
return " Primary Id " . $frm -> hidden ( $key , $name ); //
}
switch ( $type )
{
2014-11-13 19:37:37 -08:00
case 'date' :
case 'datetime' :
2017-02-06 19:25:43 -08:00
case 'time' :
case 'timestamp' :
2014-11-13 19:37:37 -08:00
$array = array (
2015-05-01 17:54:44 +02:00
'text' => EPL_ADLAN_179 ,
2017-02-06 19:25:43 -08:00
" hidden " => EPL_ADLAN_180 ,
" method " => EPL_ADLAN_186 ,
2014-11-13 19:37:37 -08:00
);
break ;
2012-12-02 01:14:02 -08:00
case 'int' :
case 'tinyint' :
2014-11-13 19:37:37 -08:00
case 'bigint' :
2012-12-02 01:14:02 -08:00
case 'smallint' :
2017-02-06 19:25:43 -08:00
case 'mediumint' :
2012-12-02 01:14:02 -08:00
$array = array (
2015-05-01 17:54:44 +02:00
" boolean " => EPL_ADLAN_181 ,
" number " => EPL_ADLAN_182 ,
" dropdown " => EPL_ADLAN_183 ,
" userclass " => EPL_ADLAN_184 ,
2015-07-02 14:33:04 +01:00
" datestamp " => LAN_DATE ,
2015-05-01 17:54:44 +02:00
" method " => EPL_ADLAN_186 ,
" hidden " => EPL_ADLAN_187 ,
" user " => EPL_ADLAN_188 ,
2012-12-02 01:14:02 -08:00
);
break ;
2013-04-15 14:08:54 -07:00
case 'decimal' :
2017-02-06 19:25:43 -08:00
case 'double' :
case 'float' :
2020-11-18 14:17:26 -08:00
2013-04-15 14:08:54 -07:00
$array = array (
2020-11-18 14:17:26 -08:00
" number " => EPL_ADLAN_182 ,
2015-05-01 17:54:44 +02:00
" dropdown " => EPL_ADLAN_190 ,
" method " => EPL_ADLAN_191 ,
" hidden " => EPL_ADLAN_192 ,
2013-04-15 14:08:54 -07:00
);
break ;
2012-12-02 01:14:02 -08:00
case 'varchar' :
2012-12-06 20:34:57 -08:00
case 'tinytext' :
2017-02-06 19:25:43 -08:00
case 'tinyblob' :
2012-12-02 01:14:02 -08:00
$array = array (
2015-05-01 17:54:44 +02:00
'text' => EPL_ADLAN_193 ,
" url " => EPL_ADLAN_194 ,
" email " => EPL_ADLAN_195 ,
" ip " => EPL_ADLAN_196 ,
" number " => EPL_ADLAN_197 ,
" password " => EPL_ADLAN_198 ,
" tags " => EPL_ADLAN_199 ,
2014-07-09 20:33:20 -07:00
2015-05-01 17:54:44 +02:00
" dropdown " => EPL_ADLAN_200 ,
" userclass " => EPL_ADLAN_201 ,
" language " => EPL_ADLAN_202 ,
2014-07-09 20:33:20 -07:00
2015-05-01 17:54:44 +02:00
" icon " => EPL_ADLAN_203 ,
" image " => EPL_ADLAN_204 ,
" file " => EPL_ADLAN_205 ,
" method " => EPL_ADLAN_206 ,
2014-07-09 20:33:20 -07:00
2015-05-01 17:54:44 +02:00
" hidden " => EPL_ADLAN_207
2012-12-02 01:14:02 -08:00
);
break ;
2017-02-06 19:25:43 -08:00
case 'enum' :
$array = array (
" dropdown " => EPL_ADLAN_200 ,
" tags " => EPL_ADLAN_211 ,
" method " => EPL_ADLAN_212 ,
" hidden " => EPL_ADLAN_215
);
break ;
2012-12-02 01:14:02 -08:00
case 'text' :
2012-12-06 21:41:53 -08:00
case 'mediumtext' :
case 'longtext' :
2017-02-06 19:25:43 -08:00
case 'blob' :
case 'mediumblob' :
case 'longblob' :
2012-12-02 01:14:02 -08:00
$array = array (
2015-05-01 17:54:44 +02:00
'textarea' => EPL_ADLAN_208 ,
'bbarea' => EPL_ADLAN_209 ,
'text' => EPL_ADLAN_210 ,
" tags " => EPL_ADLAN_211 ,
" method " => EPL_ADLAN_212 ,
" image " => EPL_ADLAN_213 ,
" images " => EPL_ADLAN_214 ,
" hidden " => EPL_ADLAN_215
2012-12-02 01:14:02 -08:00
);
break ;
}
// asort($array);
$fname = $this -> table . " [fields][ " . $name . " ][type] " ;
2013-04-25 17:29:46 -07:00
return $frm -> select ( $fname , $array , $this -> guess ( $name , $val ), 'required=1&class=null' , true );
2012-12-02 01:14:02 -08:00
}
// Guess Default Field Type based on name of field.
2019-05-20 14:53:43 -07:00
function guess ( $data , $val = null , $mode = 'type' )
2012-12-02 01:14:02 -08:00
{
$tmp = explode ( " _ " , $data );
if ( count ( $tmp ) == 3 ) // eg Link_page_title
{
$name = $tmp [ 2 ];
}
2014-11-13 19:37:37 -08:00
elseif ( count ( $tmp ) == 2 ) // Link_description
2012-12-02 01:14:02 -08:00
{
$name = $tmp [ 1 ];
}
2014-11-13 19:37:37 -08:00
elseif ( count ( $tmp ) === 1 )
{
$name = $data ;
}
2012-12-02 01:14:02 -08:00
$ret [ 'title' ] = ucfirst ( $name );
2012-12-03 13:21:50 -08:00
$ret [ 'width' ] = 'auto' ;
$ret [ 'class' ] = 'left' ;
$ret [ 'thclass' ] = 'left' ;
2014-07-09 20:33:20 -07:00
// echo "<br />name=".$name;
2012-12-02 01:14:02 -08:00
switch ( $name )
{
case 'id' :
$ret [ 'title' ] = 'LAN_ID' ;
2012-12-05 16:43:53 -08:00
$ret [ 'type' ] = 'boolean' ;
2012-12-02 01:14:02 -08:00
$ret [ 'batch' ] = false ;
$ret [ 'filter' ] = false ;
2013-04-15 14:08:54 -07:00
$ret [ 'inline' ] = false ;
2012-12-05 16:43:53 -08:00
$ret [ 'width' ] = '5%' ;
2012-12-02 01:14:02 -08:00
break ;
2012-12-02 18:12:46 -08:00
case 'start' :
case 'end' :
2012-12-02 01:14:02 -08:00
case 'datestamp' :
2013-01-22 00:21:11 -08:00
case 'date' :
2012-12-02 01:14:02 -08:00
$ret [ 'title' ] = 'LAN_DATESTAMP' ;
$ret [ 'type' ] = 'datestamp' ;
2012-12-03 13:21:50 -08:00
$ret [ 'batch' ] = false ;
2012-12-02 01:14:02 -08:00
$ret [ 'filter' ] = true ;
$ret [ 'fieldpref' ] = true ;
2013-04-15 14:08:54 -07:00
$ret [ 'inline' ] = false ;
2012-12-02 01:14:02 -08:00
break ;
2014-07-09 20:33:20 -07:00
case 'prename' :
case 'firstname' :
case 'lastname' :
case 'company' :
case 'city' :
$ret [ 'title' ] = ucfirst ( $name );
$ret [ 'type' ] = 'text' ;
$ret [ 'batch' ] = false ;
$ret [ 'filter' ] = false ;
$ret [ 'fieldpref' ] = true ;
$ret [ 'inline' ] = true ;
break ;
2012-12-02 01:14:02 -08:00
case 'name' :
case 'title' :
case 'subject' :
2012-12-02 18:12:46 -08:00
case 'summary' :
2012-12-02 01:14:02 -08:00
$ret [ 'title' ] = 'LAN_TITLE' ;
$ret [ 'type' ] = 'text' ;
$ret [ 'batch' ] = false ;
$ret [ 'filter' ] = false ;
$ret [ 'fieldpref' ] = true ;
2013-04-15 14:08:54 -07:00
$ret [ 'inline' ] = true ;
2012-12-02 01:14:02 -08:00
break ;
2014-07-09 20:33:20 -07:00
case 'email' :
case 'email2' :
$ret [ 'title' ] = 'LAN_EMAIL' ;
$ret [ 'type' ] = 'email' ;
$ret [ 'batch' ] = false ;
$ret [ 'filter' ] = false ;
$ret [ 'fieldpref' ] = false ;
$ret [ 'inline' ] = true ;
break ;
case 'ip' :
$ret [ 'title' ] = 'LAN_IP' ;
$ret [ 'type' ] = 'ip' ;
$ret [ 'batch' ] = false ;
$ret [ 'filter' ] = false ;
$ret [ 'fieldpref' ] = false ;
$ret [ 'inline' ] = false ;
break ;
case 'user' :
case 'userid' :
2012-12-02 01:14:02 -08:00
case 'author' :
$ret [ 'title' ] = 'LAN_AUTHOR' ;
$ret [ 'type' ] = 'user' ;
$ret [ 'batch' ] = false ;
$ret [ 'filter' ] = false ;
2013-04-15 14:08:54 -07:00
$ret [ 'inline' ] = false ;
2012-12-02 01:14:02 -08:00
break ;
2012-12-02 18:12:46 -08:00
case 'thumb' :
case 'thumbnail' :
2012-12-02 01:14:02 -08:00
case 'image' :
$ret [ 'title' ] = 'LAN_IMAGE' ;
$ret [ 'type' ] = 'image' ;
$ret [ 'batch' ] = false ;
$ret [ 'filter' ] = false ;
2013-04-15 14:08:54 -07:00
$ret [ 'inline' ] = false ;
2012-12-02 01:14:02 -08:00
break ;
2012-12-02 18:12:46 -08:00
case 'total' :
2012-12-02 01:14:02 -08:00
case 'order' :
2012-12-06 21:41:53 -08:00
case 'limit' :
2012-12-02 01:14:02 -08:00
$ret [ 'title' ] = 'LAN_ORDER' ;
$ret [ 'type' ] = 'number' ;
$ret [ 'batch' ] = false ;
$ret [ 'filter' ] = false ;
2013-04-15 14:08:54 -07:00
$ret [ 'inline' ] = false ;
2012-12-02 01:14:02 -08:00
break ;
2014-07-09 20:33:20 -07:00
case 'code' :
case 'zip' :
$ret [ 'title' ] = ucfirst ( $name );
$ret [ 'type' ] = 'number' ;
$ret [ 'batch' ] = false ;
$ret [ 'filter' ] = false ;
$ret [ 'inline' ] = true ;
break ;
2012-12-02 01:14:02 -08:00
2014-07-09 20:33:20 -07:00
case 'state' :
case 'country' :
2012-12-02 01:14:02 -08:00
case 'category' :
2014-07-09 20:33:20 -07:00
$ret [ 'title' ] = ( $name == 'category' ) ? 'LAN_CATEGORY' : ucfirst ( $name );
2012-12-02 01:14:02 -08:00
$ret [ 'type' ] = 'dropdown' ;
$ret [ 'batch' ] = true ;
$ret [ 'filter' ] = true ;
$ret [ 'fieldpref' ] = true ;
2014-07-09 20:33:20 -07:00
$ret [ 'inline' ] = true ;
2012-12-02 18:12:46 -08:00
break ;
case 'type' :
$ret [ 'title' ] = 'LAN_TYPE' ;
$ret [ 'type' ] = 'dropdown' ;
$ret [ 'batch' ] = true ;
$ret [ 'filter' ] = true ;
$ret [ 'fieldpref' ] = true ;
2013-04-15 14:08:54 -07:00
$ret [ 'inline' ] = true ;
2012-12-02 01:14:02 -08:00
break ;
case 'icon' :
case 'button' :
$ret [ 'title' ] = 'LAN_ICON' ;
$ret [ 'type' ] = 'icon' ;
$ret [ 'batch' ] = false ;
$ret [ 'filter' ] = false ;
2013-04-15 14:08:54 -07:00
$ret [ 'inline' ] = false ;
2012-12-02 01:14:02 -08:00
break ;
case 'website' :
case 'url' :
case 'homepage' :
$ret [ 'title' ] = 'LAN_URL' ;
$ret [ 'type' ] = 'url' ;
$ret [ 'batch' ] = false ;
$ret [ 'filter' ] = false ;
2013-04-15 14:08:54 -07:00
$ret [ 'inline' ] = true ;
2012-12-02 01:14:02 -08:00
break ;
case 'visibility' :
case 'class' :
$ret [ 'title' ] = 'LAN_USERCLASS' ;
$ret [ 'type' ] = 'userclass' ;
$ret [ 'batch' ] = true ;
$ret [ 'filter' ] = true ;
$ret [ 'fieldpref' ] = true ;
2013-04-15 14:08:54 -07:00
$ret [ 'inline' ] = true ;
2012-12-02 01:14:02 -08:00
break ;
2014-07-09 20:33:20 -07:00
case 'notes' :
case 'comment' :
case 'comments' :
case 'address' :
2012-12-02 01:14:02 -08:00
case 'description' :
2014-07-09 20:33:20 -07:00
$ret [ 'title' ] = ( $name == 'description' ) ? 'LAN_DESCRIPTION' : ucfirst ( $name );
2012-12-02 01:14:02 -08:00
$ret [ 'type' ] = ( $val [ 'type' ] == 'TEXT' ) ? 'textarea' : 'text' ;
2012-12-03 13:21:50 -08:00
$ret [ 'width' ] = '40%' ;
2013-04-15 14:08:54 -07:00
$ret [ 'inline' ] = false ;
2012-12-02 01:14:02 -08:00
break ;
default :
$ret [ 'type' ] = 'boolean' ;
2015-04-15 01:58:07 -07:00
$ret [ 'class' ] = 'left' ;
2012-12-02 01:14:02 -08:00
$ret [ 'batch' ] = false ;
$ret [ 'filter' ] = false ;
2015-04-15 01:58:07 -07:00
$ret [ 'thclass' ] = 'left' ;
2012-12-05 16:43:53 -08:00
$ret [ 'width' ] = 'auto' ;
2013-04-15 14:08:54 -07:00
$ret [ 'inline' ] = false ;
2012-12-02 01:14:02 -08:00
break ;
}
return vartrue ( $ret [ $mode ]);
}
function fieldData ( $name , $val )
{
$frm = e107 :: getForm ();
$type = $val [ 'type' ];
2012-12-06 20:34:57 -08:00
$strings = array ( 'time' , 'timestamp' , 'datetime' , 'year' , 'tinyblob' , 'blob' ,
2019-03-19 15:12:17 -07:00
'mediumblob' , 'longblob' , 'tinytext' , 'mediumtext' , 'longtext' , 'text' , 'date' );
2012-12-06 20:34:57 -08:00
2020-11-02 11:00:48 -08:00
2020-11-02 10:41:39 -08:00
$type = strtolower ( $type );
2019-03-19 15:12:17 -07:00
2020-11-02 10:41:39 -08:00
if ( in_array ( $type , $strings ))
2012-12-02 01:14:02 -08:00
{
$value = 'str' ;
2019-03-19 15:12:17 -07:00
}
elseif ( $type === 'varchar' || $type === 'char' )
{
$value = 'safestr' ;
}
2020-11-18 14:17:26 -08:00
elseif ( $type === 'decimal' || $type === 'float' )
{
$value = 'float' ;
}
2012-12-02 01:14:02 -08:00
else
{
$value = 'int' ;
}
2019-03-19 15:12:17 -07:00
2012-12-02 01:14:02 -08:00
$fname = $this -> table . " [fields][ " . $name . " ][data] " ;
return $frm -> hidden ( $fname , $value ) . " <a href='#' class='e-tip' title=' { $type } ' > " . $value . " </a> " ;
}
// ******************************** CODE GENERATION AREA *************************************************
2016-04-18 19:14:55 -07:00
function step4 ()
2012-12-02 01:14:02 -08:00
{
2016-12-02 12:04:08 -08:00
$tp = e107 :: getParser ();
2016-12-15 15:08:49 +01:00
$pluginTitle = $tp -> filter ( $_POST [ 'xml' ][ 'main-name' ]);
2012-12-05 16:43:53 -08:00
2012-12-02 18:12:46 -08:00
if ( $_POST [ 'xml' ])
{
2016-12-15 15:08:49 +01:00
$_POST [ 'xml' ] = $tp -> filter ( $_POST [ 'xml' ]);
2012-12-05 16:43:53 -08:00
$xmlText = $this -> createXml ( $_POST [ 'xml' ]);
2012-12-02 18:12:46 -08:00
}
2016-04-11 12:49:45 -07:00
if ( ! empty ( $_POST [ 'addons' ]))
{
2016-12-15 15:08:49 +01:00
$_POST [ 'addons' ] = $tp -> filter ( $_POST [ 'addons' ]);
2016-04-11 12:49:45 -07:00
$addonResults = $this -> createAddons ( $_POST [ 'addons' ]);
}
2012-12-02 18:12:46 -08:00
2017-03-07 17:39:04 -08:00
// e107::getDebug()->log($_POST);
2012-12-02 18:12:46 -08:00
2016-04-11 12:49:45 -07:00
unset ( $_POST [ 'step' ], $_POST [ 'xml' ], $_POST [ 'addons' ]);
2016-12-04 11:54:02 -08:00
$thePlugin = $tp -> filter ( $_POST [ 'newplugin' ], 'file' );
2012-12-02 01:14:02 -08:00
2013-04-15 14:08:54 -07:00
$text = " \n
2012-12-02 01:14:02 -08:00
// Generated e107 Plugin Admin Area
require_once ( '../../class2.php' );
if ( ! getperms ( 'P' ))
{
2016-01-13 19:17:37 -08:00
e107 :: redirect ( 'admin' );
2012-12-02 01:14:02 -08:00
exit ;
}
2016-04-07 11:43:28 -07:00
// e107::lan('".$thePlugin."',true);
2012-12-02 01:14:02 -08:00
2015-04-08 16:24:58 -07:00
class " . $ thePlugin . " _adminArea extends e_admin_dispatcher
2012-12-02 01:14:02 -08:00
{
protected \ $modes = array (
" ;
2013-05-18 18:23:24 -07:00
2017-03-07 17:39:04 -08:00
unset ( $_POST [ 'newplugin' ], $_POST [ 'mode' ]);
2015-06-15 23:27:36 -07:00
2012-12-02 01:14:02 -08:00
foreach ( $_POST as $table => $vars ) // LOOP Through Tables.
{
2017-03-07 17:39:04 -08:00
if ( ! empty ( $vars [ 'mode' ]) && $vars [ 'mode' ] != 'exclude' )
2013-05-18 18:23:24 -07:00
{
2016-12-02 12:04:08 -08:00
$vars [ 'mode' ] = $tp -> filter ( $vars [ 'mode' ]);
2012-12-02 01:14:02 -08:00
$text .= "
'".$vars[' mode ']."' => array (
2015-06-15 23:27:36 -07:00
'controller' => '".$table."' ,
2012-12-02 01:14:02 -08:00
'path' => null ,
2015-06-15 23:27:36 -07:00
'ui' => '".str_replace("_ui", "_form_ui", $table)."' ,
2012-12-02 01:14:02 -08:00
'uipath' => null
),
2013-05-18 18:23:24 -07:00
2012-12-02 01:14:02 -08:00
" ;
2013-05-18 18:23:24 -07:00
}
2012-12-02 01:14:02 -08:00
} // END LOOP
/*
'cat' => array (
'controller' => 'faq_cat_ui' ,
'path' => null ,
'ui' => 'faq_cat_form_ui' ,
'uipath' => null
)
);
*/
$text .= "
);
protected \ $adminMenu = array (
" ;
foreach ( $_POST as $table => $vars ) // LOOP Through Tables.
{
2017-03-07 17:39:04 -08:00
if ( ! empty ( $vars [ 'mode' ]) && $vars [ 'mode' ] != 'exclude' && ! empty ( $vars [ 'table' ]))
2013-05-18 18:23:24 -07:00
{
2016-12-02 12:04:08 -08:00
$vars [ 'mode' ] = $tp -> filter ( $vars [ 'mode' ]);
2012-12-02 01:14:02 -08:00
$text .= "
'".$vars[' mode ']."/list' => array ( 'caption' => LAN_MANAGE , 'perm' => 'P' ),
'".$vars[' mode ']."/create' => array ( 'caption' => LAN_CREATE , 'perm' => 'P' ),
" ;
2013-05-18 18:23:24 -07:00
}
2012-12-02 01:14:02 -08:00
}
2013-05-18 18:23:24 -07:00
if ( $_POST [ 'pluginPrefs' ][ 0 ][ 'index' ])
{
2012-12-02 01:14:02 -08:00
$text .= "
2013-05-18 18:23:24 -07:00
'main/prefs' => array ( 'caption' => LAN_PREFS , 'perm' => 'P' ),
" ;
}
$text .= "
2018-05-23 16:29:37 -07:00
// 'main/div0' => array('divider'=> true),
// 'main/custom' => array('caption'=> 'Custom Page', 'perm' => 'P'),
2012-12-02 01:14:02 -08:00
);
protected \ $adminMenuAliases = array (
'main/edit' => 'main/list'
);
2016-12-09 09:59:32 -08:00
protected \ $menuTitle = '".vartrue($pluginTitle, $tp->filter($vars[' pluginName ']))."' ;
2012-12-02 01:14:02 -08:00
}
" ;
// print_a($_POST);
2018-08-18 14:13:10 -07:00
2012-12-02 01:14:02 -08:00
2013-05-18 18:23:24 -07:00
$tableCount = 1 ;
2012-12-02 01:14:02 -08:00
foreach ( $_POST as $table => $vars ) // LOOP Through Tables.
{
2015-03-29 10:11:09 -07:00
2016-12-02 12:04:08 -08:00
$vars [ 'mode' ] = $tp -> filter ( $vars [ 'mode' ]);
$vars [ 'pluginName' ] = $tp -> filter ( $vars [ 'pluginName' ]);
$vars [ 'table' ] = $tp -> filter ( $vars [ 'table' ]);
$vars [ 'pid' ] = $tp -> filter ( $vars [ 'pid' ]);
2015-03-29 10:11:09 -07:00
if ( $table == 'pluginPrefs' || $vars [ 'mode' ] == 'exclude' )
2013-05-18 18:23:24 -07:00
{
continue ;
}
2015-02-09 01:05:33 -08:00
2018-08-18 14:13:10 -07:00
$FIELDS = $this -> buildAdminUIFields ( $vars );
2012-12-02 01:14:02 -08:00
$FIELDPREF = array ();
foreach ( $vars [ 'fields' ] as $k => $v )
{
2015-02-09 01:05:33 -08:00
2013-04-15 14:08:54 -07:00
if ( isset ( $v [ 'fieldpref' ]) && $k != 'checkboxes' && $k != 'options' )
2012-12-02 01:14:02 -08:00
{
$FIELDPREF [] = " ' " . $k . " ' " ;
}
}
$text .=
"
class " . $ table . " extends e_admin_ui
{
2012-12-05 16:43:53 -08:00
protected \ $pluginTitle = '".$pluginTitle."' ;
2012-12-02 01:14:02 -08:00
protected \ $pluginName = '".$vars[' pluginName ']."' ;
2015-02-09 01:05:33 -08:00
// protected \$eventName = '".$vars['pluginName']."-".$vars['table']."'; // remove comment to enable event triggers in admin.
2012-12-02 01:14:02 -08:00
protected \ $table = '".$vars[' table ']."' ;
protected \ $pid = '".$vars[' pid ']."' ;
2014-02-11 05:58:07 -08:00
protected \ $perPage = 10 ;
protected \ $batchDelete = true ;
2017-01-27 18:02:57 -08:00
protected \ $batchExport = true ;
protected \ $batchCopy = true ;
2017-04-01 09:17:25 -07:00
2014-02-11 05:58:07 -08:00
// protected \$sortField = 'somefield_order';
2017-04-01 09:17:25 -07:00
// protected \$sortParent = 'somefield_parent';
// protected \$treePrefix = 'somefield_title';
2015-02-03 12:24:15 -08:00
// protected \$tabs = array('Tabl 1','Tab 2'); // Use 'tab'=>0 OR 'tab'=>1 in the \$fields below to enable.
2014-02-11 05:58:07 -08:00
2015-02-03 12:24:15 -08:00
// protected \$listQry = \"SELECT * FROM `#tableName` WHERE field != '' \"; // Example Custom Query. LEFT JOINS allowed. Should be without any Order or Limit.
2014-02-11 05:58:07 -08:00
protected \ $listOrder = '".$vars[' pid ']." DESC' ;
2012-12-02 01:14:02 -08:00
protected \ $fields = " . $FIELDS . " ;
protected \ $fieldpref = array ( " .implode( " , " , $FIELDPREF ). " );
2013-05-18 18:23:24 -07:00
" ;
2013-05-26 16:13:45 -07:00
if ( $_POST [ 'pluginPrefs' ] && ( $vars [ 'mode' ] == 'main' ))
2013-05-18 18:23:24 -07:00
{
2015-06-15 23:27:36 -07:00
$text .= "
// protected \$preftabs = array('General', 'Other' );
2015-04-15 01:58:07 -07:00
protected \ $prefs = array ( \n " ;
2012-12-02 01:14:02 -08:00
2013-05-18 18:23:24 -07:00
foreach ( $_POST [ 'pluginPrefs' ] as $k => $val )
{
2018-08-18 14:13:10 -07:00
if ( ! empty ( $val [ 'index' ]))
2013-05-18 18:23:24 -07:00
{
2016-12-15 15:08:49 +01:00
$index = $tp -> filter ( $val [ 'index' ]);
2013-05-18 18:23:24 -07:00
$type = vartrue ( $val [ 'type' ], 'text' );
2016-04-11 12:49:45 -07:00
$help = str_replace ( " ' " , '' , vartrue ( $val [ 'help' ]));
2013-05-18 18:23:24 -07:00
2019-04-11 12:51:47 -07:00
$text .= " \t \t \t ' " . $index . " ' \t \t => array('title'=> ' " . ucfirst ( $index ) . " ', 'tab'=>0, 'type'=>' " . $tp -> filter ( $type ) . " ', 'data' => 'str', 'help'=>' " . $tp -> filter ( $help ) . " ', 'writeParms' => array()), \n " ;
2013-05-18 18:23:24 -07:00
}
}
$text .= " \t \t ); \n \n " ;
}
$text .= "
2012-12-02 01:14:02 -08:00
public function init ()
{
2018-08-18 14:13:10 -07:00
// This code may be removed once plugin development is complete.
if ( ! e107 :: isInstalled ( '".$vars[' pluginName ']."' ))
{
e107 :: getMessage () -> addWarning ( \ " This plugin is not yet installed. Saving and loading of preference or table data will fail. \" );
}
2014-07-09 20:33:20 -07:00
// Set drop-down values (if any).
" ;
foreach ( $vars [ 'fields' ] as $k => $v )
{
if ( $v [ 'type' ] == 'dropdown' )
{
2015-04-15 01:58:07 -07:00
$text .= " \t \t \t \$ this->fields[' " . $k . " ']['writeParms']['optArray'] = array(' " . $k . " _0',' " . $k . " _1', ' " . $k . " _2'); // Example Drop-down array. \n " ;
2014-07-09 20:33:20 -07:00
}
}
2012-12-02 01:14:02 -08:00
2014-07-09 20:33:20 -07:00
$text .= "
2012-12-02 01:14:02 -08:00
}
2015-02-03 12:24:15 -08:00
// ------- Customize Create --------
2016-04-22 09:01:18 -07:00
public function beforeCreate ( \ $new_data , \ $old_data )
2015-02-03 12:24:15 -08:00
{
return \ $new_data ;
}
2012-12-02 01:14:02 -08:00
2015-02-03 12:24:15 -08:00
public function afterCreate ( \ $new_data , \ $old_data , \ $id )
{
// do something
}
public function onCreateError ( \ $new_data , \ $old_data )
{
// do something
}
// ------- Customize Update --------
public function beforeUpdate ( \ $new_data , \ $old_data , \ $id )
{
return \ $new_data ;
}
public function afterUpdate ( \ $new_data , \ $old_data , \ $id )
{
// do something
}
public function onUpdateError ( \ $new_data , \ $old_data , \ $id )
{
// do something
}
2018-08-18 14:13:10 -07:00
// left-panel help menu area. (replaces e_help.php used in old plugins)
2017-09-20 16:15:18 -07:00
public function renderHelp ()
{
\ $caption = LAN_HELP ;
\ $text = 'Some help text' ;
return array ( 'caption' => \ $caption , 'text' => \ $text );
}
2015-02-03 12:24:15 -08:00
2014-07-09 20:33:20 -07:00
/*
2015-02-03 12:24:15 -08:00
// optional - a custom page.
2012-12-02 01:14:02 -08:00
public function customPage ()
{
\ $text = 'Hello World!' ;
2016-07-07 14:28:12 -07:00
\ $otherField = \ $this -> getController () -> getFieldVar ( 'other_field_name' );
2015-04-15 01:58:07 -07:00
return \ $text ;
2012-12-02 01:14:02 -08:00
}
2017-09-20 16:15:18 -07:00
2018-08-18 14:13:10 -07:00
" ;
$text .= $this -> buildAdminUIBatchFilter ( $vars [ 'fields' ], $table , 'batch' );
$text .= $this -> buildAdminUIBatchFilter ( $vars [ 'fields' ], $table , 'filter' );
$text .= "
2017-09-20 16:15:18 -07:00
2013-04-15 14:08:54 -07:00
*/
2012-12-02 01:14:02 -08:00
}
2015-06-15 23:27:36 -07:00
class " . str_replace ( " _ui " , " _form_ui " , $table ) . " extends e_admin_form_ui
2012-12-02 01:14:02 -08:00
{
" ;
foreach ( $vars [ 'fields' ] as $fld => $val )
{
2013-04-15 14:08:54 -07:00
if ( varset ( $val [ 'type' ]) != 'method' )
2012-12-02 01:14:02 -08:00
{
continue ;
}
$text .= "
// Custom Method/Function
function " . $fld . " ( \ $curVal , \ $mode )
{
2017-02-05 15:49:03 -08:00
2012-12-02 01:14:02 -08:00
switch ( \ $mode )
{
case 'read' : // List Page
return \ $curVal ;
break ;
case 'write' : // Edit Page
2017-02-05 15:49:03 -08:00
return \ $this -> text ( '".$fld."' , \ $curVal , 255 , 'size=large' );
2012-12-02 01:14:02 -08:00
break ;
case 'filter' :
2018-08-18 14:13:10 -07:00
return array ( 'customfilter_1' => 'Custom Filter 1' , 'customfilter_2' => 'Custom Filter 2' );
break ;
2012-12-02 01:14:02 -08:00
case 'batch' :
2018-08-18 14:13:10 -07:00
return array ( 'custombatch_1' => 'Custom Batch 1' , 'custombatch_2' => 'Custom Batch 2' );
2012-12-02 01:14:02 -08:00
break ;
}
2018-08-18 14:13:10 -07:00
return null ;
2012-12-02 01:14:02 -08:00
}
" ;
}
2018-08-18 14:13:10 -07:00
foreach ( $_POST [ 'pluginPrefs' ] as $fld => $val )
{
if ( varset ( $val [ 'type' ]) !== 'method' || empty ( $val [ 'index' ]))
{
continue ;
}
$index = $tp -> filter ( $val [ 'index' ]);
$text .= "
// Custom Method/Function (pref)
function " . $index . " ( \ $curVal , \ $mode )
{
switch ( \ $mode )
{
case 'write' : // Edit Page
return \ $this -> text ( '".$index."' , \ $curVal , 255 , 'size=large' );
break ;
}
return null ;
}
" ;
}
2012-12-02 01:14:02 -08:00
$text .= "
}
" ;
2013-05-18 18:23:24 -07:00
$tableCount ++ ;
2012-12-02 01:14:02 -08:00
} // End LOOP.
$text .= '
2015-04-08 16:24:58 -07:00
new '.$thePlugin.' _adminArea ();
2012-12-02 01:14:02 -08:00
require_once ( e_ADMIN . " auth.php " );
e107 :: getAdminUI () -> runPage ();
require_once ( e_ADMIN . " footer.php " );
exit ;
' ;
// ******************************** END GENERATION AREA *************************************************
$ns = e107 :: getRender ();
$mes = e107 :: getMessage ();
$generatedFile = e_PLUGIN . $thePlugin . " /admin_config.php " ;
$startPHP = chr ( 60 ) . " ?php " ;
2018-08-18 14:13:10 -07:00
$endPHP = '' ;
2016-04-11 12:49:45 -07:00
if ( ! empty ( $addonResults ))
{
foreach ( $addonResults as $v )
{
$mes -> addSuccess ( $v );
}
}
2017-11-02 19:44:48 -07:00
if ( file_exists ( $generatedFile ) && empty ( $this -> createFiles ))
{
$message = e107 :: getParser () -> lanVars ( EPL_ADLAN_256 , " admin_config.php " );
$mes -> addSuccess ( $message );
}
else
2012-12-02 01:14:02 -08:00
{
2013-04-15 14:08:54 -07:00
if ( file_put_contents ( $generatedFile , $startPHP . $text . $endPHP ))
{
2017-02-08 17:37:24 -08:00
$message = str_replace ( " [x] " , " <a class='alert-link' href=' " . $generatedFile . " '> " . EPL_ADLAN_216 . " </a> " , EPL_ADLAN_217 );
2015-05-01 17:54:44 +02:00
$mes -> addSuccess ( $message );
2013-04-15 14:08:54 -07:00
}
else
{
2015-05-07 10:55:44 +02:00
$mes -> addError ( str_replace ( '[x]' , $generatedFile , EPL_ADLAN_218 ));
2013-04-15 14:08:54 -07:00
}
}
2016-04-11 12:49:45 -07:00
2017-02-07 14:54:02 -08:00
// echo $mes->render();
$ret = " <h3>plugin.xml</h3> " ;
$ret .= " <pre style='font-size:80%'> " . $xmlText . " </pre> " ;
$ret .= " <h3>admin_config.php</h3> " ;
$ret .= " <pre style='font-size:80%'> " . $text . " </pre> " ;
2018-08-18 14:13:10 -07:00
e107 :: getPlug () -> clearCache ();
2017-02-07 14:54:02 -08:00
return array ( 'caption' => EPL_ADLAN_253 , 'text' => $ret );
2016-04-11 12:49:45 -07:00
2012-12-02 01:14:02 -08:00
}
2018-08-18 14:13:10 -07:00
/**
* @ param array $fields
* @ param string $table
* @ param string $type
* @ return string
*/
private function buildAdminUIBatchFilter ( $fields , $table , $type = 'batch' )
{
$text = '' ;
$typeUpper = ucfirst ( $type );
$params = ( $type === 'batch' ) ? " \$ selected, \$ type " : " \$ type " ;
foreach ( $fields as $fld => $val )
{
if ( varset ( $val [ 'type' ]) !== 'method' )
{
continue ;
}
$text .= "
// Handle ".$type." options as defined in ".str_replace("_ui", "_form_ui", $table)."::".$fld."; 'handle' + action + field + '".$typeUpper."'
// @important \$fields['".$fld."']['".$type."'] must be true for this method to be detected.
// @param \$selected
// @param \$type
function handleList " .eHelper::camelize( $fld ,true). $typeUpper . " ( " . $params . " )
{
" ;
if ( $type === 'filter' )
{
$text .= "
\ $this -> listOrder = '".$fld." ASC' ;
" ;
}
else
{
$text .= "
\ $ids = implode ( ',' , \ $selected ); \n " ;
}
$text .= "
switch ( \ $type )
{
case 'custom".$type."_1' :
" ;
$text .= ( $type === 'batch' ) ? " // do something " : " // return ' " . $fld . " != 'something' '; " ;
$text .= "
e107 :: getMessage () -> addSuccess ( 'Executed custom".$type."_1' );
break ;
case 'custom".$type."_2' :
" ;
$text .= ( $type === 'batch' ) ? " // do something " : " // return ' " . $fld . " != 'something' '; " ;
$text .= "
e107 :: getMessage () -> addSuccess ( 'Executed custom".$type."_2' );
break ;
}
}
" ;
}
return $text ;
}
/**
* @ param array $vars
* @ return null | string | string []
*/
private function buildAdminUIFields ( $vars )
{
$srch = array (
" \n " ,
// "),",
" " ,
" 'forced' => '1' " ,
" 'batch' => '1' " ,
" 'filter' => '1' " ,
" 'batch' => '0' " ,
" 'filter' => '0' " ,
" 'inline' => '1' " ,
" 'validate' => '1' " ,
2020-11-18 14:17:26 -08:00
" 'readonly' => '1' " ,
2018-08-18 14:13:10 -07:00
// ", 'fieldpref' => '1'",
" 'type' => '' " ,
" 'data' => '' " ,
" array ( ) " ,
);
$repl = array (
" " ,
// "),\n\t\t",
" " ,
" 'forced' => true " ,
" 'batch' => true " ,
" 'filter' => true " ,
" 'batch' => false " ,
" 'filter' => false " ,
" 'inline' => true " ,
" 'validate' => true " ,
2020-11-18 14:17:26 -08:00
" 'readonly' => true " ,
2018-08-18 14:13:10 -07:00
// "",
" 'type' => null " ,
" 'data' => null " ,
" array () "
);
foreach ( $vars [ 'fields' ] as $key => $val )
{
if (( $val [ 'type' ] === 'dropdown' || $val [ 'type' ] === 'method' ) && empty ( $val [ 'filter' ]))
{
$vars [ 'fields' ][ $key ][ 'filter' ] = '0' ;
}
if (( $val [ 'type' ] === 'dropdown' || $val [ 'type' ] === 'method' ) && empty ( $val [ 'batch' ]))
{
$vars [ 'fields' ][ $key ][ 'batch' ] = '0' ;
}
if ( $val [ 'type' ] == 'image' && empty ( $val [ 'readParms' ]))
{
$vars [ 'fields' ][ $key ][ 'readParms' ] = 'thumb=80x80' ; // provide a thumbnail preview by default.
}
if ( empty ( $vars [ 'fields' ][ $key ][ 'readParms' ]))
{
$vars [ 'fields' ][ $key ][ 'readParms' ] = array ();
}
if ( empty ( $vars [ 'fields' ][ $key ][ 'writeParms' ]))
{
$vars [ 'fields' ][ $key ][ 'writeParms' ] = array ();
}
unset ( $vars [ 'fields' ][ $key ][ 'fieldpref' ]);
}
$FIELDS = " array ( \n " ;
foreach ( $vars [ 'fields' ] as $key => $val )
{
2021-03-02 08:33:27 -08:00
$FIELDS .= " \t \t \t ' " . str_pad ( $key . " ' " , 25 , " " ) . " => " . str_replace ( $srch , $repl , var_export ( $val , true )) . " , \n " ;
2018-08-18 14:13:10 -07:00
}
$FIELDS .= " \t \t ) " ;
// $FIELDS = var_export($vars['fields'],true);
// $FIELDS = str_replace($srch,$repl,var_export($vars['fields'],true));
$FIELDS = preg_replace ( " #('([A-Z0-9_]*?LAN[_A-Z0-9]*)')# " , " $ 2 " , $FIELDS ); // remove quotations from LANs.
return $FIELDS ;
}
2019-02-01 13:10:15 +01:00
}