[geeklog-hg] geeklog: Added several config options (whats_related, whats_rela...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Mon Jun 17 21:15:55 EDT 2013
changeset 9096:a484d35ea8c3
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/a484d35ea8c3
user: Tom <websitemaster at cogeco.net>
date: Mon Jun 17 21:14:17 2013 -0400
description:
Added several config options (whats_related, whats_related_max, whats_related_trim) to improve the What's Related list for articles. List now also displays more than one topic if required (bug #0001607)
diffstat:
language/english.php | 6 +-
language/english_utf-8.php | 8 +-
public_html/admin/configuration_validation.php | 5 +
public_html/admin/install/config-install.php | 6 +
public_html/article.php | 2 +-
public_html/docs/english/config.html | 15 +-
public_html/docs/japanese/config.html | 15 +-
sql/updates/mssql_2.0.0_to_2.0.1.php | 7 +-
sql/updates/mysql_2.0.0_to_2.0.1.php | 5 +
sql/updates/pgsql_2.0.0_to_2.0.1.php | 5 +
system/lib-plugins.php | 8 +-
system/lib-story.php | 194 +++++++++++++++++++-----
system/lib-topic.php | 41 +++-
13 files changed, 247 insertions(+), 70 deletions(-)
diffs (truncated from 522 to 300 lines):
diff -r 6c40e4d4a4ae -r a484d35ea8c3 language/english.php
--- a/language/english.php Fri Jun 14 14:34:40 2013 -0400
+++ b/language/english.php Mon Jun 17 21:14:17 2013 -0400
@@ -1964,6 +1964,9 @@
'aftersave_story' => "After Saving Story",
'related_topics' => "Related Topics",
'related_topics_max' => "Max Related Topics to Display",
+ 'whats_related' => "What's Related",
+ 'whats_related_max' => "Max What's Related to Display",
+ 'whats_related_trim' => "What's Related Title Length",
'aftersave_user' => "After Saving User",
'show_right_blocks' => "Always Show Right Blocks?",
'showfirstasfeatured' => "Show First Story as Featured?",
@@ -2207,7 +2210,8 @@
29 => array('md5' => 0, 'sha1' => 1, 'sha256' => 2, 'sha512' => 3, 'blowfish' => 4),
30 => array('Start' => 'start', 'End' => 'end', 'None' => 'none'),
31 => array('Newest First' => 'DESC', 'Oldest First' => 'ASC'),
- 32 => array('Disabled' => 0, 'Just Article Pages' => 1, 'Articles and Topics' => 'articletopic')
+ 32 => array('Disabled' => 0, 'Just Article Pages' => 1, 'Articles and Topics' => 2),
+ 33 => array('Disabled' => 0, 'Enabled' => 1, 'Enabled (No Links)' => 2, 'Enabled (No Outbound Links)' => 3)
);
################################################################################
diff -r 6c40e4d4a4ae -r a484d35ea8c3 language/english_utf-8.php
--- a/language/english_utf-8.php Fri Jun 14 14:34:40 2013 -0400
+++ b/language/english_utf-8.php Mon Jun 17 21:14:17 2013 -0400
@@ -1963,7 +1963,10 @@
'onlyrootfeatures' => "Only Root can Feature?",
'aftersave_story' => "After Saving Story",
'related_topics' => "Related Topics",
- 'related_topics_max' => "Max Related Topics to Display",
+ 'related_topics_max' => "Max Related Topics to Display",
+ 'whats_related' => "What's Related",
+ 'whats_related_max' => "Max What's Related to Display",
+ 'whats_related_trim' => "What's Related Title Length",
'aftersave_user' => "After Saving User",
'show_right_blocks' => "Always Show Right Blocks?",
'showfirstasfeatured' => "Show First Story as Featured?",
@@ -2207,7 +2210,8 @@
29 => array('md5' => 0, 'sha1' => 1, 'sha256' => 2, 'sha512' => 3, 'blowfish' => 4),
30 => array('Start' => 'start', 'End' => 'end', 'None' => 'none'),
31 => array('Newest First' => 'DESC', 'Oldest First' => 'ASC'),
- 32 => array('Disabled' => 0, 'Just Article Pages' => 1, 'Articles and Topics' => 'articletopic')
+ 32 => array('Disabled' => 0, 'Just Article Pages' => 1, 'Articles and Topics' => 2),
+ 33 => array('Disabled' => 0, 'Enabled' => 1, 'Enabled (No Links)' => 2, 'Enabled (No Outbound Links)' => 3)
);
################################################################################
diff -r 6c40e4d4a4ae -r a484d35ea8c3 public_html/admin/configuration_validation.php
--- a/public_html/admin/configuration_validation.php Fri Jun 14 14:34:40 2013 -0400
+++ b/public_html/admin/configuration_validation.php Mon Jun 17 21:14:17 2013 -0400
@@ -203,6 +203,11 @@
'rule' => array('inList', array(0, 1, 2), false)
);
$_CONF_VALIDATE['Core']['related_topics_max'] = array('rule' => 'numeric');
+$_CONF_VALIDATE['Core']['whats_related'] = array(
+ 'rule' => array('inList', array(0, 1, 2, 3), false)
+);
+$_CONF_VALIDATE['Core']['whats_related_max'] = array('rule' => 'numeric');
+$_CONF_VALIDATE['Core']['whats_related_trim'] = array('rule' => 'numeric');
/* Subgroup Stories and Trackback, Tab Trackback */
$_CONF_VALIDATE['Core']['trackback_enabled'] = array('rule' => 'boolean');
diff -r 6c40e4d4a4ae -r a484d35ea8c3 public_html/admin/install/config-install.php
--- a/public_html/admin/install/config-install.php Fri Jun 14 14:34:40 2013 -0400
+++ b/public_html/admin/install/config-install.php Mon Jun 17 21:14:17 2013 -0400
@@ -36,6 +36,9 @@
function install_config()
{
global $_CONF, $_TABLES;
+
+
+ // Parameters for add function: $param_name, $default_value, $type, $subgroup, $fieldset=null, $selection_array=null, $sort=0, $set=true, $group='Core', $tab=null
$me = 'Core';
@@ -142,6 +145,9 @@
$c->add('aftersave_story','list','select',1,7,9,1330,TRUE, $me, 7);
$c->add('related_topics',1,'select',1,7,32,1340,TRUE, $me, 7);
$c->add('related_topics_max',6,'text',1,7,NULL,1350,TRUE, $me, 7);
+ $c->add('whats_related',1,'select',1,7,33,1360,TRUE, $me, 7);
+ $c->add('whats_related_max',0,'text',1,7,NULL,1370,TRUE, $me, 7);
+ $c->add('whats_related_trim',26,'text',1,7,NULL,1380,TRUE, $me, 7);
$c->add('tab_trackback', NULL, 'tab', 1, 8, NULL, 0, TRUE, $me, 8);
$c->add('fs_trackback', NULL, 'fieldset', 1, 8, NULL, 0, TRUE, $me, 8);
diff -r 6c40e4d4a4ae -r a484d35ea8c3 public_html/article.php
--- a/public_html/article.php Fri Jun 14 14:34:40 2013 -0400
+++ b/public_html/article.php Mon Jun 17 21:14:17 2013 -0400
@@ -357,7 +357,7 @@
*/
$related = STORY_whatsRelated($story->displayElements('related'),
$story->displayElements('uid'),
- $story->displayElements('tid'));
+ $story->getSid());
if (!empty ($related)) {
$related = COM_startBlock ($LANG11[1], '',
COM_getBlockTemplate ('whats_related_block', 'header'))
diff -r 6c40e4d4a4ae -r a484d35ea8c3 public_html/docs/english/config.html
--- a/public_html/docs/english/config.html Fri Jun 14 14:34:40 2013 -0400
+++ b/public_html/docs/english/config.html Mon Jun 17 21:14:17 2013 -0400
@@ -463,8 +463,19 @@
<tr>
<td valign="top"><a name="desc_related_topics_max">related_topics_max</a></td>
<td valign="top">6</td>
- <td valign="top">Maximum numbers of topics to display for Related Topics.</td></tr>
-<tr>
+ <td valign="top">Maximum numbers of topics to display for Related Topics. If 0 will display all related topics.</td></tr>
+<tr>
+ <td valign="top"><a name="desc_whats_related">whats_related</a></td>
+ <td valign="top">1</td>
+ <td valign="top">Disable or Enable article What's Related block. You may also select to have no links (from the article) to be displayed in the list, or only no outbound links (pointing to other websites).</td></tr>
+<tr>
+ <td valign="top"><a name="desc_whats_related_max">whats_related_max</a></td>
+ <td valign="top">0</td>
+ <td valign="top">Maximum numbers of items to display for the What's Related list on the article page. If 0 will display all related items found. A minimum of 2 items is required.</td></tr>
+<tr>
+ <td valign="top"><a name="desc_whats_related_trim">whats_related_trim</a></td>
+ <td valign="top">26</td>
+ <td valign="top">Max. length of the title of items listed in the What's Related list. If 0 will not trim titles. If this option is changed this will update all related links in the database for articles.</td></tr>
</table>
<h3><a name="stories_trackback">Stories and Trackback: Trackback</a></h3>
diff -r 6c40e4d4a4ae -r a484d35ea8c3 public_html/docs/japanese/config.html
--- a/public_html/docs/japanese/config.html Fri Jun 14 14:34:40 2013 -0400
+++ b/public_html/docs/japanese/config.html Mon Jun 17 21:14:17 2013 -0400
@@ -408,8 +408,19 @@
<tr>
<td valign="top"><a name="desc_related_topics_max">related_topics_max</a></td>
<td valign="top">6</td>
- <td valign="top">Maximum numbers of topics to display for Related Topics.</td></tr>
-<tr>
+ <td valign="top">Maximum numbers of topics to display for Related Topics. If 0 will display all related topics.</td></tr>
+<tr>
+ <td valign="top"><a name="desc_whats_related">whats_related</a></td>
+ <td valign="top">1</td>
+ <td valign="top">Disable or Enable article What's Related block. You may also select to have no links (from the article) to be displayed in the list, or only no outbound links (pointing to other websites).</td></tr>
+<tr>
+ <td valign="top"><a name="desc_whats_related_max">whats_related_max</a></td>
+ <td valign="top">0</td>
+ <td valign="top">Maximum numbers of items to display for the What's Related list on the article page. If 0 will display all related items found. A minimum of 2 items is required.</td></tr>
+<tr>
+ <td valign="top"><a name="desc_whats_related_trim">whats_related_trim</a></td>
+ <td valign="top">26</td>
+ <td valign="top">Max. length of the title of items listed in the What's Related list. If 0 will not trim titles. If this option is changed this will update all related links in the database for articles.</td></tr>
</table>
<h3><a name="stories_trackback">è¨äºã¨ãã©ãã¯ããã¯: ãã©ãã¯ããã¯</a></h3>
diff -r 6c40e4d4a4ae -r a484d35ea8c3 sql/updates/mssql_2.0.0_to_2.0.1.php
--- a/sql/updates/mssql_2.0.0_to_2.0.1.php Fri Jun 14 14:34:40 2013 -0400
+++ b/sql/updates/mssql_2.0.0_to_2.0.1.php Mon Jun 17 21:14:17 2013 -0400
@@ -26,7 +26,12 @@
// Article Related Topics
$c->add('related_topics',1,'select',1,7,32,1340,TRUE, $me, 7);
- $c->add('related_topics_max',6,'text',1,7,NULL,1350,TRUE, $me, 7);
+ $c->add('related_topics_max',6,'text',1,7,NULL,1350,TRUE, $me, 7);
+
+ // Article What's Related
+ $c->add('whats_related',1,'select',1,7,33,1360,TRUE, $me, 7);
+ $c->add('whats_related_max',0,'text',1,7,NULL,1370,TRUE, $me, 7);
+ $c->add('whats_related_trim',26,'text',1,7,NULL,1380,TRUE, $me, 7);
// New Topic autotag permissions
$c->add('autotag_permissions_topic', array(2, 2, 2, 2), '@select', 7, 41, 28, 1890, TRUE, $me, 37);
diff -r 6c40e4d4a4ae -r a484d35ea8c3 sql/updates/mysql_2.0.0_to_2.0.1.php
--- a/sql/updates/mysql_2.0.0_to_2.0.1.php Fri Jun 14 14:34:40 2013 -0400
+++ b/sql/updates/mysql_2.0.0_to_2.0.1.php Mon Jun 17 21:14:17 2013 -0400
@@ -27,6 +27,11 @@
// Article Related Topics
$c->add('related_topics',1,'select',1,7,32,1340,TRUE, $me, 7);
$c->add('related_topics_max',6,'text',1,7,NULL,1350,TRUE, $me, 7);
+
+ // Article What's Related
+ $c->add('whats_related',1,'select',1,7,33,1360,TRUE, $me, 7);
+ $c->add('whats_related_max',0,'text',1,7,NULL,1370,TRUE, $me, 7);
+ $c->add('whats_related_trim',26,'text',1,7,NULL,1380,TRUE, $me, 7);
// New Topic autotag permissions
$c->add('autotag_permissions_topic', array(2, 2, 2, 2), '@select', 7, 41, 28, 1890, TRUE, $me, 37);
diff -r 6c40e4d4a4ae -r a484d35ea8c3 sql/updates/pgsql_2.0.0_to_2.0.1.php
--- a/sql/updates/pgsql_2.0.0_to_2.0.1.php Fri Jun 14 14:34:40 2013 -0400
+++ b/sql/updates/pgsql_2.0.0_to_2.0.1.php Mon Jun 17 21:14:17 2013 -0400
@@ -27,6 +27,11 @@
// Article Related Topics
$c->add('related_topics',1,'select',1,7,32,1340,TRUE, $me, 7);
$c->add('related_topics_max',6,'text',1,7,NULL,1350,TRUE, $me, 7);
+
+ // Article What's Related
+ $c->add('whats_related',1,'select',1,7,33,1360,TRUE, $me, 7);
+ $c->add('whats_related_max',0,'text',1,7,NULL,1370,TRUE, $me, 7);
+ $c->add('whats_related_trim',26,'text',1,7,NULL,1380,TRUE, $me, 7);
// New Topic autotag permissions
$c->add('autotag_permissions_topic', array(2, 2, 2, 2), '@select', 7, 41, 28, 1890, TRUE, $me, 37);
diff -r 6c40e4d4a4ae -r a484d35ea8c3 system/lib-plugins.php
--- a/system/lib-plugins.php Fri Jun 14 14:34:40 2013 -0400
+++ b/system/lib-plugins.php Mon Jun 17 21:14:17 2013 -0400
@@ -2805,7 +2805,13 @@
{
global $_PLUGINS;
- foreach ($_PLUGINS as $pi_name) {
+ // Treat articles like a plugin (since belong to core group)
+ require_once $_CONF['path_system'] . 'lib-story.php';
+
+ $plugintypes[] = 'article';
+ $plugintypes = array_merge($plugintypes, $_PLUGINS);
+
+ foreach ($plugintypes as $pi_name) {
$args = array();
$args[1] = $group;
diff -r 6c40e4d4a4ae -r a484d35ea8c3 system/lib-story.php
--- a/system/lib-story.php Fri Jun 14 14:34:40 2013 -0400
+++ b/system/lib-story.php Mon Jun 17 21:14:17 2013 -0400
@@ -562,7 +562,7 @@
* @return array an array of strings of form <a href="...">link</a>
*
*/
-function STORY_extractLinks( $fulltext, $maxlength = 26 )
+function STORY_extractLinks($fulltext, $maxlength = 26)
{
$rel = array();
@@ -598,54 +598,135 @@
*
* @param string $related contents of gl_stories 'related' field
* @param int $uid user id of the author
-* @param int $tid topic id
+* @param int $sid story id
* @return string HTML-formatted list of links
*/
-function STORY_whatsRelated( $related, $uid, $tid )
+function STORY_whatsRelated($related, $uid, $sid)
{
global $_CONF, $_TABLES, $LANG24;
- // get the links from the story text
- if (!empty ($related)) {
- $rel = explode ("\n", $related);
+ // Is it enabled?
+ // Disabled' => 0, 'Enabled' => 1, 'Enabled (No Links)' => 2, 'Enabled (No Outbound Links)' => 3
+ if ($_CONF['whats_related']) {
+ // get the links from the story text
+ if ($_CONF['whats_related'] != 2) {
+ if (!empty ($related)) {
+ $rel = explode ("\n", $related);
+ } else {
+ $rel = array ();
+ }
+
+ // Used to hunt out duplicates. Stores urls that have already passed filters
+ $urls = array();
+
+ foreach ($rel as $key => &$value) {
+ if (preg_match("/<a[^>]*href=[\"']([^\"']*)[\"'][^>]*>(.*?)<\/a>/i",
+ $value, $matches) === 1) {
+
+ // Go through array and remove links with no link text except link. Since a max of only 23 characters of link text showen then compare only this
+ if (substr($matches[1] , 0, 23) != substr($matches[2] , 0, 23)) {
+ // Check if outbound links (if needed)
+ $passd_check = false;
+ if ($_CONF['whats_related'] == 3) { // no outbound links
+ if ($_CONF['site_url'] == substr($matches[1] , 0, strlen($_CONF['site_url']))) {
+ $passd_check = true;
+ }
+ } else {
+ $passd_check = true;
+ }
+
+ if ($passd_check) {
+ // Go through array and remove any duplicates of this link
+ if (in_array($matches[1], $urls)) {
+ // remove it from the array
+ unset($rel[$key]);
+ } else {
+ $urls[] = $matches[1];
+ // Now Check Words
+ $value = '<a href="' . $matches[1] . '">'
+ . COM_checkWords($matches[2]) . '</a>';
+ }
+ } else {
+ // remove it from the array
+ unset($rel[$key]);
+ }
+ } else {
+ // remove it from the array
+ unset($rel[$key]);
+ }
+ } else {
+ $value = COM_checkWords($value);
+ }
+ }
+ }
+
+ $topics = array();
+ if (!COM_isAnonUser() || (( $_CONF['loginrequired'] == 0 ) &&
+ ( $_CONF['searchloginrequired'] == 0))) {
More information about the geeklog-cvs
mailing list