index.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <?php
  2. # ***** BEGIN LICENSE BLOCK *****
  3. # This file is part of DotClear.
  4. # Copyright (c) 2004 Olivier Meunier and contributors. All rights
  5. # reserved.
  6. #
  7. # DotClear is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # DotClear is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with DotClear; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. #
  21. # ***** END LICENSE BLOCK *****
  22. require dirname(__FILE__).'/inc/prepend.php';
  23. $auth->check(1);
  24. include dirname(__FILE__).'/inc/connexion.php';
  25. if (!empty($_GET['logout'])) {
  26. $blog->tiggerLog('','','Logout');
  27. $_SESSION = array();
  28. session_unset();
  29. session_destroy();
  30. setcookie(session_name(),'',0,'/');
  31. setcookie('dc_admin', NULL, strtotime('-1 hour'),dc_app_url);
  32. header('Location: index.php');
  33. exit;
  34. }
  35. $q = (!empty($_GET['q'])) ? $_GET['q'] : '';
  36. # Sous menu
  37. $mySubMenu->addItem(
  38. '<strong>'.__('New entry').'</strong>',array('poster.php','accesskey="n"'),'images/ico_edit.png',false);
  39. $mySubMenu->addItem(
  40. __('Manage images'),'images.php','images/ico_image.png',false);
  41. $mySubMenu->addItem(
  42. __('View blog'),dc_blog_url,'images/ico_goto.png',false);
  43. # Les catégories du blog
  44. $cat_id = (!empty($_GET['cat_id'])) ? $_GET['cat_id'] : '';
  45. $rsCat = $blog->getCat();
  46. $arry_cat['&nbsp;'] = NULL;
  47. while (!$rsCat->EOF())
  48. {
  49. $arry_cat[$rsCat->f('cat_libelle').
  50. ' ['.$rsCat->f('nb_post').']'] = $rsCat->f('cat_id');
  51. $rsCat->moveNext();
  52. }
  53. # Tableau des mois du blog
  54. $arry_months = array();
  55. foreach ($blog->getAllDates('m','','','',$cat_id) as $k => $v) {
  56. $arry_months[dt::str('%B %Y',$k)] = date('Ym',$k);
  57. }
  58. # Determiner $y et $m les dates de la page
  59. if (!empty($_GET['m']) && in_array($_GET['m'],$arry_months)) {
  60. $m = substr($_GET['m'],4);
  61. $y = substr($_GET['m'],0,4);
  62. } else {
  63. $my_dt = $blog->getEarlierDate($cat_id);
  64. $my_dt = (empty($my_dt)) ? time() : strtotime($my_dt);
  65. $m = $y = '';
  66. }
  67. # Les billets (et titre)
  68. if ($q != '')
  69. {
  70. $posts = $blog->searchPost($q);
  71. $nb_res = $posts->nbRow();
  72. if ($nb_res > 1) {
  73. $subtitle = sprintf(__('%1$d entries match your search of %2$s.'),
  74. $nb_res,'<em>'.htmlspecialchars($q).'</em>');
  75. } else {
  76. $subtitle = sprintf(__('%1$d entrie matches search of %2$s.'),
  77. $nb_res,'<em>'.htmlspecialchars($q).'</em>');
  78. }
  79. }
  80. elseif (isset($_GET['offline'])) {
  81. $blog->setPubMode(0);
  82. $posts = $blog->getLastNews(NULL,'','post_dt DESC');
  83. $subtitle = __('Offline entries.');
  84. }
  85. elseif (isset($_GET['selected'])) {
  86. $posts = $blog->getLastNews(NULL,'','post_dt DESC',true);
  87. $subtitle = __('Selected entries.');
  88. }
  89. elseif ($m == '' && $y == '')
  90. {
  91. $posts = $blog->getLastNews(15,$cat_id,'post_dt DESC');
  92. $subtitle = sprintf(__('Last %d entries.'),15);
  93. }
  94. else
  95. {
  96. $posts = $blog->getPostByDate($y,$m,'',$cat_id,'post_dt DESC');
  97. }
  98. $h_script = '';
  99. if (!$posts->isEmpty()) {
  100. $h_script =
  101. '<script type="text/javascript">'."\n".
  102. "var js_post_ids = new Array('".implode("','",$posts->getIDs('content'))."');\n".
  103. //"window.onload = function() { mOpenClose(js_post_ids,-1); }\n".
  104. "</script>\n";
  105. }
  106. openPage(__('Entries'),$h_script);
  107. echo '<h2>'.__('List of entries').'</h2>';
  108. # Formulaire avec les mois et les catégories
  109. echo
  110. '<form action="index.php" class="clear"><p>'.
  111. '<label for="m" style="display:inline;"><strong>'.__('Month').' : </strong></label>'.
  112. form::combo('m',array_merge(array(''=>''),$arry_months),$y.$m).
  113. ' <label for="cat_id" style="display:inline;"><strong>'.__('Category').' : </strong></label>'.
  114. form::combo('cat_id',$arry_cat,$cat_id).
  115. ' <input class="submit" type="submit" value="'.__('ok').'" />'.
  116. '</p></form>';
  117. # Affichage des mois suivants et précédents
  118. if(!empty($arry_months) && $m != '' && $y != '')
  119. {
  120. $m_invert = array_flip($arry_months);
  121. $m_next = util::getNextPrev($m_invert,$y.$m,'prev');
  122. $m_prev = util::getNextPrev($m_invert,$y.$m,'next');
  123. echo '<p>';
  124. if($m_next) {
  125. echo '<a href="index.php?m='.key($m_next).'&amp;cat_id='.$cat_id.'">&#171; '.
  126. current($m_next).'</a> - ';
  127. }
  128. echo '<strong>'.$m_invert[$y.$m].'</strong>';
  129. if($m_prev) {
  130. echo ' - <a href="index.php?m='.key($m_prev).'&amp;cat_id='.$cat_id.'">'.
  131. current($m_prev).' &#187;</a>';
  132. }
  133. echo '</p>';
  134. }
  135. if (!empty($subtitle)) {
  136. echo '<p>'.$subtitle.'</p>';
  137. }
  138. # Affichage des billets
  139. if ($posts->isEmpty())
  140. {
  141. echo '<p>'.__('No entry').'.</p>';
  142. }
  143. else
  144. {
  145. if (dc_show_previews)
  146. {
  147. echo
  148. '<p class="small"><a href="#" onclick="mOpenClose(js_post_ids,1); return false;">'.
  149. __('show all').'</a> - <a href="#" onclick="mOpenClose(js_post_ids,-1); '.
  150. 'return false;">'.__('hide all').'</a></p>';
  151. }
  152. while(!$posts->EOF())
  153. {
  154. if ($posts->f('post_pub') == 0) {
  155. $post_cancel = __('set online');
  156. $post_class = 'cancel';
  157. $post_img = '<img src="images/check_off.png" '.
  158. 'alt="'.__('This entry is offline').'" class="status" />';
  159. } else {
  160. $post_cancel = __('set offline');
  161. $post_class = 'published';
  162. $post_img = '<img src="images/check_on.png" '.
  163. 'alt="'.__('This entry is online').'" class="status" />';
  164. }
  165. if ($posts->f('post_selected') == 1) {
  166. $post_selected = '<img src="images/selected.png" '.
  167. 'alt="'.__('This entry is selected').'" class="status" />';
  168. } else {
  169. $post_selected = '';
  170. }
  171. $nb_comments = $posts->getNbComments();
  172. $nb_trackbacks = $posts->getNbTrackbacks();
  173. # Liens pour l'édition et mise hors ligne accesibles uniquement au
  174. # propriétaire du billet ou à un admin
  175. if ($_SESSION['sess_user_level'] == 9 || $posts->f('user_id') == $_SESSION['sess_user_id']) {
  176. $edit_links = '[ <strong><a href="poster.php?post_id='.$posts->f('post_id').'">'.
  177. __('edit').'</a></strong> | '.
  178. '<a href="poster.php?post_id='.$posts->f('post_id').'&amp;cancel=1">'.
  179. $post_cancel.'</a> ] ';
  180. } else {
  181. $edit_links = '[ <strong><a href="poster.php?post_id='.$posts->f('post_id').'">'.
  182. __('read').'</a></strong> ] ';
  183. }
  184. # Nombre de commentaires et trackbacks
  185. if ($nb_comments > 1) {
  186. $str_comments = sprintf(__('%d comments'),$nb_comments);
  187. } else {
  188. $str_comments = sprintf(__('%d comment'),$nb_comments);
  189. }
  190. if ($nb_trackbacks > 1) {
  191. $str_trackbacks= sprintf(__('%d trackbacks'),$nb_trackbacks);
  192. } else {
  193. $str_trackbacks= sprintf(__('%d trackback'),$nb_trackbacks);
  194. }
  195. echo
  196. '<div class="ligne '.$post_class.'" id="p'.$posts->f('post_id').'">'.
  197. '<h3 class="ligneTitre">'.
  198. $post_img.' '.$post_selected;
  199. if (dc_show_previews)
  200. {
  201. echo
  202. '<a href="#" onclick="openClose(\'content'.$posts->f('post_id').
  203. '\',0); return false;"><img src="images/plus.png" '.
  204. 'id="img_content'.$posts->f('post_id').'" '.
  205. 'alt="'.__('show/hide').'" title="'.__('show/hide').'" /></a>'.
  206. '&nbsp;&nbsp;';
  207. }
  208. echo
  209. $posts->f('post_titre').'</h3>'.
  210. '<p class="ligneInfo">'.
  211. '<strong>'.date('d/m/Y @ H:i:s',$posts->getTS()).'</strong> '.
  212. $edit_links.
  213. '<a href="poster.php?post_id='.$posts->f('post_id').'#comments">'.
  214. $str_comments.
  215. '</a> - '.
  216. '<a href="poster.php?post_id='.$posts->f('post_id').'#trackbacks">'.
  217. $str_trackbacks.
  218. '</a></p>'.
  219. '<p class="ligneInfo">'.
  220. sprintf(__('by %s - in %s'),'<strong>'.$posts->getUserCN().'</strong>',
  221. '<strong>'.$posts->f('cat_libelle').'</strong>').
  222. '</p>'.
  223. '<div id="content'.$posts->f('post_id').'" class="preview" style="display:none">';
  224. if (dc_show_previews) {
  225. echo
  226. (($posts->f('post_chapo')!='') ? $posts->f('post_chapo').'<hr class="thin" />' : '').
  227. $posts->f('post_content');
  228. }
  229. echo '</div>'.
  230. '</div>';
  231. $posts->moveNext();
  232. }
  233. }
  234. echo
  235. '<form action="index.php"><p>'.
  236. '<label for="q" style="display:inline;">'.__('Search').' : </label> '.
  237. form::field('q',20,'',htmlspecialchars($q)).
  238. ' <input class="submit" type="submit" value="'.__('ok').'" /></p></form>';
  239. if (count($_GET) == 0)
  240. {
  241. echo
  242. '<ul>'.
  243. '<li><a href="index.php?offline=1">'.__('View all offline entries').'</a></li>'.
  244. '<li><a href="index.php?selected=1">'.__('View all selected entries').'</a></li>'.
  245. '</ul>';
  246. echo
  247. '<h3>'.__('Bookmarklet').'</h3>'.
  248. '<p>'.__('You can drag the following link to your links bar or add it to your '.
  249. 'bookmarks and when you "Blog this!" it will open up a popup window with '.
  250. 'information and a link to the site you\'re currently browsing so you can make '.
  251. 'a quick post about it.').'</p>';
  252. if (substr($_SERVER['REQUEST_URI'],-1) == '/') {
  253. $post_url = $_SERVER['REQUEST_URI'].'poster.php';
  254. } else {
  255. $post_url = dirname($_SERVER['REQUEST_URI']).'/poster.php';
  256. }
  257. $post_url = util::getHost().$post_url;
  258. $bkm1 =
  259. "javascript:if(navigator.userAgent.indexOf('Safari') >= 0){".
  260. "Q=getSelection();".
  261. "}else{".
  262. "Q=document.selection?document.selection.createRange().text:document.getSelection();".
  263. "}".
  264. "void(window.open(".
  265. "'".$post_url."?dcb=1'+'".
  266. "&ptext='+escape(Q)+'".
  267. "&purl='+escape(location.href)+'".
  268. "&ptitle='+escape(document.title),".
  269. "'DotClear bookmarklet',".
  270. "'resizable=yes,scrollbars=yes,width=700,height=460,left=100,top=150,status=yes'));";
  271. echo '<p><a href="'.$bkm1.'">Blog this! - '.dc_blog_name.'</a></p>';
  272. }
  273. closePage();
  274. ?>