~ubuntu-branches/ubuntu/wily/pluxml/wily

« back to all changes in this revision

Viewing changes to core/admin/article.php

  • Committer: Package Import Robot
  • Author(s): Tanguy Ortolo
  • Date: 2015-07-22 14:22:20 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20150722142220-m5tzuyfq6klb44vs
Tags: 5.4-1
* New upstream release.
* debian/dirs: update to new layout (data/images/ replaced by data/medias).
* debian/postinst:
   + migrate images from data/images/ to data/medias/.
   + update main configuration file (version has changed, and a parameter
     was added).
   + use `command -v` instead of `test` to check for lighty-enable-mod
     existence, to avoid using a fully qualified path.
* debian/postrm:
   + use `command -v` instead of `test` to check for lighty-disable-mod, ucf
     and ucfr existence, to avoid using a fully qualified path.
* debian/rules: remove some JavaScript minimizing rules (that file is no
  longer part of PluXml).
* debian/control:
   + no longer depend on slimit (no more JavaScript minimizing).
   + use a line per build dependency and order them alphabetically.
   + update Standards-Version to 3.9.6 (no change needed).
* debian/copyright: remove everything about respond.js which is no longer
  part of PluXml.
* debian/links: update to new layout (data/images replaced by data/medias).
* debian/NEWS: added, to document the migration to 5.4 layout.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
 
3
 
/**
4
 
 * Edition d'un article
5
 
 *
6
 
 * @package PLX
7
 
 * @author      Stephane F et Florent MONTHEL
8
 
 **/
9
 
 
10
 
include(dirname(__FILE__).'/prepend.php');
11
 
 
12
 
# Control du token du formulaire
13
 
if(!isset($_POST['preview']))
14
 
        plxToken::validateFormToken($_POST);
15
 
 
16
 
# Hook Plugins
17
 
eval($plxAdmin->plxPlugins->callHook('AdminArticlePrepend'));
18
 
 
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');
23
 
        exit;
24
 
}
25
 
 
26
 
# Formulaire validé
27
 
if(!empty($_POST)) { # Création, mise à jour, suppression ou aperçu
28
 
 
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') {
43
 
                # On valide l'article
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');
47
 
                        exit;
48
 
                }
49
 
        }
50
 
        # Previsualisation d'un article
51
 
        if(!empty($_POST['preview'])) {
52
 
                $art=array();
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'])) {
67
 
                        $array=array();
68
 
                        foreach($_POST['catId'] as $k => $v) {
69
 
                                if($v!='draft') $array[]=$v;
70
 
                        }
71
 
                        $art['categorie']=implode(',',$array);
72
 
                }
73
 
                $art['date'] = $_POST['year'].$_POST['month'].$_POST['day'].substr(str_replace(':','',$_POST['time']),0,4);
74
 
                $art['nb_com'] = 0;
75
 
                if(trim($_POST['url']) == '')
76
 
                        $art['url'] = plxUtils::title2url($_POST['title']);
77
 
                else
78
 
                        $art['url'] = plxUtils::title2url($_POST['url']);
79
 
                if($art['url'] == '') $art['url'] = L_DEFAULT_NEW_ARTICLE_URL;
80
 
 
81
 
                # Hook Plugins
82
 
                eval($plxAdmin->plxPlugins->callHook('AdminArticlePreview'));
83
 
 
84
 
                $article[0] = $art;
85
 
                $_SESSION['preview'] = $article;
86
 
                header('Location: '.PLX_ROOT.'index.php?preview');
87
 
                exit;
88
 
        }
89
 
        # Suppression d'un article
90
 
        if(isset($_POST['delete'])) {
91
 
                $plxAdmin->delArticle($_POST['artId']);
92
 
                header('Location: index.php');
93
 
                exit;
94
 
        }
95
 
        # Mode création ou maj
96
 
        if(isset($_POST['update']) OR isset($_POST['publish']) OR isset($_POST['moderate']) OR isset($_POST['draft'])) {
97
 
 
98
 
                $valid = true;
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;
105
 
                                }
106
 
                        }
107
 
                }
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;
111
 
                }
