Commit 80de0964 authored by changi67's avatar changi67

checkstyle - see http://quality.tiki.org

parent 2b6c82a0
<?php
// (c) Copyright 2002-2012 by authors of the Tiki Wiki CMS Groupware Project
//
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
......@@ -38,64 +38,64 @@ function activated_features()
$activated_features[] = 'blogs';
$activated_features[] = 'blogs_posts';
}
break;
break;
case 'comments':
$activated_features[] = 'comments';
break;
break;
case 'wiki':
if (isset($prefs['feature_wiki']) and $prefs['feature_wiki'] == 'y') {
$activated_features[] = 'pages';
}
break;
break;
case 'articles':
if (isset($prefs['feature_articles']) and $prefs['feature_articles'] == 'y') {
$activated_features[] = 'articles';
}
break;
break;
case 'faqs':
if (isset($prefs['feature_faqs']) and $prefs['feature_faqs'] == 'y') {
$activated_features[] = 'faqs';
$activated_features[] = 'faqs_questions';
}
break;
break;
case 'file_galleries':
if (isset($prefs['feature_file_galleries']) and $prefs['feature_file_galleries'] == 'y') {
$activated_features[] = 'file_galleries';
$activated_features[] = 'files';
}
break;
break;
case 'forums':
if (isset($prefs['feature_forums']) and $prefs['feature_forums'] == 'y') {
$activated_features[] = 'forums';
}
break;
break;
case 'galleries':
if (isset($prefs['feature_galleries']) and $prefs['feature_galleries'] == 'y') {
$activated_features[] = 'galleries';
$activated_features[] = 'images';
}
break;
break;
case 'trackers':
if (isset($prefs['feature_trackers']) and $prefs['feature_trackers'] == 'y') {
$activated_features[] = 'trackers';
$activated_features[] = 'tracker_items';
}
break;
break;
case 'directory':
if (isset($prefs['feature_directory']) and $prefs['feature_directory'] == 'y') {
$activated_features[] = 'directory_categories';
$activated_features[] = 'directory_sites';
}
break;
break;
}
}
return $activated_features;
......
<?php
// (c) Copyright 2002-2012 by authors of the Tiki Wiki CMS Groupware Project
//
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
/*
/*
* Simple script to convert html anchors in smarty templates to self_links for ajax (tiki 6)
* couldn't work out a clever enough regexp so trying in php
*
* ***** INSTRUCTIONS ******
*
*
* Move into root of your tiki and open in a browser
* e.g. http://localhost/trunk/convert_tpl_ajax.php
*
*
* Select a tpl from the drop down and check the "Show replacements" checkbox
* Copy the resulting source into your favourite text editor and
* compare with the original (and test lots, obviously) before committing
*
*
* ***** N.B. 2: {if} statements inside anchor attributes ******
* ***** will be commented out for later manual correction ******
*
*
* ***** N.B. 3: Nested quote marks in Smarty syntax ******
* I found one tpl (tiki-pagehistory.tpl) that had links with nested quotes in the hrefs (ik!)
* e.g. <a href="tiki-rollback.php?page={$page|escape:"url"}&amp;version={$preview}" title="{tr}Rollback{/tr}">{tr}Rollback to this version{/tr}</a>
......@@ -50,10 +50,10 @@ function replace_with_self_links($original, $template_base)
for ($j = 0; $j < $count_r; $j++) {
$ahref = $phplinks[0][$j];
preg_match_all('/([^=\s]*?)="([^"]*?)"/i', $ahref, $attrs);
$str = '{self_link ';
for ($i = 0, $icount_attrs = count($attrs[1]); $i < $icount_attrs; $i++) {
if (strtolower($attrs[1][$i]) == 'href') {
$query = parse_url(urldecode(str_replace('&amp;', '&', $attrs[2][$i])));
if ($query['path'] != $template_base . '.php') {
......@@ -69,9 +69,9 @@ function replace_with_self_links($original, $template_base)
$str .= '_' . $attrs[1][$i] . '=' . process_value($attrs[2][$i]) . ' ';
}
}
$str = trim($str) . '}' . $phplinks[1][$j] . '{/self_link}';
$str = trim($str) . '}' . $phplinks[1][$j] . '{/self_link}';
$replacements[] = $str;
}
$replaced = str_replace($phplinks[0], $replacements, $original);
return $replaced;
......@@ -87,9 +87,9 @@ function process_value ($var)
}
// comment out if's inside attributes for manual processing
$var = preg_replace(
array('/\{if\s([^\}]*)\}/i', '/\{else\}/i', '/\{\/if\}/i', '/\{elseif\s([^\}]*)\}/i'),
array('{*if $1*}', '{*else*}', '{*/if*}', '/{*elseif $1*}/'),
$var
array('/\{if\s([^\}]*)\}/i', '/\{else\}/i', '/\{\/if\}/i', '/\{elseif\s([^\}]*)\}/i'),
array('{*if $1*}', '{*else*}', '{*/if*}', '/{*elseif $1*}/'),
$var
);
$var = "$q" . $var . "$q";
return $var;
......@@ -116,16 +116,17 @@ $tpl_sel .= '</select>';
// cheating - lazy ;)
$form = str_replace(
"\n",
'',
"<form action='#'>
"\n",
'',
"<form action='#'>
<label for='toggle'>" . (empty($_REQUEST['toggle']) ? 'Show replacements' : "Showing $count_r replacements") . ":</label>
<input type='checkbox' id='toggle' name='toggle' onclick='this.form.submit();'$checked />
$tpl_sel
</form>"
);
$headerlib->add_jq_onready(<<<JS
$headerlib->add_jq_onready(
<<<JS
\$('#page-bar, .navbar, .titletips, h2').hide();
\$('a.pagetitle').text('$tpl (tpl)').parent().after(
\$("$form")
......
<?php
// (c) Copyright 2002-2012 by authors of the Tiki Wiki CMS Groupware Project
//
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
......@@ -140,9 +140,9 @@ $nbCommiters = 0;
if (! $options['no-copyright-update'] && important_step("Update '" . COPYRIGHTS_FILENAME . "' file (using final version number '$version')")) {
if ($ucf = update_copyright_file($mainversion . '.0')) {
info(
"\r>> Copyrights updated: "
. ($ucf['newContributors'] == 0 ? 'No new contributor, ' : "+{$ucf['newContributors']} contributor(s), ")
. ($ucf['newCommits'] == 0 ? 'No new commit' : "+{$ucf['newCommits']} commit(s)")
"\r>> Copyrights updated: "
. ($ucf['newContributors'] == 0 ? 'No new contributor, ' : "+{$ucf['newContributors']} contributor(s), ")
. ($ucf['newCommits'] == 0 ? 'No new commit' : "+{$ucf['newCommits']} commit(s)")
);
important_step("Commit new " . COPYRIGHTS_FILENAME, true, "[REL] Update " . COPYRIGHTS_FILENAME . " for $secdbVersion");
} else error('Copyrights update failed.');
......@@ -246,11 +246,11 @@ function md5_check_dir($root, $dir, $version, &$queries)
) {
global $phpCommand, $phpCommandArguments;
error(
"SecDB step failed because some filenames need escaping but no MySQL connection has been found."
. "\nTry this command line instead (replace HOST, USER and PASS by a valid MySQL host, user and password) :"
. "\n\n\t" . $phpCommand
. " -d mysql.default_host=HOST -d mysql.default_user=USER -d mysql.default_password=PASS "
. $phpCommandArguments . "\n"
"SecDB step failed because some filenames need escaping but no MySQL connection has been found."
. "\nTry this command line instead (replace HOST, USER and PASS by a valid MySQL host, user and password) :"
. "\n\n\t" . $phpCommand
. " -d mysql.default_host=HOST -d mysql.default_user=USER -d mysql.default_password=PASS "
. $phpCommandArguments . "\n"
);
}
......@@ -273,7 +273,7 @@ function build_packages($releaseVersion, $svnRelativePath)
$debugflag = '';
}
$cmd = "/bin/sh ".$debugflag." ".$script." ".$releaseVersion." ".$svnRelativePath;
info("Running $cmd:\n");
info("Running $cmd:\n");
`$cmd`;
info(">> Packages files have been built in ~/tikipack/$releaseVersion :\n");
passthru("ls ~/tikipack/$releaseVersion");
......@@ -380,15 +380,15 @@ function check_smarty_syntax2(&$error_msg)
// }
/* This is most odd (jonnyb aug 2010 tiki 5.1)
*
*
* There is an "error" in tiki-mods.tpl that causes an error that the existing code (pre r28273) couldn't trap
* I added an Exception which works fine in the debugger but dies in the commend line (unless you supply all
* the "skip" params --no-check-php --no-check-php-warnings etc), when it works as expected.
*
*
* Nasty fix now by not checking that file
* Better fix (or TODO KIL mods) required so leaving commented code behond - excuse the mess ;)
*/
if (! empty($compilation_output)) {
$error_msg = "\nError while compiling {$entries[$i]}."
. "\nThis may happen if one of the tiki smarty plugins (located in lib/smarty_tiki)"
......@@ -499,12 +499,12 @@ function get_options()
} elseif (substr($arg, 2, 11) == 'http-proxy=') {
if (($proxy = substr($arg, 13)) != '') {
$options[substr($arg, 2, 10)] = stream_context_create(
array(
'http' => array(
'proxy' => 'tcp://' . $proxy,
'request_fulluri' => true
)
)
array(
'http' => array(
'proxy' => 'tcp://' . $proxy,
'request_fulluri' => true
)
)
);
} else $options[substr($arg, 2, 10)] = true;
} elseif (substr($arg, 2, 15) == 'svn-mirror-uri=') {
......@@ -565,14 +565,14 @@ function important_step($msg, $increment_step = true, $commit_msg = false)
switch (strtolower($c)) {
case 'y': case '':
$do_step = true;
break;
break;
case 'n':
info(">> Skipping step $step.");
$do_step = false;
break;
break;
case 'q':
die;
break;
break;
default:
if ($c != '?') info(color(">> Unknown answer '$c'.", 'red'));
info(">> You have to type 'y' (Yes), 'n' (No) or 'q' (Quit) and press Enter.");
......@@ -591,7 +591,7 @@ function update_changelog_file($newVersion)
{
if (! is_readable(CHANGELOG) || ! is_writable(CHANGELOG) || ! ($handle = @fopen(CHANGELOG, "r")))
error('The changelog file "' . CHANGELOG . '" is not readable or writable.');
$isNewMajorVersion = substr($newVersion, -1) == 0;
$releaseNotesURL = '<http://tiki.org/ReleaseNotes'.str_replace('.', '', $newVersion).'>';
$parseLogs = $sameFinalVersion = $skipBuffer = false;
......@@ -601,12 +601,12 @@ function update_changelog_file($newVersion)
$versionMatches = array();
$newChangelog = '';
$newChangelogEnd = '';
if ($handle) {
while (! feof($handle)) {
$buffer = fgets($handle);
if (empty($buffer)) continue;
if (preg_match('/^Version (\d+)\.(\d+)/', $buffer, $versionMatches)) {
if ($versionMatches[1].'.'.$versionMatches[2] == $newVersion) {
// The changelog file already contains log for the same final version
......@@ -703,8 +703,8 @@ Tiki Copyright
The following list attempts to gather the copyright holders for Tiki
as of version $newVersion.
Accounts listed below with commits have contributed source code to CVS or SVN.
Please note that even more people contributed on various other aspects (documentation,
Accounts listed below with commits have contributed source code to CVS or SVN.
Please note that even more people contributed on various other aspects (documentation,
bug reporting, testing, etc.)
This is how we implement the Tiki Social Contract.
......@@ -720,8 +720,8 @@ from subversion repository by the following script:
doc/devtools/release.php
Counting the commits is not as trivial as it may sound. If your number of commits
seems incorrect, it could be that the script is not detecting them all. This
has been reported especially for commits early on in the project. Nonetheless,
seems incorrect, it could be that the script is not detecting them all. This
has been reported especially for commits early on in the project. Nonetheless,
the list provides a general idea.
====================================================================
......@@ -794,10 +794,10 @@ function get_contributors_data($path, &$contributors, $minRevision, $maxRevision
echo "\rRetrieving logs from revision $minByStep to $maxRevision ...\t\t\t";
$logs = get_logs($path, $minByStep, $maxRevision);
if (preg_match_all('/^r(\d+) \|\s([^\|]+)\s\|\s(\d+-\d+-\d+)\s.*\n\n(.*)\-+\n/Ums', $logs, $matches, PREG_SET_ORDER)) {
foreach ($matches as $logEntry)
foreach ($matches as $logEntry)
$mycommits[$logEntry[1]] = array($logEntry[2],$logEntry[3]);
krsort($mycommits);
foreach ($mycommits as $commitnum => $commitinfo) {
if ($lastLogRevision > 0 && $commitnum != $lastLogRevision - 1 && $lastLogRevision != $maxRevision) {
print "\nProblem with commit " . ($lastLogRevision - 1) . "\n (trying {$commitnum} after $lastLogRevision)";
......@@ -824,10 +824,10 @@ function get_contributors_data($path, &$contributors, $minRevision, $maxRevision
}
}
}
if ($lastLogRevision > $minRevision)
get_contributors_data($path, $contributors, $minRevision, $lastLogRevision - 1, $step);
return $contributors;
}
......
<?php
// (c) Copyright 2002-2012 by authors of the Tiki Wiki CMS Groupware Project
//
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
......@@ -15,10 +15,10 @@ function upgrade_20100927_better_column_fix_tiki($installer)
global $dbs_tiki;
$result = $installer->getOne(
"SELECT COUNT(*) FROM information_schema.COLUMNS" .
" WHERE COLUMN_NAME='show_lastDownload' AND TABLE_NAME='tiki_file_galleries' AND TABLE_SCHEMA='" .
$dbs_tiki .
"';"
"SELECT COUNT(*) FROM information_schema.COLUMNS" .
" WHERE COLUMN_NAME='show_lastDownload' AND TABLE_NAME='tiki_file_galleries' AND TABLE_SCHEMA='" .
$dbs_tiki .
"';"
);
if ($result == 0) {
......@@ -26,9 +26,9 @@ function upgrade_20100927_better_column_fix_tiki($installer)
}
$result = $installer->getOne(
"SELECT COUNT(*) FROM information_schema.COLUMNS" .
" WHERE COLUMN_NAME='tweetId' AND TABLE_NAME='tiki_shoutbox' AND TABLE_SCHEMA='" .
$dbs_tiki."';"
"SELECT COUNT(*) FROM information_schema.COLUMNS" .
" WHERE COLUMN_NAME='tweetId' AND TABLE_NAME='tiki_shoutbox' AND TABLE_SCHEMA='" .
$dbs_tiki."';"
);
if ($result == 0) {
......
<?php
// (c) Copyright 2002-2012 by authors of the Tiki Wiki CMS Groupware Project
//
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
......@@ -17,45 +17,45 @@ function pre_20110727_tracker_multilingual_convert_tiki($installer)
$fields = $installer->table('tiki_tracker_fields');
$multilingualFields = $fields->fetchColumn(
'fieldId',
array(
'isMultilingual' => 'y',
'type' => $fields->in(array('t', 'a')),
)
'fieldId',
array(
'isMultilingual' => 'y',
'type' => $fields->in(array('t', 'a')),
)
);
$unilingualFields = $fields->fetchColumn(
'fieldId',
array(
'isMultilingual' => $fields->not('y'),
'type' => $fields->in(array('t', 'a')),
)
'fieldId',
array(
'isMultilingual' => $fields->not('y'),
'type' => $fields->in(array('t', 'a')),
)
);
$table = $installer->table('tiki_tracker_item_fields');
// Clean up data that does not match the field definition
$table->deleteMultiple(
array(
'fieldId' => $table->in($multilingualFields),
'lang' => '',
)
array(
'fieldId' => $table->in($multilingualFields),
'lang' => '',
)
);
$table->deleteMultiple(
array(
'fieldId' => $table->in($unilingualFields),
'lang' => $table->not(''),
)
array(
'fieldId' => $table->in($unilingualFields),
'lang' => $table->not(''),
)
);
// Collect the data stored in the multilingual fields
$result = $table->fetchAll(
$table->all(),
array(
'lang' => $table->not(''),
'fieldId' => $table->in($multilingualFields),
)
$table->all(),
array(
'lang' => $table->not(''),
'fieldId' => $table->in($multilingualFields),
)
);
$multilingual_tracker_content = array();
......@@ -72,10 +72,10 @@ function pre_20110727_tracker_multilingual_convert_tiki($installer)
foreach ($multilingual_tracker_content as $itemId => $fields) {
foreach ($fields as $fieldId => $data) {
$table->deleteMultiple(
array(
'itemId' => $itemId,
'fieldId' => $fieldId,
)
array(
'itemId' => $itemId,
'fieldId' => $fieldId,
)
);
}
}
......@@ -108,11 +108,11 @@ function post_20110727_tracker_multilingual_convert_tiki($installer)
foreach ($multilingual_tracker_content as $itemId => $fields) {
foreach ($fields as $fieldId => $data) {
$table->insert(
array(
'itemId' => $itemId,
'fieldId' => $fieldId,
'value' => json_encode($data),
)
array(
'itemId' => $itemId,
'fieldId' => $fieldId,
'value' => json_encode($data),
)
);
}
}
......@@ -122,12 +122,12 @@ function post_20110727_tracker_multilingual_convert_tiki($installer)
foreach ($versions as $version => $fields) {
foreach ($fields as $fieldId => $data) {
$table->insert(
array(
'version' => $version,
'itemId' => $itemId,
'fieldId' => $fieldId,
'value' => json_encode($data),
)
array(
'version' => $version,
'itemId' => $itemId,
'fieldId' => $fieldId,
'value' => json_encode($data),
)
);
}
}
......
<?php
// (c) Copyright 2002-2012 by authors of the Tiki Wiki CMS Groupware Project
//
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
/**
* AttributeLib
*
* AttributeLib
*
* @uses TikiDb_Bridge
*/
class AttributeLib extends TikiDb_Bridge
......@@ -22,20 +22,20 @@ class AttributeLib extends TikiDb_Bridge
function get_attributes( $type, $objectId )
{
return $this->attributes->fetchMap(
'attribute',
'value',
array('type' => $type,'itemId' => $objectId,)
'attribute',
'value',
array('type' => $type,'itemId' => $objectId,)
);
}
/**
* The attribute must contain at least two dots and only lowercase letters.
*/
/**
* NAMESPACE management and attribute naming.
* Please see http://dev.tiki.org/Object+Attributes+and+Relations for guidelines on
* attribute naming, and document new tiki.*.* names that you add
* Please see http://dev.tiki.org/Object+Attributes+and+Relations for guidelines on
* attribute naming, and document new tiki.*.* names that you add
* (also grep "set_attribute" just in case there are undocumented names already used)
*/
function set_attribute( $type, $objectId, $attribute, $value )
......@@ -46,20 +46,20 @@ class AttributeLib extends TikiDb_Bridge
if ( $value == '' ) {
$this->attributes->delete(
array(
'type' => $type,
'itemId' => $objectId,
'attribute' => $name,
)
array(
'type' => $type,
'itemId' => $objectId,
'attribute' => $name,
)
);
} else {
$this->attributes->insertOrUpdate(
array('value' => $value),
array(
'type' => $type,
'itemId' => $objectId,
'attribute' => $name,
)
array('value' => $value),
array(
'type' => $type,
'itemId' => $objectId,
'attribute' => $name,
)
);
}
......@@ -77,8 +77,8 @@ class AttributeLib extends TikiDb_Bridge
$attribute = $this->get_valid($attribute);
return $this->attributes->fetchAll(
array('type', 'itemId'),
array('attribute' => $attribute, 'value' => $value,)
array('type', 'itemId'),
array('attribute' => $attribute, 'value' => $value,)
);
}
}
......
<?php
// (c) Copyright 2002-2012 by authors of the Tiki Wiki CMS Groupware Project
//
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
......@@ -40,10 +40,10 @@ class BannerLib extends TikiLib
$mid .= implode('or', $mids).')';
}
$query = "select `bannerId` from `tiki_banners` where `$dw` = ? and `hourFrom`<=? and `hourTo`>=? and" .
$query = "select `bannerId` from `tiki_banners` where `$dw` = ? and `hourFrom`<=? and `hourTo`>=? and" .
" ( ((`useDates` = ?) and (`fromDate`<=? and `toDate`>=?)) or (`useDates` = ?) ) and" .
" (`impressions`<`maxImpressions` or `maxImpressions`=?) and" .
" (`clicks`<`maxClicks` or `maxClicks`=? or `maxClicks` is NULL)" .
" (`clicks`<`maxClicks` or `maxClicks`=? or `maxClicks` is NULL)" .
" and `zone`=? $mid and (`exceptInURIs` not like ? or `exceptInURIs` IS NULL)";
$bindvars[] = '%#'.$_SERVER['REQUEST_URI'].'#%';
......@@ -93,24 +93,24 @@ class BannerLib extends TikiLib
case 'useHTML':
$raw = $res["HTMLData"];
break;
break;
case 'useFlash':
if ($prefs['javascript_enabled'] == 'y') {
global $headerlib; include_once('lib/headerlib.php');
$headerlib->add_jsfile('lib/swfobject/swfobject.js');
}
$raw = $tikilib->embed_flash(unserialize($res['HTMLData']));
break;
break;
case 'useImage':
$raw
= "<div class='banner $class'><a target='$target' href='banner_click.php?id="
= "<div class='banner $class'><a target='$target' href='banner_click.php?id="
. $res["bannerId"] . "&amp;url=" . urlencode($res["url"])
. "'><img alt='banner' border='0' src=\"banner_image.php?id="
. "'><img alt='banner' border='0' src=\"banner_image.php?id="
. $res["bannerId"] . "\" /></a></div>";
break;
break;
case 'useFixedURL':
@$fp = fopen($res["fixedURLData"], "r");
......@@ -124,14 +124,14 @@ class BannerLib extends TikiLib
fclose($fp);
}
break;
break;
case 'useText':
$raw = "<a target='$target' class='bannertext' href='banner_click.php?id=" . $res["bannerId"]
. "&amp;url=" . urlencode($res["url"]) . "'>"
$raw = "<a target='$target' class='bannertext' href='banner_click.php?id=" . $res["bannerId"]
. "&amp;url=" . urlencode($res["url"]) . "'>"
. $res["textData"] . "</a>";
break;
break;
}
// Increment banner impressions done in select_banner_id()
......@@ -140,10 +140,10 @@ class BannerLib extends TikiLib
$views = array();
if (isset($_COOKIE[$cookieName])) {
$views = TikiLib::tiki_unserialize($_COOKIE[$cookieName]);
}
}
if ($res['maxUserImpressions'] > 0) {
$views[$res['bannerId']] = isset($views[$res['bannerId']]) ? $views[$res['bannerId']]+1: 1;
$expire = $res['useDates']? $res['toDate']: $tikilib->now+60*60*24*90; //90 days
$expire = $res['useDates']? $res['toDate']: $tikilib->now+60*60*24*90; //90 days
setcookie($cookieName, serialize($views), $expire);
}
......@@ -195,7 +195,7 @@ class BannerLib extends TikiLib
return $retval;
}
function list_zones()
function list_zones()
{
$query = "select `zone` from `tiki_zones`";
......@@ -235,37 +235,37 @@ class BannerLib extends TikiLib
}
function replace_banner(
$bannerId,
$client,
$url,
$title = '',
$alt = '',
$use,
$imageData,
$imageType,
$imageName,
$bannerId,
$client,
$url,
$title = '',
$alt = '',