CMS
Version 3.9
term_dialog.inc
Go to the documentation of this file.
1
<?php
2
/**************************************************************
3
4
Copyright (c) 2014 Sonjara, Inc
5
6
Permission is hereby granted, free of charge, to any person
7
obtaining a copy of this software and associated documentation
8
files (the "Software"), to deal in the Software without
9
restriction, including without limitation the rights to use,
10
copy, modify, merge, publish, distribute, sublicense, and/or sell
11
copies of the Software, and to permit persons to whom the
12
Software is furnished to do so, subject to the following
13
conditions:
14
15
The above copyright notice and this permission notice shall be
16
included in all copies or substantial portions of the Software.
17
18
Except as contained in this notice, the name(s) of the above
19
copyright holders shall not be used in advertising or otherwise
20
to promote the sale, use or other dealings in this Software
21
without prior written authorization.
22
23
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
25
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
27
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
28
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
30
OTHER DEALINGS IN THE SOFTWARE.
31
32
*****************************************************************/
33
34
Fakoli::assertRole
(
"admin"
);
35
36
$taxonomy_id
= checkNumeric($_GET[
"taxonomy_id"
]);
37
$term_id
= checkNumeric($_GET[
"term_id"
]);
38
39
if
(!
$taxonomy_id
)
40
{
41
Fakoli::end
(
"No taxonomy specified"
);
42
}
43
44
$taxonomy
=
new
Taxonomy
(
$taxonomy_id
);
45
46
$term
=
new
TaxonomyTerm
();
47
if
(
$term_id
)
48
{
49
$term
->load(
$term_id
);
50
}
51
else
52
{
53
$term
->taxonomy_id =
$taxonomy_id
;
54
}
55
56
$form
=
new
AutoForm(
$term
,
"POST"
,
"/action/taxonomy/term_dialog?taxonomy_id=$taxonomy_id&term_id=$term_id"
);
57
$form
->hide(
"taxonomy_id"
);
58
$form
->required(
"term"
);
59
$form
->allowDelete =
true
;
60
61
$form
->ajaxSubmit(
"function(result) {taxonomyAdmin.onSave(result);}"
,
"function() {document.id('{$form->id}_error').set('text','Failed to communicate with server'); }"
);
62
$form
->button(
"Cancel"
,
"taxonomyAdmin.closeTermDialog()"
,
null
,
true
);
63
64
if
(
$method
==
"POST"
)
65
{
66
if
(
$form
->save())
67
{
68
Fakoli::end
(
"OK"
);
69
}
70
else
71
{
72
Fakoli::end
(
$form
->msg);
73
}
74
}
75
76
echo
$form
->writeScript();
77
$form
->drawForm();
78
Fakoli\end
static end($message="")
Use this method to terminate execution of a script instead of using the php keywords exit() or die().
Definition:
core.inc:1149
Fakoli\assertRole
static assertRole($role, $redirect="", $message="")
Assert that the user has one of the specified roles.
Definition:
core.inc:297
Taxonomy
Definition:
taxonomy.inc:40
TaxonomyTerm
Definition:
taxonomy_term.inc:40
$method
$method
Pull out a simple reference to the request method.
Definition:
core.inc:1573
$form
$form
Definition:
term_dialog.inc:56
$taxonomy_id
$taxonomy_id
Definition:
term_dialog.inc:36
$term_id
$term_id
Definition:
term_dialog.inc:37
$taxonomy
if(! $taxonomy_id) $taxonomy
Definition:
term_dialog.inc:44
$term
$term
Definition:
term_dialog.inc:46
code
cms.sonjara.com
cms
components
taxonomy
handlers
term_dialog.inc
Generated on Tue Mar 23 2021 15:36:14 for CMS by
1.9.1