Coding Standard Cleanup

Ignore-this: 259cb5773c3144c6c706d87298dcf674

darcs-hash:20091020212338-7ad00-6bf1c5c403491f136a1c02af5ecd9f84d7227107.gz
This commit is contained in:
Andreas Gohr 2009-10-20 23:23:38 +02:00
parent 8ec3f7bdbf
commit db959ae307
20 changed files with 4318 additions and 4294 deletions

View File

@ -229,7 +229,6 @@ function rss_buildItems(&$rss,&$data,$opt){
}
$item->description = $content; //FIXME a plugin hook here could be senseful
// add user
# FIXME should the user be pulled from metadata as well?
$user = null;

View File

@ -727,7 +727,6 @@ function updateprofile() {
if ($_POST['email'] != $INFO['userinfo']['mail'] && $auth->canDo('modMail')) $changes['mail'] = $_POST['email'];
if (!empty($_POST['newpass']) && $auth->canDo('modPass')) $changes['pass'] = $_POST['newpass'];
if (!count($changes)) {
msg($lang['profnochange'], -1);
return false;
@ -896,8 +895,12 @@ function auth_cryptPassword($clear,$method='',$salt=null){
$len = strlen($clear);
$text = $clear.'$'.$magic.'$'.$salt;
$bin = pack("H32", md5($clear.$salt.$clear));
for($i = $len; $i > 0; $i -= 16) { $text .= substr($bin, 0, min(16, $i)); }
for($i = $len; $i > 0; $i >>= 1) { $text .= ($i & 1) ? chr(0) : $clear{0}; }
for($i = $len; $i > 0; $i -= 16) {
$text .= substr($bin, 0, min(16, $i));
}
for($i = $len; $i > 0; $i >>= 1) {
$text .= ($i & 1) ? chr(0) : $clear{0};
}
$bin = pack("H32", md5($text));
for($i = 0; $i < 1000; $i++) {
$new = ($i & 1) ? $clear : $bin;

View File

@ -16,8 +16,8 @@ require_once(DOKU_INC.'inc/form.php');
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function html_wikilink($id,$name=NULL,$search=''){
static $xhtml_renderer = NULL;
function html_wikilink($id,$name=null,$search=''){
static $xhtml_renderer = null;
if(is_null($xhtml_renderer)){
$xhtml_renderer = p_get_renderer('xhtml');
}
@ -348,7 +348,7 @@ function html_search(){
$num = 1;
foreach($data as $id => $cnt){
print '<div class="search_result">';
print html_wikilink(':'.$id,useHeading('navigation')?NULL:$id,$regex);
print html_wikilink(':'.$id,useHeading('navigation')?null:$id,$regex);
if($cnt !== 0){
print ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />';
if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ?
@ -625,7 +625,7 @@ function html_recent($first=0){
)));
$form->addElement(form_makeCloseTag('a'));
$form->addElement(html_wikilink(':'.$recent['id'],useHeading('navigation')?NULL:$recent['id']));
$form->addElement(html_wikilink(':'.$recent['id'],useHeading('navigation')?null:$recent['id']));
$form->addElement(form_makeOpenTag('span', array('class' => 'sum')));
$form->addElement(' &ndash; '.htmlspecialchars($recent['sum']));
@ -836,7 +836,7 @@ function html_backlinks(){
print '<ul class="idx">';
foreach($data as $blink){
print '<li><div class="li">';
print html_wikilink(':'.$blink,useHeading('navigation')?NULL:$blink);
print html_wikilink(':'.$blink,useHeading('navigation')?null:$blink);
print '</div></li>';
}
print '</ul>';
@ -912,14 +912,16 @@ function html_diff($text='',$intro=true){
}
$r_text = rawWiki($ID,$r_rev);
if(!$l_rev){
$l_head = '&mdash;';
}else{
$l_info = getRevisionInfo($ID,$l_rev,true);
if($l_info['user']){ $l_user = editorinfo($l_info['user']);
if($l_info['user']){
$l_user = editorinfo($l_info['user']);
if(auth_ismanager()) $l_user .= ' ('.$l_info['ip'].')';
} else { $l_user = $l_info['ip']; }
} else {
$l_user = $l_info['ip'];
}
$l_user = '<span class="user">'.$l_user.'</span>';
$l_sum = ($l_info['sum']) ? '<span class="sum">'.hsc($l_info['sum']).'</span>' : '';
if ($l_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $l_minor = 'class="minor"';
@ -931,9 +933,12 @@ function html_diff($text='',$intro=true){
if($r_rev){
$r_info = getRevisionInfo($ID,$r_rev,true);
if($r_info['user']){ $r_user = editorinfo($r_info['user']);
if($r_info['user']){
$r_user = editorinfo($r_info['user']);
if(auth_ismanager()) $r_user .= ' ('.$r_info['ip'].')';
} else { $r_user = $r_info['ip']; }
} else {
$r_user = $r_info['ip'];
}
$r_user = '<span class="user">'.$r_user.'</span>';
$r_sum = ($r_info['sum']) ? '<span class="sum">'.hsc($r_info['sum']).'</span>' : '';
if ($r_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $r_minor = 'class="minor"';
@ -943,9 +948,12 @@ function html_diff($text='',$intro=true){
'<br />'.$r_user.' '.$r_sum;
}elseif($_rev = @filemtime(wikiFN($ID))){
$_info = getRevisionInfo($ID,$_rev,true);
if($_info['user']){ $_user = editorinfo($_info['user']);
if($_info['user']){
$_user = editorinfo($_info['user']);
if(auth_ismanager()) $_user .= ' ('.$_info['ip'].')';
} else { $_user = $_info['ip']; }
} else {
$_user = $_info['ip'];
}
$_user = '<span class="user">'.$_user.'</span>';
$_sum = ($_info['sum']) ? '<span class="sum">'.hsc($_info['sum']).'</span>' : '';
if ($_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $r_minor = 'class="minor"';
@ -1167,8 +1175,6 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed?
print p_locale_xhtml('read');
}
if(!$DATE) $DATE = $INFO['lastmod'];
?>
<div style="width:99%;">
@ -1183,10 +1189,8 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed?
textChanged = <?php ($mod) ? print 'true' : print 'false' ?>;
//--><!]]></script>
<span id="spell__action"></span>
<div id="spell__suggest"></div>
<?php } ?>
</div>
<div id="spell__result"></div>
<?php
$form = new Doku_Form('dw__editform');
$form->addHidden('id', $ID);
@ -1346,7 +1350,7 @@ function html_admin(){
$pluginlist = plugin_list('admin');
$menu = array();
foreach ($pluginlist as $p) {
if($obj =& plugin_load('admin',$p) === NULL) continue;
if($obj =& plugin_load('admin',$p) === null) continue;
// check permissions
if($obj->forAdminOnly() && !$INFO['isadmin']) continue;
@ -1412,7 +1416,6 @@ function html_admin(){
ptln('</ul>');
// print the rest as sorted list
if(count($menu)){
usort($menu, 'p_sort_modes');
@ -1471,7 +1474,8 @@ function html_TOC($toc){
$out .= html_buildlist($toc,'toc','html_list_toc');
$out .= '</div>'.DOKU_LF.'</div>'.DOKU_LF;
$out .= '<!-- TOC END -->'.DOKU_LF;
return $out; }
return $out;
}
/**
* Callback for html_buildlist
@ -1602,4 +1606,3 @@ function html_flashobject($swf,$width,$height,$params=null,$flashvars=null,$atts
return $out;
}
//Setup VIM: ex: et ts=2 enc=utf-8 :

View File

@ -664,7 +664,9 @@ function idx_upgradePageWords(){
if (empty($page_idx)) return;
$pagewords = array();
$len = count($page_idx);
for ($n=0;$n<$len;$n++) $pagewords[] = array();
for ($n=0;$n<$len;$n++){
$pagewords[] = array();
}
unset($page_idx);
$n=0;

View File

@ -100,7 +100,6 @@ function check(){
}
}
if(is_writable($conf['changelog'])){
msg('Changelog is writable',1);
}else{

View File

@ -38,11 +38,16 @@
}
// init memory caches
global $cache_revinfo; $cache_revinfo = array();
global $cache_wikifn; $cache_wikifn = array();
global $cache_cleanid; $cache_cleanid = array();
global $cache_authname; $cache_authname = array();
global $cache_metadata; $cache_metadata = array();
global $cache_revinfo;
$cache_revinfo = array();
global $cache_wikifn;
$cache_wikifn = array();
global $cache_cleanid;
$cache_cleanid = array();
global $cache_authname;
$cache_authname = array();
global $cache_metadata;
$cache_metadata = array();
//set the configuration cascade - but only if its not already been set in preload.php
if (empty($config_cascade)) {
@ -577,4 +582,3 @@ function fullpath($path,$exists=false){
//Setup VIM: ex: et ts=2 enc=utf-8 :

View File

@ -464,7 +464,7 @@ function io_mktmpdir() {
* if $useAttachment is false,
* - $file is the full filename to save the file, incl. path
* - if successful will return true, false otherwise
*
* if $useAttachment is true,
* - $file is the directory where the file should be saved
* - if successful will return the name used for the saved file, false otherwise
@ -591,4 +591,3 @@ function io_grep($file,$pattern,$max=0,$backref=false){
return $matches;
}
//Setup VIM: ex: et ts=2 enc=utf-8 :

View File

@ -206,8 +206,9 @@ function mail_isvalid($email){
function mail_quotedprintable_encode($sText,$maxlen=74,$bEmulate_imap_8bit=true) {
// split text into lines
$aLines= preg_split("/(?:\r\n|\r|\n)/", $sText);
$cnt = count($aLines);
for ($i=0;$i<count($aLines);$i++) {
for ($i=0;$i<$cnt;$i++) {
$sLine =& $aLines[$i];
if (strlen($sLine)===0) continue; // do nothing, if empty
@ -232,12 +233,12 @@ function mail_quotedprintable_encode($sText,$maxlen=74,$bEmulate_imap_8bit=true)
// here is, where I don't agree with imap_8_bit,
// please correct me, if I'm wrong,
// or comment next line for RFC2045 conformance, if you like
if (!($bEmulate_imap_8bit && ($i==count($aLines)-1)))
if (!($bEmulate_imap_8bit && ($i==count($aLines)-1))){
if (($iLastChar==0x09)||($iLastChar==0x20)) {
$sLine{$iLength-1}='=';
$sLine .= ($iLastChar==0x09)?'09':'20';
}
}
} // imap_8bit encodes x20 before chr(13), too
// although IMHO not requested by RFC2045, why not do it safer :)
// and why not encode any x20 around chr(10) or chr(13)
@ -263,5 +264,3 @@ function mail_quotedprintable_encode($sText,$maxlen=74,$bEmulate_imap_8bit=true)
return implode(MAILHEADER_EOL,$aLines);
}
//Setup VIM: ex: et ts=2 enc=utf-8 :

View File

@ -502,8 +502,6 @@ function media_searchlist($query,$ns,$auth=null){
/**
* Print action links for a file depending on filetype
* and available permissions
*
* @todo contains inline javascript
*/
function media_fileactions($item,$auth){
global $lang;
@ -513,7 +511,6 @@ function media_fileactions($item,$auth){
echo ' <a href="'.$link.'" target="_blank"><img src="'.DOKU_BASE.'lib/images/magnifier.png" '.
'alt="'.$lang['mediaview'].'" title="'.$lang['mediaview'].'" class="btn" /></a>';
// no further actions if not writable
if(!$item['writable']) return;

View File

@ -535,4 +535,3 @@ function isVisiblePage($id){
}
//Setup VIM: ex: et ts=2 enc=utf-8 :

View File

@ -401,7 +401,6 @@ function p_render_metadata($id, $orig){
$keep = $ID;
$ID = $id;
// add an extra key for the event - to tell event handlers the page whose metadata this is
$orig['page'] = $id;
$evt = new Doku_Event('PARSER_METADATA_RENDER', $orig);
@ -514,7 +513,6 @@ function p_get_parsermodes(){
$obj = new Doku_Parser_Mode_entity(array_keys(getEntities()));
$modes[] = array('sort' => $obj->getSort(), 'mode' => 'entity','obj' => $obj );
// add optional camelcase mode
if($conf['camelcase']){
$obj = new Doku_Parser_Mode_camelcaselink();
@ -557,7 +555,6 @@ function p_render($mode,$instructions,&$info){
$Renderer->entities = getEntities();
$Renderer->acronyms = getAcronyms();
$Renderer->interwiki = getInterwiki();
#$Renderer->badwords = getBadWords();
// Loop through the instructions
foreach ( $instructions as $instruction ) {
@ -672,4 +669,3 @@ function p_xhtml_cached_geshi($code, $language, $wrapper='pre') {
}
}
//Setup VIM: ex: et ts=2 enc=utf-8 :

View File

@ -35,9 +35,18 @@ class DokuWiki_Plugin {
// plugin introspection methods
// extract from class name, format = <plugin type>_plugin_<name>[_<component name>]
function getPluginType() { list($t) = explode('_', get_class($this), 2); return $t; }
function getPluginName() { list($t, $p, $n) = explode('_', get_class($this), 4); return $n; }
function getPluginComponent() { list($t, $p, $n, $c) = explode('_', get_class($this), 4); return (isset($c)?$c:''); }
function getPluginType() {
list($t) = explode('_', get_class($this), 2);
return $t;
}
function getPluginName() {
list($t, $p, $n) = explode('_', get_class($this), 4);
return $n;
}
function getPluginComponent() {
list($t, $p, $n, $c) = explode('_', get_class($this), 4);
return (isset($c)?$c:'');
}
// localisation methods
/**
@ -167,8 +176,11 @@ class DokuWiki_Plugin {
* @return object helper plugin object
*/
function loadHelper($name, $msg){
if (!plugin_isdisabled($name)) $obj =& plugin_load('helper',$name);
else $obj = NULL;
if (!plugin_isdisabled($name)){
$obj =& plugin_load('helper',$name);
}else{
$obj = null;
}
if (is_null($obj) && $msg) msg("Helper plugin $name is not available or invalid.",-1);
return $obj;
}

View File

@ -20,10 +20,28 @@ $plugin_controller = new $plugin_controller_class();
/**
* Original plugin functions, remain for backwards compatibility
*/
function plugin_list($type='',$all=false) { global $plugin_controller; return $plugin_controller->getList($type,$all); }
function &plugin_load($type,$name,$new=false) { global $plugin_controller; return $plugin_controller->load($type,$name,$new); }
function plugin_isdisabled($plugin) { global $plugin_controller; return $plugin_controller->isdisabled($plugin); }
function plugin_enable($plugin) { global $plugin_controller; return $plugin_controller->enable($plugin); }
function plugin_disable($plugin) { global $plugin_controller; return $plugin_controller->disable($plugin); }
function plugin_directory($plugin) { global $plugin_controller; return $plugin_controller->get_directory($plugin); }
function plugin_list($type='',$all=false) {
global $plugin_controller;
return $plugin_controller->getList($type,$all);
}
function &plugin_load($type,$name,$new=false) {
global $plugin_controller;
return $plugin_controller->load($type,$name,$new);
}
function plugin_isdisabled($plugin) {
global $plugin_controller;
return $plugin_controller->isdisabled($plugin);
}
function plugin_enable($plugin) {
global $plugin_controller;
return $plugin_controller->enable($plugin);
}
function plugin_disable($plugin) {
global $plugin_controller;
return $plugin_controller->disable($plugin);
}
function plugin_directory($plugin) {
global $plugin_controller;
return $plugin_controller->get_directory($plugin);
}

View File

@ -13,7 +13,7 @@ require_once(DOKU_INC.'inc/JSON.php');
/**
* Prepares and prints an JavaScript array with all toolbar buttons
*
* @todo add toolbar plugins
* @emits TOOLBAR_DEFINE
* @param string $varname Name of the JS variable to fill
* @author Andreas Gohr <andi@splitbrain.org>
*/
@ -209,9 +209,6 @@ function toolbar_JSdefines($varname){
'icon' => 'sig.png',
'key' => 'y',
),
));
} // end event TOOLBAR_DEFINE default action
$evt->advise_after();

View File

@ -789,24 +789,24 @@ if(!function_exists('unicode_to_utf8')){
foreach (array_keys($arr) as $k) {
# ASCII range (including control chars)
if ( ($arr[$k] >= 0) && ($arr[$k] <= 0x007f) ) {
# ASCII range (including control chars)
echo chr($arr[$k]);
# 2 byte sequence
} else if ($arr[$k] <= 0x07ff) {
# 2 byte sequence
echo chr(0xc0 | ($arr[$k] >> 6));
echo chr(0x80 | ($arr[$k] & 0x003f));
# Byte order mark (skip)
} else if($arr[$k] == 0xFEFF) {
# Byte order mark (skip)
// nop -- zap the BOM
# Test for illegal surrogates
} else if ($arr[$k] >= 0xD800 && $arr[$k] <= 0xDFFF) {
# Test for illegal surrogates
// found a surrogate
if($strict){
@ -818,15 +818,15 @@ if(!function_exists('unicode_to_utf8')){
return false;
}
# 3 byte sequence
} else if ($arr[$k] <= 0xffff) {
# 3 byte sequence
echo chr(0xe0 | ($arr[$k] >> 12));
echo chr(0x80 | (($arr[$k] >> 6) & 0x003f));
echo chr(0x80 | ($arr[$k] & 0x003f));
# 4 byte sequence
} else if ($arr[$k] <= 0x10ffff) {
# 4 byte sequence
echo chr(0xf0 | ($arr[$k] >> 18));
echo chr(0x80 | (($arr[$k] >> 12) & 0x3f));
@ -1654,5 +1654,4 @@ if(empty($UTF8_ROMANIZATION)) $UTF8_ROMANIZATION = array(
'ㅠ'=>'yu','ㅒ'=>'yay','ㅖ'=>'yey',
);
//Setup VIM: ex: et ts=2 enc=utf-8 :

View File

@ -286,7 +286,6 @@ EOT;
}
$ok = $ok && fileWrite(DOKU_LOCAL.'local.php',$output);
if ($d['acl']) {
// create users.auth.php
// --- user:MD5password:Real Name:email:groups,comma,seperated
@ -473,7 +472,6 @@ function langsel(){
closedir($dh);
sort($langs);
echo '<form action="">';
echo $lang['i_chooselang'];
echo ': <select name="l" onchange="submit()">';