112
 
                if($valid) {
113
 
                        $plxAdmin->editArticle($_POST,$_POST['artId']);
114
 
                        header('Location: article.php?a='.$_POST['artId']);
115
 
                        exit;
116
 
                }
117
 
 
118
 
        }
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'];
126
 
        }
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'];
145
 
        # Hook Plugins
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');
152
 
                exit;
153
 
        }
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'];
170
 
 
171
 
        if($author!=$_SESSION['user'] AND $_SESSION['profil']==PROFIL_WRITER) {
172
 
                plxMsg::Error(L_ERR_FORBIDDEN_ARTICLE);
173
 
                header('Location: index.php');
174
 
                exit;
175
 
        }
176
 
        # Hook Plugins
177
 
        eval($plxAdmin->plxPlugins->callHook('AdminArticleParseData'));
178
 
 
179
 
} else { # On a rien validé, c'est pour la création d'un article
180
 
        $title = plxUtils::strRevCheck(L_DEFAULT_NEW_ARTICLE_TITLE);
181
 
        $chapo = $url = '';
182
 
        $content = '';
183
 
        $tags = '';
184
 
        $author = $_SESSION['user'];
185
 
        $date = array ('year' => date('Y'),'month' => date('m'),'day' => date('d'),'time' => date('H:i'));
186
 
        $catId = array('draft');
187
 
        $artId = '0000';
188
 
        $allow_com = $plxAdmin->aConf['allow_com'];
189
 
        $template = 'article.php';
190
 
        $meta_description=$meta_keywords=$title_htmltag='';
191
 
        # Hook Plugins
192
 
        eval($plxAdmin->plxPlugins->callHook('AdminArticleInitData'));
193
 
}
194
 
 
195
 
# On inclut le header
196
 
include(dirname(__FILE__).'/top.php');
197
 
 
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']);
209
 
                else
210
 
                        $_users[L_PROFIL_WRITER][$_userid] = plxUtils::strCheck($_user['name']);
211
 
        }
212
 
}
213
 
 
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;
219
 
}
220
 
$cat_id='000';
221
 
?>
222
 
 
223
 
<form action="article.php" method="post" id="form_article">
224
 
 
225
 
        <div id="extra-container">
226
 
 
227
 
                <div id="extra-sidebar">
228
 
                        <p class="field_head"><?php echo L_ARTICLE_STATUS ?>&nbsp;:&nbsp;
229
 
                                <strong>
230
 
                                <?php
231
 
                                if(isset($_GET['a']) AND preg_match('/^_[0-9]{4}$/',$_GET['a']))
232
 
                                        echo L_AWAITING;
233
 
                                elseif(in_array('draft', $catId)) {
234
 
                                        echo L_DRAFT;
235
 
                                        echo '<input type="hidden" name="catId[]" value="draft" />';
236
 
                                }
237
 
                                else
238
 
                                        echo L_PUBLISHED;
239
 
                                ?>
240
 
                                </strong>
241
 
                        </p>
242
 
                        <fieldset>
243
 
                                <p><label for="id_author"><?php echo L_ARTICLE_LIST_AUTHORS ?>&nbsp;:&nbsp;</label></p>
244
 
                                <?php
245
 
                                if($_SESSION['profil'] < PROFIL_WRITER)
246
 
                                        plxUtils::printSelect('author', $_users, $author);
247
 
                                else {
248
 
                                        echo '<input type="hidden" id="id_author" name="author" value="'.$author.'" />';
249
 
                                        echo '<strong>'.plxUtils::strCheck($plxAdmin->aUsers[$author]['name']).'</strong>';
250
 
                                }
251
 
                                ?>
252
 
                                <p><label><?php echo L_ARTICLE_DATE ?>&nbsp;:</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>
258
 
 
259
 
                                <p><label><?php echo L_ARTICLE_CATEGORIES ?>&nbsp;:</label></p>
260
 
                                <?php
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">&nbsp;'. 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">&nbsp;'. 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.'">&nbsp;'.plxUtils::strCheck($cat_name['name']).'</label><br />';
270
 
                                                else
