This repository has been archived by the owner on Jul 25, 2018. It is now read-only.
/
view.php
executable file
·132 lines (117 loc) · 6.09 KB
/
view.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
if(!$_REQUEST['id']) die('NO ID SPECIFIED');
require_once 'tagFunctions.php';
require_once 'XNC/Ajax.php';
$group = XN_Content::load(intval($_REQUEST['id']));
$grouptags = explode(' ',$group->my->grouptags);
foreach($grouptags as $id => $tag)
$grouptags[$id] = str_replace('+',' ',$tag);
if($_REQUEST['format']) {
if(!class_exists('Outline'))
XN_Application::includeFile('xoxotools','/OutlineClasses/Outline.php');
$struct = new Outline();
$struct->addNode($grouptags);
$struct->getNode(0)->setField('title',$group->title);
$struct->getNode(0)->setField('relatedtags',new Outline(fetchTags($group)));
if($_REQUEST['format'] == 'xoxo') {
header('Content-Type: application/xml;charset=utf-8');
$struct->getNode(0)->setField('text',$group->title);
if($_ITEMONLY)
echo $struct->getNode(0)->toXOXO('item');
else
echo $struct->toXOXO();
}//end if format == xoxo
if($_REQUEST['format'] == 'json') {
header('Content-Type: text/javascript;charset=utf-8');
if(!isset($_REQUEST['raw']) && !$_ITEMONLY) {
if($_REQUEST['callback'])
echo $_REQUEST['callback'].'(';
else
echo 'if(typeof(Tagging) != "object") var Tagging = {};'."\n".'Tagging.groups = [';
}//end if ! isset raw
echo $struct->getNode(0)->toJSON('grouptags',true);
if(!isset($_REQUEST['raw']) && !$_ITEMONLY) {
if($_REQUEST['callback'])
echo ')';
else
echo '];'."\n".'if(Tagging.callbacks && Tagging.callbacks.groups) Tagging.callbacks.groups(Tagging.groups)';
}//end if ! isset raw
}//end if format == json
} else {
echo XNC_Ajax::scriptInclude();
$group->focus();
echo '<xn:head><title>tagging / tags / '.strtolower($grouptags[0]).'</title></xn:head>';
echo '<h2 style="display:inline;" id="group-title">'.$group->h('title').'</h2>';
if(XN_Profile::current()->screenName == $group->contributorName) {
echo ' <a href="javascript:toggleitem("edit-title");"><img src="http://group.ning.com/images/icn/edit.gif" alt="Edit »" /></a>';
echo '<div id="edit-title" style="display:none;">';
$edititleform = XNC_Ajax::Form()->method('post')
->actionUrl('/groupEdit.php?form')
->htmlElement('group-title')
->callback('Loading', '$("group-title").innerHTML = "<i>Saving...</i>";toggleitem("edit-title");');
$edititleform->open();
echo '<input type="hidden" name="edit-title" value="yes" />';
echo '<input type="hidden" name="id" value="'.$_REQUEST['id'].'" />';
echo '<input type="hidden" name="return_to" value="http://'.$_SERVER['HTTP_HOST'].'/view.php?id='.$_REQUEST['id'].'" />';
echo '<p>Edit Title: <input type="text" name="title" value="'.$group->h('title').'" /> <input type="submit" value="Save" /></p>';
$edititleform->close();
echo '</div>';
}//end if current == contributorName
echo '<br />';
echo '<p id="group-desc" style="display:inline;">'.nl2br($group->h('description')).'</p>';
if(XN_Profile::current()->screenName == $group->contributorName) {
echo ' <a href="javascript:toggleitem("edit-desc");"><img src="http://group.ning.com/images/icn/edit.gif" alt="Edit »" /></a>';
echo '<div id="edit-desc" style="display:none;">';
$edititleform = XNC_Ajax::Form()->method('post')
->actionUrl('/groupEdit.php?form')
->htmlElement('group-desc')
->callback('Loading', '$("group-desc").innerHTML = "<i>Saving...</i>";toggleitem("edit-desc");');
$edititleform->open();
echo '<input type="hidden" name="edit-desc" value="yes" />';
echo '<input type="hidden" name="id" value="'.$_REQUEST['id'].'" />';
echo '<input type="hidden" name="return_to" value="http://'.$_SERVER['HTTP_HOST'].'/view.php?id='.$_REQUEST['id'].'" />';
echo '<p>Edit Description:<br /> <textarea name="desc" style="width:300px;height:100px;">'.$group->h('description').'</textarea><br /> <input type="submit" value="Save" /></p>';
$edititleform->close();
echo '</div>';
}//end if current == contributorName
echo '<br />';
echo '<p id="group-tags">';
echo '<b>Group Tags:</b> ';
foreach($grouptags as $id => $grouptag) {
if($id > 0)
echo ', ';
echo $grouptag.' ';
XNC_Ajax::Link('<img src="http://www.ning.com/xnstatic/icn/cross.gif" alt="[X]" />')
->actionUrl('/groupEdit.php?form&delete&return_to='.urlencode('http://'.$_SERVER['HTTP_HOST'].'/view.php?id='.$_REQUEST['id']).'&grouptag='.urlencode($grouptag).'&id='.$_REQUEST['id'])
->htmlElement('group-tags')
->callback('Loading', '$("group-tags").innerHTML = "<i>Deleting...</i>";')
->confirm('Delete the '.$grouptag.' tag?')
->make();
}//end foreach grouptags
echo '</p>';
$grouptagform = XNC_Ajax::Form()->method('post')
->actionUrl('/groupEdit.php?form')
->htmlElement('group-tags')
->callback('Loading', '$("group-tags").innerHTML = "<i>Adding...</i>";');
$grouptagform->open();
echo '<input type="hidden" name="add" value="yes" />';
echo '<input type="hidden" name="id" value="'.$_REQUEST['id'].'" />';
echo '<input type="hidden" name="return_to" value="http://'.$_SERVER['HTTP_HOST'].'/view.php?id='.$_REQUEST['id'].'" />';
echo '<p>Add a group tag: <input type="text" name="grouptag" /> <input type="submit" value="Add" /></p>';
$grouptagform->close();
echo '<p>';
echo '<b>Related Tags:</b> ';
foreach(fetchTags($group) as $id => $tag) {
if($id > 0)
echo ', ';
echo '<a class="tag" href="/index.php/tag/'.$tag.'" rel="tag">'.$tag.'</a>';
}//end foreach tags
echo '</p>';
echo '<p style="font-style:italic;">Add/remove related tags using the sidebar.</p>';
echo '<h3 id="comments">Discuss TagGroup</h3>';
include_once 'extComments.php';
$_SERVER['SCRIPT_URI'] = 'http://'.$_SERVER['HTTP_HOST'].'/view.php';
$_SERVER['QUERY_STRING'] = 'id='.$group->id;
extComments($group);
}//end if-else format
?>