@@ -89,16 +89,16 @@ discard block |
||
| 89 | 89 | * @access private |
| 90 | 90 | */ |
| 91 | 91 | |
| 92 | -var $maxNestingLevel = 50; // maximum number of block nestings |
|
| 93 | -var $maxInclTemplateSize = 1000000; // maximum length of template string when including subtemplates |
|
| 94 | -var $template; // Template file data |
|
| 95 | -var $varTab; // variables table, array index is variable no |
|
| 92 | +var $maxNestingLevel = 50; // maximum number of block nestings |
|
| 93 | +var $maxInclTemplateSize = 1000000; // maximum length of template string when including subtemplates |
|
| 94 | +var $template; // Template file data |
|
| 95 | +var $varTab; // variables table, array index is variable no |
|
| 96 | 96 | // Fields: |
| 97 | 97 | // varName // variable name |
| 98 | 98 | // varValue // variable value |
| 99 | -var $varTabCnt; // no of entries used in VarTab |
|
| 100 | -var $varNameToNoMap; // maps variable names to variable numbers |
|
| 101 | -var $varRefTab; // variable references table |
|
| 99 | +var $varTabCnt; // no of entries used in VarTab |
|
| 100 | +var $varNameToNoMap; // maps variable names to variable numbers |
|
| 101 | +var $varRefTab; // variable references table |
|
| 102 | 102 | // Contains an entry for each variable reference in the template. Ordered by TemplatePos. |
| 103 | 103 | // Fields: |
| 104 | 104 | // varNo // variable no |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | // tPosEnd // template position of end of variable reference |
| 107 | 107 | // blockNo // block no of the (innermost) block that contains this variable reference |
| 108 | 108 | // blockVarNo // block variable no. Index into BlockInstTab.BlockVarTab |
| 109 | -var $varRefTabCnt; // no of entries used in VarRefTab |
|
| 110 | -var $blockTab; // Blocks table, array index is block no |
|
| 109 | +var $varRefTabCnt; // no of entries used in VarRefTab |
|
| 110 | +var $blockTab; // Blocks table, array index is block no |
|
| 111 | 111 | // Contains an entry for each block in the template. Ordered by TPosBegin. |
| 112 | 112 | // Fields: |
| 113 | 113 | // blockName // block name |
@@ -126,12 +126,12 @@ discard block |
||
| 126 | 126 | // blockVarCnt // no of variables in block |
| 127 | 127 | // blockVarNoToVarNoMap // maps block variable numbers to variable numbers |
| 128 | 128 | // firstVarRefNo // variable reference no of first variable of this block or -1 |
| 129 | -var $blockTabCnt; // no of entries used in BlockTab |
|
| 130 | -var $blockNameToNoMap; // maps block names to block numbers |
|
| 129 | +var $blockTabCnt; // no of entries used in BlockTab |
|
| 130 | +var $blockNameToNoMap; // maps block names to block numbers |
|
| 131 | 131 | var $openBlocksTab; |
| 132 | 132 | // During parsing, this table contains the block numbers of the open parent blocks (nested outer blocks). |
| 133 | 133 | // Indexed by the block nesting level. |
| 134 | -var $blockInstTab; // block instances table |
|
| 134 | +var $blockInstTab; // block instances table |
|
| 135 | 135 | // This table contains an entry for each block instance that has been added. |
| 136 | 136 | // Indexed by BlockInstNo. |
| 137 | 137 | // Fields: |
@@ -143,14 +143,14 @@ discard block |
||
| 143 | 143 | // nextBlockInstNo // pointer to next instance of this block or -1 |
| 144 | 144 | // Forward chain for instances of same block. |
| 145 | 145 | // blockVarTab // block instance variables |
| 146 | -var $blockInstTabCnt; // no of entries used in BlockInstTab |
|
| 146 | +var $blockInstTabCnt; // no of entries used in BlockInstTab |
|
| 147 | 147 | |
| 148 | -var $currentNestingLevel; // Current block nesting level during parsing. |
|
| 149 | -var $templateValid; // true if a valid template is prepared |
|
| 150 | -var $outputMode; // 0 = to PHP output stream, 1 = to file, 2 = to string |
|
| 151 | -var $outputFileHandle; // file handle during writing of output file |
|
| 152 | -var $outputError; // true when an output error occurred |
|
| 153 | -var $outputString; // string buffer for the generated HTML page |
|
| 148 | +var $currentNestingLevel; // Current block nesting level during parsing. |
|
| 149 | +var $templateValid; // true if a valid template is prepared |
|
| 150 | +var $outputMode; // 0 = to PHP output stream, 1 = to file, 2 = to string |
|
| 151 | +var $outputFileHandle; // file handle during writing of output file |
|
| 152 | +var $outputError; // true when an output error occurred |
|
| 153 | +var $outputString; // string buffer for the generated HTML page |
|
| 154 | 154 | |
| 155 | 155 | /**#@-*/ |
| 156 | 156 | |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | * @return boolean true on success, false on error. |
| 172 | 172 | * @access public |
| 173 | 173 | */ |
| 174 | -function readTemplateFromFile ($fileName) {
|
|
| 175 | - if (!$this->readFileIntoString($fileName,$s)) {
|
|
| 176 | - $this->triggerError ("Error while reading template file " . $fileName . ".");
|
|
| 174 | +function readTemplateFromFile($fileName) {
|
|
| 175 | + if (!$this->readFileIntoString($fileName, $s)) {
|
|
| 176 | + $this->triggerError("Error while reading template file ".$fileName.".");
|
|
| 177 | 177 | return false; } |
| 178 | 178 | if (!$this->setTemplateString($s)) return false; |
| 179 | 179 | return true; } |
@@ -199,10 +199,10 @@ discard block |
||
| 199 | 199 | * @return boolean true on success, false on error. |
| 200 | 200 | * @access private |
| 201 | 201 | */ |
| 202 | -function loadSubtemplate ($subtemplateName, &$s) {
|
|
| 203 | - $subtemplateFileName = $this->combineFileSystemPath($this->subtemplateBasePath,$subtemplateName); |
|
| 204 | - if (!$this->readFileIntoString($subtemplateFileName,$s)) {
|
|
| 205 | - $this->triggerError ("Error while reading subtemplate file " . $subtemplateFileName . ".");
|
|
| 202 | +function loadSubtemplate($subtemplateName, &$s) {
|
|
| 203 | + $subtemplateFileName = $this->combineFileSystemPath($this->subtemplateBasePath, $subtemplateName); |
|
| 204 | + if (!$this->readFileIntoString($subtemplateFileName, $s)) {
|
|
| 205 | + $this->triggerError("Error while reading subtemplate file ".$subtemplateFileName.".");
|
|
| 206 | 206 | return false; } |
| 207 | 207 | return true; } |
| 208 | 208 | |
@@ -279,15 +279,15 @@ discard block |
||
| 279 | 279 | function parseTemplateCommands() {
|
| 280 | 280 | $p = 0; |
| 281 | 281 | while (true) {
|
| 282 | - $p0 = strpos($this->template,'<!--',$p); |
|
| 282 | + $p0 = strpos($this->template, '<!--', $p); |
|
| 283 | 283 | if ($p0 === false) break; |
| 284 | - $p = strpos($this->template,'-->',$p0); |
|
| 284 | + $p = strpos($this->template, '-->', $p0); |
|
| 285 | 285 | if ($p === false) {
|
| 286 | - $this->triggerError ("Invalid HTML comment in template at offset $p0.");
|
|
| 286 | + $this->triggerError("Invalid HTML comment in template at offset $p0.");
|
|
| 287 | 287 | return false; } |
| 288 | 288 | $p += 3; |
| 289 | - $cmdL = substr($this->template,$p0+4,$p-$p0-7); |
|
| 290 | - if (!$this->processTemplateCommand($cmdL,$p0,$p,$resumeFromStart)) |
|
| 289 | + $cmdL = substr($this->template, $p0 + 4, $p - $p0 - 7); |
|
| 290 | + if (!$this->processTemplateCommand($cmdL, $p0, $p, $resumeFromStart)) |
|
| 291 | 291 | return false; |
| 292 | 292 | if ($resumeFromStart) $p = $p0; } |
| 293 | 293 | return true; } |
@@ -296,29 +296,29 @@ discard block |
||
| 296 | 296 | * @return boolean true on success, false on error. |
| 297 | 297 | * @access private |
| 298 | 298 | */ |
| 299 | -function processTemplateCommand ($cmdL, $cmdTPosBegin, $cmdTPosEnd, &$resumeFromStart) {
|
|
| 299 | +function processTemplateCommand($cmdL, $cmdTPosBegin, $cmdTPosEnd, &$resumeFromStart) {
|
|
| 300 | 300 | $resumeFromStart = false; |
| 301 | 301 | $p = 0; |
| 302 | 302 | $cmd = ''; |
| 303 | - if (!$this->parseWord($cmdL,$p,$cmd)) return true; |
|
| 304 | - $parms = substr($cmdL,$p); |
|
| 303 | + if (!$this->parseWord($cmdL, $p, $cmd)) return true; |
|
| 304 | + $parms = substr($cmdL, $p); |
|
| 305 | 305 | switch (strtoupper($cmd)) {
|
| 306 | 306 | case '$BEGINBLOCK': |
| 307 | - if (!$this->processBeginBlockCmd($parms,$cmdTPosBegin,$cmdTPosEnd)) |
|
| 307 | + if (!$this->processBeginBlockCmd($parms, $cmdTPosBegin, $cmdTPosEnd)) |
|
| 308 | 308 | return false; |
| 309 | 309 | break; |
| 310 | 310 | case '$ENDBLOCK': |
| 311 | - if (!$this->processEndBlockCmd($parms,$cmdTPosBegin,$cmdTPosEnd)) |
|
| 311 | + if (!$this->processEndBlockCmd($parms, $cmdTPosBegin, $cmdTPosEnd)) |
|
| 312 | 312 | return false; |
| 313 | 313 | break; |
| 314 | 314 | case '$INCLUDE': |
| 315 | - if (!$this->processincludeCmd($parms,$cmdTPosBegin,$cmdTPosEnd)) |
|
| 315 | + if (!$this->processincludeCmd($parms, $cmdTPosBegin, $cmdTPosEnd)) |
|
| 316 | 316 | return false; |
| 317 | 317 | $resumeFromStart = true; |
| 318 | 318 | break; |
| 319 | 319 | default: |
| 320 | 320 | if ($cmd{0} == '$' && !(strlen($cmd) >= 2 && $cmd{1} == '{')) {
|
| 321 | - $this->triggerError ("Unknown command \"$cmd\" in template at offset $cmdTPosBegin.");
|
|
| 321 | + $this->triggerError("Unknown command \"$cmd\" in template at offset $cmdTPosBegin.");
|
|
| 322 | 322 | return false; }} |
| 323 | 323 | return true; } |
| 324 | 324 | |
@@ -327,24 +327,24 @@ discard block |
||
| 327 | 327 | * @return boolean true on success, false on error. |
| 328 | 328 | * @access private |
| 329 | 329 | */ |
| 330 | -function processBeginBlockCmd ($parms, $cmdTPosBegin, $cmdTPosEnd) {
|
|
| 330 | +function processBeginBlockCmd($parms, $cmdTPosBegin, $cmdTPosEnd) {
|
|
| 331 | 331 | $p = 0; |
| 332 | - if (!$this->parseWord($parms,$p,$blockName)) {
|
|
| 333 | - $this->triggerError ("Missing block name in \$BeginBlock command in template at offset $cmdTPosBegin.");
|
|
| 332 | + if (!$this->parseWord($parms, $p, $blockName)) {
|
|
| 333 | + $this->triggerError("Missing block name in \$BeginBlock command in template at offset $cmdTPosBegin.");
|
|
| 334 | 334 | return false; } |
| 335 | - if (trim(substr($parms,$p)) != '') {
|
|
| 336 | - $this->triggerError ("Extra parameter in \$BeginBlock command in template at offset $cmdTPosBegin.");
|
|
| 335 | + if (trim(substr($parms, $p)) != '') {
|
|
| 336 | + $this->triggerError("Extra parameter in \$BeginBlock command in template at offset $cmdTPosBegin.");
|
|
| 337 | 337 | return false; } |
| 338 | - $this->registerBlock ($blockName, $blockNo); |
|
| 339 | - $btr =& $this->blockTab[$blockNo]; |
|
| 338 | + $this->registerBlock($blockName, $blockNo); |
|
| 339 | + $btr = & $this->blockTab[$blockNo]; |
|
| 340 | 340 | $btr['tPosBegin'] = $cmdTPosBegin; |
| 341 | 341 | $btr['tPosContentsBegin'] = $cmdTPosEnd; |
| 342 | 342 | $btr['nestingLevel'] = $this->currentNestingLevel; |
| 343 | - $btr['parentBlockNo'] = $this->openBlocksTab[$this->currentNestingLevel-1]; |
|
| 343 | + $btr['parentBlockNo'] = $this->openBlocksTab[$this->currentNestingLevel - 1]; |
|
| 344 | 344 | $this->openBlocksTab[$this->currentNestingLevel] = $blockNo; |
| 345 | 345 | $this->currentNestingLevel += 1; |
| 346 | 346 | if ($this->currentNestingLevel > $this->maxNestingLevel) {
|
| 347 | - $this->triggerError ("Block nesting overflow in template at offset $cmdTPosBegin.");
|
|
| 347 | + $this->triggerError("Block nesting overflow in template at offset $cmdTPosBegin.");
|
|
| 348 | 348 | return false; } |
| 349 | 349 | return true; } |
| 350 | 350 | |
@@ -353,24 +353,24 @@ discard block |
||
| 353 | 353 | * @return boolean true on success, false on error. |
| 354 | 354 | * @access private |
| 355 | 355 | */ |
| 356 | -function processEndBlockCmd ($parms, $cmdTPosBegin, $cmdTPosEnd) {
|
|
| 356 | +function processEndBlockCmd($parms, $cmdTPosBegin, $cmdTPosEnd) {
|
|
| 357 | 357 | $p = 0; |
| 358 | - if (!$this->parseWord($parms,$p,$blockName)) {
|
|
| 359 | - $this->triggerError ("Missing block name in \$EndBlock command in template at offset $cmdTPosBegin.");
|
|
| 358 | + if (!$this->parseWord($parms, $p, $blockName)) {
|
|
| 359 | + $this->triggerError("Missing block name in \$EndBlock command in template at offset $cmdTPosBegin.");
|
|
| 360 | 360 | return false; } |
| 361 | - if (trim(substr($parms,$p)) != '') {
|
|
| 362 | - $this->triggerError ("Extra parameter in \$EndBlock command in template at offset $cmdTPosBegin.");
|
|
| 361 | + if (trim(substr($parms, $p)) != '') {
|
|
| 362 | + $this->triggerError("Extra parameter in \$EndBlock command in template at offset $cmdTPosBegin.");
|
|
| 363 | 363 | return false; } |
| 364 | - if (!$this->lookupBlockName($blockName,$blockNo)) {
|
|
| 365 | - $this->triggerError ("Undefined block name \"$blockName\" in \$EndBlock command in template at offset $cmdTPosBegin.");
|
|
| 364 | + if (!$this->lookupBlockName($blockName, $blockNo)) {
|
|
| 365 | + $this->triggerError("Undefined block name \"$blockName\" in \$EndBlock command in template at offset $cmdTPosBegin.");
|
|
| 366 | 366 | return false; } |
| 367 | 367 | $this->currentNestingLevel -= 1; |
| 368 | - $btr =& $this->blockTab[$blockNo]; |
|
| 368 | + $btr = & $this->blockTab[$blockNo]; |
|
| 369 | 369 | if (!$btr['definitionIsOpen']) {
|
| 370 | - $this->triggerError ("Multiple \$EndBlock command for block \"$blockName\" in template at offset $cmdTPosBegin.");
|
|
| 370 | + $this->triggerError("Multiple \$EndBlock command for block \"$blockName\" in template at offset $cmdTPosBegin.");
|
|
| 371 | 371 | return false; } |
| 372 | 372 | if ($btr['nestingLevel'] != $this->currentNestingLevel) {
|
| 373 | - $this->triggerError ("Block nesting level mismatch at \$EndBlock command for block \"$blockName\" in template at offset $cmdTPosBegin.");
|
|
| 373 | + $this->triggerError("Block nesting level mismatch at \$EndBlock command for block \"$blockName\" in template at offset $cmdTPosBegin.");
|
|
| 374 | 374 | return false; } |
| 375 | 375 | $btr['tPosContentsEnd'] = $cmdTPosBegin; |
| 376 | 376 | $btr['tPosEnd'] = $cmdTPosEnd; |
@@ -382,10 +382,10 @@ discard block |
||
| 382 | 382 | */ |
| 383 | 383 | function registerBlock($blockName, &$blockNo) {
|
| 384 | 384 | $blockNo = $this->blockTabCnt++; |
| 385 | - $btr =& $this->blockTab[$blockNo]; |
|
| 385 | + $btr = & $this->blockTab[$blockNo]; |
|
| 386 | 386 | $btr = array(); |
| 387 | 387 | $btr['blockName'] = $blockName; |
| 388 | - if (!$this->lookupBlockName($blockName,$btr['nextWithSameName'])) |
|
| 388 | + if (!$this->lookupBlockName($blockName, $btr['nextWithSameName'])) |
|
| 389 | 389 | $btr['nextWithSameName'] = -1; |
| 390 | 390 | $btr['definitionIsOpen'] = true; |
| 391 | 391 | $btr['instances'] = 0; |
@@ -402,13 +402,13 @@ discard block |
||
| 402 | 402 | * @access private |
| 403 | 403 | */ |
| 404 | 404 | function checkBlockDefinitionsComplete() {
|
| 405 | - for ($blockNo=0; $blockNo < $this->blockTabCnt; $blockNo++) {
|
|
| 406 | - $btr =& $this->blockTab[$blockNo]; |
|
| 405 | + for ($blockNo = 0; $blockNo < $this->blockTabCnt; $blockNo++) {
|
|
| 406 | + $btr = & $this->blockTab[$blockNo]; |
|
| 407 | 407 | if ($btr['definitionIsOpen']) {
|
| 408 | - $this->triggerError ("Missing \$EndBlock command in template for block " . $btr['blockName'] . ".");
|
|
| 408 | + $this->triggerError("Missing \$EndBlock command in template for block ".$btr['blockName'].".");
|
|
| 409 | 409 | return false; }} |
| 410 | 410 | if ($this->currentNestingLevel != 0) {
|
| 411 | - $this->triggerError ("Block nesting level error at end of template.");
|
|
| 411 | + $this->triggerError("Block nesting level error at end of template.");
|
|
| 412 | 412 | return false; } |
| 413 | 413 | return true; } |
| 414 | 414 | |
@@ -417,29 +417,29 @@ discard block |
||
| 417 | 417 | * @return boolean true on success, false on error. |
| 418 | 418 | * @access private |
| 419 | 419 | */ |
| 420 | -function processIncludeCmd ($parms, $cmdTPosBegin, $cmdTPosEnd) {
|
|
| 420 | +function processIncludeCmd($parms, $cmdTPosBegin, $cmdTPosEnd) {
|
|
| 421 | 421 | $p = 0; |
| 422 | - if (!$this->parseWordOrQuotedString($parms,$p,$subtemplateName)) {
|
|
| 423 | - $this->triggerError ("Missing or invalid subtemplate name in \$Include command in template at offset $cmdTPosBegin.");
|
|
| 422 | + if (!$this->parseWordOrQuotedString($parms, $p, $subtemplateName)) {
|
|
| 423 | + $this->triggerError("Missing or invalid subtemplate name in \$Include command in template at offset $cmdTPosBegin.");
|
|
| 424 | 424 | return false; } |
| 425 | - if (trim(substr($parms,$p)) != '') {
|
|
| 426 | - $this->triggerError ("Extra parameter in \$include command in template at offset $cmdTPosBegin.");
|
|
| 425 | + if (trim(substr($parms, $p)) != '') {
|
|
| 426 | + $this->triggerError("Extra parameter in \$include command in template at offset $cmdTPosBegin.");
|
|
| 427 | 427 | return false; } |
| 428 | - return $this->insertSubtemplate($subtemplateName,$cmdTPosBegin,$cmdTPosEnd); } |
|
| 428 | + return $this->insertSubtemplate($subtemplateName, $cmdTPosBegin, $cmdTPosEnd); } |
|
| 429 | 429 | |
| 430 | 430 | /** |
| 431 | 431 | * Processes the $Include command. |
| 432 | 432 | * @return boolean true on success, false on error. |
| 433 | 433 | * @access private |
| 434 | 434 | */ |
| 435 | -function insertSubtemplate ($subtemplateName, $tPos1, $tPos2) {
|
|
| 435 | +function insertSubtemplate($subtemplateName, $tPos1, $tPos2) {
|
|
| 436 | 436 | if (strlen($this->template) > $this->maxInclTemplateSize) {
|
| 437 | - $this->triggerError ("Subtemplate include aborted because the internal template string is longer than $this->maxInclTemplateSize characters.");
|
|
| 437 | + $this->triggerError("Subtemplate include aborted because the internal template string is longer than $this->maxInclTemplateSize characters.");
|
|
| 438 | 438 | return false; } |
| 439 | - if (!$this->loadSubtemplate($subtemplateName,$subtemplate)) return false; |
|
| 439 | + if (!$this->loadSubtemplate($subtemplateName, $subtemplate)) return false; |
|
| 440 | 440 | // (Copying the template to insert a subtemplate is a bit slow. In a future implementation of MiniTemplator, |
| 441 | 441 | // a table could be used that contains references to the string fragments.) |
| 442 | - $this->template = substr($this->template,0,$tPos1) . $subtemplate . substr($this->template,$tPos2); |
|
| 442 | + $this->template = substr($this->template, 0, $tPos1).$subtemplate.substr($this->template, $tPos2); |
|
| 443 | 443 | return true; } |
| 444 | 444 | |
| 445 | 445 | /** |
@@ -455,24 +455,24 @@ discard block |
||
| 455 | 455 | $p0 = $p; |
| 456 | 456 | $p = strpos($this->template, '}', $p); |
| 457 | 457 | if ($p === false) {
|
| 458 | - $this->triggerError ("Invalid variable reference in template at offset $p0.");
|
|
| 458 | + $this->triggerError("Invalid variable reference in template at offset $p0.");
|
|
| 459 | 459 | return false; } |
| 460 | 460 | $p += 1; |
| 461 | - $varName = trim(substr($this->template, $p0+2, $p-$p0-3)); |
|
| 461 | + $varName = trim(substr($this->template, $p0 + 2, $p - $p0 - 3)); |
|
| 462 | 462 | if (strlen($varName) == 0) {
|
| 463 | - $this->triggerError ("Empty variable name in template at offset $p0.");
|
|
| 463 | + $this->triggerError("Empty variable name in template at offset $p0.");
|
|
| 464 | 464 | return false; } |
| 465 | - $this->registerVariableReference ($varName, $p0, $p); } |
|
| 465 | + $this->registerVariableReference($varName, $p0, $p); } |
|
| 466 | 466 | return true; } |
| 467 | 467 | |
| 468 | 468 | /** |
| 469 | 469 | * @access private |
| 470 | 470 | */ |
| 471 | -function registerVariableReference ($varName, $tPosBegin, $tPosEnd) {
|
|
| 472 | - if (!$this->lookupVariableName($varName,$varNo)) |
|
| 473 | - $this->registerVariable($varName,$varNo); |
|
| 471 | +function registerVariableReference($varName, $tPosBegin, $tPosEnd) {
|
|
| 472 | + if (!$this->lookupVariableName($varName, $varNo)) |
|
| 473 | + $this->registerVariable($varName, $varNo); |
|
| 474 | 474 | $varRefNo = $this->varRefTabCnt++; |
| 475 | - $vrtr =& $this->varRefTab[$varRefNo]; |
|
| 475 | + $vrtr = & $this->varRefTab[$varRefNo]; |
|
| 476 | 476 | $vrtr = array(); |
| 477 | 477 | $vrtr['tPosBegin'] = $tPosBegin; |
| 478 | 478 | $vrtr['tPosEnd'] = $tPosEnd; |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | $activeBlockNo = 0; |
| 499 | 499 | $nextBlockNo = 1; |
| 500 | 500 | while ($varRefNo < $this->varRefTabCnt) {
|
| 501 | - $vrtr =& $this->varRefTab[$varRefNo]; |
|
| 501 | + $vrtr = & $this->varRefTab[$varRefNo]; |
|
| 502 | 502 | $varRefTPos = $vrtr['tPosBegin']; |
| 503 | 503 | $varNo = $vrtr['varNo']; |
| 504 | 504 | if ($varRefTPos >= $this->blockTab[$activeBlockNo]['tPosEnd']) {
|
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | $activeBlockNo = $nextBlockNo; |
| 510 | 510 | $nextBlockNo += 1; |
| 511 | 511 | continue; }} |
| 512 | - $btr =& $this->blockTab[$activeBlockNo]; |
|
| 512 | + $btr = & $this->blockTab[$activeBlockNo]; |
|
| 513 | 513 | if ($varRefTPos < $btr['tPosBegin']) |
| 514 | 514 | $this->programLogicError(1); |
| 515 | 515 | $blockVarNo = $btr['blockVarCnt']++; |
@@ -531,10 +531,10 @@ discard block |
||
| 531 | 531 | * @access public |
| 532 | 532 | */ |
| 533 | 533 | function reset() {
|
| 534 | - for ($varNo=0; $varNo<$this->varTabCnt; $varNo++) |
|
| 534 | + for ($varNo = 0; $varNo < $this->varTabCnt; $varNo++) |
|
| 535 | 535 | $this->varTab[$varNo]['varValue'] = ''; |
| 536 | - for ($blockNo=0; $blockNo<$this->blockTabCnt; $blockNo++) {
|
|
| 537 | - $btr =& $this->blockTab[$blockNo]; |
|
| 536 | + for ($blockNo = 0; $blockNo < $this->blockTabCnt; $blockNo++) {
|
|
| 537 | + $btr = & $this->blockTab[$blockNo]; |
|
| 538 | 538 | $btr['instances'] = 0; |
| 539 | 539 | $btr['firstBlockInstNo'] = -1; |
| 540 | 540 | $btr['lastBlockInstNo'] = -1; } |
@@ -556,11 +556,11 @@ discard block |
||
| 556 | 556 | * $isOptional is false). |
| 557 | 557 | * @access public |
| 558 | 558 | */ |
| 559 | -function setVariable ($variableName, $variableValue, $isOptional=false) {
|
|
| 560 | - if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
|
|
| 561 | - if (!$this->lookupVariableName($variableName,$varNo)) {
|
|
| 559 | +function setVariable($variableName, $variableValue, $isOptional = false) {
|
|
| 560 | + if (!$this->templateValid) {$this->triggerError("Template not valid."); return false; }
|
|
| 561 | + if (!$this->lookupVariableName($variableName, $varNo)) {
|
|
| 562 | 562 | if ($isOptional) return true; |
| 563 | - $this->triggerError ("Variable \"$variableName\" not defined in template.");
|
|
| 563 | + $this->triggerError("Variable \"$variableName\" not defined in template.");
|
|
| 564 | 564 | return false; } |
| 565 | 565 | $this->varTab[$varNo]['varValue'] = $variableValue; |
| 566 | 566 | return true; } |
@@ -611,9 +611,9 @@ discard block |
||
| 611 | 611 | * @access public |
| 612 | 612 | */ |
| 613 | 613 | function addBlock($blockName) {
|
| 614 | - if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
|
|
| 615 | - if (!$this->lookupBlockName($blockName,$blockNo)) {
|
|
| 616 | - $this->triggerError ("Block \"$blockName\" not defined in template.");
|
|
| 614 | + if (!$this->templateValid) {$this->triggerError("Template not valid."); return false; }
|
|
| 615 | + if (!$this->lookupBlockName($blockName, $blockNo)) {
|
|
| 616 | + $this->triggerError("Block \"$blockName\" not defined in template.");
|
|
| 617 | 617 | return false; } |
| 618 | 618 | while ($blockNo != -1) {
|
| 619 | 619 | $this->addBlockByNo($blockNo); |
@@ -644,14 +644,14 @@ discard block |
||
| 644 | 644 | $bitr['nextBlockInstNo'] = -1; |
| 645 | 645 | $bitr['blockVarTab'] = array(); |
| 646 | 646 | // copy instance variables for this block |
| 647 | - for ($blockVarNo=0; $blockVarNo<$blockVarCnt; $blockVarNo++) {
|
|
| 647 | + for ($blockVarNo = 0; $blockVarNo < $blockVarCnt; $blockVarNo++) {
|
|
| 648 | 648 | $varNo = $btr['blockVarNoToVarNoMap'][$blockVarNo]; |
| 649 | 649 | $bitr['blockVarTab'][$blockVarNo] = $this->varTab[$varNo]['varValue']; }} |
| 650 | 650 | |
| 651 | 651 | /** |
| 652 | 652 | * @access private |
| 653 | 653 | */ |
| 654 | -function registerBlockInstance (&$blockInstNo) {
|
|
| 654 | +function registerBlockInstance(&$blockInstNo) {
|
|
| 655 | 655 | $blockInstNo = $this->blockInstTabCnt++; } |
| 656 | 656 | |
| 657 | 657 | /** |
@@ -716,14 +716,14 @@ discard block |
||
| 716 | 716 | * @return boolean true on success, false on error. |
| 717 | 717 | */ |
| 718 | 718 | function generateOutputPage() {
|
| 719 | - if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
|
|
| 719 | + if (!$this->templateValid) {$this->triggerError("Template not valid."); return false; }
|
|
| 720 | 720 | if ($this->blockTab[0]['instances'] == 0) |
| 721 | - $this->addBlockByNo (0); // add main block |
|
| 722 | - for ($blockNo=0; $blockNo < $this->blockTabCnt; $blockNo++) {
|
|
| 723 | - $btr =& $this->blockTab[$blockNo]; |
|
| 721 | + $this->addBlockByNo(0); // add main block |
|
| 722 | + for ($blockNo = 0; $blockNo < $this->blockTabCnt; $blockNo++) {
|
|
| 723 | + $btr = & $this->blockTab[$blockNo]; |
|
| 724 | 724 | $btr['currBlockInstNo'] = $btr['firstBlockInstNo']; } |
| 725 | 725 | $this->outputError = false; |
| 726 | - $this->writeBlockInstances (0, -1); |
|
| 726 | + $this->writeBlockInstances(0, -1); |
|
| 727 | 727 | if ($this->outputError) return false; |
| 728 | 728 | return true; } |
| 729 | 729 | |
@@ -733,33 +733,33 @@ discard block |
||
| 733 | 733 | * Called recursively. |
| 734 | 734 | * @access private |
| 735 | 735 | */ |
| 736 | -function writeBlockInstances ($blockNo, $parentInstLevel) {
|
|
| 737 | - $btr =& $this->blockTab[$blockNo]; |
|
| 736 | +function writeBlockInstances($blockNo, $parentInstLevel) {
|
|
| 737 | + $btr = & $this->blockTab[$blockNo]; |
|
| 738 | 738 | while (!$this->outputError) {
|
| 739 | 739 | $blockInstNo = $btr['currBlockInstNo']; |
| 740 | 740 | if ($blockInstNo == -1) break; |
| 741 | - $bitr =& $this->blockInstTab[$blockInstNo]; |
|
| 741 | + $bitr = & $this->blockInstTab[$blockInstNo]; |
|
| 742 | 742 | if ($bitr['parentInstLevel'] < $parentInstLevel) |
| 743 | - $this->programLogicError (2); |
|
| 743 | + $this->programLogicError(2); |
|
| 744 | 744 | if ($bitr['parentInstLevel'] > $parentInstLevel) break; |
| 745 | - $this->writeBlockInstance ($blockInstNo); |
|
| 745 | + $this->writeBlockInstance($blockInstNo); |
|
| 746 | 746 | $btr['currBlockInstNo'] = $bitr['nextBlockInstNo']; }} |
| 747 | 747 | |
| 748 | 748 | /** |
| 749 | 749 | * @access private |
| 750 | 750 | */ |
| 751 | 751 | function writeBlockInstance($blockInstNo) {
|
| 752 | - $bitr =& $this->blockInstTab[$blockInstNo]; |
|
| 752 | + $bitr = & $this->blockInstTab[$blockInstNo]; |
|
| 753 | 753 | $blockNo = $bitr['blockNo']; |
| 754 | - $btr =& $this->blockTab[$blockNo]; |
|
| 754 | + $btr = & $this->blockTab[$blockNo]; |
|
| 755 | 755 | $tPos = $btr['tPosContentsBegin']; |
| 756 | 756 | $subBlockNo = $blockNo + 1; |
| 757 | 757 | $varRefNo = $btr['firstVarRefNo']; |
| 758 | 758 | while (!$this->outputError) {
|
| 759 | 759 | $tPos2 = $btr['tPosContentsEnd']; |
| 760 | - $kind = 0; // assume end-of-block |
|
| 760 | + $kind = 0; // assume end-of-block |
|
| 761 | 761 | if ($varRefNo != -1 && $varRefNo < $this->varRefTabCnt) { // check for variable reference
|
| 762 | - $vrtr =& $this->varRefTab[$varRefNo]; |
|
| 762 | + $vrtr = & $this->varRefTab[$varRefNo]; |
|
| 763 | 763 | if ($vrtr['tPosBegin'] < $tPos) {
|
| 764 | 764 | $varRefNo += 1; |
| 765 | 765 | continue; } |
@@ -767,7 +767,7 @@ discard block |
||
| 767 | 767 | $tPos2 = $vrtr['tPosBegin']; |
| 768 | 768 | $kind = 1; }} |
| 769 | 769 | if ($subBlockNo < $this->blockTabCnt) { // check for subblock
|
| 770 | - $subBtr =& $this->blockTab[$subBlockNo]; |
|
| 770 | + $subBtr = & $this->blockTab[$subBlockNo]; |
|
| 771 | 771 | if ($subBtr['tPosBegin'] < $tPos) {
|
| 772 | 772 | $subBlockNo += 1; |
| 773 | 773 | continue; } |
@@ -775,24 +775,24 @@ discard block |
||
| 775 | 775 | $tPos2 = $subBtr['tPosBegin']; |
| 776 | 776 | $kind = 2; }} |
| 777 | 777 | if ($tPos2 > $tPos) |
| 778 | - $this->writeString (substr($this->template,$tPos,$tPos2-$tPos)); |
|
| 778 | + $this->writeString(substr($this->template, $tPos, $tPos2 - $tPos)); |
|
| 779 | 779 | switch ($kind) {
|
| 780 | 780 | case 0: // end of block |
| 781 | 781 | return; |
| 782 | 782 | case 1: // variable |
| 783 | - $vrtr =& $this->varRefTab[$varRefNo]; |
|
| 783 | + $vrtr = & $this->varRefTab[$varRefNo]; |
|
| 784 | 784 | if ($vrtr['blockNo'] != $blockNo) |
| 785 | - $this->programLogicError (4); |
|
| 785 | + $this->programLogicError(4); |
|
| 786 | 786 | $variableValue = $bitr['blockVarTab'][$vrtr['blockVarNo']]; |
| 787 | - $this->writeString ($variableValue); |
|
| 787 | + $this->writeString($variableValue); |
|
| 788 | 788 | $tPos = $vrtr['tPosEnd']; |
| 789 | 789 | $varRefNo += 1; |
| 790 | 790 | break; |
| 791 | 791 | case 2: // sub block |
| 792 | - $subBtr =& $this->blockTab[$subBlockNo]; |
|
| 792 | + $subBtr = & $this->blockTab[$subBlockNo]; |
|
| 793 | 793 | if ($subBtr['parentBlockNo'] != $blockNo) |
| 794 | - $this->programLogicError (3); |
|
| 795 | - $this->writeBlockInstances ($subBlockNo, $bitr['instanceLevel']); // recursive call |
|
| 794 | + $this->programLogicError(3); |
|
| 795 | + $this->writeBlockInstances($subBlockNo, $bitr['instanceLevel']); // recursive call |
|
| 796 | 796 | $tPos = $subBtr['tPosEnd']; |
| 797 | 797 | $subBlockNo += 1; |
| 798 | 798 | break; }}} |
@@ -848,17 +848,17 @@ discard block |
||
| 848 | 848 | * @return boolean true on success, false on error. |
| 849 | 849 | * @access private |
| 850 | 850 | */ |
| 851 | -function readFileIntoString ($fileName, &$s) {
|
|
| 852 | - if (function_exists('version_compare') && version_compare(phpversion(),"4.3.0",">=")) {
|
|
| 851 | +function readFileIntoString($fileName, &$s) {
|
|
| 852 | + if (function_exists('version_compare') && version_compare(phpversion(), "4.3.0", ">=")) {
|
|
| 853 | 853 | $s = file_get_contents($fileName); |
| 854 | 854 | if ($s === false) return false; |
| 855 | 855 | return true; } |
| 856 | - $fh = fopen($fileName,"rb"); |
|
| 856 | + $fh = fopen($fileName, "rb"); |
|
| 857 | 857 | if ($fh === false) return false; |
| 858 | 858 | $fileSize = filesize($fileName); |
| 859 | - if ($fileSize === false) {fclose ($fh); return false; }
|
|
| 860 | - $s = fread($fh,$fileSize); |
|
| 861 | - fclose ($fh); |
|
| 859 | + if ($fileSize === false) {fclose($fh); return false; }
|
|
| 860 | + $s = fread($fh, $fileSize); |
|
| 861 | + fclose($fh); |
|
| 862 | 862 | if (strlen($s) != $fileSize) return false; |
| 863 | 863 | return true; } |
| 864 | 864 | |
@@ -901,39 +901,39 @@ discard block |
||
| 901 | 901 | * @access private |
| 902 | 902 | * @return boolean true on success, false on error. |
| 903 | 903 | */ |
| 904 | -function parseWordOrQuotedString ($s, &$p, &$w) {
|
|
| 904 | +function parseWordOrQuotedString($s, &$p, &$w) {
|
|
| 905 | 905 | $sLen = strlen($s); |
| 906 | 906 | while ($p < $sLen && ord($s{$p}) <= 32) $p++;
|
| 907 | 907 | if ($p >= $sLen) return false; |
| 908 | - if (substr($s,$p,1) == '"') |
|
| 909 | - return $this->parseQuotedString($s,$p,$w); |
|
| 908 | + if (substr($s, $p, 1) == '"') |
|
| 909 | + return $this->parseQuotedString($s, $p, $w); |
|
| 910 | 910 | else |
| 911 | - return $this->parseWord($s,$p,$w); } |
|
| 911 | + return $this->parseWord($s, $p, $w); } |
|
| 912 | 912 | |
| 913 | 913 | /** |
| 914 | 914 | * Combine two file system paths. |
| 915 | 915 | * @access private |
| 916 | 916 | */ |
| 917 | -function combineFileSystemPath ($path1, $path2) {
|
|
| 917 | +function combineFileSystemPath($path1, $path2) {
|
|
| 918 | 918 | if ($path1 == '' || $path2 == '') return $path2; |
| 919 | 919 | $s = $path1; |
| 920 | - if (substr($s,-1) != '\\' && substr($s,-1) != '/') $s = $s . "/"; |
|
| 921 | - if (substr($path2,0,1) == '\\' || substr($path2,0,1) == '/') |
|
| 922 | - $s = $s . substr($path2,1); |
|
| 920 | + if (substr($s, -1) != '\\' && substr($s, -1) != '/') $s = $s."/"; |
|
| 921 | + if (substr($path2, 0, 1) == '\\' || substr($path2, 0, 1) == '/') |
|
| 922 | + $s = $s.substr($path2, 1); |
|
| 923 | 923 | else |
| 924 | - $s = $s . $path2; |
|
| 924 | + $s = $s.$path2; |
|
| 925 | 925 | return $s; } |
| 926 | 926 | |
| 927 | 927 | /** |
| 928 | 928 | * @access private |
| 929 | 929 | */ |
| 930 | -function triggerError ($msg) {
|
|
| 931 | - trigger_error ("MiniTemplator error: $msg", E_USER_ERROR); }
|
|
| 930 | +function triggerError($msg) {
|
|
| 931 | + trigger_error("MiniTemplator error: $msg", E_USER_ERROR); }
|
|
| 932 | 932 | |
| 933 | 933 | /** |
| 934 | 934 | * @access private |
| 935 | 935 | */ |
| 936 | -function programLogicError ($errorId) {
|
|
| 936 | +function programLogicError($errorId) {
|
|
| 937 | 937 | die ("MiniTemplator: Program logic error $errorId.\n"); }
|
| 938 | 938 | |
| 939 | 939 | } |
@@ -175,7 +175,9 @@ discard block |
||
| 175 | 175 | if (!$this->readFileIntoString($fileName,$s)) {
|
| 176 | 176 | $this->triggerError ("Error while reading template file " . $fileName . ".");
|
| 177 | 177 | return false; } |
| 178 | - if (!$this->setTemplateString($s)) return false; |
|
| 178 | + if (!$this->setTemplateString($s)) { |
|
| 179 | + return false; |
|
| 180 | + } |
|
| 179 | 181 | return true; } |
| 180 | 182 | |
| 181 | 183 | /** |
@@ -280,16 +282,22 @@ discard block |
||
| 280 | 282 | $p = 0; |
| 281 | 283 | while (true) {
|
| 282 | 284 | $p0 = strpos($this->template,'<!--',$p); |
| 283 | - if ($p0 === false) break; |
|
| 285 | + if ($p0 === false) { |
|
| 286 | + break; |
|
| 287 | + } |
|
| 284 | 288 | $p = strpos($this->template,'-->',$p0); |
| 285 | 289 | if ($p === false) {
|
| 286 | 290 | $this->triggerError ("Invalid HTML comment in template at offset $p0.");
|
| 287 | 291 | return false; } |
| 288 | 292 | $p += 3; |
| 289 | 293 | $cmdL = substr($this->template,$p0+4,$p-$p0-7); |
| 290 | - if (!$this->processTemplateCommand($cmdL,$p0,$p,$resumeFromStart)) |
|
| 291 | - return false; |
|
| 292 | - if ($resumeFromStart) $p = $p0; } |
|
| 294 | + if (!$this->processTemplateCommand($cmdL,$p0,$p,$resumeFromStart)) { |
|
| 295 | + return false; |
|
| 296 | + } |
|
| 297 | + if ($resumeFromStart) { |
|
| 298 | + $p = $p0; |
|
| 299 | + } |
|
| 300 | + } |
|
| 293 | 301 | return true; } |
| 294 | 302 | |
| 295 | 303 | /** |
@@ -300,20 +308,25 @@ discard block |
||
| 300 | 308 | $resumeFromStart = false; |
| 301 | 309 | $p = 0; |
| 302 | 310 | $cmd = ''; |
| 303 | - if (!$this->parseWord($cmdL,$p,$cmd)) return true; |
|
| 311 | + if (!$this->parseWord($cmdL,$p,$cmd)) { |
|
| 312 | + return true; |
|
| 313 | + } |
|
| 304 | 314 | $parms = substr($cmdL,$p); |
| 305 | 315 | switch (strtoupper($cmd)) {
|
| 306 | 316 | case '$BEGINBLOCK': |
| 307 | - if (!$this->processBeginBlockCmd($parms,$cmdTPosBegin,$cmdTPosEnd)) |
|
| 308 | - return false; |
|
| 317 | + if (!$this->processBeginBlockCmd($parms,$cmdTPosBegin,$cmdTPosEnd)) { |
|
| 318 | + return false; |
|
| 319 | + } |
|
| 309 | 320 | break; |
| 310 | 321 | case '$ENDBLOCK': |
| 311 | - if (!$this->processEndBlockCmd($parms,$cmdTPosBegin,$cmdTPosEnd)) |
|
| 312 | - return false; |
|
| 322 | + if (!$this->processEndBlockCmd($parms,$cmdTPosBegin,$cmdTPosEnd)) { |
|
| 323 | + return false; |
|
| 324 | + } |
|
| 313 | 325 | break; |
| 314 | 326 | case '$INCLUDE': |
| 315 | - if (!$this->processincludeCmd($parms,$cmdTPosBegin,$cmdTPosEnd)) |
|
| 316 | - return false; |
|
| 327 | + if (!$this->processincludeCmd($parms,$cmdTPosBegin,$cmdTPosEnd)) { |
|
| 328 | + return false; |
|
| 329 | + } |
|
| 317 | 330 | $resumeFromStart = true; |
| 318 | 331 | break; |
| 319 | 332 | default: |
@@ -385,8 +398,9 @@ discard block |
||
| 385 | 398 | $btr =& $this->blockTab[$blockNo]; |
| 386 | 399 | $btr = array(); |
| 387 | 400 | $btr['blockName'] = $blockName; |
| 388 | - if (!$this->lookupBlockName($blockName,$btr['nextWithSameName'])) |
|
| 389 | - $btr['nextWithSameName'] = -1; |
|
| 401 | + if (!$this->lookupBlockName($blockName,$btr['nextWithSameName'])) { |
|
| 402 | + $btr['nextWithSameName'] = -1; |
|
| 403 | + } |
|
| 390 | 404 | $btr['definitionIsOpen'] = true; |
| 391 | 405 | $btr['instances'] = 0; |
| 392 | 406 | $btr['firstBlockInstNo'] = -1; |
@@ -436,7 +450,9 @@ discard block |
||
| 436 | 450 | if (strlen($this->template) > $this->maxInclTemplateSize) {
|
| 437 | 451 | $this->triggerError ("Subtemplate include aborted because the internal template string is longer than $this->maxInclTemplateSize characters.");
|
| 438 | 452 | return false; } |
| 439 | - if (!$this->loadSubtemplate($subtemplateName,$subtemplate)) return false; |
|
| 453 | + if (!$this->loadSubtemplate($subtemplateName,$subtemplate)) { |
|
| 454 | + return false; |
|
| 455 | + } |
|
| 440 | 456 | // (Copying the template to insert a subtemplate is a bit slow. In a future implementation of MiniTemplator, |
| 441 | 457 | // a table could be used that contains references to the string fragments.) |
| 442 | 458 | $this->template = substr($this->template,0,$tPos1) . $subtemplate . substr($this->template,$tPos2); |
@@ -451,7 +467,9 @@ discard block |
||
| 451 | 467 | $p = 0; |
| 452 | 468 | while (true) {
|
| 453 | 469 | $p = strpos($this->template, '${', $p);
|
| 454 | - if ($p === false) break; |
|
| 470 | + if ($p === false) { |
|
| 471 | + break; |
|
| 472 | + } |
|
| 455 | 473 | $p0 = $p; |
| 456 | 474 | $p = strpos($this->template, '}', $p); |
| 457 | 475 | if ($p === false) {
|
@@ -469,8 +487,9 @@ discard block |
||
| 469 | 487 | * @access private |
| 470 | 488 | */ |
| 471 | 489 | function registerVariableReference ($varName, $tPosBegin, $tPosEnd) {
|
| 472 | - if (!$this->lookupVariableName($varName,$varNo)) |
|
| 473 | - $this->registerVariable($varName,$varNo); |
|
| 490 | + if (!$this->lookupVariableName($varName,$varNo)) { |
|
| 491 | + $this->registerVariable($varName,$varNo); |
|
| 492 | + } |
|
| 474 | 493 | $varRefNo = $this->varRefTabCnt++; |
| 475 | 494 | $vrtr =& $this->varRefTab[$varRefNo]; |
| 476 | 495 | $vrtr = array(); |
@@ -510,12 +529,14 @@ discard block |
||
| 510 | 529 | $nextBlockNo += 1; |
| 511 | 530 | continue; }} |
| 512 | 531 | $btr =& $this->blockTab[$activeBlockNo]; |
| 513 | - if ($varRefTPos < $btr['tPosBegin']) |
|
| 514 | - $this->programLogicError(1); |
|
| 532 | + if ($varRefTPos < $btr['tPosBegin']) { |
|
| 533 | + $this->programLogicError(1); |
|
| 534 | + } |
|
| 515 | 535 | $blockVarNo = $btr['blockVarCnt']++; |
| 516 | 536 | $btr['blockVarNoToVarNoMap'][$blockVarNo] = $varNo; |
| 517 | - if ($btr['firstVarRefNo'] == -1) |
|
| 518 | - $btr['firstVarRefNo'] = $varRefNo; |
|
| 537 | + if ($btr['firstVarRefNo'] == -1) { |
|
| 538 | + $btr['firstVarRefNo'] = $varRefNo; |
|
| 539 | + } |
|
| 519 | 540 | $vrtr['blockNo'] = $activeBlockNo; |
| 520 | 541 | $vrtr['blockVarNo'] = $blockVarNo; |
| 521 | 542 | $varRefNo += 1; }} |
@@ -531,8 +552,9 @@ discard block |
||
| 531 | 552 | * @access public |
| 532 | 553 | */ |
| 533 | 554 | function reset() {
|
| 534 | - for ($varNo=0; $varNo<$this->varTabCnt; $varNo++) |
|
| 535 | - $this->varTab[$varNo]['varValue'] = ''; |
|
| 555 | + for ($varNo=0; $varNo<$this->varTabCnt; $varNo++) { |
|
| 556 | + $this->varTab[$varNo]['varValue'] = ''; |
|
| 557 | + } |
|
| 536 | 558 | for ($blockNo=0; $blockNo<$this->blockTabCnt; $blockNo++) {
|
| 537 | 559 | $btr =& $this->blockTab[$blockNo]; |
| 538 | 560 | $btr['instances'] = 0; |
@@ -559,7 +581,9 @@ discard block |
||
| 559 | 581 | function setVariable ($variableName, $variableValue, $isOptional=false) {
|
| 560 | 582 | if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
|
| 561 | 583 | if (!$this->lookupVariableName($variableName,$varNo)) {
|
| 562 | - if ($isOptional) return true; |
|
| 584 | + if ($isOptional) { |
|
| 585 | + return true; |
|
| 586 | + } |
|
| 563 | 587 | $this->triggerError ("Variable \"$variableName\" not defined in template.");
|
| 564 | 588 | return false; } |
| 565 | 589 | $this->varTab[$varNo]['varValue'] = $variableValue; |
@@ -627,20 +651,23 @@ discard block |
||
| 627 | 651 | $btr = & $this->blockTab[$blockNo]; |
| 628 | 652 | $this->registerBlockInstance($blockInstNo); |
| 629 | 653 | $bitr = & $this->blockInstTab[$blockInstNo]; |
| 630 | - if ($btr['firstBlockInstNo'] == -1) |
|
| 631 | - $btr['firstBlockInstNo'] = $blockInstNo; |
|
| 632 | - if ($btr['lastBlockInstNo'] != -1) |
|
| 633 | - $this->blockInstTab[$btr['lastBlockInstNo']]['nextBlockInstNo'] = $blockInstNo; |
|
| 654 | + if ($btr['firstBlockInstNo'] == -1) { |
|
| 655 | + $btr['firstBlockInstNo'] = $blockInstNo; |
|
| 656 | + } |
|
| 657 | + if ($btr['lastBlockInstNo'] != -1) { |
|
| 658 | + $this->blockInstTab[$btr['lastBlockInstNo']]['nextBlockInstNo'] = $blockInstNo; |
|
| 659 | + } |
|
| 634 | 660 | // set forward pointer of chain |
| 635 | 661 | $btr['lastBlockInstNo'] = $blockInstNo; |
| 636 | 662 | $parentBlockNo = $btr['parentBlockNo']; |
| 637 | 663 | $blockVarCnt = $btr['blockVarCnt']; |
| 638 | 664 | $bitr['blockNo'] = $blockNo; |
| 639 | 665 | $bitr['instanceLevel'] = $btr['instances']++; |
| 640 | - if ($parentBlockNo == -1) |
|
| 641 | - $bitr['parentInstLevel'] = -1; |
|
| 642 | - else |
|
| 643 | - $bitr['parentInstLevel'] = $this->blockTab[$parentBlockNo]['instances']; |
|
| 666 | + if ($parentBlockNo == -1) { |
|
| 667 | + $bitr['parentInstLevel'] = -1; |
|
| 668 | + } else { |
|
| 669 | + $bitr['parentInstLevel'] = $this->blockTab[$parentBlockNo]['instances']; |
|
| 670 | + } |
|
| 644 | 671 | $bitr['nextBlockInstNo'] = -1; |
| 645 | 672 | $bitr['blockVarTab'] = array(); |
| 646 | 673 | // copy instance variables for this block |
@@ -687,7 +714,9 @@ discard block |
||
| 687 | 714 | */ |
| 688 | 715 | function generateOutputToFile($fileName) {
|
| 689 | 716 | $fh = fopen($fileName, "wb"); |
| 690 | - if ($fh === false) return false; |
|
| 717 | + if ($fh === false) { |
|
| 718 | + return false; |
|
| 719 | + } |
|
| 691 | 720 | $this->outputMode = 1; |
| 692 | 721 | $this->outputFileHandle = $fh; |
| 693 | 722 | $ok = $this->generateOutputPage(); |
@@ -717,14 +746,18 @@ discard block |
||
| 717 | 746 | */ |
| 718 | 747 | function generateOutputPage() {
|
| 719 | 748 | if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
|
| 720 | - if ($this->blockTab[0]['instances'] == 0) |
|
| 721 | - $this->addBlockByNo (0); // add main block |
|
| 749 | + if ($this->blockTab[0]['instances'] == 0) { |
|
| 750 | + $this->addBlockByNo (0); |
|
| 751 | + } |
|
| 752 | + // add main block |
|
| 722 | 753 | for ($blockNo=0; $blockNo < $this->blockTabCnt; $blockNo++) {
|
| 723 | 754 | $btr =& $this->blockTab[$blockNo]; |
| 724 | 755 | $btr['currBlockInstNo'] = $btr['firstBlockInstNo']; } |
| 725 | 756 | $this->outputError = false; |
| 726 | 757 | $this->writeBlockInstances (0, -1); |
| 727 | - if ($this->outputError) return false; |
|
| 758 | + if ($this->outputError) { |
|
| 759 | + return false; |
|
| 760 | + } |
|
| 728 | 761 | return true; } |
| 729 | 762 | |
| 730 | 763 | /** |
@@ -737,11 +770,16 @@ discard block |
||
| 737 | 770 | $btr =& $this->blockTab[$blockNo]; |
| 738 | 771 | while (!$this->outputError) {
|
| 739 | 772 | $blockInstNo = $btr['currBlockInstNo']; |
| 740 | - if ($blockInstNo == -1) break; |
|
| 773 | + if ($blockInstNo == -1) { |
|
| 774 | + break; |
|
| 775 | + } |
|
| 741 | 776 | $bitr =& $this->blockInstTab[$blockInstNo]; |
| 742 | - if ($bitr['parentInstLevel'] < $parentInstLevel) |
|
| 743 | - $this->programLogicError (2); |
|
| 744 | - if ($bitr['parentInstLevel'] > $parentInstLevel) break; |
|
| 777 | + if ($bitr['parentInstLevel'] < $parentInstLevel) { |
|
| 778 | + $this->programLogicError (2); |
|
| 779 | + } |
|
| 780 | + if ($bitr['parentInstLevel'] > $parentInstLevel) { |
|
| 781 | + break; |
|
| 782 | + } |
|
| 745 | 783 | $this->writeBlockInstance ($blockInstNo); |
| 746 | 784 | $btr['currBlockInstNo'] = $bitr['nextBlockInstNo']; }} |
| 747 | 785 | |
@@ -774,15 +812,17 @@ discard block |
||
| 774 | 812 | if ($subBtr['tPosBegin'] < $tPos2) {
|
| 775 | 813 | $tPos2 = $subBtr['tPosBegin']; |
| 776 | 814 | $kind = 2; }} |
| 777 | - if ($tPos2 > $tPos) |
|
| 778 | - $this->writeString (substr($this->template,$tPos,$tPos2-$tPos)); |
|
| 815 | + if ($tPos2 > $tPos) { |
|
| 816 | + $this->writeString (substr($this->template,$tPos,$tPos2-$tPos)); |
|
| 817 | + } |
|
| 779 | 818 | switch ($kind) {
|
| 780 | 819 | case 0: // end of block |
| 781 | 820 | return; |
| 782 | 821 | case 1: // variable |
| 783 | 822 | $vrtr =& $this->varRefTab[$varRefNo]; |
| 784 | - if ($vrtr['blockNo'] != $blockNo) |
|
| 785 | - $this->programLogicError (4); |
|
| 823 | + if ($vrtr['blockNo'] != $blockNo) { |
|
| 824 | + $this->programLogicError (4); |
|
| 825 | + } |
|
| 786 | 826 | $variableValue = $bitr['blockVarTab'][$vrtr['blockVarNo']]; |
| 787 | 827 | $this->writeString ($variableValue); |
| 788 | 828 | $tPos = $vrtr['tPosEnd']; |
@@ -790,8 +830,9 @@ discard block |
||
| 790 | 830 | break; |
| 791 | 831 | case 2: // sub block |
| 792 | 832 | $subBtr =& $this->blockTab[$subBlockNo]; |
| 793 | - if ($subBtr['parentBlockNo'] != $blockNo) |
|
| 794 | - $this->programLogicError (3); |
|
| 833 | + if ($subBtr['parentBlockNo'] != $blockNo) { |
|
| 834 | + $this->programLogicError (3); |
|
| 835 | + } |
|
| 795 | 836 | $this->writeBlockInstances ($subBlockNo, $bitr['instanceLevel']); // recursive call |
| 796 | 837 | $tPos = $subBtr['tPosEnd']; |
| 797 | 838 | $subBlockNo += 1; |
@@ -801,15 +842,20 @@ discard block |
||
| 801 | 842 | * @access private |
| 802 | 843 | */ |
| 803 | 844 | function writeString($s) {
|
| 804 | - if ($this->outputError) return; |
|
| 845 | + if ($this->outputError) { |
|
| 846 | + return; |
|
| 847 | + } |
|
| 805 | 848 | switch ($this->outputMode) {
|
| 806 | 849 | case 0: // output to PHP output stream |
| 807 | - if (!print($s)) |
|
| 808 | - $this->outputError = true; |
|
| 850 | + if (!print($s)) { |
|
| 851 | + $this->outputError = true; |
|
| 852 | + } |
|
| 809 | 853 | break; |
| 810 | 854 | case 1: // output to file |
| 811 | 855 | $rc = fwrite($this->outputFileHandle, $s); |
| 812 | - if ($rc === false) $this->outputError = true; |
|
| 856 | + if ($rc === false) { |
|
| 857 | + $this->outputError = true; |
|
| 858 | + } |
|
| 813 | 859 | break; |
| 814 | 860 | case 2: // output to string |
| 815 | 861 | $this->outputString .= $s; |
@@ -824,7 +870,9 @@ discard block |
||
| 824 | 870 | */ |
| 825 | 871 | function lookupVariableName($varName, &$varNo) {
|
| 826 | 872 | $x = & $this->varNameToNoMap[strtoupper($varName)]; |
| 827 | - if (!isset($x)) return false; |
|
| 873 | + if (!isset($x)) { |
|
| 874 | + return false; |
|
| 875 | + } |
|
| 828 | 876 | $varNo = $x; |
| 829 | 877 | return true; } |
| 830 | 878 | |
@@ -837,7 +885,9 @@ discard block |
||
| 837 | 885 | */ |
| 838 | 886 | function lookupBlockName($blockName, &$blockNo) {
|
| 839 | 887 | $x = & $this->blockNameToNoMap[strtoupper($blockName)]; |
| 840 | - if (!isset($x)) return false; |
|
| 888 | + if (!isset($x)) { |
|
| 889 | + return false; |
|
| 890 | + } |
|
| 841 | 891 | $blockNo = $x; |
| 842 | 892 | return true; } |
| 843 | 893 | |
@@ -851,15 +901,21 @@ discard block |
||
| 851 | 901 | function readFileIntoString ($fileName, &$s) {
|
| 852 | 902 | if (function_exists('version_compare') && version_compare(phpversion(),"4.3.0",">=")) {
|
| 853 | 903 | $s = file_get_contents($fileName); |
| 854 | - if ($s === false) return false; |
|
| 904 | + if ($s === false) { |
|
| 905 | + return false; |
|
| 906 | + } |
|
| 855 | 907 | return true; } |
| 856 | 908 | $fh = fopen($fileName,"rb"); |
| 857 | - if ($fh === false) return false; |
|
| 909 | + if ($fh === false) { |
|
| 910 | + return false; |
|
| 911 | + } |
|
| 858 | 912 | $fileSize = filesize($fileName); |
| 859 | 913 | if ($fileSize === false) {fclose ($fh); return false; }
|
| 860 | 914 | $s = fread($fh,$fileSize); |
| 861 | 915 | fclose ($fh); |
| 862 | - if (strlen($s) != $fileSize) return false; |
|
| 916 | + if (strlen($s) != $fileSize) { |
|
| 917 | + return false; |
|
| 918 | + } |
|
| 863 | 919 | return true; } |
| 864 | 920 | |
| 865 | 921 | /** |
@@ -887,12 +943,22 @@ discard block |
||
| 887 | 943 | */ |
| 888 | 944 | function parseQuotedString($s, &$p, &$w) {
|
| 889 | 945 | $sLen = strlen($s); |
| 890 | - while ($p < $sLen && ord($s{$p}) <= 32) $p++;
|
|
| 891 | - if ($p >= $sLen) return false; |
|
| 892 | - if (substr($s, $p, 1) != '"') return false; |
|
| 946 | + while ($p < $sLen && ord($s{$p}) <= 32) { |
|
| 947 | + $p++; |
|
| 948 | + } |
|
| 949 | + if ($p >= $sLen) { |
|
| 950 | + return false; |
|
| 951 | + } |
|
| 952 | + if (substr($s, $p, 1) != '"') { |
|
| 953 | + return false; |
|
| 954 | + } |
|
| 893 | 955 | $p++; $p0 = $p; |
| 894 | - while ($p < $sLen && $s{$p} != '"') $p++;
|
|
| 895 | - if ($p >= $sLen) return false; |
|
| 956 | + while ($p < $sLen && $s{$p} != '"') { |
|
| 957 | + $p++; |
|
| 958 | + } |
|
| 959 | + if ($p >= $sLen) { |
|
| 960 | + return false; |
|
| 961 | + } |
|
| 896 | 962 | $w = substr($s, $p0, $p - $p0); |
| 897 | 963 | $p++; |
| 898 | 964 | return true; } |
@@ -903,25 +969,36 @@ discard block |
||
| 903 | 969 | */ |
| 904 | 970 | function parseWordOrQuotedString ($s, &$p, &$w) {
|
| 905 | 971 | $sLen = strlen($s); |
| 906 | - while ($p < $sLen && ord($s{$p}) <= 32) $p++;
|
|
| 907 | - if ($p >= $sLen) return false; |
|
| 908 | - if (substr($s,$p,1) == '"') |
|
| 909 | - return $this->parseQuotedString($s,$p,$w); |
|
| 910 | - else |
|
| 911 | - return $this->parseWord($s,$p,$w); } |
|
| 972 | + while ($p < $sLen && ord($s{$p}) <= 32) { |
|
| 973 | + $p++; |
|
| 974 | + } |
|
| 975 | + if ($p >= $sLen) { |
|
| 976 | + return false; |
|
| 977 | + } |
|
| 978 | + if (substr($s,$p,1) == '"') { |
|
| 979 | + return $this->parseQuotedString($s,$p,$w); |
|
| 980 | + } else { |
|
| 981 | + return $this->parseWord($s,$p,$w); |
|
| 982 | + } |
|
| 983 | + } |
|
| 912 | 984 | |
| 913 | 985 | /** |
| 914 | 986 | * Combine two file system paths. |
| 915 | 987 | * @access private |
| 916 | 988 | */ |
| 917 | 989 | function combineFileSystemPath ($path1, $path2) {
|
| 918 | - if ($path1 == '' || $path2 == '') return $path2; |
|
| 990 | + if ($path1 == '' || $path2 == '') { |
|
| 991 | + return $path2; |
|
| 992 | + } |
|
| 919 | 993 | $s = $path1; |
| 920 | - if (substr($s,-1) != '\\' && substr($s,-1) != '/') $s = $s . "/"; |
|
| 921 | - if (substr($path2,0,1) == '\\' || substr($path2,0,1) == '/') |
|
| 922 | - $s = $s . substr($path2,1); |
|
| 923 | - else |
|
| 924 | - $s = $s . $path2; |
|
| 994 | + if (substr($s,-1) != '\\' && substr($s,-1) != '/') { |
|
| 995 | + $s = $s . "/"; |
|
| 996 | + } |
|
| 997 | + if (substr($path2,0,1) == '\\' || substr($path2,0,1) == '/') { |
|
| 998 | + $s = $s . substr($path2,1); |
|
| 999 | + } else { |
|
| 1000 | + $s = $s . $path2; |
|
| 1001 | + } |
|
| 925 | 1002 | return $s; } |
| 926 | 1003 | |
| 927 | 1004 | /** |
@@ -69,17 +69,17 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | /* not really important, this one; perhaps I could've put it inline with |
| 71 | 71 | * the rest. */ |
| 72 | -function find_match($curlscore,$curcscore,$curgtlang,$langval,$charval, |
|
| 72 | +function find_match($curlscore, $curcscore, $curgtlang, $langval, $charval, |
|
| 73 | 73 | $gtlang) |
| 74 | 74 | { |
| 75 | - if($curlscore < $langval) { |
|
| 76 | - $curlscore=$langval; |
|
| 77 | - $curcscore=$charval; |
|
| 78 | - $curgtlang=$gtlang; |
|
| 75 | + if ($curlscore < $langval) { |
|
| 76 | + $curlscore = $langval; |
|
| 77 | + $curcscore = $charval; |
|
| 78 | + $curgtlang = $gtlang; |
|
| 79 | 79 | } else if ($curlscore == $langval) { |
| 80 | - if($curcscore < $charval) { |
|
| 81 | - $curcscore=$charval; |
|
| 82 | - $curgtlang=$gtlang; |
|
| 80 | + if ($curcscore < $charval) { |
|
| 81 | + $curcscore = $charval; |
|
| 82 | + $curgtlang = $gtlang; |
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | return array($curlscore, $curcscore, $curgtlang); |
@@ -87,22 +87,20 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | function al2gt($gettextlangs, $mime) { |
| 89 | 89 | /* default to "everything is acceptable", as RFC2616 specifies */ |
| 90 | - $acceptLang=(($_SERVER["HTTP_ACCEPT_LANGUAGE"] == '') ? '*' : |
|
| 91 | - $_SERVER["HTTP_ACCEPT_LANGUAGE"]); |
|
| 92 | - $acceptChar=(($_SERVER["HTTP_ACCEPT_CHARSET"] == '') ? '*' : |
|
| 93 | - $_SERVER["HTTP_ACCEPT_CHARSET"]); |
|
| 94 | - $alparts=@preg_split("/,/",$acceptLang); |
|
| 95 | - $acparts=@preg_split("/,/",$acceptChar); |
|
| 90 | + $acceptLang = (($_SERVER["HTTP_ACCEPT_LANGUAGE"] == '') ? '*' : $_SERVER["HTTP_ACCEPT_LANGUAGE"]); |
|
| 91 | + $acceptChar = (($_SERVER["HTTP_ACCEPT_CHARSET"] == '') ? '*' : $_SERVER["HTTP_ACCEPT_CHARSET"]); |
|
| 92 | + $alparts = @preg_split("/,/", $acceptLang); |
|
| 93 | + $acparts = @preg_split("/,/", $acceptChar); |
|
| 96 | 94 | |
| 97 | 95 | /* Parse the contents of the Accept-Language header.*/ |
| 98 | - foreach($alparts as $part) { |
|
| 99 | - $part=trim($part); |
|
| 100 | - if(preg_match("/;/", $part)) { |
|
| 101 | - $lang=@preg_split("/;/",$part); |
|
| 102 | - $score=@preg_split("/=/",$lang[1]); |
|
| 103 | - $alscores[$lang[0]]=$score[1]; |
|
| 96 | + foreach ($alparts as $part) { |
|
| 97 | + $part = trim($part); |
|
| 98 | + if (preg_match("/;/", $part)) { |
|
| 99 | + $lang = @preg_split("/;/", $part); |
|
| 100 | + $score = @preg_split("/=/", $lang[1]); |
|
| 101 | + $alscores[$lang[0]] = $score[1]; |
|
| 104 | 102 | } else { |
| 105 | - $alscores[$part]=1; |
|
| 103 | + $alscores[$part] = 1; |
|
| 106 | 104 | } |
| 107 | 105 | } |
| 108 | 106 | |
@@ -116,20 +114,20 @@ discard block |
||
| 116 | 114 | * Making it 2 for the time being, so that we |
| 117 | 115 | * can distinguish between "not specified" and "specified as 1" later |
| 118 | 116 | * on. */ |
| 119 | - $acscores["ISO-8859-1"]=2; |
|
| 117 | + $acscores["ISO-8859-1"] = 2; |
|
| 120 | 118 | |
| 121 | - foreach($acparts as $part) { |
|
| 122 | - $part=trim($part); |
|
| 123 | - if(preg_match("/;/", $part)) { |
|
| 124 | - $cs=@preg_split("/;/",$part); |
|
| 125 | - $score=@preg_split("/=/",$cs[1]); |
|
| 126 | - $acscores[strtoupper($cs[0])]=$score[1]; |
|
| 119 | + foreach ($acparts as $part) { |
|
| 120 | + $part = trim($part); |
|
| 121 | + if (preg_match("/;/", $part)) { |
|
| 122 | + $cs = @preg_split("/;/", $part); |
|
| 123 | + $score = @preg_split("/=/", $cs[1]); |
|
| 124 | + $acscores[strtoupper($cs[0])] = $score[1]; |
|
| 127 | 125 | } else { |
| 128 | - $acscores[strtoupper($part)]=1; |
|
| 126 | + $acscores[strtoupper($part)] = 1; |
|
| 129 | 127 | } |
| 130 | 128 | } |
| 131 | - if($acscores["ISO-8859-1"]==2) { |
|
| 132 | - $acscores["ISO-8859-1"]=(isset($acscores["*"])?$acscores["*"]:1); |
|
| 129 | + if ($acscores["ISO-8859-1"] == 2) { |
|
| 130 | + $acscores["ISO-8859-1"] = (isset($acscores["*"]) ? $acscores["*"] : 1); |
|
| 133 | 131 | } |
| 134 | 132 | |
| 135 | 133 | /* |
@@ -137,18 +135,18 @@ discard block |
||
| 137 | 135 | * with the highest score, excluding the ones with a charset the user |
| 138 | 136 | * did not include. |
| 139 | 137 | */ |
| 140 | - $curlscore=0; |
|
| 141 | - $curcscore=0; |
|
| 142 | - $curgtlang=NULL; |
|
| 143 | - foreach($gettextlangs as $gtlang) { |
|
| 138 | + $curlscore = 0; |
|
| 139 | + $curcscore = 0; |
|
| 140 | + $curgtlang = NULL; |
|
| 141 | + foreach ($gettextlangs as $gtlang) { |
|
| 144 | 142 | |
| 145 | - $tmp1=preg_replace("/\_/","-",$gtlang); |
|
| 146 | - $tmp2=@preg_split("/\./",$tmp1); |
|
| 147 | - $allang=strtolower($tmp2[0]); |
|
| 148 | - $gtcs=strtoupper($tmp2[1]); |
|
| 149 | - $noct=@preg_split("/-/",$allang); |
|
| 143 | + $tmp1 = preg_replace("/\_/", "-", $gtlang); |
|
| 144 | + $tmp2 = @preg_split("/\./", $tmp1); |
|
| 145 | + $allang = strtolower($tmp2[0]); |
|
| 146 | + $gtcs = strtoupper($tmp2[1]); |
|
| 147 | + $noct = @preg_split("/-/", $allang); |
|
| 150 | 148 | |
| 151 | - $testvals=array( |
|
| 149 | + $testvals = array( |
|
| 152 | 150 | array(@$alscores[$allang], @$acscores[$gtcs]), |
| 153 | 151 | array(@$alscores[$noct[0]], @$acscores[$gtcs]), |
| 154 | 152 | array(@$alscores[$allang], @$acscores["*"]), |
@@ -156,15 +154,15 @@ discard block |
||
| 156 | 154 | array(@$alscores["*"], @$acscores[$gtcs]), |
| 157 | 155 | array(@$alscores["*"], @$acscores["*"])); |
| 158 | 156 | |
| 159 | - $found=FALSE; |
|
| 160 | - foreach($testvals as $tval) { |
|
| 161 | - if(!$found && isset($tval[0]) && isset($tval[1])) { |
|
| 162 | - $arr=find_match($curlscore, $curcscore, $curgtlang, $tval[0], |
|
| 157 | + $found = FALSE; |
|
| 158 | + foreach ($testvals as $tval) { |
|
| 159 | + if (!$found && isset($tval[0]) && isset($tval[1])) { |
|
| 160 | + $arr = find_match($curlscore, $curcscore, $curgtlang, $tval[0], |
|
| 163 | 161 | $tval[1], $gtlang); |
| 164 | - $curlscore=$arr[0]; |
|
| 165 | - $curcscore=$arr[1]; |
|
| 166 | - $curgtlang=$arr[2]; |
|
| 167 | - $found=TRUE; |
|
| 162 | + $curlscore = $arr[0]; |
|
| 163 | + $curcscore = $arr[1]; |
|
| 164 | + $curgtlang = $arr[2]; |
|
| 165 | + $found = TRUE; |
|
| 168 | 166 | } |
| 169 | 167 | } |
| 170 | 168 | } |
@@ -445,10 +445,12 @@ discard block |
||
| 445 | 445 | |
| 446 | 446 | if (!$hide_images) { |
| 447 | 447 | $encsize = ''; |
| 448 | - if ($entry['height'] > 0) |
|
| 449 | - $encsize .= ' height="'.intval($entry['height']).'"'; |
|
| 450 | - if ($entry['width'] > 0) |
|
| 451 | - $encsize .= ' width="'.intval($entry['width']).'"'; |
|
| 448 | + if ($entry['height'] > 0) { |
|
| 449 | + $encsize .= ' height="'.intval($entry['height']).'"'; |
|
| 450 | + } |
|
| 451 | + if ($entry['width'] > 0) { |
|
| 452 | + $encsize .= ' width="'.intval($entry['width']).'"'; |
|
| 453 | + } |
|
| 452 | 454 | $rv .= "<p><img |
| 453 | 455 | alt=\"".htmlspecialchars($entry["filename"])."\" |
| 454 | 456 | src=\"" .htmlspecialchars($entry["url"])."\" |
@@ -480,15 +482,17 @@ discard block |
||
| 480 | 482 | $rv .= "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
| 481 | 483 | |
| 482 | 484 | foreach ($entries as $entry) { |
| 483 | - if ($entry["title"]) |
|
| 484 | - $title = " — ".truncate_string($entry["title"], 30); |
|
| 485 | - else |
|
| 486 | - $title = ""; |
|
| 485 | + if ($entry["title"]) { |
|
| 486 | + $title = " — ".truncate_string($entry["title"], 30); |
|
| 487 | + } else { |
|
| 488 | + $title = ""; |
|
| 489 | + } |
|
| 487 | 490 | |
| 488 | - if ($entry["filename"]) |
|
| 489 | - $filename = truncate_middle(htmlspecialchars($entry["filename"]), 60); |
|
| 490 | - else |
|
| 491 | - $filename = ""; |
|
| 491 | + if ($entry["filename"]) { |
|
| 492 | + $filename = truncate_middle(htmlspecialchars($entry["filename"]), 60); |
|
| 493 | + } else { |
|
| 494 | + $filename = ""; |
|
| 495 | + } |
|
| 492 | 496 | |
| 493 | 497 | $rv .= "<div onclick='popupOpenUrl(\"".htmlspecialchars($entry["url"])."\")' |
| 494 | 498 | dojoType=\"dijit.MenuItem\">".$filename.$title."</div>"; |
@@ -639,10 +643,11 @@ discard block |
||
| 639 | 643 | |
| 640 | 644 | // purge orphaned posts in main content table |
| 641 | 645 | |
| 642 | - if (DB_TYPE == "mysql") |
|
| 643 | - $limit_qpart = "LIMIT 5000"; |
|
| 644 | - else |
|
| 645 | - $limit_qpart = ""; |
|
| 646 | + if (DB_TYPE == "mysql") { |
|
| 647 | + $limit_qpart = "LIMIT 5000"; |
|
| 648 | + } else { |
|
| 649 | + $limit_qpart = ""; |
|
| 650 | + } |
|
| 646 | 651 | |
| 647 | 652 | $pdo = Db::pdo(); |
| 648 | 653 | $res = $pdo->query("DELETE FROM ttrss_entries WHERE |
@@ -196,13 +196,13 @@ |
||
| 196 | 196 | $feed_id = (int) $feed_id; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - $limit = (int)clean($_REQUEST["limit"]); |
|
| 199 | + $limit = (int) clean($_REQUEST["limit"]); |
|
| 200 | 200 | |
| 201 | 201 | if (!$limit || $limit >= 200) { |
| 202 | 202 | $limit = 200; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - $offset = (int)clean($_REQUEST["skip"]); |
|
| 205 | + $offset = (int) clean($_REQUEST["skip"]); |
|
| 206 | 206 | $filter = clean($_REQUEST["filter"]); |
| 207 | 207 | $is_cat = API::param_to_bool(clean($_REQUEST["is_cat"])); |
| 208 | 208 | $show_excerpt = API::param_to_bool(clean($_REQUEST["show_excerpt"])); |
@@ -391,7 +391,7 @@ |
||
| 391 | 391 | list ($og_image, $og_stream) = Article::get_article_image($enclosures, $line['content'], $line["site_url"]); |
| 392 | 392 | |
| 393 | 393 | if ($og_image) { |
| 394 | - $rv .= "<meta property='og:image' content=\"" . htmlspecialchars($og_image) . "\"/>"; |
|
| 394 | + $rv .= "<meta property='og:image' content=\"".htmlspecialchars($og_image)."\"/>"; |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | $rv .= "<body class='flat ttrss_utility ttrss_zoom'>"; |
@@ -26,8 +26,10 @@ |
||
| 26 | 26 | if ($error) { |
| 27 | 27 | foreach (libxml_get_errors() as $error) { |
| 28 | 28 | if ($error->level == LIBXML_ERR_FATAL) { |
| 29 | - if (!isset($this->error)) //currently only the first error is reported |
|
| 29 | + if (!isset($this->error)) { |
|
| 30 | + //currently only the first error is reported |
|
| 30 | 31 | $this->error = $this->format_error($error); |
| 32 | + } |
|
| 31 | 33 | $this->libxml_errors [] = $this->format_error($error); |
| 32 | 34 | } |
| 33 | 35 | } |
@@ -1235,28 +1235,28 @@ |
||
| 1235 | 1235 | |
| 1236 | 1236 | public static function getFeedIcon($id) { |
| 1237 | 1237 | switch ($id) { |
| 1238 | - case 0: |
|
| 1239 | - return "archive"; |
|
| 1240 | - case -1: |
|
| 1241 | - return "star"; |
|
| 1242 | - case -2: |
|
| 1243 | - return "rss_feed"; |
|
| 1244 | - case -3: |
|
| 1245 | - return "whatshot"; |
|
| 1246 | - case -4: |
|
| 1247 | - return "inbox"; |
|
| 1248 | - case -6: |
|
| 1249 | - return "restore"; |
|
| 1250 | - default: |
|
| 1251 | - if ($id < LABEL_BASE_INDEX) { |
|
| 1252 | - return "label"; |
|
| 1253 | - } else { |
|
| 1254 | - $icon = self::getIconFile($id); |
|
| 1238 | + case 0: |
|
| 1239 | + return "archive"; |
|
| 1240 | + case -1: |
|
| 1241 | + return "star"; |
|
| 1242 | + case -2: |
|
| 1243 | + return "rss_feed"; |
|
| 1244 | + case -3: |
|
| 1245 | + return "whatshot"; |
|
| 1246 | + case -4: |
|
| 1247 | + return "inbox"; |
|
| 1248 | + case -6: |
|
| 1249 | + return "restore"; |
|
| 1250 | + default: |
|
| 1251 | + if ($id < LABEL_BASE_INDEX) { |
|
| 1252 | + return "label"; |
|
| 1253 | + } else { |
|
| 1254 | + $icon = self::getIconFile($id); |
|
| 1255 | 1255 | |
| 1256 | - if ($icon && file_exists($icon)) { |
|
| 1257 | - return ICONS_URL . "/" . basename($icon) . "?" . filemtime($icon); |
|
| 1258 | - } |
|
| 1256 | + if ($icon && file_exists($icon)) { |
|
| 1257 | + return ICONS_URL . "/" . basename($icon) . "?" . filemtime($icon); |
|
| 1259 | 1258 | } |
| 1259 | + } |
|
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | 1262 | return false; |
@@ -333,10 +333,10 @@ discard block |
||
| 333 | 333 | if (!get_pref("CDM_EXPANDED")) { |
| 334 | 334 | $line["cdm_excerpt"] = "<span class='collapse'> |
| 335 | 335 | <i class='material-icons' onclick='return Article.cdmUnsetActive(event)' |
| 336 | - title=\"" . __("Collapse article") . "\">remove_circle</i></span>"; |
|
| 336 | + title=\"" . __("Collapse article")."\">remove_circle</i></span>"; |
|
| 337 | 337 | |
| 338 | 338 | if (get_pref('SHOW_CONTENT_PREVIEW')) { |
| 339 | - $line["cdm_excerpt"] .= "<span class='excerpt'>" . $line["content_preview"] . "</span>"; |
|
| 339 | + $line["cdm_excerpt"] .= "<span class='excerpt'>".$line["content_preview"]."</span>"; |
|
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | |
@@ -350,11 +350,11 @@ discard block |
||
| 350 | 350 | $ofgh->execute([$line["orig_feed_id"], $_SESSION['uid']]); |
| 351 | 351 | |
| 352 | 352 | if ($tmp_line = $ofgh->fetch()) { |
| 353 | - $line["orig_feed"] = [ $tmp_line["title"], $tmp_line["site_url"], $tmp_line["feed_url"] ]; |
|
| 353 | + $line["orig_feed"] = [$tmp_line["title"], $tmp_line["site_url"], $tmp_line["feed_url"]]; |
|
| 354 | 354 | } |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - $line["updated_long"] = make_local_datetime($line["updated"],true); |
|
| 357 | + $line["updated_long"] = make_local_datetime($line["updated"], true); |
|
| 358 | 358 | $line["updated"] = make_local_datetime($line["updated"], false, false, false, true); |
| 359 | 359 | |
| 360 | 360 | |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | if (isset($rgba_cache[$feed_id])) { |
| 392 | - $line['feed_bg_color'] = 'rgba(' . implode(",", $rgba_cache[$feed_id]) . ',0.3)'; |
|
| 392 | + $line['feed_bg_color'] = 'rgba('.implode(",", $rgba_cache[$feed_id]).',0.3)'; |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | /* we don't need those */ |
@@ -1254,7 +1254,7 @@ discard block |
||
| 1254 | 1254 | $icon = self::getIconFile($id); |
| 1255 | 1255 | |
| 1256 | 1256 | if ($icon && file_exists($icon)) { |
| 1257 | - return ICONS_URL . "/" . basename($icon) . "?" . filemtime($icon); |
|
| 1257 | + return ICONS_URL."/".basename($icon)."?".filemtime($icon); |
|
| 1258 | 1258 | } |
| 1259 | 1259 | } |
| 1260 | 1260 | } |
@@ -1951,9 +1951,9 @@ discard block |
||
| 1951 | 1951 | } |
| 1952 | 1952 | |
| 1953 | 1953 | function color_of($name) { |
| 1954 | - $colormap = [ "#1cd7d7","#d91111","#1212d7","#8e16e5","#7b7b7b", |
|
| 1955 | - "#39f110","#0bbea6","#ec0e0e","#1534f2","#b9e416", |
|
| 1956 | - "#479af2","#f36b14","#10c7e9","#1e8fe7","#e22727" ]; |
|
| 1954 | + $colormap = ["#1cd7d7", "#d91111", "#1212d7", "#8e16e5", "#7b7b7b", |
|
| 1955 | + "#39f110", "#0bbea6", "#ec0e0e", "#1534f2", "#b9e416", |
|
| 1956 | + "#479af2", "#f36b14", "#10c7e9", "#1e8fe7", "#e22727"]; |
|
| 1957 | 1957 | |
| 1958 | 1958 | $sum = 0; |
| 1959 | 1959 | |
@@ -2260,7 +2260,7 @@ discard block |
||
| 2260 | 2260 | case "title": |
| 2261 | 2261 | if ($commandpair[1]) { |
| 2262 | 2262 | array_push($query_keywords, "($not (LOWER(ttrss_entries.title) LIKE ". |
| 2263 | - $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%') ."))"); |
|
| 2263 | + $pdo->quote('%'.mb_strtolower($commandpair[1]).'%')."))"); |
|
| 2264 | 2264 | } else { |
| 2265 | 2265 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
| 2266 | 2266 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
@@ -2270,7 +2270,7 @@ discard block |
||
| 2270 | 2270 | case "author": |
| 2271 | 2271 | if ($commandpair[1]) { |
| 2272 | 2272 | array_push($query_keywords, "($not (LOWER(author) LIKE ". |
| 2273 | - $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
|
| 2273 | + $pdo->quote('%'.mb_strtolower($commandpair[1]).'%')."))"); |
|
| 2274 | 2274 | } else { |
| 2275 | 2275 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
| 2276 | 2276 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
@@ -2285,7 +2285,7 @@ discard block |
||
| 2285 | 2285 | array_push($query_keywords, "($not (note IS NULL OR note = ''))"); |
| 2286 | 2286 | else |
| 2287 | 2287 | array_push($query_keywords, "($not (LOWER(note) LIKE ". |
| 2288 | - $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
|
| 2288 | + $pdo->quote('%'.mb_strtolower($commandpair[1]).'%')."))"); |
|
| 2289 | 2289 | } else { |
| 2290 | 2290 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
| 2291 | 2291 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
@@ -50,8 +50,9 @@ discard block |
||
| 50 | 50 | $reply .= strip_tags($feed_title); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - if ($error) |
|
| 54 | - $reply .= " <i title=\"".htmlspecialchars($error)."\" class='material-icons icon-error'>error</i>"; |
|
| 53 | + if ($error) { |
|
| 54 | + $reply .= " <i title=\"".htmlspecialchars($error)."\" class='material-icons icon-error'>error</i>"; |
|
| 55 | + } |
|
| 55 | 56 | |
| 56 | 57 | $reply .= "</span>"; |
| 57 | 58 | $reply .= "<span id='feed_current_unread' style='display: none'></span>"; |
@@ -325,10 +326,11 @@ discard block |
||
| 325 | 326 | |
| 326 | 327 | $line['content'] = DiskCache::rewriteUrls($line['content']); |
| 327 | 328 | |
| 328 | - if ($line['note']) |
|
| 329 | - $line['note'] = Article::format_article_note($id, $line['note']); |
|
| 330 | - else |
|
| 331 | - $line['note'] = ""; |
|
| 329 | + if ($line['note']) { |
|
| 330 | + $line['note'] = Article::format_article_note($id, $line['note']); |
|
| 331 | + } else { |
|
| 332 | + $line['note'] = ""; |
|
| 333 | + } |
|
| 332 | 334 | |
| 333 | 335 | if (!get_pref("CDM_EXPANDED")) { |
| 334 | 336 | $line["cdm_excerpt"] = "<span class='collapse'> |
@@ -395,8 +397,9 @@ discard block |
||
| 395 | 397 | /* we don't need those */ |
| 396 | 398 | |
| 397 | 399 | foreach (["date_entered", "guid", "last_published", "last_marked", "tag_cache", "favicon_avg_color", |
| 398 | - "uuid", "label_cache", "yyiw"] as $k) |
|
| 399 | - unset($line[$k]); |
|
| 400 | + "uuid", "label_cache", "yyiw"] as $k) { |
|
| 401 | + unset($line[$k]); |
|
| 402 | + } |
|
| 400 | 403 | |
| 401 | 404 | array_push($reply['content'], $line); |
| 402 | 405 | } |
@@ -1310,13 +1313,17 @@ discard block |
||
| 1310 | 1313 | |
| 1311 | 1314 | public static function getCategoryUnread($cat, $owner_uid = false) { |
| 1312 | 1315 | |
| 1313 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
| 1316 | + if (!$owner_uid) { |
|
| 1317 | + $owner_uid = $_SESSION["uid"]; |
|
| 1318 | + } |
|
| 1314 | 1319 | |
| 1315 | 1320 | $pdo = Db::pdo(); |
| 1316 | 1321 | |
| 1317 | 1322 | if ($cat >= 0) { |
| 1318 | 1323 | |
| 1319 | - if (!$cat) $cat = null; |
|
| 1324 | + if (!$cat) { |
|
| 1325 | + $cat = null; |
|
| 1326 | + } |
|
| 1320 | 1327 | |
| 1321 | 1328 | $sth = $pdo->prepare("SELECT id FROM ttrss_feeds |
| 1322 | 1329 | WHERE (cat_id = :cat OR (:cat IS NULL AND cat_id IS NULL)) |
@@ -2279,56 +2286,68 @@ discard block |
||
| 2279 | 2286 | break; |
| 2280 | 2287 | case "note": |
| 2281 | 2288 | if ($commandpair[1]) { |
| 2282 | - if ($commandpair[1] == "true") |
|
| 2283 | - array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))"); |
|
| 2284 | - else if ($commandpair[1] == "false") |
|
| 2285 | - array_push($query_keywords, "($not (note IS NULL OR note = ''))"); |
|
| 2286 | - else |
|
| 2287 | - array_push($query_keywords, "($not (LOWER(note) LIKE ". |
|
| 2289 | + if ($commandpair[1] == "true") { |
|
| 2290 | + array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))"); |
|
| 2291 | + } else if ($commandpair[1] == "false") { |
|
| 2292 | + array_push($query_keywords, "($not (note IS NULL OR note = ''))"); |
|
| 2293 | + } else { |
|
| 2294 | + array_push($query_keywords, "($not (LOWER(note) LIKE ". |
|
| 2288 | 2295 | $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
| 2296 | + } |
|
| 2289 | 2297 | } else { |
| 2290 | 2298 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
| 2291 | 2299 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
| 2292 | - if (!$not) array_push($search_words, $k); |
|
| 2300 | + if (!$not) { |
|
| 2301 | + array_push($search_words, $k); |
|
| 2302 | + } |
|
| 2293 | 2303 | } |
| 2294 | 2304 | break; |
| 2295 | 2305 | case "star": |
| 2296 | 2306 | |
| 2297 | 2307 | if ($commandpair[1]) { |
| 2298 | - if ($commandpair[1] == "true") |
|
| 2299 | - array_push($query_keywords, "($not (marked = true))"); |
|
| 2300 | - else |
|
| 2301 | - array_push($query_keywords, "($not (marked = false))"); |
|
| 2308 | + if ($commandpair[1] == "true") { |
|
| 2309 | + array_push($query_keywords, "($not (marked = true))"); |
|
| 2310 | + } else { |
|
| 2311 | + array_push($query_keywords, "($not (marked = false))"); |
|
| 2312 | + } |
|
| 2302 | 2313 | } else { |
| 2303 | 2314 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
| 2304 | 2315 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
| 2305 | - if (!$not) array_push($search_words, $k); |
|
| 2316 | + if (!$not) { |
|
| 2317 | + array_push($search_words, $k); |
|
| 2318 | + } |
|
| 2306 | 2319 | } |
| 2307 | 2320 | break; |
| 2308 | 2321 | case "pub": |
| 2309 | 2322 | if ($commandpair[1]) { |
| 2310 | - if ($commandpair[1] == "true") |
|
| 2311 | - array_push($query_keywords, "($not (published = true))"); |
|
| 2312 | - else |
|
| 2313 | - array_push($query_keywords, "($not (published = false))"); |
|
| 2323 | + if ($commandpair[1] == "true") { |
|
| 2324 | + array_push($query_keywords, "($not (published = true))"); |
|
| 2325 | + } else { |
|
| 2326 | + array_push($query_keywords, "($not (published = false))"); |
|
| 2327 | + } |
|
| 2314 | 2328 | |
| 2315 | 2329 | } else { |
| 2316 | 2330 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
| 2317 | 2331 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
| 2318 | - if (!$not) array_push($search_words, $k); |
|
| 2332 | + if (!$not) { |
|
| 2333 | + array_push($search_words, $k); |
|
| 2334 | + } |
|
| 2319 | 2335 | } |
| 2320 | 2336 | break; |
| 2321 | 2337 | case "unread": |
| 2322 | 2338 | if ($commandpair[1]) { |
| 2323 | - if ($commandpair[1] == "true") |
|
| 2324 | - array_push($query_keywords, "($not (unread = true))"); |
|
| 2325 | - else |
|
| 2326 | - array_push($query_keywords, "($not (unread = false))"); |
|
| 2339 | + if ($commandpair[1] == "true") { |
|
| 2340 | + array_push($query_keywords, "($not (unread = true))"); |
|
| 2341 | + } else { |
|
| 2342 | + array_push($query_keywords, "($not (unread = false))"); |
|
| 2343 | + } |
|
| 2327 | 2344 | |
| 2328 | 2345 | } else { |
| 2329 | 2346 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
| 2330 | 2347 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
| 2331 | - if (!$not) array_push($search_words, $k); |
|
| 2348 | + if (!$not) { |
|
| 2349 | + array_push($search_words, $k); |
|
| 2350 | + } |
|
| 2332 | 2351 | } |
| 2333 | 2352 | break; |
| 2334 | 2353 | default: |
@@ -2351,7 +2370,9 @@ discard block |
||
| 2351 | 2370 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
| 2352 | 2371 | } |
| 2353 | 2372 | |
| 2354 | - if (!$not) array_push($search_words, $k); |
|
| 2373 | + if (!$not) { |
|
| 2374 | + array_push($search_words, $k); |
|
| 2375 | + } |
|
| 2355 | 2376 | } |
| 2356 | 2377 | } |
| 2357 | 2378 | } |
@@ -31,18 +31,18 @@ |
||
| 31 | 31 | $this->adapter = new Db_Pgsql(); |
| 32 | 32 | break; |
| 33 | 33 | default: |
| 34 | - die("Unknown DB_TYPE: " . DB_TYPE); |
|
| 34 | + die("Unknown DB_TYPE: ".DB_TYPE); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | if (!$this->adapter) { |
| 38 | - print("Error initializing database adapter for " . DB_TYPE); |
|
| 38 | + print("Error initializing database adapter for ".DB_TYPE); |
|
| 39 | 39 | exit(100); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | $this->link = $this->adapter->connect(DB_HOST, DB_USER, DB_PASS, DB_NAME, defined('DB_PORT') ? DB_PORT : ""); |
| 43 | 43 | |
| 44 | 44 | if (!$this->link) { |
| 45 | - print("Error connecting through adapter: " . $this->adapter->last_error()); |
|
| 45 | + print("Error connecting through adapter: ".$this->adapter->last_error()); |
|
| 46 | 46 | exit(101); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -1072,57 +1072,57 @@ discard block |
||
| 1072 | 1072 | |
| 1073 | 1073 | switch ($k) { |
| 1074 | 1074 | case "title": |
| 1075 | - $qpart = "title = " . $this->pdo->quote($feed_title); |
|
| 1075 | + $qpart = "title = ".$this->pdo->quote($feed_title); |
|
| 1076 | 1076 | break; |
| 1077 | 1077 | |
| 1078 | 1078 | case "feed_url": |
| 1079 | - $qpart = "feed_url = " . $this->pdo->quote($feed_url); |
|
| 1079 | + $qpart = "feed_url = ".$this->pdo->quote($feed_url); |
|
| 1080 | 1080 | break; |
| 1081 | 1081 | |
| 1082 | 1082 | case "update_interval": |
| 1083 | - $qpart = "update_interval = " . $this->pdo->quote($upd_intl); |
|
| 1083 | + $qpart = "update_interval = ".$this->pdo->quote($upd_intl); |
|
| 1084 | 1084 | break; |
| 1085 | 1085 | |
| 1086 | 1086 | case "purge_interval": |
| 1087 | - $qpart = "purge_interval =" . $this->pdo->quote($purge_intl); |
|
| 1087 | + $qpart = "purge_interval =".$this->pdo->quote($purge_intl); |
|
| 1088 | 1088 | break; |
| 1089 | 1089 | |
| 1090 | 1090 | case "auth_login": |
| 1091 | - $qpart = "auth_login = " . $this->pdo->quote($auth_login); |
|
| 1091 | + $qpart = "auth_login = ".$this->pdo->quote($auth_login); |
|
| 1092 | 1092 | break; |
| 1093 | 1093 | |
| 1094 | 1094 | case "auth_pass": |
| 1095 | - $qpart = "auth_pass =" . $this->pdo->quote($auth_pass). ", auth_pass_encrypted = false"; |
|
| 1095 | + $qpart = "auth_pass =".$this->pdo->quote($auth_pass).", auth_pass_encrypted = false"; |
|
| 1096 | 1096 | break; |
| 1097 | 1097 | |
| 1098 | 1098 | case "private": |
| 1099 | - $qpart = "private = " . $this->pdo->quote($private); |
|
| 1099 | + $qpart = "private = ".$this->pdo->quote($private); |
|
| 1100 | 1100 | break; |
| 1101 | 1101 | |
| 1102 | 1102 | case "include_in_digest": |
| 1103 | - $qpart = "include_in_digest = " . $this->pdo->quote($include_in_digest); |
|
| 1103 | + $qpart = "include_in_digest = ".$this->pdo->quote($include_in_digest); |
|
| 1104 | 1104 | break; |
| 1105 | 1105 | |
| 1106 | 1106 | case "always_display_enclosures": |
| 1107 | - $qpart = "always_display_enclosures = " . $this->pdo->quote($always_display_enclosures); |
|
| 1107 | + $qpart = "always_display_enclosures = ".$this->pdo->quote($always_display_enclosures); |
|
| 1108 | 1108 | break; |
| 1109 | 1109 | |
| 1110 | 1110 | case "mark_unread_on_update": |
| 1111 | - $qpart = "mark_unread_on_update = " . $this->pdo->quote($mark_unread_on_update); |
|
| 1111 | + $qpart = "mark_unread_on_update = ".$this->pdo->quote($mark_unread_on_update); |
|
| 1112 | 1112 | break; |
| 1113 | 1113 | |
| 1114 | 1114 | case "cache_images": |
| 1115 | - $qpart = "cache_images = " . $this->pdo->quote($cache_images); |
|
| 1115 | + $qpart = "cache_images = ".$this->pdo->quote($cache_images); |
|
| 1116 | 1116 | break; |
| 1117 | 1117 | |
| 1118 | 1118 | case "hide_images": |
| 1119 | - $qpart = "hide_images = " . $this->pdo->quote($hide_images); |
|
| 1119 | + $qpart = "hide_images = ".$this->pdo->quote($hide_images); |
|
| 1120 | 1120 | break; |
| 1121 | 1121 | |
| 1122 | 1122 | case "cat_id": |
| 1123 | 1123 | if (get_pref('ENABLE_FEED_CATS')) { |
| 1124 | 1124 | if ($cat_id) { |
| 1125 | - $qpart = "cat_id = " . $this->pdo->quote($cat_id); |
|
| 1125 | + $qpart = "cat_id = ".$this->pdo->quote($cat_id); |
|
| 1126 | 1126 | } else { |
| 1127 | 1127 | $qpart = 'cat_id = NULL'; |
| 1128 | 1128 | } |
@@ -1133,7 +1133,7 @@ discard block |
||
| 1133 | 1133 | break; |
| 1134 | 1134 | |
| 1135 | 1135 | case "feed_language": |
| 1136 | - $qpart = "feed_language = " . $this->pdo->quote($feed_language); |
|
| 1136 | + $qpart = "feed_language = ".$this->pdo->quote($feed_language); |
|
| 1137 | 1137 | break; |
| 1138 | 1138 | |
| 1139 | 1139 | } |
@@ -1579,7 +1579,7 @@ discard block |
||
| 1579 | 1579 | |
| 1580 | 1580 | public static function remove_feed($id, $owner_uid) { |
| 1581 | 1581 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_UNSUBSCRIBE_FEED) as $p) { |
| 1582 | - if (! $p->hook_unsubscribe_feed($id, $owner_uid)) { |
|
| 1582 | + if (!$p->hook_unsubscribe_feed($id, $owner_uid)) { |
|
| 1583 | 1583 | user_error("Feed $id (owner: $owner_uid) not removed due to plugin error (HOOK_UNSUBSCRIBE_FEED).", E_USER_WARNING); |
| 1584 | 1584 | return; |
| 1585 | 1585 | } |