271
 
                                                        echo '<label for="cat_'.$cat_id.'">&nbsp;<em>'.plxUtils::strCheck($cat_name['name']).'</em></label><br />';
272
 
                                        }
273
 
                                ?>
274
 
 
275
 
                                <?php if($_SESSION['profil'] < PROFIL_WRITER) : ?>
276
 
                                <p><label for="id_new_catname"><?php echo L_NEW_CATEGORY ?>&nbsp;:</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 ?>" />
279
 
                                <?php endif; ?>
280
 
 
281
 
                                <p><label for="id_tags"><?php echo L_ARTICLE_TAGS_FIELD ?>&nbsp;:</label>&nbsp;<a class="help" title="<?php echo L_ARTICLE_TAGS_FIELD_TITLE ?>">&nbsp;</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">
285
 
                                <?php
286
 
                                if($plxAdmin->aTags) {
287
 
                                        $array=array();
288
 
                                        foreach($plxAdmin->aTags as $tag) {
289
 
                                                if($tags = array_map('trim', explode(',', $tag['tags']))) {
290
 
                                                        foreach($tags as $tag) {
291
 
                                                                if($tag!='') {
292
 
                                                                        $t = plxUtils::title2url($tag);
293
 
                                                                        if(!isset($array[$tag]))
294
 
                                                                                $array[$tag]=array('url'=>$t,'count'=>1);
295
 
                                                                        else
296
 
                                                                                $array[$tag]['count']++;
297
 
                                                                }
298
 
                                                        }
299
 
                                                }
300
 
                                        }
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'].') ';
304
 
                                        }
305
 
                                }
306
 
                                else echo L_NO_TAG;
307
 
                                ?>
308
 
                                </div>
309
 
 
310
 
                                <?php if($plxAdmin->aConf['allow_com']=='1') : ?>
311
 
                                <p><label for="id_allow_com"><?php echo L_ALLOW_COMMENTS ?>&nbsp;:</label></p>
312
 
                                <?php plxUtils::printSelect('allow_com',array('1'=>L_YES,'0'=>L_NO),$allow_com); ?>
313
 
                                <?php else: ?>
314
 
                                        <?php plxUtils::printInput('allow_com','0','hidden'); ?>
315
 
                                <?php endif; ?>
316
 
 
317
 
                                <p><label for="id_url"><?php echo L_ARTICLE_URL_FIELD ?>&nbsp;:</label>&nbsp;<a class="help" title="<?php echo L_ARTICLE_URL_FIELD_TITLE ?>">&nbsp;</a></p>
318
 
                                <?php plxUtils::printInput('url',$url,'text','27-255'); ?>
319
 
 
320
 
                                <p><label for="id_template"><?php echo L_ARTICLE_TEMPLATE_FIELD ?>&nbsp;:</label></p>
321
 
                                <?php plxUtils::printSelect('template', $aTemplates, $template); ?>
322
 
 
323
 
                                <p><label for="id_title_htmltag"><?php echo L_ARTICLE_TITLE_HTMLTAG ?>&nbsp;:</label></p>
324
 
                                <?php plxUtils::printInput('title_htmltag',plxUtils::strCheck($title_htmltag),'text','27-255'); ?>
325
 
 
326
 
                                <p><label for="id_meta_description"><?php echo L_ARTICLE_META_DESCRIPTION ?>&nbsp;:</label></p>
327
 
                                <?php plxUtils::printInput('meta_description',plxUtils::strCheck($meta_description),'text','27-255'); ?>
328
 
 
329
 
                                <p><label for="id_meta_keywords"><?php echo L_ARTICLE_META_KEYWORDS ?>&nbsp;:</label></p>
330
 
                                <?php plxUtils::printInput('meta_keywords',plxUtils::strCheck($meta_keywords),'text','27-255'); ?>
331
 
 
332
 
                                <?php eval($plxAdmin->plxPlugins->callHook('AdminArticleSidebar')) # Hook Plugins ?>
333
 
 
334
 
                                <?php if($artId != '0000') : ?>
335
 
                                <ul class="opts">
