mirror of
https://github.com/e107inc/e107.git
synced 2025-08-05 14:17:49 +02:00
Fixed #2921 - Plugin LANs. Scan Plugin Directories now uses the newer e_plugin class.
This commit is contained in:
@@ -1470,6 +1470,8 @@ class system_tools
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Plugin Folder Scanner
|
||||
* @return none
|
||||
@@ -1479,7 +1481,6 @@ class system_tools
|
||||
$error_messages = array(0 => DBLAN_31, 1 => LAN_ERROR, 2 => DBLAN_33, 3 => DBLAN_34);
|
||||
// $error_image = array("integrity_pass.png", "integrity_fail.png", "warning.png", "blank.png");
|
||||
$error_glyph = array(ADMIN_TRUE_ICON,ADMIN_FALSE_ICON,ADMIN_WARNING_ICON,"<i style='display:inline-block;width:17px;height:16px;'> </i>");
|
||||
|
||||
$error_type = array('warning'=>2, 'error'=>1);
|
||||
|
||||
|
||||
@@ -1489,16 +1490,10 @@ class system_tools
|
||||
$frm = e107::getForm();
|
||||
$mes = e107::getMessage();
|
||||
|
||||
require_once (e_HANDLER."plugin_class.php");
|
||||
$ep = new e107plugin();
|
||||
$ep->update_plugins_table($mode); // scan for e_xxx changes and save to plugin table.
|
||||
$ep->save_addon_prefs($mode); // generate global e_xxx_list prefs from plugin table.
|
||||
|
||||
/* we all are awaiting for PHP5 only support - method chaining...
|
||||
$mes->add(DBLAN_22.' - '.DBLAN_23, E_MESSAGE_SUCCESS)
|
||||
->add("<a href='".e_SELF."'>".LAN_BACK."</a>", E_MESSAGE_SUCCESS)
|
||||
->add(DBLAN_30);
|
||||
*/
|
||||
// require_once (e_HANDLER."plugin_class.php");
|
||||
// $ep = new e107plugin();
|
||||
// $ep->update_plugins_table($mode); // scan for e_xxx changes and save to plugin table.
|
||||
// $ep->save_addon_prefs($mode); // generate global e_xxx_list prefs from plugin table.
|
||||
|
||||
$mes->add(DBLAN_23, E_MESSAGE_SUCCESS);
|
||||
$mes->add("<a href='".e_SELF."'>".LAN_BACK."</a>", E_MESSAGE_SUCCESS);
|
||||
@@ -1526,13 +1521,80 @@ class system_tools
|
||||
<tbody>
|
||||
";
|
||||
|
||||
|
||||
$plg = e107::getPlug()->clearCache();
|
||||
|
||||
$plg->buildAddonPrefLists();
|
||||
|
||||
foreach($plg->getDetected() as $folder)
|
||||
{
|
||||
$plg->load($folder);
|
||||
|
||||
$name = $plg->getName();
|
||||
$addons = $plg->getAddons();
|
||||
|
||||
$text .= "
|
||||
<tr>
|
||||
<td>".$name."</td>
|
||||
<td>".$folder."</td>
|
||||
<td>";
|
||||
|
||||
if(!empty($addons))
|
||||
{
|
||||
|
||||
foreach(explode(',', $addons) as $this_addon)
|
||||
{
|
||||
$ret_code = 3; // Default to 'not checked
|
||||
if((strpos($this_addon, 'e_') === 0) || (substr($this_addon, - 4, 4) == '_sql'))
|
||||
{
|
||||
$ret_code = $plg->getAddonErrors($this_addon); // See whether spaces before opening tag or after closing tag
|
||||
}
|
||||
elseif(strpos($this_addon, 'sc_') === 0)
|
||||
{
|
||||
$this_addon = substr($this_addon, 3). ' (sc)';
|
||||
}
|
||||
|
||||
if(!is_numeric($ret_code))
|
||||
{
|
||||
$errorMessage = $ret_code['msg'];
|
||||
$ret_code = $error_type[$ret_code['type']];
|
||||
}
|
||||
else
|
||||
{
|
||||
$errorMessage = $error_messages[$ret_code];
|
||||
}
|
||||
|
||||
$text .= "<span class='clear e-tip' style='cursor:pointer' title='".$errorMessage."'>";
|
||||
$text .= $error_glyph[$ret_code]." ";
|
||||
|
||||
$text .= trim($this_addon); // $ret_code - 0=OK, 1=content error, 2=access error
|
||||
$text .= "</span><br />";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$text .= " </td>
|
||||
<td class='center'>";
|
||||
|
||||
$text .= ($plg->isInstalled() === true) ? "<span class='label label-warning'>".DBLAN_27."</span>" : " ";
|
||||
|
||||
|
||||
$text .= " </td>
|
||||
</tr>
|
||||
";
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
$sql->select("plugin", "*", "plugin_id !='' order by plugin_path ASC"); // Must order by path to pick up duplicates. (plugin names may change).
|
||||
$previous = '';
|
||||
while($row = $sql->fetch())
|
||||
{
|
||||
e107::loadLanFiles($row['plugin_path'],'admin');
|
||||
e107::plugLan($row['plugin_path'],'global',true);
|
||||
|
||||
e107::plugLan($row['plugin_path'],'global',true);
|
||||
|
||||
$text .= "
|
||||
<tr>
|
||||
<td>".$tp->toHtml($row['plugin_name'], FALSE, "defs,emotes_off")."</td>
|
||||
@@ -1596,7 +1658,7 @@ class system_tools
|
||||
</tr>
|
||||
";
|
||||
$previous = $row['plugin_path'];
|
||||
}
|
||||
}*/
|
||||
|
||||
$text .= "
|
||||
</tbody>
|
||||
@@ -1607,6 +1669,10 @@ class system_tools
|
||||
|
||||
e107::getRender()->tablerender(DBLAN_10.SEP.DBLAN_22, $mes->render().$text);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//XXX - what is this for (backup core)? <input type='hidden' name='sqltext' value='{$sqltext}' />
|
||||
|
@@ -311,6 +311,82 @@ class e_plugin
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the currently loaded plugin is installed
|
||||
* @return mixed
|
||||
*/
|
||||
public function isInstalled()
|
||||
{
|
||||
if(empty($this->_plugdir))
|
||||
{
|
||||
e107::getDebug()->log("\$this->_plugdir is empty ".__FILE__." ". __CLASS__ ."::".__METHOD__);
|
||||
}
|
||||
|
||||
|
||||
return in_array($this->_plugdir, array_keys($this->_installed));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the currently loaded plugin's addon has errors.
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAddonErrors($e_xxx)
|
||||
{
|
||||
if (is_readable(e_PLUGIN.$this->_plugdir."/".$e_xxx.".php"))
|
||||
{
|
||||
$content = file_get_contents(e_PLUGIN.$this->_plugdir."/".$e_xxx.".php");
|
||||
}
|
||||
else
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
if(substr($e_xxx, - 4, 4) == '_sql')
|
||||
{
|
||||
|
||||
if(strpos($content,'INSERT INTO')!==false)
|
||||
{
|
||||
return array('type'=> 'error', 'msg'=>"INSERT sql commands are not permitted here. Use a ".$this->_plugdir."_setup.php file instead.");
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Generic markup check
|
||||
if ((substr($content, 0, 5) != '<'.'?php') || ((substr($content, -2, 2) != '?'.'>') && (strrpos($content, '?'.'>') !== FALSE)))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if($e_xxx == 'e_meta' && strpos($content,'<script')!==false)
|
||||
{
|
||||
return array('type'=> 'warning', 'msg'=>"Contains script tags. Use e_header.php with the e107::js() function instead.");
|
||||
}
|
||||
|
||||
|
||||
if($e_xxx == 'e_latest' && strpos($content,'<div')!==false)
|
||||
{
|
||||
return array('type'=> 'warning', 'msg'=>"Using deprecated method. See e_latest.php in the forum plugin for an example.");
|
||||
}
|
||||
|
||||
if($e_xxx == 'e_status' && strpos($content,'<div')!==false)
|
||||
{
|
||||
return array('type'=> 'warning', 'msg'=>"Using deprecated method. See e_status.php in the forum plugin for an example.");
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getUpgradableList()
|
||||
{
|
||||
@@ -476,6 +552,7 @@ class e_plugin
|
||||
}
|
||||
|
||||
|
||||
|
||||
return implode(',', $addons);
|
||||
|
||||
|
||||
@@ -817,6 +894,134 @@ class e_plugin
|
||||
|
||||
|
||||
|
||||
public function buildAddonPrefLists()
|
||||
{
|
||||
$core = e107::getConfig('core');
|
||||
|
||||
foreach ($this->_addon_types as $var) // clear all existing prefs.
|
||||
{
|
||||
$core->update($var.'_list', "");
|
||||
}
|
||||
|
||||
// reset
|
||||
$core->set('bbcode_list', array())
|
||||
->set('shortcode_legacy_list', array())
|
||||
->set('shortcode_list', array());
|
||||
|
||||
|
||||
foreach($this->getDetected() as $path)
|
||||
{
|
||||
|
||||
$this->load($path);
|
||||
|
||||
$is_installed = $this->isInstalled();
|
||||
$tmp = explode(",", $this->getAddons());
|
||||
|
||||
|
||||
if ($is_installed)
|
||||
{
|
||||
foreach ($tmp as $val)
|
||||
{
|
||||
if (strpos($val, 'e_') === 0)
|
||||
{
|
||||
$core->setPref($val.'_list/'.$path, $path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// search for .bb and .sc files.
|
||||
$scl_array = array();
|
||||
$sc_array = array();
|
||||
$bb_array = array();
|
||||
// $sql_array = array();
|
||||
|
||||
foreach ($tmp as $adds)
|
||||
{
|
||||
// legacy shortcodes - plugin root *.sc files
|
||||
if (substr($adds, -3) === ".sc")
|
||||
{
|
||||
$sc_name = substr($adds, 0, -3); // remove the .sc
|
||||
if ($is_installed)
|
||||
{
|
||||
$scl_array[$sc_name] = "0"; // default userclass = e_UC_PUBLIC
|
||||
}
|
||||
else
|
||||
{
|
||||
$scl_array[$sc_name] = e_UC_NOBODY; // register shortcode, but disable it
|
||||
}
|
||||
}
|
||||
// new shortcodes location - shortcodes/single/*.php
|
||||
elseif (substr($adds, 0, 3) === "sc_")
|
||||
{
|
||||
$sc_name = substr(substr($adds, 3), 0, -4); // remove the sc_ and .php
|
||||
|
||||
if ($is_installed)
|
||||
{
|
||||
$sc_array[$sc_name] = "0"; // default userclass = e_UC_PUBLIC
|
||||
}
|
||||
else
|
||||
{
|
||||
$sc_array[$sc_name] = e_UC_NOBODY; // register shortcode, but disable it
|
||||
}
|
||||
}
|
||||
|
||||
if($is_installed)
|
||||
{
|
||||
// simple bbcode
|
||||
if(substr($adds,-3) == ".bb")
|
||||
{
|
||||
$bb_name = substr($adds, 0,-3); // remove the .bb
|
||||
$bb_array[$bb_name] = "0"; // default userclass.
|
||||
}
|
||||
// bbcode class
|
||||
elseif(substr($adds, 0, 3) == "bb_" && substr($adds, -4) == ".php")
|
||||
{
|
||||
$bb_name = substr($adds, 0,-4); // remove the .php
|
||||
$bb_name = substr($bb_name, 3);
|
||||
$bb_array[$bb_name] = "0"; // TODO - instance and getPermissions() method
|
||||
}
|
||||
}
|
||||
|
||||
if ($is_installed && (substr($adds, -4) == "_sql"))
|
||||
{
|
||||
$core->setPref('e_sql_list/'.$path, $adds);
|
||||
}
|
||||
}
|
||||
|
||||
// Build Bbcode list (will be empty if plugin not installed)
|
||||
if (count($bb_array) > 0)
|
||||
{
|
||||
ksort($bb_array);
|
||||
$core->setPref('bbcode_list/'.$path, $bb_array);
|
||||
}
|
||||
|
||||
// Build shortcode list - do if uninstalled as well
|
||||
if (count($scl_array) > 0)
|
||||
{
|
||||
ksort($scl_array);
|
||||
$core->setPref('shortcode_legacy_list/'.$path, $scl_array);
|
||||
}
|
||||
|
||||
if (count($sc_array) > 0)
|
||||
{
|
||||
ksort($sc_array);
|
||||
$core->setPref('shortcode_list/'.$path, $sc_array);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$core->save(FALSE, false, false);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4069,9 +4274,9 @@ class e107plugin
|
||||
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* scan the plugin table and create path-array-prefs for each addon.
|
||||
*
|
||||
* @deprecated Replaced by eplug::refreshAddonPrefList()
|
||||
* @param string $mode = install|upgrade|refresh|uninstall - defines the intent of the call
|
||||
*
|
||||
* 'upgrade' and 'refresh' are very similar in intent, and often take the same actions:
|
||||
|
@@ -61,5 +61,3 @@ if(e_ADMIN_AREA !==true)
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user