From f359fd685f164855a34c85d164e0d38da12a2434 Mon Sep 17 00:00:00 2001
From: Christian Weiske
Date: Sat, 9 Oct 2010 12:09:39 +0200
Subject: make the page valid and keep chromium happy
---
src/SemanticScuttle/header.php | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
(limited to 'src/SemanticScuttle/header.php')
diff --git a/src/SemanticScuttle/header.php b/src/SemanticScuttle/header.php
index d1a5c29..3caeb35 100644
--- a/src/SemanticScuttle/header.php
+++ b/src/SemanticScuttle/header.php
@@ -120,7 +120,10 @@ $tplVars['userservice'] = $userservice;
if (!defined('UNIT_TEST_MODE')) {
//API files define that, so we need a way to support both of them
if (!isset($httpContentType)) {
- $httpContentType = 'text/html';
+ //$httpContentType = 'text/html';
+ //using that mime type makes all javascript nice in Chromium
+ // it also serves as test base if the pages really validate
+ $httpContentType = 'application/xhtml+xml';
}
if ($httpContentType !== false) {
header('Content-Type: ' . $httpContentType . '; charset=utf-8');
--
cgit v1.3-2-g0d8e
From efdcf11bb08e424cfbe140e167d8ece398ab74fa Mon Sep 17 00:00:00 2001
From: Christian Weiske
Date: Sat, 9 Oct 2010 13:09:46 +0200
Subject: activate strict xhtml mode only on debug mode
---
src/SemanticScuttle/header.php | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
(limited to 'src/SemanticScuttle/header.php')
diff --git a/src/SemanticScuttle/header.php b/src/SemanticScuttle/header.php
index 3caeb35..dc25581 100644
--- a/src/SemanticScuttle/header.php
+++ b/src/SemanticScuttle/header.php
@@ -120,10 +120,15 @@ $tplVars['userservice'] = $userservice;
if (!defined('UNIT_TEST_MODE')) {
//API files define that, so we need a way to support both of them
if (!isset($httpContentType)) {
- //$httpContentType = 'text/html';
- //using that mime type makes all javascript nice in Chromium
- // it also serves as test base if the pages really validate
- $httpContentType = 'application/xhtml+xml';
+ if (DEBUG_MODE) {
+ //using that mime type makes all javascript nice in Chromium
+ // it also serves as test base if the pages really validate
+ $httpContentType = 'application/xhtml+xml';
+ } else {
+ //until we are sure that all pages validate, we
+ // keep the non-strict mode on for normal installations
+ $httpContentType = 'text/html';
+ }
}
if ($httpContentType !== false) {
header('Content-Type: ' . $httpContentType . '; charset=utf-8');
--
cgit v1.3-2-g0d8e
From 82ada0d75f249733936a0826b115b20cba0657ab Mon Sep 17 00:00:00 2001
From: Christian Weiske
Date: Tue, 15 Mar 2011 19:13:14 +0100
Subject: Implement request #3054906: Show user's full name instead of nickname
---
.../bookmarkcommondescriptionedit.tpl.php | 3 +-
data/templates/bookmarks.tpl.php | 3 +-
data/templates/sidebar.block.users.php | 2 +-
data/templates/tagcommondescriptionedit.tpl.php | 3 +-
data/templates/users.tpl.php | 9 ++++-
doc/ChangeLog | 5 +--
src/SemanticScuttle/Model/UserArray.php | 41 ++++++++++++++++++++++
src/SemanticScuttle/Service/Bookmark.php | 3 +-
src/SemanticScuttle/header.php | 1 +
www/rss.php | 2 +-
10 files changed, 63 insertions(+), 9 deletions(-)
create mode 100644 src/SemanticScuttle/Model/UserArray.php
(limited to 'src/SemanticScuttle/header.php')
diff --git a/data/templates/bookmarkcommondescriptionedit.tpl.php b/data/templates/bookmarkcommondescriptionedit.tpl.php
index af5909a..807c58b 100644
--- a/data/templates/bookmarkcommondescriptionedit.tpl.php
+++ b/data/templates/bookmarkcommondescriptionedit.tpl.php
@@ -30,7 +30,8 @@ window.onload = function() {
if(strlen($description['cdDatetime'])>0) {
echo T_('Last modification:').' '.$description['cdDatetime'].', ';
$lastUser = $userservice->getUser($description['uId']);
- echo ''.$lastUser['username'].'';
+ echo ''
+ . SemanticScuttle_Model_UserArray::getName($lastUser) . '';
}
?>
diff --git a/data/templates/bookmarks.tpl.php b/data/templates/bookmarks.tpl.php
index e32d3c9..c404358 100644
--- a/data/templates/bookmarks.tpl.php
+++ b/data/templates/bookmarks.tpl.php
@@ -309,7 +309,8 @@ if ($currenttag!= '') {
$copy .= T_('you');
} else {
$copy .= ''
- . $row['username'] . '';
+ . SemanticScuttle_Model_UserArray::getName($row)
+ . '';
}
// Udders!
diff --git a/data/templates/sidebar.block.users.php b/data/templates/sidebar.block.users.php
index 3ad18bc..826871e 100644
--- a/data/templates/sidebar.block.users.php
+++ b/data/templates/sidebar.block.users.php
@@ -18,7 +18,7 @@ if ($lastUsers && count($lastUsers) > 0) {
foreach ($lastUsers as $row) {
echo '
| ';
echo '';
- echo $row['username'];
+ echo SemanticScuttle_Model_UserArray::getName($row);
echo '';
echo ' ('.T_('bookmarks').')';
echo ' |
';
diff --git a/data/templates/tagcommondescriptionedit.tpl.php b/data/templates/tagcommondescriptionedit.tpl.php
index d3a006a..f938f93 100644
--- a/data/templates/tagcommondescriptionedit.tpl.php
+++ b/data/templates/tagcommondescriptionedit.tpl.php
@@ -20,7 +20,8 @@ window.onload = function() {
if(strlen($description['cdDatetime'])>0) {
echo T_('Last modification:').' '.$description['cdDatetime'].', ';
$lastUser = $userservice->getUser($description['uId']);
- echo ''.$lastUser['username'].'';
+ echo ''
+ . SemanticScuttle_Model_UserArray::getName($lastUser) . '';
}
?>
diff --git a/data/templates/users.tpl.php b/data/templates/users.tpl.php
index c209f94..fa92bef 100644
--- a/data/templates/users.tpl.php
+++ b/data/templates/users.tpl.php
@@ -14,7 +14,14 @@ if ($users && count($users) > 0) {
'.$row['username'].' ('.T_('profile').' '.T_('created in').' '.date('M Y',strtotime($row['uDatetime'])).') : '.T_('bookmarks').'';
+ echo ''
+ . SemanticScuttle_Model_UserArray::getName($row) . ''
+ . ' ('
+ . T_('profile') . ' '
+ . T_('created in') . ' '
+ . date('M Y', strtotime($row['uDatetime'])) . ')'
+ . ' : '
+ . T_('bookmarks') . '';
}
?>
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 6144a81..4c93a9a 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -3,12 +3,13 @@ ChangeLog for SemantiScuttle
0.9X.X - 2010-XX-XX
-------------------
+- Fix bug #3187177: Wrong URL / Export XML Bookmarks
- Fix bug in getTagsForBookmarks() that fetched all tags
-- Show error message on mysqli connection errors
+- Implement request #3054906: Show user's full name instead of nickname
- Implement patch #3059829: update FR_CA translation
+- Show error message on mysqli connection errors
- Update php-gettext library to 1.0.10
- api/posts/add respects the "replace" parameter now
-- Fix bug #3187177: Wrong URL / Export XML Bookmarks
0.97.2 - 2011-02-17
diff --git a/src/SemanticScuttle/Model/UserArray.php b/src/SemanticScuttle/Model/UserArray.php
new file mode 100644
index 0000000..a0d9c9b
--- /dev/null
+++ b/src/SemanticScuttle/Model/UserArray.php
@@ -0,0 +1,41 @@
+
+ * @license GPL http://www.gnu.org/licenses/gpl.html
+ * @link http://sourceforge.net/projects/semanticscuttle
+ */
+
+/**
+ * Mostly static methods that help working with a user row array from database.
+ *
+ * @category Bookmarking
+ * @package SemanticScuttle
+ * @author Christian Weiske
+ * @license GPL http://www.gnu.org/licenses/gpl.html
+ * @link http://sourceforge.net/projects/semanticscuttle
+ */
+class SemanticScuttle_Model_UserArray
+{
+ /**
+ * Returns full user name as specified in the profile if it is set,
+ * otherwise the nickname/loginname is returned.
+ *
+ * @param array $row User row array from database
+ *
+ * @return string Full name or username
+ */
+ public static function getName($row)
+ {
+ if (isset($row['name']) && $row['name']) {
+ return $row['name'];
+ }
+ return $row['username'];
+ }
+}
+?>
\ No newline at end of file
diff --git a/src/SemanticScuttle/Service/Bookmark.php b/src/SemanticScuttle/Service/Bookmark.php
index 6f8a172..a30ad5f 100644
--- a/src/SemanticScuttle/Service/Bookmark.php
+++ b/src/SemanticScuttle/Service/Bookmark.php
@@ -734,7 +734,8 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
if (SQL_LAYER == 'mysql4') {
$query_1 .= 'SQL_CALC_FOUND_ROWS ';
}
- $query_1 .= 'B.*, U.'. $userservice->getFieldName('username');
+ $query_1 .= 'B.*, U.'. $userservice->getFieldName('username')
+ . ', U.name';
$query_2 = ' FROM '. $userservice->getTableName() .' AS U'
. ', '. $this->getTableName() .' AS B';
diff --git a/src/SemanticScuttle/header.php b/src/SemanticScuttle/header.php
index d1a5c29..4fecb8f 100644
--- a/src/SemanticScuttle/header.php
+++ b/src/SemanticScuttle/header.php
@@ -68,6 +68,7 @@ require_once 'SemanticScuttle/Service.php';
require_once 'SemanticScuttle/DbService.php';
require_once 'SemanticScuttle/Service/Factory.php';
require_once 'SemanticScuttle/functions.php';
+require_once 'SemanticScuttle/Model/UserArray.php';
if (count($GLOBALS['serviceoverrides']) > 0
&& !defined('UNIT_TEST_MODE')
diff --git a/www/rss.php b/www/rss.php
index 6dcfb4c..298d9ba 100644
--- a/www/rss.php
+++ b/www/rss.php
@@ -116,7 +116,7 @@ foreach ($bookmarks_tmp as $key => $row) {
'title' => $row['bTitle'],
'link' => $_link,
'description' => $row['bDescription'],
- 'creator' => $row['username'],
+ 'creator' => SemanticScuttle_Model_UserArray::getName($row),
'pubdate' => $_pubdate,
'tags' => $row['tags']
);
--
cgit v1.3-2-g0d8e
From 361c18469af5f6782e622420797c4acd5fa70b97 Mon Sep 17 00:00:00 2001
From: Christian Weiske
Date: Sat, 26 Mar 2011 15:09:22 +0100
Subject: add new feature: allow unit test mode enabling via HTTP GET parameter
---
data/config.default.php | 8 ++++++
src/SemanticScuttle/header.php | 16 ++++++++++-
tests/TestBase.php | 63 +++++++++++++++++++++++++++++++++++++++++-
3 files changed, 85 insertions(+), 2 deletions(-)
(limited to 'src/SemanticScuttle/header.php')
diff --git a/data/config.default.php b/data/config.default.php
index 3d60b91..af79891 100644
--- a/data/config.default.php
+++ b/data/config.default.php
@@ -735,4 +735,12 @@ $authEmailSuffix = null;
*/
$unittestUrl = null;
+/**
+ * Allow "unittestMode=1" in URLs.
+ * Should only be enabled on development systems
+ *
+ * @var boolean
+ */
+$allowUnittestMode = false;
+
?>
diff --git a/src/SemanticScuttle/header.php b/src/SemanticScuttle/header.php
index 9c5f7da..75e5204 100644
--- a/src/SemanticScuttle/header.php
+++ b/src/SemanticScuttle/header.php
@@ -39,6 +39,20 @@ set_include_path(
require_once $datadir . '/config.default.php';
require_once $datadir . '/config.php';
+if (isset($_GET['unittestMode']) && $_GET['unittestMode'] == 1
+) {
+ if ($allowUnittestMode !== true) {
+ header('HTTP/1.0 400 Bad Request');
+ die("Unittestmode is not allowed\n");
+ }
+
+ $unittestConfigFile = $datadir . '/config.unittest.php';
+ if (file_exists($unittestConfigFile)) {
+ require_once $unittestConfigFile;
+ }
+ define('HTTP_UNIT_TEST_MODE', true);
+ define('UNIT_TEST_MODE', true);
+}
if (defined('UNIT_TEST_MODE')) {
//make local config vars global - needed for unit tests
//run with phpunit
@@ -118,7 +132,7 @@ $tplVars['currentUser'] = $currentUser;
$tplVars['userservice'] = $userservice;
// 6 // Force UTF-8 behaviour for server (cannot be moved into top.inc.php which is not included into every file)
-if (!defined('UNIT_TEST_MODE')) {
+if (!defined('UNIT_TEST_MODE') || defined('HTTP_UNIT_TEST_MODE')) {
//API files define that, so we need a way to support both of them
if (!isset($httpContentType)) {
if (DEBUG_MODE) {
diff --git a/tests/TestBase.php b/tests/TestBase.php
index 3e2e213..b85c189 100644
--- a/tests/TestBase.php
+++ b/tests/TestBase.php
@@ -22,6 +22,18 @@
*/
class TestBase extends PHPUnit_Framework_TestCase
{
+ /**
+ * Clean up after test
+ */
+ public function tearDown()
+ {
+ if (file_exists($GLOBALS['datadir'] . '/config.unittest.php')) {
+ unlink($GLOBALS['datadir'] . '/config.unittest.php');
+ }
+ }
+
+
+
/**
* Create a new bookmark.
*
@@ -80,8 +92,25 @@ class TestBase extends PHPUnit_Framework_TestCase
* @param string $password Password
*
* @return integer ID of user
+ *
+ * @uses addUserData()
*/
protected function addUser($username = null, $password = null)
+ {
+ return reset($this->addUserData($username, $password));
+ }
+
+
+
+ /**
+ * Creates a new user in the database and returns id, username and password.
+ *
+ * @param string $username Username
+ * @param string $password Password
+ *
+ * @return array ID of user, Name of user, password of user
+ */
+ protected function addUserData($username = null, $password = null)
{
$us = SemanticScuttle_Service_Factory::get('User');
$rand = rand();
@@ -98,7 +127,7 @@ class TestBase extends PHPUnit_Framework_TestCase
$password,
'unittest-' . $rand . '@example.org'
);
- return $uid;
+ return array($uid, $username, $password);
}
@@ -129,6 +158,38 @@ class TestBase extends PHPUnit_Framework_TestCase
return $uid;
}
+
+
+ /**
+ * Writes a special unittest configuration file.
+ * The unittest config file is read when a GET request with unittestMode=1
+ * is sent, and the user allowed unittestmode in config.php.
+ *
+ * @param array $arConfig Array with config names as key and their value as
+ * value
+ *
+ * @return void
+ */
+ protected function setUnittestConfig($arConfig)
+ {
+ $str = '<' . "?php\r\n";
+ foreach ($arConfig as $name => $value) {
+ $str .= '$' . $name . ' = '
+ . var_export($value, true) . ";\n";
+ }
+
+ if (!is_dir($GLOBALS['datadir'])) {
+ $this->fail(
+ 'datadir not set or not a directory: ' . $GLOBALS['datadir']
+ );
+ }
+
+ $this->assertInternalType(
+ 'integer',
+ file_put_contents($GLOBALS['datadir'] . '/config.unittest.php', $str),
+ 'Writing config.unittest.php failed'
+ );
+ }
}
?>
\ No newline at end of file
--
cgit v1.3-2-g0d8e