CMS
Version 3.9
article_form.inc
Go to the documentation of this file.
1
<?php
2
/**************************************************************
3
4
Copyright (c) 2010 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::using
(
"article"
,
"site"
,
"image"
,
"field_renderers"
,
"taxonomy"
,
"email"
);
35
Fakoli::usingFile
(
"framework/auto_form.inc"
);
36
37
$menu_item
=
"Articles"
;
38
39
$article
=
new
Article
();
40
$article_id
= checkNumeric($_GET[
"article_id"
]);
41
42
if
(
$article_id
)
43
{
44
$article
->load(
$article_id
);
45
}
46
else
47
{
48
$article
->created_date = now();
49
$article
->publish_date = today();
50
}
51
52
$form
=
ArticleManager::buildArticleForm
(
$article
);
53
$form
->hide(
"sort_order"
);
54
55
if
(!
$article_id
|| !
$article
->published)
56
{
57
$form
->onSaveComplete =
onPublishArticle
;
58
}
59
TaxonomyManager::addTaxonomyFieldRenderers
(
$form
);
60
61
$redirect
=
"/admin/articles"
;
62
$form
->button(
"Cancel"
,
$redirect
);
63
64
if
(
$method
==
"POST"
)
65
{
66
if
(
$form
->save())
67
{
68
redirect(
"/admin/articles"
);
69
}
70
}
71
72
if
(
$form
->data->article_id)
73
{
74
$title
=
"Edit Article"
;
75
}
76
else
77
{
78
$title
=
"Add Article"
;
79
80
if
(!
$article_id
)
$form
->hide(
"created_date"
);
81
}
82
83
$script
=
$form
->writeScript();
84
85
$form
->drawForm();
86
87
function
onPublishArticle
(
$form
)
88
{
89
ArticleManager::onPublishArticle
(
$form
->data);
90
}
91
?>
$form
$form
Definition:
article_form.inc:52
onPublishArticle
onPublishArticle($form)
Definition:
article_form.inc:87
$article
$article
Definition:
article_form.inc:39
$article_id
$article_id
Definition:
article_form.inc:40
$redirect
$redirect
Definition:
article_form.inc:61
$menu_item
$menu_item
Definition:
article_form.inc:37
$script
$script
Definition:
article_form.inc:83
$title
$title
Definition:
session_details.inc:11
Article
Defines the Article class.
Definition:
article.inc:45
ArticleManager\buildArticleForm
static buildArticleForm($article)
Definition:
article_manager.inc:16
ArticleManager\onPublishArticle
static onPublishArticle($article)
If an article is marked published but no publish date set (user may wish to set a future publish date...
Definition:
article_manager.inc:63
Fakoli\using
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition:
core.inc:116
Fakoli\usingFile
static usingFile()
Uses the specified framework file(s) from the framework directory.
Definition:
core.inc:369
TaxonomyManager\addTaxonomyFieldRenderers
static addTaxonomyFieldRenderers($form, $showSelectAll=true, $group=null, $limitTo=null)
Definition:
taxonomy_manager.inc:217
$method
$method
Pull out a simple reference to the request method.
Definition:
core.inc:1573
code
cms.sonjara.com
cms
components
article
admin
article_form.inc
Generated on Tue Mar 23 2021 15:36:11 for CMS by
1.9.1