Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
simple_sitemap
Commits
2f74a9d5
Commit
2f74a9d5
authored
Jun 21, 2016
by
Pawel G
Browse files
Check if form operation is on disallowed operations list instead of allowed operations list
parent
ae21bd37
Changes
2
Hide whitespace changes
Inline
Side-by-side
simple_sitemap.module
View file @
2f74a9d5
...
...
@@ -28,7 +28,7 @@ function simple_sitemap_form_alter(&$form, $form_state, $form_id) {
'#type'
=>
'details'
,
'#group'
=>
isset
(
$form
[
'additional_settings'
])
?
'additional_settings'
:
'advanced'
,
'#title'
=>
t
(
'Simple XML sitemap'
),
'#description'
=>
$f
->
entityCategory
==
'instance'
?
t
(
'Settings for this
specific
entity can be overridden here.'
)
:
''
,
'#description'
=>
$f
->
entityCategory
==
'instance'
?
t
(
'Settings for this entity can be overridden here.'
)
:
''
,
];
// Attach some js magic to forms.
if
(
$f
->
entityTypeId
!=
'comment'
||
$f
->
entityCategory
!=
'instance'
)
// todo: JS not working on comment entity form, hence disabling.
...
...
src/Form.php
View file @
2f74a9d5
...
...
@@ -24,7 +24,7 @@ class Form {
private
$formState
;
private
$generator
;
private
static
$
allowed
FormOperations
=
[
'de
fault'
,
'edit'
,
'add
'
];
private
static
$
skip
FormOperations
=
[
'de
lete'
,
'cancel
'
];
private
static
$valuesToCheck
=
[
'simple_sitemap_index_content'
,
'simple_sitemap_priority'
,
'simple_sitemap_regenerate_now'
];
/**
...
...
@@ -104,14 +104,15 @@ class Form {
}
$index
=
isset
(
$settings
[
'index'
])
?
$settings
[
'index'
]
:
0
;
$priority
=
isset
(
$settings
[
'priority'
])
?
$settings
[
'priority'
]
:
self
::
PRIORITY_DEFAULT
;
$bundle_name
=
!
empty
(
$this
->
bundleName
)
?
$this
->
bundleName
:
t
(
'undefined'
);
if
(
!
$multiple
)
{
$form_fragment
[
$prefix
.
'simple_sitemap_index_content'
]
=
[
'#type'
=>
'radios'
,
'#default_value'
=>
$index
,
'#options'
=>
[
0
=>
$this
->
entityCategory
==
'instance'
?
t
(
'Do not index this
entity'
)
:
t
(
'Do not index entities of this type'
),
1
=>
$this
->
entityCategory
==
'instance'
?
t
(
'Index this
entity'
)
:
t
(
'Index entities of this type'
),
0
=>
$this
->
entityCategory
==
'instance'
?
t
(
'Do not index this
@bundle entity'
,
[
'@bundle'
=>
$bundle_name
]
)
:
t
(
'Do not index entities of this type'
),
1
=>
$this
->
entityCategory
==
'instance'
?
t
(
'Index this
@bundle entity'
,
[
'@bundle'
=>
$bundle_name
]
)
:
t
(
'Index entities of this type'
),
]
];
if
(
$this
->
entityCategory
==
'instance'
&&
isset
(
$bundle_settings
[
'index'
]))
{
...
...
@@ -119,15 +120,10 @@ class Form {
}
}
if
(
$this
->
entityCategory
==
'instance'
)
{
$priority_description
=
t
(
'The priority this entity will have in the eyes of search engine bots.'
);
}
elseif
(
!
$multiple
)
{
$priority_description
=
t
(
'The priority entities of this bundle will have in the eyes of search engine bots.'
);
}
else
{
if
(
$this
->
entityCategory
==
'instance'
)
$priority_description
=
t
(
'The priority this @bundle entity will have in the eyes of search engine bots.'
,
[
'@bundle'
=>
$bundle_name
]);
else
$priority_description
=
t
(
'The priority entities of this type will have in the eyes of search engine bots.'
);
}
$form_fragment
[
$prefix
.
'simple_sitemap_priority'
]
=
[
'#type'
=>
'select'
,
'#title'
=>
t
(
'Priority'
),
...
...
@@ -198,7 +194,7 @@ class Form {
$form_object
=
$this
->
formState
->
getFormObject
();
if
(
!
is_null
(
$form_object
)
&&
method_exists
(
$form_object
,
'getEntity'
)
&&
in_array
(
$form_object
->
getOperation
(),
self
::
$
allowed
FormOperations
))
{
&&
!
in_array
(
$form_object
->
getOperation
(),
self
::
$
skip
FormOperations
))
{
return
$form_object
->
getEntity
();
}
return
FALSE
;
...
...
Write
Preview
Markdown
is supported
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