-
Notifications
You must be signed in to change notification settings - Fork 3
/
rss_article_edit.php
107 lines (90 loc) · 3.6 KB
/
rss_article_edit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
# --- BEGIN PLUGIN META ---
$plugin=array(
'name'=>'rss_article_edit',
'version'=>'0.1',
'author'=>'Rob Sable',
'author_uri'=>'http://www.wilshireone.com/',
'description'=>'Add edit article links to your public site.',
'type'=>'1',
);
# --- END PLUGIN META ---
# --- BEGIN PLUGIN CODE ---
if ('admin' === @txpinterface)
{
add_privs('editlink','1,2,3,4,5,6');
// Add a new tab under 'extensions' called 'edit link', for the 'editlink' event
register_tab("extensions", "editlink", "edit link");
// 'rss_admin_editlink' will be called to handle the 'editlink' event
register_callback("rss_admin_editlink", "editlink");
}
function rss_admin_editlink($event, $step)
{
global $rss_ae_cookie;
include(txpath . '/include/txp_prefs.php');
if (!isset($rss_ae_cookie))
{
$rss_ae_cookie = "rss_article_edit";
$rs = safe_insert('txp_prefs', "name='rss_ae_cookie', val='$rss_ae_cookie', prefs_id='1'");
}
if (gps("add"))
{
safe_update("txp_prefs", "val = '".addslashes(ps('rss_ae_cookie'))."'","name = 'rss_ae_cookie' and prefs_id ='1'");
setcookie($rss_ae_cookie, $rss_ae_cookie, time()+31536000, "/");
header("Location: index.php?event=editlink");
}
else if (gps("rem"))
{
safe_update("txp_prefs", "val = '".addslashes(ps('rss_ae_cookie'))."'","name = 'rss_ae_cookie' and prefs_id ='1'");
setcookie($rss_ae_cookie, $rss_ae_cookie, time()-3600, "/");
header("Location: index.php?event=editlink");
}
pagetop("Edit Link");
$aeset = isset($_COOKIE[$rss_ae_cookie]) ? "" : " not";
$tdaStyle = ' style="text-align:right;vertical-align:middle"';
echo form(startTable("list").
tr(tdcs(hed("Add/Remove Public Site Article Edit Link",1),2)).
tr(
tda(graf('Cookie '.$rss_ae_cookie.' is'.$aeset.' set.', ' align="center"'), ' colspan="2"')
).
tr(
tda(gTxt('Cookie Name:'), ' style="text-align:right;vertical-align:middle"').tda(text_input("rss_ae_cookie",$rss_ae_cookie,'20'), ' ')
).
tr(
tda(graf(fInput("submit","add",gTxt("Add Edit Link"),"publish").fInput("submit","rem",gTxt("Remove Edit Link"),"publish").eInput("editlink"), ' align="center"'), ' colspan="2"')
).
endTable());
}
function rss_article_edit($atts,$thing="")
{
global $thisarticle, $rss_ae_cookie, $prefs;
extract(lAtts(array(
'hidelive' => '', # Set to non-empty string to hide links on live sites.
'prefix' => '',
'suffix' => ''
),$atts)
);
$hidelive = !empty($hidelive) && ('live'===$prefs['production_status']);
return (isset($_COOKIE[$rss_ae_cookie]) && !$hidelive) ? $prefix.'<a href="'.hu.'textpattern/index.php?event=article&step=edit&ID='.$thisarticle['thisid'].'">'.parse($thing).'</a>'.$suffix : '';
}
# --- END PLUGIN CODE ---
if (0) {
?>
<!--
# --- BEGIN PLUGIN HELP ---
<p>
h1. Public Site Article Edit Link</p>
<p>This plugin allows you to add an edit link for articles to you public website that can only be seen by you. Clicking the link will bring you into the <span class="caps">TXP</span> admin interface article editing view for that article allowing you to edit articles without having to search for them in the article listing.</p>
<p>In order to use the plugin:</p>
<ol>
<li>Navigate to the extensions -> edit link tab</li>
<li>You have the option to change the cookie name that will be used</li>
<li>Click the Add or Remove buttons to set or expire the cookie</li>
<li>Add the rss_editlink tag to your article form (e.g., <code><txp:rss_article_edit>Edit</txp:rss_article_edit></code>)</li>
<li>Navigate to an article on your public site and click the edit link to be taken to the content -> write tab for that article.</li>
</ol>
# --- END PLUGIN HELP ---
-->
<?php
}
?>