BUG 0000 Adjustment for the standardization of code. CODE_STYLE
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
* @package gulliver.system
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
@@ -43,18 +44,19 @@
|
||||
*/
|
||||
class Menu
|
||||
{
|
||||
var $Id = null;
|
||||
var $Options = null;
|
||||
var $Labels = null;
|
||||
var $Icons = null;
|
||||
var $JS = null;
|
||||
var $Types = null;
|
||||
var $Class = "mnu";
|
||||
var $Classes = null;
|
||||
var $Enabled = null;
|
||||
var $optionOn = - 1;
|
||||
var $id_optionOn = "";
|
||||
var $ElementClass = null;
|
||||
|
||||
public $Id = null;
|
||||
public $Options = null;
|
||||
public $Labels = null;
|
||||
public $Icons = null;
|
||||
public $JS = null;
|
||||
public $Types = null;
|
||||
public $Class = "mnu";
|
||||
public $Classes = null;
|
||||
public $Enabled = null;
|
||||
public $optionOn = - 1;
|
||||
public $id_optionOn = "";
|
||||
public $ElementClass = null;
|
||||
|
||||
/**
|
||||
* Set menu style
|
||||
@@ -64,7 +66,7 @@ class Menu
|
||||
* @param $strClass name of style class default value 'mnu'
|
||||
* @return void
|
||||
*/
|
||||
function SetClass ($strClass = "mnu")
|
||||
public function SetClass($strClass = "mnu")
|
||||
{
|
||||
$this->Class = "mnu";
|
||||
}
|
||||
@@ -77,35 +79,35 @@ class Menu
|
||||
* @param $strMenuName name of menu
|
||||
* @return void
|
||||
*/
|
||||
function Load ($strMenuName)
|
||||
public function Load($strMenuName)
|
||||
{
|
||||
global $G_TMP_MENU;
|
||||
$G_TMP_MENU = null;
|
||||
$G_TMP_MENU = new Menu();
|
||||
$fMenu = G::ExpandPath( "menus" ) . $strMenuName . ".php";
|
||||
$fMenu = G::ExpandPath("menus") . $strMenuName . ".php";
|
||||
|
||||
//if the menu file doesn't exists, then try with the plugins folders
|
||||
if (! is_file( $fMenu )) {
|
||||
$aux = explode( PATH_SEP, $strMenuName );
|
||||
if (count( $aux ) == 2) {
|
||||
if (!is_file($fMenu)) {
|
||||
$aux = explode(PATH_SEP, $strMenuName);
|
||||
if (count($aux) == 2) {
|
||||
$oPluginRegistry = & PMPluginRegistry::getSingleton();
|
||||
if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) {
|
||||
if ($oPluginRegistry->isRegisteredFolder($aux[0])) {
|
||||
$fMenu = PATH_PLUGINS . $aux[0] . PATH_SEP . $aux[1] . ".php";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! is_file( $fMenu )) {
|
||||
if (!is_file($fMenu)) {
|
||||
return;
|
||||
}
|
||||
include ($fMenu);
|
||||
//this line will add options to current menu.
|
||||
$oPluginRegistry = & PMPluginRegistry::getSingleton();
|
||||
$oPluginRegistry->getMenus( $strMenuName );
|
||||
$oPluginRegistry->getMenus($strMenuName);
|
||||
|
||||
//?
|
||||
$c = 0;
|
||||
for ($i = 0; $i < count( $G_TMP_MENU->Options ); $i ++)
|
||||
for ($i = 0; $i < count($G_TMP_MENU->Options); $i++) {
|
||||
if ($G_TMP_MENU->Enabled[$i] == 1) {
|
||||
$this->Options[$c] = $G_TMP_MENU->Options[$i];
|
||||
$this->Labels[$c] = $G_TMP_MENU->Labels[$i];
|
||||
@@ -116,15 +118,17 @@ class Menu
|
||||
$this->Id[$c] = $G_TMP_MENU->Id[$i];
|
||||
$this->Classes[$c] = $G_TMP_MENU->Classes[$i];
|
||||
$this->ElementClass[$c] = $G_TMP_MENU->ElementClass[$i];
|
||||
$c ++;
|
||||
$c++;
|
||||
} else {
|
||||
if ($i == $this->optionOn)
|
||||
if ($i == $this->optionOn) {
|
||||
$this->optionOn = - 1;
|
||||
elseif ($i < $this->optionOn)
|
||||
$this->optionOn --;
|
||||
elseif ($this->optionOn > 0)
|
||||
$this->optionOn --; //added this line
|
||||
} elseif ($i < $this->optionOn) {
|
||||
$this->optionOn--;
|
||||
} elseif ($this->optionOn > 0) {
|
||||
$this->optionOn--; //added this line
|
||||
}
|
||||
}
|
||||
}
|
||||
$G_TMP_MENU = null;
|
||||
}
|
||||
|
||||
@@ -135,11 +139,11 @@ class Menu
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
function OptionCount ()
|
||||
public function OptionCount()
|
||||
{
|
||||
$result = 0;
|
||||
if (is_array( $this->Options )) {
|
||||
$result = count( $this->Options );
|
||||
if (is_array($this->Options)) {
|
||||
$result = count($this->Options);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
@@ -154,7 +158,7 @@ class Menu
|
||||
* @param string $strType type, defualt value ='plugins'
|
||||
* @return void
|
||||
*/
|
||||
function AddOption ($strLabel, $strURL, $strType = "plugins")
|
||||
public function AddOption($strLabel, $strURL, $strType = "plugins")
|
||||
{
|
||||
$pos = $this->OptionCount();
|
||||
$this->Options[$pos] = $strURL;
|
||||
@@ -162,7 +166,7 @@ class Menu
|
||||
$this->Types[$pos] = $strType;
|
||||
$this->Enabled[$pos] = 1;
|
||||
$this->Id[$pos] = $pos;
|
||||
unset( $pos );
|
||||
unset($pos);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,20 +180,20 @@ class Menu
|
||||
* @param string $strType type, defualt value ='plugins'
|
||||
* @return void
|
||||
*/
|
||||
function AddIdOption ($strId, $strLabel, $strURL, $strType = "plugins")
|
||||
public function AddIdOption($strId, $strLabel, $strURL, $strType = "plugins")
|
||||
{
|
||||
$pos = $this->OptionCount();
|
||||
$this->Options[$pos] = $strURL;
|
||||
$this->Labels[$pos] = $strLabel;
|
||||
$this->Types[$pos] = $strType;
|
||||
$this->Enabled[$pos] = 1;
|
||||
if (is_array( $strId )) {
|
||||
if (is_array($strId)) {
|
||||
$this->Id[$pos] = $strId[0];
|
||||
$this->Classes[$pos] = $strId[1];
|
||||
} else {
|
||||
$this->Id[$pos] = $strId;
|
||||
}
|
||||
unset( $pos );
|
||||
unset($pos);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,7 +205,7 @@ class Menu
|
||||
* @param string $strType type, defualt value ='plugins'
|
||||
* @return void
|
||||
*/
|
||||
function AddRawOption ($strURL = "", $strType = "plugins")
|
||||
public function AddRawOption($strURL = "", $strType = "plugins")
|
||||
{
|
||||
$pos = $this->OptionCount();
|
||||
$this->Options[$pos] = $strURL;
|
||||
@@ -209,7 +213,7 @@ class Menu
|
||||
$this->Types[$pos] = $strType;
|
||||
$this->Enabled[$pos] = 1;
|
||||
$this->Id[$pos] = $pos;
|
||||
unset( $pos );
|
||||
unset($pos);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -224,7 +228,7 @@ class Menu
|
||||
* @param string $elementClass default value =''
|
||||
* @return void
|
||||
*/
|
||||
function AddIdRawOption ($strId, $strURL = "", $label = "", $icon = "", $js = "", $strType = "plugins", $elementClass = '')
|
||||
public function AddIdRawOption($strId, $strURL = "", $label = "", $icon = "", $js = "", $strType = "plugins", $elementClass = '')
|
||||
{
|
||||
$pos = $this->OptionCount();
|
||||
$this->Options[$pos] = $strURL;
|
||||
@@ -234,13 +238,13 @@ class Menu
|
||||
$this->Types[$pos] = $strType;
|
||||
$this->Enabled[$pos] = 1;
|
||||
$this->ElementClass[$pos] = $elementClass;
|
||||
if (is_array( $strId )) {
|
||||
if (is_array($strId)) {
|
||||
$this->Id[$pos] = $strId[0];
|
||||
$this->Classes[$pos] = $strId[1];
|
||||
} else {
|
||||
$this->Id[$pos] = $strId;
|
||||
}
|
||||
unset( $pos );
|
||||
unset($pos);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -251,7 +255,7 @@ class Menu
|
||||
* @param string $intPos menu option's position
|
||||
* @return void
|
||||
*/
|
||||
function DisableOptionPos ($intPos)
|
||||
public function DisableOptionPos($intPos)
|
||||
{
|
||||
$this->Enabled[$intPos] = 0;
|
||||
}
|
||||
@@ -264,10 +268,10 @@ class Menu
|
||||
* @param string $id menu's id
|
||||
* @return void
|
||||
*/
|
||||
function DisableOptionId ($id)
|
||||
public function DisableOptionId($id)
|
||||
{
|
||||
if (array_search( $id, $this->Id )) {
|
||||
$this->Enabled[array_search( $id, $this->Id )] = 0;
|
||||
if (array_search($id, $this->Id)) {
|
||||
$this->Enabled[array_search($id, $this->Id)] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +283,7 @@ class Menu
|
||||
* @param string $intPos menu option's position
|
||||
* @return void
|
||||
*/
|
||||
function RenderOption ($intPos)
|
||||
public function RenderOption($intPos)
|
||||
{
|
||||
if ($this->Enabled[$intPos] != 1) {
|
||||
return;
|
||||
@@ -290,9 +294,9 @@ class Menu
|
||||
}
|
||||
$target = $this->Options[$intPos];
|
||||
if ($this->Types[$intPos] != "absolute") {
|
||||
if (defined( 'ENABLE_ENCRYPT' )) {
|
||||
if (defined('ENABLE_ENCRYPT')) {
|
||||
$target = "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target;
|
||||
} else if (defined( 'SYS_SYS' )) {
|
||||
} elseif (defined('SYS_SYS')) {
|
||||
$target = "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target;
|
||||
} else {
|
||||
$target = "/sys/" . SYS_LANG . "/" . SYS_SKIN . "/" . $target;
|
||||
@@ -301,10 +305,9 @@ class Menu
|
||||
$label = $this->Labels[$intPos];
|
||||
$result = "<a href=\"$target\"";
|
||||
$result .= " class=\"$classname\">";
|
||||
$result .= htmlentities( $label, ENT_NOQUOTES, 'utf-8' );
|
||||
$result .= htmlentities($label, ENT_NOQUOTES, 'utf-8');
|
||||
$result .= "</a>";
|
||||
print ($result) ;
|
||||
|
||||
print ($result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -319,18 +322,18 @@ class Menu
|
||||
* @param string $G_ID_MENU_SELECTED
|
||||
* @return array
|
||||
*/
|
||||
function generateArrayForTemplate ($G_MAIN_MENU, $classOn, $classOff, $G_MENU_SELECTED, $G_ID_MENU_SELECTED)
|
||||
public function generateArrayForTemplate($G_MAIN_MENU, $classOn, $classOff, $G_MENU_SELECTED, $G_ID_MENU_SELECTED)
|
||||
{
|
||||
$menus = array ();
|
||||
$menus = array();
|
||||
if ($G_MAIN_MENU == null) {
|
||||
return $menus;
|
||||
}
|
||||
$this->Load( $G_MAIN_MENU );
|
||||
$this->Load($G_MAIN_MENU);
|
||||
$this->optionOn = $G_MENU_SELECTED;
|
||||
$this->id_optionOn = $G_ID_MENU_SELECTED;
|
||||
//$this->Class = $G_MENU_CLASS;
|
||||
if (is_array( $this->Options )) {
|
||||
for ($ncount = 0; $ncount < $this->OptionCount(); $ncount ++) {
|
||||
if (is_array($this->Options)) {
|
||||
for ($ncount = 0; $ncount < $this->OptionCount(); $ncount++) {
|
||||
$target = $this->Options[$ncount];
|
||||
|
||||
//$aux = $this->Icons[$ncount];
|
||||
@@ -340,10 +343,10 @@ class Menu
|
||||
$target = $this->Options[$ncount];
|
||||
}
|
||||
if ($this->Types[$ncount] != 'absolute') {
|
||||
if (defined( 'SYS_SYS' )) {
|
||||
$target = '/sys' . SYS_TEMP . G::encryptLink( '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount] );
|
||||
if (defined('SYS_SYS')) {
|
||||
$target = '/sys' . SYS_TEMP . G::encryptLink('/' . SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount]);
|
||||
} else {
|
||||
$target = '/sys/' . G::encryptLink( SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount] );
|
||||
$target = '/sys/' . G::encryptLink(SYS_LANG . '/' . SYS_SKIN . '/' . $this->Options[$ncount]);
|
||||
}
|
||||
}
|
||||
$label = $this->Labels[$ncount];
|
||||
@@ -374,11 +377,10 @@ class Menu
|
||||
$elementclass = 'class="' . $this->ElementClass[$ncount] . '"';
|
||||
}
|
||||
|
||||
$menus[] = array ('id' => $ncount,'target' => $target,'label' => $label,'onMenu' => $onMenu,'classname' => $classname,'imageLeft' => $imageLeft,'onclick' => $onclick,'icon' => $icon,'aux' => $aux,'idName' => $idName,'elementclass' => $elementclass
|
||||
);
|
||||
$menus[] = array('id' => $ncount, 'target' => $target, 'label' => $label, 'onMenu' => $onMenu, 'classname' => $classname, 'imageLeft' => $imageLeft, 'onclick' => $onclick, 'icon' => $icon, 'aux' => $aux, 'idName' => $idName, 'elementclass' => $elementclass);
|
||||
}
|
||||
}
|
||||
return $menus;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user