336
 
                                        <li>&nbsp;<a href="comments.php?a=<?php echo $artId ?>&amp;page=1" title="<?php echo L_ARTICLE_MANAGE_COMMENTS_TITLE ?>"><?php echo L_ARTICLE_MANAGE_COMMENTS ?></a></li>
337
 
                                        <li>&nbsp;<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>
338
 
                                </ul>
339
 
                                <?php endif; ?>
340
 
 
341
 
                        </fieldset>
342
 
 
343
 
                </div><!-- extra sidebar -->
344
 
 
345
 
                <div id="extra-content">
346
 
 
347
 
                        <p class="back"><a href="index.php"><?php echo L_BACK_TO_ARTICLES ?></a></p>
348
 
 
349
 
                        <h2><?php echo (empty($_GET['a']))?L_MENU_NEW_ARTICLES:L_ARTICLE_EDITING; ?></h2>
350
 
 
351
 
                        <?php eval($plxAdmin->plxPlugins->callHook('AdminArticleTop')) # Hook Plugins ?>
352
 
 
353
 
                        <div class="form_content">
354
 
                                <fieldset>
355
 
                                        <?php plxUtils::printInput('artId',$artId,'hidden'); ?>
356
 
                                        <p><label for="id_title"><?php echo L_ARTICLE_TITLE ?>&nbsp;:</label></p>
357
 
                                        <?php plxUtils::printInput('title',plxUtils::strCheck($title),'text','42-255'); ?>
358
 
                                        <p id="p_chapo">
359
 
                                                <label for="id_chapo"><?php echo L_HEADLINE_FIELD ?>&nbsp;:</label>
360
 
                                                &nbsp;
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>
362
 
                                        </p>
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 ?>&nbsp;:</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 ?>&nbsp;:&nbsp;</label>
369
 
                                                        <?php echo '<a onclick="this.target=\'_blank\';return true;" href="'.$link.'" title="'.L_LINK_ACCESS.'">'.L_LINK_VIEW.'</a>'; ?>
370
 
                                                </p>
371
 
                                                <?php echo '<input id="id_link" onclick="this.select()" class="readonly" readonly="readonly" type="text" value="'.$link.'" />' ?>
372
 
                                        <?php endif; ?>
373
 
                                </fieldset>
374
 
                                <?php eval($plxAdmin->plxPlugins->callHook('AdminArticleContent')) ?>
375
 
                        </div>
376
 
 
377
 
                        <div class="form_bottom">
378
 
                                <p class="center">
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 ?>"/>
381
 
                                        <?php
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.'"/>';
388
 
                                                        } else {
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 . '"/>';
393
 
                                                                } else {
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.'"/>';
396
 
                                                                }
397
 
                                                        }
398
 
                                                } else {
399
 
                                                        if($artId!='0000')
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 . '"/>';
404
 
                                                        } else {
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 . '"/>';
407
 
                                                                else
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 . '"/>';
410
 
                                                        }
411
 
                                                }
412
 
                                        ?>
413
 
                                </p>
414
 
                        </div>
415
 
 
416
 
                </div><!-- extra-content -->
417
 
 
418
 
        </div><!-- extra container -->
419
 
 
420
 
</form>
421
 
<?php
422
 
# Hook Plugins
423
 
eval($plxAdmin->plxPlugins->callHook('AdminArticleFoot'));
424
 
# On inclut le footer
425
 
include(dirname(__FILE__).'/foot.php');
426
 
?>
 
1
<?php
 
2
 
 
3
/**
 
4
 * Edition d'un article
 
5
 *
 
6
 * @package PLX
 
7
 * @author      Stephane F et Florent MONTHEL
 
8
 **/
 
9
 
 
10
include(dirname(__FILE__).'/prepend.php');
 
11
 
 
12
# Control du token du formulaire
 
13
if(!isset($_POST['preview']))
 
14
        plxToken::validateFormToken($_POST);
 
15
 
 
16
# Hook Plugins
 
17
eval($plxAdmin->plxPlugins->callHook('AdminArticlePrepend'));
 
18
 
 
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');
 
23
        exit;
 
24
}
 
