Commit d867c7cd authored by changi67's avatar changi67

no changes code styling - http://quality.tiki.org

parent 2bd73dba
......@@ -33,19 +33,19 @@ function upgrade_999999991_decode_pages_sources_tiki($installer)
$data = htmlspecialchars_decode($page['data']);
if ($data != $page['data']) {
$tikilib->update_page(
$page['pageName'],
$data,
'System upgrade: Converting special HTML characters',
'admin',
'0.0.0.0',
$page['description'],
1,
$page['lang'],
$page['is_html'],
null,
null,
'',
$page['wiki_authors_style']
$page['pageName'],
$data,
'System upgrade: Converting special HTML characters',
'admin',
'0.0.0.0',
$page['description'],
1,
$page['lang'],
$page['is_html'],
null,
null,
'',
$page['wiki_authors_style']
);
}
}
......
......@@ -10,23 +10,20 @@ require_once "SentenceAlignments.php";
class Multilingual_Aligner_MockMTWrapper extends Multilingual_Aligner_SentenceAlignments
{
public function getTranslationInOtherLanguage($source_lng_sentence, $source_lng) {
public function getTranslationInOtherLanguage($source_lng_sentence, $source_lng)
{
if ($source_lng=="en")
$k=1;
else if ($source_lng=="fr")
$k=0;
foreach ($this->alignment_table as $key=>$val)
{
if ($k==1)
{
foreach ($this->alignment_table as $key=>$val) {
if ($k==1) {
if ($key==$source_lng_sentence)
return $val;
}
else
{
} else {
if ($val==$source_lng_sentence)
return $key;
return $key;
}
}
......@@ -34,22 +31,19 @@ class Multilingual_Aligner_MockMTWrapper extends Multilingual_Aligner_SentenceAl
}
public function SetMT($source_file,$target_file,$source_lng,$target_lng)
{
$source_array=explode("<br/>",$source_file);
$target_array=explode("<br/>",$target_file);
{
$source_array=explode("<br/>", $source_file);
$target_array=explode("<br/>", $target_file);
for($i=0, $ct_a=count($target_array);$i<$ct_a;$i++)
{
for ($i=0, $ct_a=count($target_array);$i<$ct_a;$i++) {
$target_array[$i]=trim($target_array[$i]);
// $target_array[$i]=utf8_decode($target_array[$i]);
}
for($i=0, $cs_a=count($source_array);$i<$cs_a;$i++)
{
for ($i=0, $cs_a=count($source_array);$i<$cs_a;$i++) {
$source_array[$i]=trim($source_array[$i]);
}
for($i=0, $cs_a=count($source_array);$i<$cs_a;$i++)
{
$this->addSentencePair($source_array[$i],$source_lng,$target_array[$i],$target_lng);
for ($i=0, $cs_a=count($source_array);$i<$cs_a;$i++) {
$this->addSentencePair($source_array[$i], $source_lng, $target_array[$i], $target_lng);
}
}//function ends
}//function ends
}//class ends
......@@ -11,25 +11,29 @@ class Perms_Check_Alternate implements Perms_Check
private $resolver;
private $applicableCache = null;
function __construct( $permission ) {
function __construct( $permission )
{
$this->permission = $permission;
}
function check( Perms_Resolver $resolver, array $context, $name, array $groups ) {
function check( Perms_Resolver $resolver, array $context, $name, array $groups )
{
if ( $this->resolver ) {
return $this->resolver->check( $this->permission, $groups );
return $this->resolver->check($this->permission, $groups);
} else {
return false;
}
}
function setResolver( $resolver ) {
function setResolver( $resolver )
{
$this->resolver = $resolver;
$this->applicableCache = null;
}
function applicableGroups( Perms_Resolver $resolver ) {
if ( ! is_null( $this->applicableCache ) ) {
function applicableGroups( Perms_Resolver $resolver )
{
if ( ! is_null($this->applicableCache) ) {
return $this->applicableCache;
}
......@@ -39,7 +43,7 @@ class Perms_Check_Alternate implements Perms_Check
$groups = $this->resolver->applicableGroups();
foreach ( $groups as $group ) {
if ( $this->resolver->check( $this->permission, array($group) ) ) {
if ( $this->resolver->check($this->permission, array($group)) ) {
$this->applicableCache[] = $group;
}
}
......
......@@ -29,7 +29,8 @@ class Reports_Send
$this->mail = $mail;
}
public function sendEmail($userData, $reportPreferences, $reportCache) {
public function sendEmail($userData, $reportPreferences, $reportCache)
{
$mailData = $this->buildEmailBody($userData, $reportPreferences, $reportCache);
$this->mail->setUser($userData['login']);
......@@ -50,17 +51,23 @@ class Reports_Send
{
if (is_array($reportCache)) {
if (count($reportCache) == 1) {
$subject = tr('Report from %0 (1 change)',
TikiLib::date_format($this->tikiPrefs['short_date_format'], $this->dt->getTimestamp()));
$subject = tr(
'Report from %0 (1 change)',
TikiLib::date_format($this->tikiPrefs['short_date_format'], $this->dt->getTimestamp())
);
} else {
$subject = tr('Report from %0 (%1 changes)',
TikiLib::date_format($this->tikiPrefs['short_date_format'], $this->dt->getTimestamp()), count($reportCache));
$subject = tr(
'Report from %0 (%1 changes)',
TikiLib::date_format($this->tikiPrefs['short_date_format'], $this->dt->getTimestamp()), count($reportCache)
);
}
} else {
$subject = tr('Report from %0 (no changes)',
TikiLib::date_format($this->tikiPrefs['short_date_format'], $this->dt->getTimestamp()));
$subject = tr(
'Report from %0 (no changes)',
TikiLib::date_format($this->tikiPrefs['short_date_format'], $this->dt->getTimestamp())
);
}
$this->mail->setSubject($subject);
}
}
\ No newline at end of file
}
......@@ -16,14 +16,14 @@ class Search_Formatter_ValueFormatter_Categorylist implements Search_Formatter_V
{
if (isset($arguments['requiredParents'])) {
if (!empty($arguments['requiredParents'])) {
$this->requiredParents = explode(',',$arguments['requiredParents']);
$this->requiredParents = explode(',', $arguments['requiredParents']);
} else {
$this->requiredParents = 'all';
}
}
if (isset($arguments['excludeParents'])) {
$this->excludeParents = explode(',',$arguments['excludeParents']);
$this->excludeParents = explode(',', $arguments['excludeParents']);
}
if (isset($arguments['singleList'])) {
......@@ -48,14 +48,13 @@ class Search_Formatter_ValueFormatter_Categorylist implements Search_Formatter_V
if ($this->singleList == 'y') {
foreach ($value as $ar)
{
foreach ($value as $ar) {
if ($ar == 'orphan') {
break;
}
$p_info = $myArr[$ar];
if ( ($this->requiredParents=='all' || in_array( $p_info['parentId'], $this->requiredParents)) && !in_array( $p_info['parentId'], $this->excludeParents)) {
if ( ($this->requiredParents=='all' || in_array($p_info['parentId'], $this->requiredParents)) && !in_array($p_info['parentId'], $this->excludeParents)) {
$params = array('type' => 'category', 'id' => $ar);
$link = smarty_function_object_link($params, $smarty);
......@@ -72,22 +71,21 @@ class Search_Formatter_ValueFormatter_Categorylist implements Search_Formatter_V
}
if (!empty($this->separator)) {
$g = 0-strlen($this->separator);
$list = substr($list,0,$g);
$list = substr($list, 0, $g);
} else if (!empty($list)) {
$list .= "</ul>";
}
} else {
$parent = array();
foreach ($value as $ar)
{
foreach ($value as $ar) {
if ($ar == 'orphan') {
break;
}
$p_info = $myArr[$ar];
if ( ($this->requiredParents=='all' || in_array( $p_info['parentId'], $this->requiredParents)) && !in_array( $p_info['parentId'], $this->excludeParents)) {
if ( ($this->requiredParents=='all' || in_array($p_info['parentId'], $this->requiredParents)) && !in_array($p_info['parentId'], $this->excludeParents)) {
$parent[$p_info['parentId']][] = $ar;
}
}
......@@ -111,7 +109,7 @@ class Search_Formatter_ValueFormatter_Categorylist implements Search_Formatter_V
}
if (!empty($this->separator)) {
$g = 0-strlen($this->separator);
$list = substr($list,0,$g);
$list = substr($list, 0, $g);
$list .= "<br />";
}
}
......
......@@ -20,7 +20,7 @@ class TikiDb_Adodb extends TikiDb
function qstr( $str ) // {{{
{
return $this->db->quote( $str );
return $this->db->quote($str);
} // }}}
function query( $query = null, $values = null, $numrows = -1, $offset = -1, $reporterrors = true ) // {{{
......@@ -33,7 +33,7 @@ class TikiDb_Adodb extends TikiDb
if ( $query == null ) {
$query = $this->getQuery();
}
$this->convertQueryTablePrefixes( $query );
$this->convertQueryTablePrefixes($query);
$starttime=$this->startTimer();
if ($numrows == -1 && $offset == -1)
......@@ -44,16 +44,16 @@ class TikiDb_Adodb extends TikiDb
$this->stopTimer($starttime);
if (!$result ) {
$this->setErrorMessage( $this->db->ErrorMsg() );
$this->setErrorMessage($this->db->ErrorMsg());
if ($reporterrors) {
$this->handleQueryError( $query, $values, $result );
$this->handleQueryError($query, $values, $result);
}
}
global $num_queries;
$num_queries++;
$this->setQuery( null );
$this->setQuery(null);
return $result;
} // }}}
......
......@@ -77,7 +77,8 @@ class Tracker_field_Image extends Tracker_Field_File
);
}
function __construct($fieldInfo, $itemData, $trackerDefinition) {
function __construct($fieldInfo, $itemData, $trackerDefinition)
{
parent::__construct($fieldInfo, $itemData, $trackerDefinition);
$this->imgMimeTypes = array('image/jpeg', 'image/gif', 'image/png', 'image/pjpeg', 'image/bmp');
$this->imgMaxSize = (1048576 * 4); // 4Mo
......@@ -128,13 +129,13 @@ class Tracker_field_Image extends Tracker_Field_File
switch ($shadowtype) {
case 'item':
$rel = '['.$this->getItemId().']';
break;
break;
case 'individual':
$rel = '';
break;
break;
default:
$rel = '['.$this->getConfiguration('fieldId').']';
break;
break;
}
$pre = "<a href=\"$val\" rel=\"shadowbox$rel;type=img\">";
}
......@@ -143,13 +144,21 @@ class Tracker_field_Image extends Tracker_Field_File
}
if ($list_mode != 'n') {
if ($this->getOption(0) || $this->getOption(1)) {
list( $params['width'], $params['height']) = $this->get_resize_dimensions( $image_size_info[0], $image_size_info[1],
$this->getOption(0), $this->getOption(1));
list( $params['width'], $params['height']) = $this->get_resize_dimensions(
$image_size_info[0],
$image_size_info[1],
$this->getOption(0),
$this->getOption(1)
);
}
} else {
if ($this->getOption(2) || $this->getOption(3)) {
list( $params['width'], $params['height']) = $this->get_resize_dimensions( $image_size_info[0], $image_size_info[1],
$this->getOption(2), $this->getOption(3));
list( $params['width'], $params['height']) = $this->get_resize_dimensions(
$image_size_info[0],
$image_size_info[1],
$this->getOption(2),
$this->getOption(3)
);
}
}
} else {
......@@ -169,9 +178,13 @@ class Tracker_field_Image extends Tracker_Field_File
function renderInput($context = array())
{
return $this->renderTemplate('trackerinput/image.tpl', $context, array(
'image_tag' => $this->renderInnerOutput($context),
));
return $this->renderTemplate(
'trackerinput/image.tpl',
$context,
array(
'image_tag' => $this->renderInnerOutput($context),
)
);
}
function handleSave($value, $oldValue)
......
......@@ -7,7 +7,8 @@
class GeoLib
{
function get_coordinates($type, $itemId) {
function get_coordinates($type, $itemId)
{
$attributelib = TikiLib::lib('attribute');
$attributes = $attributelib->get_attributes($type, $itemId);
......@@ -26,13 +27,15 @@ class GeoLib
}
}
function get_coordinates_string($type, $itemId) {
function get_coordinates_string($type, $itemId)
{
if ($coords = $this->get_coordinates($type, $itemId)) {
return $this->build_location_string($coords);
}
}
function build_location_string($coords) {
function build_location_string($coords)
{
if (! empty($coords['lat']) && ! empty($coords['lon'])) {
$string = "{$coords['lon']},{$coords['lat']}";
......@@ -44,7 +47,8 @@ class GeoLib
}
}
function set_coordinates($type, $itemId, $coordinates) {
function set_coordinates($type, $itemId, $coordinates)
{
if (is_string($coordinates)) {
$coordinates = $this->parse_coordinates($coordinates);
}
......@@ -60,7 +64,8 @@ class GeoLib
}
}
function parse_coordinates($string) {
function parse_coordinates($string)
{
if (preg_match("/^(-?\d*(\.\d+)?),(-?\d*(\.\d+)?)(,(\d+))?$/", $string, $parts)) {
$coords = array(
'lat' => $parts[3],
......@@ -75,11 +80,16 @@ class GeoLib
}
}
function geocode($where) {
$url = 'http://maps.googleapis.com/maps/api/geocode/json?' . http_build_query(array(
'address' => $where,
'sensor' => 'false',
), '', '&');
function geocode($where)
{
$url = 'http://maps.googleapis.com/maps/api/geocode/json?' . http_build_query(
array(
'address' => $where,
'sensor' => 'false',
),
'',
'&'
);
$response = TikiLib::lib('tiki')->httprequest($url);
$data = json_decode($response);
......@@ -99,7 +109,8 @@ class GeoLib
);
}
function geofudge($geo) {
function geofudge($geo)
{
if (!$geo) {
return false;
}
......@@ -111,7 +122,8 @@ class GeoLib
return $geo;
}
function setTrackerGeo($itemId, $geo) {
function setTrackerGeo($itemId, $geo)
{
global $prefs, $trklib;
if (!is_object($trklib)) {
include_once('lib/trackers/trackerlib.php');
......
......@@ -14,7 +14,8 @@ if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) {
class HotwordsLib extends TikiLib
{
function list_hotwords($offset = 0, $maxRecords = -1, $sort_mode = 'word_desc', $find = '') {
function list_hotwords($offset = 0, $maxRecords = -1, $sort_mode = 'word_desc', $find = '')
{
if ($find) {
$findesc = '%' . $find . '%';
......@@ -27,8 +28,8 @@ class HotwordsLib extends TikiLib
$query = "select * from `tiki_hotwords` $mid order by ".$this->convertSortMode($sort_mode);
$query_cant = "select count(*) from `tiki_hotwords` $mid";
$result = $this->query($query,$bindvars,$maxRecords,$offset);
$cant = $this->getOne($query_cant,$bindvars);
$result = $this->query($query, $bindvars, $maxRecords, $offset);
$cant = $this->getOne($query_cant, $bindvars);
$ret = array();
while ($res = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
......@@ -41,20 +42,22 @@ class HotwordsLib extends TikiLib
return $retval;
}
function add_hotword($word, $url) {
function add_hotword($word, $url)
{
// $word = addslashes($word);
$url = addslashes($url);
$query = "delete from `tiki_hotwords` where `word`=?";
$result = $this->query($query,array($word));
$result = $this->query($query, array($word));
$query = "insert into `tiki_hotwords`(`word`,`url`) values(?,?)";
$result = $this->query($query,array($word,$url));
$result = $this->query($query, array($word,$url));
return true;
}
function remove_hotword($word) {
function remove_hotword($word)
{
$query = "delete from `tiki_hotwords` where `word`=?";
$result = $this->query($query,array($word));
$result = $this->query($query, array($word));
}
}
$hotwordlib = new HotwordsLib;
......@@ -21,29 +21,33 @@ class ScoreLib extends TikiLib
{
// User's general classification on site
function user_position($user) {
$score = $this->getOne("select `score` from `users_users` where `login`=?",array($user));
return $this->getOne("select count(*)+1 from `users_users` where `score` > ? and `login` <> ?",array((int)$score,'admin'));
function user_position($user)
{
$score = $this->getOne("select `score` from `users_users` where `login`=?", array($user));
return $this->getOne("select count(*)+1 from `users_users` where `score` > ? and `login` <> ?", array((int)$score,'admin'));
}
// User's score on site
// allows getting score of a single user
function get_user_score($user) {
$score = $this->getOne("select `score` from `users_users` where `login`=?",array($user));
function get_user_score($user)
{
$score = $this->getOne("select `score` from `users_users` where `login`=?", array($user));
return $score;
}
// Number of users that go on ranking
function count_users() {
return $this->getOne("select count(*) from `users_users` where `score`>0 and `login`<>'admin'",array());
function count_users()
{
return $this->getOne("select count(*) from `users_users` where `score`>0 and `login`<>'admin'", array());
}
// All event types, for administration
function get_all_events() {
function get_all_events()
{
global $prefs;
$query = "select * from `tiki_score`";
$result = $this->query($query,array());
$result = $this->query($query, array());
$index = array();
while ($res = $result->fetchRow()) {
$index[$res['event']] = $res;
......@@ -54,7 +58,7 @@ class ScoreLib extends TikiLib
$event_list = array();
foreach ($events as $event_data) {
$features = preg_split('/(\s|,)+/',$event_data[0]);
$features = preg_split('/(\s|,)+/', $event_data[0]);
$show = true;
foreach ($features as $feature) {
if (!empty($feature)) {
......@@ -86,13 +90,14 @@ class ScoreLib extends TikiLib
}
// Read information from admin and updates event's punctuation
function update_events($events) {
function update_events($events)
{
foreach ($events as $event_name => $event) {
$query = "delete from `tiki_score` where `event`=?";
$this->query($query, array($event_name));
$query = "insert into `tiki_score` (`event`,`score`,`expiration`) values (?,?,?)";
$this->query($query,array($event_name, (int) $event['score'], $event['expiration']));
$this->query($query, array($event_name, (int) $event['score'], $event['expiration']));
}
}
......
......@@ -14,7 +14,8 @@ if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) {
class TagLineLib extends TikiLib
{
function list_cookies($offset, $maxRecords, $sort_mode, $find) {
function list_cookies($offset, $maxRecords, $sort_mode, $find)
{
if ($find) {
$mid = " where (`cookie` like ?)";
$bindvars = array('%' . $find . '%');
......@@ -24,8 +25,8 @@ class TagLineLib extends TikiLib
}
$query = "select * from `tiki_cookies` $mid order by ".$this->convertSortMode($sort_mode);
$query_cant = "select count(*) from `tiki_cookies` $mid";
$result = $this->query($query,$bindvars,$maxRecords,$offset);
$cant = $this->getOne($query_cant,$bindvars);
$result = $this->query($query, $bindvars, $maxRecords, $offset);
$cant = $this->getOne($query_cant, $bindvars);
$ret = array();
while ($res = $result->fetchRow()) {
$ret[] = $res;
......@@ -36,7 +37,8 @@ class TagLineLib extends TikiLib
return $retval;
}
function replace_cookie($cookieId, $cookie) {
function replace_cookie($cookieId, $cookie)
{
// $cookie = addslashes($cookie);
// Check the name
if ($cookieId) {
......@@ -45,22 +47,24 @@ class TagLineLib extends TikiLib
} else {
$bindvars = array($cookie);
$query = "delete from `tiki_cookies` where `cookie`=?";
$result = $this->query($query,$bindvars);
$result = $this->query($query, $bindvars);
$query = "insert into `tiki_cookies`(`cookie`) values(?)";
}
$result = $this->query($query,$bindvars);
$result = $this->query($query, $bindvars);
return true;
}
function remove_cookie($cookieId) {
function remove_cookie($cookieId)
{
$query = "delete from `tiki_cookies` where `cookieId`=?";
$result = $this->query($query,array((int)$cookieId));
$result = $this->query($query, array((int)$cookieId));
return true;
}
function get_cookie($cookieId) {
function get_cookie($cookieId)
{
$query = "select * from `tiki_cookies` where `cookieId`=?";
$result = $this->query($query,array((int)$cookieId));
$result = $this->query($query, array((int)$cookieId));
if (!$result->numRows())
return false;
......@@ -68,9 +72,10 @@ class TagLineLib extends TikiLib
return $res;
}
function remove_all_cookies() {
function remove_all_cookies()
{
$query = "delete from `tiki_cookies`";
$result = $this->query($query,array());
$result = $this->query($query, array());
}
}
$taglinelib = new TagLineLib;
......@@ -33,7 +33,8 @@ abstract class TreeMaker
var $prefix;
/// Constructor
function __construct($prefix) {
function __construct($prefix)
{
$this->prefix = $prefix;
}
......@@ -42,12 +43,14 @@ abstract class TreeMaker
// * parent => Identifier of the node's parent
// * data => Node content (HTML)
/// Returns HTML code for tree
function make_tree($rootid, $ar) {
function make_tree($rootid, $ar)
{
return $this->make_tree_r($rootid, $ar);
}
/// Recursively make a tree
protected function make_tree_r($rootid, &$ar) {
protected function make_tree_r($rootid, &$ar)
{
global $debugger;
$debugger->msg("TreeMaker::make_tree_r: Root ID=" . $rootid);
......@@ -133,45 +136,54 @@ abstract class TreeMaker
* So to make smth other use inheritance and redefine
* corresponding function :)
*/
function indent($nodeinfo) {
function indent($nodeinfo)
{
return '';
}
function node_start_code($nodeinfo, $count=0) {
function node_start_code($nodeinfo, $count=0)
{
return '';
}
function node_start_code_flip($nodeinfo, $count=0) {
function node_start_code_flip($nodeinfo, $count=0)
{
return '';
}
//
function node_flipper_code($nodeinfo) {
function node_flipper_code($nodeinfo)
{
return '';
}
//
function node_data_start_code($nodeinfo) {
function node_data_start_code($nodeinfo)
{
return '';
}
//
function node_data_end_code($nodeinfo) {
function node_data_end_code($nodeinfo)
{
return '';
}
//
function node_child_start_code($nodeinfo) {
function node_child_start_code($nodeinfo)
{
return '';
}