[geeklog-hg] geeklog: Added a feature that the staticpage autotag second para...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Tue May 21 10:58:39 EDT 2013
changeset 9082:0eab11c26d52
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/0eab11c26d52
user: dengen
date: Tue May 21 23:56:35 2013 +0900
description:
Added a feature that the staticpage autotag second parameter supports the switching of language id. (feature request #0001525)
And also added a similar feature to the story autotag.
diffstat:
plugins/staticpages/functions.inc | 23 +++++++++++++----------
public_html/lib-common.php | 22 ++++++++++++++++++++++
system/lib-story.php | 17 +++++++++--------
3 files changed, 44 insertions(+), 18 deletions(-)
diffs (132 lines):
diff -r 668e73841e0c -r 0eab11c26d52 plugins/staticpages/functions.inc
--- a/plugins/staticpages/functions.inc Mon May 20 19:01:18 2013 +0200
+++ b/plugins/staticpages/functions.inc Tue May 21 23:56:35 2013 +0900
@@ -1221,14 +1221,10 @@
static $recursive = array();
- if ($op == 'tagname' ) {
+ if ($op == 'tagname') {
return array('staticpage', 'staticpage_content');
} elseif ($op == 'permission' || $op == 'nopermission') {
- if ($op == 'permission') {
- $flag = true;
- } else {
- $flag = false;
- }
+ $flag = ($op == 'permission');
$tagnames = array();
if (isset($_GROUPS['Static Page Admin'])) {
@@ -1237,12 +1233,17 @@
$group_id = DB_getItem($_TABLES['groups'], 'grp_id',
"grp_name = 'Static Page Admin'");
}
- $owner_id = SEC_getDefaultRootUser();
-
- if (COM_getPermTag($owner_id, $group_id, $_SP_CONF['autotag_permissions_staticpage_content'][0], $_SP_CONF['autotag_permissions_staticpage_content'][1], $_SP_CONF['autotag_permissions_staticpage_content'][2], $_SP_CONF['autotag_permissions_staticpage_content'][3]) == $flag) {
+ $owner_id = SEC_getDefaultRootUser();
+ $p = 'autotag_permissions_staticpage_content';
+ if (COM_getPermTag($owner_id, $group_id,
+ $_SP_CONF[$p][0], $_SP_CONF[$p][1],
+ $_SP_CONF[$p][2], $_SP_CONF[$p][3]) == $flag) {
$tagnames[] = 'staticpage_content';
}
- if (COM_getPermTag($owner_id, $group_id, $_SP_CONF['autotag_permissions_staticpage'][0], $_SP_CONF['autotag_permissions_staticpage'][1], $_SP_CONF['autotag_permissions_staticpage'][2], $_SP_CONF['autotag_permissions_staticpage'][3]) == $flag) {
+ $p = 'autotag_permissions_staticpage';
+ if (COM_getPermTag($owner_id, $group_id,
+ $_SP_CONF[$p][0], $_SP_CONF[$p][1],
+ $_SP_CONF[$p][2], $_SP_CONF[$p][3]) == $flag) {
$tagnames[] = 'staticpage';
}
@@ -1257,6 +1258,7 @@
} elseif ($op == 'parse') {
if ($autotag['tag'] == 'staticpage') {
$sp_id = COM_applyFilter($autotag['parm1']);
+ $sp_id = COM_switchLanguageIdForObject($sp_id);
if (! empty($sp_id)) {
$result = DB_query("SELECT COUNT(*) AS count "
. "FROM {$_TABLES['staticpage']} "
@@ -1277,6 +1279,7 @@
}
} elseif ($autotag['tag'] == 'staticpage_content') {
$sp_id = COM_applyFilter($autotag['parm1']);
+ $sp_id = COM_switchLanguageIdForObject($sp_id);
if (! empty($sp_id)) {
$result = DB_query("SELECT COUNT(*) AS count "
. "FROM {$_TABLES['staticpage']} "
diff -r 668e73841e0c -r 0eab11c26d52 public_html/lib-common.php
--- a/public_html/lib-common.php Mon May 20 19:01:18 2013 +0200
+++ b/public_html/lib-common.php Tue May 21 23:56:35 2013 +0900
@@ -7648,6 +7648,28 @@
}
/**
+* Switch the language ID of the object id
+*
+* @param string $id object id that the language ID is attached to the end
+* @return string id that is overwritten with the current language ID
+*
+*/
+function COM_switchLanguageIdForObject($id)
+{
+ global $_CONF;
+
+ if (!empty($_CONF['languages']) && !empty($_CONF['language_files'])) {
+ $new_id = COM_getLanguageId();
+ $old_id = COM_getLanguageIdForObject($id);
+ if (!empty($new_id) && !empty($old_id)) {
+ $id = substr_replace($id, $new_id, -strlen($old_id));
+ }
+ }
+
+ return $id;
+}
+
+/**
* Get the name of the current language, minus the character set
*
* Strips the character set from $_CONF['language'].
diff -r 668e73841e0c -r 0eab11c26d52 system/lib-story.php
--- a/system/lib-story.php Mon May 20 19:01:18 2013 +0200
+++ b/system/lib-story.php Tue May 21 23:56:35 2013 +0900
@@ -1248,11 +1248,7 @@
if ($op == 'tagname' ) {
return 'story';
} elseif ($op == 'permission' || $op == 'nopermission') {
- if ($op == 'permission') {
- $flag = true;
- } else {
- $flag = false;
- }
+ $flag = ($op == 'permission');
$tagnames = array();
if (isset($_GROUPS['Story Admin'])) {
@@ -1262,8 +1258,10 @@
"grp_name = 'Story Admin'");
}
$owner_id = SEC_getDefaultRootUser();
-
- if (COM_getPermTag($owner_id, $group_id, $_CONF['autotag_permissions_story'][0], $_CONF['autotag_permissions_story'][1], $_CONF['autotag_permissions_story'][2], $_CONF['autotag_permissions_story'][3]) == $flag) {
+ $p = 'autotag_permissions_story';
+ if (COM_getPermTag($owner_id, $group_id,
+ $_CONF[$p][0], $_CONF[$p][1],
+ $_CONF[$p][2], $_CONF[$p][3]) == $flag) {
$tagnames[] = 'story';
}
@@ -1276,8 +1274,11 @@
);
} else {
$sid = COM_applyFilter($autotag['parm1']);
+ $sid = COM_switchLanguageIdForObject($sid);
if (! empty($sid)) {
- $result = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE sid = '$sid'" . COM_getPermSql('AND'));
+ $result = DB_query("SELECT COUNT(*) AS count "
+ . "FROM {$_TABLES['stories']} "
+ . "WHERE sid = '$sid'" . COM_getPermSql('AND'));
$A = DB_fetchArray($result);
if ($A['count'] > 0) {
More information about the geeklog-cvs
mailing list