25
 
 
26
# Formulaire validé
 
27
if(!empty($_POST)) { # Création, mise à jour, suppression ou aperçu
 
28
 
 
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') {
 
43
                # On valide l'article
 
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');
 
47
                        exit;
 
48
                }
 
49
        }
 
50
        # Previsualisation d'un article
 
51
        if(!empty($_POST['preview'])) {
 
52
                $art=array();
 
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'])) {
 
67
                        $array=array();
 
68
                        foreach($_POST['catId'] as $k => $v) {
 
69
                                if($v!='draft') $array[]=$v;
 
70
                        }
 
71
                        $art['categorie']=implode(',',$array);
 
72
                }
 
73
                $art['date'] = $_POST['year'].$_POST['month'].$_POST['day'].substr(str_replace(':','',$_POST['time']),0,4);
 
74
                $art['nb_com'] = 0;
 
75
                if(trim($_POST['url']) == '')
 
76
                        $art['url'] = plxUtils::title2url($_POST['title']);
 
77
                else
 
78
                        $art['url'] = plxUtils::title2url($_POST['url']);
 
79
                if($art['url'] == '') $art['url'] = L_DEFAULT_NEW_ARTICLE_URL;
 
80
 
 
81
                # Hook Plugins
 
82
                eval($plxAdmin->plxPlugins->callHook('AdminArticlePreview'));
 
83
 
 
84
                $article[0] = $art;
 
85
                $_SESSION['preview'] = $article;
 
86
                header('Location: '.PLX_ROOT.'index.php?preview');
 
87
                exit;
 
88
        }
 
89
        # Suppression d'un article
 
90
        if(isset($_POST['delete'])) {
 
91
                $plxAdmin->delArticle($_POST['artId']);
 
92
                header('Location: index.php');
 
93
                exit;
 
94
        }
 
95
        # Mode création ou maj
 
96
        if(isset($_POST['update']) OR isset($_POST['publish']) OR isset($_POST['moderate']) OR isset($_POST['draft'])) {
 
97
 
 
98
                $valid = true;
 
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;
 
105
                                }
 
106
                        }
 
107
                }
 
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;
 
111
                }
 
112
                if($valid) {
 
113
                        $plxAdmin->editArticle($_POST,$_POST['artId']);
 
114
                        header('Location: article.php?a='.$_POST['artId']);
 
115
                        exit;
 
116
                # Si url ou date invalide, on ne sauvegarde pas mais on repasse en mode brouillon
 
117
                }else{
 
118
                        array_unshift($_POST['catId'], 'draft');
 
119
                }
 
120
 
 
121
        }
 
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'];
 
129
        }
 
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'];
 
148
        # Hook Plugins
 
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');
 
155
                exit;
 
156
        }
 
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'];
 
173
 
 
174
        if($author!=$_SESSION['user'] AND $_SESSION['profil']==PROFIL_WRITER) {
 
175
                plxMsg::Error(L_ERR_FORBIDDEN_ARTICLE);
 
176
                header('Location: index.php');
 
177
                exit;
 
178
        }
 
179
        # Hook Plugins
 
180
        eval($plxAdmin->plxPlugins->callHook('AdminArticleParseData'));
 
181
 
 
182
} else { # On a rien validé, c'est pour la création d'un article
 
183
        $title = plxUtils::strRevCheck(L_DEFAULT_NEW_ARTICLE_TITLE);
 
184
        $chapo = $url = '';
 
185
        $content = '';
 
186
        $tags = '';
 
187
        $author = $_SESSION['user'];
 
188
        $date = array ('year' => date('Y'),'month' => date('m'),'day' => date('d'),'time' => date('H:i'));
 
189
        $catId = array('draft');
 
190
        $artId = '0000';
 
191
        $allow_com = $plxAdmin->aConf['allow_com'];
 
192
        $template = 'article.php';
 
193
        $meta_description=$meta_keywords=$title_htmltag='';
 
194
        # Hook Plugins
 
195
        eval($plxAdmin->plxPlugins->callHook('AdminArticleInitData'));
 
196
}
 
197
 
 
198
# On inclut le header
 
