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
*
*/
2006-12-02 04:36:16 +00:00
require_once ( " ../class2.php " );
2010-06-23 10:21:21 +00:00
if ( ! getperms ( " Z " ))
2008-12-10 22:39:43 +00:00
{
2006-12-02 04:36:16 +00:00
header ( " location: " . e_BASE . " index.php " );
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 );
2013-05-01 00:55:32 -07:00
define ( 'PLUGIN_SCAN_INTERVAL' , 360 );
2009-07-07 02:22:57 +00:00
global $user_pref ;
2006-12-02 04:36:16 +00:00
require_once ( e_HANDLER . 'plugin_class.php' );
require_once ( e_HANDLER . 'file_class.php' );
2013-05-19 18:38:27 +03:00
$plugin = new e107plugin ;
$pman = new pluginManager ;
define ( " e_PAGETITLE " , ADLAN_98 . " - " . $pman -> pagetitle );
2013-02-27 17:18:33 +01:00
2013-05-19 18:38:27 +03:00
if ( e_AJAX_REQUEST && isset ( $_GET [ 'action' ])) // Ajax
{
if ( $_GET [ 'action' ] == 'download' )
{
$string = base64_decode ( $_GET [ 'src' ]);
parse_str ( $string , $p );
$mp = $pman -> getMarketplace ();
$mp -> generateAuthKey ( $e107SiteUsername , $e107SiteUserpass );
// Server flush useless. It's ajax ready state 4, we can't flush (sadly) before that (at least not for all browsers)
echo " <pre>Connecting... \n " ; flush (); // FIXME change the modal default label, default is Loading...
// download and flush
$mp -> download ( $p [ 'plugin_id' ], $p [ 'plugin_mode' ], 'plugin' );
echo " </pre> " ; flush ();
}
/* $string = base64_decode ( $_GET [ 'src' ]);
parse_str ( $string , $p );
$remotefile = $p [ 'plugin_url' ];
$localfile = md5 ( $remotefile . time ()) . " .zip " ;
$status = " Downloading... " ;
$fl = e107 :: getFile ();
$fl -> setAuthKey ( $e107SiteUsername , $e107SiteUserpass );
$fl -> download ( $remotefile , 'plugin' ); */
exit ;
}
2009-07-07 02:22:57 +00:00
2012-07-29 02:36:18 +00:00
if ( isset ( $_POST [ 'uninstall_cancel' ]))
{
header ( " location: " . e_SELF );
exit ;
}
2009-07-07 02:22:57 +00:00
2013-03-05 06:11:05 -08: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 )
{
return ( $plugURL ) ? " <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' /> " : E_32_CAT_PLUG ;
$conf_file = " # " ;
$conf_title = " " ;
if ( $this -> plug_vars [ 'administration' ][ 'configFile' ] && $this -> plug [ 'plugin_installflag' ] == true )
{
$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' title=' { $conf_title } ' href=' { $conf_file } ' > " . ADMIN_CONFIGURE_ICON . " </a> " ;
}
$text = " <div class='btn-group'> " ;
$text .= vartrue ( $plugin_config_icon );
if ( $this -> plug_vars [ '@attributes' ][ 'installRequired' ])
{
if ( $this -> plug [ 'plugin_installflag' ])
{
$text .= ( $this -> plug [ 'plugin_installflag' ] ? " <a class='btn' 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 ( PLUGIN_SHOW_REFRESH && ! varsettrue ( $this -> plug_vars [ 'plugin_php' ]))
{
$text .= " <br /><br /><input type='button' class='btn button' onclick= \" location.href=' " . e_SELF . " ?refresh. { $this -> plug [ 'plugin_id' ] } ' \" title=' " . 'Refresh plugin settings' . " ' value=' " . 'Refresh plugin settings' . " ' /> " ;
}
}
else
{
2013-04-26 13:48:23 -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."' />";
2013-03-05 06:11:05 -08:00
// $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' href= \" " . e_SELF . " ?install. { $this -> plug [ 'plugin_id' ] } \" title=' " . EPL_ADLAN_0 . " ' > " . ADMIN_INSTALLPLUGIN_ICON . " </a> " ;
}
}
else
{
if ( $this -> plug_vars [ 'menuName' ])
{
$text .= EPL_NOINSTALL . str_replace ( " .. " , " " , e_PLUGIN . $this -> plug [ 'plugin_path' ]) . " / " . EPL_DIRECTORY ;
}
else
{
$text .= EPL_NOINSTALL_1 . str_replace ( " .. " , " " , e_PLUGIN . $this -> plug [ 'plugin_path' ]) . " / " . EPL_DIRECTORY ;
if ( $this -> plug [ 'plugin_installflag' ] == false )
{
e107 :: getDb () -> db_Delete ( 'plugin' , " plugin_installflag=0 AND (plugin_path=' { $this -> plug [ 'plugin_path' ] } ' OR plugin_path=' { $this -> plug [ 'plugin_path' ] } /' ) " );
}
}
}
if ( $this -> plug [ 'plugin_version' ] != $this -> plug_vars [ '@attributes' ][ 'version' ] && $this -> plug [ 'plugin_installflag' ])
{
2013-04-26 13:48:23 -07:00
// $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."' />";
2013-03-05 06:11:05 -08:00
$text .= " <a class='btn' href=' " . e_SELF . " ?upgrade. { $this -> plug [ 'plugin_id' ] } ' title= \" " . EPL_UPGRADE . " to v " . $this -> plug_vars [ '@attributes' ][ 'version' ] . " \" > " . ADMIN_UPGRADEPLUGIN_ICON . " </a> " ;
}
$text .= " </div> " ;
return $text ;
}
}
2009-08-14 21:11:49 +00:00
require_once ( " auth.php " );
$pman -> pluginObserver ();
2013-02-27 17:18:33 +01:00
$mes = e107 :: getMessage ();
$frm = e107 :: getForm ();
2006-12-02 04:36:16 +00:00
2013-04-17 15:22:47 -07:00
function e_help ()
{
return array (
'caption' => " Scan for Changes " ,
'text' => " Plugin folders are scanned every " . ( PLUGIN_SCAN_INTERVAL / 60 ) . " minutes for changes. Click the button below to scan now.
< p >< a class = 'btn btn-mini btn-primary' href = '".e_SELF."?refresh' > Refresh </ a ></ p > "
);
}
2009-07-07 02:22:57 +00:00
require_once ( " footer.php " );
exit ;
2006-12-02 04:36:16 +00:00
2013-03-05 06:11:05 -08:00
2012-01-06 09:49:08 +00:00
// FIXME switch to admin UI
2009-07-07 02:22:57 +00:00
class pluginManager {
2008-12-10 22:39:43 +00:00
2009-07-07 02:22:57 +00:00
var $plugArray ;
var $action ;
var $id ;
var $frm ;
var $fieldpref ;
2013-05-03 21:34:59 -07:00
var $titlearray = array ();
2009-08-14 21:11:49 +00:00
var $pagetitle ;
2013-05-17 15:41:02 +03:00
/**
* Marketplace handler instance
* @ var e_marketplace
*/
var $mp ;
2013-05-03 21:34:59 -07:00
2013-03-05 06:11:05 -08:00
protected $pid = 'plugin_id' ;
protected $fields = array (
" checkboxes " => array ( " title " => " " , 'type' => null , " forced " => TRUE , " width " => " 3% " , 'thclass' => 'center' , 'class' => 'center' ),
" plugin_icon " => array ( " title " => EPL_ADLAN_82 , " type " => " icon " , " width " => " 5% " , " thclass " => " middle center " , 'class' => 'center' , " url " => " " ),
" plugin_name " => array ( " title " => EPL_ADLAN_10 , 'forced' => true , " type " => " text " , " width " => " auto " , 'class' => 'left' , " thclass " => " middle " , " url " => " " ),
" plugin_version " => array ( " title " => EPL_ADLAN_11 , " type " => " numeric " , " width " => " 5% " , " thclass " => " middle " , " url " => " " ),
2013-05-06 05:19:20 -07:00
" plugin_date " => array ( " title " => " Released " , " type " => " text " , " width " => " 8% " , " thclass " => " middle " ),
2013-03-05 06:11:05 -08:00
" plugin_folder " => array ( " title " => EPL_ADLAN_64 , " type " => " text " , " width " => " 10% " , " thclass " => " middle " ),
" plugin_category " => array ( " title " => LAN_CATEGORY , " type " => " text " , " width " => " auto " , " thclass " => " middle " ),
" plugin_author " => array ( " title " => EPL_ADLAN_12 , " type " => " text " , " width " => " 10% " , " thclass " => " middle " ),
2013-05-06 05:19:20 -07:00
" plugin_price " => array ( " title " => " Price " , 'nolist' => true , " forced " => true , " type " => " text " , " width " => " 5% " , " thclass " => " left " ),
" plugin_compatible " => array ( " title " => EPL_ADLAN_13 , " type " => " text " , " width " => " 5% " , " thclass " => " middle " ),
2013-03-05 06:11:05 -08:00
" plugin_description " => array ( " title " => EPL_ADLAN_14 , " type " => " bbarea " , " width " => " 30% " , " thclass " => " middle center " , 'readParms' => 'expand=1&truncate=180&bb=1' ),
" plugin_compliant " => array ( " title " => EPL_ADLAN_81 , " type " => " text " , " width " => " 5% " , " thclass " => " middle center " , " url " => " " ),
// "plugin_release" => array("title" => EPL_ADLAN_81, "type"=>"text", "width" => "5%", "thclass" => "middle center", "url" => ""),
// "plugin_notes" => array("title" => EPL_ADLAN_83, "type"=>"url", "width" => "5%", "thclass" => "middle center", "url" => ""),
2013-03-29 04:47:01 -07:00
" options " => array ( " title " => LAN_OPTIONS , 'forced' => TRUE , 'type' => 'method' , " width " => " 15% " , " thclass " => " right last " , 'class' => 'right' ),
2013-03-05 06:11:05 -08:00
);
2008-12-10 22:39:43 +00:00
2013-05-03 21:34:59 -07:00
function __construct ()
2008-01-26 04:47:27 +00:00
{
2009-08-14 21:11:49 +00:00
global $user_pref , $admin_log ;
2009-07-07 02:22:57 +00:00
$tmp = explode ( '.' , e_QUERY );
2009-07-09 02:47:17 +00:00
$this -> action = ( $tmp [ 0 ]) ? $tmp [ 0 ] : " installed " ;
2009-07-14 03:18:17 +00:00
$this -> id = varset ( $tmp [ 1 ]) ? intval ( $tmp [ 1 ]) : " " ;
2009-08-14 21:11:49 +00:00
$this -> titlearray = array ( 'installed' => EPL_ADLAN_22 , 'avail' => EPL_ADLAN_23 , 'upload' => EPL_ADLAN_38 );
2012-07-24 00:42:17 +00:00
if ( isset ( $_GET [ 'mode' ]))
{
$this -> action = $_GET [ 'mode' ];
}
2009-08-14 21:11:49 +00:00
2013-05-06 05:19:20 -07:00
if ( $this -> action == 'online' )
{
$this -> fields [ " plugin_price " ][ 'nolist' ] = false ; // = array("title" => "Price", "forced"=>true, "type"=>"text", "width" => "5%", "thclass" => "middle center");
}
2009-08-14 21:11:49 +00:00
$keys = array_keys ( $this -> titlearray );
$this -> pagetitle = ( in_array ( $this -> action , $keys )) ? $this -> titlearray [ $this -> action ] : $this -> titlearray [ 'installed' ];
2009-07-07 02:22:57 +00:00
2009-07-07 06:26:51 +00:00
/* if ( isset ( $_POST [ 'uninstall-selected' ]))
2008-01-26 04:47:27 +00:00
{
2013-03-05 06:11:05 -08:00
foreach ( $_POST [ 'checkboxes' ] as $val )
2009-07-07 06:26:51 +00:00
{
$this -> id = intval ( $val );
$this -> pluginUninstall ();
}
$this -> action = " installed " ;
2009-07-07 02:22:57 +00:00
$this -> pluginRenderList ();
2009-07-07 06:26:51 +00:00
return ;
// Complicated, as each uninstall system is different.
} */
2009-07-07 02:22:57 +00:00
2013-05-03 21:34:59 -07:00
}
2009-07-07 02:22:57 +00:00
2013-05-19 18:38:27 +03:00
/**
* Temporary , e107 :: getMarketplace () coming soon
* @ return e_marketplace
*/
public function getMarketplace ()
{
if ( null === $this -> mp )
{
require_once ( e_HANDLER . 'e_marketplace.php' );
2013-05-19 18:58:17 +03:00
$this -> mp = new e_marketplace (); // autodetect the best method
2013-05-19 18:38:27 +03:00
}
return $this -> mp ;
}
2009-08-14 21:11:49 +00:00
function pluginObserver ()
{
2010-06-23 10:21:21 +00:00
2009-08-14 21:11:49 +00:00
global $user_pref , $admin_log ;
if ( isset ( $_POST [ 'upload' ]))
2009-07-09 02:47:17 +00:00
{
2009-08-14 21:11:49 +00:00
$this -> pluginProcessUpload ();
2009-07-09 02:47:17 +00:00
}
2009-07-13 09:31:19 +00:00
2009-11-05 17:32:19 +00:00
if ( isset ( $_POST [ 'etrigger_ecolumns' ]))
2009-08-14 21:11:49 +00:00
{
$user_pref [ 'admin_pluginmanager_columns' ] = $_POST [ 'e-columns' ];
save_prefs ( 'user' );
}
2009-07-09 02:47:17 +00:00
2013-03-05 06:11:05 -08:00
$user_pref [ 'admin_pluginmanager_columns' ] = false ;
2013-05-06 05:19:20 -07:00
$this -> fieldpref = ( vartrue ( $user_pref [ 'admin_pluginmanager_columns' ])) ? $user_pref [ 'admin_pluginmanager_columns' ] : array ( " plugin_icon " , " plugin_name " , " plugin_version " , " plugin_date " , " plugin_description " , " plugin_category " , " plugin_compatible " , " plugin_author " , " plugin_website " , " plugin_notes " );
2009-07-09 02:47:17 +00:00
2009-07-07 06:26:51 +00:00
2013-05-06 05:19:20 -07:00
foreach ( $this -> fields as $key => $val )
{
if ( $val [ 'forced' ] == true && substr ( $key , 0 , 6 ) == 'plugin' )
{
$this -> fieldpref [] = $key ;
}
}
2009-07-09 02:47:17 +00:00
2009-08-14 21:11:49 +00:00
if ( $this -> action == 'avail' || $this -> action == 'installed' ) // Plugin Check is done during upgrade_routine.
{
$this -> pluginCheck ();
}
2009-07-09 02:47:17 +00:00
2009-08-14 21:11:49 +00:00
if ( $this -> action == " uninstall " )
{
$this -> pluginUninstall ();
2013-05-01 00:55:32 -07:00
$this -> pluginCheck ( true ); // forced
2008-01-26 04:47:27 +00:00
}
2013-04-17 15:22:47 -07:00
if ( $this -> action == " refresh " )
{
$this -> pluginCheck ( true ); // forced
}
2009-07-07 02:22:57 +00:00
2013-04-17 15:22:47 -07:00
if ( $this -> action == " install " || $this -> action == " refresh " )
2008-01-26 04:47:27 +00:00
{
2009-07-07 02:22:57 +00:00
$this -> pluginInstall ();
$this -> action = " installed " ;
}
2012-12-02 01:14:02 -08:00
if ( $this -> action == 'create' )
{
2012-12-02 18:12:46 -08:00
$pc = new pluginBuilder ;
2012-12-02 01:14:02 -08:00
return ;
}
2009-07-07 06:26:51 +00:00
2009-07-07 02:22:57 +00:00
if ( $this -> action == " upgrade " )
{
$this -> pluginUpgrade ();
$this -> action = " installed " ;
2006-12-02 04:36:16 +00:00
}
2009-07-07 02:22:57 +00:00
if ( $this -> action == " refresh " )
{
$this -> pluginRefresh ();
}
if ( $this -> action == " upload " )
2008-01-26 04:47:27 +00:00
{
2009-07-07 02:22:57 +00:00
$this -> pluginUpload ();
}
2012-07-20 07:31:16 +00:00
if ( $this -> action == " online " )
{
$this -> pluginOnline ();
return ;
}
2013-03-05 06:11:05 -08:00
// print_a($_POST);
2009-07-07 06:26:51 +00:00
2009-07-09 02:47:17 +00:00
if ( isset ( $_POST [ 'install-selected' ]))
{
2013-03-05 06:11:05 -08:00
foreach ( $_POST [ 'multiselect' ] as $val )
2009-07-09 02:47:17 +00:00
{
$this -> id = intval ( $val );
$this -> pluginInstall ();
}
$this -> action = " installed " ;
}
2010-06-23 10:21:21 +00:00
2013-03-05 06:11:05 -08:00
if ( $this -> action != 'avail' && varset ( $this -> fields [ 'checkboxes' ]))
2009-07-07 06:26:51 +00:00
{
2013-03-05 06:11:05 -08:00
unset ( $this -> fields [ 'checkboxes' ]); // = FALSE;
2009-07-07 06:26:51 +00:00
}
2009-07-09 02:47:17 +00:00
if ( $this -> action != 'upload' && $this -> action != 'uninstall' )
2009-07-07 06:26:51 +00:00
{
$this -> pluginRenderList ();
}
2010-06-23 10:21:21 +00:00
2009-08-14 21:11:49 +00:00
}
2012-07-20 07:31:16 +00:00
2013-03-05 01:38:46 -08:00
private function compatibilityLabel ( $val = '' )
{
$badge = ( vartrue ( $val ) > 1.9 ) ? " <span class='label label-warning'>Made for v2</span> " : '1.x' ;
return $badge ;
}
2012-07-20 07:31:16 +00:00
function pluginOnline ()
{
2013-05-17 15:41:02 +03:00
global $plugin , $e107SiteUsername , $e107SiteUserpass ;
2012-07-24 00:42:17 +00:00
$tp = e107 :: getParser ();
$frm = e107 :: getForm ();
2012-07-20 07:31:16 +00:00
$caption = " Search Online " ;
$e107 = e107 :: getInstance ();
$xml = e107 :: getXml ();
2012-07-23 10:25:45 +00:00
$mes = e107 :: getMessage ();
2013-03-04 03:39:27 -08:00
// $mes->addWarning("Some older plugins may produce unpredictable results.");
2013-05-14 22:42:06 +02:00
// check for cURL
if ( ! function_exists ( curl_init ))
{
$mes -> addWarning ( " cURL is currently required to use this feature. Contact your webhosting provider to enable cURL " ); // TODO LAN?
}
2013-05-17 15:41:02 +03: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 ;
2013-03-03 23:42:37 -08:00
$srch = preg_replace ( '/[^\w]/' , '' , vartrue ( $_GET [ 'srch' ]));
2013-05-17 15:41:02 +03:00
2013-05-19 18:38:27 +03:00
$mp = $this -> getMarketplace ();
2013-05-17 15:41:02 +03:00
// auth
2013-05-19 18:38:27 +03:00
$mp -> generateAuthKey ( $e107SiteUsername , $e107SiteUserpass );
2013-05-17 15:41:02 +03:00
// do the request, retrieve and parse data
2013-05-19 18:38:27 +03:00
$xdata = $mp -> call ( 'getList' , array (
2013-05-17 15:41:02 +03:00
'type' => 'plugin' ,
'params' => array ( 'limit' => 10 , 'search' => $srch , 'from' => $from )
));
$total = $xdata [ 'params' ][ 'count' ];
// OLD BIT OF CODE ------------------------------->
/*
2012-07-24 00:42:17 +00:00
// $file = SITEURLBASE.e_PLUGIN_ABS."release/release.php"; // temporary testing
2013-03-04 03:39:27 -08:00
$file = " http://e107.org/feed?type=plugin&frm= " . $from . " &srch= " . $srch . " &limit=10 " ;
2012-07-20 07:31:16 +00:00
$xml -> setOptArrayTags ( 'plugin' ); // make sure 'plugin' tag always returns an array
$xdata = $xml -> loadXMLfile ( $file , 'advanced' );
2013-05-17 15:41:02 +03:00
$total = $xdata [ '@attributes' ][ 'total' ]; */
// OLD BIT OF CODE END ------------------------------->
2012-07-24 00:42:17 +00:00
2013-05-17 15:41:02 +03:00
2012-07-24 00:42:17 +00:00
$c = 1 ;
2013-05-17 15:41:02 +03:00
foreach ( $xdata [ 'data' ] as $row )
2012-07-20 07:31:16 +00:00
{
2013-05-17 15:41:02 +03:00
//$row = $r['@attributes'];
2012-07-20 07:31:16 +00:00
2013-05-06 05:19:20 -07:00
$badge = $this -> compatibilityLabel ( $row [ 'compatibility' ]);;
$featured = ( $row [ 'featured' ] == 1 ) ? " <span class='label label-info'>Featured</span> " : '' ;
$price = ( $row [ 'price' ] > 0 ) ? " <span class='label label-success'> " . $row [ 'price' ] . " credits</span> " : " <span class='label label-success'>Free</span> " ;
2013-03-03 23:42:37 -08:00
2012-07-20 07:31:16 +00:00
$data [] = array (
2013-05-19 18:38:27 +03:00
'plugin_id' => $row [ 'params' ][ 'id' ],
'plugin_mode' => $row [ 'params' ][ 'mode' ],
2012-07-24 00:42:17 +00:00
'plugin_icon' => vartrue ( $row [ 'icon' ], e_IMAGE . " admin_images/plugins_32.png " ),
2013-05-19 18:38:27 +03:00
'plugin_name' => stripslashes ( $row [ 'name' ]),
'plugin_featured' => $featured ,
2012-07-20 07:31:16 +00:00
'plugin_folder' => $row [ 'folder' ],
2012-07-24 00:42:17 +00:00
'plugin_date' => vartrue ( $row [ 'date' ]),
2013-05-17 15:41:02 +03:00
'plugin_category' => vartrue ( $row [ 'category' ], 'n/a' ),
2012-07-20 07:31:16 +00:00
'plugin_author' => vartrue ( $row [ 'author' ]),
2012-07-24 00:42:17 +00:00
'plugin_version' => $row [ 'version' ],
2013-05-17 15:41:02 +03:00
'plugin_description' => nl2br ( vartrue ( $row [ 'description' ])),
2013-03-03 23:42:37 -08:00
'plugin_compatible' => $badge ,
2012-07-24 00:42:17 +00:00
2012-07-20 07:31:16 +00:00
'plugin_website' => vartrue ( $row [ 'authorUrl' ]),
2013-05-19 18:38:27 +03:00
//'plugin_url' => $row['url'],
2013-05-06 05:19:20 -07:00
'plugin_notes' => '' ,
'plugin_price' => $price
);
2012-07-24 00:42:17 +00:00
$c ++ ;
2012-07-20 07:31:16 +00:00
}
2013-05-17 15:41:02 +03:00
2012-07-24 00:42:17 +00:00
$fieldList = $this -> fields ;
2013-03-05 06:11:05 -08:00
unset ( $fieldList [ 'checkboxes' ]);
2013-05-17 15:41:02 +03:00
2012-07-20 07:31:16 +00:00
$text = "
2013-05-06 20:47:46 -07:00
< form class = 'form-search' action = '".e_SELF."?".e_QUERY."' id = 'core-plugin-list-form' method = 'get' >
2013-05-03 21:34:59 -07:00
< div class = 'e-search' > " . $frm->search ('srch', $srch , 'go', $filterName , $filterArray , $filterVal ). $frm->hidden ('mode','online'). "
</ div >
2013-03-03 23:42:37 -08:00
</ form >
2013-05-03 21:34:59 -07:00
2012-07-20 07:31:16 +00:00
< form action = '".e_SELF."?".e_QUERY."' id = 'core-plugin-list-form' method = 'post' >
2013-03-03 23:42:37 -08:00
< fieldset class = 'e-filter' id = 'core-plugin-list' >
2012-07-20 07:31:16 +00:00
< legend class = 'e-hideme' > " . $caption . " </ legend >
2013-03-03 23:42:37 -08:00
2013-03-04 02:47:51 -08:00
< table id = core - plugin - list ' class=' table adminlist ' >
2012-07-24 00:42:17 +00:00
" . $frm->colGroup ( $fieldList , $this->fieldpref ).
$frm -> thead ( $fieldList , $this -> fieldpref ) . "
2012-07-20 07:31:16 +00:00
< tbody >
" ;
2012-07-24 00:42:17 +00:00
2012-07-20 07:31:16 +00:00
foreach ( $data as $key => $val )
{
2012-07-24 00:42:17 +00:00
// print_a($val);
2012-07-20 07:31:16 +00:00
$text .= " <tr> " ;
2012-07-24 00:42:17 +00:00
foreach ( $this -> fields as $v => $foo )
2012-07-20 07:31:16 +00:00
{
2013-03-05 06:11:05 -08:00
if ( ! in_array ( $v , $this -> fieldpref ) || $v == 'checkboxes' )
2012-07-24 00:42:17 +00:00
{
continue ;
}
2013-05-19 18:38:27 +03:00
$_value = $val [ $v ];
if ( $v == 'plugin_name' ) $_value .= $val [ 'plugin_featured' ];
2012-07-24 00:42:17 +00:00
// echo '<br />v='.$v;
2013-05-19 18:38:27 +03:00
$text .= " <td style='height: 40px' class=' " . vartrue ( $this -> fields [ $v ][ 'class' ], 'left' ) . " '> " . $frm -> renderValue ( $v , $_value , $this -> fields [ $v ], $key ) . " </td> \n " ;
2012-07-20 07:31:16 +00:00
}
$text .= " <td class='center'> " . $this -> options ( $val ) . " </td> " ;
$text .= " </tr> " ;
}
$text .= "
</ tbody >
</ table > " ;
$text .= "
</ fieldset >
</ form >
" ;
2012-07-24 00:42:17 +00:00
$amount = 30 ;
2012-07-20 07:31:16 +00:00
2012-07-24 00:42:17 +00:00
if ( $total > $amount )
{
$parms = $total . " , " . $amount . " , " . $from . " , " . e_SELF . '?mode=' . $_GET [ 'mode' ] . '&frm=[FROM]' ;
$text .= " <div style='text-align:center;margin-top:10px'> " . $tp -> parseTemplate ( " { NEXTPREV= $parms } " , TRUE ) . " </div> " ;
}
2013-02-22 21:34:06 -08:00
e107 :: getRender () -> tablerender ( ADLAN_98 . SEP . $caption , $mes -> render () . $text );
2012-07-20 07:31:16 +00:00
}
function options ( $data )
2013-05-03 21:34:59 -07:00
{
// print_a($data);
2013-06-06 15:07:59 +02:00
/*
2013-05-03 21:34:59 -07:00
if ( ! e107 :: getFile () -> hasAuthKey ())
{
// return "<a href='".e_SELF."' class='btn btn-primary e-modal' >Download and Install</a>";
}
2013-06-06 15:07:59 +02:00
*/
2013-05-03 21:34:59 -07:00
2012-07-20 07:31:16 +00:00
$d = http_build_query ( $data , false , '&' );
2013-05-19 18:38:27 +03:00
//$url = e_SELF."?src=".base64_encode($d);
$url = e_SELF . '?action=download&src=' . base64_encode ( $d ); //$url.'&action=download';
2013-05-03 21:34:59 -07:00
$id = 'plug_' . $data [ 'plugin_id' ];
2013-05-19 18:38:27 +03:00
//<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>
$dicon = " <a data-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> " ;
2012-07-24 00:42:17 +00:00
return " <div id=' { $id } ' style='vertical-align:middle'>
2013-05-19 18:38:27 +03:00
{ $dicon }
2012-07-24 00:42:17 +00:00
</ div > " ;
2012-07-20 07:31:16 +00:00
}
2012-01-06 09:49:08 +00:00
// FIXME - move it to plugin handler, similar to install_plugin() routine
2009-07-07 02:22:57 +00:00
function pluginUninstall ()
{
2012-01-06 09:49:08 +00:00
$pref = e107 :: getPref ();
$admin_log = e107 :: getAdminLog ();
$plugin = e107 :: getPlugin ();
$tp = e107 :: getParser ();
$sql = e107 :: getDb ();
2012-01-11 14:54:47 +00:00
$eplug_folder = '' ;
2009-07-07 02:22:57 +00:00
if ( ! isset ( $_POST [ 'uninstall_confirm' ]))
{ // $id is already an integer
$this -> pluginConfirmUninstall ( $this -> id );
2009-07-09 02:47:17 +00:00
return ;
2006-12-02 04:36:16 +00:00
}
2009-07-07 02:22:57 +00:00
$plug = $plugin -> getinfo ( $this -> id );
$text = '' ;
//Uninstall Plugin
if ( $plug [ 'plugin_installflag' ] == TRUE )
2008-01-26 04:47:27 +00:00
{
2009-09-23 23:18:18 +00:00
$eplug_folder = $plug [ 'plugin_path' ];
2009-07-07 02:22:57 +00:00
$_path = e_PLUGIN . $plug [ 'plugin_path' ] . '/' ;
2010-06-23 10:21:21 +00:00
2009-07-07 02:22:57 +00:00
if ( file_exists ( $_path . 'plugin.xml' ))
2010-06-23 10:21:21 +00:00
{
unset ( $_POST [ 'uninstall_confirm' ]);
2009-10-30 09:13:37 +00:00
$text .= $plugin -> install_plugin_xml ( $this -> id , 'uninstall' , $_POST ); //$_POST must be used.
2008-01-26 04:47:27 +00:00
}
else
2009-09-21 20:57:55 +00:00
{ // Deprecated - plugin uses plugin.php
2009-07-07 02:22:57 +00:00
include ( e_PLUGIN . $plug [ 'plugin_path' ] . '/plugin.php' );
2009-09-23 23:18:18 +00:00
2009-07-07 02:22:57 +00:00
$func = $eplug_folder . '_uninstall' ;
if ( function_exists ( $func ))
{
$text .= call_user_func ( $func );
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
if ( $_POST [ 'delete_tables' ])
{
if ( is_array ( $eplug_table_names ))
{
$result = $plugin -> manage_tables ( 'remove' , $eplug_table_names );
if ( $result !== TRUE )
{
$text .= EPL_ADLAN_27 . ' <b>' . $mySQLprefix . $result . '</b> - ' . EPL_ADLAN_30 . '<br />' ;
}
else
{
$text .= EPL_ADLAN_28 . " <br /> " ;
}
}
}
else
{
$text .= EPL_ADLAN_49 . " <br /> " ;
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
if ( is_array ( $eplug_prefs ))
{
$plugin -> manage_prefs ( 'remove' , $eplug_prefs );
$text .= EPL_ADLAN_29 . " <br /> " ;
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
if ( is_array ( $eplug_comment_ids ))
{
$text .= ( $plugin -> manage_comments ( 'remove' , $eplug_comment_ids )) ? EPL_ADLAN_50 . " <br /> " : " " ;
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
if ( is_array ( $eplug_array_pref ))
{
foreach ( $eplug_array_pref as $key => $val )
{
$plugin -> manage_plugin_prefs ( 'remove' , $key , $eplug_folder , $val );
}
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
if ( $eplug_menu_name )
{
2009-09-21 20:57:55 +00:00
$sql -> db_Delete ( 'menus' , " menu_name=' { $eplug_menu_name } ' " );
2009-07-07 02:22:57 +00:00
}
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
if ( $eplug_link )
2008-02-02 22:04:18 +00:00
{
2009-07-07 02:22:57 +00:00
$plugin -> manage_link ( 'remove' , $eplug_link_url , $eplug_link_name );
2008-02-02 22:04:18 +00:00
}
2009-07-07 02:22:57 +00:00
if ( $eplug_userclass )
2008-02-02 22:04:18 +00:00
{
2009-07-07 02:22:57 +00:00
$plugin -> manage_userclass ( 'remove' , $eplug_userclass );
2008-02-02 22:04:18 +00:00
}
2009-07-07 02:22:57 +00:00
2013-03-03 23:42:37 -08:00
$sql -> update ( 'plugin' , " plugin_installflag=0, plugin_version=' { $eplug_version } ' WHERE plugin_id=' { $this -> id } ' " );
2009-07-07 02:22:57 +00:00
$plugin -> manage_search ( 'remove' , $eplug_folder );
$plugin -> manage_notify ( 'remove' , $eplug_folder );
2012-01-06 09:49:08 +00:00
// it's done inside install_plugin_xml(), required only here
if ( isset ( $pref [ 'plug_installed' ][ $plug [ 'plugin_path' ]]))
2009-08-14 21:11:49 +00:00
{
2012-01-06 09:49:08 +00:00
unset ( $pref [ 'plug_installed' ][ $plug [ 'plugin_path' ]]);
2009-08-14 21:11:49 +00:00
}
2012-01-06 09:49:08 +00:00
e107 :: getConfig ( 'core' ) -> setPref ( $pref );
$plugin -> rebuildUrlConfig ();
e107 :: getConfig ( 'core' ) -> save ();
2009-07-07 02:22:57 +00:00
}
2012-01-06 09:49:08 +00:00
2014-01-01 18:38:02 -08:00
$logInfo = deftrue ( $plug [ 'plugin_name' ], $plug [ 'plugin_name' ]) . " v " . $plug [ 'plugin_version' ] . " ( { e_PLUGIN} " . $plug [ 'plugin_path' ] . " ) " ;
$admin_log -> log_event ( 'PLUGMAN_03' , $logInfo , E_LOG_INFORMATIVE , '' );
2008-02-02 22:04:18 +00:00
}
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
if ( $_POST [ 'delete_files' ])
2008-02-02 22:04:18 +00:00
{
2009-09-21 20:57:55 +00:00
include_once ( e_HANDLER . 'file_class.php' );
2009-07-07 02:22:57 +00:00
$fi = new e_file ;
$result = $fi -> rmtree ( e_PLUGIN . $eplug_folder );
2009-09-21 20:57:55 +00:00
$text .= ( $result ? '<br />' . EPL_ADLAN_86 . e_PLUGIN . $eplug_folder : '<br />' . EPL_ADLAN_87 . '<br />' . EPL_ADLAN_31 . ' <b>' . e_PLUGIN . $eplug_folder . '</b> ' . EPL_ADLAN_32 );
2008-02-02 22:04:18 +00:00
}
2009-07-07 02:22:57 +00:00
else
2008-02-02 22:04:18 +00:00
{
2009-07-07 02:22:57 +00:00
$text .= '<br />' . EPL_ADLAN_31 . ' <b>' . e_PLUGIN . $eplug_folder . '</b> ' . EPL_ADLAN_32 ;
2008-02-02 22:04:18 +00:00
}
2009-07-07 02:22:57 +00:00
2012-12-23 15:00:15 +00:00
$plugin -> save_addon_prefs ( 'update' );
2009-07-07 06:26:51 +00:00
$this -> show_message ( $text , E_MESSAGE_SUCCESS );
// $ns->tablerender(EPL_ADLAN_1.' '.$tp->toHtml($plug['plugin_name'], "", "defs,emotes_off,no_make_clickable"), $text);
2009-07-07 02:22:57 +00:00
$text = '' ;
2009-09-21 20:57:55 +00:00
$this -> action = 'installed' ;
2009-07-09 02:47:17 +00:00
return ;
2009-07-07 02:22:57 +00:00
}
function pluginProcessUpload ()
{
if ( ! $_POST [ 'ac' ] == md5 ( ADMINPWCHANGE ))
2008-02-02 22:04:18 +00:00
{
2009-07-07 02:22:57 +00:00
exit ;
2008-02-02 22:04:18 +00:00
}
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
extract ( $_FILES );
/* check if e_PLUGIN dir is writable ... */
if ( ! is_writable ( e_PLUGIN ))
2008-02-02 22:04:18 +00:00
{
2009-07-07 02:22:57 +00:00
/* still not writable - spawn error message */
2009-08-14 21:11:49 +00:00
e107 :: getRender () -> tablerender ( EPL_ADLAN_40 , EPL_ADLAN_39 );
2008-02-02 22:04:18 +00:00
}
2009-07-07 02:22:57 +00:00
else
2008-02-02 22:04:18 +00:00
{
2009-07-07 02:22:57 +00:00
/* e_PLUGIN is writable - continue */
require_once ( e_HANDLER . " upload_handler.php " );
$fileName = $file_userfile [ 'name' ][ 0 ];
$fileSize = $file_userfile [ 'size' ][ 0 ];
$fileType = $file_userfile [ 'type' ][ 0 ];
if ( strstr ( $file_userfile [ 'type' ][ 0 ], " gzip " ))
2006-12-02 04:36:16 +00:00
{
2009-07-07 02:22:57 +00:00
$fileType = " tar " ;
}
else if ( strstr ( $file_userfile [ 'type' ][ 0 ], " zip " ))
{
$fileType = " zip " ;
}
else
{
/* not zip or tar - spawn error message */
2009-08-14 21:11:49 +00:00
e107 :: getRender () -> tablerender ( EPL_ADLAN_40 , EPL_ADLAN_41 );
2009-07-07 02:22:57 +00:00
require_once ( " footer.php " );
exit ;
2006-12-02 04:36:16 +00:00
}
2008-10-11 11:55:18 +00:00
2009-07-07 02:22:57 +00:00
if ( $fileSize )
{
$uploaded = file_upload ( e_PLUGIN );
$archiveName = $uploaded [ 0 ][ 'name' ];
/* attempt to unarchive ... */
if ( $fileType == " zip " )
{
require_once ( e_HANDLER . " pclzip.lib.php " );
$archive = new PclZip ( e_PLUGIN . $archiveName );
$unarc = ( $fileList = $archive -> extract ( PCLZIP_OPT_PATH , e_PLUGIN , PCLZIP_OPT_SET_CHMOD , 0666 ));
}
else
{
require_once ( e_HANDLER . " pcltar.lib.php " );
$unarc = ( $fileList = PclTarExtract ( $archiveName , e_PLUGIN ));
}
if ( ! $unarc )
{
/* unarc failed ... */
if ( $fileType == " zip " )
{
$error = EPL_ADLAN_46 . " ' " . $archive -> errorName ( TRUE ) . " ' " ;
}
else
{
$error = EPL_ADLAN_47 . PclErrorString () . " , " . EPL_ADLAN_48 . intval ( PclErrorCode ());
}
2009-08-14 21:11:49 +00:00
e107 :: getRender () -> tablerender ( EPL_ADLAN_40 , EPL_ADLAN_42 . " " . $archiveName . " " . $error );
2009-07-07 02:22:57 +00:00
require_once ( " footer.php " );
exit ;
}
/* ok it looks like the unarc succeeded - continue */
2010-10-21 13:07:40 +00:00
/* get folder name ... */
2013-03-05 06:11:05 -08:00
2009-07-07 02:22:57 +00:00
$folderName = substr ( $fileList [ 0 ][ 'stored_filename' ], 0 , ( strpos ( $fileList [ 0 ][ 'stored_filename' ], " / " )));
if ( file_exists ( e_PLUGIN . $folderName . " /plugin.php " ) || file_exists ( e_PLUGIN . $folderName . " /plugin.xml " ))
{
/* upload is a plugin */
2009-08-14 21:11:49 +00:00
e107 :: getRender () -> tablerender ( EPL_ADLAN_40 , EPL_ADLAN_43 );
2009-07-07 02:22:57 +00:00
}
2010-10-21 13:07:40 +00:00
elseif ( file_exists ( e_PLUGIN . $folderName . " /theme.php " ) || file_exists ( e_PLUGIN . $folderName . " /theme.xml " ))
2009-07-07 02:22:57 +00:00
{
/* upload is a menu */
2009-08-14 21:11:49 +00:00
e107 :: getRender () -> tablerender ( EPL_ADLAN_40 , EPL_ADLAN_45 );
2009-07-07 02:22:57 +00:00
}
2010-10-21 13:07:40 +00:00
else
{
/* upload is unlocatable */
e107 :: getRender () -> tablerender ( EPL_ADLAN_40 , 'Unknown file: ' . $fileList [ 0 ][ 'stored_filename' ]);
}
2009-07-07 02:22:57 +00:00
/* attempt to delete uploaded archive */
@ unlink ( e_PLUGIN . $archiveName );
}
2006-12-02 04:36:16 +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
// -----------------------------------------------------------------------------
function pluginInstall ()
{
2009-09-23 23:18:18 +00:00
global $plugin , $admin_log , $eplug_folder ;
2009-10-20 03:49:28 +00:00
$text = $plugin -> install_plugin ( $this -> id );
2014-01-01 18:38:02 -08:00
$log = e107 :: getAdminLog ();
2009-07-07 02:22:57 +00:00
if ( $text === FALSE )
{ // Tidy this up
2009-07-07 06:26:51 +00:00
$this -> show_message ( " Error messages above this line " , E_MESSAGE_ERROR );
2008-01-26 04:47:27 +00:00
}
2009-07-07 02:22:57 +00:00
else
2008-01-26 04:47:27 +00:00
{
2014-01-01 18:38:02 -08:00
$plugin -> save_addon_prefs ( 'update' );
$info = $plugin -> getinfo ( $this -> id );
$name = deftrue ( $info [ 'plugin_name' ], $info [ 'plugin_name' ]) . " v " . $info [ 'plugin_version' ] . " ( { e_PLUGIN} " . $info [ 'plugin_path' ] . " ) " ;
$log -> log_event ( 'PLUGMAN_01' , $name , E_LOG_INFORMATIVE , '' );
2009-07-07 06:26:51 +00:00
$this -> show_message ( $text , E_MESSAGE_SUCCESS );
2006-12-02 04:36:16 +00:00
}
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
}
// -----------------------------------------------------------------------------
2012-01-06 09:49:08 +00:00
function pluginUpgrade ()
{
2012-12-08 00:36:34 -08:00
$pref = e107 :: getPref ();
$admin_log = e107 :: getAdminLog ();
$plugin = e107 :: getPlugin ();
2010-06-23 10:21:21 +00:00
2012-12-08 00:36:34 -08:00
$sql = e107 :: getDb ();
2013-02-26 16:36:25 +01:00
$mes = e107 :: getMessage ();
2012-12-08 00:36:34 -08:00
$plug = $plugin -> getinfo ( $this -> id );
2008-12-04 21:36:09 +00:00
2012-01-06 09:49:08 +00:00
$_path = e_PLUGIN . $plug [ 'plugin_path' ] . '/' ;
if ( file_exists ( $_path . 'plugin.xml' ))
{
$plugin -> install_plugin_xml ( $this -> id , 'upgrade' );
}
else
{
include ( e_PLUGIN . $plug [ 'plugin_path' ] . '/plugin.php' );
$func = $eplug_folder . '_upgrade' ;
if ( function_exists ( $func ))
2008-02-02 22:04:18 +00:00
{
2012-01-06 09:49:08 +00:00
$text .= call_user_func ( $func );
2006-12-02 04:36:16 +00:00
}
2012-01-06 09:49:08 +00:00
if ( is_array ( $upgrade_alter_tables ))
{
$result = $plugin -> manage_tables ( 'upgrade' , $upgrade_alter_tables );
if ( true !== $result )
2009-07-07 02:22:57 +00:00
{
2012-01-06 09:49:08 +00:00
//$text .= EPL_ADLAN_9.'<br />';
2013-02-26 16:36:25 +01:00
$mes -> addWarning ( EPL_ADLAN_9 )
2012-01-06 09:49:08 +00:00
-> addDebug ( $result );
2009-07-07 02:22:57 +00:00
}
else
{
2012-01-06 09:49:08 +00:00
$text .= EPL_ADLAN_7 . " <br /> " ;
2009-07-07 02:22:57 +00:00
}
2012-01-06 09:49:08 +00:00
}
2006-12-02 04:36:16 +00:00
2012-01-06 09:49:08 +00:00
if ( is_array ( $upgrade_add_prefs ))
{
$plugin -> manage_prefs ( 'add' , $upgrade_add_prefs );
$text .= EPL_ADLAN_8 . '<br />' ;
}
2008-12-04 21:36:09 +00:00
2012-01-06 09:49:08 +00:00
if ( is_array ( $upgrade_remove_prefs ))
{
$plugin -> manage_prefs ( 'remove' , $upgrade_remove_prefs );
}
2008-12-04 21:36:09 +00:00
2012-01-06 09:49:08 +00:00
if ( is_array ( $upgrade_add_array_pref ))
{
foreach ( $upgrade_add_array_pref as $key => $val )
2009-07-07 02:22:57 +00:00
{
2012-01-06 09:49:08 +00:00
$plugin -> manage_plugin_prefs ( 'add' , $key , $eplug_folder , $val );
2009-07-07 02:22:57 +00:00
}
2012-01-06 09:49:08 +00:00
}
2008-12-04 21:36:09 +00:00
2012-01-06 09:49:08 +00:00
if ( is_array ( $upgrade_remove_array_pref ))
{
foreach ( $upgrade_remove_array_pref as $key => $val )
2009-07-07 02:22:57 +00:00
{
2012-01-06 09:49:08 +00:00
$plugin -> manage_plugin_prefs ( 'remove' , $key , $eplug_folder , $val );
2009-07-07 02:22:57 +00:00
}
2012-01-06 09:49:08 +00:00
}
2008-12-04 21:36:09 +00:00
2012-01-06 09:49:08 +00:00
$plugin -> manage_search ( 'upgrade' , $eplug_folder );
$plugin -> manage_notify ( 'upgrade' , $eplug_folder );
2008-12-04 21:36:09 +00:00
2012-01-06 09:49:08 +00:00
$eplug_addons = $plugin -> getAddons ( $eplug_folder );
2008-12-04 21:36:09 +00:00
2014-01-01 18:38:02 -08:00
$info = $plugin -> getinfo ( $this -> id );
$name = deftrue ( $info [ 'plugin_name' ], $info [ 'plugin_name' ]) . " v " . $eplug_version . " ( { e_PLUGIN} " . $info [ 'plugin_path' ] . " ) " ;
$admin_log -> log_event ( 'PLUGMAN_02' , $name , E_LOG_INFORMATIVE , '' );
2012-01-06 09:49:08 +00:00
$text .= ( isset ( $eplug_upgrade_done )) ? '<br />' . $eplug_upgrade_done : " <br /> " . LAN_UPGRADE_SUCCESSFUL ;
2013-03-03 23:42:37 -08:00
$sql -> update ( 'plugin' , " plugin_version =' { $eplug_version } ', plugin_addons=' { $eplug_addons } ' WHERE plugin_id=' $this->id ' " );
2012-01-06 09:49:08 +00:00
$pref [ 'plug_installed' ][ $plug [ 'plugin_path' ]] = $eplug_version ; // Update the version
e107 :: getConfig ( 'core' ) -> setPref ( $pref );
$plugin -> rebuildUrlConfig ();
e107 :: getConfig ( 'core' ) -> save ();
}
2010-06-23 10:21:21 +00:00
2013-02-26 16:36:25 +01:00
$mes -> addSuccess ( $text );
2012-12-23 15:00:15 +00:00
$plugin -> save_addon_prefs ( 'update' );
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
// -----------------------------------------------------------------------------
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
function pluginRefresh ()
{
global $plug ;
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
$plug = $plugin -> getinfo ( $this -> id );
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
$_path = e_PLUGIN . $plug [ 'plugin_path' ] . '/' ;
if ( file_exists ( $_path . 'plugin.xml' ))
2008-02-02 22:04:18 +00:00
{
2009-10-23 14:16:08 +00:00
$text .= $plugin -> install_plugin_xml ( $this -> id , 'refresh' );
2009-07-07 02:22:57 +00:00
$admin_log -> log_event ( 'PLUGMAN_04' , $this -> id . ':' . $plug [ 'plugin_path' ], E_LOG_INFORMATIVE , '' );
2008-02-02 22:04:18 +00: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
// -----------------------------------------------------------------------------
2008-12-04 21:36:09 +00:00
2009-07-07 02:22:57 +00:00
// Check for new plugins, create entry in plugin table ...
2013-04-17 15:22:47 -07:00
function pluginCheck ( $force = false )
2009-07-07 02:22:57 +00:00
{
global $plugin ;
2013-04-17 15:22:47 -07:00
if (( time () > vartrue ( $_SESSION [ 'nextPluginFolderScan' ], 0 )) || $force == true )
{
$plugin -> update_plugins_table ( 'update' );
}
2013-05-01 00:55:32 -07:00
$_SESSION [ 'nextPluginFolderScan' ] = time () + PLUGIN_SCAN_INTERVAL ;
2013-04-17 15:22:47 -07:00
//echo "TIME = ".$_SESSION['nextPluginFolderScan'];
2009-07-07 02:22:57 +00:00
}
// ----------------------------------------------------------
// render plugin information ...
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
// -----------------------------------------------------------------------------
2006-12-02 04:36:16 +00:00
2008-12-10 22:39:43 +00:00
2009-07-07 02:22:57 +00:00
function pluginUpload ()
2008-12-10 22:39:43 +00:00
{
2012-07-24 00:42:17 +00:00
global $plugin ;
$frm = e107 :: getForm ();
2008-12-10 22:39:43 +00:00
2009-09-28 07:17:52 +00:00
//TODO 'install' checkbox in plugin upload form. (as it is for theme upload)
2009-07-07 02:22:57 +00:00
/* plugin upload form */
2008-12-10 22:39:43 +00:00
2009-07-07 02:22:57 +00:00
if ( ! is_writable ( e_PLUGIN ))
{
2009-08-14 21:11:49 +00:00
e107 :: getRender () -> tablerender ( EPL_ADLAN_40 , EPL_ADLAN_44 );
2009-07-07 02:22:57 +00:00
}
else
{
// Get largest allowable file upload
require_once ( e_HANDLER . 'upload_handler.php' );
$max_file_size = get_user_max_upload ();
$text = "
< form enctype = 'multipart/form-data' method = 'post' action = '".e_SELF."' >
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' >
2012-05-13 05:50:32 +00:00
< colgroup >
2009-07-10 14:25:23 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
2009-07-07 02:22:57 +00:00
< tr >
2009-07-10 14:25:23 +00:00
< td > " .EPL_ADLAN_37. " </ td >
< td >
2009-07-07 02:22:57 +00:00
< 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 >
2009-07-10 14:25:23 +00:00
</ tr >
</ table >
< div class = 'center buttons-bar' > " ;
2009-07-07 02:22:57 +00:00
$text .= $frm -> admin_button ( 'upload' , EPL_ADLAN_38 , 'submit' , EPL_ADLAN_38 );
$text .= "
2009-07-10 14:25:23 +00:00
</ div >
</ form > \n " ;
2009-07-07 02:22:57 +00:00
}
2013-02-22 21:34:06 -08:00
e107 :: getRender () -> tablerender ( ADLAN_98 . SEP . EPL_ADLAN_38 , $text );
2009-07-07 02:22:57 +00:00
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
// -----------------------------------------------------------------------------
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
function pluginRenderList () // Uninstall and Install sorting should be fixed once and for all now !
{
2006-12-02 04:36:16 +00:00
2012-07-24 00:42:17 +00:00
global $plugin ;
$frm = e107 :: getForm ();
2009-09-25 02:02:38 +00:00
$e107 = e107 :: getInstance ();
2013-02-26 16:36:25 +01:00
$mes = e107 :: getMessage ();
2010-06-23 10:21:21 +00:00
2009-07-07 02:22:57 +00:00
if ( $this -> action == " " || $this -> action == " installed " )
{
$installed = $plugin -> getall ( 1 );
2009-07-22 12:00:51 +00:00
$caption = EPL_ADLAN_22 ;
$pluginRenderPlugin = $this -> pluginRenderPlugin ( $installed );
2009-07-07 06:26:51 +00:00
$button_mode = " uninstall-selected " ;
$button_caption = EPL_ADLAN_85 ;
$button_action = " delete " ;
2009-07-07 02:22:57 +00:00
}
if ( $this -> action == " avail " )
{
2013-02-22 22:35:15 -08:00
$uninstalled = $plugin -> getall ( 0 );
2009-07-22 12:00:51 +00:00
$caption = EPL_ADLAN_23 ;
$pluginRenderPlugin = $this -> pluginRenderPlugin ( $uninstalled );
2009-07-07 06:26:51 +00:00
$button_mode = " install-selected " ;
$button_caption = EPL_ADLAN_84 ;
$button_action = " update " ;
2009-07-07 02:22:57 +00:00
}
2006-12-02 04:36:16 +00:00
2009-07-22 12:00:51 +00:00
$text = "
< form action = '".e_SELF."?".e_QUERY."' id = 'core-plugin-list-form' method = 'post' >
< fieldset id = 'core-plugin-list' >
2012-12-08 15:52:40 +01:00
< legend class = 'e-hideme' > " .vartrue( $caption ). " </ legend >
2012-11-26 14:41:32 -08:00
< table class = 'table adminlist' >
2009-07-22 12:00:51 +00:00
" . $frm->colGroup ( $this->fields , $this->fieldpref ).
$frm -> thead ( $this -> fields , $this -> fieldpref ) . "
< tbody >
" ;
2012-12-08 15:52:40 +01:00
if ( vartrue ( $pluginRenderPlugin ))
2009-09-10 15:39:09 +00:00
{
2010-06-23 10:21:21 +00:00
$text .= $pluginRenderPlugin ;
2009-09-10 15:39:09 +00:00
}
else
{
//TODO LANs
2010-06-23 10:21:21 +00:00
$text .= " <tr><td class='center' colspan=' " . count ( $this -> fields ) . " '>No plugins installed - <a href=' " . e_ADMIN . " plugin.php?avail'>click here to install some</a>.</td></tr> " ;
2009-09-10 15:39:09 +00:00
}
2009-07-22 12:00:51 +00:00
$text .= "
</ tbody >
2009-07-07 06:26:51 +00:00
</ table > " ;
if ( $this -> action == " avail " )
{
2009-07-22 12:00:51 +00:00
$text .= "
2013-02-20 12:25:55 +01:00
< div class = 'buttons-bar center' > " . $frm->admin_button ( $button_mode , $button_caption , $button_action ). " </ div > " ;
2009-07-07 06:26:51 +00:00
}
$text .= "
2009-07-22 12:00:51 +00:00
</ fieldset >
</ form >
2009-07-07 02:22:57 +00:00
" ;
2006-12-02 04:36:16 +00:00
2013-02-26 16:36:25 +01:00
e107 :: getRender () -> tablerender ( ADLAN_98 . SEP . $caption , $mes -> render () . $text );
2009-07-07 02:22:57 +00:00
}
2006-12-02 04:36:16 +00:00
2008-01-26 04:47:27 +00:00
2009-07-07 02:22:57 +00:00
// -----------------------------------------------------------------------------
2008-04-05 07:58:30 +00:00
2009-07-07 02:22:57 +00:00
function pluginRenderPlugin ( $pluginList )
2008-01-26 04:47:27 +00:00
{
2012-07-24 00:42:17 +00:00
global $plugin ;
2012-08-22 02:45:32 +00:00
2009-07-07 02:22:57 +00:00
if ( empty ( $pluginList )) return '' ;
2010-06-23 10:21:21 +00:00
2009-09-28 07:17:52 +00:00
$tp = e107 :: getParser ();
2012-08-22 02:45:32 +00:00
$frm = e107 :: getForm ();
2013-03-05 06:11:05 -08:00
$pgf = new pluginmanager_form ;
2006-12-02 04:36:16 +00:00
2009-07-14 03:18:17 +00:00
$text = " " ;
2009-07-07 02:22:57 +00:00
foreach ( $pluginList as $plug )
2010-06-23 10:21:21 +00:00
{
2009-09-10 15:24:57 +00:00
e107 :: loadLanFiles ( $plug [ 'plugin_path' ], 'admin' );
2012-12-12 18:46:34 -08:00
if ( $this -> action == " avail " )
{
e107 :: lan ( $plug [ 'plugin_path' ], 'global' , true ); // Load language files.
}
2010-06-23 10:21:21 +00:00
2009-07-07 02:22:57 +00:00
$_path = e_PLUGIN . $plug [ 'plugin_path' ] . '/' ;
2010-06-23 10:21:21 +00:00
2009-07-07 02:22:57 +00:00
$plug_vars = false ;
2009-07-15 09:38:00 +00:00
$plugin_config_icon = " " ;
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
if ( $plugin -> parse_plugin ( $plug [ 'plugin_path' ]))
{
$plug_vars = $plugin -> plug_vars ;
}
2010-06-23 10:21:21 +00:00
if ( varset ( $plug [ 'plugin_category' ]) == " menu " ) // Hide "Menu Only" plugins.
2009-09-19 17:43:19 +00:00
{
continue ;
}
2010-06-23 10:21:21 +00:00
2009-07-07 02:22:57 +00:00
if ( $plug_vars )
{
2008-01-26 04:47:27 +00:00
2009-07-07 02:22:57 +00:00
$icon_src = ( isset ( $plug_vars [ 'plugin_php' ]) ? e_PLUGIN : $_path ) . $plug_vars [ 'administration' ][ 'icon' ];
2013-03-05 06:11:05 -08:00
// $plugin_icon = $plug_vars['administration']['icon'] ? "<img src='{$icon_src}' alt='' class='icon S32' />" : E_32_CAT_PLUG;
$plugin_icon = $plug_vars [ 'administration' ][ 'icon' ] ? $icon_src : ' HELLO ' ; E_32_CAT_PLUG ;
2009-07-07 02:43:14 +00:00
$conf_file = " # " ;
$conf_title = " " ;
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
if ( $plug_vars [ 'administration' ][ 'configFile' ] && $plug [ 'plugin_installflag' ] == true )
{
2009-07-07 02:43:14 +00:00
$conf_file = e_PLUGIN . $plug [ 'plugin_path' ] . '/' . $plug_vars [ 'administration' ][ 'configFile' ];
2009-07-07 02:22:57 +00:00
$conf_title = LAN_CONFIGURE . ' ' . $tp -> toHtml ( $plug_vars [ '@attributes' ][ 'name' ], " " , " defs,emotes_off, no_make_clickable " );
2013-03-05 06:11:05 -08:00
// $plugin_icon = "<a title='{$conf_title}' href='{$conf_file}' >".$plugin_icon."</a>";
2013-03-03 23:42:37 -08:00
$plugin_config_icon = " <a class='btn' title=' { $conf_title } ' href=' { $conf_file } ' > " . ADMIN_CONFIGURE_ICON . " </a> " ;
2009-07-07 02:22:57 +00:00
}
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
$plugEmail = varset ( $plug_vars [ 'author' ][ '@attributes' ][ 'email' ], '' );
$plugAuthor = varset ( $plug_vars [ 'author' ][ '@attributes' ][ 'name' ], '' );
$plugURL = varset ( $plug_vars [ 'author' ][ '@attributes' ][ 'url' ], '' );
2012-07-24 00:42:17 +00:00
$plugDate = varset ( $plug_vars [ '@attributes' ][ 'date' ], '' );
2013-03-05 01:38:46 -08:00
$compatibility = varset ( $plug_vars [ '@attributes' ][ 'compatibility' ], '' );
2012-07-24 00:42:17 +00:00
2012-08-22 02:45:32 +00:00
$description = varset ( $plug_vars [ 'description' ][ '@attributes' ][ 'lang' ]) ? $tp -> toHTML ( $plug_vars [ 'description' ][ '@attributes' ][ 'lang' ], false , " defs,emotes_off, no_make_clickable " ) : $tp -> toHTML ( $plug_vars [ 'description' ][ '@value' ], false , " emotes_off, no_make_clickable " ) ;
2009-07-07 02:22:57 +00:00
$plugReadme = " " ;
2009-07-14 03:18:17 +00:00
if ( varset ( $plug [ 'plugin_installflag' ]))
2009-07-07 02:43:14 +00:00
{
$plugName = " <a title=' { $conf_title } ' href=' { $conf_file } ' > " . $tp -> toHTML ( $plug [ 'plugin_name' ], false , " defs,emotes_off, no_make_clickable " ) . " </a> " ;
}
else
{
$plugName = $tp -> toHTML ( $plug [ 'plugin_name' ], false , " defs,emotes_off, no_make_clickable " );
}
2009-07-14 03:18:17 +00:00
if ( varset ( $plug_vars [ 'readme' ])) // 0.7 plugin.php
2009-07-07 02:22:57 +00:00
{
$plugReadme = $plug_vars [ 'readme' ];
}
2009-07-14 03:18:17 +00:00
if ( varset ( $plug_vars [ 'readMe' ])) // 0.8 plugin.xml
2009-07-07 02:22:57 +00:00
{
$plugReadme = $plug_vars [ 'readMe' ];
}
2013-03-05 06:11:05 -08:00
if ( ! file_exists ( $plugin_icon ))
{
$plugin_icon = e_IMAGE . " admin_images/cat_plugins_32.png " ;
}
$data = array (
'plugin_id' => $plug [ 'plugin_id' ],
'plugin_icon' => $plugin_icon ,
'plugin_name' => $plugName ,
'plugin_folder' => $plug [ 'plugin_path' ],
'plugin_date' => $plugDate ,
'plugin_category' => vartrue ( $plug [ 'plugin_category' ]),
'plugin_author' => vartrue ( $plugAuthor ), // vartrue($plugEmail) ? "<a href='mailto:".$plugEmail."' title='".$plugEmail."'>".$plugAuthor."</a>" : vartrue($plugAuthor),
'plugin_version' => $plug [ 'plugin_version' ],
'plugin_description' => $description ,
'plugin_compatible' => $this -> compatibilityLabel ( $plug_vars [ '@attributes' ][ 'compatibility' ]),
'plugin_website' => vartrue ( $row [ 'authorUrl' ]),
// 'plugin_url' => vartrue($plugURL), // ; // ? "<a href='{$plugURL}' title='{$plugURL}' >".ADMIN_URL_ICON."</a>" : "",
'plugin_notes' => ''
);
$pgf -> plug_vars = $plug_vars ;
$pgf -> plug = $plug ;
$text .= $pgf -> renderTableRow ( $this -> fields , $this -> fieldpref , $data , 'plugin_id' );
/*
//LEGACY CODE
2009-07-07 02:22:57 +00:00
$text .= " <tr> " ;
2009-07-07 06:26:51 +00:00
2013-03-05 06:11:05 -08:00
if ( varset ( $this -> fields [ 'checkboxes' ]))
2009-07-07 06:26:51 +00:00
{
2013-03-05 06:11:05 -08:00
$rowid = " checkboxes[ " . $plug [ 'plugin_id' ] . " ] " ;
2009-07-07 06:26:51 +00:00
$text .= " <td class='center middle'> " . $frm -> checkbox ( $rowid , $plug [ 'plugin_id' ]) . " </td> \n " ;
}
2009-07-07 02:22:57 +00:00
// $text .= (in_array("plugin_status",$this->fieldpref)) ? "<td class='center'>".$img."</td>" : "";
2013-03-05 06:11:05 -08:00
2009-07-07 02:22:57 +00:00
$text .= ( in_array ( " plugin_icon " , $this -> fieldpref )) ? " <td class='center middle'> " . $plugin_icon . " </td> " : " " ;
2009-07-07 02:43:14 +00:00
$text .= ( in_array ( " plugin_name " , $this -> fieldpref )) ? " <td class='middle'> " . $plugName . " </td> " : " " ;
2009-07-07 02:22:57 +00:00
$text .= ( in_array ( " plugin_version " , $this -> fieldpref )) ? " <td class='middle'> " . $plug [ 'plugin_version' ] . " </td> " : " " ;
2012-07-24 00:42:17 +00:00
$text .= ( in_array ( " plugin_date " , $this -> fieldpref )) ? " <td class='middle'> " . $plugDate . " </td> " : " " ;
2009-07-07 02:22:57 +00:00
$text .= ( in_array ( " plugin_folder " , $this -> fieldpref )) ? " <td class='middle'> " . $plug [ 'plugin_path' ] . " </td> " : " " ;
2009-07-09 02:47:17 +00:00
$text .= ( in_array ( " plugin_category " , $this -> fieldpref )) ? " <td class='middle'> " . $plug [ 'plugin_category' ] . " </td> " : " " ;
2009-07-07 02:22:57 +00:00
$text .= ( in_array ( " plugin_author " , $this -> fieldpref )) ? " <td class='middle'><a href='mailto: " . $plugEmail . " ' title=' " . $plugEmail . " '> " . $plugAuthor . " </a> </td> " : " " ;
2009-07-17 03:53:14 +00:00
$text .= ( in_array ( " plugin_website " , $this -> fieldpref )) ? " <td class='center middle'> " . ( $plugURL ? " <a href=' { $plugURL } ' title=' { $plugURL } ' > " . ADMIN_URL_ICON . " </a> " : " " ) . " </td> " : " " ;
2013-03-05 06:11:05 -08:00
$text .= ( in_array ( " plugin_compatible " , $this -> fieldpref )) ? " <td class='center middle'> " . $this -> compatibilityLabel ( $plug_vars [ '@attributes' ][ 'compatibility' ]) . " </td> " : " " ;
2013-03-05 01:38:46 -08:00
2012-08-22 02:45:32 +00:00
$text .= ( in_array ( " plugin_description " , $this -> fieldpref )) ? " <td class='middle'> " . $description . " </td> " : " " ;
2013-03-05 01:38:46 -08:00
$text .= ( in_array ( " plugin_compliant " , $this -> fieldpref )) ? " <td class='center middle'> " . (( varset ( $plug_vars [ 'compliant' ]) || varsettrue ( $plug_vars [ '@attributes' ][ 'xhtmlcompliant' ])) ? ADMIN_TRUE_ICON : " " ) . " </td> " : " " ;
2013-03-05 06:11:05 -08:00
$text .= ( in_array ( " plugin_notes " , $this -> fieldpref )) ? " <td class='center middle'> " . ( $plugReadme ? " <a href=' " . e_PLUGIN . $plug [ 'plugin_path' ] . " / " . $plugReadme . " ' title=' " . $plugReadme . " '> " . ADMIN_INFO_ICON . " </a> " : " " ) . " </td> " : " " ;
2009-07-07 02:22:57 +00:00
// Plugin options Column --------------
2013-03-03 23:42:37 -08:00
$text .= " <td class='options center middle'>
< div class = 'btn-group' > " . $plugin_config_icon ;
2009-07-15 09:38:00 +00:00
2009-07-07 02:22:57 +00:00
if ( $plug_vars [ '@attributes' ][ 'installRequired' ])
{
if ( $plug [ 'plugin_installflag' ])
{
2013-03-03 23:42:37 -08:00
$text .= ( $plug [ 'plugin_installflag' ] ? " <a class='btn' href= \" " . e_SELF . " ?uninstall. { $plug [ 'plugin_id' ] } \" title=' " . EPL_ADLAN_1 . " ' > " . ADMIN_UNINSTALLPLUGIN_ICON . " </a> " : " <a class='btn' href= \" " . e_SELF . " ?install. { $plug [ 'plugin_id' ] } \" title=' " . EPL_ADLAN_0 . " ' > " . ADMIN_INSTALLPLUGIN_ICON . " </a> " );
2009-07-07 02:22:57 +00:00
2009-08-15 15:44:37 +00:00
// $text .= ($plug['plugin_installflag'] ? "<button type='button' class='delete' value='no-value' onclick=\"location.href='".e_SELF."?uninstall.{$plug['plugin_id']}'\"><span>".EPL_ADLAN_1."</span></button>" : "<button type='button' class='update' value='no-value' onclick=\"location.href='".e_SELF."?install.{$plug['plugin_id']}'\"><span>".EPL_ADLAN_0."</span></button>");
2009-07-07 02:22:57 +00:00
if ( PLUGIN_SHOW_REFRESH && ! varsettrue ( $plug_vars [ 'plugin_php' ]))
{
2013-02-02 20:34:19 +01:00
$text .= " <br /><br /><input type='button' class='btn button' onclick= \" location.href=' " . e_SELF . " ?refresh. { $plug [ 'plugin_id' ] } ' \" title=' " . 'Refresh plugin settings' . " ' value=' " . 'Refresh plugin settings' . " ' /> " ;
2009-07-07 02:22:57 +00:00
}
}
else
{
2013-04-26 13:48:23 -07:00
// $text .= "<input type='button' class='btn' onclick=\"location.href='".e_SELF."?install.{$plug['plugin_id']}'\" title='".EPL_ADLAN_0."' value='".EPL_ADLAN_0."' />";
2009-08-15 15:44:37 +00:00
// $text .= "<button type='button' class='update' value='no-value' onclick=\"location.href='".e_SELF."?install.{$plug['plugin_id']}'\"><span>".EPL_ADLAN_0."</span></button>";
2013-03-03 23:42:37 -08:00
$text .= " <a class='btn' href= \" " . e_SELF . " ?install. { $plug [ 'plugin_id' ] } \" title=' " . EPL_ADLAN_0 . " ' > " . ADMIN_INSTALLPLUGIN_ICON . " </a> " ;
2009-07-07 02:22:57 +00:00
}
}
else
{
if ( $plug_vars [ 'menuName' ])
{
$text .= EPL_NOINSTALL . str_replace ( " .. " , " " , e_PLUGIN . $plug [ 'plugin_path' ]) . " / " . EPL_DIRECTORY ;
}
else
{
$text .= EPL_NOINSTALL_1 . str_replace ( " .. " , " " , e_PLUGIN . $plug [ 'plugin_path' ]) . " / " . EPL_DIRECTORY ;
if ( $plug [ 'plugin_installflag' ] == false )
2012-07-24 00:42:17 +00:00
{
e107 :: getDb () -> db_Delete ( 'plugin' , " plugin_installflag=0 AND (plugin_path=' { $plug [ 'plugin_path' ] } ' OR plugin_path=' { $plug [ 'plugin_path' ] } /' ) " );
2009-07-07 02:22:57 +00:00
}
}
}
if ( $plug [ 'plugin_version' ] != $plug_vars [ '@attributes' ][ 'version' ] && $plug [ 'plugin_installflag' ])
{
2013-04-26 13:48:23 -07:00
// $text .= "<br /><input type='button' class='btn' onclick=\"location.href='".e_SELF."?upgrade.{$plug['plugin_id']}'\" title='".EPL_UPGRADE." to v".$plug_vars['@attributes']['version']."' value='".EPL_UPGRADE."' />";
2013-03-03 23:42:37 -08:00
$text .= " <a class='btn' href=' " . e_SELF . " ?upgrade. { $plug [ 'plugin_id' ] } ' title= \" " . EPL_UPGRADE . " to v " . $plug_vars [ '@attributes' ][ 'version' ] . " \" > " . ADMIN_UPGRADEPLUGIN_ICON . " </a> " ;
2009-07-07 02:22:57 +00:00
}
2013-03-03 23:42:37 -08:00
$text .= " </div></td> " ;
2013-03-05 06:11:05 -08:00
// $text .= "</tr>";
*/
2009-07-07 02:22:57 +00:00
}
2008-01-26 04:47:27 +00:00
}
2009-07-07 02:22:57 +00:00
return $text ;
}
// -----------------------------------------------------------------------------
2006-12-02 04:36:16 +00:00
2009-07-07 02:22:57 +00:00
function pluginConfirmUninstall ()
{
2009-10-30 12:56:07 +00:00
global $plugin ;
2010-06-23 10:21:21 +00:00
2009-10-30 12:56:07 +00:00
$frm = e107 :: getForm ();
$tp = e107 :: getParser ();
$mes = e107 :: getMessage ();
2010-06-23 10:21:21 +00:00
2009-07-07 02:22:57 +00:00
$plug = $plugin -> getinfo ( $this -> id );
if ( $plug [ 'plugin_installflag' ] == true )
2008-01-26 04:47:27 +00:00
{
2009-07-07 02:22:57 +00:00
if ( $plugin -> parse_plugin ( $plug [ 'plugin_path' ]))
2008-12-10 22:39:43 +00:00
{
2009-07-07 02:22:57 +00:00
$plug_vars = $plugin -> plug_vars ;
2008-12-10 22:39:43 +00:00
}
else
{
2009-07-07 02:22:57 +00:00
return FALSE ;
2008-12-10 22:39:43 +00:00
}
2008-01-26 04:47:27 +00:00
}
else
{
2009-07-07 02:22:57 +00:00
return FALSE ;
}
$userclasses = '' ;
$eufields = '' ;
2009-09-23 23:18:18 +00:00
if ( isset ( $plug_vars [ 'userClasses' ]))
2009-07-07 02:22:57 +00:00
{
if ( isset ( $plug_vars [ 'userclass' ][ '@attributes' ]))
2008-01-26 04:47:27 +00:00
{
2009-07-07 02:22:57 +00:00
$plug_vars [ 'userclass' ][ 0 ][ '@attributes' ] = $plug_vars [ 'userclass' ][ '@attributes' ];
unset ( $plug_vars [ 'userclass' ][ '@attributes' ]);
2008-01-26 04:47:27 +00:00
}
2009-07-07 02:22:57 +00:00
$spacer = '' ;
2009-09-23 23:18:18 +00:00
foreach ( $plug_vars [ 'userClasses' ][ 'class' ] as $uc )
2008-01-26 04:47:27 +00:00
{
2009-07-07 02:22:57 +00:00
$userclasses .= $spacer . $uc [ '@attributes' ][ 'name' ] . ' - ' . $uc [ '@attributes' ][ 'description' ];
$spacer = '<br />' ;
}
}
2009-09-23 23:18:18 +00:00
if ( isset ( $plug_vars [ 'extendedFields' ]))
2009-07-07 02:22:57 +00:00
{
2009-09-23 23:18:18 +00:00
if ( isset ( $plug_vars [ 'extendedFields' ][ '@attributes' ]))
2009-07-07 02:22:57 +00:00
{
$plug_vars [ 'extendedField' ][ 0 ][ '@attributes' ] = $plug_vars [ 'extendedField' ][ '@attributes' ];
unset ( $plug_vars [ 'extendedField' ][ '@attributes' ]);
}
$spacer = '' ;
2009-09-23 23:18:18 +00:00
foreach ( $plug_vars [ 'extendedFields' ][ 'field' ] as $eu )
2009-07-07 02:22:57 +00:00
{
$eufields .= $spacer . 'plugin_' . $plug_vars [ 'folder' ] . '_' . $eu [ '@attributes' ][ 'name' ];
$spacer = '<br />' ;
2008-01-26 04:47:27 +00:00
}
}
2009-07-07 02:22:57 +00:00
if ( is_writable ( e_PLUGIN . $plug [ 'plugin_path' ]))
{
2013-04-25 17:29:46 -07:00
$del_text = $frm -> select ( 'delete_files' , 'yesno' , 0 );
2009-07-07 02:22:57 +00:00
}
else
{
$del_text = "
" .EPL_ADLAN_53. "
< input type = 'hidden' name = 'delete_files' value = '0' />
" ;
2008-01-26 04:47:27 +00:00
}
2009-07-07 02:22:57 +00:00
$text = "
< form action = '".e_SELF."?".e_QUERY."' method = 'post' >
2009-07-10 14:25:23 +00:00
< fieldset id = 'core-plugin-confirmUninstall' >
< legend > " .EPL_ADLAN_54. " " . $tp->toHtml ( $plug_vars['@attributes'] ['name'], " " , " defs , emotes_off , no_make_clickable " ). " </ legend >
2012-11-26 14:41:32 -08:00
< table class = 'table adminform' >
2012-05-13 05:50:32 +00:00
< colgroup >
2009-07-10 14:25:23 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tr >
2009-09-28 07:17:52 +00:00
< td > " .EPL_ADLAN_55. " </ td >
< td > " .LAN_YES. " </ td >
2009-07-07 02:22:57 +00:00
</ tr > " ;
2010-06-23 10:21:21 +00:00
2009-10-30 09:13:37 +00:00
$opts = array ();
2010-06-23 10:21:21 +00:00
2009-10-30 09:13:37 +00:00
$opts [ 'delete_tables' ] = array (
'label' => EPL_ADLAN_57 ,
'helpText' => EPL_ADLAN_58 ,
'itemList' => array ( 1 => LAN_YES , 0 => LAN_NO ),
'itemDefault' => 1
);
2009-07-07 02:22:57 +00:00
if ( $userclasses )
2010-06-23 10:21:21 +00:00
{
2009-10-30 09:13:37 +00:00
$opts [ 'delete_userclasses' ] = array (
'label' => EPL_ADLAN_78 ,
'preview' => $userclasses ,
'helpText' => EPL_ADLAN_79 ,
'itemList' => array ( 1 => LAN_YES , 0 => LAN_NO ),
'itemDefault' => 1
);
2009-07-07 02:22:57 +00:00
}
if ( $eufields )
{
2009-10-30 09:13:37 +00:00
$opts [ 'delete_xfields' ] = array (
'label' => EPL_ADLAN_80 ,
'preview' => $eufields ,
'helpText' => EPL_ADLAN_79 ,
'itemList' => array ( 1 => LAN_YES , 0 => LAN_NO ),
'itemDefault' => 0
);
2009-09-28 07:17:52 +00:00
}
2009-10-30 09:13:37 +00:00
2010-03-14 02:11:23 +00:00
$med = e107 :: getMedia ();
$icons = $med -> listIcons ( e_PLUGIN . $plug [ 'plugin_path' ]);
2010-06-23 10:21:21 +00:00
2010-03-14 02:11:23 +00:00
if ( count ( $icons ) > 0 )
2009-09-28 07:17:52 +00:00
{
2009-10-30 09:13:37 +00:00
foreach ( $icons as $key => $val )
{
2010-06-23 10:21:21 +00:00
$iconText .= " <img src=' " . $tp -> replaceConstants ( $val ) . " ' alt='' /> " ;
2009-10-30 09:13:37 +00:00
}
2010-06-23 10:21:21 +00:00
2009-10-30 09:13:37 +00:00
$opts [ 'delete_ipool' ] = array (
2010-03-14 02:11:23 +00:00
'label' => 'Remove icons from Media-Manager' ,
2009-10-30 09:13:37 +00:00
'preview' => $iconText ,
'helpText' => EPL_ADLAN_79 ,
'itemList' => array ( 1 => LAN_YES , 0 => LAN_NO ),
'itemDefault' => 1
);
}
2010-06-23 10:21:21 +00:00
2009-10-30 09:13:37 +00:00
if ( is_readable ( e_PLUGIN . $plug [ 'plugin_path' ] . " / " . $plug [ 'plugin_path' ] . " _setup.php " ))
{
include_once ( e_PLUGIN . $plug [ 'plugin_path' ] . " / " . $plug [ 'plugin_path' ] . " _setup.php " );
2010-06-23 10:21:21 +00:00
2009-10-30 09:13:37 +00:00
$mes -> add ( " Loading " . e_PLUGIN . $plug [ 'plugin_path' ] . " / " . $plug [ 'plugin_path' ] . " _setup.php " , E_MESSAGE_DEBUG );
2010-06-23 10:21:21 +00:00
2009-10-30 09:13:37 +00:00
$class_name = $plug [ 'plugin_path' ] . " _setup " ;
2010-06-23 10:21:21 +00:00
2009-10-30 09:13:37 +00:00
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 = $plug [ 'plugin_path' ] . " _ " . $key ;
$opts [ $newkey ] = $val ;
2010-06-23 10:21:21 +00:00
}
2009-10-30 09:13:37 +00:00
}
}
2009-07-07 02:22:57 +00:00
}
2010-06-23 10:21:21 +00:00
2009-10-30 09:13:37 +00:00
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> " : " " ;
2013-04-25 17:29:46 -07:00
$text .= " </td> \n <td> " . $frm -> select ( $key , $val [ 'itemList' ], $val [ 'itemDefault' ]);
2009-10-30 09:13:37 +00:00
$text .= varset ( $val [ 'helpText' ]) ? " <div class='field-help'> " . $val [ 'helpText' ] . " </div> " : " " ;
$text .= " </td> \n </tr> \n " ;
}
2010-06-23 10:21:21 +00:00
2009-07-07 02:22:57 +00:00
$text .= " <tr>
2009-09-28 07:17:52 +00:00
< td > " .EPL_ADLAN_59. " </ td >
< td > { $del_text }
< div class = 'field-help' > " .EPL_ADLAN_60. " </ div >
</ td >
2009-07-07 02:22:57 +00:00
</ tr >
2009-07-10 14:25:23 +00:00
</ table >
< div class = 'buttons-bar center' > " ;
2012-07-29 02:36:18 +00:00
$text .= $frm -> admin_button ( 'uninstall_confirm' , EPL_ADLAN_3 , 'submit' );
$text .= $frm -> admin_button ( 'uninstall_cancel' , EPL_ADLAN_62 , 'cancel' );
2009-07-07 06:26:51 +00:00
2012-07-29 02:36:18 +00:00
/*
2013-04-26 13:48:23 -07:00
$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; \" /> " ;
2012-07-29 02:36:18 +00:00
*/
2009-07-07 06:26:51 +00:00
// $frm->admin_button($name, $value, $action = 'submit', $label = '', $options = array());
2009-07-10 14:25:23 +00:00
$text .= " </div>
</ fieldset >
2009-07-07 02:22:57 +00:00
</ form >
" ;
2013-02-22 21:34:06 -08:00
e107 :: getRender () -> tablerender ( EPL_ADLAN_63 . SEP . $tp -> toHtml ( $plug_vars [ '@attributes' ][ 'name' ], " " , " defs,emotes_off, no_make_clickable " ), $mes -> render () . $text );
2009-07-09 02:47:17 +00:00
2008-01-26 04:47:27 +00:00
}
2006-12-02 04:36:16 +00:00
2009-07-07 06:26:51 +00:00
function show_message ( $message , $type = E_MESSAGE_INFO , $session = false )
{
// ##### Display comfort ---------
2013-02-26 16:36:25 +01:00
$mes = e107 :: getMessage ();
$mes -> add ( $message , $type , $session );
2009-07-07 06:26:51 +00:00
}
2009-07-07 02:22:57 +00:00
2009-08-31 14:37:24 +00:00
function pluginMenuOptions ()
2009-07-09 02:47:17 +00:00
{
// $e107 = &e107::getInstance();
2006-12-02 04:36:16 +00:00
2009-07-09 02:47:17 +00:00
$var [ 'installed' ][ 'text' ] = EPL_ADLAN_22 ;
$var [ 'installed' ][ 'link' ] = e_SELF ;
2006-12-02 04:36:16 +00:00
2009-07-09 02:47:17 +00:00
$var [ 'avail' ][ 'text' ] = EPL_ADLAN_23 ;
$var [ 'avail' ][ 'link' ] = e_SELF . " ?avail " ;
2012-07-20 07:31:16 +00:00
// $var['upload']['text'] = EPL_ADLAN_38;
// $var['upload']['link'] = e_SELF."?upload";
2013-05-03 21:34:59 -07:00
$var [ 'online' ][ 'text' ] = " Find Plugins " ;
2012-07-24 00:42:17 +00:00
$var [ 'online' ][ 'link' ] = e_SELF . " ?mode=online " ;
2012-12-02 01:14:02 -08:00
$var [ 'create' ][ 'text' ] = " Plugin Builder " ;
$var [ 'create' ][ 'link' ] = e_SELF . " ?mode=create " ;
2009-07-09 02:47:17 +00:00
$keys = array_keys ( $var );
2006-12-02 04:36:16 +00:00
2009-07-09 02:47:17 +00:00
$action = ( in_array ( $this -> action , $keys )) ? $this -> action : " installed " ;
2012-12-03 01:40:47 -08:00
e107 :: getNav () -> admin ( ADLAN_98 , $action , $var );
2009-07-09 02:47:17 +00:00
}
2006-12-02 04:36:16 +00:00
2008-12-30 19:01:17 +00:00
2012-12-02 01:14:02 -08:00
2009-07-09 02:47:17 +00:00
} // end of Class.
2008-12-30 19:01:17 +00:00
2009-07-07 02:22:57 +00:00
2009-07-09 02:47:17 +00:00
function plugin_adminmenu ()
{
global $pman ;
2009-08-31 14:37:24 +00:00
$pman -> pluginMenuOptions ();
2006-12-02 04:36:16 +00:00
}
2012-12-02 01:14:02 -08:00
/**
* Plugin Admin Generator by CaMer0n . //TODO Incorporate plugin.xml generation
*/
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 ();
var $createFiles = false ;
2012-12-02 01:14:02 -08:00
function __construct ()
{
$this -> special [ 'checkboxes' ] = array ( 'title' => '' , 'type' => null , 'data' => null , 'width' => '5%' , 'thclass' => 'center' , 'forced' => TRUE , 'class' => 'center' , 'toggle' => 'e-multiselect' , 'fieldpref' => true );
$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-15 18:06:55 -08:00
if ( vartrue ( $_GET [ 'newplugin' ]))
2012-12-02 18:12:46 -08:00
{
$this -> pluginName = $_GET [ 'newplugin' ];
}
2013-04-15 14:08:54 -07:00
if ( vartrue ( $_GET [ 'createFiles' ]))
{
$this -> createFiles = true ;
}
2012-12-02 18:12:46 -08:00
2012-12-02 01:14:02 -08:00
if ( vartrue ( $_POST [ 'step' ]) == 3 )
{
2012-12-02 18:12:46 -08:00
$this -> step3 ();
return ;
2012-12-02 01:14:02 -08:00
}
if ( vartrue ( $_GET [ 'newplugin' ]) && $_GET [ 'step' ] == 2 )
{
return $this -> step2 ();
}
return $this -> step1 ();
}
function step1 ()
{
$fl = e107 :: getFile ();
$frm = e107 :: getForm ();
$ns = e107 :: getRender ();
$mes = e107 :: getMessage ();
$plugFolders = $fl -> get_dirs ( e_PLUGIN );
foreach ( $plugFolders as $dir )
{
2012-12-10 18:41:24 -08:00
if ( file_exists ( e_PLUGIN . $dir . " /admin_config.php " ))
2012-12-02 01:14:02 -08:00
{
continue ;
}
$newDir [ $dir ] = $dir ;
}
$mes -> addInfo ( " This Wizard will build an admin area for your plugin and generate a plugin.xml meta file.
Before you start : < ul >
< li > Create a new writable folder in the " .e_PLUGIN. " directory eg . < b > myplugin </ b ></ li >
2012-12-10 18:41:24 -08:00
< li > If your plugin will use sql tables , create a new file in this folder and name it the same as the directory but with < b > _sql . php </ b > as a sufix eg . < b > myplugin_sql . php </ b ></ li >
2012-12-02 01:14:02 -08:00
< li > Create your table in Phpmyadmin and paste an sql dump of it into your file and save . ( see < il > e107_plugins / _blank / _blank_sql . php </ i > for an example ) </ li >
< li > Select your plugin ' s folder to begin .</ li >
</ ul >
" );
$text = $frm -> open ( 'createPlugin' , 'get' );
2012-12-02 18:12:46 -08:00
$text .= " <table class='table adminform'>
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tr >
< td > Select your plugin ' s folder </ td >
2013-04-25 17:29:46 -07:00
< td > " . $frm->select ( " newplugin " , $newDir ). " </ td >
2012-12-06 20:34:57 -08:00
</ tr > " ;
$text .= "
< tr >
< td > Create Files </ td >
< td > " . $frm->checkbox ('createFiles',1,1). " </ td >
</ tr > " ;
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' >
" . $frm->admin_button ('step', 2,'other','Go'). "
</ div > " ;
2013-02-22 21:34:06 -08:00
2012-12-02 01:14:02 -08:00
$text .= $frm -> close ();
2013-02-22 21:34:06 -08:00
$ns -> tablerender ( ADLAN_98 . SEP . " Plugin Builder " , $mes -> render () . $text );
2012-12-02 01:14:02 -08:00
}
2012-12-02 18:12:46 -08:00
function enterMysql ()
{
$frm = e107 :: getForm ();
return " <div> " . $frm -> textarea ( 'mysql' , '' , 10 , 80 ) . " </div> " ;
}
2012-12-02 01:14:02 -08:00
function step2 ()
{
require_once ( e_HANDLER . " db_verify_class.php " );
$dv = new db_verify ;
$frm = e107 :: getForm ();
$ns = e107 :: getRender ();
$mes = e107 :: getMessage ();
$newplug = $_GET [ 'newplugin' ];
$this -> pluginName = $newplug ;
2012-12-02 18:12:46 -08:00
// $data = e107::getXml()->loadXMLfile(e_PLUGIN.'links_page/plugin.xml', 'advanced');
// print_a($data);
// echo "<pre>".var_export($data,true)."</pre>";
2012-12-10 18:41:24 -08:00
$sqlFile = e_PLUGIN . $newplug . " / " . $newplug . " _sql.php " ;
2012-12-02 18:12:46 -08:00
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 );
$ret = $dv -> getTables ( $data );
}
2012-12-02 01:14:02 -08:00
2013-04-15 14:08:54 -07:00
$text = $frm -> open ( 'newplugin-step3' , 'post' , e_SELF . '?mode=create&newplugin=' . $newplug . '&createFiles=' . $this -> createFiles . '&step=3' );
2013-02-25 02:47:23 -08:00
$text .= " <ul class='nav nav-tabs'> \n " ;
$text .= " <li class='active'><a data-toggle='tab' href='#xml'>Basic Info.</a></li> " ;
2012-12-02 01:14:02 -08:00
2012-12-05 16:43:53 -08:00
$this -> tableCount = count ( $ret [ 'tables' ]);
2012-12-02 01:14:02 -08:00
foreach ( $ret [ 'tables' ] as $key => $table )
{
2013-02-25 02:47:23 -08:00
$text .= " <li><a data-toggle='tab' href='# " . $table . " '>Table: " . $table . " </a></li> " ;
2013-04-15 14:08:54 -07:00
$this -> tableList [] = $table ;
2012-12-02 01:14:02 -08:00
}
2013-02-25 02:47:23 -08:00
$text .= " <li><a data-toggle='tab' href='#preferences'>Preferences</a></li> " ;
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> " ;
2012-12-02 01:14:02 -08:00
foreach ( $ret [ 'tables' ] as $key => $table )
{
2013-02-25 02:47:23 -08:00
$text .= " <div class='tab-pane' id=' " . $table . " '> \n " ;
2012-12-02 01:14:02 -08:00
$fields = $dv -> getFields ( $ret [ 'data' ][ $key ]);
$text .= $this -> form ( $table , $fields );
2013-02-25 02:47:23 -08:00
$text .= " </div> " ;
2012-12-02 01:14:02 -08: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> " ;
2012-12-02 01:14:02 -08:00
$text .= " </div> " ;
$text .= "
< div class = 'buttons-bar center' >
" . $frm->hidden ('newplugin', $this->pluginName ). "
" . $frm->admin_button ('step', 3,'other','Generate'). "
</ div > " ;
$text .= $frm -> close ();
$mes -> addInfo ( " Review all fields and modify if necessary. " );
2012-12-05 16:43:53 -08:00
$mes -> addInfo ( " Review ALL tabs before clicking 'Generate'. " );
2012-12-02 01:14:02 -08:00
2013-02-22 21:34:06 -08:00
$ns -> tablerender ( ADLAN_98 . SEP . " Plugin Builder " . SEP . " Step 2 " , $mes -> render () . $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 (
'text' => " Text Box " ,
'bbarea' => " Rich-Text Area " ,
'boolean' => " Text Area " ,
" method " => " Custom Function " ,
" image " => " Image " ,
);
for ( $i = 0 ; $i < 10 ; $i ++ )
{
$text .= " <div> " .
$frm -> text ( " pluginPrefs[ " . $i . " ][index] " , '' , 40 , 'placeholder=Preference Name' ) . " " .
$frm -> text ( " pluginPrefs[ " . $i . " ][value] " , '' , 40 , 'placeholder=Default Value' ) . " " .
$frm -> select ( " pluginPrefs[ " . $i . " ][type] " , $options , '' , 'class=null' , 'Field Type...' ) .
" </div> " ;
}
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' ),
2012-12-05 16:43:53 -08:00
'keywords' => array ( 'one' , 'two' ),
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 ))
{
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 ))
{
$mes -> addInfo ( $this -> pluginName . " _sql.php as been generated " , 'default' , true );
$red = e107 :: getRedirect ();
$red -> redirect ( e_REQUEST_URL , true );
// $red->redirect(e_SELF."?mode=create&newplugin=".$this->pluginName."&createFiles=1&step=2",true);
}
else
{
$msg = $this -> pluginName . " _sql.php is missing!<br /> " ;
$msg .= " Please create <b> " . $this -> pluginName . " _sql.php</b> in your plugin directory with the following content:<pre> " . $cont . " </pre> " ;
$mes -> addWarning ( $msg );
}
}
}
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 ] " ;
$size = ( count ( $val ) == 1 ) ? 'span7' : 'span2' ;
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 );
$size = 30 ;
$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' :
$help = " The name of your plugin. (Must be written in English) " ;
$required = true ;
2013-07-08 11:18:51 -07:00
$pattern = " [A-Za-z0-9 ]* " ;
2012-12-02 18:12:46 -08:00
break ;
case 'main-lang' :
$help = " If you have a language file, enter the LAN_XXX value for the plugin's name " ;
$required = false ;
2012-12-05 19:28:22 -08:00
$placeholder = " " ;
$pattern = " [A-Z0-9_]* " ;
2012-12-02 18:12:46 -08:00
break ;
case 'main-date' :
$help = " Creation date of your plugin " ;
$required = true ;
break ;
case 'main-version' :
$default = '1.0' ;
$required = true ;
2012-12-05 19:28:22 -08:00
$help = " The version of your plugin. Format: x.x " ;
$pattern = " ^[ \ d] { 1,2} \ .[ \ d] { 1,2} $ " ;
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 ;
$help = " Compatible with this version of e107 " ;
2012-12-05 19:28:22 -08:00
$pattern = " ^[ \ d] { 1,2} \ .[ \ d] { 1,2} $ " ;
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 ;
$help = " Author Name " ;
2012-12-05 19:28:22 -08:00
$pattern = " [A-Za-z \ .0-9]* " ;
2012-12-02 18:12:46 -08:00
break ;
case 'author-url' :
$required = true ;
$help = " Author Website Url " ;
2012-12-05 21:30:17 -08:00
// $pattern = "https?://.+";
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' :
$help = " A short one-line description of the plugin<br />(Must be written in English) " ;
$required = true ;
$size = 100 ;
$placeholder = " " ;
2012-12-05 19:28:22 -08:00
$pattern = " [A-Za-z \ .0-9]* " ;
2012-12-05 16:43:53 -08:00
break ;
case 'keywords-one' :
case 'keywords-two' :
$help = " Keyword/Tag for this plugin<br />(Must be written in English) " ;
$required = true ;
$size = 20 ;
$placeholder = " " ;
2012-12-05 19:28:22 -08:00
$pattern = '^[a-z]*$' ;
2012-12-05 16:43:53 -08:00
break ;
2012-12-02 18:12:46 -08:00
case 'description-description' :
2012-12-05 16:43:53 -08:00
$help = " A full description of the plugin<br />(Must be written in English) " ;
2012-12-02 18:12:46 -08:00
$required = true ;
$size = 100 ;
2012-12-05 16:43:53 -08:00
$placeholder = " " ;
2012-12-05 19:28:22 -08:00
$pattern = " [A-Za-z \ .0-9]* " ;
2012-12-02 18:12:46 -08:00
break ;
case 'category-category' :
$help = " What category of plugin is this? " ;
$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 ;
2012-12-05 19:28:22 -08:00
$pat = ( $pattern ) ? " &pattern= " . $pattern : " " ;
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' :
2013-05-25 16:03:53 -07:00
$text = $frm -> datepicker ( $name , time (), 'format=yyyy-mm-dd' . $req );
2012-12-05 16:43:53 -08:00
break ;
case 'description' :
2012-12-05 19:28:22 -08:00
$text = $frm -> textarea ( $name , $default , 3 , 100 , $req ); // 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 (
2012-12-02 18:12:46 -08:00
'settings' => 'settings' ,
'users' => 'users' ,
'content' => 'content' ,
'tools' => 'tools' ,
'manage' => 'manage' ,
'misc' => 'misc' ,
'menu' => 'menu' ,
'about' => 'about'
2012-12-05 16:43:53 -08:00
);
2012-12-02 18:12:46 -08:00
2013-04-25 17:29:46 -07:00
$text = $frm -> select ( $name , $options , '' , 'required=1&class=null' , true );
2012-12-05 16:43:53 -08:00
break ;
default :
2012-12-05 19:28:22 -08:00
$text = $frm -> text ( $name , $default , $size , 'placeholder=' . $placeholder . $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 ));
$newArray [ $key ] = $val ;
}
2012-12-05 19:28:22 -08:00
$newArray [ 'DESCRIPTION_DESCRIPTION' ] = strip_tags ( $tp -> toHtml ( $newArray [ 'DESCRIPTION_DESCRIPTION' ], true ));
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']);
if ( count ( $plugPref ))
{
$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 >
</ keywords >
2012-12-02 18:12:46 -08:00
< category > { CATEGORY_CATEGORY } </ category >
< copyright > { COPYRIGHT_COPYRIGHT } </ copyright >
< adminLinks >
< link url = " admin_config.php " description = " { ADMINLINKS_DESCRIPTION} " icon = " images/icon_32.png " iconSmall = " images/icon_16.png " primary = " true " > LAN_CONFIGURE </ link >
</ 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 " ;
2013-04-15 14:08:54 -07:00
if ( $this -> createFiles == true )
2012-12-02 18:12:46 -08:00
{
2013-04-15 14:08:54 -07:00
if ( file_put_contents ( $path , $result ) )
{
$mes -> addSuccess ( " Saved: " . $path );
}
else {
$mes -> addError ( " Couldn't Save: " . $path );
}
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 )
{
$frm = e107 :: getForm ();
2013-01-22 00:21:11 -08:00
$modes = array ( " main " => " Main Area " , " cat " => " Categories " , " other1 " => " Other 1 " , " other2 " => " Other 2 " );
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 )
{
$tbl = $this -> tableList [ $c ];
$defaultMode [ $tbl ] = $id ;
$c ++ ;
}
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' );
}
2012-12-02 01:14:02 -08:00
$text .= " </table> " . $this -> special ( 'checkboxes' );
$text .= " <table class='table adminlist'>
< thead >
< tr >
< th > Field </ th >
< th > Caption </ th >
< th > Type </ th >
< th > Data </ th >
< th > Width </ th >
< th class = 'center' > Batch </ th >
< th class = 'center' > Filter </ th >
2013-04-15 14:08:54 -07:00
< th class = 'center' > Inline </ th >
2012-12-02 01:14:02 -08:00
< th class = 'center e-tip' title = 'Field is required to be filled' > Validate </ th >
< th class = 'center e-tip' title = 'Displayed by Default' > Display </ th >
< th > HelpTip </ th >
< th > ReadParms </ th >
< th > WriteParms </ th >
</ tr >
</ thead >
< tbody >
" ;
foreach ( $fieldArray as $name => $val )
{
list ( $tmp , $nameDef ) = explode ( " _ " , $name , 2 );
// 'faq_question', 'faq_answer', 'faq_parent', 'faq_datestamp'
$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 >
2013-04-15 14:08:54 -07:00
< td > " . $frm->text ( $this->table . " [ fields ][ " . $name . " ][ help ] " ,'', 50,'size=medium'). " </ td >
< td > " . $frm->text ( $this->table . " [ fields ][ " . $name . " ][ readParms ] " ,'', 20,'size=small'). " </ td >
< td > " . $frm->text ( $this->table . " [ fields ][ " . $name . " ][ writeParms ] " ,'', 20,'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 ;
}
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 )
{
case 'int' :
case 'tinyint' :
case 'smallint' :
$array = array (
2013-05-24 17:15:11 +02:00
" boolean " => " True/False " ,
2012-12-02 01:14:02 -08:00
" number " => " Text Box " ,
" dropdown " => " DropDown " ,
" userclass " => " DropDown (userclasses) " ,
" datestamp " => " Date " ,
" method " => " Custom Function " ,
2013-01-22 00:21:11 -08:00
" hidden " => " Hidden " ,
" user " => " User " ,
2012-12-02 01:14:02 -08:00
);
break ;
2013-04-15 14:08:54 -07:00
case 'decimal' :
$array = array (
" number " => " Text Box " ,
" dropdown " => " DropDown " ,
" method " => " Custom Function " ,
" hidden " => " Hidden " ,
);
break ;
2012-12-02 01:14:02 -08:00
case 'varchar' :
2012-12-06 20:34:57 -08:00
case 'tinytext' :
2012-12-02 01:14:02 -08:00
$array = array (
'text' => " Text Box " ,
" dropdown " => " DropDown " ,
" userclass " => " DropDown (userclasses) " ,
" url " => " Text Box (url) " ,
" icon " => " Icon " ,
" image " => " Image " ,
" method " => " Custom Function " ,
" hidden " => " Hidden "
);
break ;
case 'text' :
2012-12-06 21:41:53 -08:00
case 'mediumtext' :
case 'longtext' :
2012-12-02 01:14:02 -08:00
$array = array (
'textarea' => " Text Area " ,
'bbarea' => " Rich-Text Area " ,
'text' => " Text Box " ,
" method " => " Custom Function " ,
2012-12-02 18:12:46 -08:00
" image " => " Image " ,
2012-12-02 01:14:02 -08:00
" hidden " => " Hidden "
);
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.
function guess ( $data , $val = '' , $mode = 'type' )
{
$tmp = explode ( " _ " , $data );
if ( count ( $tmp ) == 3 ) // eg Link_page_title
{
$name = $tmp [ 2 ];
}
else // Link_description
{
$name = $tmp [ 1 ];
}
$ret [ 'title' ] = ucfirst ( $name );
2012-12-03 13:21:50 -08:00
$ret [ 'width' ] = 'auto' ;
$ret [ 'class' ] = 'left' ;
$ret [ 'thclass' ] = 'left' ;
2012-12-02 01:14:02 -08:00
//echo "<br />name=".$name;
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 ;
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 ;
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 ;
case 'category' :
$ret [ 'title' ] = 'LAN_CATEGORY' ;
$ret [ 'type' ] = 'dropdown' ;
$ret [ 'batch' ] = true ;
$ret [ 'filter' ] = true ;
$ret [ 'fieldpref' ] = true ;
2013-04-15 14:08:54 -07:00
$ret [ 'inline' ] = false ;
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 ;
case 'description' :
$ret [ 'title' ] = 'LAN_DESCRIPTION' ;
$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' ;
2012-12-03 13:21:50 -08:00
$ret [ 'class' ] = 'center' ;
2012-12-02 01:14:02 -08:00
$ret [ 'batch' ] = false ;
$ret [ 'filter' ] = false ;
2012-12-03 13:21:50 -08:00
$ret [ 'thclass' ] = 'center' ;
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' ,
2013-01-22 00:21:11 -08:00
'mediumblob' , 'longblob' , 'tinytext' , 'mediumtext' , 'longtext' , 'text' , 'date' , 'varchar' , 'char' );
2012-12-06 20:34:57 -08:00
if ( in_array ( strtolower ( $type ), $strings ))
2012-12-02 01:14:02 -08:00
{
$value = 'str' ;
}
else
{
$value = 'int' ;
}
$fname = $this -> table . " [fields][ " . $name . " ][data] " ;
return $frm -> hidden ( $fname , $value ) . " <a href='#' class='e-tip' title=' { $type } ' > " . $value . " </a> " ;
}
// ******************************** CODE GENERATION AREA *************************************************
function step3 ()
{
2012-12-05 16:43:53 -08:00
$pluginTitle = $_POST [ 'xml' ][ 'main-name' ] ;
2012-12-02 18:12:46 -08:00
if ( $_POST [ 'xml' ])
{
2012-12-05 16:43:53 -08:00
$xmlText = $this -> createXml ( $_POST [ 'xml' ]);
2012-12-02 18:12:46 -08:00
}
unset ( $_POST [ 'step' ], $_POST [ 'xml' ]);
2013-05-18 18:23:24 -07:00
$thePlugin = $_POST [ 'newplugin' ];
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' ))
{
header ( 'location:' . e_BASE . 'index.php' );
exit ;
}
2013-05-18 18:23:24 -07:00
class " . $ thePlugin . " _admin extends e_admin_dispatcher
2012-12-02 01:14:02 -08:00
{
protected \ $modes = array (
" ;
2013-05-18 18:23:24 -07:00
2012-12-02 01:14:02 -08:00
unset ( $_POST [ 'newplugin' ]);
foreach ( $_POST as $table => $vars ) // LOOP Through Tables.
{
2013-05-18 18:23:24 -07:00
if ( vartrue ( $vars [ 'mode' ]))
{
2012-12-02 01:14:02 -08:00
$text .= "
'".$vars[' mode ']."' => array (
'controller' => '".$vars[' table ']."_ui' ,
'path' => null ,
'ui' => '".$vars[' table ']."_form_ui' ,
'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.
{
2013-05-18 18:23:24 -07:00
if ( vartrue ( $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 .= "
// 'main/custom' => array('caption'=> 'Custom Page', 'perm' => 'P')
2012-12-02 01:14:02 -08:00
);
protected \ $adminMenuAliases = array (
'main/edit' => 'main/list'
);
2013-11-08 22:38:09 -08:00
protected \ $menuTitle = '".vartrue($vars[' pluginName '],' Nav ')."' ;
2012-12-02 01:14:02 -08:00
}
" ;
// print_a($_POST);
$srch = array (
" \n " ,
" ), " ,
" " ,
" 'batch' => '1' " ,
" 'filter' => '1' " ,
2013-04-15 14:08:54 -07:00
" 'inline' => '1' " ,
2012-12-02 01:14:02 -08:00
" 'validate' => '1' " ,
" , 'fieldpref' => '1' " ,
2013-01-22 00:21:11 -08:00
" 'type' => '' " ,
" 'data' => '' "
2012-12-02 01:14:02 -08:00
);
$repl = array (
" " ,
" ), \n \t \t " ,
" " ,
" 'batch' => true " ,
" 'filter' => true " ,
2013-04-15 14:08:54 -07:00
" 'inline' => true " ,
2012-12-02 01:14:02 -08:00
" 'validate' => true " ,
2013-01-22 00:21:11 -08:00
" " ,
" 'type' => null " ,
" 'data' => null "
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.
{
2013-05-18 18:23:24 -07:00
if ( $table == 'pluginPrefs' )
{
continue ;
}
2012-12-02 01:14:02 -08:00
$FIELDS = str_replace ( $srch , $repl , var_export ( $vars [ 'fields' ], true ));
2013-05-18 18:23:24 -07:00
$FIELDS = preg_replace ( " #('([A-Z0-9_]*?LAN[_A-Z0-9]*)')# " , " $ 2 " , $FIELDS ); // remove quotations from LANs.
2012-12-02 01:14:02 -08:00
$FIELDPREF = array ();
foreach ( $vars [ 'fields' ] as $k => $v )
{
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 ']."' ;
protected \ $table = '".$vars[' table ']."' ;
protected \ $pid = '".$vars[' pid ']."' ;
protected \ $perPage = 10 ;
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
{
$text .= "
2012-12-02 01:14:02 -08:00
2013-05-18 18:23:24 -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 )
{
if ( vartrue ( $val [ 'index' ]))
{
$index = $val [ 'index' ];
$type = vartrue ( $val [ 'type' ], 'text' );
$text .= " \t \t \t ' " . $index . " ' \t \t => array('title'=> ' " . ucfirst ( $index ) . " ', 'type'=>' " . $type . " ', 'data' => 'string','help'=>'Help Text goes here'), \n " ;
}
}
$text .= " \t \t ); \n \n " ;
}
2012-12-02 01:14:02 -08:00
2013-05-18 18:23:24 -07:00
$text .= "
/*
2012-12-02 01:14:02 -08:00
// optional
public function init ()
{
}
public function customPage ()
{
\ $ns = e107 :: getRender ();
\ $text = 'Hello World!' ;
\ $ns -> tablerender ( 'Hello' , \ $text );
}
2013-04-15 14:08:54 -07:00
*/
2012-12-02 01:14:02 -08:00
}
class " . $ vars [ 'table' ] . " _form_ui extends e_admin_form_ui
{
" ;
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 )
{
\ $frm = e107 :: getForm ();
switch ( \ $mode )
{
case 'read' : // List Page
return \ $curVal ;
break ;
case 'write' : // Edit Page
return \ $frm -> text ( '".$fld."' , \ $curVal );
break ;
case 'filter' :
case 'batch' :
return \ $array ;
break ;
}
}
" ;
}
$text .= "
}
" ;
2013-05-18 18:23:24 -07:00
$tableCount ++ ;
2012-12-02 01:14:02 -08:00
} // End LOOP.
$text .= '
2013-05-18 18:23:24 -07:00
new '.$thePlugin.' _admin ();
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 " ;
$endPHP = " ?> " ;
2013-04-15 14:08:54 -07:00
if ( $this -> createFiles == true )
2012-12-02 01:14:02 -08:00
{
2013-04-15 14:08:54 -07:00
if ( file_put_contents ( $generatedFile , $startPHP . $text . $endPHP ))
{
$mes -> addSuccess ( " <a href=' " . $generatedFile . " '>Click Here</a> to vist your generated admin area " );
}
else
{
$mes -> addError ( " Could not write to " . $generatedFile );
}
}
else
2012-12-02 01:14:02 -08:00
{
2013-04-15 14:08:54 -07:00
$mes -> addInfo ( " No Files have been created. Please Copy & Paste the code below into your files. " );
2012-12-02 01:14:02 -08:00
}
2012-12-02 18:12:46 -08:00
echo $mes -> render ();
2013-04-15 14:08:54 -07:00
$ns -> tablerender ( ADLAN_98 . SEP . " Plugin Builder " . SEP . " plugin.xml " , " <pre style='font-size:80%'> " . $xmlText . " </pre> " );
2012-12-02 18:12:46 -08:00
2013-04-15 14:08:54 -07:00
$ns -> tablerender ( " admin_config.php " , " <pre style='font-size:80%'> " . $text . " </pre> " );
2012-12-02 01:14:02 -08:00
//
return ;
}
}
2008-01-26 04:47:27 +00:00
?>