[geeklog-hg] geeklog: #1490 entertained, Added feature for a [topic:] tag
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sat May 11 13:38:16 EDT 2013
changeset 9062:6f68f38f2dd8
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/6f68f38f2dd8
user: gugu <rishabhr123 at gmail.com>
date: Fri May 10 19:43:19 2013 +0530
description:
#1490 entertained, Added feature for a [topic:] tag
diffstat:
language/english.php | 3 +-
public_html/admin/install/config-install.php | 1 +
system/lib-plugins.php | 3 +-
system/lib-topic.php | 69 +++++++++++++++++++++++++++-
4 files changed, 73 insertions(+), 3 deletions(-)
diffs (135 lines):
diff -r 48487930824a -r 6f68f38f2dd8 language/english.php
--- a/language/english.php Sat May 11 13:49:34 2013 +0200
+++ b/language/english.php Fri May 10 19:43:19 2013 +0530
@@ -929,7 +929,8 @@
52 => 'Story',
53 => 'Image',
'breadcrumb_separator' => '>',
- 'breadcrumb_root' => 'Home'
+ 'breadcrumb_root' => 'Home',
+ 'autotag_desc_topic' => '[topic: id alternate title] - Displays a link to a topic using the ID as the title. An alternate title may be specified but is not required.'
);
###############################################################################
diff -r 48487930824a -r 6f68f38f2dd8 public_html/admin/install/config-install.php
--- a/public_html/admin/install/config-install.php Sat May 11 13:49:34 2013 +0200
+++ b/public_html/admin/install/config-install.php Fri May 10 19:43:19 2013 +0530
@@ -425,6 +425,7 @@
$c->add('fs_autotag_permissions', NULL, 'fieldset', 7, 41, NULL, 0, TRUE, $me, 37);
$c->add('autotag_permissions_story', array(2, 2, 2, 2), '@select', 7, 41, 28, 1870, TRUE, $me, 37);
$c->add('autotag_permissions_user', array(2, 2, 2, 2), '@select', 7, 41, 28, 1880, TRUE, $me, 37);
+ $c->add('autotag_permissions_topic', array(2, 2, 2, 2), '@select', 7, 41, 28, 1890, TRUE, $me, 37);
$c->add('tab_webservices', NULL, 'tab', 7, 40, NULL, 0, TRUE, $me, 40);
$c->add('fs_webservices', NULL, 'fieldset', 7, 40, NULL, 0, TRUE, $me, 40);
diff -r 48487930824a -r 6f68f38f2dd8 system/lib-plugins.php
--- a/system/lib-plugins.php Sat May 11 13:49:34 2013 +0200
+++ b/system/lib-plugins.php Fri May 10 19:43:19 2013 +0530
@@ -1569,6 +1569,7 @@
require_once $_CONF['path_system'] . 'lib-story.php';
require_once $_CONF['path_system'] . 'lib-user.php';
+ require_once $_CONF['path_system'] . 'lib-topic.php';
if (! is_array($_PLUGINS)) {
/** as a side effect of parsing autotags in templates, we may end
@@ -1577,7 +1578,7 @@
*/
$_PLUGINS = array();
}
- $all_plugins = array_merge($_PLUGINS, array('story', 'user'));
+ $all_plugins = array_merge($_PLUGINS, array('story', 'user', 'topic'));
$autolinkModules = array();
diff -r 48487930824a -r 6f68f38f2dd8 system/lib-topic.php
--- a/system/lib-topic.php Sat May 11 13:49:34 2013 +0200
+++ b/system/lib-topic.php Fri May 10 19:43:19 2013 +0530
@@ -70,6 +70,7 @@
* @return array
*
*/
+
function TOPIC_buildTree($id, $parent = '', $branch_level = -1, $tree_array = array())
{
global $_TABLES, $_CONF, $_USER, $LANG27;
@@ -156,6 +157,72 @@
}
/**
+* Implements the [topic:] autotag.
+*
+* @param string $op operation to perform
+* @param string $content item (e.g. topic text), including the autotag
+* @param array $autotag parameters used in the autotag
+* @param mixed tag names (for $op='tagname') or formatted content
+*
+*/
+
+function plugin_autotags_topic($op, $content = '', $autotag = '')
+{
+ global $_CONF, $_TABLES, $LANG27, $_GROUPS;
+ if($op == 'tagname') {
+ return 'topic';
+ }
+
+ elseif (($op == 'permission') || ($op == 'nopermission')) {
+ if ($op == 'permission') {
+ $flag = true;
+ } else {
+ $flag = false;
+ }
+ $tagnames = array();
+
+ if (isset($_GROUPS['Topic Admin'])) {
+ $group_id = $_GROUPS['Topic Admin'];
+ } else {
+ $group_id = DB_getItem($_TABLES['groups'], 'grp_id',"grp_name = 'Topic Admin'");
+ }
+ $owner_id = SEC_getDefaultRootUser();
+
+ if (COM_getPermTag($owner_id, $group_id, $_CONF['autotag_permissions_topic'][0], $_CONF['autotag_permissions_topic'][1], $_CONF['autotag_permissions_topic'][2], $_CONF['autotag_permissions_topic'][3]) == $flag) {
+ $tagnames[] = 'topic';
+ }
+
+ if (count($tagnames) > 0) {
+ return $tagnames;
+ }
+ }
+
+ elseif ($op == 'description') {
+ return array ('topic' => $LANG27['autotag_desc_topic']);
+ }
+
+ elseif ($op == 'parse') {
+ $tid = COM_applyFilter($autotag['parm1']);
+ $tid = DB_escapeString($tid);
+ if(! empty($tid)) {
+ $sql = "SELECT COUNT(*) as count FROM {$_TABLES['topics']} where tid = '$tid'";
+ $result = DB_query($sql);
+ $A = DB_fetchArray($result);
+ if ($A['count'] == 1) {
+ $url = COM_buildUrl($_CONF['site_url'] . '/index.php?topic=' . $tid);
+ $linktext = $autotag['parm2'];
+ if (empty($linktext)) {
+ $linktext = stripslashes(DB_getItem($_TABLES['topics'],'meta_description', "tid = '$tid'"));
+ }
+ $link = COM_createLink($linktext, $url);
+ $content = str_replace($autotag['tagstr'], $link, $content);
+ }
+ }
+ return $content;
+ }
+}
+
+/**
* Return the index of a topic in the TOPICS array that matches the topic id
*
* @param string $id The id of the topic to find the index for
@@ -1449,4 +1516,4 @@
}
}
-?>
\ No newline at end of file
+?>
More information about the geeklog-cvs
mailing list