199
include(dirname(__FILE__).'/top.php');
 
200
 
 
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']);
 
212
                else
 
213
                        $_users[L_PROFIL_WRITER][$_userid] = plxUtils::strCheck($_user['name']);
 
214
        }
 
215
}
 
216
 
 
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;
 
223
}
 
224
if(empty($aTemplates)) $aTemplates[''] = L_NONE1;
 
225
$cat_id='000';
 
226
?>
 
227
 
 
228
<form action="article.php" method="post" id="form_article">
 
229
 
 
230
        <div class="inline-form action-bar">
 
231
 
 
232
                <h2><?php echo (empty($_GET['a']))?L_MENU_NEW_ARTICLES:L_ARTICLE_EDITING; ?></h2>
 
233
 
 
234
                <p><a class="back" href="index.php"><?php echo L_BACK_TO_ARTICLES ?></a></p>
 
235
 
 
236
                <input type="submit" name="preview" onclick="this.form.target='_blank';return true;" value="<?php echo L_ARTICLE_PREVIEW_BUTTON ?>"/>
 
237
                <?php
 
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 '&nbsp;&nbsp;&nbsp;<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;}" /> ';
 
244
                                } else {
 
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 '&nbsp;&nbsp;&nbsp;<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;}" /> ';
 
249
                                        } else {
 
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.'"/> ';
 
252
                                        }
 
253
                                }
 
254
                        } else {
 
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 . '"/> ';
 
258
                                } else {
 
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 . '"/> ';
 
261
                                        else
 
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 . '"/> ';
 
264
                                }
 
265
                                if($artId!='0000')
 
266
                                        echo '&nbsp;&nbsp;&nbsp;<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;}" /> ';
 
267
                        }
 
268
                ?>
 
269
 
 
270
        </div>
 
271
 
 
272
        <?php eval($plxAdmin->plxPlugins->callHook('AdminArticleTop')) # Hook Plugins ?>
 
273
 
 
274
        <div class="grid">
 
275
 
 
276
                <div class="col sml-12 med-7 lrg-8">
 
277
 
 
278
                        <fieldset>
 
279
                                <div class="grid">
 
280
                                        <div class="col sml-12">
 
281
                                                <?php plxUtils::printInput('artId',$artId,'hidden'); ?>
 
282
                                                <label for="id_title"><?php echo L_ARTICLE_TITLE ?>&nbsp;:</label>
 
283
                                                <?php plxUtils::printInput('title',plxUtils::strCheck($title),'text','42-255',false,'full-width'); ?>
 
284
                                        </div>
 
285
                                </div>
 
286
                                <div class="grid">
 
287
                                        <div class="col sml-12">
 
288
                                                <label for="id_chapo"><?php echo L_HEADLINE_FIELD ?>&nbsp;:&nbsp;<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'); ?>
 
291
                                                </div>
 
292
                                        </div>
 
293
                                </div>
 
294
                                <div class="grid">
 
295
                                        <div class="col sml-12">
 
296
                                                <label for="id_content"><?php echo L_CONTENT_FIELD ?>&nbsp;:</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) ?>
 
300
                                        </div>
 
301
                                </div>
 
302
                                <div class="grid">
 
303
                                        <div class="col sml-12">
 
304
                                                <label for="id_link"><?php echo L_LINK_FIELD ?>&nbsp;:&nbsp;<?php echo '<a onclick="this.target=\'_blank\';return true;" href="'.$link.'" title="'.L_LINK_ACCESS.'">'.L_LINK_VIEW.'</a>'; ?></label>
 
305
 
 
306
                                                <?php echo '<input id="id_link" onclick="this.select()" class="readonly" readonly="readonly" type="text" value="'.$link.'" />' ?>
 
307
                                                <?php endif; ?>
 
308
                                        </div>
 
309
                                </div>
 
310
                        </fieldset>
 
311
                        <?php eval($plxAdmin->plxPlugins->callHook('AdminArticleContent')) ?>
 
312
 
 
313
                        <?php echo plxToken::getTokenPostMethod() ?>
 
314
                </div>
 
