Dotclear

source: admin/trackbacks.php @ 1346:5d534e157079

Revision 1346:5d534e157079, 4.0 KB checked in by franck <carnet.franck.paul@…>, 12 years ago (diff)

Some pretty jolifications under the high control of kozlika :-)

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12
13require dirname(__FILE__).'/../inc/admin/prepend.php';
14
15dcPage::check('usage,contentadmin');
16
17# Check if post exists and is online
18$id = !empty($_REQUEST['id']) ? (integer) $_REQUEST['id'] : null;
19
20$post = null;
21$tb_excerpt = $tb_urls = '';
22$auto_link = '';
23$can_view_page = true;
24
25# Check if post exists
26if ($id !== null)
27{
28     $params['post_id'] = $id;
29     $params['post_status'] = 1;
30     $post = $core->blog->getPosts($params);
31     
32     if ($post->isEmpty()) {
33          $core->error->add(__('This entry does not exist or is not published'));
34          $can_view_page = false;
35     } else {
36          $TB = new dcTrackback($core);
37          $tb_excerpt = $post->post_excerpt_xhtml.' '.$post->post_content_xhtml;
38          $post_title = $post->post_title;
39          $post_url = $post->getURL();
40     }
41}
42else
43{
44     $core->error->add(__('This entry does not exist.'));
45     $can_view_page = false;
46}
47
48# Change excerpt
49if (!empty($_POST['tb_excerpt'])) {
50     $tb_excerpt = $_POST['tb_excerpt'];
51}
52
53# Sanitize excerpt
54$tb_excerpt = html::clean($tb_excerpt);
55$tb_excerpt = html::decodeEntities($tb_excerpt);
56$tb_excerpt = text::cutString(html::escapeHTML($tb_excerpt),255);
57$tb_excerpt = preg_replace('/\s+/ms',' ',$tb_excerpt);
58
59# Send pings
60if ($post && !$post->isEmpty() && !empty($_POST['tb_urls']))
61{
62     $tb_urls = $_POST['tb_urls'];
63     $tb_urls = str_replace("\r",'',$tb_urls);
64     
65     $post_title = html::escapeHTML(trim(html::clean($post_title)));
66     
67     foreach (explode("\n",$tb_urls) as $tb_url)
68     {
69          try {
70               $TB->ping($tb_url,$id,$post_title,$tb_excerpt,$post_url);
71          } catch (Exception $e) {
72               $core->error->add($e->getMessage());
73          }
74     }
75     
76     if (!$core->error->flag()) {
77          http::redirect('trackbacks.php?id='.$id.'&sent=1');
78     }
79}
80
81$page_title = __('Ping blogs');
82
83/* DISPLAY
84-------------------------------------------------------- */
85dcPage::open($page_title,dcPage::jsLoad('js/_trackbacks.js'));
86
87# Exit if we cannot view page
88if (!$can_view_page) {
89     dcPage::close();
90     exit;
91}
92
93if (!empty($_GET['sent'])) {
94     dcPage::message(__('All pings sent.'));
95}
96
97dcPage::breadcrumb(
98     array(
99          html::escapeHTML($core->blog->name) => '',
100          html::escapeHTML($post->post_title) => $core->getPostAdminURL($post->post_type,$id),
101          '<span class="page-title">'.$page_title.'</span>' => ''
102     ));
103
104echo '<p><a class="back" href="'.$core->getPostAdminURL($post->post_type,$id).'">'.
105     sprintf(__('Back to "%s"'),html::escapeHTML($post->post_title)).'</a></p>';
106
107echo
108'<h3 id="entry-preview-title">'.
109html::escapeHTML($post->post_title).'</h3>'.
110'<div class="frame-shrink" id="entry-preview">'.
111($post->post_excerpt_xhtml ? $post->post_excerpt_xhtml.'<hr />' : '').
112$post->post_content_xhtml.
113'</div>';
114
115if (!empty($_GET['auto'])) {
116     flush();
117     $tb_urls = implode("\n",$TB->discover($post->post_excerpt_xhtml.' '.$post->post_content_xhtml));
118} else {
119     $auto_link = '<strong><a class="button" href="trackbacks.php?id='.$id.'&amp;auto=1">'.
120     __('Auto discover ping URLs').'</a></strong>';
121}
122
123echo
124'<h3>'.__('Ping blogs').'</h3>'.
125'<form action="trackbacks.php" id="trackback-form" method="post">'.
126'<p><label for="tb_urls" class="area">'.__('URLs to ping:').
127form::textarea('tb_urls',60,5,$tb_urls).
128'</label></p>'.
129
130'<p><label for="tb_excerpt" class="area">'.__('Send excerpt:').
131form::textarea('tb_excerpt',60,3,$tb_excerpt).'</label></p>'.
132
133'<p>'.form::hidden('id',$id).
134$core->formNonce().
135'<input type="submit" value="'.__('Ping blogs').'" />&nbsp;&nbsp;'.
136$auto_link.'</p>'.
137'</form>';
138
139$pings = $TB->getPostPings($id);
140
141if (!$pings->isEmpty())
142{
143     echo '<h3>'.__('Previously sent pings').'</h3>';
144     
145     echo '<ul class="nice">';
146     while ($pings->fetch()) {
147          echo
148          '<li>'.dt::dt2str(__('%Y-%m-%d %H:%M'),$pings->ping_dt).' - '.
149          $pings->ping_url.'</li>';
150     }
151     echo '</ul>';
152}
153
154dcPage::close();
155?>
Note: See TracBrowser for help on using the repository browser.

Sites map