7
* @author Stephane F et Florent MONTHEL
10
include(dirname(__FILE__).'/prepend.php');
12
# Control du token du formulaire
13
if(!isset($_POST['preview']))
14
plxToken::validateFormToken($_POST);
17
eval($plxAdmin->plxPlugins->callHook('AdminArticlePrepend'));
19
# validation de l'id de l'article si passé en parametre
20
if(isset($_GET['a']) AND !preg_match('/^_?[0-9]{4}$/',$_GET['a'])) {
21
plxMsg::Error(L_ERR_UNKNOWN_ARTICLE); # Article inexistant
22
header('Location: index.php');
27
if(!empty($_POST)) { # Création, mise à jour, suppression ou aperçu
29
if(!isset($_POST['catId'])) $_POST['catId']=array();
30
# Titre par défaut si titre vide
31
if(trim($_POST['title'])=='') $_POST['title'] = L_DEFAULT_NEW_ARTICLE_TITLE;
32
# Si demande d'enregistrement en brouillon on ajoute la categorie draft à la liste et on retire la demande de validation
33
if(isset($_POST['draft']) AND !in_array('draft',$_POST['catId'])) array_unshift($_POST['catId'], 'draft');
34
# si aucune catégorie sélectionnée on place l'article dans la catégorie "non classé"
35
if(sizeof($_POST['catId'])==1 AND $_POST['catId'][0]=='draft') $_POST['catId'][]='000';
36
else $_POST['catId'] = array_filter($_POST['catId'], create_function('$a', 'return $a!="000";'));
37
# Si demande de publication ou demande de validation, on supprime la catégorie draft si elle existe
38
if((isset($_POST['update']) OR isset($_POST['publish']) OR isset($_POST['moderate'])) AND isset($_POST['catId'])) $_POST['catId'] = array_filter($_POST['catId'], create_function('$a', 'return $a!="draft";'));
39
# Si profil PROFIL_WRITER on vérifie l'id du rédacteur connecté et celui de l'article
40
if($_SESSION['profil']==PROFIL_WRITER AND isset($_POST['author']) AND $_SESSION['user']!=$_POST['author']) $_POST['author']=$_SESSION['user'];
41
# Si profil PROFIL_WRITER on vérifie que l'article n'est pas celui d'un autre utilisateur
42
if($_SESSION['profil']==PROFIL_WRITER AND isset($_POST['artId']) AND $_POST['artId']!='0000') {
44
if(($aFile = $plxAdmin->plxGlob_arts->query('/^'.$_POST['artId'].'.([home[draft|0-9,]*).'.$_SESSION['user'].'.(.+).xml$/')) == false) { # Article inexistant
45
plxMsg::Error(L_ERR_UNKNOWN_ARTICLE);
46
header('Location: index.php');
50
# Previsualisation d'un article
51
if(!empty($_POST['preview'])) {
53
$art['title'] = trim($_POST['title']);
54
$art['allow_com'] = $_POST['allow_com'];
55
$art['template'] = basename($_POST['template']);
56
$art['chapo'] = trim($_POST['chapo']);
57
$art['content'] = trim($_POST['content']);
58
$art['tags'] = trim($_POST['tags']);
59
$art['meta_description'] = $_POST['meta_description'];
60
$art['meta_keywords'] = $_POST['meta_keywords'];
61
$art['title_htmltag'] = $_POST['title_htmltag'];
62
$art['filename'] = '';
63
$art['numero'] = $_POST['artId'];
64
$art['author'] = $_POST['author'];
65
$art['categorie'] = '';
66
if(!empty($_POST['catId'])) {
68
foreach($_POST['catId'] as $k => $v) {
69
if($v!='draft') $array[]=$v;
71
$art['categorie']=implode(',',$array);
73
$art['date'] = $_POST['year'].$_POST['month'].$_POST['day'].substr(str_replace(':','',$_POST['time']),0,4);
75
if(trim($_POST['url']) == '')
76
$art['url'] = plxUtils::title2url($_POST['title']);
78
$art['url'] = plxUtils::title2url($_POST['url']);
79
if($art['url'] == '') $art['url'] = L_DEFAULT_NEW_ARTICLE_URL;
82
eval($plxAdmin->plxPlugins->callHook('AdminArticlePreview'));
85
$_SESSION['preview'] = $article;
86
header('Location: '.PLX_ROOT.'index.php?preview');
89
# Suppression d'un article
90
if(isset($_POST['delete'])) {
91
$plxAdmin->delArticle($_POST['artId']);
92
header('Location: index.php');
95
# Mode création ou maj
96
if(isset($_POST['update']) OR isset($_POST['publish']) OR isset($_POST['moderate']) OR isset($_POST['draft'])) {
99
# Vérification de l'unicité de l'url
100
$_POST['url'] = plxUtils::title2url(trim($_POST['url'])==''?$_POST['title']:$_POST['url']);
101
foreach($plxAdmin->plxGlob_arts->aFiles as $numart => $filename) {
102
if(preg_match("/^_?[0-9]{4}.([0-9,|home|draft]*).[0-9]{3}.[0-9]{12}.".$_POST["url"].".xml$/", $filename)) {
103
if($numart!=str_replace('_', '',$_POST['artId'])) {
104
$valid = plxMsg::Error(L_ERR_URL_ALREADY_EXISTS." : ".plxUtils::strCheck($_POST["url"])) AND $valid;
108
# Vérification de la validité de la date de publication
109
if(!plxDate::checkDate($_POST['day'],$_POST['month'],$_POST['year'],$_POST['time'])) {
110
$valid = plxMsg::Error(L_ERR_INVALID_PUBLISHING_DATE) AND $valid;
113
$plxAdmin->editArticle($_POST,$_POST['artId']);
114
header('Location: article.php?a='.$_POST['artId']);
119
# Ajout d'une catégorie
120
if(isset($_POST['new_category'])) {
121
# Ajout de la nouvelle catégorie
122
$plxAdmin->editCategories($_POST);
123
# On recharge la nouvelle liste
124
$plxAdmin->getCategories(path('XMLFILE_CATEGORIES'));
125
$_GET['a']=$_POST['artId'];
127
# Alimentation des variables
128
$artId = $_POST['artId'];
129
$title = trim($_POST['title']);
130
$author = $_POST['author'];
131
$catId = isset($_POST['catId'])?$_POST['catId']:array();
132
$date['day'] = $_POST['day'];
133
$date['month'] = $_POST['month'];
134
$date['year'] = $_POST['year'];
135
$date['time'] = $_POST['time'];
136
$chapo = trim($_POST['chapo']);
137
$content = trim($_POST['content']);
138
$tags = trim($_POST['tags']);
139
$url = $_POST['url'];
140
$allow_com = $_POST['allow_com'];
141
$template = $_POST['template'];
142
$meta_description = $_POST['meta_description'];
143
$meta_keywords = $_POST['meta_keywords'];
144
$title_htmltag = $_POST['title_htmltag'];
146
eval($plxAdmin->plxPlugins->callHook('AdminArticlePostData'));
147
} elseif(!empty($_GET['a'])) { # On n'a rien validé, c'est pour l'édition d'un article
148
# On va rechercher notre article
149
if(($aFile = $plxAdmin->plxGlob_arts->query('/^'.$_GET['a'].'.(.+).xml$/')) == false) { # Article inexistant
150
plxMsg::Error(L_ERR_UNKNOWN_ARTICLE);
151
header('Location: index.php');
154
# On parse et alimente nos variables
155
$result = $plxAdmin->parseArticle(PLX_ROOT.$plxAdmin->aConf['racine_articles'].$aFile['0']);
156
$title = trim($result['title']);
157
$chapo = trim($result['chapo']);
158
$content = trim($result['content']);
159
$tags = trim($result['tags']);
160
$author = $result['author'];
161
$url = $result['url'];
162
$date = plxDate::date2Array($result['date']);
163
$catId = explode(',', $result['categorie']);
164
$artId = $result['numero'];
165
$allow_com = $result['allow_com'];
166
$template = $result['template'];
167
$meta_description=$result['meta_description'];
168
$meta_keywords=$result['meta_keywords'];
169
$title_htmltag = $result['title_htmltag'];
171
if($author!=$_SESSION['user'] AND $_SESSION['profil']==PROFIL_WRITER) {
172
plxMsg::Error(L_ERR_FORBIDDEN_ARTICLE);
173
header('Location: index.php');
177
eval($plxAdmin->plxPlugins->callHook('AdminArticleParseData'));
179
} else { # On a rien validé, c'est pour la création d'un article
180
$title = plxUtils::strRevCheck(L_DEFAULT_NEW_ARTICLE_TITLE);
184
$author = $_SESSION['user'];
185
$date = array ('year' => date('Y'),'month' => date('m'),'day' => date('d'),'time' => date('H:i'));
186
$catId = array('draft');
188
$allow_com = $plxAdmin->aConf['allow_com'];
189
$template = 'article.php';
190
$meta_description=$meta_keywords=$title_htmltag='';
192
eval($plxAdmin->plxPlugins->callHook('AdminArticleInitData'));
195
# On inclut le header
196
include(dirname(__FILE__).'/top.php');
198
# On construit la liste des utilisateurs
199
foreach($plxAdmin->aUsers as $_userid => $_user) {
200
if($_user['active'] AND !$_user['delete'] ) {
201
if($_user['profil']==PROFIL_ADMIN)
202
$_users[L_PROFIL_ADMIN][$_userid] = plxUtils::strCheck($_user['name']);
203
elseif($_user['profil']==PROFIL_MANAGER)
204
$_users[L_PROFIL_MANAGER][$_userid] = plxUtils::strCheck($_user['name']);
205
elseif($_user['profil']==PROFIL_MODERATOR)
206
$_users[L_PROFIL_MODERATOR][$_userid] = plxUtils::strCheck($_user['name']);
207
elseif($_user['profil']==PROFIL_EDITOR)
208
$_users[L_PROFIL_EDITOR][$_userid] = plxUtils::strCheck($_user['name']);
210
$_users[L_PROFIL_WRITER][$_userid] = plxUtils::strCheck($_user['name']);
214
# On récupère les templates des articles
215
$files = plxGlob::getInstance(PLX_ROOT.$plxAdmin->aConf['racine_themes'].$plxAdmin->aConf['style']);
216
if ($array = $files->query('/^article(-[a-z0-9-_]+)?.php$/')) {
217
foreach($array as $k=>$v)
218
$aTemplates[$v] = $v;
223
<form action="article.php" method="post" id="form_article">
225
<div id="extra-container">
227
<div id="extra-sidebar">
228
<p class="field_head"><?php echo L_ARTICLE_STATUS ?> :
231
if(isset($_GET['a']) AND preg_match('/^_[0-9]{4}$/',$_GET['a']))
233
elseif(in_array('draft', $catId)) {
235
echo '<input type="hidden" name="catId[]" value="draft" />';
243
<p><label for="id_author"><?php echo L_ARTICLE_LIST_AUTHORS ?> : </label></p>
245
if($_SESSION['profil'] < PROFIL_WRITER)
246
plxUtils::printSelect('author', $_users, $author);
248
echo '<input type="hidden" id="id_author" name="author" value="'.$author.'" />';
249
echo '<strong>'.plxUtils::strCheck($plxAdmin->aUsers[$author]['name']).'</strong>';
252
<p><label><?php echo L_ARTICLE_DATE ?> :</label></p>
253
<?php plxUtils::printInput('day',$date['day'],'text','2-2',false,'fld1'); ?>
254
<?php plxUtils::printInput('month',$date['month'],'text','2-2',false,'fld1'); ?>
255
<?php plxUtils::printInput('year',$date['year'],'text','2-4',false,'fld2'); ?>
256
<?php plxUtils::printInput('time',$date['time'],'text','2-5',false,'fld2'); ?>
257
<a id="id_cal" href="javascript:void(0)" onclick="dateNow(<?php echo date('Z') ?>); return false;" title="<?php L_NOW; ?>"><img src="theme/images/date.png" alt="" /></a>
259
<p><label><?php echo L_ARTICLE_CATEGORIES ?> :</label></p>
261
$selected = (is_array($catId) AND in_array('000', $catId)) ? ' checked="checked"' : '';
262
echo '<input readonly="readonly" disabled="disabled" type="checkbox" id="cat_unclassified" name="catId[]"'.$selected.' value="000" /><label for="cat_unclassified"> '. L_UNCLASSIFIED .'</label><br />';
263
$selected = (is_array($catId) AND in_array('home', $catId)) ? ' checked="checked"' : '';
264
echo '<input type="checkbox" id="cat_home" name="catId[]"'.$selected.' value="home" /><label for="cat_home"> '. L_CATEGORY_HOME_PAGE .'</label><br />';
265
foreach($plxAdmin->aCats as $cat_id => $cat_name) {
266
$selected = (is_array($catId) AND in_array($cat_id, $catId)) ? ' checked="checked"' : '';
267
echo '<input type="checkbox" id="cat_'.$cat_id.'" name="catId[]"'.$selected.' value="'.$cat_id.'" />';
268
if($plxAdmin->aCats[$cat_id]['active'])
269
echo '<label for="cat_'.$cat_id.'"> '.plxUtils::strCheck($cat_name['name']).'</label><br />';
271
echo '<label for="cat_'.$cat_id.'"> <em>'.plxUtils::strCheck($cat_name['name']).'</em></label><br />';
275
<?php if($_SESSION['profil'] < PROFIL_WRITER) : ?>
276
<p><label for="id_new_catname"><?php echo L_NEW_CATEGORY ?> :</label></p>
277
<?php plxUtils::printInput('new_catname','','text','17-50') ?>
278
<input class="button new" type="submit" name="new_category" value="<?php echo L_CATEGORY_ADD_BUTTON ?>" />
281
<p><label for="id_tags"><?php echo L_ARTICLE_TAGS_FIELD ?> :</label> <a class="help" title="<?php echo L_ARTICLE_TAGS_FIELD_TITLE ?>"> </a></p>
282
<?php plxUtils::printInput('tags',$tags,'text','25-255'); ?>
283
<a title="<?php echo L_ARTICLE_TOGGLER_TITLE ?>" id="toggler" href="javascript:void(0)" onclick="toggleDiv('tags','toggler','+','-')" style="outline:none">+</a>
284
<div id="tags" style="display:none;margin-top:5px">
286
if($plxAdmin->aTags) {
288
foreach($plxAdmin->aTags as $tag) {
289
if($tags = array_map('trim', explode(',', $tag['tags']))) {
290
foreach($tags as $tag) {
292
$t = plxUtils::title2url($tag);
293
if(!isset($array[$tag]))
294
$array[$tag]=array('url'=>$t,'count'=>1);
296
$array[$tag]['count']++;
301
array_multisort($array);
302
foreach($array as $tagname => $tag) {
303
echo '<a href="javascript:void(0)" onclick="insTag(\'tags\',\''.$tagname.'\')" title="'.plxUtils::strCheck($tagname).' ('.$tag['count'].')">'.plxUtils::strCheck($tagname).'</a> ('.$tag['count'].') ';
310
<?php if($plxAdmin->aConf['allow_com']=='1') : ?>
311
<p><label for="id_allow_com"><?php echo L_ALLOW_COMMENTS ?> :</label></p>
312
<?php plxUtils::printSelect('allow_com',array('1'=>L_YES,'0'=>L_NO),$allow_com); ?>
314
<?php plxUtils::printInput('allow_com','0','hidden'); ?>
317
<p><label for="id_url"><?php echo L_ARTICLE_URL_FIELD ?> :</label> <a class="help" title="<?php echo L_ARTICLE_URL_FIELD_TITLE ?>"> </a></p>
318
<?php plxUtils::printInput('url',$url,'text','27-255'); ?>
320
<p><label for="id_template"><?php echo L_ARTICLE_TEMPLATE_FIELD ?> :</label></p>
321
<?php plxUtils::printSelect('template', $aTemplates, $template); ?>
323
<p><label for="id_title_htmltag"><?php echo L_ARTICLE_TITLE_HTMLTAG ?> :</label></p>
324
<?php plxUtils::printInput('title_htmltag',plxUtils::strCheck($title_htmltag),'text','27-255'); ?>
326
<p><label for="id_meta_description"><?php echo L_ARTICLE_META_DESCRIPTION ?> :</label></p>
327
<?php plxUtils::printInput('meta_description',plxUtils::strCheck($meta_description),'text','27-255'); ?>
329
<p><label for="id_meta_keywords"><?php echo L_ARTICLE_META_KEYWORDS ?> :</label></p>
330
<?php plxUtils::printInput('meta_keywords',plxUtils::strCheck($meta_keywords),'text','27-255'); ?>
332
<?php eval($plxAdmin->plxPlugins->callHook('AdminArticleSidebar')) # Hook Plugins ?>
334
<?php if($artId != '0000') : ?>
336
<li> <a href="comments.php?a=<?php echo $artId ?>&page=1" title="<?php echo L_ARTICLE_MANAGE_COMMENTS_TITLE ?>"><?php echo L_ARTICLE_MANAGE_COMMENTS ?></a></li>
337
<li> <a href="comment_new.php?a=<?php echo $artId ?>" title="<?php echo L_ARTICLE_NEW_COMMENT_TITLE ?>"><?php echo L_ARTICLE_NEW_COMMENT ?></a></li>
343
</div><!-- extra sidebar -->
345
<div id="extra-content">
347
<p class="back"><a href="index.php"><?php echo L_BACK_TO_ARTICLES ?></a></p>
349
<h2><?php echo (empty($_GET['a']))?L_MENU_NEW_ARTICLES:L_ARTICLE_EDITING; ?></h2>
351
<?php eval($plxAdmin->plxPlugins->callHook('AdminArticleTop')) # Hook Plugins ?>
353
<div class="form_content">
355
<?php plxUtils::printInput('artId',$artId,'hidden'); ?>
356
<p><label for="id_title"><?php echo L_ARTICLE_TITLE ?> :</label></p>
357
<?php plxUtils::printInput('title',plxUtils::strCheck($title),'text','42-255'); ?>
359
<label for="id_chapo"><?php echo L_HEADLINE_FIELD ?> :</label>
361
<a id="toggler_chapo" href="javascript:void(0)" onclick="toggleDiv('toggle_chapo', 'toggler_chapo', '<?php echo L_ARTICLE_CHAPO_DISPLAY ?>','<?php echo L_ARTICLE_CHAPO_HIDE ?>')"><?php echo $chapo==''?L_ARTICLE_CHAPO_DISPLAY:L_ARTICLE_CHAPO_HIDE ?></a>
363
<div id="toggle_chapo"<?php echo $chapo!=''?'':' style="display:none"' ?>><?php plxUtils::printArea('chapo',plxUtils::strCheck($chapo),35,8); ?></div>
364
<p id="p_content"><label for="id_content"><?php echo L_CONTENT_FIELD ?> :</label></p>
365
<?php plxUtils::printArea('content',plxUtils::strCheck($content),35,28); ?>
366
<?php if($artId!='' AND $artId!='0000') : ?>
367
<?php $link = $plxAdmin->urlRewrite('index.php?article'.intval($artId).'/'.$url) ?>
368
<p id="p_link"><label for="id_link"><?php echo L_LINK_FIELD ?> : </label>
369
<?php echo '<a onclick="this.target=\'_blank\';return true;" href="'.$link.'" title="'.L_LINK_ACCESS.'">'.L_LINK_VIEW.'</a>'; ?>
371
<?php echo '<input id="id_link" onclick="this.select()" class="readonly" readonly="readonly" type="text" value="'.$link.'" />' ?>
374
<?php eval($plxAdmin->plxPlugins->callHook('AdminArticleContent')) ?>
377
<div class="form_bottom">
379
<?php echo plxToken::getTokenPostMethod() ?>
380
<input class="button preview" type="submit" name="preview" onclick="this.form.target='_blank';return true;" value="<?php echo L_ARTICLE_PREVIEW_BUTTON ?>"/>
382
if($_SESSION['profil']>PROFIL_MODERATOR AND $plxAdmin->aConf['mod_art']) {
383
if(in_array('draft', $catId)) { # brouillon
384
if($artId!='0000') # nouvel article
385
echo '<input class="button delete" type="submit" name="delete" value="'.L_DELETE.'" onclick="Check=confirm(\''.L_ARTICLE_DELETE_CONFIRM.'\');if(Check==false) {return false;} else {this.form.target=\'_self\';return true;}" />';
386
echo '<input class="button" onclick="this.form.target=\'_self\';return true;" type="submit" name="draft" value="'.L_ARTICLE_DRAFT_BUTTON.'"/>';
387
echo '<input class="button submit" onclick="this.form.target=\'_self\';return true;" type="submit" name="moderate" value="'.L_ARTICLE_MODERATE_BUTTON.'"/>';
389
if(isset($_GET['a']) AND preg_match('/^_[0-9]{4}$/',$_GET['a'])) { # en attente
390
echo '<input class="button delete" type="submit" name="delete" value="'.L_DELETE.'" onclick="Check=confirm(\''.L_ARTICLE_DELETE_CONFIRM.'\');if(Check==false) {return false;} else {this.form.target=\'_self\';return true;}" />';
391
echo '<input class="button" onclick="this.form.target=\'_self\';return true;" type="submit" name="draft" value="'.L_ARTICLE_DRAFT_BUTTON.'"/>';
392
echo '<input class="button update" onclick="this.form.target=\'_self\';return true;" type="submit" name="update" value="' . L_ARTICLE_UPDATE_BUTTON . '"/>';
394
echo '<input class="button" onclick="this.form.target=\'_self\';return true;" type="submit" name="draft" value="'.L_ARTICLE_DRAFT_BUTTON.'"/>';
395
echo '<input class="button submit" onclick="this.form.target=\'_self\';return true;" type="submit" name="moderate" value="'.L_ARTICLE_MODERATE_BUTTON.'"/>';
400
echo '<input class="button delete" type="submit" name="delete" value="'.L_DELETE.'" onclick="Check=confirm(\''.L_ARTICLE_DELETE_CONFIRM.'\');if(Check==false) {return false;} else {this.form.target=\'_self\';return true;}" />';
401
if(in_array('draft', $catId)) {
402
echo '<input class="button" onclick="this.form.target=\'_self\';return true;" type="submit" name="draft" value="' . L_ARTICLE_DRAFT_BUTTON . '"/>';
403
echo '<input class="button submit" onclick="this.form.target=\'_self\';return true;" type="submit" name="publish" value="' . L_ARTICLE_PUBLISHING_BUTTON . '"/>';
405
if(!isset($_GET['a']) OR preg_match('/^_[0-9]{4}$/',$_GET['a']))
406
echo '<input class="button submit" onclick="this.form.target=\'_self\';return true;" type="submit" name="publish" value="' . L_ARTICLE_PUBLISHING_BUTTON . '"/>';
408
echo '<input class="button" onclick="this.form.target=\'_self\';return true;" type="submit" name="draft" value="' . L_ARTICLE_OFFLINE_BUTTON . '"/>';
409
echo '<input class="button update" onclick="this.form.target=\'_self\';return true;" type="submit" name="update" value="' . L_ARTICLE_UPDATE_BUTTON . '"/>';
416
</div><!-- extra-content -->
418
</div><!-- extra container -->
423
eval($plxAdmin->plxPlugins->callHook('AdminArticleFoot'));
424
# On inclut le footer
425
include(dirname(__FILE__).'/foot.php');
7
* @author Stephane F et Florent MONTHEL
10
include(dirname(__FILE__).'/prepend.php');
12
# Control du token du formulaire
13
if(!isset($_POST['preview']))
14
plxToken::validateFormToken($_POST);
17
eval($plxAdmin->plxPlugins->callHook('AdminArticlePrepend'));
19
# validation de l'id de l'article si passé en parametre
20
if(isset($_GET['a']) AND !preg_match('/^_?[0-9]{4}$/',$_GET['a'])) {
21
plxMsg::Error(L_ERR_UNKNOWN_ARTICLE); # Article inexistant
22
header('Location: index.php');
27
if(!empty($_POST)) { # Création, mise à jour, suppression ou aperçu
29
if(!isset($_POST['catId'])) $_POST['catId']=array();
30
# Titre par défaut si titre vide
31
if(trim($_POST['title'])=='') $_POST['title'] = L_DEFAULT_NEW_ARTICLE_TITLE;
32
# Si demande d'enregistrement en brouillon on ajoute la categorie draft à la liste et on retire la demande de validation
33
if(isset($_POST['draft']) AND !in_array('draft',$_POST['catId'])) array_unshift($_POST['catId'], 'draft');
34
# si aucune catégorie sélectionnée on place l'article dans la catégorie "non classé"
35
if(sizeof($_POST['catId'])==1 AND $_POST['catId'][0]=='draft') $_POST['catId'][]='000';
36
else $_POST['catId'] = array_filter($_POST['catId'], create_function('$a', 'return $a!="000";'));
37
# Si demande de publication ou demande de validation, on supprime la catégorie draft si elle existe
38
if((isset($_POST['update']) OR isset($_POST['publish']) OR isset($_POST['moderate'])) AND isset($_POST['catId'])) $_POST['catId'] = array_filter($_POST['catId'], create_function('$a', 'return $a!="draft";'));
39
# Si profil PROFIL_WRITER on vérifie l'id du rédacteur connecté et celui de l'article
40
if($_SESSION['profil']==PROFIL_WRITER AND isset($_POST['author']) AND $_SESSION['user']!=$_POST['author']) $_POST['author']=$_SESSION['user'];
41
# Si profil PROFIL_WRITER on vérifie que l'article n'est pas celui d'un autre utilisateur
42
if($_SESSION['profil']==PROFIL_WRITER AND isset($_POST['artId']) AND $_POST['artId']!='0000') {
44
if(($aFile = $plxAdmin->plxGlob_arts->query('/^'.$_POST['artId'].'.([home[draft|0-9,]*).'.$_SESSION['user'].'.(.+).xml$/')) == false) { # Article inexistant
45
plxMsg::Error(L_ERR_UNKNOWN_ARTICLE);
46
header('Location: index.php');
50
# Previsualisation d'un article
51
if(!empty($_POST['preview'])) {
53
$art['title'] = trim($_POST['title']);
54
$art['allow_com'] = $_POST['allow_com'];
55
$art['template'] = basename($_POST['template']);
56
$art['chapo'] = trim($_POST['chapo']);
57
$art['content'] = trim($_POST['content']);
58
$art['tags'] = trim($_POST['tags']);
59
$art['meta_description'] = $_POST['meta_description'];
60
$art['meta_keywords'] = $_POST['meta_keywords'];
61
$art['title_htmltag'] = $_POST['title_htmltag'];
62
$art['filename'] = '';
63
$art['numero'] = $_POST['artId'];
64
$art['author'] = $_POST['author'];
65
$art['categorie'] = '';
66
if(!empty($_POST['catId'])) {
68
foreach($_POST['catId'] as $k => $v) {
69
if($v!='draft') $array[]=$v;
71
$art['categorie']=implode(',',$array);
73
$art['date'] = $_POST['year'].$_POST['month'].$_POST['day'].substr(str_replace(':','',$_POST['time']),0,4);
75
if(trim($_POST['url']) == '')
76
$art['url'] = plxUtils::title2url($_POST['title']);
78
$art['url'] = plxUtils::title2url($_POST['url']);
79
if($art['url'] == '') $art['url'] = L_DEFAULT_NEW_ARTICLE_URL;
82
eval($plxAdmin->plxPlugins->callHook('AdminArticlePreview'));
85
$_SESSION['preview'] = $article;
86
header('Location: '.PLX_ROOT.'index.php?preview');
89
# Suppression d'un article
90
if(isset($_POST['delete'])) {
91
$plxAdmin->delArticle($_POST['artId']);
92
header('Location: index.php');
95
# Mode création ou maj
96
if(isset($_POST['update']) OR isset($_POST['publish']) OR isset($_POST['moderate']) OR isset($_POST['draft'])) {
99
# Vérification de l'unicité de l'url
100
$_POST['url'] = plxUtils::title2url(trim($_POST['url'])==''?$_POST['title']:$_POST['url']);
101
foreach($plxAdmin->plxGlob_arts->aFiles as $numart => $filename) {
102
if(preg_match("/^_?[0-9]{4}.([0-9,|home|draft]*).[0-9]{3}.[0-9]{12}.".$_POST["url"].".xml$/", $filename)) {
103
if($numart!=str_replace('_', '',$_POST['artId'])) {
104
$valid = plxMsg::Error(L_ERR_URL_ALREADY_EXISTS." : ".plxUtils::strCheck($_POST["url"])) AND $valid;
108
# Vérification de la validité de la date de publication
109
if(!plxDate::checkDate($_POST['day'],$_POST['month'],$_POST['year'],$_POST['time'])) {
110
$valid = plxMsg::Error(L_ERR_INVALID_PUBLISHING_DATE) AND $valid;
113
$plxAdmin->editArticle($_POST,$_POST['artId']);
114
header('Location: article.php?a='.$_POST['artId']);
116
# Si url ou date invalide, on ne sauvegarde pas mais on repasse en mode brouillon
118
array_unshift($_POST['catId'], 'draft');
122
# Ajout d'une catégorie
123
if(isset($_POST['new_category'])) {
124
# Ajout de la nouvelle catégorie
125
$plxAdmin->editCategories($_POST);
126
# On recharge la nouvelle liste
127
$plxAdmin->getCategories(path('XMLFILE_CATEGORIES'));
128
$_GET['a']=$_POST['artId'];
130
# Alimentation des variables
131
$artId = $_POST['artId'];
132
$title = trim($_POST['title']);
133
$author = $_POST['author'];
134
$catId = isset($_POST['catId'])?$_POST['catId']:array();
135
$date['day'] = $_POST['day'];
136
$date['month'] = $_POST['month'];
137
$date['year'] = $_POST['year'];
138
$date['time'] = $_POST['time'];
139
$chapo = trim($_POST['chapo']);
140
$content = trim($_POST['content']);
141
$tags = trim($_POST['tags']);
142
$url = $_POST['url'];
143
$allow_com = $_POST['allow_com'];
144
$template = $_POST['template'];
145
$meta_description = $_POST['meta_description'];
146
$meta_keywords = $_POST['meta_keywords'];
147
$title_htmltag = $_POST['title_htmltag'];
149
eval($plxAdmin->plxPlugins->callHook('AdminArticlePostData'));
150
} elseif(!empty($_GET['a'])) { # On n'a rien validé, c'est pour l'édition d'un article
151
# On va rechercher notre article
152
if(($aFile = $plxAdmin->plxGlob_arts->query('/^'.$_GET['a'].'.(.+).xml$/')) == false) { # Article inexistant
153
plxMsg::Error(L_ERR_UNKNOWN_ARTICLE);
154
header('Location: index.php');
157
# On parse et alimente nos variables
158
$result = $plxAdmin->parseArticle(PLX_ROOT.$plxAdmin->aConf['racine_articles'].$aFile['0']);
159
$title = trim($result['title']);
160
$chapo = trim($result['chapo']);
161
$content = trim($result['content']);
162
$tags = trim($result['tags']);
163
$author = $result['author'];
164
$url = $result['url'];
165
$date = plxDate::date2Array($result['date']);
166
$catId = explode(',', $result['categorie']);
167
$artId = $result['numero'];
168
$allow_com = $result['allow_com'];
169
$template = $result['template'];
170
$meta_description=$result['meta_description'];
171
$meta_keywords=$result['meta_keywords'];
172
$title_htmltag = $result['title_htmltag'];
174
if($author!=$_SESSION['user'] AND $_SESSION['profil']==PROFIL_WRITER) {
175
plxMsg::Error(L_ERR_FORBIDDEN_ARTICLE);
176
header('Location: index.php');
180
eval($plxAdmin->plxPlugins->callHook('AdminArticleParseData'));
182
} else { # On a rien validé, c'est pour la création d'un article
183
$title = plxUtils::strRevCheck(L_DEFAULT_NEW_ARTICLE_TITLE);
187
$author = $_SESSION['user'];
188
$date = array ('year' => date('Y'),'month' => date('m'),'day' => date('d'),'time' => date('H:i'));
189
$catId = array('draft');
191
$allow_com = $plxAdmin->aConf['allow_com'];
192
$template = 'article.php';
193
$meta_description=$meta_keywords=$title_htmltag='';
195
eval($plxAdmin->plxPlugins->callHook('AdminArticleInitData'));
198
# On inclut le header
199
include(dirname(__FILE__).'/top.php');
201
# On construit la liste des utilisateurs
202
foreach($plxAdmin->aUsers as $_userid => $_user) {
203
if($_user['active'] AND !$_user['delete'] ) {
204
if($_user['profil']==PROFIL_ADMIN)
205
$_users[L_PROFIL_ADMIN][$_userid] = plxUtils::strCheck($_user['name']);
206
elseif($_user['profil']==PROFIL_MANAGER)
207
$_users[L_PROFIL_MANAGER][$_userid] = plxUtils::strCheck($_user['name']);
208
elseif($_user['profil']==PROFIL_MODERATOR)
209
$_users[L_PROFIL_MODERATOR][$_userid] = plxUtils::strCheck($_user['name']);
210
elseif($_user['profil']==PROFIL_EDITOR)
211
$_users[L_PROFIL_EDITOR][$_userid] = plxUtils::strCheck($_user['name']);
213
$_users[L_PROFIL_WRITER][$_userid] = plxUtils::strCheck($_user['name']);
217
# On récupère les templates des articles
218
$aTemplates = array();
219
$files = plxGlob::getInstance(PLX_ROOT.$plxAdmin->aConf['racine_themes'].$plxAdmin->aConf['style']);
220
if ($array = $files->query('/^article(-[a-z0-9-_]+)?.php$/')) {
221
foreach($array as $k=>$v)
222
$aTemplates[$v] = $v;
224
if(empty($aTemplates)) $aTemplates[''] = L_NONE1;
228
<form action="article.php" method="post" id="form_article">
230
<div class="inline-form action-bar">
232
<h2><?php echo (empty($_GET['a']))?L_MENU_NEW_ARTICLES:L_ARTICLE_EDITING; ?></h2>
234
<p><a class="back" href="index.php"><?php echo L_BACK_TO_ARTICLES ?></a></p>
236
<input type="submit" name="preview" onclick="this.form.target='_blank';return true;" value="<?php echo L_ARTICLE_PREVIEW_BUTTON ?>"/>
238
if($_SESSION['profil']>PROFIL_MODERATOR AND $plxAdmin->aConf['mod_art']) {
239
if(in_array('draft', $catId)) { # brouillon
240
if($artId!='0000') # nouvel article
241
echo '<input onclick="this.form.target=\'_self\';return true;" type="submit" name="draft" value="'.L_ARTICLE_DRAFT_BUTTON.'"/> ';
242
echo '<input onclick="this.form.target=\'_self\';return true;" type="submit" name="moderate" value="'.L_ARTICLE_MODERATE_BUTTON.'"/> ';
243
echo ' <input class="red" type="submit" name="delete" value="'.L_DELETE.'" onclick="Check=confirm(\''.L_ARTICLE_DELETE_CONFIRM.'\');if(Check==false) {return false;} else {this.form.target=\'_self\';return true;}" /> ';
245
if(isset($_GET['a']) AND preg_match('/^_[0-9]{4}$/',$_GET['a'])) { # en attente
246
echo '<input onclick="this.form.target=\'_self\';return true;" type="submit" name="update" value="' . L_ARTICLE_UPDATE_BUTTON . '"/> ';
247
echo '<input onclick="this.form.target=\'_self\';return true;" type="submit" name="draft" value="'.L_ARTICLE_DRAFT_BUTTON.'"/> ';
248
echo ' <input class="red" type="submit" name="delete" value="'.L_DELETE.'" onclick="Check=confirm(\''.L_ARTICLE_DELETE_CONFIRM.'\');if(Check==false) {return false;} else {this.form.target=\'_self\';return true;}" /> ';
250
echo '<input onclick="this.form.target=\'_self\';return true;" type="submit" name="draft" value="'.L_ARTICLE_DRAFT_BUTTON.'"/> ';
251
echo '<input onclick="this.form.target=\'_self\';return true;" type="submit" name="moderate" value="'.L_ARTICLE_MODERATE_BUTTON.'"/> ';
255
if(in_array('draft', $catId)) {
256
echo '<input onclick="this.form.target=\'_self\';return true;" type="submit" name="draft" value="' . L_ARTICLE_DRAFT_BUTTON . '"/> ';
257
echo '<input onclick="this.form.target=\'_self\';return true;" type="submit" name="publish" value="' . L_ARTICLE_PUBLISHING_BUTTON . '"/> ';
259
if(!isset($_GET['a']) OR preg_match('/^_[0-9]{4}$/',$_GET['a']))
260
echo '<inpu onclick="this.form.target=\'_self\';return true;" type="submit" name="publish" value="' . L_ARTICLE_PUBLISHING_BUTTON . '"/> ';
262
echo '<input onclick="this.form.target=\'_self\';return true;" type="submit" name="update" value="' . L_ARTICLE_UPDATE_BUTTON . '"/> ';
263
echo '<input onclick="this.form.target=\'_self\';return true;" type="submit" name="draft" value="' . L_ARTICLE_OFFLINE_BUTTON . '"/> ';
266
echo ' <input class="red" type="submit" name="delete" value="'.L_DELETE.'" onclick="Check=confirm(\''.L_ARTICLE_DELETE_CONFIRM.'\');if(Check==false) {return false;} else {this.form.target=\'_self\';return true;}" /> ';
272
<?php eval($plxAdmin->plxPlugins->callHook('AdminArticleTop')) # Hook Plugins ?>
276
<div class="col sml-12 med-7 lrg-8">
280
<div class="col sml-12">
281
<?php plxUtils::printInput('artId',$artId,'hidden'); ?>
282
<label for="id_title"><?php echo L_ARTICLE_TITLE ?> :</label>
283
<?php plxUtils::printInput('title',plxUtils::strCheck($title),'text','42-255',false,'full-width'); ?>
287
<div class="col sml-12">
288
<label for="id_chapo"><?php echo L_HEADLINE_FIELD ?> : <a id="toggler_chapo" href="javascript:void(0)" onclick="toggleDiv('toggle_chapo', 'toggler_chapo', '<?php echo L_ARTICLE_CHAPO_DISPLAY ?>','<?php echo L_ARTICLE_CHAPO_HIDE ?>')"><?php echo $chapo==''?L_ARTICLE_CHAPO_DISPLAY:L_ARTICLE_CHAPO_HIDE ?></a></label>
289
<div id="toggle_chapo"<?php echo $chapo!=''?'':' style="display:none"' ?>>
290
<?php plxUtils::printArea('chapo',plxUtils::strCheck($chapo),35,8,false,'full-width'); ?>
295
<div class="col sml-12">
296
<label for="id_content"><?php echo L_CONTENT_FIELD ?> :</label>
297
<?php plxUtils::printArea('content',plxUtils::strCheck($content),35,30,false,'full-width'); ?>
298
<?php if($artId!='' AND $artId!='0000') : ?>
299
<?php $link = $plxAdmin->urlRewrite('index.php?article'.intval($artId).'/'.$url) ?>
303
<div class="col sml-12">
304
<label for="id_link"><?php echo L_LINK_FIELD ?> : <?php echo '<a onclick="this.target=\'_blank\';return true;" href="'.$link.'" title="'.L_LINK_ACCESS.'">'.L_LINK_VIEW.'</a>'; ?></label>
306
<?php echo '<input id="id_link" onclick="this.select()" class="readonly" readonly="readonly" type="text" value="'.$link.'" />' ?>
311
<?php eval($plxAdmin->plxPlugins->callHook('AdminArticleContent')) ?>
313
<?php echo plxToken::getTokenPostMethod() ?>
316
<div class="sidebar col sml-12 med-5 lrg-4">
318
<p><?php echo L_ARTICLE_STATUS ?> :
321
if(isset($_GET['a']) AND preg_match('/^_[0-9]{4}$/',$_GET['a']))
323
elseif(in_array('draft', $catId)) {
325
echo '<input type="hidden" name="catId[]" value="draft" />';
334
<div class="col sml-12">
335
<label for="id_author"><?php echo L_ARTICLE_LIST_AUTHORS ?> : </label>
337
if($_SESSION['profil'] < PROFIL_WRITER)
338
plxUtils::printSelect('author', $_users, $author);
340
echo '<input type="hidden" id="id_author" name="author" value="'.$author.'" />';
341
echo '<strong>'.plxUtils::strCheck($plxAdmin->aUsers[$author]['name']).'</strong>';
347
<div class="col sml-12">
348
<label><?php echo L_ARTICLE_DATE ?> :</label>
349
<div class="inline-form">
350
<?php plxUtils::printInput('day',$date['day'],'text','2-2',false,false); ?>
351
<?php plxUtils::printInput('month',$date['month'],'text','2-2',false,false); ?>
352
<?php plxUtils::printInput('year',$date['year'],'text','2-4',false,false); ?>
353
<?php plxUtils::printInput('time',$date['time'],'text','2-5',false,false); ?>
354
<a id="id_cal" href="javascript:void(0)" onclick="dateNow(<?php echo date('Z') ?>); return false;" title="<?php L_NOW; ?>">
355
<img src="theme/images/date.png" alt="calendar" />
361
<div class="col sml-12">
362
<label><?php echo L_ARTICLE_CATEGORIES ?> :</label>
364
$selected = (is_array($catId) AND in_array('000', $catId)) ? ' checked="checked"' : '';
365
echo '<label for="cat_unclassified"><input class="no-margin" disabled="disabled" type="checkbox" id="cat_unclassified" name="catId[]"'.$selected.' value="000" /> '. L_UNCLASSIFIED .'</label>';
366
$selected = (is_array($catId) AND in_array('home', $catId)) ? ' checked="checked"' : '';
367
echo '<label for="cat_home"><input type="checkbox" class="no-margin" id="cat_home" name="catId[]"'.$selected.' value="home" /> '. L_CATEGORY_HOME_PAGE .'</label>';
368
foreach($plxAdmin->aCats as $cat_id => $cat_name) {
369
$selected = (is_array($catId) AND in_array($cat_id, $catId)) ? ' checked="checked"' : '';
370
if($plxAdmin->aCats[$cat_id]['active'])
371
echo '<label for="cat_'.$cat_id.'">'.'<input type="checkbox" class="no-margin" id="cat_'.$cat_id.'" name="catId[]"'.$selected.' value="'.$cat_id.'" /> '.plxUtils::strCheck($cat_name['name']).'</label>';
373
echo '<label for="cat_'.$cat_id.'">'.'<input type="checkbox" class="no-margin" id="cat_'.$cat_id.'" name="catId[]"'.$selected.' value="'.$cat_id.'" /> '.plxUtils::strCheck($cat_name['name']).'</label>';
379
<?php if($_SESSION['profil'] < PROFIL_WRITER) : ?>
382
<div class="col sml-12">
383
<label for="id_new_catname"><?php echo L_NEW_CATEGORY ?> :</label>
384
<div class="inline-form">
385
<?php plxUtils::printInput('new_catname','','text','17-50') ?>
386
<input type="submit" name="new_category" value="<?php echo L_CATEGORY_ADD_BUTTON ?>" />
394
<div class="col sml-12">
395
<label for="id_tags">
396
<?php echo L_ARTICLE_TAGS_FIELD ?> : <a class="hint"><span><?php echo L_ARTICLE_TAGS_FIELD_TITLE ?></span></a>
398
<div class="inline-form">
399
<?php plxUtils::printInput('tags',$tags,'text','25-255',false,false); ?>
400
<a title="<?php echo L_ARTICLE_TOGGLER_TITLE ?>" id="toggler" href="javascript:void(0)" onclick="toggleDiv('tags','toggler','+','-')" style="outline:none; text-decoration: none">+</a>
402
<div id="tags" style="display:none; margin-top: 1rem">
404
if($plxAdmin->aTags) {
406
foreach($plxAdmin->aTags as $tag) {
407
if($tags = array_map('trim', explode(',', $tag['tags']))) {
408
foreach($tags as $tag) {
410
$t = plxUtils::title2url($tag);
411
if(!isset($array[$tag]))
412
$array[$tag]=array('url'=>$t,'count'=>1);
414
$array[$tag]['count']++;
419
array_multisort($array);
420
foreach($array as $tagname => $tag) {
421
echo '<a href="javascript:void(0)" onclick="insTag(\'tags\',\''.$tagname.'\')" title="'.plxUtils::strCheck($tagname).' ('.$tag['count'].')">'.plxUtils::strCheck($tagname).'</a> ('.$tag['count'].') ';
430
<div class="col sml-12">
431
<?php if($plxAdmin->aConf['allow_com']=='1') : ?>
432
<label for="id_allow_com"><?php echo L_ALLOW_COMMENTS ?> :</label>
433
<?php plxUtils::printSelect('allow_com',array('1'=>L_YES,'0'=>L_NO),$allow_com); ?>
435
<?php plxUtils::printInput('allow_com','0','hidden'); ?>
440
<div class="col sml-12">
442
<?php echo L_ARTICLE_URL_FIELD ?> : <a class="hint"><span><?php echo L_ARTICLE_URL_FIELD_TITLE ?></span></a>
444
<?php plxUtils::printInput('url',$url,'text','27-255'); ?>
448
<div class="col sml-12">
449
<label for="id_template"><?php echo L_ARTICLE_TEMPLATE_FIELD ?> :</label>
450
<?php plxUtils::printSelect('template', $aTemplates, $template); ?>
454
<div class="col sml-12">
455
<label for="id_title_htmltag"><?php echo L_ARTICLE_TITLE_HTMLTAG ?> :</label>
456
<?php plxUtils::printInput('title_htmltag',plxUtils::strCheck($title_htmltag),'text','27-255'); ?>
460
<div class="col sml-12">
461
<label for="id_meta_description"><?php echo L_ARTICLE_META_DESCRIPTION ?> :</label>
462
<?php plxUtils::printInput('meta_description',plxUtils::strCheck($meta_description),'text','27-255'); ?>
466
<div class="col sml-12">
467
<label for="id_meta_keywords"><?php echo L_ARTICLE_META_KEYWORDS ?> :</label>
468
<?php plxUtils::printInput('meta_keywords',plxUtils::strCheck($meta_keywords),'text','27-255'); ?>
472
<?php eval($plxAdmin->plxPlugins->callHook('AdminArticleSidebar')) # Hook Plugins ?>
474
<?php if($artId != '0000') : ?>
475
<ul class="unstyled-list">
476
<li><a href="comments.php?a=<?php echo $artId ?>&page=1" title="<?php echo L_ARTICLE_MANAGE_COMMENTS_TITLE ?>"><?php echo L_ARTICLE_MANAGE_COMMENTS ?></a></li>
477
<li><a href="comment_new.php?a=<?php echo $artId ?>" title="<?php echo L_ARTICLE_NEW_COMMENT_TITLE ?>"><?php echo L_ARTICLE_NEW_COMMENT ?></a></li>
490
eval($plxAdmin->plxPlugins->callHook('AdminArticleFoot'));
491
# On inclut le footer
492
include(dirname(__FILE__).'/foot.php');