315
 
 
316
                <div class="sidebar col sml-12 med-5 lrg-4">
 
317
 
 
318
                        <p><?php echo L_ARTICLE_STATUS ?>&nbsp;:&nbsp;
 
319
                                <strong>
 
320
                                <?php
 
321
                                if(isset($_GET['a']) AND preg_match('/^_[0-9]{4}$/',$_GET['a']))
 
322
                                        echo L_AWAITING;
 
323
                                elseif(in_array('draft', $catId)) {
 
324
                                        echo L_DRAFT;
 
325
                                        echo '<input type="hidden" name="catId[]" value="draft" />';
 
326
                                }
 
327
                                else
 
328
                                        echo L_PUBLISHED;
 
329
                                ?>
 
330
                                </strong>
 
331
                        </p>
 
332
                        <fieldset>
 
333
                                <div class="grid">
 
334
                                        <div class="col sml-12">
 
335
                                                <label for="id_author"><?php echo L_ARTICLE_LIST_AUTHORS ?>&nbsp;:&nbsp;</label>
 
336
                                                <?php
 
337
                                                if($_SESSION['profil'] < PROFIL_WRITER)
 
338
                                                        plxUtils::printSelect('author', $_users, $author);
 
339
                                                else {
 
340
                                                        echo '<input type="hidden" id="id_author" name="author" value="'.$author.'" />';
 
341
                                                        echo '<strong>'.plxUtils::strCheck($plxAdmin->aUsers[$author]['name']).'</strong>';
 
342
                                                }
 
343
                                                ?>
 
344
                                        </div>
 
345
                                </div>
 
346
                                <div class="grid">
 
347
                                        <div class="col sml-12">
 
348
                                                <label><?php echo L_ARTICLE_DATE ?>&nbsp;:</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" />
 
356
                                                        </a>
 
357
                                                </div>
 
358
                                        </div>
 
359
                                </div>
 
360
                                <div class="grid">
 
361
                                        <div class="col sml-12">
 
362
                                                <label><?php echo L_ARTICLE_CATEGORIES ?>&nbsp;:</label>
 
363
                                                <?php
 
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" />&nbsp;'. 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" />&nbsp;'. 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.'" />&nbsp;'.plxUtils::strCheck($cat_name['name']).'</label>';
 
372
                                                                else
 
373
                                                                        echo '<label for="cat_'.$cat_id.'">'.'<input type="checkbox" class="no-margin" id="cat_'.$cat_id.'" name="catId[]"'.$selected.' value="'.$cat_id.'" />&nbsp;'.plxUtils::strCheck($cat_name['name']).'</label>';
 
374
                                                        }
 
375
                                                ?>
 
376
                                        </div>
 
377
                                </div>
 
378
 
 
379
                                <?php if($_SESSION['profil'] < PROFIL_WRITER) : ?>
 
380
 
 
381
                                <div class="grid">
 
382
                                        <div class="col sml-12">
 
383
                                                <label for="id_new_catname"><?php echo L_NEW_CATEGORY ?>&nbsp;:</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 ?>" />
 
387
                                                </div>
 
388
                                        </div>
 
389
                                </div>
 
390
 
 
391
                                <?php endif; ?>
 
392
 
 
393
                                <div class="grid">
 
394
                                        <div class="col sml-12">
 
395
                                                <label for="id_tags">
 
396
                                                        <?php echo L_ARTICLE_TAGS_FIELD ?>&nbsp;:&nbsp;<a class="hint"><span><?php echo L_ARTICLE_TAGS_FIELD_TITLE ?></span></a>
 
397
                                                </label>
 
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>
 
401
                                                </div>
 
402
                                                <div id="tags" style="display:none; margin-top: 1rem">
 
403
                                                        <?php
 
