Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
SAMBUMBA
pasteque-server
Commits
75572ae3
Commit
75572ae3
authored
Feb 19, 2013
by
Cédric Houbart
Browse files
Menu sections
parent
4b780f6e
Changes
8
Hide whitespace changes
Inline
Side-by-side
inc/Menu.php
View file @
75572ae3
...
...
@@ -36,23 +36,62 @@ class MenuEntry {
public
function
getAction
()
{
return
$this
->
action
;
}
}
class
MenuSection
{
private
$nameDomain
;
private
$name
;
private
$entries
;
public
function
__construct
(
$name
,
$domain
=
NULL
)
{
$this
->
name
=
$name
;
$this
->
nameDomain
=
$domain
;
$this
->
entries
=
array
();
}
public
function
addEntry
(
$menuEntry
)
{
$this
->
entries
[]
=
$menuEntry
;
}
public
function
getName
()
{
return
$this
->
name
;
}
public
function
getNameDomain
()
{
return
$this
->
nameDomain
;
}
public
function
getEntries
()
{
return
$this
->
entries
;
}
}
class
Menu
{
private
$
entrie
s
;
private
$
section
s
;
public
function
__construct
()
{
$this
->
entries
=
array
();
$this
->
entries
[]
=
new
MenuEntry
(
"Home"
,
"home"
);
$this
->
sections
=
array
();
$this
->
addSection
(
"general"
,
"General"
);
$entry
=
new
MenuEntry
(
"Home"
,
"home"
);
$this
->
addEntry
(
"general"
,
$entry
);
}
public
function
addSection
(
$id
,
$name
,
$nameDomain
=
NULL
)
{
if
(
!
isset
(
$this
->
sections
[
$id
]))
{
$this
->
sections
[
$id
]
=
new
MenuSection
(
$name
,
$nameDomain
);
return
TRUE
;
}
return
FALSE
;
}
public
function
addEntry
(
$sectionId
,
$entry
)
{
if
(
isset
(
$this
->
sections
[
$sectionId
]))
{
$this
->
sections
[
$sectionId
]
->
addEntry
(
$entry
);
return
TRUE
;
}
return
FALSE
;
}
public
function
register
_m
odule
_e
ntry
(
$module_name
,
$name
,
$action
)
{
$this
->
entries
[]
=
new
MenuEntry
(
$name
,
get_module_action
(
$module_name
,
$action
),
public
function
register
M
odule
E
ntry
(
$sectionId
,
$module_name
,
$name
,
$action
)
{
$entry
=
new
MenuEntry
(
$name
,
get_module_action
(
$module_name
,
$action
),
$module_name
);
return
$this
->
addEntry
(
$sectionId
,
$entry
);
}
public
function
get
_entrie
s
()
{
return
$this
->
entrie
s
;
public
function
get
Section
s
()
{
return
$this
->
section
s
;
}
}
...
...
modules/base_products/base_products.php
View file @
75572ae3
...
...
@@ -22,9 +22,10 @@ namespace BaseProducts;
function
init
()
{
global
$MENU
;
$MENU
->
register_module_entry
(
PLUGIN_NAME
,
"Taxes"
,
"taxes"
);
$MENU
->
register_module_entry
(
PLUGIN_NAME
,
"Categories"
,
"categories"
);
$MENU
->
register_module_entry
(
PLUGIN_NAME
,
"Products"
,
"products"
);
$MENU
->
addSection
(
"catalog"
,
"Catalog"
,
PLUGIN_NAME
);
$MENU
->
registerModuleEntry
(
"catalog"
,
PLUGIN_NAME
,
"Taxes"
,
"taxes"
);
$MENU
->
registerModuleEntry
(
"catalog"
,
PLUGIN_NAME
,
"Categories"
,
"categories"
);
$MENU
->
registerModuleEntry
(
"catalog"
,
PLUGIN_NAME
,
"Products"
,
"products"
);
\
Pasteque\register_i18n
(
PLUGIN_NAME
);
}
\
Pasteque\hook
(
"module_load"
,
__NAMESPACE__
.
"\init"
);
...
...
modules/base_products/languages/default.locale
View file @
75572ae3
{
"Catalog": "Catalog",
"Products": "Products",
"Add a product": "Add a product",
"No product found": "No product found",
...
...
modules/base_products/languages/fr-FR.locale
View file @
75572ae3
{
"Catalog": "Catalogue",
"Products": "Produits",
"Add a product": "Ajouter un produit",
"No product found": "Aucun produit trouvé",
...
...
modules/base_users/base_users.php
View file @
75572ae3
...
...
@@ -22,7 +22,8 @@ namespace BaseUsers;
function
init
()
{
global
$MENU
;
$MENU
->
register_module_entry
(
PLUGIN_NAME
,
"Users"
,
"users"
);
$MENU
->
addSection
(
"admin"
,
"Administration"
,
PLUGIN_NAME
);
$MENU
->
registerModuleEntry
(
"admin"
,
PLUGIN_NAME
,
"Users"
,
"users"
);
\
Pasteque\register_i18n
(
PLUGIN_NAME
);
}
\
Pasteque\hook
(
"module_load"
,
__NAMESPACE__
.
"\init"
);
...
...
modules/base_users/languages/default.locale
View file @
75572ae3
{
"Administration": "Administration",
"Products": "Products",
"Add a product": "Add a product",
"No product found": "No product found",
...
...
modules/base_users/languages/fr-FR.locale
View file @
75572ae3
{
"Administration": "Administration",
"Products": "Produits",
"Add a product": "Ajouter un produit",
"No product found": "Aucun produit trouvé",
...
...
templates/pasteque/module.php
View file @
75572ae3
...
...
@@ -52,14 +52,19 @@ function tpl_404() {
function
tpl_menu
()
{
global
$MENU
;
$
entrie
s
=
$MENU
->
get
_entrie
s
();
$
section
s
=
$MENU
->
get
Section
s
();
echo
"<div id=
\"
menu-container
\"
>
\n
"
;
echo
"
\t
<img src=
\"
"
.
get_template_url
()
.
"img/logo.png"
.
"
\"
/>
\n
"
;
echo
"
\t
<ul class=
\"
menu
\"
>
\n
"
;
foreach
(
$entries
as
$entry
)
{
echo
"
\t\t
<li><a href=
\"
"
.
get_url_action
(
$entry
->
getAction
())
.
"
\"
>"
.
__
(
$entry
->
getName
(),
$entry
->
getNameDomain
())
.
"</a></li>
\n
"
;
foreach
(
$sections
as
$section
)
{
echo
(
"
\t
<div class=
\"
section-title
\"
>"
.
\
i18n
(
$section
->
getName
(),
$section
->
getNameDomain
())
.
"</div>
\n
"
);
echo
"
\t
<ul class=
\"
menu
\"
>
\n
"
;
$entries
=
$section
->
getEntries
();
foreach
(
$entries
as
$entry
)
{
echo
"
\t\t
<li><a href=
\"
"
.
get_url_action
(
$entry
->
getAction
())
.
"
\"
>"
.
\
i18n
(
$entry
->
getName
(),
$entry
->
getNameDomain
())
.
"</a></li>
\n
"
;
}
echo
"
\t
</ul>
\n
"
;
}
echo
"</div>"
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment