1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 06:07:32 +02:00

Optimized 'new menu' detection.

This commit is contained in:
Cameron
2014-06-26 18:08:10 -07:00
parent e3088a877f
commit 0b437addda

View File

@@ -367,6 +367,20 @@ class e_menuManager {
$efile->dirFilter = array('/', 'CVS', '.svn', 'languages'); $efile->dirFilter = array('/', 'CVS', '.svn', 'languages');
$fileList = $efile->get_files(e_PLUGIN,"_menu\.php$",'standard',2); $fileList = $efile->get_files(e_PLUGIN,"_menu\.php$",'standard',2);
$this->menuAddMessage('Scanning for new menus', E_MESSAGE_DEBUG);
$menuList = array(); // existing menus in table.
if($result = $sql->retrieve('menus', 'menu_name', null, true))
{
foreach($result as $mn)
{
if($mn['menu_name'])
{
$menuList[] = $mn['menu_name'];
}
}
}
foreach($fileList as $file) foreach($fileList as $file)
{ {
@@ -374,7 +388,8 @@ class e_menuManager {
$file['path'] = str_replace(e_PLUGIN,"",$file['path']); $file['path'] = str_replace(e_PLUGIN,"",$file['path']);
$file['fname'] = str_replace(".php","",$file['fname']); $file['fname'] = str_replace(".php","",$file['fname']);
$valid_menu = FALSE; $valid_menu = FALSE;
$existing_menu = $sql->count("menus", "(*)", "WHERE menu_name='{$file['fname']}'");
$existing_menu = in_array($file['fname'], $menuList); // $sql->count("menus", "(*)", "WHERE menu_name='{$file['fname']}'");
if (file_exists(e_PLUGIN.$parent_dir.'/plugin.xml') || file_exists(e_PLUGIN.$parent_dir.'/plugin.php')) if (file_exists(e_PLUGIN.$parent_dir.'/plugin.xml') || file_exists(e_PLUGIN.$parent_dir.'/plugin.php'))
{ {
if (e107::isInstalled($parent_dir)) if (e107::isInstalled($parent_dir))
@@ -405,11 +420,15 @@ class e_menuManager {
'menu_parms' => '' 'menu_parms' => ''
); );
if($sql->db_Insert("menus",$insert)) if($sql->insert("menus",$insert))
{ {
// Could do admin logging here - but probably not needed // Could do admin logging here - but probably not needed
$message .= MENLAN_10." - ".$file['fname']."<br />"; //FIXME $message .= MENLAN_10." - ".$file['fname']."<br />"; //FIXME
} }
else
{
$this->menuAddMessage("Couldn't add menu: ".$file['fname']." to table ", E_MESSAGE_DEBUG);
}
} }
} }
} }