404
                                                        if($plxAdmin->aTags) {
 
405
                                                                $array=array();
 
406
                                                                foreach($plxAdmin->aTags as $tag) {
 
407
                                                                        if($tags = array_map('trim', explode(',', $tag['tags']))) {
 
408
                                                                                foreach($tags as $tag) {
 
409
                                                                                        if($tag!='') {
 
410
                                                                                                $t = plxUtils::title2url($tag);
 
411
                                                                                                if(!isset($array[$tag]))
 
412
                                                                                                        $array[$tag]=array('url'=>$t,'count'=>1);
 
413
                                                                                                else
 
414
                                                                                                        $array[$tag]['count']++;
 
415
                                                                                        }
 
416
                                                                                }
 
417
                                                                        }
 
418
                                                                }
 
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'].')&nbsp;&nbsp;';
 
422
                                                                }
 
423
                                                        }
 
424
                                                        else echo L_NO_TAG;
 
425
                                                        ?>
 
426
                                                </div>
 
427
                                        </div>
 
428
                                </div>
 
429
                                <div class="grid">
 
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 ?>&nbsp;:</label>
 
433
                                                <?php plxUtils::printSelect('allow_com',array('1'=>L_YES,'0'=>L_NO),$allow_com); ?>
 
434
                                                <?php else: ?>
 
435
                                                <?php plxUtils::printInput('allow_com','0','hidden'); ?>
 
436
                                                <?php endif; ?>
 
437
                                        </div>
 
438
                                </div>
 
439
                                <div class="grid">
 
440
                                        <div class="col sml-12">
 
441
                                                <label for="id_url">
 
442
                                                        <?php echo L_ARTICLE_URL_FIELD ?>&nbsp;:&nbsp;<a class="hint"><span><?php echo L_ARTICLE_URL_FIELD_TITLE ?></span></a>
 
443
                                                </label>
 
444
                                                <?php plxUtils::printInput('url',$url,'text','27-255'); ?>
 
445
                                        </div>
 
446
                                </div>
 
447
                                <div class="grid">
 
448
                                        <div class="col sml-12">
 
449
                                                <label for="id_template"><?php echo L_ARTICLE_TEMPLATE_FIELD ?>&nbsp;:</label>
 
450
                                                <?php plxUtils::printSelect('template', $aTemplates, $template); ?>
 
451
                                        </div>
 
452
                                </div>
 
453
                                <div class="grid">
 
454
                                        <div class="col sml-12">
 
455
                                                <label for="id_title_htmltag"><?php echo L_ARTICLE_TITLE_HTMLTAG ?>&nbsp;:</label>
 
456
                                                <?php plxUtils::printInput('title_htmltag',plxUtils::strCheck($title_htmltag),'text','27-255'); ?>
 
457
                                        </div>
 
458
                                </div>
 
459
                                <div class="grid">
 
460
                                        <div class="col sml-12">
 
461
                                                <label for="id_meta_description"><?php echo L_ARTICLE_META_DESCRIPTION ?>&nbsp;:</label>
 
462
                                                <?php plxUtils::printInput('meta_description',plxUtils::strCheck($meta_description),'text','27-255'); ?>
 
463
                                        </div>
 
464
                                </div>
 
465
                                <div class="grid">
 
466
                                        <div class="col sml-12">
 
467
                                                <label for="id_meta_keywords"><?php echo L_ARTICLE_META_KEYWORDS ?>&nbsp;:</label>
 
468
                                                <?php plxUtils::printInput('meta_keywords',plxUtils::strCheck($meta_keywords),'text','27-255'); ?>
 
469
                                        </div>
 
470
                                </div>
 
471
 
 
472
                                <?php eval($plxAdmin->plxPlugins->callHook('AdminArticleSidebar')) # Hook Plugins ?>
 
473
 
 
474
                                <?php if($artId != '0000') : ?>
 
475
                                <ul class="unstyled-list">
 
476
                                        <li><a href="comments.php?a=<?php echo $artId ?>&amp;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>
 
478
                                </ul>
 
479
                                <?php endif; ?>
 
480
 
 
481
                        </fieldset>
 
482
 
 
483
                </div>
 
484
 
 
485
        </div>
 
486
 
 
487
</form>
 
488
<?php
 
489
# Hook Plugins
 
490
eval($plxAdmin->plxPlugins->callHook('AdminArticleFoot'));
 
491
# On inclut le footer
 
492
include(dirname(__FILE__).'/foot.php');
 
493
?>